/************************************************************************** * STM32F407ZET6芯片有512K的FLASH,有192K的RAM(128K SRAM和64K CCM) * * Bootloader功能介绍: * 在芯片上电之后,首先运行的是Bootloader,Bootloader引导程序根据Flash上Flag段 * 的数据选择将哪一部分的固件加载到运行区间。 * * BootLoader预留空间为16K ****************************************************************************/ #include "delay.h" #include "string.h" #include "usart1.h" #include "uart5.h" #include "iap.h" #include "led.h" #include "flash.h" #include "ymodem.h" int main(void) { uint32_t handle; uint8_t ret; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);//设置系统中断优先级分组4 delay_init(); usart1_init(); uart5_init(); LED_Init(); display_bootloader_extry_information(); handle = STMFLASH_ReadWord(FLAG_BASE_ADDR); switch(handle) //选择加载那一部分的固件 { case BOOTLOADER_LOAD: //升级段 load_process(); break; case BOOTLOADER_RUN: //运行段 ret= uart_boot_detect(); if(LOCAL_BOOT_NONE == ret) { app_run(); } else { printf("User instuction deteced!\r\n"); uart_boot(); } break; case BOOTLOADER_DEFAULT: default : printf("No valid firmware detected!\r\n"); uart_boot(); break; } while(1) { printf("unreachable!\r\n"); delay_ms(5000); } }