/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2022-01-19 19813 the first version */ /// /// /// /// /// /// 使用跳转功能前需要设置的几项 /// /// 1. 设置boot loader工程的rom 起始地址不变 大小缩减为给bl预留的大小 /// 设置位置在linkscripts stm32xxxx - > link.lds /// /// 2. 设置bl工程中的烧录方式由auto改为块擦除 选择烧录bin文件 起始位置不变 /// /// 3. 设置app工程中 rom的起始位置为0x08000000 + bl预留空间的大小 设置rom大小为flash大小-bl大小 /// /// 4. 设置app工程中的烧录方式由auto改为块擦除 选择烧录bin文件 起始位置改为0x08000000 + bl预留空间的大小 /// /// 5. 在app工程中libraries\CMSIS\Device\ST\STM32G0xx\Source\Templates\System_stm32xxxx.h中 /// 修改中断向量表的宏定义 VECT_TAB_OFFSET 的值 由默认值0x0U 改为app Rom起始地址 /// 如预留32K给bootloader 则 VECT_TAB_OFFSET 的值设置为0x8000U 即可 /// /// 6. 再BL工程中 #define app_start_addr 修改为 0x08000000 + VECT_TAB_OFFSET ( boot.c ) 同时修改iap.c中的定义 /// /// 7. App工程中 iap.c 和 at_client.c 中 #define 的 App_size 的大小改为app区 的空间大小 /// /// /// /// /// /// #include "boot.h" #include "main.h" #define app_start_addr 0x08008000 void Start_app(void) { rt_kprintf("Go To App --->"); HAL_RCC_DeInit(); SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0; HAL_DeInit(); __set_PRIMASK(1); /* 关闭总中断 */ pFunction Jump_To_Application; __IO uint32_t JumpAddress; /* Test if user code is programmed starting from address "APPLICATION_ADDRESS" */ if (((*(__IO uint32_t *)app_start_addr) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t *)(app_start_addr + 4); Jump_To_Application = (pFunction)JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t *)app_start_addr); Jump_To_Application(); } // else // { // rt_kprintf("Address Err\n"); // } }