1 2 Previous Next 17 Replies Latest reply on Jul 31, 2019 12:00 PM by BushraH_91

    WICED- CYW943907 - S25FL064L Flash Support

    veb_4093841

      Hi ,

       

      Problem Statement : Not able to READ / WRITE to Flash S25FL064L

       

      Background:  We are using S25FL064L  in our board, as WICED has the support to this device, we have declared the macro GLOBAL_DEFINES += SFLASH_SUPPORT_CYPRESS_PARTS in CYW943907AEVAL1F.mk make file  and also in product level make file as well and included flash driver in product make make file  $(NAME)_COMPONENTS += libraries/drivers/spi_flash

       

      In the test funtion, Init flash returns the device ID correctly but read or write is not happening and there are no error prints as well.

       

      Sequence of the calls:

       

      int flash_test(int argc, char *argv[])

      {

          sflash_handle_t sflash_handle;

          int rx_data=100,rx_data_1=0;

       

          /* Initialise the serial flash driver */

          if ( init_sflash( &sflash_handle, INTERFACE_4390x_SFLASH, SFLASH_WRITE_ALLOWED ) != 0 )

          {

              /* return from main in order to try rebooting... */

              WPRINT_APP_INFO(( "[%s] Flash Initialization Failed\n",__FUNCTION__ ));

          }

       

          if(sflash_handle.device_id == FLASH_DEVICE_ID)

          {

              WPRINT_APP_INFO(( "Flash Device ID = 0X%X \n", sflash_handle.device_id ));

          }

       

              WPRINT_APP_INFO(( "rx_data : %d\n" , rx_data));

       

              if(sflash_write( &sflash_handle,0x0000400, &rx_data, 1) != WICED_SUCCESS)

              {

                  WPRINT_APP_INFO(( "Write Fail ...!!\n" ));

              }

       

              rx_data_1= 0;

       

              WPRINT_APP_INFO(( "Reading 0x0000400 \n" ));

       

              if (sflash_read( &sflash_handle,0x0000400, &rx_data_1, 1) != WICED_SUCCESS)

              {

                  WPRINT_APP_INFO(( "Read Fail ...!!\n" ));

              }

              WPRINT_APP_INFO(( "rx_data_1 : %d\n" , rx_data_1));

       

              deinit_sflash( &sflash_handle);

       

          return ERR_CMD_OK;

      }

        • 1. Re: WICED- CYW943907 - S25FL064L Flash Support
          BushraH_91

          Hello,

          Since you can read correct Flash device ID, the connection between host and Flash is OK, and the init_sflash() is working. I am internally discussing with WICED group about WICED driver usage issue.

           

          Thank you

          Regards,

          Bushra

          • 2. Re: WICED- CYW943907 - S25FL064L Flash Support
            veb_4093841

            Hi Bushra,

             

            Thanks for your  support.

             

            We are using WICED version 6.2.

             

            Since WICED has support for flash device S25FL064L, flash api's shall work directly without any additional configurations. Please correct me if my understanding is wrong and let me know the configurations required.

             

            Regards

            venkatesh

            • 3. Re: WICED- CYW943907 - S25FL064L Flash Support
              PriyaM_16

              Hello,

              Please refer this blog post: SFLASH support addition in WICED

              Kindly let me know if you still face problem.

              • 4. Re: WICED- CYW943907 - S25FL064L Flash Support
                veb_4093841

                Hi Priya,

                 

                1. As per the blog CYW43907 with External SFLASH in WICED .The flash(S25FL064L) is supported by WICED, as per my understanding need not to do any additional configuration.

                 

                For debug logs, did define '#define DEBUG_PRINT' in sflash_write.c , not getting any debug log's for Flash.

                 

                Below is out setup, Please confirm Flash driver works with this environment.

                 

                Setup:

                WICED vWiced_006.002.001.0002

                FreeRTOS v9.0.0

                LwIP v2.0.3

                 

                2. As mentioned in the  blog  did try below command

                 

                command 'waf.sflash_write-CYW943907AEVAL1-NoNs-NoOS WIPE=1 download run' fails with error message below

                 

                "

                Creating Filesystem BCM94390x_targets.mk ...

                Downloading DCT ... build/waf.sflash_write-CYW943907AEVAL1F-NoNs-NoOS/DCT.bin @ SFLASH_DCT_LOC=0x00008000

                ./tools/common/Win32/mk_wicedfs32 build/waf.sflash_write-CYW943907AEVAL1F-NoNs-NoOS/filesystem.bin build/waf.sflash_write-CYW943907AEVAL1F-NoNs-NoOS/resources/Staging/

                Creating Filesystem Done

                WICED/platform/MCU/BCM4390x/BCM94390x_targets.mk:372: recipe for target 'download_dct' failed

                make.exe[1]: *** [download_dct] Error 1

                Makefile:351: recipe for target 'main_app' failed

                make: *** [main_app] Error 2

                 

                "

                • 5. Re: WICED- CYW943907 - S25FL064L Flash Support
                  veb_4093841

                  Hi Priya,

                   

                  Thought of checking with another flash, did run the test with another board.

                   

                  Tried to write value '0x95' into address location '0x000F000' and read back from the same location , expecting the value to be same.

                   

                  Observation is that " first time the Write value and read back value is matching" from 2nd time onward values are not matching. Meaning first time read back value is 0x95 , 2nd time onward it is different value.

                  • 6. Re: WICED- CYW943907 - S25FL064L Flash Support
                    PriyaM_16

                    Hello,

                    Can you please reset the flash once as mentioned in this blog: Unbricking of CYW943907

                    • 7. Re: WICED- CYW943907 - S25FL064L Flash Support
                      veb_4093841

                      Hi Priya,

                       

                      Thanks for sharing the link.

                       

                      Did perform Chip erase functionality. As mentioned earlier, tried to write and read back the fixed value into fix location.   

                       

                      After chip erase , could able to write into location and read back data successfully.  2nd time , when attempt to write and read back the different value sflash_read returns a values different than what is written.

                       

                      Can you please through some light on what  could be the problem.

                       

                      Can you please provide an working example code / reference for S25FL064L with WICED ??

                       

                       

                      Does sflash_write api perform erase before write or erase should be called explicitly before sflash_write  ??

                      • 8. Re: WICED- CYW943907 - S25FL064L Flash Support
                        PriyaM_16

                        Hello,

                        Does sflash_write api perform erase before write or erase should be called explicitly before sflash_write  ??

                        >> Yes. It erases the data, writes it and verifies once.

                         

                        By default, the macronix parts are enabled in the CYW943907AEVAL1F.mk makefile in platform directory.

                        Change this to SFLASH_SUPPORT_CYPRESS_PARTS in the platform makefile(/43xxx_Wi-Fi/platforms/CYW943907AEVAL1F/CYW943907AEVAL1F.mk).

                        GLOBAL_DEFINES += SFLASH_SUPPORT_CYPRESS_PARTS

                         

                         

                        Are you checking the sflash write logs while programming your board?

                        I enabled the DEBUG_PRINT in sflash_write.c file and programmed the board after enabling the flag.

                        During progamming, the contents are written into the sflash and hence you should see logs like below:

                         

                        Received command: POST_WRITE_VERIFY WRTIE_ERASE_IF_NEEDED

                        Destination address: 32768

                        Size: 8000

                        Initialising serial flash

                        Done initialising

                         

                        SFLASH Device ID ( 0x1720c2)

                        SFLASH Size      ( 0x800000)

                         

                        Verifying existing data!

                        Verifying after write

                        Going back to idle

                        Waiting for command

                        Waiting for command

                        Received command: POST_WRITE_VERIFY WRTIE_ERASE_IF_NEEDED

                        Destination address: 0

                        Size: 15528

                        Initialising serial flash

                        Done initialising

                         

                        SFLASH Device ID ( 0x1720c2)

                        SFLASH Size      ( 0x800000)

                         

                        Verifying existing data!

                        Verifying after write

                        Going back to idle

                        Waiting for command

                         

                        Waiting for command

                        Received command: POST_WRITE_VERIFY WRTIE_ERASE_IF_NEEDED

                        Destination address: 69632

                        Size: 57

                        Initialising serial flash

                        Done initialising

                        • 9. Re: WICED- CYW943907 - S25FL064L Flash Support
                          veb_4093841

                          Hi,

                           

                          Does sflash_write api perform erase before write or erase should be called explicitly before sflash_write  ??

                          >> Yes. It erases the data, writes it and verifies once.

                          --->> But the observation is not, if i erase the sector by sflash_sector_erase and then write sflash_write. In this case Flash write and read values are matching. Using only sflash_write not updating right value into flash.

                           

                          Are you checking the sflash write logs while programming your board?

                          I enabled the DEBUG_PRINT in sflash_write.c file and programmed the board after enabling the flag.

                          During progamming, the contents are written into the sflash and hence you should see logs like below:

                          -->> Yes, I am looking for log's during Programming the board. Using FreeRTOS, there are no log's . Did give a try with ThreadX OS, I do see the Log's.

                          • 10. Re: WICED- CYW943907 - S25FL064L Flash Support
                            PriyaM_16

                            Hello,

                            Can you please test the attached application with ThreadX and FreeRTOS and report back the results?

                            • 11. Re: WICED- CYW943907 - S25FL064L Flash Support
                              BushraH_91

                              Hello,

                              Any update on the suggested test?

                               

                              Thank you

                              Regards,

                              Bushra

                              • 12. Re: WICED- CYW943907 - S25FL064L Flash Support
                                veb_4093841

                                Hi Bushra,

                                 

                                The test passes with the  ThreadX as well Free RTOS, if it is run as it is.

                                 

                                What is the intention of the test ? if it is to verify the 'sflash_write' the the test is not enough, because it need to be tested by writing the bits from 1 to 0 and then same bits from 0 to 1.Where as the test does it one way.

                                 

                                The test code writing 0x00 to 0xFF on to Flash twice to veriy, I modified test such that

                                1. writing 0x00 to 0xFF   -> same as test code

                                2. write all '0' to flash  -> New addition

                                3. write 0x00 to 0xFF. -> same as test code

                                 

                                I am looking at the read & write values printed ,The result is as follows ,

                                 

                                1. Both Write and Read values matches

                                2. Both Write and Read values matches

                                3. Write and Read values doesn't match

                                 

                                Regards,

                                Venkatesh

                                • 13. Re: WICED- CYW943907 - S25FL064L Flash Support
                                  PriyaM_16

                                  Can ypu please attach your application?

                                  • 14. Re: WICED- CYW943907 - S25FL064L Flash Support
                                    veb_4093841

                                    couldn't attach file as  zip.

                                     

                                    below is the modified test code:

                                     

                                    void application_start( void )

                                    {

                                        sflash_handle_t handle;

                                        int retval;

                                        int status, verify_result;

                                     

                                        wiced_init( );

                                     

                                        DEBUG_PRINT( ( "SFLASH test application\n" ) );

                                        DEBUG_PRINT( ( "=======================\n" ) );

                                     

                                     

                                        verify_result = status = init_sflash ( &handle, 0, SFLASH_WRITE_ALLOWED );

                                        DEBUG_PRINT( ( " init_sflash() status: %d\n", status ) );

                                     

                                     

                                        if ( verify_result == 0 )

                                        {

                                           sflash_sector_erase( &handle, TEST_ADDR1 );

                                           sflash_sector_erase( &handle, TEST_ADDR2 );

                                     

                                     

                                           retval = sflash_read( &handle, TEST_ADDR1, dispbuf, PAGE_BUF_SIZE );

                                           if ( retval ) {

                                               DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                           }

                                           displaybuf( dispbuf, PAGE_BUF_SIZE );

                                     

                                     

                                           if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, ERASED ) ) != 0 )

                                           {

                                              DEBUG_PRINT( ( "FAILURE to erase!!\n" ) );

                                           }

                                         }

                                     

                                     

                                         if ( verify_result == 0 )

                                         {

                                            retval = sflash_read(  &handle, TEST_ADDR2, dispbuf, PAGE_BUF_SIZE );

                                            if ( retval ) {

                                                DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                            }

                                            displaybuf( dispbuf, PAGE_BUF_SIZE );

                                     

                                     

                                            if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, ERASED ) ) != 0 )

                                            {

                                               DEBUG_PRINT( ( "FAILURE to erase!!\n" ) );

                                            }

                                         }

                                     

                                     

                                         if ( verify_result == 0 )

                                         {

                                            init_buffers( txbuf, dispbuf, PAGE_BUF_SIZE );

                                            DEBUG_PRINT( ( "Before sflash_write() dump of txbuf\n" ) );

                                            displaybuf( txbuf, PAGE_BUF_SIZE );

                                            retval = sflash_write( &handle, TEST_ADDR1, txbuf, PAGE_BUF_SIZE );

                                            if ( retval ) {

                                                DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                            }

                                     

                                     

                                            DEBUG_PRINT( ( "Before sflash_read() dump of local buffer\n" ) );

                                            displaybuf( dispbuf, 10 );

                                     

                                     

                                            retval = sflash_read( &handle, TEST_ADDR1, dispbuf, PAGE_BUF_SIZE );

                                            if ( retval ) {

                                               DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                            }

                                            displaybuf( dispbuf, PAGE_BUF_SIZE );

                                     

                                     

                                            if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, INCREMENT ) ) != 0 )

                                            {

                                               DEBUG_PRINT( ( "FAILURE to write!!\n" ) );

                                            }

                                     

                                     

                                    //        retval = sflash_read( &handle, TEST_ADDR2, dispbuf, PAGE_BUF_SIZE );

                                    //        if ( retval ) {

                                    //           DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                    //        }

                                    //        displaybuf( dispbuf, PAGE_BUF_SIZE );

                                    //

                                    //        if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, ERASED ) ) != 0 )

                                    //        {

                                    //           DEBUG_PRINT( ( "FAILURE write to wrong sector!!\n" ) );

                                    //        }

                                         }

                                     

                                     

                                         if ( verify_result == 0 )

                                         {

                                            init_buffers( txbuf, dispbuf, PAGE_BUF_SIZE );

                                            memset(txbuf,0,PAGE_BUF_SIZE);

                                            DEBUG_PRINT( ( "Before sflash_write() dump of txbuf\n" ) );

                                            displaybuf( txbuf, PAGE_BUF_SIZE );

                                            retval = sflash_write( &handle, TEST_ADDR1, txbuf, PAGE_BUF_SIZE );

                                            if ( retval ) {

                                               DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                            }

                                     

                                     

                                            retval = sflash_read( &handle, TEST_ADDR1, dispbuf, PAGE_BUF_SIZE );

                                            if ( retval ) {

                                               DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                            }

                                            displaybuf( dispbuf, PAGE_BUF_SIZE );

                                     

                                     

                                            if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, INCREMENT ) ) != 0 )

                                            {

                                               DEBUG_PRINT( ( "FAILURE to write!!\n" ) );

                                            }

                                        }

                                     

                                     

                                    //     if ( verify_result == 0 )

                                              {

                                                 init_buffers( txbuf, dispbuf, PAGE_BUF_SIZE );

                                                 DEBUG_PRINT( ( "Before sflash_write() dump of txbuf\n" ) );

                                                 displaybuf( txbuf, PAGE_BUF_SIZE );

                                                 retval = sflash_write( &handle, TEST_ADDR1, txbuf, PAGE_BUF_SIZE );

                                                 if ( retval ) {

                                                     DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                                 }

                                     

                                     

                                                 DEBUG_PRINT( ( "Before sflash_read() dump of local buffer\n" ) );

                                                 displaybuf( dispbuf, 10 );

                                     

                                     

                                                 retval = sflash_read( &handle, TEST_ADDR1, dispbuf, PAGE_BUF_SIZE );

                                                 if ( retval ) {

                                                    DEBUG_PRINT( ( "Error Code: %d\n", retval ) );

                                                 }

                                                 displaybuf( dispbuf, PAGE_BUF_SIZE );

                                     

                                     

                                                 if ( ( verify_result = verify_buffers( dispbuf, PAGE_BUF_SIZE, INCREMENT ) ) != 0 )

                                                 {

                                                    DEBUG_PRINT( ( "FAILURE to write!!\n" ) );

                                                 }

                                              }

                                     

                                     

                                        if ( verify_result == 0 )

                                        {

                                           printf( "SFlash test pass\n" );

                                        } else

                                        {

                                           printf( "SFlash test fail\n" );

                                        }

                                     

                                     

                                        DEBUG_PRINT( ( " Entering Infinite Loop !!\n" ) );

                                        while( 1 )

                                        {

                                            wiced_rtos_delay_milliseconds( 100 );

                                        }

                                    }

                                    1 2 Previous Next