2010-11-04 13:54:46     MTD Partitions and flash_erase on BF527

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

2010-11-04 13:54:46     MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95569   

 

We're in the progress of migrating from the BF536 to the BF527. So far everything is going well, but I cannot seem to erase the partition on the parallel flash where I store the uImage.

 

 

 

Using an older and modified version of 2009R1, I was able to erase about 30% of the flash before it would stall. I'm running from the trunk now (with a trunk toolchain) and I get "Permission Denied" when trying to erase the partition.

 

 

 

I am able to unprotect and erase the relevant blocks of flash via u-boot.

 

This is custom hardware, all of the CPU and flash layouts are as per the 527 EZKit v2 reference design. We do have a m25p128 serial flash instead of m25p16. I haven't created a custom board resource file yet, but I don't think that the serioal flash would affect anything since those partitions are created after the partitions on the parallel flash.

 

My boot args from u-boot are:

 

root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial,uart1,57600 console=tty0 console=ttyBF1,57600 mtdparts=physmap-flash.0:256k(uboot)ro,3712k(uImage)rw

 

 

 

The boot console:

 

2 cmdlinepart partitions found on MTD device physmap-flash.0

Creating 2 MTD partitions on "physmap-flash.0":

0x000000000000-0x000000040000 : "uboot"

0x000000040000-0x0000003e0000 : "uImage"

m25p80 spi0.1: found m25p128, expected m25p16

m25p80 spi0.1: m25p128 (16384 Kbytes)

Creating 2 MTD partitions on "m25p80":

0x000000000000-0x000000040000 : "bootloader(spi)"

0x000000040000-0x000001000000 : "linux kernel(spi)"                                                                                                                                                            

 

 

 

root:/> ls /dev/mtd*

/dev/mtd0       /dev/mtd1ro     /dev/mtd3       /dev/mtdblock1

/dev/mtd0ro     /dev/mtd2       /dev/mtd3ro     /dev/mtdblock2

/dev/mtd1       /dev/mtd2ro     /dev/mtdblock0  /dev/mtdblock3

 

 

 

root:/> flash_erase /dev/mtd1 0 0

flash_erase: error!: /dev/mtd1

             error 13 (Permission denied)

 

 

I've attached my kernel and distro config files. Hopefully I'm just missing something obvious since this did work for us with the 536.

 

kernel.config

distro.config

QuoteReplyEditDelete

 

 

2010-11-08 20:10:21     Re: MTD Partitions and flash_erase on BF527

Mike Frysinger (UNITED STATES)

Message: 95659   

 

first, fix your platform resources.  the boot message already warned you:

m25p80 spi0.1: found m25p128, expected m25p16

 

did you run `flash_unlock` first on /dev/mtd1 ?  otherwise, the mtd kconfig has verbose options you can enable and then review the `dmesg` output.

 

your partition size seems a little weird.  why stop mtd1 at 0x3e0000 ?  are you using the last sector for some info and you just arent exposing it to linux ?

QuoteReplyEditDelete

 

 

2010-11-11 12:39:30     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95779   

 

I was trying to run a "virgin" build, so to speak, to make sure that I didn't introduce any problems. That's why I hadn't modified the resource file to use the larger serial flash. If I remove the serial flash from the kconfig, I get the same results.

 

 

 

The partition sizes are a bit odd. Yes, the last sector is reserved and unused by linux.

 

 

 

With both the current trunk and latest 2009R1 branches I get the following while running flash_unlock:

 

 

 

root:/> flash_unlock /dev/mtd1

Could not unlock MTD device: /dev/mtd1

root:/> flash_unlock /dev/mtd2

Could not unlock MTD device: /dev/mtd2

root:/> flash_unlock /dev/mtd3

Could not unlock MTD device: /dev/mtd3

root:/> flash_unlock /dev/mtd4

Could not unlock MTD device: /dev/mtd4

 

 

I'm using the "unlock" application from "MTD utils."

 

 

 

I'm rebuilding now with verbose debug info on MTD.

QuoteReplyEditDelete

 

 

2010-11-11 12:58:34     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95780   

 

2009R1 kernel, distro and u-boot all pulled from git with verbose MTD output enabled :

 

(the verbose output clobbered my console, so this is what dmesg reports)

 

 

 

flash_unlock /dev/mtd1

 

MTD_open

MTD_ioctl

MTD_ioctl

MTD_close

 

 

flash_eraseall /dev/mtd1

 

MTD_open

MTD_ioctl

MTD_ioctl

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00020000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00030000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00040000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00050000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00060000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00070000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00080000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00090000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000a0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000b0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000c0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000d0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000e0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000f0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00100000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00110000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00120000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00130000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00140000

MTD do_erase_oneblock(): software timeout

 

 

That went on for about 5 minutes before I gave up and ^c'd the application.

 

