Am 29.06.24 um 19:02 schrieb Levente via Gcc-help:
I'm trying to write some code on an AVR64DD32 CPU that modifies its own
flash content at runtime.
I use the __attribute__((__progmem__)) to specify that my variable shall
be in the flash memory. This works, however it places the default
content into the beginning of the flash right after the interrupt
vectors which belongs to APPCODE space.
The datasheet says that I can't modify APPCODE space from APPCODE, and I
need to put those to APPDATA space. The address of it is defined by a
fuse bytes (in my case it is 0xC000).
So the question is how can I instruct the linker to put my variable to a
specific location in the Flash memory?
Thanks,
Levente
Seems you need a custom linker script.
Maybe what also works in simple cases is to place the object
into an orphan section (a section not mentioned in the ld script)
and then link with -Wl,--section-start,SECNAME=ADDRESS
like outlined in
https://avrdudes.github.io/avr-libc/avr-libc-user-manual-2.2.0/FAQ.html#faq_reloc_code
Johann