I need to store a constant array in flash memory at a specific location using GCC in my embedded C project. For a uint32_t value, I managed to do it like this, and it works:
const uint32_t __attribute__((section(".metadata.SW_VERSION_VALUE"))) SW_VERSION_VALUE = 11;
Now, I want to allocate space for two arrays in the same metadata section, one after the other, but I’m not sure how to do it correctly. Here is my current linker script snippet:
.metadata :
{
. = ALIGN(4);
KEEP(*(.metadata.METADATA_START_ADDR))
. = ALIGN(4);
FW_SIGNATURE_START = .;
. += 256;
KEEP(*(.metadata.FW_SIGNATURE))
KEEP(*(.metadata.FW_PUBLIC_KEY_SIZE))
. = ALIGN(4);
FW_PUBLIC_KEY_START = .;
. += 128;
KEEP(*(.metadata.FW_PUBLIC_KEY))
. = ALIGN(4);
} >FLASH_METADATA_APP1
And here is my attempt to define arrays in the metadata section:
const uint8_t __attribute__((section(".metadata.FW_SIGNATURE"))) FW_SIGNATURE[256] = { /* values */ };
const uint8_t __attribute__((section(".metadata.FW_PUBLIC_KEY"))) FW_PUBLIC_KEY[128] = { /* values */ };
Is this the correct approach to place these arrays in flash memory one after the other within the specified metadata section?