2009-05-01 12:16:53     U-boot on a custom BF527 board

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

2009-05-01 12:16:53     U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73511   

Hi,

 

I'm trying to port it for a BF527 board.

That's the output:

 

U-Boot 2009.03 (ADI-2009R2-pre) (May 01 2009 - 16:55:58)

 

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

Board: ADI BF527 AD7160 EVAL board

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

Clock: VCO: 528 MHz, Core: 528 MHz, System: 132 MHz

RAM:   32 MB

Flash:  4 MB

*** Warning - bad CRC, using default environment

 

In:    serial

Out:   serial

Err:   serial

Hit any key to stop autoboot:  0

 

I try to saveenv, but it doesn't work:

bfin> saveenv

Saving Environment to SPI Flash...

Environment SPI flash not initialized

 

Then I check the SPI flash:

bfin> sf probe 1 10000000 3

4096 KiB M25P32 at 0:1 is now current device

 

saveenv still doesn't work:

bfin> saveenv

Saving Environment to SPI Flash...

Environment SPI flash not initialized

 

The environment settings are:

/*

* Env Storage Settings

*/

#define CONFIG_ENV_IS_IN_SPI_FLASH

#define CONFIG_ENV_SPI_MAX_HZ    30000000

#define CONFIG_ENV_SPI_CS       1

/* env after the U-boot*/

#define CONFIG_ENV_OFFSET        0x40000

/* one sector for env */

#define CONFIG_ENV_SIZE            0x2000

#define CONFIG_ENV_SECT_SIZE    0x10000

//#define ENV_IS_EMBEDDED_CUSTOM

 

As the U-boot occupy the address space from offset 0 to 0x30000, I want to set my env. variable space at offset 0x40000. The sector size for M25P32 flash is 64k (0x10000).

I tried also to embedd the variables in the U-boot (#define ENV_IS_EMBEDDED_CUSTOM) but the result was the same.

 

What I'm doing wrong here?

 

...and one more thing I noticed during the build:

Building with #define ENV_IS_EMBEDDED_CUSTOM

 

When I change CONFIG_ENV_OFFSET  it is not applied on the next make, but on the second, i.e.

CONFIG_ENV_OFFSET was 0x10000 and I've changed it to 0x20000

make clean

make (first time)

<snip> cpu/blackfin/initcode.o --punchit $((0x10000)):$((0x2000))  <snip>  <-- old value

make (second time)

<snip> cpu/blackfin/initcode.o --punchit $((0x20000)):$((0x2000))  <snip> <-- new value

 

Best regards,

Nikolay

QuoteReplyEditDelete

 

 

2009-05-01 12:21:09     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73512   

... one more thing...

the silicon seems to be a rev.0.2

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

,so I've changed the

#define CONFIG_BFIN_CPU             bf527-0.0

to

#define CONFIG_BFIN_CPU             bf527-0.2

...and the U-boot stop working...

 

 

QuoteReplyEditDelete

 

 

2009-05-01 14:38:55     Re: U-boot on a custom BF527 board

Robin Getz (UNITED STATES)

Message: 73515   

 

Nikolay:

 

What version of toolchain are you using?

 

-Robin

QuoteReplyEditDelete

 

 

2009-05-01 15:03:49     Re: U-boot on a custom BF527 board

Robin Getz (UNITED STATES)

Message: 73516   

 

Nikolay:

 

>When I change CONFIG_ENV_OFFSET  it is not applied on the next make, but on the second,

 

This is a known issue about how the board config file propagates to the make system. Either run make twice, or run "make clean" (I can't remember off the top of my head if it was clean or distclean).

 

As for the SPI flash - did you look at the other boards which use SPI?

 

That message comes from:common/env_sf.c

 

        if (!env_flash) {

                puts("Environment SPI flash not initialized\n");

                return 1;

        }

 

 

static struct spi_flash *env_flash;

 

It looks like there are some shortcuts in env_relocate_spec() which always prints out the same on all error conditions. A few extra puts in there when the different errors might be helpful - to see if it is a real bad CRC or if the call to spi_flash_probe is failing...

 

I compiled this - but didn't try it out.Index: common/env_sf.c

===================================================================

--- common/env_sf.c     (revision 1849)

+++ common/env_sf.c     (working copy)

@@ -119,18 +119,25 @@

void env_relocate_spec(void)

{

        int ret;

+       char buf[35]="*** Warning - ";

 

        env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,

                        CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);

-       if (!env_flash)

+       if (!env_flash){

+               buf[13]="SPI probe failed";

                goto err_probe;

+       }

 

        ret = spi_flash_read(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr);

-       if (ret)

+       if (ret) {

+               buf[13]="SPI read failed";

                goto err_read;

+       }

 

-       if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc)

+       if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) {

+               buf[13]="bad CRC";

                goto err_crc;

+       }

 

        gd->env_valid = 1;

 

@@ -141,7 +148,7 @@

        env_flash = NULL;

err_probe:

err_crc:

-       puts("*** Warning - bad CRC, using default environment\n\n");

+       printf("%s, using default environment\n\n",buf);

 

        if (default_environment_size > CONFIG_ENV_SIZE) {

                gd->env_valid = 0;

 

 

That should help figure out what is going on.

 

-Robin

 

 

QuoteReplyEditDelete

 

 

2009-05-02 16:33:40     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73526   

 

Hi Robin,

 

I downloaded the latest from the website ... it should be 2009R1_RC5. I'll check that for sure in tuesday.

The host machine is RadHat Enterprise Linux 4 64bit.

 

Best regards,

Nikolay

 

 

 

QuoteReplyEditDelete

 

 

2009-05-02 16:46:29     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73527   

 

Robin:

 

Yes, I looked at other boards with SPI, but I'm a little bit confused... On BF527 EZKIT (and othe boards) the sector size is 0x4000, but there is M25P16 SPI FLASH on it, which sector is 64k. In other site there are boards with the same flash with secgtor size 0x10000. I supposed that the metrics for these sizes is different, so I tried different values - the result is the same. Now I assume that the value for these defines should be in bytes. Is that correct?

 

Thank you for the suggestion! I'll test it on the next working day.

 

Best regards,

Nikolay

 

 

 

QuoteReplyEditDelete

 

 

2009-05-04 23:02:05     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73603   

 

it's probably wrong on the BF527-EZKIT (i'll double check it).  but for other boards which dont have a dedicated part hooked up (like the bf537-ezkit), the size really doesnt matter since it needs to be changed for whatever SPI part actually gets hooked up.

QuoteReplyEditDelete

 

 

2009-05-05 01:36:26     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73606   

 

btw you should also fix the offset so that it starts at the sector boundary

QuoteReplyEditDelete

 

 

2009-05-05 04:08:20     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73622   

Hi Robin,

 

The toolchain version is:

ADI-09r1-5

Thread model: posix

gcc version 4.1.2 (ADI svn)

The host PC is:

Red Hat Enterprise Linux WS 4 (Nahant Update 6) 2.6.9-67.EL  (64 bit)

 

Regards,

Nikolay

QuoteReplyEditDelete

 

 

2009-05-05 09:13:56     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73661   

... it seems the SPI FLASH is not recognized correctly...

 

bfin> LMNOPQST>

Early:start.S: Init Registers

Early:start.S: Find ourselves

Early:start.S: Lower to 15

Early: Board init flash

Early: Init CPLB tables

Early: Exceptions setup

Early: Turn on ICACHE

Early: Turn on DCACHE

Early: Init global data

Early: IRQ init

Early: Environment init

Early: Baudrate init

Early: Serial init

Early: Console init flash

Early: End of early debugging

 

 

U-Boot 2009.03 (ADI-2009R2-pre) (May 05 2009 - 14:00:45)

 

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

Board: ADI BF527 AD7160 EVAL board

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

Clock: VCO: 528 MHz, Core: 528 MHz, System: 132 MHz

RAM:   32 MB

Flash: flash detect cfi

fwc addr 20000000 cmd f0 f0 8bit x 8 bit

fwc addr 20000000 cmd ff ff 8bit x 8 bit

fwc addr 20000055 cmd 98 98 8bit x 8 bit

is= cmd 51(Q) addr 20000010 is= ff 51

fwc addr 20000555 cmd 98 98 8bit x 8 bit

is= cmd 51(Q) addr 20000010 is= ff 51

fwc addr 20000000 cmd f0 f0f0 16bit x 8 bit

fwc addr 20000000 cmd ff ffff 16bit x 8 bit

fwc addr 200000aa cmd 98 9898 16bit x 8 bit

is= cmd 51(Q) addr 20000020 is= 0051 5151

fwc addr 20000aaa cmd 98 9898 16bit x 8 bit

is= cmd 51(Q) addr 20000020 is= 0051 5151

fwc addr 20000000 cmd f0 00f0 16bit x 16 bit

