Hi,
I already have a Bootloader project and Application project loaded in the flash memory.
The whole system is working, I can use the Bootloader to load a new Application from the USB.
Now, I would like to share data between the Bootloader and the Application.
I am trying to do it using a specific location at the FLASH memory.
-------------------------------------------------------------------------------------------------------------------------------------------
BOOTLOADER:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x003E800
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0030000 /* 192K */
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x0004000 /* 16K */
QSPI_FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x4000000 /* 64M, Change in QSPI section below also */
}
After .text I added:
.text :
{
// Content removed to spare space in the post
} > FLASH = 0xFF
.app_info 0x000DE800:
{
*(.app_info)
} > FLASH
-------------------------------------------------------------------------------------------------------------------------------------------
APPLICATION:
MEMORY
{
FLASH (rx) : ORIGIN = 0x0003E800, LENGTH = 0x00C1800
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0030000 /* 192K */
DATA_FLASH (rx) : ORIGIN = 0x40100000, LENGTH = 0x0004000 /* 16K */
QSPI_FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x4000000 /* 64M, Change in QSPI section below also */
}
After .text I added:
.text :
{
// Content removed to spare space in the post
} > FLASH = 0xFF
.app_info 0x000DE800:
{
*(.app_info)
} > FLASH
-------------------------------------------------------------------------------------------------------------------------------------------
Then,
In the Application code I added:
typedef struct {
u32 magic_word;
} app_info_t;
app_info_t __attribute__((section (".app_info"))) app_info = { .magic_word = 0xAA };
-------------------------------------------------------------------------------------------------------------------------------------------
And in the Bootloader:
typedef struct {
u32 magic_word;
} app_info_t;
#define APP_INFO_ADDR 0x000DE800
const app_info_t * app_info = (app_info_t *)(APP_INFO_ADDR);
Simple test:
// DEBUG
if(app_info->magic_word == 0xAA)
{
while(1);
}
-------------------------------------------------------------------------------------------------------------------------------------------
But when trying to run "if(app_info->magic_word == 0xAA)" the program goes to:
void Default_Handler (void)
{
/** A error has occurred. The user will need to investigate the cause. Common problems are stack corruption
* or use of an invalid pointer.
*/
BSP_CFG_HANDLE_UNRECOVERABLE_ERROR(0);
}
What Am I doing wrong?
Is there a better way to share data between my two projects?