Hello, i need to place a variable in a non volatile memory I managed to do it with updating linker file, is there any other way that i can do it just changing main.c code? I'm implementing this on ARM-Cortex M0(Nuvoton Microcontroller) and using GCC.
The standard C method to do this would be to use a pointer to the address.
It could also be done by placing the variable in a particular section, then using the linker to place that section at the desired address.
The Arm Compiler toolchain has a special section name that can be used, I'm unsure if gcc supports similar:https://developer.arm.com/documentation/101754/0620/armlink-Reference/Scatter-loading-Features/Root-region-and-the-initial-entry-point/Methods-of-placing-functions-and-data-at-specific-addresses/Placing-a-variable-at-a-specific-address-without-scatter-loading