OK210制作根文件系统(2)NFS

 将上一篇博客中制作的根文件系统通过NFS挂载到开发板内核中,方便开发过程中修改程序文件。

1、  修改内核,使内核支持网络,使内核支持NFS以及NFS方式挂载根文件系统

a)        进入内核目录

b)        #make menuconfig

c)        General setup -> [ ]Initial RAM filesystem and RAM disk support(取消该项)

d)        Device  Drivers -> [*]Networkdevice support -> []Ethernet (10 or 100Mbit)
-><*>DM9000 support 选中

e)        File systems -> [*]Network File Systems -><*>NFSclient support 以及后边的几个version 都选中

f)         #make zImage 编译内核

g)        #make modules  编译内核模块

h)        #make modules_installINSTALL_MOD_PATH=(rootfs的路径)  (安装编译完的内核模块)

i)          cp  arch/arm/boot/zImage /tftproot   将编译完的内核复制到tftp服务路径下

2、   修改u-boot 启动参数 bootargs

#setenv bootargs noinitrd console=ttySAC2,115200 init=/initroot=/dev/nfs nfsroot=192.168.2.254:/nfs_share/rootfs(nfs服务器地址:/rootfs路径)

ip=192.168.2.14:192.168.2.254:192.168.2.1:255.255.255.0::eth0:off

(ip=开发板启动后的IP:NFS服务器的IP:网关:子网掩码:主机名:开发板网卡:dhcp等服务开关等)

                   #saveenv

3、  配置虚拟机的nfs服务器

#rpm –qa | grep nfs

nfs-utils-1.0.9-16.el5

nfs-utils-lib-1.0.8-7.2

system-config-nfs-1.3.23-1.el5

                   如果以上软件包已经安装就可以直接配置,否则先安装nfs服务软件

                   #vim/etc/export

                   添加以下内容

                   /nfs_share/rootfs192.168.2.*(rw,sync,no_root_squash)

                   关闭iptables和selinux 后重启nfs服务

                   #servicenfs restart

                   完成后可以 在本机新建一个目录挂载一下试试,如果没有问题就可以上板子测试了。

4、  打开开发板电源,在出现U-boot信息后按下键盘任意键,进入u-boot的命令行界面

#tftp c0008000 zImage

#bootm zImage

 

以下为遇到的一些错误

(1)启动内核过程中出现如下情况

dm9000: read wrong id0x2b2a2928

dm9000 dm9000: read wrongid 0x2b2a2928

dm9000 dm9000: read wrongid 0x2b2a2928

dm9000 dm9000: read wrongid 0x2b2a2928

dm9000 dm9000: read wrongid 0x2b2a2928

dm9000 dm9000: read wrongid 0x2b2a2928

dm9000 dm9000: wrong id:0x2b2a2928

dm9000 dm9000: not found(-19).

mousedev: PS/2 mouse device common for allmice

TCP cubic registered

NET: Registered protocol family 17

Bridge firewalling registered

CCID: Activated CCID 2 (TCP-like)

CCID: Activated CCID 3 (TCP-Friendly RateControl)

sctp: Hash tables configured (established8192 bind 6553)

NET: Registered protocol family 21

Registered RDS/tcp transport

Registering the dns_resolver key type

VFP support v0.3:implementor 41 architecture 3 part 30 variant c rev 2

VFS: Unable to mount rootfs via NFS, trying floppy.

VFS: Cannot open rootdevice "nfs" or unknown-block(2,0)

Please append a correct"root=" boot option; here are the available partitions:

Kernel panic - notsyncing: VFS: Unable to mount root fs on unknown-block(2,0)

[<8002f988>](unwind_backtrace+0x0/0xec) from [<80298604>] (panic+0x6c/0x18c)

[<80298604>] (panic+0x6c/0x18c) from[<80008e7c>] (mount_block_root+0x1d0/0x210)

[<80008e7c>](mount_block_root+0x1d0/0x210) from [<80008f5c>] (mount_root+0xa0/0xbc)

[<80008f5c>] (mount_root+0xa0/0xbc)from [<800090d0>] (prepare_namespace+0x158/0x1b0)

[<800090d0>](prepare_namespace+0x158/0x1b0) from [<80008468>](kernel_init+0x100/0x13c)

[<80008468>](kernel_init+0x100/0x13c) from [<8002b7d4>] (kernel_thread_exit+0x0/0x8)

 

原因是dm9000的网卡驱动中存在地址不匹配问题可以按照如下步骤改错

 

#vim arch/arm/mach-s5pv210/mach-smdkv210.c 找到相应函数并修改成内容

static struct resourcesmdkv210_dm9000_resources[] = {

       [0] = {

                .start  =  0x88000000,

                .end  =   0x88000000+3,

                .flags  = IORESOURCE_MEM,

       },

       [1] = {

                .start  = 0x88000000 + 4,

                .end    = 0x88000000 + 4 + 3,

                .flags  = IORESOURCE_MEM,

       },

       [2] = {

                .start  = IRQ_EINT(10),

               .end    = IRQ_EINT(10),

                .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,

       },

};

 

static void __initsmdkv210_dm9000_init(void)

