Convert .elf to .img firmware for FX3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
agba_3844561
Level 3
Level 3
5 likes given First like given

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

```

0 Likes
1 Solution
7 Replies
YangyangC_06
Employee
Employee
750 replies posted 500 replies posted 250 replies posted

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

0 Likes
lock attach
Attachments are accessible only for community members.

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.

0 Likes

Hi Agustin,

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

0 Likes

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)

0 Likes

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.

0 Likes

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

Thank you a lot!!!

0 Likes