在线时间22 小时
UID2029093
注册时间2013-7-28
NXP金币0
该用户从未签到
注册会员
- 积分
- 149
- 最后登录
- 2022-6-14
|
各位大神好!
最近正在尝试为S12P64编写一个基于XCPCAN通讯的bootloader,但是尝试了近一个礼拜进展甚微,对于BOOTLOADER的原理理解不深入,有点迷茫,有没有相关经验的出来讨论讨论。参考官网的AN4258SW修改自己的程序。
对PRM定义修改RAM、ROM,和相应的PLACEMENT :
SEGMENTS
/* RAM */
RAM = READ_WRITE 0x3000 TO 0x35FF; //1.5K
/* D-Flash */
DFLASH = READ_ONLY 0x010400 TO 0x0113FF;
/* non-paged FLASHs */
ROM_APP = READ_ONLY 0xC000 TO 0xF4FF;
BOOT_RAM = READ_ONLY 0xF500 TO 0xFEFF RELOCATE_TO 0x3600;
END
PLACEMENT /* here all predefined and user segments are placed into the SEGMENTS defined above. */
_PRESTART, /* Used in HIWARE format: jump to _Startup at the code start */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
//.ostext, /* OSEK */
DEFAULT_ROM,
NON_BANKED /* runtime routines which must not be banked */
// COPY /* copy down information: how to initialize variables */
/* in case you want to use ROM_4000 here as well, make sure
that all files (incl. library files) are compiled with the
option: -OnB=b */
INTO ROM_APP /*, ROM_1400, ROM_4000*/;
//DEFAULT_ROM INTO PAGE_0E /* PAGE_0C_B000, PAGE_0E */ ;
//.stackstart, /* eventually used for OSEK kernel awareness: Main-Stack Start */
// SSTACK, /* allocate stack first to avoid overwriting variables on overflow */
//.stackend, /* eventually used for OSEK kernel awareness: Main-Stack End */
DEFAULT_RAM INTO RAM;
RAM_CODE INTO BOOT_RAM;
//.vectors INTO OSVECTORS; /* OSEK */
END
ENTRIES /* keep the following unreferenced variables */
/* OSEK: always allocate the vector table and all dependent objects */
//_vectab OsBuildNumber _OsOrtiStackStart _OsOrtiStart
END
STACKSIZE 0x100
VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */
//VECTOR 0 Entry /* reset vector: this is the default entry point for an Assembly application. */
//INIT Entry /* for assembly applications: that this is as well the initialization entry point */
在main函数中如下编写:
void main(void) {
/* put your own code here */
INT8U delays = 0;
INT8U cc;
PLL_Init(); //bus 32MHz
FCLKDIV = 0x1f; //参考手册 设置为0x1f
CopyCodeToRAM();
//PortInit();
Can_Init();
EnableInterrupts;
for(;;)
{}
}
但是执行后发现无法实现代码复制到RAM中,还请有经验的人士指点迷津。
|
|