7 Replies Latest reply on Jan 23, 2019 5:36 AM by agba_3844561

    Convert .elf to .img firmware for FX3

    agba_3844561

      I followed the CYUSB3KIT-003 SuperSpeed Explorer Kit User Guide perfectly. I runned the USBBulkSourceSinkLED and was able to see messages on UART, use the JTAG debugger and modifiy the code. However, I want to generate the the img file. I deleted the img files on both the workspace and the original place of the source code to make sure if any img file appears it will be the newly created one.

       

      I followed both: Generate Bootable Image File for FX3 with I2C EEPROM - KBA218344  and FX3 EZ USB Suite cannot generate image file. In the end I even put the exact path like the following picture shows:

      Image1.png

      When I try to compile I get:

       

      ```

      14:24:20 **** Incremental Build of configuration Debug for project USBBulkSourceSinkLED ****

      cs-make all

      Building target: USBBulkSourceSinkLED.elf

      Invoking: ARM Sourcery Windows GCC C Linker

      arm-none-eabi-gcc  ./cyfx_gcc_startup.o ./cyfxbulkdscr.o ./cyfxbulksrcsink.o ./cyfxtx.o    -T"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/common/fx3.ld" -nostartfiles -Wl,-Map,USBBulkSourceSinkLED.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--entry,CyU3PFirmwareEntry "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyfxapi.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyu3lpp.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyu3threadx.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\\arm-none-eabi\lib\libc.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\\lib\gcc\arm-none-eabi\4.8.1\libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"USBBulkSourceSinkLED.elf"

      Finished building target: USBBulkSourceSinkLED.elf

       

      C:/Program Files (x86)/Cypress/EZ-USB FX3 SDK/1.3/ARM GCC/bin/cs-make --no-print-directory post-build

      /usr/bin/sh: -c: line 0: syntax error near unexpected token `('

      /usr/bin/sh: -c: line 0: `C:/Program Files (x86)/Cypress/EZ-USB FX3 SDK/1.3/ARM GCC/bin/cs-make --no-print-directory post-build'

      cs-make: *** [USBBulkSourceSinkLED.elf] Error 1

       

       

      14:24:22 Build Finished (took 1s.843ms)

      ```

       

      So it seams the elf file is being created correctly. However I cannot seem to be able to generate the img file. Same problem with debug or release...

       

      In the end I resigned to using only the elf version and programming the device via EZ-USB (eclipse) but when I hit run I get:

      ```

      Error starting process.

      Cannot run program "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED\Release\USBBulkSourceSinkLED.elf" (in directory "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED"): CreateProcess error=193, %1 is not a valid Win32 application

      Cannot run program "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED\Release\USBBulkSourceSinkLED.elf" (in directory "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED"): CreateProcess error=193, %1 is not a valid Win32 application

      Cannot run program "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED\Release\USBBulkSourceSinkLED.elf" (in directory "C:\Users\<MyUser>\Workspace\USBBulkSourceSinkLED"): CreateProcess error=193, %1 is not a valid Win32 application

      ```

        • 1. Re: Convert .elf to .img firmware for FX3
          YangyangC_06

          Could you please upload your whole project? I could check it for you on my side.

          • 2. Re: Convert .elf to .img firmware for FX3
            agba_3844561

            So here is the project in the Workspace folder. It should be the same as the downloaded in the path `C:\Program Files (x86)\Cypress\SuperSpeed Explorer Kit\1.0\Firmware\USBBulkSourceSinkLED`

             

            I'm using OpenOCD following the instructions on the pfd attached.

            • 3. Re: Convert .elf to .img firmware for FX3
              YangyangC_06

              Hi Agustin,

               

              I could build and generate Img file with your project. I do nothing and only try to build.

              • 4. Re: Convert .elf to .img firmware for FX3
                YangyangC_06

                Here are the outputs from Console window.

                 

                10:09:28 **** Incremental Build of configuration Debug for project USBBulkSourceSinkLED ****

                cs-make all

                'Building file: ../cyfxbulksrcsink.c'

                'Invoking: ARM Sourcery Windows GCC C Compiler'

                arm-none-eabi-gcc -D__CYU3P_TX__=1 -I"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc" -I"..\." -O0 -Wall -Wa,-adhlns="cyfxbulksrcsink.o.lst" -c -fmessage-length=0 -MMD -MP -MF"cyfxbulksrcsink.d" -MT"cyfxbulksrcsink.d" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o "cyfxbulksrcsink.o" "../cyfxbulksrcsink.c"

                ../cyfxbulksrcsink.c: In function 'CyFxBulkSrcSinkApplnUSBSetupCB':

                ../cyfxbulksrcsink.c:429:30: warning: variable 'wLength' set but not used [-Wunused-but-set-variable]

                     uint16_t wValue, wIndex, wLength;

                                              ^

                ../cyfxbulksrcsink.c: In function 'CyFxBulkSrcSinkApplnInit':

                ../cyfxbulksrcsink.c:683:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_DEVICE_DESCR, NULL, (uint8_t *)CyFxUSB30DeviceDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:691:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_DEVICE_DESCR, NULL, (uint8_t *)CyFxUSB20DeviceDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:699:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_BOS_DESCR, NULL, (uint8_t *)CyFxUSBBOSDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:707:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_DEVQUAL_DESCR, NULL, (uint8_t *)CyFxUSBDeviceQualDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:715:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_CONFIG_DESCR, NULL, (uint8_t *)CyFxUSBSSConfigDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:723:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_CONFIG_DESCR, NULL, (uint8_t *)CyFxUSBHSConfigDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                ../cyfxbulksrcsink.c:731:5: warning: passing argument 2 of 'CyU3PUsbSetDesc' makes integer from pointer without a cast [enabled by default]

                     apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_FS_CONFIG_DESCR, NULL, (uint8_t *)CyFxUSBFSConfigDscr);

                     ^

                In file included from ../cyfxbulksrcsink.c:62:0:

                C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\inc/cyu3usb.h:753:1: note: expected 'uint8_t' but argument is of type 'void *'

                CyU3PUsbSetDesc (

                ^

                'Finished building: ../cyfxbulksrcsink.c'

                ' '

                'Building target: USBBulkSourceSinkLED.elf'

                'Invoking: ARM Sourcery Windows GCC C Linker'

                arm-none-eabi-gcc  ./cyfx_gcc_startup.o ./cyfxbulkdscr.o ./cyfxbulksrcsink.o ./cyfxtx.o    -T"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/common/fx3.ld" -nostartfiles -Wl,-Map,USBBulkSourceSinkLED.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--entry,CyU3PFirmwareEntry "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyfxapi.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyu3lpp.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\\firmware\u3p_firmware\lib\fx3_debug\cyu3threadx.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\\arm-none-eabi\lib\libc.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\\lib\gcc\arm-none-eabi\4.8.1\libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"USBBulkSourceSinkLED.elf"

                'Finished building target: USBBulkSourceSinkLED.elf'

                ' '

                cs-make --no-print-directory post-build

                'Converting ELF to image (.img) format'

                "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\util\elf2img\elf2img.exe" -i USBBulkSourceSinkLED.elf -o USBBulkSourceSinkLED.img

                Note: 256 bytes of interrupt vector code have been removed from the image.

                      Use the "-vectorload yes" option to retain this code.

                 

                 

                ' '

                'Invoking: ARM Sourcery Windows GNU Create Listing'

                arm-none-eabi-objdump -h -S USBBulkSourceSinkLED.elf > "USBBulkSourceSinkLED.lst"

                'Finished building: USBBulkSourceSinkLED.lst'

                ' '

                'Invoking: ARM Sourcery Windows GNU Print Size'

                arm-none-eabi-size  --format=berkeley USBBulkSourceSinkLED.elf

                   text    data     bss     dec     hex filename

                124232     692    6336 131260   200bc USBBulkSourceSinkLED.elf

                'Finished building: USBBulkSourceSinkLED.siz'

                ' '

                 

                 

                10:09:35 Build Finished (took 6s.986ms)

                • 5. Re: Convert .elf to .img firmware for FX3
                  agba_3844561

                  I copy pasted the .elf on the same folder the elf2img.exe is and I runned:

                   

                  C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\util\elf2img>elf2img.exe -i USBBulkSourceSinkLED.elf -o USBBulkSourceSinkLED.img

                  Note: 256 bytes of interrupt vector code have been removed from the image.

                        Use the "-vectorload yes" option to retain this code.

                   

                  So it seams to be working. Now I have to know just how to integrate it with EZ-USB. I'll come back when I solve it.

                   

                  Regards.

                  • 6. Re: Convert .elf to .img firmware for FX3
                    KeerthyV_76
                    1 of 1 people found this helpful
                    • 7. Re: Convert .elf to .img firmware for FX3
                      agba_3844561

                      OMG it worked. It's true I have the git in my envs and the fix did work.

                       

                      Thank you a lot!!!