S25FL256S - 4K sector erase/write issue

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

cross mob
Anonymous
Not applicable

Hi,

I am failing to erase 4K sector (cmd: 0x21) at address Flash Address 0x10000 then write (cmd: 0x12) to that same sector. Flash configured such that 4k sectors start at low addresses. I can, however, perform a 64K erase (cmd: 0xdc) at 0x10000 then write sucessfully.

I do need to be able to make use of 4K sectors. Any guidance would be appreciated

Thanks

1 Solution
Anonymous
Not applicable

Hello Sandy,

The desired state of TBPARM must be selected during the initial configuration of the device during system manufacture; before the first program or erase operation on the main flash array. TBPARM must not be programmed after programming or erasing is done in the main flash array.

Thanks,

Krishna.

View solution in original post

0 Likes
14 Replies
Anonymous
Not applicable

Hello Sandy,

Which SPI mode you are operating Single SPI or Quad SPI.

Please provide the values of Status register and configuration when you do 4K sector erase. Did you try any other 4K sectors after 0x10000

say like  2nd (0x11000) or 3rd sector 4-KB sectors (0x12000). In case if you did not try can you please try and let us know your observation.

Do you observe the same issue in the first sector with address 0x0000.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

Hi Krishna,

The contents of status registers SR1 and SR2 are both 0x00 before any erase/write (ie. before write enable written to FLASH). The configuration register CR1 is set to 0x02.

I had intended reserving 0x0000 to 0x1000 for later development ...... so am not currently using this address space.

I tried erasing/writing to 0x11000 but unfortunately this did not work either

Thanks

0 Likes
Anonymous
Not applicable

Hello Sandy,

CR1 value 0x02 implies that the device in quad mode. So I assume your Master SPI controller also will be in quad mode.

The command  for 4K sector erase needs to be sent in  single SPI mode. So the SPI controller i.e master needs to send the command in single SPI mode i.e command bits should go on SI line only.

If it is in quad mode it will ignore. So please switch to single SPI while erasing and back to quad mode for programming and reading.

Please try the above and let me know if you are able to erase.

In case if the erase did not work please perform PPB read ( command : E2h ).The instruction E2h followed by the 32-bit address selecting location zero within the desired sector in your case it is 0x10000 and let us know the value.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

Hello Sandy,

Can you please tell the full part number and send us top side of the device showing the part number and date code.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

Hi Krishna,

The part number is S25FL256SAGBHI20, taken from assembly schedule ..... I am sorry but I do not have magnifying equipment (as currenlty working remote form office) to check actual type and date code on IC.

I've  tried programming configuration register by sending 2 bytes, {0x01, 0x00}, but readback shows the confguration register is not changing, remaining at 0x02. I clearly don't understand interface. Is there C reference source code that I could refer to for interfacing with this FLASH?

Contents of 0xE2 were "0xff, 0xff, 0xff, 0x00"

Do I have to go into SPI for erasing 64K sector as well?

Thank you

0 Likes
Anonymous
Not applicable

Hi sandy,

Can you let me know what is the sector addresses provided along with 0xE2 command. 0xFF sows the sector is unprotected and 0x00 shows the sector is protected. So I would like to know which sector addresses are provided along with E2.

If you want to write in to configuration register you need to use WRR command followed by 0x00 and then the byte which you want to write in to CR register. WREN has to be issued before WRR.

Below is the sequence :

1.WREN

2.WRR

3.0x00

4.0x "XX" ( which ever you wish to write in to CR register ).

You can refer section 9.3.7 page 77 in datasheet.

Please note that if you try to write to OTP bits it will throw an error. Also don't try to write to last bit which is freeze bit.

For erasing 64K sector also it has to be in SPI mode. All the commands should be used in Single IO mode.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

Thank you Krishna,

I think I am reliably erasing the FLASH now. When debugging my code I was using the 0x13 read command, where I write 0x13 followed by 4 bytes of address. I would then expect the data read to begin appearing after the last address byte is written. However, I appear to be reading 3 dymmy bytes before the data starts. Is this correct?

0 Likes
Anonymous
Not applicable

Hello Sandy,

Q) However, I appear to be reading 3 dummy bytes before the data starts. Is this correct?

A) No it is not expected. You data should appear. Please let me know what is the data you wrote and what is the data you are observing.

Are you observing the issue after every read. Did you try at different addresses.

Glad to here that the erase is working. Please let me know what exactly was going wrong before.

I suggest you to program incrementing data of 10 bytes and try to read it back and let me know what you are observing.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

Hi Krishna,

In my test I intially erase FLASH sector and readback. This is what I get back reading (using 0x13 command) from start of sector:

          rdBuf[] = {3, 0, 0, 0, 0, 0, 0, 0,0xff,0xff,0xff .........................

I then program the FLASH with:

          dataArray[1024] = {1,0xff, 0xff, 0xff, 0xff, 2, 0xff, 0xff, oxff, 0xff, 3, 0xff, 0xff, oxff, 0xff, 4, ...................

ie. each 5th position is filled with an incementing value starting at 1 at dataArray[0]

I read back the following:

     rdBuf[] = {0x3,0,0,0,0,0,0,0,1,0xff, 0xff, oxff, 0xff, 2, 0xff, 0xff, oxff, 0xff, 3, 0xff, 0xff, oxff, 0xff, 4, ............0xff, 0 (@rdBuf[1029]), 0,0,0......

2 things concern me are why are the dummy bits there at the start of read and why cannot I read the last bytes I program into FLASH.

I get same thing at other address

Thanks

0 Likes
Anonymous
Not applicable

Hello Sandy,

Can you attach your code so that I can review and suggest what could be going wrong.

Thanks,

Krishna.

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

Hi Krishna,

Please see attached

Thanks

0 Likes
Anonymous
Not applicable

Hello Sandy,

I have gone through your code. In the QspiFalsh_rd function you are calling " XQspiPs_PolledTransfer". why are you sending numbytes + 5 as one of the parameters for the function . Can you please remove +5  and check if you see the same issue.

Thanks,

Krishna.

0 Likes
Anonymous
Not applicable

HI Krishna,

"XQspiPs_PolledTransfer" is a manufacturer API. The "+5" in the argument accounts for the inclusion of read command byte and 4 address bytes, which must be included .......... I suspect the API may have a bug? I am using an alternate API call, which gives me what I now expect. I am now erasing, writing and reading back successfully .... thank you for guidance re. this.

I would like to set up the FLASH with the 4K sectors at the top address range as opposed to the delivered default FLASH state of the 4K addresses at the bottom. Is it possible for me to change this (via configuration register) when data has already been blown into FLASH at the lower adresses (following board aseembly)?

Thank you

0 Likes
Anonymous
Not applicable

Hello Sandy,

The desired state of TBPARM must be selected during the initial configuration of the device during system manufacture; before the first program or erase operation on the main flash array. TBPARM must not be programmed after programming or erasing is done in the main flash array.

Thanks,

Krishna.

0 Likes