Skip to main content
kurta999
Senior
June 6, 2019
Question

How to detect last used address in flash?

  • June 6, 2019
  • 3 replies
  • 1219 views

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!

This topic has been closed for replies.

3 replies

After Forever
Senior III
June 6, 2019

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.

Uwe Bonnes
Chief
June 6, 2019

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.

Tesla DeLorean
Guru
June 6, 2019

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.​

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