1 Reply Latest reply on Dec 4, 2014 2:29 PM by userc_12277

    [Possible] bug in "wiced_apps_erase"

      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