1 Reply Latest reply on Nov 28, 2018 10:49 PM by PriyaM_16

    download_resource failed

      static wwd_result_t download_resource( wwd_resource_t resource, uint32_t address )
      {
          uint32_t transfer_progress;
          wiced_buffer_t buffer;
          uint32_t buffer_size = INDIRECT_BUFFER_SIZE;

          uint32_t size;
          wwd_result_t result = WWD_SUCCESS;

          result = host_platform_resource_size( resource, &size );

          if( result != WWD_SUCCESS )
          {
              WPRINT_WWD_ERROR(("Fatal error: download_resource doesn't exist\n"));
              goto exit;
          }

          if ( size <= 0 )
          {
              WPRINT_WWD_ERROR(("Fatal error: download_resource cannot load with invalid size\n"));
              result = WWD_BADARG;
              goto exit;
          }

          /* Transfer firmware image into the RAM */
          transfer_progress = 0;

          do
          {
              result = host_buffer_get( &buffer, WWD_NETWORK_TX, (unsigned short) ( buffer_size + sizeof(wwd_buffer_header_t) ), WICED_FALSE );
          } while ( ( result == WWD_BUFFER_UNAVAILABLE_PERMANENT ) && ( ( buffer_size >>= 1 ) > 1 ) );

          while ( transfer_progress < size )
          {
              uint8_t* packet;
              uint16_t transfer_size;
              uint32_t segment_size;

              if ( result != WWD_SUCCESS )
              {
                  WPRINT_WWD_ERROR(("Fatal error: download_resource cannot allocate buffer\n"));
                  goto exit;
              }
              packet = (uint8_t*) host_buffer_get_current_piece_data_pointer( buffer );

              host_platform_resource_read_indirect( resource, transfer_progress, packet + sizeof(wwd_buffer_header_t), buffer_size, &segment_size );

      #ifdef WLAN_ARM_CR4
          if ( ( resource == WWD_RESOURCE_WLAN_FIRMWARE ) && ( reset_instr == 0 ) )
          {
              reset_instr = *((uint32_t*)(packet + sizeof(wwd_buffer_header_t)));
          }
      #endif /* WLAN_ARM_CR4 */
              for ( ; segment_size != 0; segment_size -= transfer_size, packet += transfer_size, transfer_progress += transfer_size, address += transfer_size )
              {
                  if ( resource_download_abort == WICED_TRUE )
                  {
                      WPRINT_WWD_ERROR(("Download_resource is aborted; terminating after %lu iterations\n", transfer_progress));
                      host_buffer_release( buffer, WWD_NETWORK_TX );
                      result = WWD_UNFINISHED;
                      goto exit;
                  }
                  transfer_size = (uint16_t) MIN( WWD_BUS_MAX_TRANSFER_SIZE, segment_size );
                  result = wwd_bus_set_backplane_window( address );

                  if ( result != WWD_SUCCESS )
                  {
                      host_buffer_release( buffer, WWD_NETWORK_TX );
                      goto exit;
                  }
                  result = wwd_bus_transfer_bytes( BUS_WRITE, BACKPLANE_FUNCTION, ( address & BACKPLANE_ADDRESS_MASK ), transfer_size, (wwd_transfer_bytes_packet_t*) ( packet + sizeof(wwd_buffer_queue_ptr_t)) );
                  if ( result != WWD_SUCCESS )
                  {
                      host_buffer_release( buffer, WWD_NETWORK_TX );
                      goto exit;
                  }
              }

          }

          host_buffer_release( buffer, WWD_NETWORK_TX );
      exit:
          return result;
      }

       

      In above function,

      result = wwd_bus_transfer_bytes( BUS_WRITE, BACKPLANE_FUNCTION, ( address & BACKPLANE_ADDRESS_MASK ), transfer_size, (wwd_transfer_bytes_packet_t*) ( packet + sizeof(wwd_buffer_queue_ptr_t)) );

      the result will be WWD_TIMEOUT(0x0002), what will cause this issue, and how to fix it?

       

      My hardware is Inventek ISM43362 module connected to host platform via SDIO with fly wires. My Wiced version is WICED-Studio-6.2.

        • 1. Re: download_resource failed
          PriyaM_16

          Hello,

          The download_resource API is calling various other APIs for transferring over SDIO.

          To find out the exact place where the function returns TIMEOUT error, one would have to debug the application and check the return value by stepping over/in all the APIs as per the code flow.

          The timeout error might be possible due to the host_rtos_get_semaphore API. This API tries to acquire the semaphore within the timeout_ms parameter passed to it. If the semaphore can not be acquired within the passed timeout_ms, it results in WWD_TIMEOUT. You may increase the timeout if you want to wait for some more time for acquiring the semaphore.

           

          /**

          * Gets a semaphore

          * @param semaphore   : Pointer to variable which will receive handle of created semaphore

          * @param timeout_ms  : Maximum period to block for. Can be passed NEVER_TIMEOUT to request no timeout

          * @param will_set_in_isr : True if the semaphore will be set in an ISR. Currently only used for NoOS/NoNS

          *

          */

          wwd_result_t host_rtos_get_semaphore( host_semaphore_type_t* semaphore, uint32_t timeout_ms, wiced_bool_t will_set_in_isr )

          1 of 1 people found this helpful