I have a an embedded application that uses an STM32 (ARM) micro controller. I am using ARMCC 5.06 to compile source code.
I want to place a few variables at absolute addresses so that I can use a flasher to overwrite those absolute addresses with data (giving each device a unique serial number) during programming.
I want the variables to be initialized to a value of 0 (for easy detection of a device that has not received a serial number).
After reading about the __attribute__((at(address))) feature, I thought it would do exactly what I was looking for.
uint8_t __attribute__((at(0x20000000))) SerialNumber = 0;
Gives me a linker error: Error: L6971E: main.o(.ARM.__AT_0x20000001) type RW incompatible with main.o(.ARM.__AT_0x20000000) type ZI in er RW_IRAM1.
const uint8_t __attribute__((at(0x20000000))) SerialNumber = 0;
Gives me a linker errors: Error: L6985E: Unable to automatically place AT section main.o(.ARM.__AT_0x20000000) with required base address 0x20000000. Please manually place in the scatter file using the --no_autoat option.
uint8_t __attribute__((at(0x20000000))) SerialNumber = 0xFF;
Links successfully and when I view the .map file, the variable is located at 0x20000000. However, it has been initialized to a non-zero value.
I feel like I'm missing something obvious here. Any suggestions?