I dumped the flash and it was erased up until offset 0x00100000.

QuoteReplyEditDelete

 

 

2010-11-12 17:04:44     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95806   

 

I updated my tool chain (git commit 0c908924fa8c513e28eb5b799e35cec1378d9b11), u-boot, (git commit 62c5312d4639a0303541dbccc5f950dd76896b60), kernel (git commit c471e794257e7cc8ef36c089a8df6556ee16a016), and distro (git commit 0d33603ba94810cfa6801c172f65d3e12dab9975).

 

 

 

u-boot boot args:

 

root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial,uart1,57600 console=tty0 console=ttyBF0,57600 mtdparts=physmap-flash.0:256k(uboot)ro,3712k(uImage),64k(defconf),64k(conf)

 

 

 

Boot messages:

 

cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. (clue?)

4 cmdlinepart partitions found on MTD device physmap-flash.0

Creating 4 MTD partitions on "physmap-flash.0":

0x00000000-0x00040000 : "uboot"

mtd: Giving out device 0 to uboot

0x00040000-0x003e0000 : "uImage"

mtd: Giving out device 1 to uImage

0x003e0000-0x003f0000 : "defconf"

mtd: Giving out device 2 to defconf

0x003f0000-0x00400000 : "conf"

mtd: Giving out device 3 to conf

 

 

flash_unlock output:

 

MTD_open

MTD_ioctl

MTD_ioctl

MTD_close

 

 

flash_eraseall output:

 

MTD_open

MTD_ioctl

MTD_ioctl

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00040000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00050000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00060000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00070000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00080000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00090000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000a0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000b0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000c0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000d0000

MTD_ioctl                              

 

MTD do_erase_oneblock(): ERASE 0x000e0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x000f0000

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00100000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00110000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00120000

MTD do_erase_oneblock(): software timeout

MTD_ioctl

MTD do_erase_oneblock(): ERASE 0x00130000

MTD do_erase_oneblock(): software timeout

MTD_close (after CTRL^C)

 

QuoteReplyEditDelete

 

 

2010-11-14 23:00:18     Re: MTD Partitions and flash_erase on BF527

Sonic Zhang (CHINA)

Message: 95837   

 

Looks like only the first 1Mbyte Async bank0 is connect properly to your NOR flash chip. Could you check if the AMS1 to AMS3 is connect properly to the flash chip.

QuoteReplyEditDelete

 

 

2010-11-15 11:07:18     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95858   

 

I'll double check, but I am able to erase the partition with u-boot.

QuoteReplyEditDelete

 

 

2010-11-15 13:12:04     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95860   

 

The flash is connected correctly.

 

I also experience the same problem on the EZ-KIT board.

QuoteReplyEditDelete

 

 

2010-11-15 15:46:06     Re: MTD Partitions and flash_erase on BF527

Mike Frysinger (UNITED STATES)

Message: 95868   

 

please run `make bugreport` with the setup that reproduces the problem on the bf527-ezkit and post the tarball as an attachment

 

also describe the exact versions of software you're using for that so we can reproduce

QuoteReplyEditDelete

 

 

2010-11-15 18:20:35     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95869   

 

Trunk Toolchain:

 

Built from git commit 0c908924fa8c513e28eb5b799e35cec1378d9b11 Tue Nov 9 10:39:11 2010 +0000

 

cameron@camlinux:~$ bfin-uclinux-gcc --version

bfin-uclinux-gcc (ADI-trunk/git-0c90892) 4.3.5

 

 

 

Trunk Distro:

 

git commit 0d33603ba94810cfa6801c172f65d3e12dab9975 Thu Nov 11 09:01:31 2010 +0000

 

 

 

Trunk Kernel:

 

git commit c471e794257e7cc8ef36c089a8df6556ee16a016 Fri Nov 12 05:54:32 2010 +0000

 

 

 

Trunk u-boot::

 

git commit 62c5312d4639a0303541dbccc5f950dd76896b60 Mon Oct 25 21:40:00 2010 +0000

 

 

 

Kernel config, distro config, and bug report are attached.

 

bugreport.tar.gz

kernel.config

distro.config

QuoteReplyEditDelete

 

 

2010-11-17 21:47:56     Re: MTD Partitions and flash_erase on BF527

Sonic Zhang (CHINA)

Message: 95933   

 

Could you try "flash_eraseall -j /dev/mtd1" instead?

 

We can't replicate your problem with 2010R1 release on bf527-ezkit v2. 2009R1 release doesn't support bf527-ezkit v2.

 

In addition, don't use SVN trunk by now. There is a lot of kernel update after 2010R1 code freeze and we have never running test against SVN trunk since then.

QuoteReplyEditDelete

 

 

2010-11-18 16:39:46     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95958   

 

