日志(须整理)

来源:互联网 发布:破坏电力设备罪 知乎 编辑:程序博客网 时间:2024/04/29 22:23

U-boot启动之学习
任务:
1,用tftp启动内核和文件系统,
2,尝试用u-boot烧写内核和文件系统
3,掌握u-boot的命令的使用
4,理解启动参数
5,资料找到怎样向内核传递参数

现在开发吧
硬件环境:
mini2440
在windows下建立tftp服务器,或者在从虚拟机上的tftp启动
tftp 0x32000000 zImage_N35

could not establish link
TFTP from server 192.168.1.120; our IP address is 192.168.1.70
Filename 'zImage_N35'.
Load address: 0x32000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #####
done
Bytes transferred = 2021488 (1ed870 hex)
FA24x0> boot 0x32000000
Usage:
boot    - boot default, i.e., run 'bootcmd'

FA24x0> bootm 0x32000000
## Booting image at 32000000 ...
Bad Magic Number
FA24x0> bootm 0x32000000
## Booting image at 32000000 ...
Bad Magic Number
FA24x0>

经过查资料才发现,通过U-boot启动的Linux的内核镜像必须是是zImage
郁闷,学习怎么做uImage
呵呵
看来是需要对内核和编译和u-boot编译研究一下,先用u-boot通过USB下载内核和文件系统
烧写吧

编译U-Boot成功后,在u-boot代码的tools目录中生成一些工具,比如mkimage。
将它们复制到/usr/local/bin 目录下,就可以直接使用了。现在我们编译内核需要用到mkimage来
生成U-Boot格式的内核映像文件uImage 。复制完成后在终端输入命令" mkimage "并回车,显示关
于mkimage的提示信息,表示你现在已经可以使用此命令了

在内核的根目录下执行命令进行编译。如果之前编译过,最好先 make clean 一下。然后 make zImage
生成 zImage 的内核(在此之前别忘了参看说明书装载缺省配置文件)。
最后在目录kernel-2.6.29/arch/arm/boot下执行命令           
mkimage -n 'linux-2.6.29' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage uImage.img
生成 U-Boot可以引导的内核,生成的文件名为uImage.img (也可以使用默认设置,
在内核根目录下执行make uImage,生成默认的文件名为uImage)。生成的内核文件都在目录kernel-2.6.13/arch/arm/boot下。


在移植内核时,一般要将内核烧到flash,然后从flash启动.这样一方面老是烧写flash会降低flash寿命,而且费时费力.研究u-boot后,发现一条命令可以直接从tftp下载内核后启动.
命令:
setenv bootcmd tftp 0xa0800000 zImage/;bootm a0800000

注意:命令一定要加/


有一Chris兄弟的帮忙,我想我站在了巨人的肩膀上了
主机Win+VM+fedora10
arm-linux-gcc(4.3.2)

下面设置u-boot从nfs引导内核和文件系统

1.首先设置u-boot的启动参数(前提是nfs服务已建立好)此处不再多说,网上的教程大把把的
我的Linux的主机的ip:192.168.1.111
rootfs:/work/root_qtopia
zImage:/work/root_qtopia

setenv bootargs console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.111:/work/root_qtopia ip=192.168.1.8:192.168.1.111:192.168.1.1:255.255.255.0:localhost:eth0:off init=/linuxrc

备件一下原始的参数,以作参考
[u-boot@MINI2440]# printenv
bootargs=noinitrd root=/dev/nfs rw nfsroot=192.168.1.3:/home/tekkaman/working/nf
s/rootfs ip=192.168.1.8:192.168.1.3::255.255.255.0 console=ttySAC0,115200 init=/
linuxrc mem=64M
bootcmd=nfs 0x30008000 192.168.1.3:/home/tekkaman/working/nfs/zImage.img;bootm
bootdelay=1
baudrate=115200
ethaddr=08:08:11:18:12:27
ipaddr=192.168.1.8
netmask=255.255.255.0
tekkaman=bmp d 70000
 stdin=serial
stdout=serial
stderr=serial
serverip=192.168.1.111

Environment size: 436/65532 bytes


参考上面
setenv bootargs noinitrd root=/dev/nfs rw nfsroot=192.168.1.111:/work/root_qtopia ip=192.168.1.8:192.168.1.111::255.255.255.0 console=ttySAC0,115200 init=/linuxrc mem=64M

setenv bootcmd nfs 0x30008000 192.168.1.111:/work/root_qtopia/image/zImage/;bootm

错误信息

[u-boot@MINI2440]# nfs 0x32000000 192.168.1.111:/work/root_qtopia/uImage.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
File transfer via NFS from server 192.168.1.111; our IP address is 192.168.1.8
Filename '/work/root_qtopia/uImage.img'.
Load address: 0x32000000
Loading: #*** ERROR: Cannot umount
[u-boot@MINI2440]#


TFTP from server 192.168.1.111; our IP address is 192.168.1.8
Filename 'uImage.img'.
Load address: 0x30008000
Loading: *
TFTP error: 'Unsupported option(s) requested' (8)
Starting again


实现这个
setenv bootargs console=ttyS0,115200 root=/work/root_qtopia rw
setenv bootcmd tftp 0x30008000 uImage/; bootm 0x30008000


目前我确定Linux主机上nfs文件系统可用,因为已经实现了挂载,网络也是通的。从u-boot可以ping通linux主机


[u-boot@MINI2440]# boot
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
File transfer via NFS from server 192.168.1.111; our IP address is 192.168.1.8
Filename '/work/root_qtopia/zImage.img'.
Load address: 0x30008000
Loading: #*** ERROR: Cannot umount

setenv bootcmd tftp 0x30008000 uImage.img/;bootm 0x30008000

结果还是有点
File transfer via NFS from server 192.168.1.111; our IP address is 192.168.1.8
Filename '/work/root_qtopia/image/uImage.img'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #####*** ERROR: Cannot umount
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   linux-2.6.29
   Created:      2009-08-27   8:39:15 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2021556 Bytes =  1.9 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

到这里不知道是不是内核的问题,还是别的
文件系统怎么自动挂载上的,也不清楚。
郁闷中。。。。。。。