Skip to content

Instantly share code, notes, and snippets.

@sprintersb
sprintersb / avr-rodata.md
Last active January 28, 2024 16:51
avr-gcc: Locate .rodata in Flash for AVR Devices like AVR64 and AVR128

avr-gcc: Locate .rodata in Flash for AVR Devices like AVR64 and AVR128

Abstract: Modern AVR microcontrollers from families AVR64 and AVR128, like AVR128DA32, map a 32 KiB portion of their flash memory into the RAM address space. This makes it possible to locate read-only data in flash memory, and not in RAM like it is currently the case with GNU Tools for AVR.

Locating .rodata in flash can be done without touching or extending the tools, and by means of the following steps:

  1. Specify the start address of the .rodata segment.
  2. Tell the AVR to use that segment for .rodata.
  3. Locate .rodata in the specified segment.