FLASH Part Cypress S29JL032J In-System Sector Protect Programming

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

cross mob
lock attach
Attachments are accessible only for community members.
MiSw_4385396
Level 1
Level 1

We employ Cypress flash device P/N S29JL032J70TFI310 in our product design. There is application code residing in the bottom-most sector SA0 (0x0000) of the subject device that needs to be protected from inadvertent erasure.

Per the attached Cypress datasheet 002-00857 Rev. *J, paragraph 8.10 (page 22), I can do an in-system sector protect of any flash sector such as SA0.  Implementing this algorithm as depicted in Figure 2. In-System Sector Protect/Unprotect Algorithms (page 24), it appears to be successfully performed as signified by a data value “01h” <Data = 01h?> when any byte location within the boot sector is read back.  However after protecting the boot sector per the algorithm, when I subsequently execute a chip erase command the boot sector is erased with all other sectors.

Is that correct device operation or am I incorrectly implementing or interpreting the sector protect algorithm?  In other words, does the in-system sector protect pertain only to the individual sectors and will not protect those sectors from an inadvertent chip erase command?

Thank you.

0 Likes
11 Replies
SudheeshK
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Hello Mike,

Could you please double check the voltage on RESET# pin while executing sector protection command sequence and sector erase command sequence? Voltage on RESET# pin should be VID during sector protection and VIH during sector erase.

Thanks and Regards,

Sudheesh

0 Likes

Hi Sudheesh,

Thank you for responding to the my question. I’ve been out of town on family leave so I apologize for this late follow-up.

During the sector protect command sequence RESET# is pulled up to 12.0 VDC and then set back to VIH level when sector protect programming completes (sector data read = 01h). The RESET# is at the VIH level during the sector erase too.

Regards,

Mike

0 Likes

Hi Mike,

Could you please tell us the status of the WP#/ACC pin?

If you go to page 12 of the datasheet, Note 4 tells the protection status of the sectors with regards to the voltage on the WP#/ACC pin. Also note that leaving the WP#/ACC pin floating or unconnected might result in inconsistent device behavior.

Best Regards,

Apurva 

0 Likes

Hello Apurva,

I appreciate your response.

The schematic shows WP#/ACC grounded through a resistor and I confirmed by measuring WP#/ACC = VIL , or 0.0 VDC.

I just noticed that I may be incorrectly programming the Sector Protect operation. In the Addresses column of Table 1 on page 12 for the Sector Protect operation gives “SA, A6 = L, A1 = H, A0 = L” . What does A6 = L, A1= H, and A0 =L indicating to do? Do I force those address lines to the levels indicated (L=0, H=1)?

Regards,

Mike

0 Likes

Hi Mike,

Thank you for your reply.

Yes, your understanding of Table 1 is correct. You need to force these lines to the indicated levels.

Best Regards,

Apurva

0 Likes
lock attach
Attachments are accessible only for community members.

Thank you and hello again, Apurva.

Attached is a simplified version of my sector protect source code which I am using with an emulator and the target circuit card (CCA), and a Word doc with a snapshot of the flash memory during the execution of the sector protect algorithm.


I am not having any luck getting the flash to protect or unprotect any sectors in-system. With focus on the sector protect side of Figure 2. In-System Sector Protect/Unprotect Algorithms flow diagram,  after I apply 12VDC to RESET# [RESET# = VID] and then perform the write cycle of 60h first [Sector Protect: Write 60h to sector address with A6 = 0, A1 = 1, A0 = 0], all of the flash memory immediately reflects 0x22f6 (attachment). Note that the base address for flash is 0x90000000.

I then wait for 250us  [Wait 150 μs]  followed by a write cycle of 40h [Verify Sector Protect: Write 40h to sector address with A6 = 0, A1 = 1, A0 = 0], but then when I read the data in that sector [Read from sector address with A6 = 0, A1 = 1, A0 = 0] it is not 01h but still 22f6h.

I re-attempt PLSCNT for 25 more times with no difference in this outcome (I have removed that loop from the attached source code for clarity).

The function flashProtectAllSectors() calls flashProtectSector() for each sector of the flash device. I do program the flash device successfully in every other way without any issues. Does Cypress have any code or a in-system sector protect/unprotect software driver that I can examine and to compare my code implementation?


I downloaded the low level drivers Spansion_pNOR_LLD_15.3.1.zip file from Cypress only to find a comment block section “Following are sector protection driver routines“ at the end of the lo lld_S29JLxxxJ.c source file with no code following the section comment. I've attached that too.

Warm regards,

Mike

0 Likes

Hi Mike,

Apologies for the delay. We were discussing your issue internally. We have found the following issues with the code -

  1. At line#84, the TMP_ADRS should be calculated using sectAdrs8Bit and not using FLASH_START_ADDRESS. You may need to add FLASH_START_ADDRESS to get the physical sector address.
  2. At line#90 and line#102, you should use the previously calculated address in (1) and not simply “sectAdrs8Bit
  3. At line#107, in case you dont read 0x1 during verification, you should try the same procedure up to 25 times before giving up.
  4. We were not able to understand the logic in calculating the sector addresses in lines 28 to 41. You should just double check that its doing the right calculation.

The first two issues are major bugs and this is why sector protection is not working.

Regards,

Apurva

0 Likes

Hi Apurva,

No apologies necessary. I appreciate your patience.

The “sectAdrs8Bit” is the (x8) Address Range’ column of ‘Table 3.
S29JL032J Sector Addresses - Top Boot Devices’ in the datasheet, which is calculated in
lines 28 to 41 of this source code (item 4 of your last reply). I verified the
sectAdrs8bit values are calculated properly using an emulator. I didn’t write
this code but need to work with it as is.

pastedImage_10.png

I’m still not successful with the sector protect in-system programming. Can you please reply with an code example of the
address programming mentioned in your last reply’s items 1 and 2? I’m not quite grasping the intent there. Flash base memory is 0x90000000.

Many thanks!

Mike

0 Likes

Hi Mike,

As suggested in the flowchart in the datasheet, did you try implementing the sector protection algorithm for upto 25 times? If not can you please try doing that?

Regards,

Apurva

0 Likes

Hi Apurva,

I forgot to mention that I did:

                  bProtectSuccess = FALSE;

                  PLSCNT = 26;

                  while( (--PLSCNT > 0)&& (bProtectSuccess == FALSE) )

                  {

                        // Figure 2 - In-System Sector Protect algorithm.

                        bProtectSuccess = flashProtectSector( sectorAddress );             

                  }

From your prior response:

  1. At line#84, the TMP_ADRS should be calculated using sectAdrs8Bit and not using FLASH_START_ADDRESS. You may need to add FLASH_START_ADDRESS to get the physical sector address.
  2. At line#90 and line#102, you should use the previously  calculated address in (1) and not simply “sectAdrs8Bit

Can you please detail these two items? That is for, a Flash start address is 0x90000000 and using the SA3 sector address as an example as per the following datasheet snapshot? And setting address lines Write 60h to sector address with A6 = 0, A1 = 1,A0 = 0.

Thanks you.

Mike

pastedImage_15.png

0 Likes

Hi Mike,

Upon a more thorough code review, we believe that the suggested modifications in my previous response are not required. Sincere apologies for the confusion.

However we have one more suggestion -

  • A0, A1 and A6 are the address bits from the word address and not the byte address.
  • Could you please replace line 84 in the code with the following line and let us know the results :

    Uint32 TMP_ADRS = ((FLASH_START_ADDRESS & (1<<SECT_PROT_A6_A0)) | (1<<SECT_PROT_A1));

Regards,

Apurva

0 Likes