1 Reply Latest reply on Oct 18, 2016 7:56 AM by axel.lin_1746341

    SDK 3.5.2  and SDK 3.7.0 error (OTA)

    darius1

      static wiced_result_t wiced_dct_load( const image_location_t* dct_location )

      {

          elf_header_t         header;

          elf_program_header_t prog_header;

          uint32_t             size;

          uint32_t             offset;

          uint32_t             dest_loc = PLATFORM_DCT_COPY1_START_ADDRESS;

          uint8_t              buff[64];

       

          /* Erase the application area */

          wiced_dct_erase_non_current_dct( dest_loc );

       

          /* Read the image header */

          if (wiced_apps_read( dct_location, (uint8_t*) &header, 0, sizeof( header ) ) != 0)

          {

              return WICED_ERROR;

          }

       

          if ( header.program_header_entry_count != 1 )

          {

              return WICED_ERROR;

          }

       

          if (wiced_apps_read( dct_location, (uint8_t*) &prog_header, header.program_header_offset, sizeof( prog_header ) ) != 0)

          {

              return WICED_ERROR;

          }

       

          size   = prog_header.data_size_in_file;

          offset = prog_header.data_offset;

       

          while ( size > 0 )

          {

              uint32_t write_size = MIN(sizeof(buff), size);

              //if (wiced_apps_read( dct_location, buff, offset, write_size) != 0)                {

              if (wiced_apps_read( dct_location, buff, offset, write_size) == 0)//Darius - if read ok, so need write

              {

                  if ( platform_write_flash_chunk(dest_loc, buff, write_size ) != 0)

                  {

                      return WICED_ERROR;

                  }

              }

       

              offset   += write_size;

              dest_loc += write_size;

              size     -= write_size;

          }

          return WICED_SUCCESS;

      }