手上一块TQ2440的板,因为NANDFLASH损坏严重,无法从flash启动,只有nor flash上有u-boot还能使用,用usb下载又比较麻烦,需要dnw软件点来点去,
所以考虑用tftp+nfs的方式加载内核和文件系统。
言归正传,先讲正确的可以引导的方式,再讲我遇到的各种错误
前题:虚拟机的tftp 和 nfs服务已经正确设置,而且uboot 和 虚拟机网络可以ping 通
打开开发板电源,按空格进入uboot
##### Boot for Nor Flash #####
[1] Download u-boot to Nand Flash
[2] Download Eboot
[3] Download Linux Kernel
[4] Download WinCE NK.bin
[5] Download CRAMFS image
[6] Download YAFFS image
[7] Download to SDRAM & Run
[8] Boot the system
[9] Format the Nand Flash
[0] Set the boot parameters
[a] Download User Program
[o] Download u-boot to Nor Flash
[q] quit from menu
Enter your selection:
有如下菜单,选择q, 进入uboot命令行模式
Enter your selection: q
EmbedSky>
这时打印出所有可以用的命令,因为用的是天嵌提供的uboot,所以有些标准的uboot命令可能在这个修改过版本的里面用不了,所以需要先看有哪些命令可用
EmbedSky> help
tftpboot- boot image via network using TFTP protocol
里面有个tftpboot的命令,就表示可以用tftp下载了,
tftpboot 命令 + 下载地址 + 文件名
这里的下载地址一般是在uboot已经初始化好的内存中,这个地址选择是看别人这样选的,跟地址分配有一定关系,还没有深入研究,先暂时能用就好
下载好以后用 bootm 0x31000000启动内核,如果nfs文件系统设置没有问题,uboot参数设置也没问题应该就能挂载nfs网络文件系统了
EmbedSky> tftpboot 0x31000000 uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
MAC: 0a:1b:2c:3d:4e:5f
TFTP from server 192.168.1.13; our IP address is 192.168.1.11
Filename 'uImage'.
Load address: 0x31000000
Loading: T #################################################################
###########################################
done
Bytes transferred = 1563948 (17dd2c hex)
EmbedSky> bootm 0x31000000
## Booting image at 31000000 ...
Image Name: linux-2.6.13
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1563884 Bytes = 1.5 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux.......................................................................................................... done, booting the kernel.
Linux version 2.6.13 (root@RED26DVEVM) (gcc version 3.4.5) #3 Thu May 10 11:48:01 CST 2012
CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: TQ2440
。。。。。。
Looking up port of RPC 100003/2 on 192.168.1.13
Looking up port of RPC 100005/1 on 192.168.1.13
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 176K
[31/Dec/1969:23:59:59 +0000] boa: server version Boa/0.94.13
[31/Dec/1969:23:59:59 +0000] boa: server built Aug 19 2007 at 17:40:00.
[31/Dec/1969:23:59:59 +0000] boa: starting server pid=764, port 80
Please press Enter to activate this console.
只要出现Looking up port of 那几句基本就没问题了,最后please press enter to avtivate this console 就更让人满意了,呵呵
我出现过错误就是前面提示信息都有,没有最后那一句please press enter to activate this console这一句,试了好几次都不行,结果是文件系统问题,内核跟文件系统不匹配,找到对应内核的文件系统就OK了,还有问题就是要检查/root_nfs/init.d /root_nfs/rc.d这两个文件夹下的文件了
还有个问题就是bootm 命令启动内核需要加上一个文件头
The bootm
command is used to start operating system images.
From the image header it gets information about the type of the operating system, the file compression method used (if any), the load and entry point addresses, etc. The command will then load the image to the required memory address, uncompressing it on the fly if necessary. Depending on the OS it will pass the required boot arguments and start the OS at it's entry point.
所以编译内核生成zImage以后需要为内核加上文件头
用u-boot/tools/mkimage这个工具为你的内核加上u-boot引导所需要的文件头,具体做法如下:
[root@localhost tftpboot]#mkimage -n 'linux-2.6.13' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage zImage.img
Image Name: linux-2.6.14
Created: Fri Jan 12 17:14:50 2007
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1262504 Bytes = 1232.91 kB = 1.20 MB
Load Address: 0x30008000
Entry Point: 0x30008000
这里解释一下参数的意义:
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)
加上文件头以后,bootm就可以从文件头获取一些信息了
在uboot的help文件里面还有一个命令是boot_zImage这个命令看着貌似能启动zImage文件,没有试过,不知道能不能用,
下载的那几个命令,可以写成一个脚本,直接去执行就好了