QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1174|回复: 1

Boot from NFS on SkyEye (zz)

[复制链接]
发表于 2006-3-30 09:38:26 | 显示全部楼层 |阅读模式
(from http://skyeye.sourceforge.net/wiki/BootfromNFS)

After a period of hard work, I have found a solution to let Uclinux on Skyeye boot its’ root file system from hosts’ NFS service. The detail steps of the method are showed in the following.

First of all, it is necessary to list my software environment.
Host Operating system: Fedora core 1 (or Red hat 9) with NFS service
Skyeye 0.8.0.0
Cross compiler: arm-elf-tools-20030314.sh
Uclinux: uClinux-dist-20030522.tar
The root file system: ./skyeye-binary-testutils-1.0.7/at91/uclinux3/boot.rom

Through my experiments, I found the NFS client of Uclinux on skyeye always failed to work with the 2.6 kernel on the host. It is the reason to choose Fedora core 1 or Red hat 9 for my host. Furthermore, because the network components of Skyeye 0.8 are faster than Skyeye 1.0, it was used by me.

1. Install or uncompress Skyeye, Skyeye-binary-testutils, Skyeye net drivers, Cross complier and Uclinux on the host according to their install guide. For brief examples:



  /* Install Skyeye0.8*/
   #tar jxfv skyeye-0.8.0.tar.bz2
   #./configure --target=arm-elf --prefix=/usr/local
   #make
   #make install

   /* uncompress skyeye-binary-testutils */
   #tar jxfv skyeye-binary-testutils-1.0.7.1.tar.bz2

   /* Install a cross complier */
   #sh arm-elf-tools-20030314.sh

   /* uncompress uclinux resource code */
  #tar zxf uClinux-dist-20030522.tar.gz

  /* uncompress and install Skyeye net drivers */
  #tar zxf uclinux4skyeye-v0.2.3.tgz
  #cd uclinux4skyeye
  #cp example/uclinux-dist-20030522/vendor__GDB_ARMulator/* ../uClinux-dist/vendors/GDB/ARMulator/
  #cp example/uclinux-dist-20030522/linux-2.4.x__drivers__net/* ../uClinux-dist/drivers/net/


2. Setup the root file system NFS directory and configure the NFS service on the host.
2.1 Copy the root file system from boot.img to the root file system NFS directory on the host



   #cd /skyeye-binary-testutils-1.0.7/at91/uclinux3/
   #mount -o loop boot.img /mnt/tmp  /*mount the root file system on a temporary directory */
   #cd /mnt/tmp
   #cp . /tmp/nfs –r   /* /tmp/nfs will be the root file system NFS directory */

Note: In order to avoid booting conflict and save booting time, please delete “/bin/ifconfig eth0 up 10.0.0.2” in /tmp/nfs/etc/rc.

2.2 Configure the NFS service on the host and restart it.
The configures can be completed using menu operations:



   System Settings->Server settings->NFS->Add button:
   Directory: /tmp/nfs
   Host(s): *
   Basic permissions : Read/Write
   System Settings->Server settings->Services->nfs(click mouse right button)->restart



3.To change relevant recourse code to force Uclinux boot its’ root filesystem from NFS.
There are four changes on two C files: /uClinux-dist/linux-2.4.x/init/do_mounts.c and /uClinux-dist/linux-2.4.x/arch/armnommu/kernel/stup.c

3.1 Only one change is in do_mounts.c to correct a bug.



static void __init mount_root(void)
{
#ifdef CONFIG_ROOT_NFS

ROOT_DEV =MKDEV(UNNAMED_MAJOR,0);
/* You only need to add this sentence in here */

if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) {
if (mount_nfs_root()) { ……}
}
#endif

“As in do_mount.c file there is a function called mount_root() which, depending upon the root
configuration it mount the particular file system as a system root. For NFS mount it check the
Root device by comparing the major value for the device by MAJOR(ROOT_DEV)==UNNAMED_MAJOR
Where UNNAMED_MAJOR =0 and here we are failing to get it,I found that the ROOT_DEV value is
getting changed Somewhere between setup_arch() and mount_root(), the value ROOT_DEV gets
set to 31, which is not desired value. and the solution I found was either you comment that testing line

i.e. // if(MAJOR(ROOT_DEV)== UNNAMED_MAJOR) , I know this is not gud solution but it works..
or hack the proper ROOT_DEV value for NFS.

I  added  ROOT_DEV =MKDEV(UNNAMED_MAJOR,0); because mount_root() first check if MAJOR(ROOT_DEV) != UNNAMED_MAJOR. If this is the case, it skips the root NFS mount. (ref :some mail archives on list)

so I just changed it. And everything works fine after these changes and I was successful to mount root file system as nfs.”
(Reference 1: http://marc.10east.com/?l=uclinux-dev&m=109360277632198&w=4)


3.2 The rest three changes are in setup.c to configure a boot command line
In this case, the host IP address is 10.0.0.1 and the simulator client IP address: 10.0.0.2.The guide about the boot command line can be found in /uClinux_dist/linux_2.4.x/Document/nfsroot.txt.

3.2.1 Change the CONFIG_CMDLINE as:



#ifndef CONFIG_CMDLINE

//#define CONFIG_CMDLINE "root=/dev/rom0"

#define CONFIG_CMDLINE "root=/dev/nfs rootfstype=nfs ip=10.0.0.2 \
nfsroot=10.0.0.1:/tmp/nfs rw \
nfsaddrs=10.0.0.2:10.0.0.1:10.0.0.1:255.0.0.0:skyeye:eth0:none"
#endif


3.2.2 Change the command_line variable like:



//static char command_line[COMMAND_LINE_SIZE] = "root=/dev/rom0";
static char command_line[COMMAND_LINE_SIZE] = "root=/dev/nfs rootfstype=nfs \
ip=10.0.0.2 \
nfsroot=10.0.0.1:/tmp/nfs rw \
nfsaddrs=10.0.0.2:10.0.0.1:10.0.0.1:255.0.0.0:skyeye:eth0:none";


3.2.3 “If you face any problem in parsing the command line then you can directly pass the command line argument by putting the following code in setup_arch() function before the line

memcpy(saved_cammand_line,from,COMMAND_LINE_SIZE) :

your code should look like:”
(Reference 2: http://marc.10east.com/?l=uclinux-dev&m=109360277632198&w=4∞)



#ifdef CONFIG_ROOT_NFS
strcpy(from,"root=/dev/nfs rootfstype=nfs ip=10.0.0.2 "
"nfsroot=10.0.0.1:/tmp/nfs rw \
nfsaddrs=10.0.0.2:10.0.0.1:10.0.0.1:255.0.0.0:skyeye:eth0:none");
#endif
memcpy(saved_command_line, from, COMMAND_LINE_SIZE);


4. Compile the uclinux kernel on the host.

4.1 Confirm to customize kernel settings



#cd / uClinux-dist
#make menuconfig
Target Platform Selection-> (GDB/Armulator) Vendor/Product
                   (Linux-2.4.x) Kernel Version
                   (uClibc) Libc Version
                  
  • Customize Kernel Settings (new)
    Exit
    Do you wish to save your new kernel configuration [Yes]


    4.2 Two essential options to compile the kernel for booting from NFS on the host:



    Networking options->
  • IP: kernel level autoconfiguration

    File systems->Network File Systems->
  • NFS file system support
                                           
  • Provide NFSv3 client support
                                           
  • Root file system on NFS  
    Exit
    Do you wish to save your new kernel configuration [Yes]

    #make dep
    #make
    #ls /uClinux-dist/linux-2.4.x/linux


    One new kernel which named “linux” comes out now if every thing is fine.

    Note: Do not use “File systems-> /dev file system support” or get a conflict when booting and expanding ramfs.img.

    5. Configure skyeye.conf for skyeye on the host.
    The following is the content of my skyeye.conf:



    #kyeye config file sample
    cpu: arm7tdmi
    mach: at91
    mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
    mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000
    mem_bank: map=M, type=R,  addr=0x01400000, size=0x00400000
    #, file=./boot.rom
    mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000
    mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000
    mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000
    mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000
    #set nic info state=on/off  mac=xxxxxxx  ethmod=tuntap/vnet hostip=dd.dd.dd.dd
    net: state=on, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1


    It is similar to /skyeye-binary-testutils-1.0.7/at91/uclinux3/skyeye.conf and only changed one line. Moreover, this configure file should be saved in the same directory with the new kernel.

    6. It is time to try the kernel with skyeye on the host.

    In this stage, it spends approximate seven or eight minutes to wait for next message after seeing “VFS: Mounted root (nfs filesystem).” and then still should keep patient because some message come out very slowly. Furthermore, there are four alarms about “write data to nic is bigger than 256” to be seen in this boot process, which is a bug in skyeye and do not need to be panic.
    Ok, that is it.



    # skyeye linux
    ***************************************************************
    ****                                                       ****
    ****   SkyEye  Simulator Ver 0.8.0 with  GDB 5.3 Interface ****
    ****                                                       ****
    ***************************************************************
    GNU gdb 5.3
    Copyright 2002 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This SkyEye was configured as "--host=i686-pc-linux-gnu --target=arm-elf"...
    (SkyEye) targ sim
    cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
    mach info: name at91, mach_init addr 0x813e02c
    nic[0] info: state=1, ethmod num=1, mac addr=0:4:3:2:1:f, hostip=10.0.0.1
    nic_init_begin
    tapif_init begin
    tapif_init: fd 6
    tapif_init: system("ifconfig tap0 inet 10.0.0.1");
    tapif_init end
    nic_init_end
    SKYEYE: use arm7100 mmu ops
    Connected to the simulator.
    (SkyEye) load
    Loading section .init, size 0xc000 vma 0x1000000
    Loading section .text, size 0xd0920 vma 0x100c000
    Loading section .data, size 0x91f0 vma 0x10de000
    Start address 0x1000000
    Transfer rate: 7526528 bits in <1 sec.
    (SkyEye) run
    Starting program: /mnt/kernel_nfs/linux
    Linux version 2.4.20-uc0 ([email protected]) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #18 Mon Mar 13 16:29:39 GMT 2006
    Processor: Atmel AT91M40xxx revision 0
    Architecture: EB01
    On node 0 totalpages: 1024
    zone(0): 0 pages.
    zone(1): 1024 pages.
    zone(2): 0 pages.
    Kernel command line: root=/dev/nfs rootfstype=nfs ip=10.0.0.2 nfsroot=10.0.0.1:/tmp/nfs rw
    nfsaddrs=10.0.0.2:10.0.0.1:10.0.0.1:255.0.0.0:skyeye:eth0:none
    Calibrating delay loop... 12.97 BogoMIPS
    Memory: 4MB = 4MB total
    Memory: 2976KB available (834K code, 180K data, 48K init)
    Dentry cache hash table entries: 512 (order: 0, 4096 bytes)
    Inode cache hash table entries: 512 (order: 0, 4096 bytes)
    Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
    Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
    Page-cache hash table entries: 1024 (order: 0, 4096 bytes)
    POSIX conformance testing by UNIFIX
    Linux NET4.0 for Linux 2.4
    Based upon Swansea University Computer Society NET3.039
    Initializing RT netlink socket
    Starting kswapd
    Atmel USART driver version 0.99
    ttyS0 at 0xfffd0000 (irq = 2) is a builtin Atmel APB USART
    ttyS1 at 0xfffcc000 (irq = 3) is a builtin Atmel APB USART
    Blkmem copyright 1998,1999 D. Jeff Dionne
    Blkmem copyright 1998 Kenneth Albanowski
    Blkmem 1 disk images:
    0: 1400000-13FFFFF [VIRTUAL 1400000-13FFFFF] (RO)
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
    SkyEye NE2k Ethernet driver version 0.2 (2003-04-27)
    sene2k dev name: eth0: <6>NET4: Linux TCP/IP 1.0 for NET4.0
    IP Protocols: ICMP, UDP, TCP
    IP: routing cache hash table of 512 buckets, 4Kbytes
    TCP: Hash tables configured (established 512 bind 512)
    IP-Config: Guessing netmask 255.0.0.0
    IP-Config: Complete:
      device=eth0, addr=10.0.0.2, mask=255.0.0.0, gw=255.255.255.255,
    host=10.0.0.2, domain=, nis-domain=(none),
    bootserver=255.255.255.255, rootserver=10.0.0.1, rootpath=
    NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
    Looking up port of RPC 100003/2 on 10.0.0.1
    Looking up port of RPC 100005/1 on 10.0.0.1
    VFS: Mounted root (nfs filesystem).
    Shell invoked to run file: /etc/rc
    Command: hostname GDB-ARMulator
    Command: /bin/expand /etc/ramfs.img /dev/ram0
    Command: mount -t proc proc /proc
    skyeye: write data to nic is bigger than 256
    R ff000040,fffa002f,1a,22,fffa0024,fffa0020,40,fffa0000,fffa001f,11263a0,136,11cbbdc,fffa003f,11cbbb0,fffa0028,1077514,C 20000013,S 0,0,20000093,20000000,0,0,0,M 13,B 3,E 0,I 0,P 13d1ae0,T 0,L e3740a01,D e1a04000,skyeye: write data to nic is bigger than 256
    R fffa0014,fffa0018,40,fffa001f,fffa0fff,fffa0020,40,fffa0000,fffa001f,11263a0,136,11cbbdc,fffa0000,11cbbb0,fffa0010,1077590,C 20000013,S 0,0,20000093,20000000,0,0,0,M 13,B 3,E 0,I 0,P 13d1ae0,T 0,L e3740a01,D e1a04000,Command: mount -t ext2 /dev/ram0 /var
    skyeye: write data to nic is bigger than 256
    R ff000040,fffa002f,1a,22,fffa0024,fffa0020,40,fffa0000,fffa001f,11263a0,132,11cbbdc,fffa003f,11cbbb0,fffa0028,1077514,C 20000013,S 0,0,60000093,20000000,0,0,0,M 13,B 3,E 0,I 0,P 13d1ae0,T 0,L e3740a01,D e1a04000,skyeye: write data to nic is bigger than 256
    R fffa0014,fffa0018,40,fffa001f,fffa0fff,fffa0020,40,fffa0000,fffa001f,11263a0,132,11cbbdc,fffa0000,11cbbb0,fffa0010,1077590,C 20000013,S 0,0,60000093,20000000,0,0,0,M 13,B 3,E 0,I 0,P 13d1ae0,T 0,L e3740a01,D e1a04000,Command: mkdir /var/tmp
    Command: mkdir /var/log
    Command: mkdir /var/run
    Command: mkdir /var/lock
    Command: cat /etc/motd
    Welcome to
          ____ _  _
         /  __| ||_|
    _   _| |  | | _ ____  _   _  _  _
       | | | | |  | || |  _ \| | | |\ \/ /
       | |_| | |__| || | | | | |_| |/    \
       |  ___\____|_||_|_| |_|\____|\_/\_/
       | |
       |_|

    GDB/ARMulator support by <[email protected]>
    For further information check:
    http://www.uclinux.org/

    Execution Finished, Exiting

    Sash command shell (version 1.1.1)
    /> ping 10.0.0.1 -c 4
    PING 10.0.0.1 (10.0.0.1): 56 data bytes
    64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=0.-7 ms
    64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.-7 ms
    64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.-7 ms
    64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.-8 ms

    --- 10.0.0.1 ping statistics ---
    4 packets transmitted, 4 packets received, 0% packet loss
    round-trip min/avg/max = 0.-8/107374181.6/0.0 ms
    />
  • 发表于 2006-3-31 07:21:46 | 显示全部楼层
    谢谢版主帮我转贴,过几天我会再写一篇中文的。
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    GMT+8, 2024-6-8 01:45 , Processed in 0.109537 second(s), 16 queries .

    © 2021 Powered by Discuz! X3.5.

    快速回复 返回顶部 返回列表