之前做过430和STM32的升级,串口无线GPRS都折腾过,虽说两个不是同样的套路,但是流程差不多。
现在在做LORA的远程升级,CPU使用STM8L151,32Kflash,前16K放BOOT,后16K放APP。
最简单的流程是:上电-运行BOOT-进行跳转到APP-APP接收串口指令复位(包括配置信息)-运行BOOT,如此循环没有问题。
目前想把一些配置信息进行保存,流程是:上电-运行BOOT-进行跳转到APP-APP接收串口指令复位(包括配置信息)-将配置信息存放于EEPROM-运行BOOT,这时候就运行就跑飞了。
应该是8L有什么机制是32没有的,目前还没查到。
BOOT跳转程序:
disableInterrupts();
asm("LDW X, SP ");
asm("LD A, $FF");
asm("LD XL, A ");
asm("LDW SP, X ");
asm("JPF $C000");
APP复位:
EEPROM_Write((uint16)IAPFlagAddr,&IAPFlag,1); //设置更新标志
EEPROM_Write((uint16)TotalPackNumAddr,&TotalPack,1); //更新总包数
EEPROM_Write((uint16)CurrCodeVerAddr,&TxAppBuffer[16],2); //更新程序版本号
WWDG->CR|=0x80;
WWDG->CR&=~0x40;
上面APP复位部分,只要不加那三句EEPROM_Write程序就能复位,加了以后就不能复位。
介似为嘛啊?
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 0xBFFF];
define region FarFuncCode = [from 0x8000 to 0xBFFF];
define region HugeFuncCode = [from 0x8000 to 0xBFFF];
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 0xC000 to 0xFFFF];
define region FarFuncCode = [from 0xC000 to 0xFFFF];
define region HugeFuncCode = [from 0xC000 to 0xFFFF];
我在app工程中加了:
//***
__root const long reintvec[]@".intvec"=
{
0x82008080,0x8200C004,0x8200C008,0x8200C00C, //当应用程序地址不是0xB000时则要相应改掉除第一个
0x8200C010,0x8200C014,0x8200C018,0x8200C01C, //0x82008080以外的数值
0x8200C020,0x8200C024,0x8200C028,0x8200C02C,
0x8200C030,0x8200C034,0x8200C038,0x8200C03C,
0x8200C040,0x8200C044,0x8200C048,0x8200C04C,
0x8200C050,0x8200C054,0x8200C058,0x8200C05C,
0x8200C060,0x8200C064,0x8200C068,0x8200C06C,
0x8200C070,0x8200C074,0x8200C078,0x8200C07C,
};
在boot工程中加了:
//***
__root const long reintvec[]@".intvec"=
{
0x82008080,0x82009004,0x82009008,0x8200900C, //当应用程序地址不是0xB000时则要相应改掉除第一个
0x82009010,0x82009014,0x82009018,0x8200901C, //0x82008080以外的数值
0x82009020,0x82009024,0x82009028,0x8200902C,
0x82009030,0x82009034,0x82009038,0x8200903C,
0x82009040,0x82009044,0x82009048,0x8200904C,
0x82009050,0x82009054,0x82009058,0x8200905C,
0x82009060,0x82009064,0x82009068,0x8200906C,
0x82009070,0x82009074,0x82009078,0x8200907C,
};
貌似还是没有解决问题。
|
|