二、功能实现
根据上面的说明,自己编写BootLoader需要实现以下几个方面:中断向量表、分区大小、数据写入、程序跳转
1)中断向量表
中断向量表的重定向,需要根据自己的Bootloader大小进行设置,例如,大小为4KB,则Bootloader地址范围为0x8000 ~ 0x8FFF,则可以中断向量表可以重定向如下:
/* interrupt vetor redirected app addres is 0x9000
* bld size is 4kb
*/
__root const long reintvec[]@".intvec"=
{
0x82008080,0x82009004,0x82009008,0x8200900c,
0x82009010,0x82009014,0x82009018,0x8200901c,
0x82009020,0x82009024,0x82009028,0x8200902c,
0x82009030,0x82009034,0x82009038,0x8200903c,
0x82009040,0x82009044,0x82009048,0x8200904c,
0x82009050,0x82009054,0x82009058,0x8200905c,
0x82009060,0x82009064,0x82009068,0x8200906c,
0x82009070,0x82009074,0x82009078,0x8200907c,
};
如果大小为5KB,则Bootloader地址范围为0x8000 ~ 0x93FF,则可以中断向量表可以重定向如下:
/* interrupt vetor redirected app addres is 0x9400
* bld size is 5kb
*/
__root const long reintvec[]@".intvec"=
{
0x82008080,0x82009404,0x82009408,0x8200940c,
0x82009410,0x82009414,0x82009418,0x8200941c,
0x82009420,0x82009424,0x82009428,0x8200942c,
0x82009430,0x82009434,0x82009438,0x8200943c,
0x82009440,0x82009444,0x82009448,0x8200944c,
0x82009450,0x82009454,0x82009458,0x8200945c,
0x82009460,0x82009464,0x82009468,0x8200946c,
0x82009470,0x82009474,0x82009478,0x8200947c,
};
|