fwc addr 20000000 cmd ff 00ff 16bit x 16 bit

fwc addr 200000aa cmd 98 0098 16bit x 16 bit

is= cmd 51(Q) addr 20000020 is= 0051 0051

is= cmd 52(R) addr 20000022 is= 0052 0052

is= cmd 59(Y) addr 20000024 is= 0059 0059

device interface is 2

found port 2 chip 2 port 16 bits chip 16 bits

00 : 51 52 59 02 00 40 00 00 00 00 00 27 36 b5 c5 04  QRY..@.....'6...

10 : 00 0a 00 04 00 03 00 16 02 00 00 00 02 07 00 20  ...............

20 : 00 3e 00 00 01 00 00 80 00 3e 00 00 01 00 ea 01  .>.......>......

fwc addr 20000000 cmd f0 00f0 16bit x 16 bit

fwc addr 20000aaa cmd aa 00aa 16bit x 16 bit

fwc addr 20000554 cmd 55 0055 16bit x 16 bit

fwc addr 20000aaa cmd 90 0090 16bit x 16 bit

fwc addr 20000000 cmd f0 00f0 16bit x 16 bit

fwc addr 200000aa cmd 98 0098 16bit x 16 bit

manufacturer is 2

manufacturer id is 0x20

device id is 0x2257

device id2 is 0x0

cfi version is 0x3130

size_ratio 1 port 16 bits chip 16 bits

found 2 erase regions

erase region 0: 0x00200007

erase_region_count = 8 erase_region_size = 8192

erase region 1: 0x0100003e

erase_region_count = 63 erase_region_size = 65536

fwc addr 20000000 cmd f0 00f0 16bit x 16 bit

4 MB

flash_protect ON: from 0x20000000 to 0x200BFFFF

flash_is_busy: 0

protect on 0

flash_is_busy: 0

protect on 1

flash_is_busy: 0

protect on 2

flash_is_busy: 0

protect on 3

flash_is_busy: 0

protect on 4

flash_is_busy: 0

protect on 5

flash_is_busy: 0

protect on 6

flash_is_busy: 0

protect on 7

flash_is_busy: 0

protect on 8

flash_is_busy: 0

protect on 9

flash_is_busy: 0

protect on 10

flash_is_busy: 0

protect on 11

flash_is_busy: 0

protect on 12

flash_is_busy: 0

protect on 13

flash_is_busy: 0

protect on 14

flash_is_busy: 0

protect on 15

flash_is_busy: 0

protect on 16

flash_is_busy: 0

protect on 17

flash_is_busy: 0

protect on 18

spi_setup_slave: bus:0 cs:1 mmr:ffc00500 ctl:5c01 baud:2 flg:0

spi_claim_bus: bus:0 cs:1

spi_xfer: bus:0 cs:1 bitlen:8 bytes:1 flags:1

spi_cs_activate: SPI_FLG:fd02

spi_xfer: tx:9f rx:ff

spi_xfer: bus:0 cs:1 bitlen:40 bytes:5 flags:2

spi_xfer: tx:0 rx:a0

spi_xfer: tx:0 rx:20

spi_xfer: tx:0 rx:16

spi_xfer: tx:0 rx:10

spi_xfer: tx:0 rx:0

spi_cs_deactivate: SPI_FLG:ff02

spi_cs_deactivate: SPI_FLG:ff00

SF: Got idcode a0 20 16 10 00

SF: Unsupported manufacturer A0

spi_release_bus: bus:0 cs:1

*** Warning - SPI probe failed, using default environment

 

MSTAT:0x100 FSTAT:0x0 ISTAT:0x00        i2c_init            :236: CONTROL:0x008d

CLKDIV:0x6666

In:    serial

Out:   serial

Err:   serial

gd: 1e9ff80

|-flags: 3

|-board_type: 0

|-baudrate: 57600

|-have_console: 1

|-ram_size: 0

|-reloc_off: 0

|-env_addr: 1ea000c

|-env_valid: 1

|-jt(1eda898): 1f4b4d4

\-bd: 1e9ffa8

   |-bi_baudrate: e100

   |-bi_ip_addr: 0

   |-bi_boot_params: 0

   |-bi_memstart: 0

   |-bi_memsize: 2000000

   |-bi_flashstart: 20000000

   |-bi_flashsize: 400000

   \-bi_flashoffset: 0

### main_loop entered: bootdelay=5

 

### main_loop: bootcmd="mmcinit"

Hit any key to stop autoboot:  0

