Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Linux, U-Boot, and Root File Systems

I'm working with a Nios II design with an MMU, on a Nios II Development Kit, Cyclone II Edition board (EP2C35).

I'm trying to figure out how to get to a system that boots with some sort of root filesystem stored in flash.

With help from hippo's wiki page (http://www.nioswiki.com/linux) (http://www.nioswiki.com/linux%29), I can now:
  • Build a kernel

  • Download it with nios2-download

  • Connect with nios2-terminal

  • Get a Linux Command Prompt
I have also ported U-Boot (starting from the U-Boot code included in the nios-linux tarball from the above-mentioned wiki page). I can burn a kernel to flash, and have U-Boot boot that kernel. I can TFTP a vmImage file, and boot from that (though the system hangs due to lack of a root filesystem).

The "bootargs" variable isn't passed from U-Boot to the Linux Kernel. To work around this, I compile the kernel command line arguments into the kernel (CONFIG_COMMANDLINE).

By compiling in the kernel command-line arguments, I can boot with root=/dev/nfs. After adding a few devices to uClinux-Dist/romfs/dev, I was able to get a command prompt.

Now, I want to boot without using NFS.

Here are the files in my uClinux-dist/images directory:

-rwxrwxr-x 1 pinta pinta 4442546 2009-09-28 15:21 linux.initramfs.gz

-rw-rw-r-- 1 pinta pinta 2478080 2009-09-28 15:20 rootfs.initramfs

-rw-rw-r-- 1 pinta pinta 15997 2009-09-28 15:20 rootfs.initramfs.contents

-rw-rw-r-- 1 pinta pinta 1059759 2009-09-28 15:20 rootfs.initramfs.gz

-rw-r--r-- 1 pinta pinta 579226 2009-09-28 15:21 System.map.initramfs.gz

-rw-r--r-- 1 pinta pinta 1221552 2009-09-28 15:20 vmImage

-rwxrwxr-x 1 pinta pinta 3383298 2009-09-28 15:20 vmlinux

-rwxrwxr-x 1 pinta pinta 2296861 2009-09-28 15:21 zImage.initramfs.gz

linux.initramfs.gz is the file I download with nios2-download.

vmImage is the file I use to boot Linux from U-Boot.

According to the nioswiki Linux page, rootfs.initramfs.gz is compressed initramfs to be used as initrd by u-boot.

How do I use rootfs.initramfs.gz? Specifically:

1) How do I pass it to U-Boot?

2) What (if any) kernel command-line arguments should I compile into the Linux Kernel?

