How to generate srec or bin file in MCUXpresso IDE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to generate srec or bin file in MCUXpresso IDE

Jump to solution
24,306 Views
Lurkersoo
Contributor III

Hello, can you help to check where to set generating srec file or bin file when compiling in MCUXpresso? Thanks!

Best Regards,

Shaowei

Tags (2)
1 Solution
17,584 Views
BlackNight
NXP Employee
NXP Employee

I have posted a document on that topic here:

https://community.nxp.com/docs/DOC-333991 

Erich

View solution in original post

13 Replies
17,586 Views
lpcxpresso_supp
NXP Employee
NXP Employee

In addition to Rob's comments above, I would also suggest that you take a look at the supplied MCUXpresso IDE User Guide - there is a section in the Appendix called "Creating bin and hex files" that goes into details on the various options.

In particular, if you just need a one-off generation, then rather than modifying the post-build steps, you can use Project Explorer right click menu -> Binary Utilities options.

Regards,

MCUXpresso IDE Support

0 Kudos
Reply
15,721 Views
julian123
Contributor I

Hi,

I'm using MCUXpresso IDE V11.2.1 Build 4149 and SDK_2.x_EVK_MIMXRT1064 version 2.8.6.

This is my Post-build steps:
arm-none-eabi-size "${BuildArtifactFileName}"
arm-none-eabi-objcopy -v -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex"
arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"
checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"

I also manually followed the steps in MCUXpresso IDE User Guide to create bin and hex records by using the Binary Utilities.

myproject.axf 'file size' on disk is about 4.42 MB.  For each of the above two approaches/methods, the generated myproject.hex and/or myproject.bin 'file size' on disk is about 1.2 GB.

I'm puzzled why the generated hex or bin files are so large. Please help with what I'm doing incorrectly.

Thanks in advance.

0 Kudos
Reply
15,713 Views
converse
Senior Contributor V

By definition a BIN file contains just data, no address information. If there are holes in the address space, then these are filled with zeroes so that the memory that does exist (beyond the holes) is correctly filled.

Basically, BIN files are only suitable for single contiguous address spaces and not for address spaces with holes. You should instead use a format that contains address information, such as SREC or similar.

0 Kudos
Reply
15,697 Views
julian123
Contributor I

Here is a copy of the MCUXpresso console output:

Memory region         Used Size  Region Size  %age Used
   PROGRAM_FLASH:      493856 B         4 MB     11.77%
        SRAM_ITC:       51600 B       128 KB     39.37%
        SRAM_DTC:       70240 B       128 KB     53.59%
         SRAM_OC:        5624 B       768 KB      0.72%
COLLECT_GCC_OPTIONS='-nostdlib' '-v' '-mcpu=cortex-m7' '-mfpu=fpv5-d16' '-mfloat-abi=hard' '-mthumb' '-T' 'myproject_Debug.ld' '-o' 'myproject.axf' '-march=armv7e-m+fp.dp'
Finished building target: myproject.axf
 
make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "myproject.axf" ; arm-none-eabi-objcopy -v -O ihex "myproject.axf" "myproject.hex" ; arm-none-eabi-objcopy -v -O binary "myproject.axf" "myproject.bin" ; arm-none-eabi-objcopy -v -O srec "myproject.axf" "myproject.s19" ; #checksum -p MIMXRT1064xxxxA -d "myproject.bin"
   text    data     bss     dec     hex filename
 492576   71520   47504  611600   95510 myproject.axf
copy from `myproject.axf' [elf32-littlearm] to `myproject.hex' [ihex]
copy from `myproject.axf' [elf32-littlearm] to `myproject.bin' [binary]
copy from `myproject.axf' [elf32-littlearm] to `myproject.s19' [srec]
 

0 Kudos
Reply
15,685 Views
ErichStyger
Specialist I

The console/command line looks fine.

Can you check if the S19 and iHex really have the right content?

(see https://mcuoneclipse.com/2012/09/27/s-record-intel-hex-and-binary-files/ how they should look like).

Other than that: can you share more, for example your .axf file?

Erich

0 Kudos
Reply
15,660 Views
julian123
Contributor I

Thanks Erich.
It was my bad about the size, bin size throw me off.
Hex and S19 sizes seem to be ok.

0 Kudos
Reply
15,704 Views
julian123
Contributor I

Thanks for your reply Converse.

I tried both hex and s19 formats, same issue.
My axf file is about 4.42 MB but hex, s19 files are about 1.2 GB each.

This is how I generate any of the above two (2) formats:
- Right click on myproject.axf.
- Select Binary Utilities
- Then I select either Create hex or Create S Record.

I'm doing something incorrectly, unfortunately can not figure out what though.
Any help is greatly appreciated.

0 Kudos
Reply
17,585 Views
BlackNight
NXP Employee
NXP Employee

I have posted a document on that topic here:

https://community.nxp.com/docs/DOC-333991 

Erich

17,586 Views
christopher_hes
Contributor I

Is there a way to specify the EOL character?  I am wanting the output to match the format of an output file from Code Warrior that specified the EOL character as DOS(\r\n).

0 Kudos
Reply
17,586 Views
ErichStyger
Specialist I

The IDE uses the GNU objcopy tool (see GNU Binary Utilities  for its command line arguments), and afik there is no option to change the line endings. I believe it is controlled by the host machine. I just checked on my Windows machine and there is \r\n present:

pastedImage_2.png

I hope this helps,

Erich

0 Kudos
Reply
17,586 Views
Anonymous
Deactivated User

in your project properties select the "Build Steps" tab and edit the "Post build steps".

Most likely there is something like:

arm-none-eabi-size "${BuildArtifactFileName}"
# arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"
# checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"

in there. Just remove the "#" in front of the two lines to create a binary file and place the correct checksum in the file.

When you replace the "-O binary" with "-O srec" or "-O ihex" you get the output in motorola S-record or intel Hex format.

Rob

17,586 Views
Lurkersoo
Contributor III

One more question, if I want to specify dedicated data per line in srec format, how to set it.

For example, 32 byts per line or 64 byts per line.

Best Regards,

Shaowei

0 Kudos
Reply
17,586 Views
Anonymous
Deactivated User

Add the option --srec-len 32 or --srec-len 64 tp the options, so the line then reads:

arm-none-eabi-objcopy -v -O srec --srec-len 64 "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"