STM32H7A3 HAL_FLASH_Program() data and address alignment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-19 2:49 AM
Hello There,
I'm working on an IAP application based on STM32H7A3 and have a query related to code alignment.
Correct me if I'm wrong, as per my understanding HAL_FLASH_Program() in H7A3 writes a flash word (i,e., 16 Bytes) at a time. If so, then it must need data to be a multiple of 16.
Then also for an IAP, the target bin should also be 16 byte aligned? If yes, then how to make it correctly.
Regards,
Keshav Aggarwal
- Labels:
-
Flash
-
STM32H7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-19 4:02 AM
Shouldn't be hard to align a .BIN, start with how you build it with the Linker.
Pad the file with void bytes to get the desired lengths.
For .HEX there's the potential to output short or misaligned lines of data, you might have to buffer and process multiple lines, and their might be voids you need to fill with padding bytes.​
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
‎2023-05-19 5:21 AM
I'm using .bin,
You mean manually adding 0x00 as required to the last byte of bin to be aligned with 16 Bytes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-19 6:19 AM
​
The flash program unit in STM32H7 is multiple of 32-bit words.
For STM32H7A: 4 32-bit words (16 bytes).
This is both the program unit size and required alignment.
The MCU itself cannot move 16 bytes at once, so it writes 4 32-bit words into successive addresses.
After the 4th write, programming of the whole 16-byte unit starts automatically.
So yes, the size must be multiple of 16 bytes.
​
You don't have to pad the image file to 16 bytes, the padding can be added by the updater program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-19 6:25 AM
Or 0xFF, to attain the desired lengths/widths
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
‎2023-05-22 3:13 AM
Thanks for replying!
You don't have to pad the image file to 16 bytes, the padding can be added by the updater program.
How can it be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-22 3:13 AM
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-22 3:19 AM
Check linker script alignment directives.
Do some simple STDIO file manipulation in C if you have too.​
Up vote any posts that you find helpful, it shows what's working..
