8 Replies Latest reply on Jun 23, 2020 6:10 PM by TeMa_2997106

    Sample code for Advanced sector protection of S25FL512S

    TeMa_2997106

      My customer wants to use Advanced Sector Protection.

       

      I see AN200452.

      I think this matched what they want to do.

       

      Is there sample code to implement this feature?

       

      Thanks,

      Tetsuo

        • 1. Re: Sample code for Advanced sector protection of S25FL512S
          SudheeshK_26

          Hello,

           

          Please download the low level driver for our serial NOR flash devices from the following link, https://www.cypress.com/documentation/software-and-drivers/low-level-driver-spi-flash?source=search&cat=software_tools . You can use it as a reference to write your application.

           

          Thanks and Regards,

          Sudheesh

          • 2. Re: Sample code for Advanced sector protection of S25FL512S
            TeMa_2997106

            Sudheesh-san,

             

            Thank you for your response.

             

            I downloaded it.

            Should I use the function that write(read) ASP register?

             

            Thanks,

            Tetsuo

            • 3. Re: Sample code for Advanced sector protection of S25FL512S
              SudheeshK_26

              Hello,

               

              I am not clear about your query. You can use the low level driver functions to read and write ASP register.

              Which protection method are you planning to use in your application, password or PPB bits? Please provide more details about your requirement.

               

              Thanks and Regards,

              Sudheesh

              • 4. Re: Sample code for Advanced sector protection of S25FL512S
                TeMa_2997106

                Sudheesh-san,

                 

                They want to use password protection.

                Their plan is to implement a function to protect the first 256KB (2 sectors) of the flash with a password (64bit).

                 

                Thanks,

                Tetsuo

                • 5. Re: Sample code for Advanced sector protection of S25FL512S
                  SudheeshK_26

                  Hello,

                   

                  Below are the steps to be followed to enable password protection and protect first two sectors.

                  Enable password protection

                  1. Program password to the flash device (slld_WPWDOp()).

                  2. Read back the password from flash and verify it (slld_PASSRDCmd()).

                  3. Set bit 2 of ASP register to 1 and enable password protection permanently (slld_WASPOp()). Once password protection is selected, you won't be able to read password back and change it.

                   

                  Protect first 2 sectors

                  1. Unlock the PPB lock bit using password unlock command (slld_PASSUCmd()). It will set the PPB lock bit to 1 (not protected state).

                  2. Program PPB bits of first 2 sectors to 0 (slld_PPB_PGOp()).

                  3. Clear PPB lock bit to 0 (protected state) (slld_PLBWRCmd()). Please note, you have to send WREN command before calling slld_PLBWRCmd() function.

                  4. Now, first two sectors will be in protected state.

                   

                  Refer datasheet for more details about above operations and let us know if you need any clarifications.

                   

                  Thanks and Regards,

                  Sudheesh

                  1 of 1 people found this helpful
                  • 6. Re: Sample code for Advanced sector protection of S25FL512S
                    TeMa_2997106

                    Sudheesh-san,

                     

                    Thank you very much.

                     

                    In the same way, please tell me about the operation of Persistent Protection Mode.

                     

                    I can't understand how to use SLLD even after reading AN.

                     

                    And I have another question.

                     

                    The data sheet has the following description:

                    ----------

                     8.4.6 Persistent Protection Mode

                    The Persistent Protection method sets the PPB Lock bit to 1 during POR or Hardware Reset so that the PPB bits are unprotected by a device hardware reset. Software reset does not affect the PPB Lock bit. The PLBWR command can clear the PPB Lock bit to 0 to protect the PPB. There is no command to set the PPB Lock bit therefore the PPB Lock bit will remain at 0 until the next power-off or hardware reset.

                    ----------

                     

                    I understood this:

                    - The PPB Lock bit changes 1 when the power is turned off or reset.

                    - As a result, PPB can be changed to 0 or 1.

                    - If PPB Lock bit = 0 and PPB = 0 in advance,

                      When the power is turned off, PPB Lock bit = 1, but PPB = 0,

                      so the target sector is kept in the rewrite prohibited.

                     

                    Is it correct ?

                     

                    Thanks,

                    Tetsuo

                    • 7. Re: Sample code for Advanced sector protection of S25FL512S
                      SudheeshK_26

                      Hello Tetsuo,

                       

                      You can refer the user guide for the low level driver to get an idea about using our low level driver. It is available under "Cypress_SLLD_v16.2.1\doc" folder.

                       

                      Your understanding about persistent protection method is correct. Persistent protection method is enabled by default, when the bits 1 (PSTMLB - Persistent Protection Mode Lock Bit) and 2 (PWDMLB - Password Protection Mode Lock Bit) are not programmed to 0. Every main flash sector has a non-volatile PPB bit. When PPB bit of a particular sector is programmed to 0, that sector cannot be erased or programmed. The PPB bits are protected from program and erase when the PPB Lock bit is 0.

                       

                      There is no command to change PPB lock bit from 0 to 1. Only a hardware reset or POR can change PPB lock bit from 0 to 1. If you are planning to use persistent protection method, then you should program all the required data to flash first, program PPB bits of the sectors to be protected and then Clear PPB lock bit.

                       

                      You can use below SLLD APIs to use persistent protection method.

                      1. Program data to flash (slld_PPOp()).

                      2. Program PPB bits of the sectors to be protected (slld_PPB_PGOp()).

                      3. Clear PPB lock bit to 0 (protected state) (slld_PLBWRCmd()). Please note, you have to send WREN command before calling slld_PLBWRCmd() function.

                       

                      Also, please note that you cannot change individual PPB bits from 0 to 1. You have to erase all of the PPB bits (slld_PPB_ERSCmd()) and program the required PPB bits to protect the sectors again.

                       

                      Please let me know, if you need any clarifications.

                       

                      Thanks and Regards,

                      Sudheesh

                       

                      1 of 1 people found this helpful
                      • 8. Re: Sample code for Advanced sector protection of S25FL512S
                        TeMa_2997106

                        Sudheesh-san,

                         

                        Thank you for your reply again.

                        I can understand all feature.

                         

                        Thanks,

                        Tetsuo