2019-06-06 02:37 AM
Hi,
I would like to detect last used address in flash to be able to backup the firmware from internal flash memory to external from my bootloader. I know the start address where from start copying data, but don't know the end. I was unable to found a good working solution for detecting firmware "latest address" in flash. I tried to look after something to create custom linker script section at end of the flash with special data but I was unable to do it. My temponary solution currently is splitting the internal flash into two parts, use the first one for actual firmware and second for backup, which I don't want to use anymore since it's not effective.
Could somebody help with this? Thanks!
2019-06-06 02:52 AM
Use the symbols defined in the linker script - like "_etext" or "_edata". You can also define your own symbol there in the end of the last section which goes into flash, then use the symbol in your code with extern.
2019-06-06 03:06 AM
A pragmatic approach would be: Scan from Flash end to the first non-erased flash cell. But using linker variables is the right way to go.
2019-06-06 04:47 AM
The linker frequently generates symbolic information the program itself can use. For external applications these symbols can be stored in unused vector table locations, and recovered from there.