大家好,我想把官方给的TMS570L04的CAN 的bootloader 移植到 TMS570LS0232上,在执行CAN_COMMAND_DOWNLOAD命令过程中,程序卡在BLInternalFlashStartAddrCheck(g_ulTransferAddress, g_ulTransferSize)里出不来。该函数已经被我改了,如下:
uint32_t BLInternalFlashStartAddrCheck(uint32_t ulAddr, uint32_t ulImgSize)
{
uint32_t count=0, i;
uint32_t ulWholeFlashSize;
uint8_t ucStatus;
//
// Determine the size of the flash available on the part in use.
//
ulWholeFlashSize = (uint32_t)flash_sector[NUMBEROFSECTORS-1].start + flash_sector[NUMBEROFSECTORS-1].length; /* 128K */
/* The start address must be at the begining of the sector */
for (i = 0; i < NUMBEROFSECTORS-1; i++){
if (ulAddr == (uint32_t)(flash_sector[i].start))
{
count++;
}
}
if (count == 0){
#ifdef DEBUG_MSG_L3
//UART_putString(UART, "\r Application Address should be aligned with flash sector start address!\r");
// ucStatus = data_start_address_error;
// PacketWrite(CAN_PORT, CAN_COMMAND_ACK, &ucStatus, 1);
#endif
return(0);
}
//
// Is the address we were passed a valid start address? We allow:
//
// 1. Address 0 if configured to update the boot loader.
// 2. The start of the reserved block if parameter space is reserved (to
// allow a download of the parameter block contents).
// 3. The application start address specified in bl_config.h.
//
// The function fails if the address is not one of these, if the image
// size is larger than the available space or if the address is not word
// aligned.
//
if((
#ifdef ENABLE_BL_UPDATE
(ulAddr != 0) &&
#endif
(ulAddr != APP_START_ADDRESS)) ||
((ulAddr + ulImgSize) > ulWholeFlashSize) ||
((ulAddr & 3) != 0))
{
#ifdef DEBUG_MSG_L3
// UART_putString(UART, "\r Flash address and size check failed!\r");
#endif
return(0);
}
else
{
#ifdef DEBUG_MSG_L3
// UART_putString(UART, "\r Flash address and size check passed!\r");
// ucStatus = data_address_size_error;
// PacketWrite(CAN_PORT, CAN_COMMAND_ACK, &ucStatus, 1);
#endif
return(1);
}
}
我移植的过程如下:
第一步:添加头文件路径和添加F021的库,如下图:
库添加后,出现了警告,警告如下图:
请问这是不是我的库添加错了,我换了 F021_API_CortexR4_LE.lib 库,发现错误还是存在。
第二步:改CMD
TMS570LS0232的FLASH如下图:
我写的CMD如下:
MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000200
BOOT_LOAD (RX) : origin=0x00000200 length=0x00001000
FLASH_API (RX) : origin=0x00001200 length=0x00001000
FLASH0 (RX) : origin=0x00002200 length=0x00005200 //32K flash for bootloader
STACK (RW) : origin=0x08000000 length=0x00001500 //5K RAM for Stack
SRAM (RW) : origin=0x08001500 length=0x00006B00 //27K RAM for others
}
SECTIONS
{
.intvecs : {} > VECTORS
boot_code : {..\Debug\src\sys_core.obj (.text)} > BOOT_LOAD
eabi_start : {..\Debug\src\sys_startup.obj (.text)} > BOOT_LOAD
flashAPI :
{
..\Debug\src\Fapi_UserDefinedFunctions.obj (.text)
..\Debug\src\bl_flash.obj (.text)
–library= F021_API_CortexR4_BE.lib <FlashStateMachine.obj
Program.obj
Init.obj
Utilities.obj
Async.obj> (.text)
} load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
.text > FLASH0
.const > FLASH0
.cinit > FLASH0
.pinit > FLASH0
.data > SRAM
.bss > SRAM
}
麻烦大家指教一下,非常感谢!
yuanqiang hu1:
回复 David Bai1:
谢谢您 David Bai1 ,问题解决了。我现在又碰到了新问题。 我的程序在Bootlaoder中跳转到App的起始地址后,程序直接跑飞。可以保证app程序下载是正确的。 是否在App中对于中断向量表需要处理?
David Bai1:
回复 yuanqiang hu1:
Hi Yuanqiang,
建议你检查一下App的cmd文件中对应起始地址是否正确,与Bootloader的跳转地址是否一致;
另外,若App程序的地址确认无误,将你的App的程序的起始地址改为0x00000000,单独下载运行一下App程序看是否正常,验证一下你的App程序单独运行是否会跑飞。
yuanqiang hu1:
回复 David Bai1:
David Bai1,您好!我的App的cmd文件中对应起始地址是与Bootloader的跳转地址一致,App的程序的起始地址改为0x00000000可以正常运行。我用bootloader例程基础上写APP程序可以正常跳转,用HALCoGen生成的APP就不可以正常跳转,请问这是不是由于bootloader对内核初始化和APP对内核初始化不同导致的?
user5817497:
回复 David Bai1:
你好,我在移植boot到tms570ls0714遇到同一问题,boot和app无法烧写在同一扇区bank0,尝试将F021模块放在ram中运行,仍然不成功,烧写不了app,有没有官方例程是关于0714 烧写内存方面的?急求 谢谢!