[Yaffs] Accessing a YAFFS linux MTD partition from u-boot

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Author: Michel Benoit
Date:  
To: yaffs
Subject: [Yaffs] Accessing a YAFFS linux MTD partition from u-boot
Hi,

I'm trying to mount a YAFFS partition in u-boot so that I can read/write
files that are in an existing YAFFS partition created with linux.
I've built u-boot v2012.10 with som very minor changes to support our
embedded linux board (similar to at91sam9260ek).

>From linux I have the following partitions


# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "uboot-env0"
mtd1: 00040000 00020000 "uboot-env1"
mtd2: 00400000 00020000 "kernel0"
mtd3: 00400000 00020000 "kernel1"
mtd4: 01400000 00020000 "rootfs0"
mtd5: 01400000 00020000 "rootfs1"
mtd6: 1cf00000 00020000 "user"
mtd7: 00020000 00020000 "bootstrap"
mtd8: 00060000 00020000 "uboot"


# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / yaffs2 rw,relatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=14148k,nr_inodes=3537,mode=755 0 0
proc /proc proc rw,relatime 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs rw,relatime,mode=777 0 0
tmpfs /tmp tmpfs rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
/dev/mtdblock6 /mnt/flash yaffs2 rw,relatime 0 0

Where the MTD partitions are defined in the linux borad file as:

static struct mtd_partition __initdata exyp_nand_partition[] = {
        {
                .name   = "uboot-env0",
                .offset = 0x00080000,
                .size   = 0x00040000,  /* two erase blocks (256kB) */
        },
        {
                .name   = "uboot-env1",
                .offset = 0x000C0000,
                .size   = 0x00040000,  /* two erase blocks (256kB) */
        },
        {
                .name   = "kernel0",
                .offset = 0x00100000,
                .size   = 0x00400000,  /* 4MB */
        },
        {
                .name   = "kernel1",
                .offset = 0x00500000,
                .size   = 0x00400000,  /* 4MB */
        },
        {
                .name   = "rootfs0",
                .offset = 0x00900000,
                .size   = 0x01400000,  /* 20MB */
        },
        {
                .name   = "rootfs1",
                .offset = 0x01D00000,
                .size   = 0x01400000,  /* 20MB */
        },
        {
                .name   = "user",
                .offset = 0x03100000,
                .size   = 0x1cf00000,  /* 463MB */
        },
        {
                .name   = "bootstrap",
                .offset = 0,
                .size   = 0x00020000,  /* one erase block (128kB) */
        },
        {
                .name   = "uboot",
                .offset = 0x00020000,
                .size   = 0x00060000, /* three erase blocks (384kB) */
        },


};


Both rootfs and user MTD partitions are formatted YAFFS with file content.

When I try to access the yaffs file systems from u-boot I can mount them
but they are empty.
I can store files to the and make directories etc but I get no access to
the existing files in the partitions created within linux and the files
disappear after a reboot.

U-Boot> version

U-Boot 2012.10 (Nov 15 2012 - 11:10:15)
arm-linux-gcc (Buildroot 2011.11-svn407) 4.3.6
GNU ld (GNU Binutils) 2.21.1

U-Boot> nand info

Device 0: nand0, sector size 128 KiB
  Page size      2048 b
  OOB size         64 b
  Erase size   131072 b


U-Boot> ydevconfig user 0 0x188 0xfff
Configures yaffs mount user: dev 0 start block 392, end block 4095

U-Boot> ydevconfig rootfs 0 0xe8 0x187
Configures yaffs mount rootfs: dev 0 start block 232, end block 391

U-Boot> ydevls
rootfs         0 0x000e8 0x00187 not mounted
user           0 0x00188 0x00fff not mounted


U-Boot> ymount user
Mounting yaffs2 mount point user
U-Boot> ymount rootfs
Mounting yaffs2 mount point rootfs
U-Boot> yls rootfs
lost+found
U-Boot> yls user
lost+found

U-Boot> ywr user/foo 0x55 10
Writing value (55) 10 times to user/foo... done

U-Boot> yls user
foo
lost+found

<REBOOT>

U-Boot> ydevconfig user 0 0x188 0xfff
Configures yaffs mount user: dev 0 start block 392, end block 4095
U-Boot> ymount user
Mounting yaffs2 mount point user
U-Boot> yls user
lost+found


It seems that YAFFS is mounting on top of RAM instead of on the NAND chip.
Do I have to specify mtd parts in u-boot order to access the NAND?
Is there a u-boot config define for selecting NAND or RAM for YAFFS2
support?

My ultimate goal is to read out the linux kernel image from the rootfs
(YAFFS), copy it to RAM and boot.

Michel