Hi. We are using the TI Hercules RM48L952ZWT board and the example bootloader on Bank0 the 1st 4 sectors. The bootloader works jumping to our application that starts later on bank 0 (address 0x00020000. The problem is when we have a new application, and we want the bootloader to erase flash sectors of our application in the later sectors of Bank 0 and Bank 1, before trying to of course program the new application binary. The FAPI functions (version 02.01.00) are not erasing the flash. Below is some test code. and have verified in CCS memory browser that Flash is not erased (as well as Fapi_doBlankCheck the fails) Are we missing a step? Thank you.
Fapi_StatusType bootloader_FlashApplicationRegion(void)
{
Fapi_StatusType FapiStatus = Fapi_Error_Fail;
uint32_t flashAddress = 0x00020000;
Fapi_FlashStatusWordType oFlashStatusWord;
uint32_t Freq_In_MHz;
Freq_In_MHz = SYS_CLK_FREQ; //=160
Fapi_initializeAPI((Fapi_FmcRegistersType *)F021_CPU0_REGISTER_ADDRESS, Freq_In_MHz);
FapiStatus = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if ( FapiStatus == Fapi_Status_Success )
{
while (flashAddress <= 0x002E0000 )
{
FapiStatus = bootloader_FlashEraseSector(flashAddress);
if (FapiStatus == Fapi_Status_Success)
{
/* Verify that needed space was erased properly */
FapiStatus = Fapi_doBlankCheck( (uint32_t *)(&flashAddress), 0x7FFF, &oFlashStatusWord);
if (FapiStatus != Fapi_Status_Success)
{
UARTprintf("\r\nERROR: Fapi_doBlankCheck ...... \r\n");
break;
}
flashAddress = flashAddress + 0x00020000;
if (flashAddress == 0x00180000)
{
FapiStatus = Fapi_setActiveFlashBank(Fapi_FlashBank1);
if ( FapiStatus != Fapi_Status_Success )
{
UARTprintf("\r\nERROR: Fapi_setActiveFlashBank Fapi_FlashBank1...... \r\n");
break;
}
}
}
else
{
UARTprintf("\r\nERROR: bootloader_FlashEraseSector ...... \r\n");
}
}
}
else
{
UARTprintf("ERROR: Fapi_setActiveFlashBank-Fapi_FlashBank0 ...... \r\n");
}
return (FapiStatus);
}
Fapi_StatusType bootloader_FlashEraseSector(uint32_t ui32Address)
{
Fapi_StatusType FapiStatus = Fapi_Error_Fail;
FapiStatus = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t*)(ui32Address));
if ( FapiStatus == Fapi_Status_Success )
{
/* Wait till sector erase command has finished */
while ( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy );
/* Check for errors during sector erase */
if ( 0ul == Fapi_getFsmStatus() )
{
FapiStatus = Fapi_Status_Success;
}
}
return (FapiStatus);
}