Using 2010R1 on the ezkit

 

 

 

Kernel command line: root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial,uart1,57600 console=tty0 console=ttyBF1,57600 mtdparts=physmap-flash.0:128k(uboot)ro,3840k(uImage),64k(defconf),64k(conf) ip=f...

 

 

 

<snip>

 

physmap platform flash device: 00400000 at 20000000

physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank

Amd/Fujitsu Extended Query Table at 0x0040

number of CFI chips: 1

4 cmdlinepart partitions found on MTD device physmap-flash.0

Creating 4 MTD partitions on "physmap-flash.0":

0x000000000000-0x000000020000 : "uboot"

0x000000020000-0x0000003e0000 : "uImage"

0x0000003e0000-0x0000003f0000 : "defconf"

0x0000003f0000-0x000000400000 : "conf"

 

 

<snip>

 

 

 

root:/> flash_eraseall -j /dev/mtd1

Erasing 64 Kibyte @ e0000 -- 23 % complete. Cleanmarker written at d0000.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ f0000 -- 25 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 100000 -- 26 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 110000 -- 28 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 120000 -- 30 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 130000 -- 31 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 140000 -- 33 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 150000 -- 35 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 160000 -- 36 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 170000 -- 38 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 180000 -- 40 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 190000 -- 41 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 1a0000 -- 43 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 1b0000 -- 45 % complete.               

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 1c0000 -- 46 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 1d0000 -- 48 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ 3c0000 -- 100 % complete.Cleanmarker written at 3b0000.

 

distro.config

bugreport.tar.gz

kernel.config

QuoteReplyEditDelete

 

 

2010-11-18 17:10:07     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95960   

 

It would also appear that whatever did manage get erased was on /dev/mtd0 since my ezkit board no longer boots.

QuoteReplyEditDelete

 

 

2010-11-18 17:50:02     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95961   

 

So we've ruled out hardware. We're apparently using the same software now....have you guys tried my configs? Maybe I've got something stupid going on in there.

QuoteReplyEditDelete

 

 

2010-11-18 19:13:43     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 95962   

 

u-boot getting erased was my fault. I had a bad value for the MTD0 size in the bootargs. I changed it to:

 

root=/dev/mtdblock0 rw clkin_hz=25000000 earlyprintk=serial,uart1,57600 console=tty0 console=ttyBF1,57600 mtdparts=physmap-flash.0:256k(uboot)ro,3840k(uImage),64k(defconf),64k(conf)

 

 

 

I still get the following errors trying to erase mtd1, though:

 

root:/> flash_eraseall -j /dev/mtd1

Erasing 64 Kibyte @ c0000 -- 20 % complete. Cleanmarker written at b0000.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ d0000 -- 21 % complete.MTD do_erase_oneblock(): software timeout

 

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error

Erasing 64 Kibyte @ e0000 -- 23 % complete.

flash_eraseall: /dev/mtd1: MTD Erase failure: Input/output error                

QuoteReplyEditDelete

 

 

2010-11-18 22:12:10     Re: MTD Partitions and flash_erase on BF527

Mike Frysinger (UNITED STATES)

Message: 95965   

 

using -j when writing a raw partition (like a uImage) makes no sense

QuoteReplyEditDelete

 

 

2010-11-19 01:11:43     Re: MTD Partitions and flash_erase on BF527

Vivi Li (CHINA)

Message: 95970   

 

I attach the kernel and user config file, which has no problem with flash earse.

 

Btw, I'm using bf527-ezkit-v2, silicon version 0.2.

 

config.linux.pnormtd

config.config.pnormtd

QuoteReplyEditDelete

 

 

2010-11-19 12:11:21     Re: MTD Partitions and flash_erase on BF527

Cameron Barfield (UNITED STATES)

Message: 96016   

 

Vivi Li's configs work for me.

 

It looks like there's a problem if the kernel is passed the MTD partition information from u-boot. I even modified the partition sizes in the board resource file to match what I was passing from u-boot and was still able to erase the MTD partition.

QuoteReplyEditDelete

 

 

2010-11-21 22:57:46     Re: MTD Partitions and flash_erase on BF527

Sonic Zhang (CHINA)

Message: 96071   

 

Thanks for your confirmation. I add a new bug here

 

  blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=6347&start=0

QuoteReplyEditDelete

 

 

2010-11-23 03:43:29     Re: MTD Partitions and flash_erase on BF527

Bob Liu (CHINA)

Message: 96127   

 

I can't repeat this problem on 2010R1.

 

Passed the MTD partition information from u-boot also works fine.

QuoteReplyEditDelete

 

 

2010-11-23 21:58:40     Re: MTD Partitions and flash_erase on BF527

Bob Liu (CHINA)

Message: 96147   

 

Both on bf537-stamp and bf527-ezkit.

Outcomes