Skip to contentSkip to conversation

dfu, nand: writing on not empty nand partition

U-Boot Heiko Schocher 2 participants 3 messages Jun 13, 2013

lore
Share & tools
lore
#0 lore raw

Hello,

I just tried to write with "dfu" and dfu-util on the host to a not empty partiton on a nand flash. After the dfu returned without error, I wanted to read the nand partiton with "nand read" and I get ECC errors. This is on an am335x based board (mainline patches coming soon) with ECC BCH8 enabled...

Here is a log:

U-Boot# dfu nand 0
using id 'nand0,0'
using id 'nand0,1'
using id 'nand0,2'
using id 'nand0,3'
using id 'nand0,4'
using id 'nand0,6'
using id 'nand0,7'
using id 'nand0,9'
GADGET DRIVER: usb_dnl_dfu
#
DFU complete CRC32: 0x4b157e97
DOWNLOAD ... OK
Ctrl+C to exit ...
U-Boot#
U-Boot# nand read 80100000 780000 2000

NAND read: device 0 offset 0x780000, size 0x2000
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
NAND read from offset 780000 failed -74
0 bytes read: ERROR
U-Boot# nand erase.part kernel_b

NAND erase.part: device 0 offset 0x780000, size 0x500000 Erasing at 0xc60000 -- 100% complete.
OK
U-Boot# dfu nand 0
using id 'nand0,0'
using id 'nand0,1'
using id 'nand0,2'
using id 'nand0,3'
using id 'nand0,4'
using id 'nand0,6'
using id 'nand0,7'
using id 'nand0,9'
GADGET DRIVER: usb_dnl_dfu
#
DFU complete CRC32: 0x4b157e97
DOWNLOAD ... OK
Ctrl+C to exit ...
U-Boot# nand read 80100000 780000 2000

NAND read: device 0 offset 0x780000, size 0x2000
8192 bytes read: OK
U-Boot# md 80100000

80100000: 56190527 5657499d 00379251 101f2f00    '..V.IWVQ.7../..
80100010: 00800080 00800080 f3f41c20 00020205    ........ .......
80100020: 756e694c 2e332d78 2d302e32 00303172    Linux-3.2.0-r10.
80100030: 00000000 00000000 00000000 00000000    ................
80100040: e1a00000 e1a00000 e1a00000 e1a00000    ................
80100050: e1a00000 e1a00000 e1a00000 e1a00000    ................
80100060: ea000002 016f2818 00000000 002f1f10    .....(o......./.
80100070: e1a07001 e1a08002 e10f2000 e3120003    .p....... ......
80100080: 1a000001 e3a00017 ef123456 e10f2000    ........V4... ..
80100090: e38220c0 e121f002 00000000 00000000    . ....!.........
801000a0: e59f4784 eb000055 e28f0f4a e8901c4e    .G..U...J...N...
801000b0: e590d01c e0400001 e0866000 e08aa000    ...... at ..`......
801000c0: e5da9000 e5dae001 e189940e e5dae002    ................
801000d0: e5daa003 e189980e e1899c0a e08dd000    ................
801000e0: e28da801 e3a05000 e28aa901 e154000a    .....P........T.
801000f0: 2a000016 e084a009 e28f9050 e15a0009    ...*....P.....Z.

U-Boot#

Is this a bug or a feature?

If it is a bug, I fixed it as I added in my tree in drivers/mtd/nand/nand_util.c a nand_erase_write_skip_bad() function, which erases before writes to "off, length" ... and call this function in drivers/dfu/dfu_nand.c nand_block_op() instead nand_write_skip_bad() ... Is this a possible solution?

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 7 lines · Heiko Schocher

Hello,

I just tried to write with "dfu" and dfu-util on the host to a not empty partiton on a nand flash. After the dfu returned without error, I wanted to read the nand partiton with "nand read" and I get ECC errors. This is on an am335x based board (mainline patches coming soon) with ECC BCH8 enabled...

[snip]

Quoted 7 lines

Is this a bug or a feature?

If it is a bug, I fixed it as I added in my tree in drivers/mtd/nand/nand_util.c a nand_erase_write_skip_bad() function, which erases before writes to "off, length" ... and call this function in drivers/dfu/dfu_nand.c nand_block_op() instead nand_write_skip_bad() ... Is this a possible solution?

So yes, if you don't erase first, just like doing a nand write from the command line, it will fail. This is arguably a bug. But, I would go for making dfu_nand spell out a call to an existing erase function since we know the size of the alt setting to be written to.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRubwzAAoJENk4IS6UOR1WceYP/RFobx5O0JXJ60d7BhvmjFhl okzfkxu04Mh/qckehZntF+AjRP1lrZvs2b7I0xWd2BRn2dqjrS9ViqS0Hs9WQ2x8 enMGJGAq03+M3uNiSgZ9OjNbKb5eWm3XAhvqc6uUnWtcJAccMSJ0EHS1u95am6Pa iaY98ofydIHZNO5nyJ7rMmPPLUG13ADTR3JZrFwro7rpxQAc64yIu7klzyD8BqhA mJug5HdiUqXnkb9caTK8REVQ0hatp2Qpv3KZq2rgDbe0urRNpHxg3khCb+2j1duI Ts85dcYQj824cbIipPxd3/8I50LrAe6pxO4aS3tSEX6bri+3R4PvTv+uo9g94dZJ gAaLp9fdZDNSola9T1Ae5aG6eYjKVa6U7UfcAKKW5+GTG4wEuA1tzb0HUj+aMdST FPL7Z8Fkd0np67H1HSDurzrMyOHi+yk+mfMvYsJLnbZGxvZ+3YTBynAxT5KSUDIs fNsZRdh4hgr8Dg/DQ2tkJ35EjgWTjwQAwtWwC1rfC3aznWj/08H33vxsZrnwYUvz hNV3VD/p6BGoPUOmtS0DN3QZeDeX3ur+Sv6l7dMIHKKeUOGHtrpAOtBiSJp2LxvE 6xQ0LyBSEleJuZ64jdMY2Lq8jnA5ZZgJt0f+Tg+qEQDHr56cZAhRQtyD6rEj3iiG O+chE7ulvNQ89XSziDoo
=++kF
-----END PGP SIGNATURE-----

#2 lore raw

Hello Tom,

Am 13.06.2013 14:33, schrieb Tom Rini:

Quoted 17 lines · Heiko Schocher
Quoted 7 lines

Hello,

I just tried to write with "dfu" and dfu-util on the host to a not empty partiton on a nand flash. After the dfu returned without error, I wanted to read the nand partiton with "nand read" and I get ECC errors. This is on an am335x based board (mainline patches coming soon) with ECC BCH8 enabled...

[snip]

Quoted 7 lines

Is this a bug or a feature?

If it is a bug, I fixed it as I added in my tree in drivers/mtd/nand/nand_util.c a nand_erase_write_skip_bad() function, which erases before writes to "off, length" ... and call this function in drivers/dfu/dfu_nand.c nand_block_op() instead nand_write_skip_bad() ... Is this a possible solution?

Quoted 4 lines

So yes, if you don't erase first, just like doing a nand write from the command line, it will fail. This is arguably a bug. But, I would go for making dfu_nand spell out a call to an existing erase function since we know the size of the alt setting to be written to.

Ok, can do it this way also ...

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany