This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Spansion S25FL128S SPI flash password programming is not working.

Other Parts Discussed in Thread: AM3352

Hi All,

-> I am using SPI nor flash S25Fl128S(SPANSION) with processor AM3352 using SPI1 interface.

 -> To use SPI1 interface I have did changes in MLO code for providing clocks to SPI1 interface

-> Then, after I am using command sf probe 1:0  (1 = SPI1 bus and 0=CS0) file present at /common/cmd_sf.c file in u-boot code.

-> I am getting response with 16MiB flash is detected.

-> But then after I am writing some data in flash sector1 and reading the data . I am able to do the same.

-> As SPANSION SPI flash having a property that we can lock its sectors using paasword, 

   Thus I am giving command for programme a password there u-boot is hanging.

Functions which I have used for read:

spi_flash_read_cmd

and for write I have used command:

spi_flash_write_cmd.

Please, someone give some directions.

Rgs,

Santosh Rai

  • Hi,

    I suggest you check the flash datasheet for the correct sequence of password programming and check if you are implementing it correctly.
  • Hi Biser,

    I have gone through the datasheet and according to datasheet,

    For programming the password the steps should be as below.

    1. Give command to flash for write enable.

    2. Give command to program password following by 64 bit encrypted password.

    NOTE:

    Here, step two should occur in single CS assertion and de-assertion.

    Password command and 64 bit password should be written in PP register of SPI flash in a single CS activity.

    My code implementation is as mentioned,

    1. Claiming my SPI flash .

    2. Giving command to make SPI flash write enable.

    Function used :

    3. Then after using a function

    spi_flash_cmd_write(flash->spi, cmd (password write command), cmd_len, password buffer, buffer,size);

    This function should is failing to write password in SPI flash.

    4. Then waiting for the SPI flash program time out.

    Might be issue is for below reason,

    Not able to debug this please help.

    Issue 1 :

    I gone through the code flow found that its reaching to omap3_spi_txrx();

    In my code also used function omap3_spi_txrx();

    But then after TX and RX timeout is occurring,

    Issue 2 :

    Is CS is assertion and De-assertion is happening dual time in step 2?

    Rgs,

    Santosh Rai

  • You should check CS assertion/deassertion using an oscilloscope. I think the problem resides with the spi_flash_cmd_write function. If you want to ensure that writing is done within only one CS, you should configure the SPI as described in section 24.3.2.6.2 of the AM335X TRM Rev. M.
  • Hi Biser,

    I have gone through the code and found that I can use spi_xfer(); function for my read and write operation.

    But the issue is that I am able to write some registers and able to read some SPI registers but some registers I am not able to read , Beacuse my SPI_XFER function is failing some times.

    Please help.

  • The password command is 64 bits long from what I remember. The SPI cannot write more than 32 bits in a single transfer. To write 64 bits you need two consecutive transfers without deasserting CS between them. See my previous post for TRM section where this is explained.
  • Hi Biser,

    You are right SPI bus is able to transmit 32 bit at a time .
    But if you give value more that 32 bit it will store in a buffer and then will transfer it.
    Because I was being having an issue of loop, my system was failing because of loop.

    Rgs,
    Santosh