Dynamic, sector protection scheme for SPI based NOR Flash

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Shivam
Level 1
Level 1
5 sign-ins First reply posted First question asked

Hi Team,

In our project we are using the SPI based NOR flash chip as a slave, whose ordering part number is S25FL256SAGMFI000.

As per the datasheet, we can see that there is dynamic sector protection schemes available for each sector(independent to the size of sector). To implement this scheme, we would like to understand the flow to make this protection scheme enable. I am slightly confuse what the DYBAR returns, is it the sector number associated with the protection which it returns or anything else? and if it is the sector number then why only 8-bits are allotted to it; in fact the sector numbers are more considering the 32 4Kb and 510 64Kb sectors.

We are stuck and unable to achieve our ultimate goal which is to -> write some data to the desired sector(4kb or 64kb or both) and then enables the protection for it (in the boot software), so that later though application wanted to modify that sector it will not allow. and then once the protection is enabled how to read the data from that protected sector?

Request you to please suggest some inputs which we have to implement to achieve this protection schemes.

Regards,

Shivam Kakad

0 Likes
1 Solution
Apurva_S
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi Shivam,

Every sector in the main flash array has a volatile dynamic protection bit (DYB) associated with it. When the bit is 0, the sector is protected from program and erase operations. When the bit is 1, the sector is in unprotected state. Even though it is called the dynamic protection 'bit', however, this bit is written to/read from the flash in the form of a one byte data, and DYBAR is the Dynamic Protection Bit Access Register which holds this one byte of data.

Therefore, if the value of DYB Access Register associated with a particular sector is 0x00 it means that the particular register is protected from program and erase operations. And, when the value of DYB Access Register associated with a particular sector is 0xFF then it means that the particular sector is not protected against program or erase operations.

AS_36_0-1612961336289.png

The value of the DYB Access Register associated with any particular register can be read using the DYB Read (0xE0) command.

AS_36_1-1612961447291.png

The DYB Write (0xE1) command can be used to write the desired value to the DYB Access Register.

AS_36_2-1612961538317.png

Please note that this is just a volatile protection scheme.

The process of reading data from a sector always remains same, irrespective of whether it is protected or unprotected. The protection scheme only protects the sector against program and erase. The method used for reading shall remain same.

Let us know if you have more questions.

Thank you and Regards.

View solution in original post

0 Likes
3 Replies
Apurva_S
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi Shivam,

Every sector in the main flash array has a volatile dynamic protection bit (DYB) associated with it. When the bit is 0, the sector is protected from program and erase operations. When the bit is 1, the sector is in unprotected state. Even though it is called the dynamic protection 'bit', however, this bit is written to/read from the flash in the form of a one byte data, and DYBAR is the Dynamic Protection Bit Access Register which holds this one byte of data.

Therefore, if the value of DYB Access Register associated with a particular sector is 0x00 it means that the particular register is protected from program and erase operations. And, when the value of DYB Access Register associated with a particular sector is 0xFF then it means that the particular sector is not protected against program or erase operations.

AS_36_0-1612961336289.png

The value of the DYB Access Register associated with any particular register can be read using the DYB Read (0xE0) command.

AS_36_1-1612961447291.png

The DYB Write (0xE1) command can be used to write the desired value to the DYB Access Register.

AS_36_2-1612961538317.png

Please note that this is just a volatile protection scheme.

The process of reading data from a sector always remains same, irrespective of whether it is protected or unprotected. The protection scheme only protects the sector against program and erase. The method used for reading shall remain same.

Let us know if you have more questions.

Thank you and Regards.

0 Likes
Shivam
Level 1
Level 1
5 sign-ins First reply posted First question asked

Appreciate the quick response, this information actually helped us to understand the protection scheme in better way.

Further I need suggestion on its execution, considering our project requirements.

As per the requirement,

1. write the data to the sector

2. enables the protection such that data will not get altered(either by programming or erasing).

So, as per my understanding i have to perform the following:

1. Select the required sector  for the protection among all the available sectors (selected sector size could be 4KB or 64KB).

2. Issue the WREN command

3. pull the chip select low

4. Program required number of pages with the desired data in the selected sector with 4PP command.

5. after programming the necessary data, issue the DYBWR command followed by the 32-bit address and then 1 data byte as 00; where, the address could be anything but from the selected sector for which the protection has to be enable.

6. pull chip select to high

7. Issue the WRDI command

Is this the correct sequence to follow, to achieve the requirement correctly?

Regards,

Shivam Kakad

0 Likes
Apurva_S
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi Shivam,

The correct sequence of commands is - 

 

  • Select the required sector  for the protection among all the available sectors (selected sector size could be 4KB or 64KB)
  • Drive CS# LOW
  • Send WREN command
  • Drive CS# HIGH

 

  • Drive CS# LOW
  • Send 4PP command
  • Send 32 bit address
  • Send all the required data (byte by byte)
  • Drive CS# HIGH

 

  • Drive CS# LOW
  • Send RDSR1 command
  • Read Status Register 1 value
  • Drive CS# HIGH
  • Check the value of WIP bit. If WIP bit is 1, it indicates program operation is still executing. Keep reading the SR1 value till WIP bit becomes 0

 

  • Drive CS# LOW
  • Send WREN command
  • Drive CS# HIGH

 

  • Drive CS# LOW
  • Send DYBWR command
  • Send 32 bit address  selecting location zero within the desired sector
  • Send data byte (0 for protecting, 1 for unprotecting)
  • Drive CS# HIGH

 

  • Drive CS# LOW
  • Send RDSR1 command
  • Read Status Register 1 value
  • Drive CS# HIGH
  • Check the value of WIP bit. If WIP bit is 1, it indicates program operation is still executing. Keep reading the SR1 value till WIP bit becomes 0

 

Thank you and Regards.

0 Likes