|
/*************** IAP程序跳转APP程序' T. ^) O# x; l+ v #define APPLICATION_ADDRESS (uint32_t)0x08003000 c8 G8 V! b D! v typedef void (*pFunction)(void);" H! g( d0 [- z 6 z2 u }* J* E% s 把用户程序写入FLASH地址后执行以下代码' N& e+ U" _" y4 m b //跳转APP //) l6 y% K6 d$ y' D6 W# O! V% i+ H JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4); a1 j( f; j2 D" n; u* U Jump_To_Application = (pFunction) JumpAddress;! R2 N) Z( l4 ? ?. G __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS); Jump_To_Application();
编译器默认8 M- f! F8 W: e$ e2 J) d5 B# t ***************/ " `, i! C K' e; ?" Y8 V$ J /**************, D4 s& w- O4 M0 Z: T4 p( ^- _- `, B APP程序* [1 K8 `1 `# {3 ^ #define APPLICATION_ADDRESS ((uint32_t)0x08004400): E: t( w9 R: F& M1 |/ m1 W& i5 u void IAP_Set(void)8 ^. E# Q) G- r/ y' d { uint32_t i = 0; /* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/ 7 p& v3 b3 l; O: j /* Copy the vector table from the Flash (mapped at the base of the application load address 0x08003000) to the base address of the SRAM at 0x20000000. */ 5 U) u% z4 Y' A3 f9 w4 l: G1 ^, O for(i = 0; i < 48; i++) { *((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); }" Y- F7 u; M2 H /* Enable the SYSCFG peripheral clock*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 2 @/ P; U* J' z/ ]0 K6 P& g' h' f+ f /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);1 t. L# {+ _# { }) o2 E r! g; l/ m ~' c! ?
**************/9 _, r3 b3 x4 d, ~! d |
DMA 原理从 0 到 1:为什么它能解放 CPU?一文讲透 DMA 的工作流程
小白也能明白的STM32的低功耗与唤醒机制
STM32系统中2种数据掉电保护的方法
分享STM32F051中文参考手册(重制书签版)
AI工具训练营-用ChatGPT解决HID Keyboard实现的问题
STM32固件库分享,超全系列整理
STM32小白入门指南:从基础到OTA实现方案
STM32超详细学习笔记
新手必看!STM32单片机应该怎么学?
如果你解决了这些问题,就可以直接学STM32
微信公众号
手机版
对是的,这些我也懂,但是map文件里面_Vectors_Size 0x000000b4 Number 0 startup_stm32f030.o ABSOLUTE+ s Z+ N& N8 ~) g
__Vectors 0x08002000 Data 4 startup_stm32f030.o(RESET)
__Vectors_End 0x080020b4 Data 0 startup_stm32f030.o(RESET) r7 K s# R% J% i @/ s; ]+ U) n
应该和型号也有关系吧,是不是按map文件_Vectors_Size 大小来判断更准确呢?
1 `% Y4 z% g& w0 n7 L! Y9 n& n& [7 V
, S( O3 Y; }2 v1 E
你看看你map文件里面是多少?: q. A! D- h9 |) b* \* t, f
我搞错了 不好意思大神,我想问一下stm32f030 iap中配置ram起始地址为ox200000c0是怎么算出来的?4 U/ z% j( s' A: E. t) V
但是我在map里面查看却不是c0" Q4 j9 y1 S' q
__Vectors_Size 0x000000b4 Number 0 startup_stm32f030.o ABSOLUTE
__Vectors 0x08002000 Data 4 startup_stm32f030.o(RESET)9 z% X0 K8 H9 ^# |- W: q0 o" W
__Vectors_End 0x080020b4 Data 0 startup_stm32f030.o(RESET)5 f( ?* a1 ^1 V7 t2 n
注意在APP开始地方放那一段代码:( J* D9 K6 O6 v. P5 d
uint32_t i = 0;3 t& U+ V: g8 K
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x08003000) to the base address of the SRAM at 0x20000000. */
for(i = 0; i < 48; i++)
{( x( |' S4 P+ H
*((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));% a' \! ~; E# n' a
}
/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 6 q* n9 O# X$ E- F$ |
/* Remap SRAM at 0x00000000 */+ F0 ^1 d. F. y
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);$ l6 e% a# \$ {9 }
一个STM32F0 的IAP 应用话题
我是用官方的IAP,我明天去公司上传分享
IAP升级DEMO6 o: i; u6 z- L" N! I/ u$ T; A
点评
我当时搞IAP也是费了点周折,最后还是搞定,谢谢分享!
呵呵呵