Skip to contentSkip to conversation

flash_eraseall with jffs2 corrupts separate partition?

DISCUSSION Zeri Virgo 1 participant 1 message Mar 28, 2005 Memory technology devices (MTD)

lore
Share & tools
lore

Zeri Virgo

author
#0 lore raw

I have a few 64MB diskonchip 2000 (not TSOP). Given the apparent lack of support in linuxbios, u-boot and RedBoot for my x86-based Boser HS-4020 (and my lack of time), I'm trying the method of booting with GRUB, loading a kernel from a small NFTL/ext2 partition and then mounting a jffs2 partition as root.
I've been trying this with linux kernel 2.6.11.5 and the utils from MTD CVS.

I've made a two-line change to diskonchip.c to shift the "BDTL partition" it creates along a couple of MB to allow me to use the following layout (is this ok?).

# cat /proc/mtd0
dev:    size    erasesize       name
mtd0: 04000000 00004000 "DiskOnChip 2000 (NFTL Model)"
mtd1: 03de0000 00004000 " DiskOnChip BDTL partition"

I want...
mtd0: grub_firmware and media headers totalling 131072 bytes.
mtd0: 2097152 bytes with ./nftl_format /dev/mtd0 131072 2097152 and ext2
mtd1: 64880640 bytes with jffs2

(BTW, I did try modifying diskonchip.c to give me an mtd1 of 2MB and mtd2 of the rest, but, after running nftl_format /dev/mtd1, I didn't get a /dev/nftla, b or anything to fdisk ???)

So, I run something like this...

# modprobe diskonchip    ( and get cat /proc/mtd0 results as above )
# flash_eraseall /dev/mtd0
# nftl_format /dev/mtd0 131072 2097152
# modprobe nftl
# fdisk /dev/nftla
[NB: fdisk seems to see the whole chip as available, but I create a
partition of 32 cylinders (65536 bytes a cylinder)].
# mke2fs /dev/nftla1
# nanddump -f /tmp/a -l 3000000 -b -p
[Things are as I'd expected - nothing touched before 0x20000 or after
0x220000, and /dev/nftla1 mounts and unmounts without any problems -
2MB as desired.]
# flash_eraseall -j /dev/mtd1
# nanddump -f /tmp/b -l 3000000 -b -p

/dev/nftla1 no longer mounts - group descriptors corrupted! A diff of the two nanddumps shows the expected changes to the mtd1 area, but also a few bytes near the beginning of the nftl partition have been played with! Nearly 2MB before the mtd1 partition!
I have reproduced this a couple of times on different chips. Also, making the nftl/ext2 partition after the jffs2 one seems to screw up the jffs2 partition, though I can't see anything changed in the mtd1 area.

Interestingly, flash_eraseall without the -j option doesn't seem to affect the nftl area. I've put debug in flash_eraseall, and I can't see anything wrong with the start and length values passed to the ioctl calls.

There must be something I'm not understanding here, though I've read all I can find......help!?

- Zeri