在使用TASKING 建立TC397 工程时,编译报错 syntax error - token “” deleted, 主要在 IfxScu_regdef.h 文件中。
由于TASKING 默认使用了.sfr 文件,因此出现编译冲突。在TASKING 中 Setting -> Preprocessing-> Automatic inclusion of sfr file , 取消勾选即可
UCB 用于描述用户配置信息,非数据存储区域。UCB 起始地址 0xAF400000
Boot Mode Header 是固化在代码中的启动信息。包含了启动地址, 具体的信息有以下部分组成
unsigned short bmi; /**< \brief 0x000: Boot Mode Index (BMI)*/
unsigned short bmhdid; /**< \brief 0x002: Boot Mode Header ID (CODE) = B359H*/
unsigned int stad; /**< \brief 0x004: User Code start address*/
unsigned int crc; /**< \brief 0x008: Check Result for the BMI Header (offset 000H - 007H)*/
unsigned int crcInv; /**< \brief 0x00C: Inverted Check Result for the BMI Header (offset 000H - 007H)*/
unsigned int reserved0[60]; /**< \brief 0x010: Reserved area (60 words) till the offset 0x100*/
unsigned int pw[8]; /**< \brief 0x100: Password protection (8 words) till the offset 0x120 */
unsigned int reserved1[52]; /**< \brief 0x120: Reserved area (52 words) till the offset 0x1F0*/
unsigned int confirmation; /**< \brief 0x1F0: 32-bit CODE, (always same)*/
实现例子如下
0x00FE, /* 0x000: .bmi: Boot Mode Index (BMI) */
0xB359, /* 0x002: .bmhdid: Boot Mode Header ID (CODE) = B359H */
0xA00E0800, /* 0x004: .stad: User Code start address */
0xF33EF272, /* 0x008: .crc: Check Result for the BMI Header (offset 000H - 007H) */
0x0CC10D8D, /* 0x00C: .crcInv: Inverted Check Result for the BMI Header (offset 000H - 007H) */
CRC计算可以采用在线计算工具进行计算 http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
当计算非翻转CRC(crc)时,使用如下参数进行计算,输入地址时请注意大小端
当计算翻转CRC(crcInv)时,使用如下参数进行计算
在Project->Properties->C/C++ Build -> Memory 中, Boot Mode Headers界面支持可视化配置BMHD
配置后,TASKING会根据选项,更新项目链接文件,生成不同的宏。
根据宏的定义,在通过tc39xb_tc0.lsl 链接文件包含 tc1v1_6_2.bmhd.lsl 文件,最终获取获取启动入口地址。如前面图片展示的启动地址的标识符为 _START
_START 函数定义在cstart 中
#pragma section code libc.reset
#pragma optimize g
void _START( void )
{
__init_sp();
}
#pragma optimize restore
#pragma section code restore
_START 又通过链接指令,链接到指定地址,地址也可以在TASKING 配置,如下图所示
最终_START 调用main 函数完成启动工作。
TC397 支持4个BMHD, BMHD0-3. 启动时会依次寻找是否有可用的BMHD, 判断流程如下图
对于常见的Boot+App 场景。即存在多个 BMHD,具体的跳转流程图下图蓝色标记所示
详细分为一下几步
Step1. 系统BOOTROM,根据BMHD0 跳转到Bootloader程序
Step2. Bootloader 根据自身跳转条件,检测App, App 有效即可跳转App(不需要经过BMHD1)
对于单App, 也是可以通过BMHD1 进行单独的启动调试