Using RAM_D3 start as flag for system_bootloader
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
// define the magic number for the bootloader 8 bytes
|
||||
/* USER CODE BEGIN PV */
|
||||
uint8_t gCLS_DEVICE_ADDRESS = 0x11;
|
||||
/* USER CODE END PV */
|
||||
@@ -72,11 +73,13 @@ static void MPU_Config(void);
|
||||
void MX_FREERTOS_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
void ULOG_SendLPUART(ulog_level_t level, char *msg);
|
||||
void JumpToBootloader_system(void);
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
const uint32_t OS_BOOTFLAG_ADDRESS = 0x38000000;
|
||||
const uint32_t OS_BOOTFLAG_MAGIC = 0xDEADBEFF;
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@@ -87,10 +90,24 @@ int main(void)
|
||||
{
|
||||
/* 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 */
|
||||
|
||||
/* Enable I-Cache---------------------------------------------------------*/
|
||||
SCB_EnableICache();
|
||||
//SCB_EnableICache();
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
||||
@@ -286,6 +303,17 @@ void ULOG_SendLPUART(ulog_level_t level, char *msg) {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user