2011-01-03 10:49:59     uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Document created by Aaronwu Employee on Sep 25, 2013
Version 1Show Document
  • View in full screen mode

2011-01-03 10:49:59     uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Ashish Gupta (INDIA)

Message: 97142   

 

Hi,

 

I am using our custom ADSP-BF527 based HW and wish to port u-boot 2010R1 for the same. Since it is very similar architecture to the BF527-Ezkit, I started with the default ezkit settings (/include/configs/bf527-ezkit.h) and it works fine for most part.

 

Major differences:

 

a. VDDEXT = 1.8V so max SCLK cab be 100MHz, hence I changed the default CCLK = 500MHz and SCLK = 100MHz.

 

b. NO NOR FLASH, so removed support for NOR FLASH

 

c. SPI FLASH used is Spansion S25FL128P uniform 256KB / sector version. After modification of the corresponing settings (CONFIG_SPI_FLASH_SPANSION; etc.), the SPI FLASH is detected fine and I am able to use the SF commands to probe, erase, reach, write to the FLASH. Also BOOT OVER SPI FLASH is also working perfectly fine. Tested with cold reboot of HW several times.

 

SF probe command response

 

bfin> sf probe 0:1 20000000 3

SF: Detected S25FL128P_256K with page size 256, total 16 MiB

 

Problems happends when I try to use SAVEENV to store the environment into SPI FLASH, although the command seems to execute fine with following response:

 

bfin> set serverip 192.168.1.8

bfin> set ipaddr 192.168.1.85

bfin> save

Saving Environment to SPI Flash...

Erasing SPI flash...Writing to SPI flash...done

bfin>

 

Next time I reset the HW, I don't see any boot messages on the terminal (seems u-boot gets erased). I have to re-FLASH uboot image. If I don't use the "save" command u-boot boots fine the next time i reset the system.

 

I suspect there is something wrong with my settings in the config file, current settings are as follows:

 

#define CONFIG_ENV_IS_IN_SPI_FLASH

/

#define CONFIG_ENV_OFFSET    0x40000

#define CONFIG_ENV_SIZE        0x2000

#define CONFIG_ENV_SECT_SIZE    0x40000 /* S25FL128P, 256 KB */

#define CONFIG_ENV_SPI_MAX_HZ    20000000

#define CONFIG_ENV_SPI_MODE    SPI_MODE_3

#define CONFIG_ENV_SPI_BUS    0

#define CONFIG_ENV_SPI_CS    1

 

Since the S25FL128P flash has uniform sector sizes of 256 KB, I set CONFIG_ENV_SECT_SIZE = 0x40000 and CONFIG_ENV_OFFSET = 0x40000 to store it at second sector.

 

Any pointers to solve this issue would be helpful. Attached is the modified uboot file /include/configs/bf527-ezkit.h (No other file was changed, uboot version: 2010R1)

 

regards

 

Ashish Gupta

 

modified_bf527-ezkit.h

QuoteReplyEditDelete

 

 

2011-01-03 22:35:06     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Aaron Wu (CHINA)

Message: 97147   

 

Hi,

 

I agree with you, looks like when do saveenv something are ereased unexpectedly, should be related with the config value, could you look into the details to see what's happening, related code in common/env_sf.c, may need to debug if the saveenv function works as wanted with your three config size.

 

Also your MAX_HZ is doubled, no idea if this is OK for the hardware, you may also lower if first and have a try.

QuoteReplyEditDelete

 

 

2011-01-04 10:36:59     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Ashish Gupta (INDIA)

Message: 97166   

 

Hi,

 

1. Changing the speed of course does not make a difference. I had tested all the SF commands with speed = 20000000 Hz for my board. (It actually configures SPI controller for 16.67 MHz and my board works fine at that speed)

 

2. I went through the code in common/sf_env.c. I did a dry run for my initial settings:

 

#define CONFIG_ENV_OFFSET    0x40000

#define CONFIG_ENV_SIZE      0x2000

#define CONFIG_ENV_SECT_SIZE    0x40000 /* S25FL128P, 256 KB */

 

It should work fine for me. But still since the README also STRONGLY DISCOURAGES mixing uboot env and rest of u-boot code in same sector, I proceeded to step 3

 

3. I went through the env_sf.c file. I tried to avoid the "CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE" conditions, since flash is erased on sector boundary and its better that full sector is reserved for the uboot env area so that when it is updated rest of the uboot code need not be copied back and forth . For this I changed the config file and set the sizes as follows:

 

#define CONFIG_ENV_IS_IN_SPI_FLASH

#define CONFIG_ENV_OFFSET    0x40000

#define CONFIG_ENV_SIZE      0x40000

#define CONFIG_ENV_SECT_SIZE    0x40000 /* S25FL128P, 256 KB */

#define CONFIG_ENV_SPI_MODE    SPI_MODE_3

