10 Replies Latest reply on Sep 5, 2019 7:05 AM by JaAr_633041

    SpansionFFS with SLLD: FTL_InitAll() fails!!

    JaAr_633041

      Hi,

      Using a Renesas RX111 MCU via RSPI @ 3V3 to a S25FS064SDSMFI010 device @1V8 via PI4ULS3V304ZMEX level translator.

      Electrical interface is OK, I can read and write to the Spansion SPI flash.

      Now, trying to use SpansionFFS, it seems stuck here (within ion_pim_spansion.c):

      With stuck I mean: does not matter whether I first try to read the sectors [ionFS_get_sectors(0)], or mount [ionFS_mount(_TC("/a/", 0, 0, 0)], or format[ionFS_format(_TC("/a/", 0, 0, 0, 8400, _TC("FAT16"), 0)], all of them of course all after calling ionFS_zero_init() and ionFS_init(, it always gets into the green highlighted line (line 274) and of course fails.

      Serial console shows:

      FTL Version: 04.00.05 2015.10.30 09.00 PM PST

      ERROR: pim_ioctl_span_init: FTL_InitAll() 2

      ERROR: FTL return code = 14

      Through analysis and debugging I could see:

      1. When getting into line 272 the value of initStruct.format is still FTL_DONT_FORMAT (0), which is the reason why the second FTL_InitAll() takes place.
      2. The second FTL_InitAll() returns 14 = FTL_ERR_NOT_FORMATTED.
      3. The weird thing is that line 266 does not return any error, meaning the formatting took place.

      Has anybody experienced such a situation and can provide hints on how to solve it?

      Thanks and regards.

        • 1. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
          SudheeshK_26

          Hello Jaime,

           

          I have observed this error, if the SLLD is not properly configured.

           

          1. Did you enable pre-processor definition '__SLLD' while building your project?

          2. Did you implement following commands in slld?

               a. write enable (0x06)

               b. write disable (0x04)

               c. sector erase (0xd8)

               d. program (0x02)

               e. read (0x03)

               f. read status register (0x05)

          3. You mentioned that, you are able to read and write to flash. Are you using the same slld (in our ffs package) to read and write?

           

          Thanks and Regards,

          Sudheesh

          • 2. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
            JaAr_633041

            Hi Sudheesh,

             

            Thanks a lot for the feedback.

             

            Yes, I have __SLLD defined in the project options.

             

            I am using Spansion's SLLD, of course modified a bit to match bettwer what I have in my HW. Namely, I modified SLLD/Hals/slld_hal.c in the following ways:

            1. FLASH_READ
              1. Commands with DUALIO and QUADIO return SLLD_E_HAL_ERROR, because they originally write to SPIDATA_D or SPIDATA_Q respectively, which are not supported
              2. For actuall sending I am using my own function for sending/receiving via SPI, blocking (bsp_spi_transaction_blocking(g_buf_tx, g_buf_rx, len_hdr + Number_Of_Read_Bytes)
              3. g_buf_tx and g_buf_rx are file-local, global buffers of size CONTROLLER_BUFFER_SIZE + 4u entries. Since my application is no-RTOS, there is no risk of multiple access to them.
            2. FLASH_WRITE
              1. Most same as for FLASH_READ, but only with the difference that in this case, commands with QPP are the ones returning SLLD_E_HAL_ERROR, because they originally write to SPIDATA_Q which is not supported

             

            I am attaching my slld_hal.c for reference.

             

            Other than that I did not make any modification to SLLD, therefore I assume all needed commands are implemented. Will give it a look, though.

             

            Further analysis / debugging shows what is the reason for the second call to FTL_InitAll() to fail. Setepping into the second call to FTL_InitAll() looks as in following screen capture:

            As can be seen, it goes into the else because initStructPtr->format is still FTL_DONT_FORMAT (0). I wonder, how it then works for others? I must be doing something wrong.

             

            The point is: between the two calls to FTL_InitAll() in ion_pim_spansion.c (lines 264 and 272) nothing changes initStruct.format (it is still FTL_DONT_FORMAT (0)) therefore it will always fail within ftl_init.c at line 221, unless the flow is different in such a way that for the second call to FTL_InitAll() the condition initStructPtr->format == FTL_FORMAT_AS_NEEDED (line 196) is not checked.

             

            How to achieve that?

             

            All support in figuring it out and fixing it is very welcome.

            • 3. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
              JaAr_633041

              Hello Sudheesh,

               

              About the flow within FTL_initAll():

              • FTL_FindSuperSysEB() returns 28019 (FTL_ERR_SUPER_LOG_GET_ENTRY), therefore getting into the else commented with "Fail Super System EB" (line 175 in ftl_init.c), see below. Is that bad? If so how to fix? Does it impact the flow within FTL_initAll()?

               

              • formatCount is set to 26 within UpdateEBOrderingTable()(line188), therefore getting into the code checking for initStructPtr->format == FTL_FORMAT_AS_NEEDED, which is then bringing to the trouble situation mentioned in previous post(s).
              • Both the first and the second invokations to FTL_initAll() behave exactly the same.
                • Is that indended?
                • If so, what is the sense on that?
                • If not, why and how to fix?

               

              Please, I desperately need support in getting FFS to work.

              How can it be fixed from the application / configuration / HAL / whatever?

               

              Thanks and regards.

              • 4. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                JaAr_633041

                Hi Sudheesh,

                 

                Just some additional information: I have small test to check that I can communicate to the flash, see further below.

                 

                Console output is:

                 

                Manufacturer ID OK

                Device ID - Memory Interface Type OK

                Device ID - Density OK

                Device ID - ID-CFI Length OK

                Device ID - Physical Sector Architecture OK, Uniform 64kB physical sectors

                Device ID - Family ID OK

                 

                Code here:

                 

                #define TST_FLASH_BUF_LEN      (7u)      //!< Length of buffer for flash test

                 

                void tst_flash (void)

                {

                    uint32_t buf_tx[TST_FLASH_BUF_LEN] = { 0 };

                    uint32_t buf_rx[TST_FLASH_BUF_LEN] = { 0 };

                    uint8_t  idx;

                 

                    /* Setup command (RDID) */

                    buf_tx[0] = 0x9Fu;

                 

                    /* Transaction */

                    bsp_spi_transaction_blocking(buf_tx, buf_rx, TST_FLASH_BUF_LEN);

                 

                    /* Check Manufacturer ID according to Table 59 of Flash datasheet */

                    idx = 1u;

                 

                    if (0x01u == buf_rx[idx])

                    {

                        printf("Manufacturer ID OK\n");

                    }

                    else

                    {

                        printf("Manufacturer ID failed, was 0x%02X\n", buf_rx[idx]);

                    }

                 

                    /* Check Device ID - Memory Interface Type according to Table 59 of Flash datasheet */

                    idx = 2u;

                 

                    if (0x02u == buf_rx[idx])

                    {

                        printf("Device ID - Memory Interface Type OK\n");

                    }

                    else

                    {

                        printf("Device ID - Memory Interface Type failed, was 0x%02X\n", buf_rx[idx]);

                    }

                 

                    /* Check Device ID - Density according to Table 59 of Flash datasheet */

                    idx = 3u;

                 

                    if (0x17u == buf_rx[idx])

                    {

                        printf("Device ID - Density OK\n");

                    }

                    else

                    {

                        printf("Device ID - Density failed, was 0x%02X\n", buf_rx[idx]);

                    }

                 

                    /* Check ID-CFI Length according to Table 59 of Flash datasheet */

                    idx = 4u;

                 

                    if (0x4Du == buf_rx[idx])

                    {

                        printf("Device ID - ID-CFI Length OK\n");

                    }

                    else

                    {

                        printf("Device ID - ID-CFI Length failed, was 0x%02X\n", buf_rx[idx]);

                    }

                 

                    /* Check Physical Sector Architecture according to Table 59 of Flash datasheet */

                    idx = 5u;

                 

                    if (0x00 == buf_rx[idx])

                    {

                        printf("Device ID - Physical Sector Architecture OK, Uniform 256kB physical sectors\n");

                    }

                    else if (0x01u == buf_rx[idx])

                    {

                        printf("Device ID - Physical Sector Architecture OK, Uniform 64kB physical sectors\n");

                    }

                    else

                    {

                        printf("Device ID - Physical Sector Architecture failed, was 0x%02X\n", buf_rx[idx]);

                    }

                 

                    /* Check Family ID according to Table 59 of Flash datasheet */

                    idx = 6u;

                 

                    if (0x81u == buf_rx[idx])

                    {

                        printf("Device ID - Family ID OK\n");

                    }

                    else

                    {

                        printf("Device ID - Family ID failed, was 0x%02X\n", buf_rx[idx]);

                    }

                }

                • 5. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                  SudheeshK_26

                  Hi Jaime,

                   

                  Can you use function "slld_RDIDCmd()" in slld.c to read Flash ID from your main function before calling any of the FFS APIs?

                  Please let me know, if you can read ID correctly.


                  Thanks and Regard,

                  Sudheesh

                  • 6. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                    JaAr_633041

                    Hi SudheeshK_26

                     

                    In the meantime I could do initial integration of the code under SLLD/TestCase.

                     

                    slld_test_init() gives:

                     

                    Initialize Spansion PCI

                    SLLD version = 13.2.1

                    CFG content:

                     

                     

                    0x00000000 01 02 17 4d 01 81 30 31 82 ff ff ff ff ff ff ff

                    0x00000010 51 52 59 02 00 40 00 53 46 51 00 17 19 00 00 09

                    0x00000020 09 08 05 02 02 03 03 17 02 01 08 00 03 07 00 10

                    0x00000030 00 00 00 80 00 7e 00 00 00 ff ff ff ff ff ff ff

                    Device S25FS- is Found

                    Order Information :

                    0 ,SOIC16 / WSON footprint, 64-kB Physical Sector

                    1 ,

                    Memory size = 8 MB

                    Boot Type = 7

                    Total Bank number = 0

                    Total Block number = 1

                    Total Sector number = 136

                    Total Region number = 3

                    Region[0].SecotrNumber = 8

                    Region[0].SectorSize =  4 KB

                    Region[1].SecotrNumber = 1

                    Region[1].SectorSize =  32 KB

                    Region[2].SecotrNumber = 127

                    Region[2].SectorSize =  0 KB

                    Max SectorSize = 32 KB

                    Page size = 256

                    Small Sector locate in Top

                     

                    Which seems completely fine, or?

                     

                    I will give a try to your suggestion also, and let you know.

                     

                    Regards.

                    • 7. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                      JaAr_633041

                      Hi SudheeshK_26,

                       

                      It turned out, slld_RDIDCmd() is called from within slld_ProbeDevice(), which in turn is called within slld_test_init().

                       

                      Therefore, yes, it reads the ID, and the CFI is shown in the console (decoded as well).

                       

                      I plan to continue integrating the tests from TestCase. Have to modify them a bit though, because I have small RAM (64 kB total) and no heap.

                       

                      Any further hints are very welcome.

                       

                      Regards.

                      • 8. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                        SudheeshK_26

                        Hello Jaime,

                         

                        Is it possible for you to share your project with us? We can check if there are any issues with it.

                         

                        Thanks and Regards,

                        Sudheesh

                        1 of 1 people found this helpful
                        • 9. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                          JaAr_633041

                          Hi SudheeshK_26,

                           

                          Sure, I can share it. How to send privately? Can you share your email address?

                           

                          Regards.

                          • 10. Re: SpansionFFS with SLLD: FTL_InitAll() fails!!
                            JaAr_633041

                            After countless hours of investigation, reading API manuals, analyzing Logic Analyzer traces, fine tuning low level drivers, rebuilding and downloading to the board, and a lot of support from Cypress, it was possible to spot the cause of the trouble: a timing issue with the level translator between MCU and Flash IC. I just had to add a 2us syncronization margin between the level shifter and the flash /CS signal, and done!

                             

                            I really want to thank SudheeshK_26 for the extraordinary patience, the attention to detail, the very structured guidance, all topics only through which it was possible to find the root cause.

                             

                            Now I am able to run successfully, not only my test cases, but also application code for starting the file system, mounting it, opening files, writing to and reading from them, closing them, unmounting the file system and closing it, without any issue whatsoever.

                             

                            As SudheeshK_26 rightly pointed out, it all smelt like issues with SLLD.

                             

                            Keep up the good job and thank you for your extaordinary support.