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.
Hello,
We are developing the bootloader using TMS570LS3137 and found that in the bootloader:
Fapi_issueAsyncCommandWithAddress (Fapi_EraseSector, flash_sector [sectornum]. Start);
this function can erase bank1 sector, However, it is not possible to erase a sector in bank0, for example, when erasing sector10 in bank0, the system will make an error in erasing the sector.
1. The erasing function is as follows:
const SECTORS flash_sector[NUMBEROFSECTORS]= { (void *)0x00000000, 0x08000, 0, 0, 0xfff87000, (void *)0x00008000, 0x08000, 0, 1, 0xfff87000, (void *)0x00010000, 0x08000, 0, 2, 0xfff87000, (void *)0x00018000, 0x08000, 0, 3, 0xfff87000, (void *)0x00020000, 0x20000, 0, 4, 0xfff87000, (void *)0x00040000, 0x20000, 0, 5, 0xfff87000, (void *)0x00060000, 0x20000, 0, 6, 0xfff87000, (void *)0x00080000, 0x20000, 0, 7, 0xfff87000, (void *)0x000A0000, 0x20000, 0, 8, 0xfff87000, (void *)0x000C0000, 0x20000, 0, 9, 0xfff87000, (void *)0x000E0000, 0x20000, 0, 10, 0xfff87000, (void *)0x00100000, 0x20000, 0, 11, 0xfff87000, (void *)0x00120000, 0x20000, 0, 12, 0xfff87000, (void *)0x00140000, 0x20000, 0, 13, 0xfff87000, (void *)0x00160000, 0x20000, 0, 14, 0xfff87000, (void *)0x00180000, 0x20000, 1, 0, 0xfff87000, (void *)0x001A0000, 0x20000, 1, 1, 0xfff87000, (void *)0x001C0000, 0x20000, 1, 2, 0xfff87000, (void *)0x001E0000, 0x20000, 1, 3, 0xfff87000, (void *)0x00200000, 0x20000, 1, 4, 0xfff87000, (void *)0x00220000, 0x20000, 1, 5, 0xfff87000, (void *)0x00240000, 0x20000, 1, 6, 0xfff87000, (void *)0x00260000, 0x20000, 1, 7, 0xfff87000, (void *)0x00280000, 0x20000, 1, 8, 0xfff87000, (void *)0x002A0000, 0x20000, 1, 9, 0xfff87000, (void *)0x002C0000, 0x20000, 1, 10, 0xfff87000, (void *)0x002E0000, 0x20000, 1, 11, 0xfff87000 }; uint8_t drvFapi_BlockEraseSector(uint8_t sectornum) { uint8_t RetValue=0; Fapi_initializeFlashBanks((uint32_t)SYS_CLK_FREQ); /* used for API Rev2.01 */ Fapi_setActiveFlashBank((Fapi_FlashBankType)(flash_sector[sectornum].bankNumber)); Fapi_enableMainBankSectors(0xFFFF); /* used for API 2.01*/ while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady ); Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, flash_sector[sectornum].start); while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy ); while(FAPI_GET_FSM_STATUS != Fapi_Status_Success); if(Flash_Erase_Check((uint32_t)flash_sector[sectornum].start, flash_sector[sectornum].length)) { RetValue |= 0x82;/*flash中的值不为0xFFFFFFFF,擦除失败*/ } else { ; } return RetValue; }
2. Link configuration is as follows:
MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000100
FLASH_API (RX) : origin=0x00010000 length=0x00010000
FLASH0 (RX) : origin=0x00020000 length=0x00040000
STACKS (RW) : origin=0x08000000 length=0x00009000
RAM_F201API (RW) : origin=0x08009000 length=0x00003000
RAM (RW) : origin=0x0800C000 length=0x00033F00
USERDEFINE (RW) : origin=0x0803FF00 length=0x00000100 //GET_COREREG_ADDR用户自定义使用的内存段
}
SECTIONS
{
.intvecs : {} > VECTORS
flashAPI :
{
Fapi_UserDefinedFunctions.obj (.text)
bl_flash.obj (.text)
--library= ..\lib\F021_API_CortexR4_BE.lib (.text)
} load = FLASH_API, run = RAM_F201API, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
.text : {} > FLASH0
.const : {} > FLASH0
.cinit : {} > FLASH0
.pinit : {} > FLASH0
.bss : {} > RAM
.data : {} > RAM
.sysmem : {} > RAM
}
3. The function _copyAPI2RAM_() is also called in void _c_int00(void)。
4. When erasing bank0 sector, the following error message is displayed
Hi Shunyun,
Can you check if the flash APIs have been copied to SRAM starting at api_run?
Please add .data section to the following statements in your cmd file:
flashAPI :
{
Fapi_UserDefinedFunctions.obj (.text)
bl_flash.obj (.text, .data)
--library= ..\lib\F021_API_CortexR4_BE.lib (.text, .data)
} load = FLASH_API, run = RAM_F201API, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
Hi Shunyun,
Just noticed that the flash section from 0x100 to 0x10000 is not used in your cmd file.
VECTORS (X) : origin=0x00000000 length=0x00000100
FLASH_API (RX) : origin=0x00010000 length=0x00010000
FLASH0 (RX) : origin=0x00020000 length=0x00040000
This will generate a big hole without any data and valid ECC.
Can you try those modifications:
MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000020
FLASH0 (RX) : origin=0x00000020 length=0x00080000 - 0x20
STACKS (RW) : origin=0x08000000 length=0x00009000
RAM_F201API (RW) : origin=0x08009000 length=0x00003000
RAM (RW) : origin=0x0800C000 length=0x00033F00
USERDEFINE (RW) : origin=0x0803FF00 length=0x00000100 //GET_COREREG_ADDR用户自定义使用的内存段
}
SECTIONS
{
.intvecs : {} > VECTORS
flashAPI :
{
Fapi_UserDefinedFunctions.obj (.text)
bl_flash.obj (.text, .data)
--library= ..\lib\F021_API_CortexR4_BE.lib (.text, .data)
} load = FLASH0, run = RAM_F201API, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)
.text : {} > FLASH0
.const : {} > FLASH0
.cinit : {} > FLASH0
.pinit : {} > FLASH0
.bss : {} > RAM
.data : {} > RAM
.sysmem : {} > RAM
}