cancel
Showing results for 
Search instead for 
Did you mean: 

Build a .hex file which including the Bootloader

Jayce Cao
Associate II

I am working on an application based on STM32F103 chips.

After build the application, I do full chip erase using ST-LINK Utility and then flash the chip using new .hex file.

I know that STM32 starts executing the code at the address of 0x8000000. However, my main program starts from address of 0x8003000. I thought the stm32 used a space of 0x8000000 ~ 0x8002FFF for Bootloader. Therefore, my application cannot work.

I cannot find any solutions to build a .hex file which including the Bootloader for my application.

Do you guys know any way to build that one?

Thanks and BRs,

10 REPLIES 10

ST doesn't provide that loader.

The .HEX files are of a simple ASCII format​ and can be merged in a text editor. You just have to lose one or two of the non data end record.

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

Actually, I have a Firmware which main program starts from address of 0x8003000 and an .hex file which start from the address of 0x8000000 (it's from former employee).

If I build the application, erase full chips and flash, and then flash to my circuit, it cannot work. However, if I flash the .hex file (older one) and overwrite with new one, it's working. But I want to flash one time without overwrite anything.

How could I fix this problem?

Merge the .HEX files.​

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

Dear Mr. Clive,

Thank you for your response!

Do you know other solutions which can export directly after each build time?

Hex files can be combined, but this is not required. Even bin files can be combined.

You can build bootoader and main app separately, and download separately.

Just do not erase full chip when downloading. Erase only occupied sectors.

-- pa

Keil provides for post-link command execution, you could use that to bind a pair of .HEX or create .BIN image.

I tend to write my own packaging applications, but you could probably use a batch file, script, or tools like SRECORD to generate the required forms.

Creating a C App to merge a .HEX file is a relatively low complexity task.

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

you can merge the two hex files using SRECORD tool.

follow the descripition mentioned in this link

http://www.keil.com/support/docs/2666.htm

@Pavel A.​ : I am sorry but I have to use the erase full chip function. Thank you for your response!

@Community member​ : Thank you for your solution and guide!

@Sivasubramaniyan​ : Thank you for your solution!