Skip to content

Commit

Permalink
[Fix] Bootloader NUCLEO-L0 vector in ram rsvd
Browse files Browse the repository at this point in the history
  • Loading branch information
BiliouriV authored and JeromeGalan committed Nov 10, 2022
1 parent 027abd4 commit 38e2590
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
22 changes: 20 additions & 2 deletions engine/HAL/STM32L0/luos_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/*******************************************************************************
* Variables
******************************************************************************/
#define RSVD_SECTION ".rsvd.data,\"aw\",%nobits//"
#define _RSVD __attribute__((used, section(RSVD_SECTION)))
// timestamp variable
static ll_timestamp_t ll_timestamp;
/*******************************************************************************
Expand Down Expand Up @@ -77,7 +79,23 @@ static void LuosHAL_SystickInit(void)
******************************************************************************/
static void LuosHAL_VectorTableRemap(void)
{
SCB->VTOR = LUOS_VECT_TAB;
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x0800C800) to the base address of the SRAM at 0x20000000. */
// check if we are at the beginning of flash
if (LUOS_VECT_TAB > FLASH_BASE)
{
static volatile _RSVD uint32_t VectorTable[48];

for (uint32_t i = 0; i < 48; i++)
{
VectorTable[i] = *(__IO uint32_t *)(LUOS_VECT_TAB + (i << 2));
}

/* Enable the SYSCFG peripheral clock*/
__HAL_RCC_SYSCFG_CLK_ENABLE();
/* Remap SRAM at 0x00000000 */
__HAL_SYSCFG_REMAPMEMORY_SRAM();
}
}
/******************************************************************************
* @brief Luos HAL general systick tick at 1ms
Expand Down Expand Up @@ -307,7 +325,7 @@ void LuosHAL_EraseMemory(uint32_t address, uint16_t size)

/******************************************************************************
* @brief Programm flash memory
* @param address : Start address
* @param address : Start address
* @param size :: Data size
* @param data : Pointer to data
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
RAM_RSVD (xrw) : ORIGIN = 0x20000000, LENGTH = 1K
RAM (xrw) : ORIGIN = 0x20000400, LENGTH = 19K
FLASH (rx) : ORIGIN = 0x800C800, LENGTH = 142K
}

Expand Down Expand Up @@ -174,6 +175,12 @@ SECTIONS
. = ALIGN(8);
} >RAM

.boot_data :
{
*(.rsvd.data)
*(.rsvd.data*)
} > RAM_RSVD

/* Remove information from the compiler libraries */
/DISCARD/ :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
RAM_RSVD (xrw) : ORIGIN = 0x20000000, LENGTH = 1K
RAM (xrw) : ORIGIN = 0x20000400, LENGTH = 19K
FLASH (rx) : ORIGIN = 0x800C800, LENGTH = 142K
}

Expand Down Expand Up @@ -174,6 +175,12 @@ SECTIONS
. = ALIGN(8);
} >RAM

.boot_data :
{
*(.rsvd.data)
*(.rsvd.data*)
} > RAM_RSVD

/* Remove information from the compiler libraries */
/DISCARD/ :
{
Expand Down

0 comments on commit 38e2590

Please sign in to comment.