Put rodata in flash for devices like AVR128* and AVR64* · Issue #931 · avrdudes/avr-libc (original) (raw)

Devices from the AVR64* and AVR128* families see a 32 KiB segment of their program memory in the RAM address space.

The current implementation for avrxmega2 and avrxmega4 locates .rodata in RAM, which is sub-optimal.

Locating rodata in flash for these devices requires changes in Binutlis (PR31124: Adjust ld scripts and add new emulations) in the compiler (chosing the location of .rodata and emulation, provide built-in macros, etc) and in AVR-LibC (setting up the hardware in startup-code).

Question: This issue is basically the question if the AVR-LibC maintainers would support such a feature?

The change is a few lines (5 instructions) in gcrt1.S that are only activated if the respective build-in macro is defined by the compiler. No changes to configure are required. This means the changes can go upstream and are a no-op until avr-gcc implements the required features and attached built-in macros. The configure work (check if Binutils PR31124 is upstream) will be done in the compiler.

The communication beween ld script and startup code is performed by means of new symbols. The task of the startup code is to initialize NVMCTRL_CTRLB.FLMAP which selects the 32 KiB block of flash that's seen in RAM space.