3 Replies Latest reply on Mar 5, 2019 6:33 AM by NikolayUshakov

    snip.scan app halt after first scan

    NikolayUshakov

      Hello!


        I ported WICED SDK 6.1 code to the Cortex-A9.

      Hardware:

      • my own (ARM Cortex-A9 + Murata 1DX module with BCM4343W)
      • bus SDIO


        I made the changes based on this article:

      Bluetooth works fine.


        but:


        I'm trying to run a snip scan.

        The initialization is fine, successfull firmware download 4343WA1.bin and 4343WA1.clm_blob.

      It prints a list of access points, but only once.


        The function wiced_scan_result_handler() receives the argument result_ptr = NULL.


        I added an argument NULL check.

      ...
        if (result_ptr == NULL || *result_ptr == NULL)
        {
           PRINT("[%s] LINE = %d result_ptr 0x%X", __FUNCTION__, __LINE__, result_ptr);
           wwd_print_stats(WICED_FALSE); //TEST
           return;
        }
      ...
      


      After that it hangs on:

      wiced_rtos_get_semaphore(&scan_data.semaphore, WICED_WAIT_FOREVER);

      in function application_start()


      Log in attached.

      I added debug messages like this article.

       

      What could be my problem?


      Thanks.

        • 1. Re: snip.scan app halt after first scan
          siba_3185206

          When result_ptr == NULL and you are printing the pointer value in the print statement:

          PRINT("[%s] LINE = %d result_ptr 0x%X", __FUNCTION__, __LINE__, result_ptr);

           

          This will generate a NULL pointer de-referencing and the system will crash.

          can you modify the print statement to remove the result_ptr as below and see what happens:

          PRINT("[%s] LINE = %d", __FUNCTION__, __LINE__);

           

          One more thing: when result_ptr == NULL, *result_ptr will also generate a null pointer de-reference exception.

          So, modify your code accordingly.

           

          If you still see a problem, then there might be a problem in your code.

          1 of 1 people found this helpful
          • 2. Re: snip.scan app halt after first scan
            NikolayUshakov

            siba_3185206 , thanks for the reply!

             

            This code does not use dereference.

            PRINT("[%s] LINE = %d result_ptr 0x%X", __FUNCTION__, __LINE__, result_ptr);  
            

            I added this line only for debugging, it does not cause crash.

            I added this code to avoid crashing the system, without it the system crashes:

            ...  
              if (result_ptr == NULL || *result_ptr == NULL)  
              {  
                 PRINT("[%s] LINE = %d result_ptr 0x%X", __FUNCTION__, __LINE__, result_ptr);  
                 wwd_print_stats(WICED_FALSE); //TEST  
                 return;  
              }  
            ...  
            

             

            For the test, I made the changes you recommend, but the problem remained the same. The snip.scan application freezes.

             

            I did not make any changes to WICED, the changes relate only to the SDIO bus and platform-specific parts of the code.

             

            The code regarding the SDIO bus is working fine, because the firmware and BLOB file download is successful. The commands for configuring the module also pass successfully:

            - clmload, bus:txglom, apsta, ampdu_ba_wsize, ampdu_mpdu, ampdu_rx_factor, country, event_msgs, cur_etheraddr, ver, clmver, bsscfg:event_msgs.

             

            Can you recommend some debugging methods that will help me find my problem?

            • 3. Re: snip.scan app halt after first scan
              NikolayUshakov

              I found a solution to my problem.

              In the folder apps/wwd/scan there is a scanning application and in my case it works fine. I compared it with apps/snip/scan to find any differences. The scan_results_handler() function from wwd checks result_ptr for NULL as follows.

                   ...
                  if (result_ptr == NULL)
                  {
                      / * finished * /
                      result_buff [result_buff_write_pos] .channel = 0xff;
                      host_rtos_set_semaphore (& num_scan_results_semaphore, WICED_FALSE);
                      return;
                  }
                   ...
              

              And in the main thread app_main() in the loop there is a check.

                          ...
                          / * TODO: change 0xff to a defined flag * /
                          if (record-> channel == (uint8_t) 0xff)
                          {
                              / * Scan completed * /
                              break;
                          }
                          ...
              

              Which is missing from apps/snip/scan app. With this the scan works fine.

               

              Judging by the "TODO ..." comment this code is a workaround. Maybe there is a way to do it right.