[Possible] bug in "wiced_apps_erase"

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

I'm currently using SDK_3.1.1 and likely find a bug in "wicked_apps_erase" when calling "wiced_framework_app_erase".

The api is used to erase specified application depended on app header location was stored in DCT, if I understand the code correctly, the problem is using "app_header.sectors[ index ].start"  as maximum sectors need to be erased, it's not quite right, but should be app_header.sectors[ index ].count instead, otherwise unexpected sectors will be erased.

It's currently modification I think:

wiced_result_t wiced_apps_erase( const image_location_t* app_header_location )

{

        sflash_handle_t sflash_handle;

    app_header_t    app_header;

    uint8_t        index;

    /* Loop on each entry and erase the sectors*/

    init_sflash( &sflash_handle, PLATFORM_SFLASH_PERIPHERAL_ID, SFLASH_WRITE_ALLOWED );

    sflash_read( &sflash_handle, app_header_location->detail.external_fixed.location, &app_header, sizeof(app_header_t) );

    for ( index = 0; index < app_header.count; index++ )

    {

        unsigned long sector;


#if 0 //Original

        for ( sector = 0; sector < app_header.sectors[ index ].start; sector++ )

#else //Fix

        for ( sector = 0; sector < app_header.sectors[ index ].count; sector++ )

#endif

        {

            sflash_sector_erase( &sflash_handle, ( app_header.sectors[ index ].start + sector ) * SFLASH_SECTOR_SIZE );

        }

    }

    return WICED_SUCCESS;

}

--

Andy

0 Likes
1 Reply
Anonymous
Not applicable

Hi,

Thank you for raising this. We are aware of the bug, and hopefully it would be fixed in the next patch.

However you don't need to call wiced_apps_erase to write a new file, as the write function have an embedded erase per section inside it. This is usually to avoid long delays in erasing the full flash at start.

please have a look at: WICED Multi-Application Support Question

Regards,

Bassem

0 Likes