目前需要做STM8L151G6的串口升级,flash工32K,boot分2K,应用程序(run_APP)占15K,升级程序(isp_APP)15K。正常情况下运行run_APP,与升级命令时通过串口接收数据并存放于isp_APP区域,接收成功后复位到boot,它将isp_APP的数据搬到run_APP中并运行。之前做过
STM32和430的程序,总以为差不多,不过调试了两周多了,总是找不到问题。使用了IAR 1.41.1.boot的icf文件:
define memory with size = 16M;
define region
tinyData = [from 0x00 to 0xFF];
define region NearData = [from 0x0000 to 0x07FF];
define region Eeprom = [from 0x1000 to 0x13FF];
define region BootROM = [from 0x6000 to 0x67FF];
define region NearFuncCode = [from 0x8000 to 0x87FF];
define region FarFuncCode = [from 0x8000 to 0x87FF];
define region HugeFuncCode = [from 0x8000 to 0x87FF];
run_APP的icf文件:
define memory with size = 16M;
define region TinyData = [from 0x00 to 0xFF];
define region NearData = [from 0x0000 to 0x07FF];
define region Eeprom = [from 0x1000 to 0x13FF];
define region BootROM = [from 0x6000 to 0x67FF];
define region NearFuncCode = [from 0x8800 to 0xC3FF];
define region FarFuncCode = [from 0x8800 to 0xC3FF];
define region HugeFuncCode = [from 0x8800 to 0xC3FF];
boot的main文件:
__root const long reintvec[]@".intvec"=
{
0x82008080,0x82008804,0x82008808,0x8200880C, //当应用程序地址不是0xB000时则要相应改掉除第一个
0x82008810,0x82008814,0x82008818,0x8200881C, //0x82008080以外的数值
0x82008820,0x82008824,0x82008828,0x8200882C,
0x82008830,0x82008834,0x82008838,0x8200883C,
0x82008840,0x82008844,0x82008848,0x8200884C,
0x82008850,0x82008854,0x82008858,0x8200885C,
0x82008860,0x82008864,0x82008868,0x8200886C,
0x82008870,0x82008874,0x82008878,0x8200887C,
};
void main(void)
{
u8 i;
Main_Init();
EEPROM_Read(IAPFlagAddr, StartIAPFlag,1);
if(StartIAPFlag==0x01) //如果存在升级标志
{
//清空APP区的数据
FLASH_Unlock(FLASH_MemType_Program);
for(i=0;i