《an4657-stm32cube_iap_using_uart》
《stm32串列埠iap實驗(戰艦stm32開發板實驗)
《stm32串列埠iap實驗(戰艦stm32開發板實驗)
《mdk stm32啟動檔案的詳細分析(_main,map詳細分析)
《keil .sct分散載入檔案及其應用
平台:stm32f030f4 flash 16k, ram 4k
1. iap公升級流程:
3. iap原始碼和工程配置
主函式如下:
int main(void)
#ifdef flash_update_flag
//讀取是否公升級成功的標誌
iledinit();
ikeyinit();
#else
syscfg_memoryremapconfig(syscfg_memoryremap_flash); //設定成flash啟動
iledinit();
ikeyinit();
#endif
while (1)
if (s_u8keypress == 1)
s_u8keypress = 0;
//防止大小端問題
// s_u32val = 0;
// s_u32val |= (s_u8uartbuff[7] << 24);
// s_u32val |= (s_u8uartbuff[6] << 16);
// s_u32val |= (s_u8uartbuff[5] << 8);
// s_u32val |= (s_u8uartbuff[4] << 0);
while (wlen != sizeof(s_u8uartbuff))
if (sizeof(s_u8uartbuff) - wlen >= 1024)
wtmp = 1024;
else
wtmp = sizeof(s_u8uartbuff) - wlen;
wlen += wtmp;
#ifdef flash_update_flag
nvic_systemreset();
#else
#endif
// led 快速閃爍
iledon();
idelayms(500);
iledoff();
idelayms(500);
exti_deinit(); //關閉外部中斷
syscfg_deinit();
rcc_deinit();
//跳轉到應用程式段
if((s_u32val & 0x2ffe0000) == 0x20000000) //檢查棧頂位址是否合法.
注意:2.如果是通過非重啟的方式回到iap,那麼在執行iap之前,需要設定為flash啟動模式。
iap工程配置:
我這裡分配的是10k的flash空間給iap,這裡最好是配置一下。
int main(void)
iremapirqvector(); //拷貝中斷向量到ram,並設定為ram啟動模式
ikeyinit();
iledinit();
while (1)
if (s_u8keypress == 1)
s_u8keypress = 0;
#ifdef flash_update_flag
//如果通過這種方式,在iap裡面不需要去設定啟動模式
nvic_systemreset();
#else
// 如果通過這種方式去跳轉到iap,在iap裡面一定要設定啟動模式為flash模式
//否則會出現宕機的情況
exti_deinit(); //關閉外部中斷
syscfg_deinit();
rcc_deinit();
#endif
// led慢閃爍
iledon();
idelayms(10000);
iledoff();
idelayms(10000);
#if (defined ( __cc_arm ))
__io uint32_t vectortable[48] __attribute__((at(0x20000000)));
#elif (defined (__iccarm__))
#pragma location = 0x20000000
__no_init __io uint32_t vectortable[48];
#elif defined ( __gnuc__ )
__io uint32_t vectortable[48] __attribute__((section(".ramvectortable")));
#elif defined ( __tasking__ )
__io uint32_t vectortable[48] __at(0x20000000);
#endif
// 重對映中斷向量
static void iremapirqvector(void)
// 中斷向量重對映
unsigned char i = 0;
for(i = 0; i < 48; i++)
/* enable the syscfg peripheral clock*/
rcc_apb2periphclockcmd(rcc_apb2periph_syscfg, enable); //這個一定要有
/* remap sram at 0x00000000 */
syscfg_memoryremapconfig(syscfg_memoryremap_sram); //設定為ram啟動模式
工程配置:
需要勾上use memory layout from target dialog選項,否則會出現..\obj\stm32f030.axf: error: l6985e: unable to automatically place at section main.o(.arm.__at_0x20000000) with required base address 0x20000000. please manually place in the scatter file using the --no_autoat option.
的問題。
STM32F030的IAP應用簡介
可以看到函式用了for迴圈將向量表拷貝到0 x20000000 sram的基位址,即將向量表由flash對映到了sram。所以在mdk裡面設定flash偏移位址的時候,同時要設定sram偏移位址。如下截圖 iap set void 函式 falsh address sram address 0x02...
STM32 IAP公升級工具
1 內部包含了crc mode的檢驗 2 檔案包含了頭尾 長度的資料,確保公升級操作的可靠性 3 win32串列埠查詢功能getseriallist 4 regkey.open hkey local machine,t hardware devicemap serialcomm key read e...
STM32的IAP韌體公升級
an2606 system memory boot mode an3155 usart for bootloader 指令集詳解 an2557 iap using usart 將0x08000000開始的main memory空間劃分為兩部分,其中低位址空間用於儲存iap driver,剩餘空間用於...