9 Replies Latest reply on Apr 9, 2020 4:52 AM by ApurvaS_36

    S25FL512S with PSoC6-BLE-Kit

    user_4600591

      I am a lite bit confused how to Address the Flash Memory while using Quad SPI.

       

      For Basis is used the "CE220823 SMIF Memory Write and Read Operaration" example.

       

      To check the correct addressing i manipulate the example like this:

           - increase PACKET_SIZE to 128

           - remove Comparing rxbuffer and txbuffer.

           - Insert below Step 4: 

       

      /* Read back after Write for verification */

      static uint8_t rxLongBuffer[4096]={0};

      extMemAddress[0]=0;

      extMemAddress[1]=0;

      extMemAddress[2]=0;

      extMemAddress[3]=0;

      printf("\n5. Reading back Zero Add for verification.\n");
      smifApiStatus = ReadMemory(smifMemConfigs[0], extMemAddress, rxLongBuffer, 4096);
      CheckStatus("Reading memory failed", smifApiStatus);
      PrintArray("Received Data", rxLongBuffer, 4096);

       

      so after step 4 the MCU print always the first 4096 Bytes of the externe Flash.

       

      So know i can configure different Addresses to check if the will be address.

      uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x00, 0x00, 0x00};

       

      For example to Addresse number Two:

      uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x00, 0x02, 0x00};

      all want right with the Output:

       

      SMIF code example has started

      SMIF interrupt is initialized

       

      SMIF hardware block is initialized

       

      ================================================================================

       

      1. Erasing 262144 bytes of memory.

       

      2. Reading after Erase. Ensure that the data read is 0xFF for each byte.

       

      Received Data (128 bytes):

      -------------------------

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

       

      3. Writing data to memory.

       

      Written Data (128 bytes):

      -------------------------

      0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F

      0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F

      0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F

      0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F

       

      4. Reading back same Add for verification.

       

      Received Data (128 bytes):

      -------------------------

      0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F

      0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F

      0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F

      0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F

       

      5. Reading back Zero Add for verification.

       

      Received Data (4096 bytes):

      -------------------------

      0xFF 0xFF 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D

      0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D

      0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D

      0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D

      0x7E 0x7F 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF ........

      0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

       

       

      But when i try to address the Memory above 0xFF i can not see how to do this.

      For example uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x01, 0xFF, 0x00};

      I just get 0xFF in the first 4096 Bytes.

       

      For example uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x00, 0xFF, 0x01};

      I got the same Result then Addressing {0x00, 0x00, 0xFF, 0x00};

       

       

      So my Question is how to Address the ext Memory in the right way???

       

      Nachricht geändert durch Julian Müller

        • 1. Re: S25FL512S with PSoC6-BLE-Kit
          ApurvaS_36

          Hi,

           

          Thank you for contacting Cypress Semiconductor.

          Is it possible for you to attach the PSoC project, so we can try recreating the issue at our end?

           

          Regards,

          Apurva

          • 2. Re: S25FL512S with PSoC6-BLE-Kit
            user_4600591

            It is so confusing for example:

            I try to use

             

            uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x01, 0xFF, 0x00};

            where i hope to write/read to/from Address 511.

            But result is:

             

            SMIF code example has started

            SMIF interrupt is initialized

             

            SMIF hardware block is initialized

             

            ================================================================================

             

            1. Erasing 262144 bytes of memory.

             

            2. Reading after Erase. Ensure that the data read is 0xFF for each byte.

             

            Received Data (128 bytes):

            -------------------------

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

             

            3. Writing data to memory.

             

            Written Data (128 bytes):

            -------------------------

            0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F

            0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F

            0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F

            0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F

             

            4. Reading back same Add for verification.

             

            Received Data (128 bytes):

            -------------------------

            0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

             

            5. Reading back Zero Add for verification.

             

            Received Data (2048 bytes):

            -------------------------

            0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20

            0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40

            0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60

            0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7A 0x7B 0x7C 0x7D 0x7E 0x7F 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

            ...

            0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

             

            ================================================================================

             

            FAIL: Read data does not match with written data. Read/Write operation failed.

            Error Code: 0xFFFFFF02

             

            ================================================================================

            • 3. Re: S25FL512S with PSoC6-BLE-Kit
              user_4600591

              So somebody can tell me how to address S25F512S Flash?

              • 4. Re: S25FL512S with PSoC6-BLE-Kit
                ApurvaS_36

                Hi,

                 

                I tried to run the project (attached in the first response) on my PSoC 6 BLE kit and my observation is as follows -

                I am attaching the serial terminal output log that I received. The output seems to be correct as per the modifications made to the code example. The screenshot of one section of the output is shown below -

                We can see that when the last read operation starts from the zeroth memory location the initial data is all 0xFF which means the memory is erased. The data which was programmed to the flash in the 3rd step (Writing data to memory) starts from the 0x0120 memory location.

                Though the MAX_ADDRESS_SIZE is set to 4u, the program is only considering the first 3 most significant bytes of extMemAddress as address for flash and the last byte is getting ignored.

                 

                Could you please elaborate the issue that you are facing at your end?

                 

                Regards,

                Apurva

                • 5. Re: S25FL512S with PSoC6-BLE-Kit
                  user_4600591

                  Same Problem using the SMIF_Memory_Write_and_Read_Operation example and try to read/write

                  uint8_t extMemAddress[ADDRESS_SIZE] = {0x00, 0x01, 0xFF};

                   

                  result:

                  Read data does not match with written data in quad mode

                   

                  So what did i misunderstand in using the MemAddress Array??

                  • 6. Re: S25FL512S with PSoC6-BLE-Kit
                    user_4600591

                    If i run the same project with:

                    uint8_t extMemAddress[MAX_ADDRESS_SIZE] = {0x00, 0x01, 0xFF, 0x00};

                     

                    putty_Output.png

                     

                    So written and received Data do not match for Address 0x0001FF

                    and if you watch Output 5) The Data were written to Address 0x000000

                    • 7. Re: S25FL512S with PSoC6-BLE-Kit
                      ApurvaS_36

                      Hi,

                       

                      I would like to inform you about address wrapping that takes place when we program data at page boundaries. The following screenshot is from the datasheet of S25FL512S Flash

                      Please note that the page size for S25FL512S Flash device is 512 bytes. 0x0001FF (511) is the last address of the first page. Hence, when you start programming 64 bytes of data starting from 0x0001FF memory location, one byte of data gets programmed to 0x0001FF memory location and the address gets wrapped to the first location of the same page (which is 0x000000 or the zeroth location of the flash) and the rest of the 63 bytes of data get programmed starting from 0x000000 memory location.

                       

                      However, this address wrapping does not happen during read operations. It is possible to read the entire flash memory in a single read operation. Therefore, when you read 64 bytes of data (in the fourth step) starting from 0x0001FF memory location you are actually reading the last byte of first page and 63 bytes of data from the next page.

                       

                      Inkedputty_Output_LI.jpg

                      Please note that the starting byte (0x00) of the data being programmed is at the 0x0001FF memory location and the rest of the data starting from 0x01 is programmed starting from 0x000000 memory location.

                       

                      Regards,

                      Apurva

                      • 8. Re: S25FL512S with PSoC6-BLE-Kit
                        user_4600591

                        Okay, so i fix it on my side with only writing in page width.

                        Finally is search for the way to unlock 4Bit Addressing?

                         

                         

                        curretly i tested with:

                             - manipulating cy_smif_memconfig.c

                             - with setting EXTADD bit int the Bank register

                         

                        What is the preferred way to use the full Memory?

                        • 9. Re: S25FL512S with PSoC6-BLE-Kit
                          ApurvaS_36

                          Hi,

                           

                          There are three ways in which extended addressing can be implemented in FL-S devices -

                          The Bank Address Register configuration is as follows -

                          • By default, the EXTADD bit of Bank Address Register (BAR) is set to zero. In this case, all legacy SPI commands expect only 3 bytes of address and the higher order address bits are supplied from the BAR (The default values for these higher order address bits A25 and A24 are also zero as shown in the table above). These A25 and A24 bits can be programmed to some other value (one) using the BRWR (17h) command.
                          • The second configuration is when the EXTADD bit is programmed to one. In this configuration, the A25 and A24 bits are not supplied from the BAR, and all legacy SPI commands expect 4 bytes of address after the command byte.
                          • The third method of addressing is by using the new commands.

                           

                          Let us take READ command as an example to understand this.

                          • 03h command expects 3 bytes of address when EXTADD bit of BAR is set to zero. The higher order address bits are being supplied by the BAR.
                          • 03h command expects 4 bytes of address when EXTADD bit of BAR is set to one. Complete 4 bytes of address need to be provided after the command byte.
                          • 13h command can be used directly followed by 4 bytes of address without making any changes to the BAR.

                           

                          You can choose to implement either of the ways in your application. There is no preferred/recommended way to implement extended addressing as long as correct result is being obtained. If you choose not to perform any programming operation on the BAR then you can edit the cy_smif_memconfig.c file to change the legacy SPI commands to new commands that expect 4 bytes of address. I am attaching the file with my response. Number of address bytes (numOfAddrBytes variable) is also updated to 4.

                          • Read command is changed from EBh to ECh
                          • Sector Erase command is changed from D8h to DCh
                          • Page Program command is changed from 32h to 34h

                           

                          Best Regards,

                          Apurva