需求说明:
需要实现MCU通过BOOT程序启动,加载App主程序。BOOT程序实现程序烧录功能,App实现主程序业务功能。BOOT和App程序均存储在MCU内部Flash里面。
实现原理:
MCU型号:STM32L432RC
存储空间分布:
0x8000000~0x800f000 boot存储区
0x800f000~0x8010000 参数存储区
0x8010000~0x8028000 主程序存储区
0x8028000~0x8040000 备份存储区
核心代码如下:
pFunction Jump_To_Application;
uint32_t JumpAddress;
void JumpToApp(void)
{
/* Check if valid stack address (RAM address) then jump to user application */
if (((*(__IO uint32_t*)APP_FLASH_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
__disable_irq();
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APP_FLASH_ADDRESS + 4);
J