链接被吞,简述一下,在SRAM中运行flash解锁程序:
1,BOOT0、BOO1全部接1;
2,MDK新建工程,main.c如下
#include "hk32f10x.h"
#include "hk32f10x_flash.h"
int main(void)
{
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
FLASH_Unlock();//unlock flash
FLASH_ReadOutProtection(DISABLE);//unlock protection
while(1) {;}
return 0;
}
3,MDK options选项中设置
Target页: IROM1 Start:0x20000000 Size:0x4000 ;IRAM1 Start:0x20004000 Size:0x1000
C/C++页:Preprocessors Symbols define:HK32F103RBXX,VECT_TAB_SRAM
Linker页:R/O base:0x20000000 R/W base:0x20004000
Debug页:取消Load Application at Startup
Utilities页:取消选择Update Target before Debugging
点setting,在Flash Download页选择Do not Erase,填写 RAM for Algorithm Start:0x20004000 Size:0x1000 ,Programming Algorithm Start:0x20000000 Size:0x4000 ,点ok返回Utilities页,
新建一个runinsram.ini文件,Utilities页面中Init file选择runinsram.ini,
runinsram.ini文件内容如下:
FUNC void Setup (void) {
SP = _RDWORD(0x20000000); // Setup Stack Pointer
PC = _RDWORD(0x20000004); // Setup Program Counter
_WDWORD(0xE000ED08, 0x20000000); // Setup Vector Table
}
LOAD ARMBlinky.axf INCREMENTAL // Download
Setup(); // Setup for Running
g, main
4,Build 工程后调试运行
|