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.

TMS570LC4357: TMS570LC4357

Part Number: TMS570LC4357


Hello,
I need to write a code to prevent overwriting the binary image once it is written in the memory.
can you please give us an idea about how to do this?
I thought of flipping a variable once the binary image is written, but the variable value will revert back to it's original value after reset. How do I preserve the variable value after reset?
I know that you  have saved the 0x5A5A5A5A  value into a memory location that is preserved after reset. How do you  save the value in a certain location and perverse it  after reset? 
Thanks and regards,
Farough
  • 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);

  • Thanks. Following your commands, I will try to write a flag to the flash. How do I read the flag to prevent overwriting the binary image?

  • 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 

       ..........

    }