|
/***************( D0 h/ }! {2 U$ f6 N0 u7 G IAP程序跳转APP程序# o+ r: ^: e4 i' K #define APPLICATION_ADDRESS (uint32_t)0x080030007 R2 b* t! _" ]- I/ p typedef void (*pFunction)(void);; E# r$ u* M2 C7 e ' v, U" ?$ x5 y 把用户程序写入FLASH地址后执行以下代码 //跳转APP //9 Q! C$ s g5 c, `( v/ _ JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);: s0 u6 `2 F* ]2 ?( H Jump_To_Application = (pFunction) JumpAddress;, Q. b5 T7 o! r% |& G# f; J) A __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);% L# M' K& H+ s5 p Jump_To_Application(); - v/ r% c' y# _. v" h
编译器默认 ***************/- M) _3 ^3 F+ f4 @' r+ d! z ( W) a/ r7 d1 F /**************6 r9 n; H' I3 s" b {: G; Y! L APP程序. J$ [% c) U; N3 G1 s. D #define APPLICATION_ADDRESS ((uint32_t)0x08004400)- t( g; G: O0 }9 K+ ] void IAP_Set(void) {& |* \+ J3 ?8 y/ u8 Q: d7 `) v! C uint32_t i = 0; /* 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" c R3 W* Z2 E1 P& ^ load address 0x08003000) to the base address of the SRAM at 0x20000000. */ for(i = 0; i < 48; i++) { *((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); y3 K- w$ o7 ]2 |5 ? }; n4 w1 I3 E( d# T& G /* Enable the SYSCFG peripheral clock*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 0 b4 k: \% [: f# A4 k; w- Y3 | /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM); % f4 i* M* |4 \+ k- o }
**************/ |
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 ABSOLUTE1 v% V7 U- b! T9 N
__Vectors 0x08002000 Data 4 startup_stm32f030.o(RESET)9 @$ {; ^& O- y' }
__Vectors_End 0x080020b4 Data 0 startup_stm32f030.o(RESET)
应该和型号也有关系吧,是不是按map文件_Vectors_Size 大小来判断更准确呢?
7 u0 E+ ~+ o) [5 r& |
7 j" T. K9 k0 c D5 Q; x& _6 Z% p( q
你看看你map文件里面是多少?, Q: g1 o9 @( t" a" x6 A
我搞错了 不好意思大神,我想问一下stm32f030 iap中配置ram起始地址为ox200000c0是怎么算出来的?
但是我在map里面查看却不是c0- S* {2 f0 W$ L. f$ w
__Vectors_Size 0x000000b4 Number 0 startup_stm32f030.o ABSOLUTE
__Vectors 0x08002000 Data 4 startup_stm32f030.o(RESET)* f; s0 \" A! L# f5 Z
__Vectors_End 0x080020b4 Data 0 startup_stm32f030.o(RESET)
注意在APP开始地方放那一段代码:
uint32_t i = 0;4 g5 z0 f7 b6 q
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/ # S- U1 I1 `3 f: C3 n& ]
/* 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++)
{# E) a* S+ E h' n% k
*((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}
/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 7 y& O/ L3 y1 Z3 Y, o6 K3 R6 [0 y
/* Remap SRAM at 0x00000000 */$ x8 y5 e; g2 ^
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);# K6 u/ r K- l& n' J
# _& W* Q8 p) {" [& U. ^* q
一个STM32F0 的IAP 应用话题
我是用官方的IAP,我明天去公司上传分享
8 _* X5 Q. j" [; {- v; `. ?3 h
IAP升级DEMO
点评
我当时搞IAP也是费了点周折,最后还是搞定,谢谢分享!
呵呵呵