Using RAM_D3 start as flag for system_bootloader
This commit is contained in:
@@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
// define the magic number for the bootloader 8 bytes
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
uint8_t gCLS_DEVICE_ADDRESS = 0x11;
|
uint8_t gCLS_DEVICE_ADDRESS = 0x11;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
@@ -72,11 +73,13 @@ static void MPU_Config(void);
|
|||||||
void MX_FREERTOS_Init(void);
|
void MX_FREERTOS_Init(void);
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
void ULOG_SendLPUART(ulog_level_t level, char *msg);
|
void ULOG_SendLPUART(ulog_level_t level, char *msg);
|
||||||
|
void JumpToBootloader_system(void);
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
const uint32_t OS_BOOTFLAG_ADDRESS = 0x38000000;
|
||||||
|
const uint32_t OS_BOOTFLAG_MAGIC = 0xDEADBEFF;
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,10 +90,24 @@ int main(void)
|
|||||||
{
|
{
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
// Check if the bootloader magic number is set at the given address
|
||||||
|
volatile uint32_t * ptr = (uint32_t *)OS_BOOTFLAG_ADDRESS;
|
||||||
|
if (*ptr == OS_BOOTFLAG_MAGIC) {
|
||||||
|
// Jump to the bootloader
|
||||||
|
*ptr = 0;
|
||||||
|
JumpToBootloader_system();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ptr == 0) {
|
||||||
|
*ptr = 2;
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
/* Enable I-Cache---------------------------------------------------------*/
|
/* Enable I-Cache---------------------------------------------------------*/
|
||||||
SCB_EnableICache();
|
//SCB_EnableICache();
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -286,6 +303,17 @@ void ULOG_SendLPUART(ulog_level_t level, char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JumpToBootloader(void)
|
void JumpToBootloader(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Set the magic number to the given address
|
||||||
|
volatile uint32_t * ptr = (uint32_t *)OS_BOOTFLAG_ADDRESS;
|
||||||
|
*ptr = OS_BOOTFLAG_MAGIC;
|
||||||
|
|
||||||
|
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JumpToBootloader_system(void)
|
||||||
{
|
{
|
||||||
#define conBootloadAddress 0x1FF09800
|
#define conBootloadAddress 0x1FF09800
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,9 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
|||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM_EXEC (xrw) : ORIGIN = 0x24000000, LENGTH = 320K
|
RAM_EXEC (xrw) : ORIGIN = 0x24000000, LENGTH = 319K
|
||||||
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
RAM_NOINIT(xrw) : ORIGIN = 0x2404fc00, LENGTH = 1K
|
||||||
|
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 127K
|
||||||
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
|
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
|
||||||
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
|
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
|
||||||
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
|
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
|
||||||
@@ -161,6 +162,12 @@ SECTIONS
|
|||||||
. = ALIGN(8);
|
. = ALIGN(8);
|
||||||
} >DTCMRAM
|
} >DTCMRAM
|
||||||
|
|
||||||
|
|
||||||
|
.noinit :
|
||||||
|
{
|
||||||
|
KEEP(*(.noinitdata))
|
||||||
|
} >DTCMRAM2
|
||||||
|
|
||||||
/* Remove information from the standard libraries */
|
/* Remove information from the standard libraries */
|
||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user