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,
You can write a key or a flag to the flash using the F021 flash API. Before writing to the flash, the flash sector needs to be erased first. You can not write a value to flash location whose content is not 0xFFFFFFFF.
Please refer to the DCAN bootloader:
http://software-dl.ti.com/hercules/hercules_docs/latest/hercules/Examples/Examples.html#bootloader
bl_flash.c: functions which call Flash APIs to erase the flash, and write data to flash
flash_defines.h: flash sector definition
Line 629 of bl_dcan.c is to write the status to flash:
oReturnCheck = Fapi_UpdateStatusProgram(g_ulUpdateStatusAddr, (uint32_t)&g_pulUpdateSuccess[0], g_ulUpdateBufferSize);
You can refer to the example used in the bootloader code. If the flag is not the magic word, the image will be overwritten. If the magic word is already programmed, the programming of image can be skipped, or the image can be programmed to another location:
For example:
// Check if update needed
if(0 == CheckGPIOForceUpdate() && (*(uint32_t *) APP_STATUS_ADDRESS) == 0x5A5A5A5A)
{
//skip the overwrite, and jump to the application
g_ulTransferAddress = (uint32_t)APP_START_ADDRESS;
((void (*)(void))g_ulTransferAddress)();
} else{
//program the image
..........
}