Booloadable Project Gets Stuck in Bootloader If Frequently Powered ON and OFF in PSoC 3, PSoC 4, or PSoC 5LP - KBA227541

Version 4

    Author: GeonaM_26            Version: **

     

    Question:

    When bootloadable project is frequently powered on and off, the project gets stuck in the bootloader project and flash is corrupted. How do I solve this issue?

     

    Answer:

    At startup, the bootloader validates the bootloadable and updates the metadata region in device flash. A flash write requires stable power for device VDD and VSS pins. Refer to the “Flash AC Specifications” table in the device datasheet for flashrow write time (erase and program). During this time, the device should not be reset, or flash operations will be interrupted and cannot be relied on to have completed. If flash write is interrupted, metadata region might contain invalid data.

    Bootloader v1.50 or earlier updates the metadata each time during startup even if the same data is already in flash. To avoid redundant metadata updates during startup, update to bootloader v1.60 from Project > Update Components or change the line from 2812 to 2828 in the Bootloader.c file to the following code, which will check whether the same data is already in flash before writing to flash.

     

    /* Check flash content to avoid unnecessary write to flash */

    if (rowData[address % CYDEV_FLS_ROW_SIZE] != runType)

    {

    rowData[address % CYDEV_FLS_ROW_SIZE] = runType;

     

    #if(CY_PSOC4)

    (void) CySysFlashWriteRow((uint32) rowNum, rowData);

    #else

    (void) CyWriteRowData(arrayId, rowNum, rowData);

    #endif  /* (CY_PSOC4) */

     

    #if(CY_PSOC5)

    /***************************************************************************

    * When writing to flash, data in the instruction cache can become stale.

    * Therefore, the cache data does not correlate to the data just written to

    * flash. A call to CyFlushCache() is required to invalidate the data in the

    * cache and force fresh information to be loaded from flash.

    ***************************************************************************/

    CyFlushCache();

    #endif /* (CY_PSOC5) */

    }