cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate unified hex file of Bootloader and Application Project

TShet.2
Associate III

Hello,

 

I have a Bootloader and Application Project using STM32F030CCT6TR controller with 256KB flash.

I am using 32KB for Bootloader starting from 0x8000000 address and Application of 220KB from 0x8008000 address.

Can I generate a unified hex file to program controller with Both the Project with their respective addresses in STM32CubeIDE.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Semer CHERNI
ST Employee

Hello @TShet.2 

First let me thank you for posting.

ARM provide an utility to merge hex files you can check it from ARM web site.

If you could run this command line successfully, you can make an automatic generation by adding it to the build configuration : Post build command.

SemerCHERNI_0-1699019985946.png

BR,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5

If you can use an editor or write an AWK script, or a basic C program app on the host system, you can probably just merge the two, striping the terminating line on the first, and appending the second file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Semer CHERNI
ST Employee

Hello @TShet.2 

First let me thank you for posting.

ARM provide an utility to merge hex files you can check it from ARM web site.

If you could run this command line successfully, you can make an automatic generation by adding it to the build configuration : Post build command.

SemerCHERNI_0-1699019985946.png

BR,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Yes, they are point to SRecords, a HEX file tool. But in all honesty the formats are pretty trivial. It's the terminal record in the Intel HEX format that you need to remove when concatenating files.

Do it once, or twice, in an editor to understand the mechanics, and then automate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief II

STMCubeIDE is multiproject Eclipse envi , then you have one project for bootloader in same workspace next project app. What you setup into build or run sequence result to create one hex for every project or more hex based on scripting etc. 

krotti42
Associate II

As alternative to external tools, is to write a top level linker script and let GCC (linker) do this job.

 

This linker script is from one of my projects, but for a AVR MCU. But with some modifications, it should also work on STM32 devices:

top.ld:

OUTPUT_FORMAT(elf32-avr)
OUTPUT_ARCH(avr51)

MEMORY {
    FLASH_APP   (rx) : ORIGIN = 0x00000000, LENGTH = 120K
    FLASH_BOOT  (rx) : ORIGIN = 0x0001E000, LENGTH = 8K
    SRAM        (rw) : ORIGIN = 0x00800100, LENGTH = 16K
}

SECTIONS {
    .bootldr : {
        bootldr.o
    } > FLASH_BOOT
    
    .application : {
        application.o
    } > FLASH_APP
}

 Then invoke GCC with the the (modified) linker script:

$ arm-none-eabi-gcc -o out.elf -T top.ld bootldr.o application.o

 (You can also link ELF executables directly, but you might get a warning from the linker, that the symbol _start occurs twice.)

After that simple use objcopy, to get the hex file:

 

$ arm-none-eabi-objopy -I elf32-littlearm -O ihex out.elf out.hex