#define CONFIG_ENV_SPI_BUS    0

#define CONFIG_ENV_SPI_CS    1

 

But now uboot fails to boot with following message: -----

 

-------------------------------------------------------------------------------------------------------

 

CPU:   ADSP bf527-0.0 (Detected Rev: 0.2) (spi flash boot)

Board: ADI BF527 EZ-Kit board

       Support: http://blackfin.uclinux.org/

Clock: VCO: 500 MHz, Core: 500 MHz, System: 100 MHz

RAM:   64 MiB

SF: Detected S25FL128P_256K with page size 256, total 16 MiB

DCPLB exception outside of memory map at 0x62400000

 

Ack! Something bad happened to the Blackfin!

 

SEQUENCER STATUS:

SEQSTAT: 00000026  IPEND: 0032  SYSCFG: 4341e270

  HWERRCAUSE: 0x0: undef

  EXCAUSE   : 0x26: dcplb miss

RETE: <0x20805010> { ___umulsi3_highpart + 0x1c8a78d8 }

RETN: <0x03e9fe38> /* unknown address */

RETX: <0x03f5c4d6> { _spi_xfer + 0x13a }

RETS: <0x03f5c4a6> { _spi_xfer + 0x10a }

RETI: <0x03f400d6> { _start + 0xd6 }

DCPLB_FAULT_ADDR: <0x626d6172> { ___umulsi3_highpart + 0x5e778a3a }

ICPLB_FAULT_ADDR: <0x03f5c4d6> { _spi_xfer + 0x13a }

 

PROCESSOR STATE:

R0 : 00006f6f    R1 : 00000060    R2 : 00001801    R3 : 00000001

R4 : 00200000    R5 : 00000001    R6 : 03ea0008    R7 : 00000000

P0 : 03ee0020    P1 : 00001801    P2 : 626d6172    P3 : 03e9ff80

P4 : 00000000    P5 : ffc00dc0    FP : 03ee0010    SP : ffb00f18

LB0: 03f5d6a2    LT0: 03f5d6a2    LC0: 00000000

LB1: 03f5870a    LT1: 03f5870a    LC1: 00000000

B0 : ffb00400    L0 : 00000000    M0 : ffffffff    I0 : 01000000

B1 : 00000000    L1 : 00000000    M1 : 00000000    I1 : 00000000

B2 : 00000000    L2 : 00000000    M2 : 00000000    I2 : 0000000f

B3 : 00000000    L3 : 00000000    M3 : 03f87047    I3 : 0000001b

A0.w: 03621ce0   A0.x: 00000000   A1.w: 00004b83   A1.x: 00000000

USP : ffb00ffc  ASTAT: 00001044

 

Hardware Trace:

   0 Target : <0x03f4113c> { _trap_c + 0x0 }

     Source : <0x03f409c4> { _trap + 0x6c }

   1 Target : <0x03f40958> { _trap + 0x0 }

     Source : <0x03f5c4d4> { _spi_xfer + 0x138 }

   2 Target : <0x03f5c4b8> { _spi_xfer + 0x11c }

     Source : <0x03f5c4a8> { _spi_xfer + 0x10c }

   3 Target : <0x03f5c4a6> { _spi_xfer + 0x10a }

     Source : <0x03f4d5e4> { _ctrlc + 0x3c }

   4 Target : <0x03f4d5de> { _ctrlc + 0x36 }

     Source : <0x03f4d5c6> { _ctrlc + 0x1e }

   5 Target : <0x03f4d5c4> { _ctrlc + 0x1c }

     Source : <0x03f585b2> { _serial_tstc + 0xe }

   6 Target : <0x03f585a4> { _serial_tstc + 0x0 }

     Source : <0x03f4d594> { _tstc + 0xc }

   7 Target : <0x03f4d594> { _tstc + 0xc }

     Source : <0x03f4d58c> { _tstc + 0x4 }

   8 Target : <0x03f4d588> { _tstc + 0x0 }

     Source : <0x03f4d5c0> { _ctrlc + 0x18 }

   9 Target : <0x03f4d5a8> { _ctrlc + 0x0 }

     Source : <0x03f5c4a2> { _spi_xfer + 0x106 }

  10 Target : <0x03f5c4a2> { _spi_xfer + 0x106 }

     Source : <0x03f5c4c2> { _spi_xfer + 0x126 }

  11 Target : <0x03f5c4b8> { _spi_xfer + 0x11c }

     Source : <0x03f5c4a8> { _spi_xfer + 0x10c }

  12 Target : <0x03f5c4a6> { _spi_xfer + 0x10a }

     Source : <0x03f4d5e4> { _ctrlc + 0x3c }

  13 Target : <0x03f4d5de> { _ctrlc + 0x36 }

     Source : <0x03f4d5c6> { _ctrlc + 0x1e }

  14 Target : <0x03f4d5c4> { _ctrlc + 0x1c }

     Source : <0x03f585b2> { _serial_tstc + 0xe }

  15 Target : <0x03f585a4> { _serial_tstc + 0x0 }

     Source : <0x03f4d594> { _tstc + 0xc }

 