Pinta

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The hardware is a standard Altera Development Kit, http://www.altera.com/products/devkits/altera/kit-nios-2c35.html

    The Quartus design is probably a slightly tweaked version of the standard design that comes with that board. I directed the hardware team to the Linux for Nios II Wiki page, section "Create a Nios II design with MMU", and asked them to modify the design accordingly.

    I don't think I will be able to post the FPGA design. I'll check tomorrow.

    Is there any more specific information I could provide to help figure this out?

    Or, do you have any recommendations on where I should be looking? Or what questions I should be asking the hardware team?

    Something that looked weird to me:

    As you had recommended, I copied images/rootfs.jffs2 to the flash, at the start of the area I allocated to jffs2, 0x00200000. I'm concerned that Linux is mucking around with lower addresses (The "CLEANMARKER" references in the output), where I have stored U-Boot and the kernel. Is this ok?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It seems I'm not done with silly mistakes.

    The flash device is 16 bit, but it is being used in 8-bit mode.

    Switching to ".width = 1" solves the problem of detecting two devices and twice as much flash.

    It also eliminated the CLEANMARKER error.

    Now, I think I am down to flash driver problems.

    The Spansion part is slightly different from the original AMD part. Specifically, the erase commands need to be written to specific offsets in the flash. For the original part, it was sufficient to write the commands to the start address of the flash.

    The older sector erase sequence (for flash starting at address 0x0, and sector to erase at SA) was:

    Address Data

    ---------------------

    0x0 0xAA

    0x0 0x55

    0x0 0x80

    0x0 0xAA

    0x0 0x55

    SA 0x30

    New Sector Erase Sequence:

    Address Data

    ---------------------

    0xAAA 0xAA

    0x555 0x55

    0xAAA 0x80

    0xAAA 0xAA

    0x555 0x55

    SA 0x30

    Here is the new boot log output. It does eventually get to a command prompt, but it keeps generating errors about erase and write errors.

    Am I on the right track here?

    
    Linux version 2.6.30-00494-g84a224b-dirty (pinta@drake-linux.fw5540.net) (gcc version 4.1.2)# 47 Tue Oct 6 14:08:55 EDT 2009
    console  enabled
    Early printk initialized
    Linux/Nios II-MMU
    init_bootmem_node(?,0x6391, 0x6000, 0x8000)
    free_bootmem(0x6391000, 0x1c6f000)
    reserve_bootmem(0x6391000, 0x400)
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128
    Kernel command line:
    NR_IRQS:32
    PID hash table entries: 128 (order: 7, 512 bytes)
    Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
    Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
    We have 32768 pages of RAM
    Memory available: 28824k/3648k RAM, 0k/0k ROM (2119k kernel code, 1528k data)
    Calibrating delay loop... 41.98 BogoMIPS (lpj=209920)
    Mount-cache hash table entries: 512
    net_namespace: 492 bytes
    NET: Registered protocol family 16
    init_BSP(): registering device resources
    bio: create slab <bio-0> at 0
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 1024 (order: 1, 8192 bytes)
    TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
    TCP: Hash tables configured (established 1024 bind 1024)
    TCP reno registered
    NET: Registered protocol family 1
    JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
    JFFS2: default compression mode: priority
    msgmni has been set to 56
    io scheduler noop registered
    io scheduler anticipatory registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    ttyJ0 at MMIO 0x21208b0 (irq = 1) is a Altera JTAG UART
    ttyS0 at MMIO 0x2120840 (irq = 4) is a Altera UART
    console handover: boot  -> real 
    ttyS1 at MMIO 0x2120b00 (irq = 8) is a Altera UART
    smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>
    eth0: SMC91C11xFD (rev 2) at e2110300 IRQ 6 
    eth0: Ethernet addr: 00:07:ed:0f:0a:53
    physmap platform flash device: 01000000 at 00000000
    Physmap Width: 1
    physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank in cfi_chip_setup
     Amd/Fujitsu Extended Query Table at 0x0040
    physmap-flash.0: CFI does not contain boot bank location. Assuming top.
    number of CFI chips: 1
    cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
    cmdlinepart partition parsing not available
    RedBoot partition parsing not available
    Using physmap partition information
    Creating 3 MTD partitions on "physmap-flash.0":
    0x000000000000-0x000000060000 : "U-Boot"
    0x000000060000-0x000000200000 : "uImage"
    0x000000200000-0x000001000000 : "romfs/jffs2"
    TCP cubic registered
    NET: Registered protocol family 10
    NET: Registered protocol family 17
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    /home/pinta/projects/micropump/nios_linux/nios2-linux/linux-2.6/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
    eth0: link down
    ADDRCONF(NETDEV_UP): eth0: link is not ready
    IP-Config: Unable to set interface netmask (-22).
    eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00120000: 0x55ff instead
    JFFS2: Erase block at 0x00120000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x002b0000: 0x55ff instead
    JFFS2: Erase block at 0x002b0000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00440000: 0x55ff instead
    JFFS2: Erase block at 0x00440000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x005d0000: 0x55ff instead
    JFFS2: Erase block at 0x005d0000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00760000: 0x55ff instead
    JFFS2: Erase block at 0x00760000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x008f0000: 0x55ff instead
    JFFS2: Erase block at 0x008f0000 is not formatted. It will be erased
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00010: 0xd76a instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00014: 0x5000 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00018: 0x6a00 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a0001c: 0x0040 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00020: 0x0068 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00024: 0x40ff instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00028: 0x6880 instead
    Empty flash at 0x00a0002c ends at 0x00a0004c
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a0004c: 0x0400 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00050: 0x0404 instead
    jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00a00054: 0x0704 instead
    Further such events for this erase block will not be printed
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    OK.... so those errors were just initialization stuff. They went away once the partition was formatted, I guess.

    I accidentally blew away my FPGA image, but I have that back now. And, I think I've adjusted my partitions so that doesn't happen again.

    Hippo, you are a genius (or at least very helpful).