cancel
Showing results for 
Search instead for 
Did you mean: 

How to load flash from .hex file using built-in bootloader. Specifically, where to write the start address?

BCoch
Senior

If loading the on-chip flash from a .hex file, the Write Memory command can be used to write the hex file data records. However, what should done with the start address? Where does that get written? (Assumming an STM32G0, in my case.)

1 ACCEPTED SOLUTION

Accepted Solutions
MPatt.11
Associate II

In the HEX files I've used, I've never run across an 05 record. The stack pointer is the first 4 bytes, and the starting address is the next 4 bytes of the data that you are downloading. (Remember, little endian format). Therefore the 05 record wouldn't need to be used.

View solution in original post

5 REPLIES 5
MPatt.11
Associate II

I think you are asking about the start address in flash where the bootloader should start writing the data. The start address is contained in the Intel HEX file. The first line of the HEX file is a type 04 record, which is the extended linear starting address. The type 00 (data) records contain the lower bits of the address. I have found this article on Wikipedia useful in learning how to decode Intel HEX files.

https://en.wikipedia.org/wiki/Intel_HEX

Thanks for the answer. Indeed I found the same Wikipedia article very helpful. I do read and process the type 04 record, using it to modify the type 00 record addresses.

However, my question is regarding the 05 record, which provides the application starting address. Does this also need to be written to a location in flash, or is it already taken care of by the vectors that are presumably part of the rest of the data?

MPatt.11
Associate II

In the HEX files I've used, I've never run across an 05 record. The stack pointer is the first 4 bytes, and the starting address is the next 4 bytes of the data that you are downloading. (Remember, little endian format). Therefore the 05 record wouldn't need to be used.

It is a historic parameter used by debuggers. Here I'd expect it to point to the Reset_Handler where it could place a breakpoint.

With. HEX files the address of the data is inferred directly, unlike a .BIN which is just a blob of data.​

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

Ah yes, thanks. I see the same address as the second 4 bytes.