將上一篇博客中製作的根文件系統通過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根文件系統了