{

       unsigned long * srom_bw = ioremap(0xE8000000, 4);

       unsigned long * srom_bc1 = ioremap(0xE8000004, 4);

 

       *srom_bc1 =((0<<28)|(0<<24)|(5<<16)|(0<<12)|(0<<8)|(0<<4)|(0<<0));

       *srom_bw &= ~(0xf << 4);

       *srom_bw |= (1<<4)|(1<<5);

 

       gpio_request(S5PV210_MP01(1),"nCS1");

       s3c_gpio_cfgpin(S5PV210_MP01(1), S3C_GPIO_SFN(2));

       gpio_free(S5PV210_MP01(1));

 

       iounmap(srom_bw);

       iounmap(srom_bc1);

}

 

由于本人还没有看过裸机方面的知识以上步骤纯属抄袭网友做法,附上原文链接

http://www.aiuxian.com/article/p-1437449.html

 

(2)改完以上错误又出现如下错误

IP-Config: Complete:

    device=eth0, addr=192.168.2.14, mask=255.255.255.0, gw=192.168.2.1,

    host=192.168.2.14, domain=, nis-domain=(none),

    bootserver=192.168.2.254, rootserver=192.168.2.254, rootpath=

------------[ cut here ]------------

WARNING: at net/sched/sch_generic.c:256dev_watchdog+0x164/0x254()

NETDEV WATCHDOG: eth0 (dm9000): transmitqueue 0 timed out

Modules linked in:

[<8002f988>](unwind_backtrace+0x0/0xec)from[<80042750>](warn_slowpath_common+0x4c/0x64)

[<80042750>](warn_slowpath_common+0x4c/0x64)from[<800427e8>](warn_slowpath_fmt+0x2c/0x3c)

[<800427e8>](warn_slowpath_fmt+0x2c/0x3c) from [<801e4354>](dev_watchdog+0x164/0x254)

[<801e4354>](dev_watchdog+0x164/0x254) from [<8004cb64>](run_timer_softirq+0x14c/0x1f8)

[<8004cb64>](run_timer_softirq+0x14c/0x1f8) from [<80047920>](__do_softirq+0x6c/0xf4)

[<80047920>] (__do_softirq+0x6c/0xf4)from [<80047b7c>] (irq_exit+0x44/0xa8)

[<80047b7c>] (irq_exit+0x44/0xa8)from [<80025078>] (asm_do_IRQ+0x78/0x98)

[<80025078>] (asm_do_IRQ+0x78/0x98)from [<8002a448>] (__irq_svc+0x48/0xc0)

Exception stack(0x80375f80 to 0x80375fc8)

5f80: 8037fab0 80384b90 80375fc8 0000000080374000 8039d080 8001f9a8 803796f4

5fa0: 20000000 412fc082 00000000 0000000000000000 80375fc8 80035ab4 80035ab8

5fc0: 60000013 ffffffff

[<8002a448>] (__irq_svc+0x48/0xc0)from [<80035ab8>] (s5pv210_idle+0x24/0x28)

[<80035ab8>] (s5pv210_idle+0x24/0x28)from [<8002bde0>] (cpu_idle+0x48/0xa0)

[<8002bde0>] (cpu_idle+0x48/0xa0)from [<80008918>] (start_kernel+0x234/0x27c)

[<80008918>](start_kernel+0x234/0x27c) from [<20008038>] (0x20008038)

---[ end trace fcc5c62ae9b64fcc ]---

VFS: Unable to mount root fs via NFS,trying floppy.

VFS: Cannot open root device"nfs" or unknown-block(2,0)

Please append a correct "root="boot option; here are the available partitions:

Kernel panic - not syncing: VFS: Unable tomount root fs on unknown-block(2,0)

[<8002f988>](unwind_backtrace+0x0/0xec) from [<80298604>] (panic+0x6c/0x18c)

[<80298604>] (panic+0x6c/0x18c) from[<80008e7c>] (mount_block_root+0x1d0/0x210)

[<80008e7c>] (mount_block_root+0x1d0/0x210)from [<80008f5c>] (mount_root+0xa0/0xbc)

[<80008f5c>] (mount_root+0xa0/0xbc)from [<800090d0>] (prepare_namespace+0x158/0x1b0)

[<800090d0>](prepare_namespace+0x158/0x1b0) from [<80008468>](kernel_init+0x100/0x13c)

[<80008468>] (kernel_init+0x100/0x13c)from [<8002b7d4>] (kernel_thread_exit+0x0/0x8)

原因是刚才修改static struct resource smdkv210_dm9000_resources[] 结构是将dm9000中断信号改为网友的EXINT10,而笔者自己板子的情况如下

是EXTIN9 中断,因此将中断改一下,如下红色部分

 

#vim arch/arm/mach-s5pv210/mach-smdkv210.c

static struct resource smdkv210_dm9000_resources[]= {

       [0] = {

                .start  = 0x88000000,

                .end    = 0x88000000+3,

                .flags  = IORESOURCE_MEM,

       },

       [1] = {

                .start  = 0x88000000 + 4,

                .end    = 0x88000000 + 4 + 3,

                .flags  = IORESOURCE_MEM,

       },

       [2] = {

                .start = IRQ_EINT(9),

                .end    = IRQ_EINT(9),

                .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,

       },

};

然后再开机下载内核,bootm   发现ok了可以挂载虚拟机的nfs根文件系统了

发布了31 篇原创文章 · 获赞 9 · 访问量 9万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章