qemu下u-boot+kernel+rootfs完整启动移植手册

2020-04-03 00:01

东拼西凑终于把u-boot+kernel+rootfs完整的启动成功了!以下是过程的总结,软件包官网上可以下载到。 先把一些库装上,嘎嘎:

安装zilb库

#sudo apt-get install zlib1g-dev 安装glib2.12

#wget http://ftp.gtk.org/pub/glib/2.12/glib-2.12.0.tar.bz2

#tar jxf glib-2.12.0.tar.bz2 #cd glib-2.12.0

#./confugure(出现错误 安装gettext 再次就可以执行) #sudo make

#sudo make install 安装autoreconf

#sudo apt-get install dh-autoreconf 安装libsdl1.2

#sudo apt-get install libsdl1.2-dev

一、安装qemu 1、下载qemu

#tar zxvf qemu-0.14.0.tar.gz #cd qemu??

#git clone git://git.qemu.org/qemu.git 2、安装qemu

#sudo chmod 777 /opt?? 将qemu安装在/opt下

#./configure --prefix=/opt/qemu --target-list=arm-softmmu,arm-linux-user --enable-debug?? # make

# sudo make install 3、测试qemu是否能启动

#tar zxvf arm-test-0.2.tar.gz?? #cd arm-test??

#qemu-system-arm -kernel zImage.integrator -initrd arm_root.img?? 弹出界面,ok!!!

二、安装交叉编译工具 这里安装编译工具4.3.2。 1、安装4.3.2

#tar xvf arm-linux-gcc-4.3.2.tgz

#mv -f “you path”/usr/local/arm/* /usr/local/arm #sudo gedit /etc/profile

末行添加export PATH=/usr/local/arm/4.3.2/bin:$PATH

#source /etc/profile 2、测试qemu

你可以写一个Hello World!!!的C程序来进行测试。

#arm-none-linux-gnueabi-gcc -o hello hello.c??

#qemu-arm -L “your path”/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc hello??

三、安装u-boot 1、下载和解压

2、修改源码(后期方便制作文件系统) u-boot-2010.03/common/image.c中,941行处

#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) 改为:

#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) || defined(CONFIG_VERSATILE)

u-boot-2010.03/include/configs/versatile.h中,124行处

#define CONFIG_BOOTDELAY 2 #define CONFIG_BOOTARGS \ \改为:

#define CONFIG_BOOTARGS \ #define CONFIG_BOOTCOMMAND \ #define CONFIG_INITRD_TAG 1 3、编译u-boot

#make ARCH=arm CROSS_COMPILE=arm-linux- versatilepb_config #make ARCH=arm CROSS_COMPILE=arm-linux- 4、测试u-boot

qemu-system-arm -M versatilepb -nographic -kernel u-boot.bin

四、编译linux内核

#tar xvf linux-2.6.34.14.tar.xz #cd linux-2.6.34.14

#make ARCH=arm versatile_defconfig #make ARCH=arm menuconfig

进入图形配置界面将Kernel Featurer中的Use the ARM EABI to compile the kernel选上

#make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi all

在arch/arm/boot/下会生成zImage文件,该文件就是后期制作kernel的bin文件用的kernel镜像文件。 测试一下:

qemu-system-arm -M versatilepb -kernel zImage

五、编译busybox

#tar xvf busybox-1.20.0.tar.bz2 #cd busybox-1.20.0

#make ARCH=arm CROSS_COMPILE=arm-linux- defconfig 将init/init.c

694 new_init_action(ASKFIRST,bb_default_login_shell,VC_2); 695 new_init_action(ASKFIRST,bb_default_login_shell,VC_3); 696 new_init_action(ASKFIRST,bb_default_login_shell,VC_4); 这三行注释掉

#make menuconfig 进入图形配置界面 将

Busybox Settings –> Build Options –> Build Busybox as a static binary勾上 Networking Utilities -> inetd去掉

#make ARCH=arm CROSS_COMPILE=arm-linux- install 完成后,在本目录会生成_install目录。

六、制作文件系统

#cd busybox-1.20.0/_install

#mkdir proc sys dev etc etc/init.d

#vim etc/init.d/rcS 添加内容

#!/bin/sh

mount -t proc none /proc mount -t sysfs none /sys /sbin/mdev -s 修改rcS权限 #chmod 777 rcS

#cd _install

#find . | cpio -o --format=newc > ../rootfs.img #cd ..

#gzip -c rootfs.img > rootfs.img.gz 测试kernel和rootfs:

将zImage拷贝到busybox-1.20.0/下

qemu-system-arm -M versatilepb -kernel zImage -initrd rootfs.img.gz -append \

七、制作flash文件

到此,我们有了u-boot.bin、zImage和rootfs.img.gz文件:

#mkimage -A arm -C none -O linux -T kernel -d zImage -a 0x00010000 -e 0x00010000 zImage.uimg

#mkimage -A arm -C none -O linux -T ramdisk -d rootfs.img.gz -a 0x00800000 -e 0x00800000 rootfs.uimg #dd if=/dev/zero of=flash.bin bs=1 count=6M

#dd if=u-boot.bin of=flash.bin conv=notrunc bs=1

#dd if=zImage.uimg of=flash.bin conv=notrunc bs=1 seek=2M #dd if=rootfs.uimg of=flash.bin conv=notrunc bs=1 seek=4M 将flash.bin文件加载到qemu下运行。

#qemu-system-arm -M versatilepb -m 128M -kernel flash.bin -serial stdio 如果没有自动加载内核,在虚拟机终端下:

VersatilePB#printenv

VersatilePB#bootm 0x210000 0x410000

在qemu图形界面下键入回车,启动文件系统成功!

如果失败,可以执行如下命令,会打印出错信息:

#qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append \mem=128M rdinit=/sbin/init\

参考文献:

http://elinux.org/Virtual_Development_Board#Load_Linux_Kernel

http://www.linuxforu.com/2011/06/qemu-for-embedded-systems-development-part-1/ http://www.linuxforu.com/2011/07/qemu-for-embedded-systems-development-part-2/ http://www.linuxforu.com/2011/08/qemu-for-embedded-systems-development-part-3/ http://www.verydemo.com/demo_c167_i25921.html http://blog.csdn.net/luckpiky/article/details/7381350

http://www.52rd.com/Blog/Archive_Thread.asp?SID=22503 http://wenku.http://www.wodefanwen.com//view/9cc8d64ffe4733687e21aad2.html

《基于qemu+busybox+ddd的调试用Linux环境(X86版)V1.0.0》


qemu下u-boot+kernel+rootfs完整启动移植手册.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:微生物学实验教案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: