How to load flash from .hex file using built-in bootloader. Specifically, where to write the start address?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 4:00 PM
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.)
Solved! Go to Solution.
- Labels:
-
STM32G0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 5:33 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 4:14 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 4:37 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 5:33 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-04 6:03 PM
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.​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-03-05 8:58 AM
Ah yes, thanks. I see the same address as the second 4 bytes.
