How can PSoC Creator GCC linker generate binary BIN file?

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

cross mob
MiHo_2283311
Level 1
Level 1

Hi,

 

I'm developing for a 4200M-based target system, and I'm using Creator v4.2 with the ARM GCC 5.4 toolchain.

 

Question: Is there a way to tell the linker to output a flat binary load image instead of hex and elf files?

 

Thanks,

 

Mike Holmes

MPE Design Inc.

0 Likes
1 Solution
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

Capture.PNG

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy" -S -O binary ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01.bin"

 

To generate standard intel hex file instead of cypress hex file, please use script:

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy-O ihex ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01_intel_hex.hex"

 

To generate .s19 file instead of hex file, please use script:

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy" -O srec ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01.s19"

 

To generate bin file use ARM MDK compiler, please use script:

"C:\Keil_v5\ARM\ARMCC\bin\fromelf--bincombined --output=".\CortexM0p\ARM_MDK_Generic\Debug\Design01.bin" ".\CortexM0p\ARM_MDK_Generic\Debug\Design01.elf"

 

 

View solution in original post

0 Likes
3 Replies
dafe_3707916
Level 1
Level 1
First like given

Hi Mike,

You can generate any binary or hex file using objcopy (arm-none-eabi-objcopy in most ARM toolchains used in embedded development).

have a look at the man page for it so you see all the possibilities.

To generate binaries out of elf files comming from the linker:

arm-none-eabi-objcopy -S -O binary final.elf final.bin

Instead of -S you may want to use -R <pattern> or -j <pattern>  to specify what sections do you not want or want included in the binary.

Use --info on its own to see all the formats you can convert from and to (usually ihex, srec, binary, etc).

Regards

0 Likes
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

I have encountered similar problem, my steps are somewhat complicated (not optimized), for reference only.

GCC Compiler

Assuming the current project name is Design01, and the Design01.elf file directory generated by the GCC compiler is

C:\Users\xzng\Desktop\Workspace04\Design01.cydsn\CortexM0p\ARM_GCC_541\Debug

Assuming the arm-none-eabi-objcopy utility file directory for the default GCC compiler is

C:\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\import\gnu\arm\5.4.1\bin>

Then you need to use the following steps to generate BIN file

1 Open the DOS interface with the CMD command.

2 Set the directory where the arm-none-eabi-objcopy tool is located to the current directory. cd C:\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\import\gnu\arm\5.4.1\bin\

3 Enter command arm-none-eabi-objcopy -O binary C:\Users\xzng\Desktop\Workspace04\Design01.cydsn\CortexM0p\ARM_GCC_541\Debug\Design01.elf Design01.bin

4 The generated BIN file is located in the directory C:\Users\xzng\AppData\Local\VirtualStore\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\import\gnu\arm\5.4.1\bin

MDK Compiler

Assuming the current project name is Design01, the Design01.elf file directory generated by the MDK compiler is

C:\Users\xzng\Desktop\Workspace04\Design01.cydsn\CortexM0p\ARM_MDK_Generic\Debug\

Assuming that the formelf tool file directory of the MDK compiler is C:\Keil_v5\ARM\ARMCC\bin\

Then you need to use the following steps to generate BIN files from ELF files in DOS environment.

1 Open the DOS interface with the CMD command.

2 Set the directory where the formelf tool is located to the current directory. cd C:\Keil_v5\ARM\ARMCC\bin\

3. Enter command fromelf --bin --output=Design01.bin C:\Users\xzng\Desktop\Workspace04\Design01.cydsn\CortexM0p\ARM_MDK_Generic\Debug\Design01.elf

4. Enter command fromelf --bincombined --output=Design01.bin C:\Users\xzng\Desktop\Workspace04\Design01.cydsn\CortexM0p\ARM_MDK_Generic\Debug\Design01.elf

Note: The fromelf option --bin generates one binary file for each load region of your application. if one complete binary file is needed, consider using the option --bincombined.

0 Likes
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

Capture.PNG

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy" -S -O binary ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01.bin"

 

To generate standard intel hex file instead of cypress hex file, please use script:

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy-O ihex ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01_intel_hex.hex"

 

To generate .s19 file instead of hex file, please use script:

"C:\Program Files (x86)\Cypress\PSoC Creator\4.4\PSoC Creator\import\gnu\arm\5.4.1\bin\arm-none-eabi-objcopy" -O srec ".\CortexM0p\ARM_GCC_541\Debug\Design01.elf" ".\CortexM0p\ARM_GCC_541\Debug\Design01.s19"

 

To generate bin file use ARM MDK compiler, please use script:

"C:\Keil_v5\ARM\ARMCC\bin\fromelf--bincombined --output=".\CortexM0p\ARM_MDK_Generic\Debug\Design01.bin" ".\CortexM0p\ARM_MDK_Generic\Debug\Design01.elf"

 

 

0 Likes