I’m working with an ATmega328P and I wanted to interface with the flash memory writing data to it with the macros provided by avr-libc. This is the memory map for my chip:
I don’t understand where the program code is exactly located when compiled. What I mean is: How can I be sure the address I use in boot_page_fill and boot_page_write is not used for the program code? Do I need to use the “–section-start” linker option to move the program code to a specific location and be sure the flash page I’m going to use doesn’t overwrite that code?
NOTE: The data to write in the flash is unknown at compile time.