### ERROR ### Please RESET the board ###

 

-------------------------------------------------------------------------------------------------------

 

Is this because memory map cannot accomodate such a huge size for the uboot env? What is the way to secure a full sector (sieze = 0x40000 for my flash chip) for u-boot env so that erasures need to happen at sector boundary and no extra code needs to be copied temprarily and restored back (referring to saveenv function of u-boot/common/sf_env.c )

 

regards

 

Ashish

QuoteReplyEditDelete

 

 

2011-01-04 13:14:12     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Wojtek Skulski (UNITED STATES)

Message: 97168   

 

Ashish:

 

in your config I do not see a definition of the SPI flash vendor Spansion. I do not know if it is needed with new U-Boot. It was needed with 2009 tools which I am still using.

 

For whatever it is worth, here are my settings which work under 2009 U-Boot with Numonyx and Windbond chips. Note that I have to choose the proper settings and recompile. If I try to use Windbond settings for Numonyx or vice versa, it does not work. I am am copying the whole section of my config, with comments and everything.

 

/* Serial SPI Flash sector size and chip layout.

* --------------------------------------------

* UBoot is located from 0 to 0x20000 (128kB area).

* Environment starts after uBoot. Env offset = 0x20000 ALWAYS.

* Environment is given one sector, whose size depends on the chip.

* Kernel starts after (uBoot+env). Kernel size < 8MB (as of today).

* JFSS2 starts after (uBoot+env+kernel).

* 8M == 0x800000  16M == 0x1000000

*

* Vendor  chip    size   sector      kernstart kernarea JFSS2

* Winbond W25Q64   8M    4k 0x1000   0x21000   0x7DF000 none

* Numonyx M25P64   8M   64k 0x10000  0x30000   0x7D0000 none

* Winbond W25Q128 16M    4k 0x1000   0x21000   0xFDF000 0x800000

* Numonyx M25P128 16M  128k 0x20000  0x40000   0xFC0000 0x800000

*

* Winbond provides 4kB, 32kB, and 64kB sectors (W25Q64, W25Q128).

* Winbond W25Q128BV does NOT support 128kB sectors.

* The chip support code is in ./drivers/mtd/spi/

*

* Reasonable max environment size 0x1000 = 4096 bytes

* As of Oct/27/2010 only 1100 bytes are used

*/

#define CONFIG_BFIN_SPI

#define CONFIG_SPI_FLASH

#define CONFIG_SPI_FLASH_STMICRO /* Numonyx */

/* define CONFIG_SPI_FLASH_WINBOND */

 

#define CONFIG_ENV_IS_IN_SPI_FLASH

#define CONFIG_ENV_SECT_SIZE    0x10000 /* M25P64 64kB */

/* define CONFIG_ENV_SECT_SIZE  0x01000  W25Q64  4kB */

#define CONFIG_ENV_OFFSET       0x20000 /* 128 kB */

#define CONFIG_ENV_SIZE         0x1000  /* 4096 bytes */

 

/*SCK should be kept reasonable because of reflections*/

#define CONFIG_ENV_SPI_MAX_HZ   15000000

#define CONFIG_SF_DEFAULT_SPEED 15000000

QuoteReplyEditDelete

 

 

2011-01-05 04:15:08     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Ashish Gupta (INDIA)

Message: 97181   

 

Hi,

 

Well I did define the SPANSION vendor (under the section "SPI Settings"), that is very much needed and without that none of the SF commands will work. See my config file here:

 

http://blackfin.uclinux.org/gf/download/forummessage/97142/8722/modified_bf527-ezkit.h

 

I've been basically playing with the 3 size parameters :

 

#define CONFIG_ENV_SECT_SIZE    0x40000 /* S25FL128P 256 kB */

#define CONFIG_ENV_OFFSET       0x40000 /* palce ENV on second sector */

#define CONFIG_ENV_SIZE         0x2000

 

But these do not work, I mean they work but when I execute saveenv, uboot itself gets erased.

 

Regards,

 

Ashish

QuoteReplyEditDelete

 

 

2011-01-05 04:21:17     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Mike Frysinger (UNITED STATES)

Message: 97182   

 

you probably need this fix from upstream:

http://git.denx.de/?p=u-boot.git;a=commit;h=c3cb09207f8765dddc67298b08f1f0796c1b98db

QuoteReplyEditDelete

 

 

2011-01-10 05:51:38     Re: uboot 2010 R1: Issue with saving ENV in SPI FLASH - Spansion 16MB S25FL128P

Ashish Gupta (INDIA)

Message: 97297   

 

Thanks!

 

That was it. Patch solved the issue.

Outcomes