Skip to content

Put rodata in flash for devices like AVR128* and AVR64* #931

Description

@sprintersb

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions