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 team,
I cannot find in the forum an answer to my problem so there it is,
In my RM48 I have the bootloader software and the application software in the same bank 0 so that I can disable the bank 1 to save power. The bootloader shall update the application and so the flash API must run from RAM. I follow the TI examples which uses the _copyAPI2RAM_() function to do that. Another point is that the application image file must have the ECC data, which requires the modification of the linker file accordingly, to avoid problems when running the application. The current application image file type is intel hex, rather than binary due to the file size (gigabytes).
In my first approach I erased the whole application area before programming and everything worked as expected. However, to update a small part of the application I cannot use this approach because the Fapi erase function cannot erase less than a sector (128K). So, I tried to program only without erase and in here I found a problem that I cannot fix or understand.
/* Program bytes to Flash and wait until ready */ status = Fapi_issueProgrammingCommand((uint32_t*)dst, (uint8_t *)src, WIDTH_MAIN_BANK, 0, 0, Fapi_AutoEccGeneration); if(status != Fapi_Status_Success) { return status; } while(FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy); status = (Fapi_StatusType)FAPI_GET_FSM_STATUS; if(status != Fapi_Status_Success) { return Fapi_Error_Fail; }
The status variable after get the FAPI_GET_FSM_STATUS has the vale 0x30. From the Flash API reference guide the error is INVDAT.
I do not know where I can find information to fix the problem or at least understand. I must erase first before programming?
Hello,
Before programming data to the flash, the location and its ECC area has to be erased (0xFFFFFFFF).
Hello QJ Wang,
call you please tell me where can find it in the documentation? In the flash reference guide I do not find any information saying that before program I should erase.
If it is always required, how I can patch/update a small part of the application without erase the entire sector? Save that sector to another sector or to RAM? I think that it is not a good approach for a bootloader.
thanks
Hello,
The flash can be erased only a sector or a bank at a time. The erase operation sets all bits in the sector or bank to 1. With a freshly erased sector, any location can be programmed. However, once a bit has been set to 0, only by erasing the entire sector can it be changed back to 1.
If the flash ECC is disabled, a location can be rewritten as long as the new value's 0 bits are a superset of the over-written values. For example, a location may is erased to 1111, then written as 1110. Successive writes to that location can change it to 1010, then 0010, and finally 0000.
If the flash ECC is enabled, when change the location value to 1010 or 0010 or 0000, the new ECC value may not be writtable (need to change the cell from 0 to 1). So please write data to a valid erased location (both data and ecc are 0xFFFF).