2021-09-15 02:47 AM
I'm trying to use this lines of code:
#define DATA_EEPROM_BASE_ADDRESS = 0x08080000;
const calibration_param_t parameters __attribute__((at(DATA_EEPROM_BASE_ADDRESS)));
but if I check in debug, the constant structure parameters is allocated inside the code flash (at the address 0x0800d4f8).
Should I add something to the linker script for example? in my .ld file I have this memory definition:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
}
Flash ends at 0x08010000, that is lower than 0x08080000..could that be the problem? if yes, how to modify the script?
thank you
Cristiano
2021-09-15 03:40 AM
I have found a solution by myself. I have modified the .ld file in order to add a section:
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 8K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
EEPROM (rx) : ORIGIN = 0x08080000, LENGTH = 2K
}
/* Sections */
SECTIONS
{
[....]
/* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM
/* Added this section */
.dataeeprom :
{
. = ALIGN(4);
_sdataeeprom = .; /* create a global symbol at data start */
*(.dataeeprom) /* .data sections */
*(.dataeeprom*) /* .data* sections */
*(.eeprom) /* .data sections */
*(.eeprom*) /* .data* sections */
. = ALIGN(4);
_edataeeprom = .; /* define a global symbol at data end */
} >EEPROM AT> FLASH
[....]
and defining the constant this way:
const calibration_param_t calibration_parameters __attribute__((section(".eeprom"))) = {
it works...any idea if this is actually ok? I can't understand why I had to add two sections (dataeeprom and eeprom), as using section(".dataeeprom") was not working.
thank you
C.