11 Replies Latest reply on Jul 17, 2012 8:33 AM by danilo.tromp

    firmware download in RAM for FX3

    user_16672

      How to create the .img file to download the FX3 firmware through the USB interface (CyControl.exe) in RAM ?

         

      Best Regards,

        • 1. Re: firmware download in RAM for FX3
          christian.richter

          You can find the ELF to IMG conversion tool in C:\Cypress\FX3 SDK\util\elf2img.

             

          I put this in the Eclipse Post Build Step: elf2img.exe -i "${BuildArtifactFileName}" -o "${BuildArtifactFileBaseName}.img"

             

          For this you have to set the PATH variable in Windows correctly.

          • 2. Re: firmware download in RAM for FX3
            user_16672

            Hi,

               

            Since which version is this util (elf2img) present ?

               

            I've been currently using a 321 version and it was not present.

               

            I've downloaded a 384 version (of FX3 SDK only, not Eclipse nor GCC toolchain) but it is still not present.

               

            Best Regards.

            • 3. Re: firmware download in RAM for FX3
              user_16672

              Ok it is present, but there was a bad installation because I selected a different directory than "c:\cypress\fx3 sdk" as root.

                 

              Sorry.

                 

              Best Regards,

              • 4. Re: firmware download in RAM for FX3
                user_16672

                Ok It seems to work. 2 additionnal questions :

                   

                is the .img file created with these options directly downloadable into RAM via USB interface ?

                   

                what are the options to create a SPI bootable file ?

                   

                Thank you for your help,

                   

                Best Regards.

                   

                D.

                • 5. Re: firmware download in RAM for FX3
                  content.librarian

                  1) what are the options to create a SPI bootable file ?

                     

                  Please check following Applucation Note for details - AN70193 - EZ-USB® FX3 SPI Boot Option.

                     

                  You can use the same utility to create the image by just choose an appropriate EEPROM Control byte.

                     

                   

                     

                  2) is the .img file created with these options directly downloadable into RAM via USB interface ?

                     

                  The Image generated will have following 8 bytes as header:

                     

                  'C' ,'Y',0xXX, 0xXX                             //CY Signature followed by 2 dummy bytes

                     

                  4bytes of  'length' of image section                   //get length

                     

                  4bytes of start 'address' in RAM            //get address

                     

                  Next byte is start of Image section.

                     

                  So after this you can use vendor command 0xA0 and the image can be downloaded to RAM in chunks of 4Kbytes. Each section is terminated by 4bytes of zeroes. 0x0000_0000.

                     

                  And all new sections start with 4bytes length and 4bytes address followed by Image.

                     

                  Thanks,

                     

                  Shruti

                  • 6. Re: firmware download in RAM for FX3
                    content.librarian

                    Correction: Image generated has 12 bytes of header.

                    • 7. Re: firmware download in RAM for FX3
                      wheatley.glados

                       You said there are 4 bytes of zeros at the end of every section.

                         

                       

                         

                      Can you explain this in more detail?  Are these bytes just padding?  Are they included in the size calculations for each section?

                         

                       

                         

                      Also, the elf2img tool, distributed with the SDK, does _not_ have 4 bytes of zero padding in the *.img output.  Is there a reason for this?

                      • 8. Re: firmware download in RAM for FX3
                        content.librarian

                        Sorry for the confusion.

                           

                        After end of the last section next 4 bytes are 0x0000_0000. This indicated image termination. After that next 4 bytes are address you want PC to jump to after download complete.

                           

                        And after that last 4 bytes of image are checksum bytes.

                           

                        Any data after that is ignored.

                        • 9. Re: firmware download in RAM for FX3
                          wheatley.glados

                           Thank you so much for responding!  You are being very helpful.

                             

                           

                             

                          Okay, so, just to make sure I understand this:

                             

                          1) Image Header:

                             

                          C, Y, 0xXX, 0xXX

                             

                          <4 bytes length of image>

                             

                          <4 bytes start address in RAM>

                             

                          Push the image header using the command 0xA0.

                             

                           

                             

                          2) Each section of 4Kb chunks:

                             

                          <4 bytes section length>

                             

                          <4 bytes start address>

                             

                          <image data of the length specified above>

                             

                          Push all of the sections using the command 0xA0.

                             

                           

                             

                          3) Image termination:

                             

                          0x0000_0000,

                             

                          <4 bytes address to jump to>

                             

                          <checksum of image>

                             

                          Push image termination sequence using 0xA0.

                             

                           

                             

                          My last question is what other fields do we need to use for the vendor command 0xA0?  For example, in the FX2, you would need to tell the CPU to reset by pushing: <0xA0, 0xE600, 0x0000, 0x1, 1>.  Each section you pushed then looked like:

                             

                          <0xA0, address, index (unused?), data, length>

                             

                          Since the FX3 has 32 bit addressing, how do we do this?  For example, in order to write the image header, what does it look like?

                          • 10. Re: firmware download in RAM for FX3
                            zafrir.patt

                             The firmware (.img) is downloaded to FX3 RAM using the Control Center --> Program --> FX3 --> RAM and selecting the .img file.

                               

                            My question is: How can I do it programmatically from C/C++ promgram ?

                               

                            Is there an API that do the above operation done by the Control Center GUI?

                               

                            Thanks,

                               

                            Zafrir Patt

                            • 11. Re: firmware download in RAM for FX3
                              christian.richter

                              The firmware download is included in the CyUSB3 API. Without the API you can download the new firmware by every driver/API you want (WinUSB, LibUSB) using the control transfers as described above.

                              • 12. Re: firmware download in RAM for FX3
                                danilo.tromp

                                Hi Everybody,

                                   

                                I just studied this topic, and it may be helpfull to others that there is pseudocode in

                                   

                                AN73150: Booting EZ-USB® FX3 over High-Speed USB

                                   

                                Further you may test your firmware uploader using the firmware example in

                                   

                                C:\Cypress\EZ-USB FX3 SDK\1.1\firmware\boot_fw

                                   

                                It worked for me