This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS0232用 F021 API 写bootloader 疑问

Other Parts Discussed in Thread: TMS570LS0232, HALCOGEN, TMS570LS0714

大家好,我想把官方给的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
}

麻烦大家指教一下,非常感谢!



  • Hi yuanqiang,

    1. 就F021库而言,毋庸置疑,你应该选择F021_API_CortexR4_BE.lib。 BE和LE分别指大端序和小端序,Hercules系列产品中,TMS570系列为大端序,RM系列为小端序;

    2. 上面警告为路径的问题。cmd文件你可以参考附件的cmd内容进行修改。另外,在你导入CCS工程时,不要勾选Copy projects into workspace。否则,--library= ..\..\..\lib\F021_API_CortexR4_BE.lib有可能报路径错误。因为copy后,其项目的根路径会改变。

    SECTIONS
    {
       .intvecs : {} > VECTORS
       flashAPI :
       {
         Fapi_UserDefinedFunctions.obj (.text)
         bl_flash.obj (.text)
         --library= ..\..\..\lib\F021_API_CortexR4_BE.lib (.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
    }

  • 谢谢您 ,问题解决了。我现在又碰到了新问题。 我的程序在Bootlaoder中跳转到App的起始地址后,程序直接跑飞。可以保证app程序下载是正确的。   是否在App中对于中断向量表需要处理?

  • Hi Yuanqiang,

    建议你检查一下App的cmd文件中对应起始地址是否正确,与Bootloader的跳转地址是否一致;

    另外,若App程序的地址确认无误,将你的App的程序的起始地址改为0x00000000,单独下载运行一下App程序看是否正常,验证一下你的App程序单独运行是否会跑飞。

  • David Bai1,您好!我的App的cmd文件中对应起始地址是与Bootloader的跳转地址一致,App的程序的起始地址改为0x00000000可以正常运行。我用bootloader例程基础上写APP程序可以正常跳转,用HALCoGen生成的APP就不可以正常跳转,请问这是不是由于bootloader对内核初始化和APP对内核初始化不同导致的?

  • 你好,我在移植boot到tms570ls0714遇到同一问题,boot和app无法烧写在同一扇区bank0,尝试将F021模块放在ram中运行,仍然不成功,烧写不了app,有没有官方例程是关于0714 烧写内存方面的?急求 谢谢!