bfin>

 

The 'manufacturer ID' is correct when it is get by the CFI driver, but with the blackfin spi driver returns 0xA0...

 

QuoteReplyEditDelete

 

 

2009-05-05 09:23:27     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73662   

 

the first id you quote is from the CFI parallel nor flash and has nothing to do with the SPI flash

 

what spi flash are you using ?  there is no driver for whatever 0xA0 is ...

 

you should also try doing `sf probe` manually to see if you get the same results

QuoteReplyEditDelete

 

 

2009-05-05 09:51:08     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73664   

 

Hi Mike,

 

the sf probe was OK, but I ran it @ 10MHz. It seems that

 

CONFIG_ENV_SPI_MAX_HZ    30000000 is too high. I've got this from BF527 EZKIT as the Flash on this board is similar - M25P32 (it is M25P16 on the BF527 EZKIT). Setting lower frequency (CONFIG_ENV_SPI_MAX_HZ    20000000) makes the things working!

 

It's a little bit strange why it doesn't work @ 30 MHz, as the datasheet says ...for read instruction up to 33 MHz...

 

However it works for now on this board. I didn't tested on the EZKIT as there is a HW problem on my board and I cannot access the SPI flash, but it is interesting if it is working on the EZKIT also...

 

Other env settings for this boards are:

 

#define CONFIG_ENV_IS_IN_SPI_FLASH

#define CONFIG_ENV_SPI_MAX_HZ    20000000

#define CONFIG_ENV_SPI_CS       1

#define CONFIG_ENV_OFFSET        0x30000

#define CONFIG_ENV_SIZE            0x2000

#define CONFIG_ENV_SECT_SIZE    0x10000

QuoteReplyEditDelete

 

 

2009-05-05 10:00:47     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73665   

 

i tested the current bf527-ezkit spi config and it worked fine

 

U-Boot 2009.03-00199-gc2a678b-dirty (ADI-2009R2-pre) (May 05 2009 - 01:27:08)

 

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

Board: ADI BF527 EZ-Kit board

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

Clock: VCO: 525 MHz, Core: 525 MHz, System: 131.250 MHz

RAM:   64 MB

Flash:  4 MB

SF: Got idcode 20 20 15 10 05

SF: Detected M25P16 with page size 256, total 2097152 bytes

QuoteReplyEditDelete

 

 

2009-05-05 14:32:33     Re: U-boot on a custom BF527 board

Robin Getz (UNITED STATES)

Message: 73687   

 

Nikolay:

 

It could be a hardware problem (missing, too small/too big of a pull up).

 

See:

 

https://docs.blackfin.uclinux.org/doku.php?id=hw:checklist#spi_interface

 

-Robin

QuoteReplyEditDelete

 

 

2009-05-05 14:32:53     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73688   

...maybe it works as the sector index is not used and doesn't matter what is the sector size. Maybe any size multiple of 2 will work for this type of access.

According the datasheet the sector size is 0x10000, and the VDSP flash tool says that.

I can't think of scenario when the wrong sector size can affect anything... Even for sector erase command, the datasheet says that eny address inside the sector will work (for this particular flash).

 

QuoteReplyEditDelete

 

 

2009-05-05 16:21:31     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73699   

 

i dont really know what you're talking about.  the initial SPI check that is done at boot does not involve erasing at all.  the board probes the SPI flash (asks it for its JEDEC ID) and then does a read of the environment.

QuoteReplyEditDelete

 

 

2009-05-06 03:54:27     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73730   

 

I'm talking about the SPI Flash sector size. For BF527 EZKIT it seems that it is not as per M25P16 datasheet...

QuoteReplyEditDelete

 

 

2009-05-06 03:56:28     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73731   

 

Robin:

 

You are maybe right. It could be the hardware issue, as the serial flash is not on the same board with BF527. There are long tracks, connectors, etc. between. Most probably that's the reason I have to slow down the speed.

 

Regards,

 

Nikolay

QuoteReplyEditDelete

 

 

2009-05-06 05:53:44     Re: U-boot on a custom BF527 board

Mike Frysinger (UNITED STATES)

Message: 73743   

 

as i said earlier, ive fixed that in latest svn

QuoteReplyEditDelete

 

 

2009-05-06 12:35:53     Re: U-boot on a custom BF527 board

Nikolay Chokoev (IRELAND)

Message: 73777   

 

I've missed that... I'm sorry!

 

Thanks!

 

Regards,

 

Nikolay

Attachments

    Outcomes