This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NAND JFFS2

Other Parts Discussed in Thread: OMAP-L138

On the following webpage, http://processors.wiki.ti.com/index.php/Booting_Linux_kernel_using_U-Boot, the following statement is made:

"In the above commands 'X' in '/dev/mtdX' and '/dev/mtdblockX' refer to the NAND partition which is reserved for file system."

Where are /dev/mtdX and /dev/mtdblockX defined?

 

  • It is defined in EVM specific file. For example for DA850, it is defined in arch/arm/mach-davinci/board-da850-evm.c file. Look for da850_evm_nandflash_partition structure.

    Regards, Sudhakar

  • I had looked at that, but none of the names match '/dev/mtdX' or '/dev/mtdblockX'.  Does the .name = "filesystem" need to be changed to match one of these names (and which one)?  I'm guessing that the "X" should be replaced with a "0" as well.

  • /dev/mtdX names are assigned by the kernel in the order how the MTD devices get registered. For example if NAND is the only MTD device in teh kernel. then for as per "da850_evm_nandflash_partition" structure:

    /dev/mtdblock0 - u-boot env

    /dev/mtdblock1 - UBL

    /dev/mtdblock2 - u-boot

    /dev/mtdblock3 - kernel

    /dev/mtdblock4 - filesystem

    Regards, Sudhakar

  • Partially works now.  I get the following, followed by a Backtrace:

    Empty flash at 0x0000fffc ends at 0x00010000
    Empty flash at 0x0002fffc ends at 0x00030000
    .
    .
    .
    Empty flash at 0x00e4fffc ends at 0x00e50000
    Empty flash at 0x00e6ffa4 ends at 0x00e70000
    VFS: Mounted root (jffs2 filesystem) on device 31:0.
    Freeing init memory: 144K
    INIT: version 2.86 booting
    Please wait: booting...
    Starting udev
    Erase at 0x0b600000 failed immediately: -EROFS. Is the sector locked?
    Erase at 0x0b5e0000 failed immediately: -EROFS. Is the sector locked?
    .
    .
    .
    Erase at 0x0b640000 failed immediately: -EROFS. Is the sector locked?
    Erase at 0x0b620000 failed immediately: -EROFS. Is the sector locked?
    Argh. No free space left for GC. nr_erasing_blocks is 0. nr_free_blocks is 0. (erasableempty: yes, erasingempty: yes, erasependinge)
    Failed to allocate space for wbuf recovery. Data loss ensues.
    Write of 186 bytes at 0x00e75fbc failed. returned -30, retlen 0
    Not marking the space at 0x00e75fbc as dirty because the flash driver returned retlen zero
    Unable to handle kernel NULL pointer dereference at virtual address 00000024
    pgd = c0004000
    [00000024] *pgd=00000000
    Internal error: Oops: 17 [#1] PREEMPT
    last sysfs file: /sys/devices/virtual/block/ram0/removable
    Modules linked in:
    CPU: 0    Not tainted  (2.6.33-rc4 #109)
    PC is at __jffs2_flush_wbuf+0x80/0xd4c
    LR is at __jffs2_flush_wbuf+0x6c/0xd4c
    pc : [<c0156188>]    lr : [<c0156174>]    psr: 60000013
    sp : c7889ed8  ip : c7889ed8  fp : c7889f4c
    r10: 00000000  r9 : 00000000  r8 : 00000000
    r7 : 00000002  r6 : c7a4175c  r5 : c79c8e00  r4 : c79c8e2c
    r3 : 00000000  r2 : c7a40000  r1 : 00020000  r0 : c79c8e00
    Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
    Control: 0005317f  Table: c7bd0000  DAC: 00000017
    Process sync_supers (pid: 165, stack limit = 0xc7888270)
    Stack: (0xc7889ed8 to 0xc788a000)
    9ec0:                                                       c03455c4 c7877978
    9ee0: c7889f6c c7888000 c79c8e2c c79c8e30 c7877900 00000000 00000000 00000000
    9f00: c7889f3c c7889f10 c0346118 c0345120 c79c8eac c79c8e30 c79c8e30 00e75800
    9f20: c7889f3c 00e75800 c79c8e00 c79c8f18 c79c8e2c 00000000 00000000 00000000
    9f40: c7889f6c c7889f50 c01573d8 c0156118 c79c8e00 c79c8c00 00000000 c00884bc
    9f60: c7889f8c c7889f70 c015520c c0157354 c79c8c00 c7888000 c79c8c40 c00884bc
    9f80: c7889fac c7889f90 c00a64c0 c01551d0 c7888000 c7823f50 00000000 c00884bc
    9fa0: c7889fc4 c7889fb0 c00884f8 c00a6428 c7889fcc c7823f50 c7889ff4 c7889fc8
    9fc0: c0057ae8 c00884cc 00000000 00000000 c7889fd0 c7889fd0 00000000 00000000
    9fe0: 00000000 00000000 00000000 c7889ff8 c0044134 c0057a70 57555755 55515755

    It looks like the EROFS (Error Read-Only File System) errors are the problem.  The .jffs2 file has all rw permissions set.  Is there something else I need to do?

     

  • How did you create the JFFS2 file system and how did you write it to the nand?

    John A

  • 1.  Downloaded arago-demo-image-da850-omapl138-evm.tar.gz to a directory on my Linux Host, then unzipped it: sudo tar -xvzf arago-demo-image-da850-omapl138-evm.tar.gz

    2.  Created the jffs2 file system:  sudo mkfs.jffs2 -r <directory> -p -n -o rootfs.jffs2

    3.  On target board, under u-boot:

    u-boot> tftp C0000000 uboard-rootfs.jffs2
    u-boot> nand erase 0 10000000
    u-boot> nand write.jffs2 C0000000 0 e80000

  • I also tried writing to NAND under Linux on the target board, but the following command fails:

    $ flash_eraseall -j /dev/mtd0
    $ flash_eraseall: /dev/mtd0: Permission denied

    I'm logged in as root.

  • I'm not positive if it's required but I specify the page and block size.

    block/erase block size = 128K
    Page size = 2048

    mkfs.jffs2 -lqn -e128 -s2048 -p0x20000 -r ~/dm368/dvrfs -o rfs.jffs2

    I also use u-boot to erase the section of the nand reserved for the jffs2 partition.  Then I write the JFFS2 RFS to the nand from Linux after mounting.

    John A

  • What are the commands you're using in Linux?  I get an error with the following:

    # tftp -r rootfs.jffs2 -g 192.168.11.3
    tftp: write error

    The error pops up a few seconds after the command is issued.  The Ethernet LED blinks, so some transfers do occur.

    Inderjit

     

  • From the TMS320DM365 Software Developers Guide in the dvsdk_4_00_00_22/docs directory.

    Page 24 - How to flash a filesystem

     target # flash_eraseall /dev/mtd4
     target # mkdir -p /mnt/nand
     target # mount /dev/mtdblock4 /mnt/nand -t jffs2
     target # cd /mnt/nand
     target # tar zxf /home/root/filesystem.tar.gz
     target # sync
     target # cd /home/root
     target # umount /mnt/nand

    John A

  • I used the method described in my previous post and am able to boot up and mount the root filesystem.

    John A

  • I'm still getting a tftp:  write error when I use the following command (in Linux on the target board):

    # tftp -r rootfs.jffs2 -g 192.168.11.3

    rootfs.jffs2 is around 12 MBytes.  This got me to thinking that tftp may have some sort of built-in file size limitation:  smaller files of a ~2 MBytes transfer without error.  After some tests, it appears that 8 MBytes is the limit - a file of 6.6MB transfers without error, but a file of 8.5 MBytes does not.  Using "initrd=0xc1180000,16M" instead of "initrd=0xc1180000,4M" in bootargs did not make any difference (and I'm not sure that it should).

    Any ideas?

  • TFTP the file system and write it from u-boot.  I don't have this size limitation when getting the file from u-boot.

    John A

  • Hi,

    Have you succeed to mount NAND jffs2 on OMAP-L138EVM?

    How did you config the NAND(MT29F4G08AAC) on kernel?

    Would you share your know-how related in AIS, U-Bott or Kernel, etc.?

    OMAP-L138 initialization passed!
    Booting TI User Boot Loader
            UBL Version: 1.65
            UBL Flashtype: NAND
    Starting NAND Copy...
    Valid magicnum, 0x55424CBB, found in block 0x00000006.
       DONE
    Jumping to entry point at 0xC1080000.


    U-Boot 2009.11 ( 4월 01 2011 - 11:32:03)

    I2C:   ready
    DRAM:  64 MB
    NAND:  512 MiB
    MMC:   davinci: 0
    Bad block table found at page 262080, version 0x01
    Bad block table found at page 262016, version 0x01
    In:    serial
    Out:   serial
    Err:   serial
    ARM Clock : 300000000 Hz
    DDR Clock : 150000000 Hz
    Net:   Ethernet PHY: GENERIC @ 0x00

    Hit any key to stop autoboot:  0
    U-Boot > tftp c0000000 rootfs.jffs2
    Using  device
    TFTP from server 192.0.0.171; our IP address is 192.0.0.83
    Filename 'rootfs.jffs2'.
    Load address: 0xc0000000
    Loading: #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             ############
    done
    Bytes transferred = 13369344 (cc0000 hex)
    U-Boot > nand erase 0 100000000

    NAND erase: device 0 offset 0x0, size 0x0
    Warning: Erase size 0x00000000 smaller than one erase block 0x00020000
             Erasing 0x00020000 instead
    Erasing at 0x0 -- 100% complete.
    OK
    U-Boot > nand write.jffs2 C0000000 0 cc0000

    NAND write: device 0 offset 0x0, size 0xcc0000
     13369344 bytes written: OK
    U-Boot >
    U-Boot > boot
    Using  device
    TFTP from server 192.0.0.171; our IP address is 192.0.0.83
    Filename 'rootfs.jffs2'.
    Load address: 0xc0000000
    Loading: #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             #################################################################
             ############
    done
    Bytes transferred = 13369344 (cc0000 hex)
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!
    U-Boot >

    Best regards,
    Seyoung