用Qemu模拟vexpress-a9 (三)--- 实现用u-boot引导Linux内核
环境介绍
Win7 64 + Vmware 11 + ubuntu14.04 32
u-boot 版本:u-boot-2015-04
Linux kernel版本:linux-3.16.y
busybox版本:1_24_stable
交叉编译工具链:arm-linux-gnueabi-
qemu版本:stable-2.4
概述
这里我采用的方法是,利用网络引导的方式启动Linux内核。具体方式如下:
开启Qemu的网络支持功能,启动u-boot,设置u-boot的环境变量,u-boot采用tftp的方式将uImage格式的Linux内核下载到内存地址0x60003000处,为什么是0x60000000起始的地址,参考文件u-boot的配置文件 include/configs/vexpress_common.h。如果用Qemu直接启动Kernel,是通过-append parameter 的方式给kernel传参的,现在是通过u-boot,那么需要通过u-boot的环境变量bootargs,可以设置为如下值 setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0 console=tty0'。 然后设置u-boot环境变量bootcmd,如下: setenv bootcmd 'tftp 0x60003000 uImage; bootm 0x60003000'.
具体步骤
1、启动Qemu的网络支持
这个请参考博客:http://www.cnblogs.com/pengdonglin137/p/5023340.html
2、配置u-boot
主要是修改include/configs/vexpress_common.h
diff --git a/include/configs/vexpress_common.h b/include/configs/vexpress_common.h
index 0c1da01..9fa7d9e
--- a/include/configs/vexpress_common.h
+++ b/include/configs/vexpress_common.h
@@ -, +, @@
#define CONFIG_SYS_TEXT_BASE 0x80800000
#endif +/* netmask */
+#define CONFIG_IPADDR 192.168.11.5
+#define CONFIG_NETMASK 255.255.255.0
+#define CONFIG_SERVERIP 192.168.11.20
+
/*
* Physical addresses, offset from V2M_PA_CS0-3
*/
@@ -, +, @@
#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_GBL_DATA_OFFSET /* Basic environment settings */
-#define CONFIG_BOOTCOMMAND "run bootflash;"
+/* #define CONFIG_BOOTCOMMAND "run bootflash;" */
+#define CONFIG_BOOTCOMMAND "tftp 0x60003000 uImage; setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0'; bootm 0x60003000
+
说明:
这里我把ipaddr等设置为了192.168.11.x网段,这个需要跟br0的网址一致,br0的地址在/etc/qemu-ifuo中修改:
#!/bin/sh echo sudo tunctl -u $(id -un) -t $
sudo tunctl -u $(id -un) -t $ echo sudo ifconfig $ 0.0.0.0 promisc up
sudo ifconfig $ 0.0.0.0 promisc up echo sudo brctl addif br0 $
sudo brctl addif br0 $ echo brctl show
brctl show sudo ifconfig br0 192.168.11.20
然后重新编译u-boot代码
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j2
测试:
qemu-system-arm -M vexpress-a9 \
-kernel u-boot \
-nographic \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0
运行:
U-Boot 2015.07-rc3--gf3edfd3-dirty (Dec - :: -) DRAM: MiB
WARNING: Caches not enabled
Flash: MiB
MMC: MMC:
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: smc911x-
Warning: smc911x- using MAC address from net device Hit any key to stop autoboot:
VExpress# ping 192.168.11.20
smc911x: MAC :::::
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC :::::
Using smc911x- device
smc911x: MAC :::::
host 192.168.11.20 is alive
2、配置Linux Kernel
因为要用u-boot引导,所以需要把Kernel编译成uImage格式。
执行如下命令:
make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=./out_vexpress_3_16 uImage -j2
编译时会报错:
make[]: Entering directory `/root/tq2440_work/kernel/linux-stable/out_vexpress_3_16'
CHK include/config/kernel.release
GEN ./Makefile
CHK include/generated/uapi/linux/version.h
Using .. as source for kernel
CHK include/generated/utsrelease.h
make[]: `include/generated/mach-types.h' is up to date.
CALL ../scripts/checksyscalls.sh
CHK include/generated/compile.h
CHK kernel/config_data.h
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
multiple (or no) load addresses:
This is incompatible with uImages
Specify LOADADDR on the commandline to build an uImage
make[]: *** [arch/arm/boot/uImage] Error
make[]: *** [uImage] Error
make: *** [sub-make] Error
这里需要我们制定LOADADDR的值,即uImage的加载地址,根据u-boot,我们可以将其设置为0x60003000.
修改后的命令如下:
make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=./out_vexpress_3_16 LOADADDR=0x60003000 uImage -j2
编译信息:
make[]: Entering directory `/root/tq2440_work/kernel/linux-stable/out_vexpress_3_16'
CHK include/config/kernel.release
GEN ./Makefile
CHK include/generated/uapi/linux/version.h
Using .. as source for kernel
CHK include/generated/utsrelease.h
make[]: `include/generated/mach-types.h' is up to date.
CALL ../scripts/checksyscalls.sh
CHK include/generated/compile.h
CHK kernel/config_data.h
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-3.16.
Created: Sat Dec ::
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: Bytes = 3248.73 kB = 3.17 MB
Load Address: 0x60003000
Entry Point: 0x60003000
Image arch/arm/boot/uImage is ready
编译生成的uImage在 linux-stable/out_vexpress_3_16/arch/arm/boot下,然后将uImage拷贝到/tftpboot目录下,关于tftp服务器的配置请参考:
http://files.cnblogs.com/files/pengdonglin137/ubuntu-12.04%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.pdf
3、测试
执行如下命令:
qemu-system-arm -M vexpress-a9 \
-kernel /root/tq2440_work/u-boot/u-boot/u-boot \
-nographic \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0 \
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3
启动信息:
sudo tunctl -u root -t tap0
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl addif br0 tap0
brctl show
bridge name bridge id STP enabled interfaces
br0 .000c290bd2f3 no eth0
tap0 U-Boot 2015.07-rc3--gf3edfd3-dirty (Dec - :: -) DRAM: MiB
WARNING: Caches not enabled
Flash: MiB
MMC: MMC:
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: smc911x-
Warning: smc911x- using MAC address from net device Hit any key to stop autoboot:
smc911x: MAC :::::
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC :::::
Using smc911x- device
TFTP from server 192.168.11.20; our IP address is 192.168.11.5
Filename 'uImage'.
Load address: 0x60003000
Loading: #################################################################
#################################################################
#################################################################
################################
796.9 KiB/s
done
Bytes transferred = (32c328 hex)
smc911x: MAC :::::
## Booting kernel from Legacy Image at ...
Image Name: Linux-3.16.
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: Bytes = 3.2 MiB
Load Address:
Entry Point:
Verifying Checksum ... OK
Loading Kernel Image ... OK Starting kernel ... Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.16. (root@ubuntu) (gcc version 4.7. (Ubuntu/Linaro 4.7.-12ubuntu1) ) # SMP Sat Dec :: PST
CPU: ARMv7 Processor [410fc090] revision (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: ARM-Versatile Express
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
sched_clock: bits at 24MHz, resolution 41ns, wraps every 178956969942ns
PERCPU: Embedded pages/cpu @9fbed000 s7552 r8192 d12928 u32768
Built zonelists in Zone order, mobility grouping on. Total pages:
Kernel command line: root=/dev/mmcblk0 console=ttyAMA0
PID hash table entries: (order: , bytes)
Dentry cache hash table entries: (order: , bytes)
Inode-cache hash table entries: (order: , bytes)
Memory: 513272K/524288K available (4563K kernel code, 190K rwdata, 1292K rodata, 239K init, 149K bss, 11016K reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( kB)
fixmap : 0xffc00000 - 0xffe00000 ( kB)
vmalloc : 0xa0800000 - 0xff000000 ( MB)
lowmem : 0x80000000 - 0xa0000000 ( MB)
modules : 0x7f000000 - 0x80000000 ( MB)
.text : 0x80008000 - 0x805c01b0 ( kB)
.init : 0x805c1000 - 0x805fcd80 ( kB)
.data : 0x805fe000 - 0x8062dba0 ( kB)
.bss : 0x8062dba8 - 0x8065336c ( kB)
SLUB: HWalign=, Order=-, MinObjects=, CPUs=, Nodes=
Hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS= to nr_cpu_ids=.
RCU: Adjusting geometry for rcu_fanout_leaf=, nr_cpu_ids=
NR_IRQS: nr_irqs:
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
smp_twd: clock not found -
Console: colour dummy device 80x30
Calibrating local timer... .21MHz.
Calibrating delay loop... 310.68 BogoMIPS (lpj=)
pid_max: default: minimum:
Mount-cache hash table entries: (order: , bytes)
Mountpoint-cache hash table entries: (order: , bytes)
CPU: Testing write buffer coherency: ok
missing device node for CPU
CPU0: thread -, cpu , socket , mpidr
Setting up static identity map for 0x604546d0 - 0x60454728
Brought up CPUs
SMP: Total of processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.: implementor architecture part variant rev
regulator-dummy: no parameters
NET: Registered protocol family
DMA: preallocated KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
mb:uart0: ttyAMA0 at MMIO 0x10009000 (irq = , base_baud = ) is a PL011 rev1
console [ttyAMA0] enabled
mb:uart1: ttyAMA1 at MMIO 0x1000a000 (irq = , base_baud = ) is a PL011 rev1
mb:uart2: ttyAMA2 at MMIO 0x1000b000 (irq = , base_baud = ) is a PL011 rev1
mb:uart3: ttyAMA3 at MMIO 0x1000c000 (irq = , base_baud = ) is a PL011 rev1
fixed-dummy: no parameters
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource v2m-timer1
NET: Registered protocol family
TCP established hash table entries: (order: , bytes)
TCP bind hash table entries: (order: , bytes)
TCP: Hash tables configured (established bind )
TCP: reno registered
UDP hash table entries: (order: , bytes)
UDP-Lite hash table entries: (order: , bytes)
NET: Registered protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4. backchannel transport module.
CPU PMU: probing PMU on CPU
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, counters available
futex hash table entries: (order: , bytes)
squashfs: version 4.0 (//) Phillip Lougher
jffs2: version 2.2. (NAND) © - Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
msgmni has been set to
io scheduler noop registered (default)
clcd-pl11x ct:clcd: PL111 rev2 at 0x10020000
clcd-pl11x ct:clcd: CT-CA9X4 hardware, XVGA display
Console: switching to colour frame buffer device 128x48
physmap platform flash device: at
physmap-flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
physmap platform flash device: at
physmap-flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(): "physmap-flash"
(): "physmap-flash"
into device "physmap-flash"
libphy: smsc911x-mdio: probed
smsc911x smsc911x eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=smsc911x-fffffff:, irq=-)
smsc911x smsc911x eth0: MAC Address: :::::
isp1760 isp1760: NXP ISP1760 USB Host Controller
isp1760 isp1760: new USB bus registered, assigned bus number
isp1760 isp1760: Scratch test failed.
isp1760 isp1760: can't setup: -19
isp1760 isp1760: USB bus deregistered
isp1760: Failed to register the HCD device
usbcore: registered new interface driver usb-storage
mousedev: PS/ mouse device common for all mice
rtc-pl031 mb:rtc: rtc core: registered pl031 as rtc0
mmci-pl18x mb:mmci: mmc0: PL181 manf rev0 at 0x10005000 irq , (pio)
input: AT Raw Set keyboard as /devices/mb:kmi0/serio0/input/input0
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new SD card at address
mmcblk0: mmc0: QEMU! 32.0 MiB
mmcblk0: unknown partition table
aaci-pl041 mb:aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
aaci-pl041 mb:aaci: FIFO entries
oprofile: using arm/armv7-ca9
TCP: cubic registered
NET: Registered protocol family
9pnet: Installing 9P2000 support
rtc-pl031 mb:rtc: setting system clock to -- :: UTC ()
ALSA device list:
#: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
input: ImExPS/ Generic Explorer Mouse as /devices/mb:kmi1/serio1/input/input2
kjournald starting. Commit interval seconds
EXT3-fs (mmcblk0): using internal journal
EXT3-fs (mmcblk0): recovery complete
EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) on device :.
Freeing unused kernel memory: 236K (805c1000 - 805fc000)
random: nonblocking pool is initialized
mount: mounting none on /proc/bus/usb failed: No such file or directory Please press Enter to activate this console. [root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]# ls
bin etc linuxrc mnt root sys usr
dev lib lost+found proc sbin tmp var
[root@vexpress ]# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 B) TX bytes: (0.0 B) [root@vexpress ]# ifconfig eth0 192.168.11.5
smsc911x smsc911x eth0: SMSC911x/921x identified at 0xa0a40000, IRQ:
[root@vexpress ]# ping 192.168.11.20
PING 192.168.11.20 (192.168.11.20): data bytes
bytes from 192.168.11.20: seq= ttl= time=20.928 ms
bytes from 192.168.11.20: seq= ttl= time=1.250 ms
bytes from 192.168.11.20: seq= ttl= time=0.573 ms
^C
--- 192.168.11.20 ping statistics ---
packets transmitted, packets received, % packet loss
round-trip min/avg/max = 0.573/7.583/20.928 ms
[root@vexpress ]#
可以在/etc/init.d/rcS中设置eth0的ip地址为 ifconfig eth0 192.168.11.5
4、开启图形界面
修改u-boot的bootargs环境变量为:
setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0 console=tty0';
执行命令:
qemu-system-arm -M vexpress-a9 \
-kernel /root/tq2440_work/u-boot/u-boot/u-boot \
-nographic \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0 \
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3
截图:
未完待续。
用Qemu模拟vexpress-a9 (三)--- 实现用u-boot引导Linux内核的更多相关文章
- Linux内核设计第三周学习总结 跟踪分析Linux内核的启动过程
陈巧然 原创作品 转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 实验步骤 登陆实验楼虚 ...
- qemu通过命令行直接引导linux内核启动
qemu -kernel vmlinuz-3.14.0 -hda img_custom -append root=/dev/sda1
- 用QEMU模拟运行uboot从SD卡启动Linux
平台:Qemu + vexpress-a9 u-boot:u-boot-2019.10 Linux:linux-4.14.13 之前介绍过用Qemu模拟运行uboot,然后从网络启动lin ...
- qemu模拟vexpress-a9及u-boot引导 linux
前言 本文讲述使用 qemu 来模拟 vexpress-a9 开发板 ,同时介绍使用 u-boot 引导 linux 的流程.整个坐下来对 qemu 和 u-boot 以及嵌入式 linux 的工作方 ...
- 用Qemu模拟vexpress-a9 (二) --- 搭建u-boot调试环境
参考: http://blog.csdn.net/caspiansea/article/details/12986565 环境介绍 Win7 64 + Vmware 11 + ubuntu14.04 ...
- 《Linux内核分析》课程第三周学习总结
姓名:何伟钦 学号:20135223 ( *原创作品转载请注明出处*) ( 学习课程:<Linux内核分析>MOOC课程http://mooc.study.163.com/course/U ...
- Linux内核分析作业三
构造一个简单的Linux系统MenuOS 复习 计算机三大法宝 存储程序计算机 函数调用堆栈 中断 操作系统两把宝剑 中断上下文的切换 进程上下文的切换 一.Linux内核源代码简介 函数目录 Lin ...
- 《Linux内核分析》第三周:Linux系统启动过程
杨舒雯 原创作品转载请注明出处 Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.实验--使用gdb跟踪调试内 ...
- 作业三--Linux内核分析
一.Linux内核源码 arch目录支持不同CPU的源代码,是内核源码中比较大的文件. fs文件系统Linux内核的源码放在kernel目录中. 二.构造一个简单的Linux系统MenuOS 三.使用 ...
随机推荐
- C#验证身份证号码
一.18位的身份证号码 如:130429####%%%%00781.1~6位为地区代码,其中1.2位数为各省级政府的代码,3.4位数为地.市级政府的代码,5.6位数为县.区级政府代码.如13(河北省) ...
- ActiveReports 报表应用教程 (9)---交互式报表之动态排序
在 ActiveReports 中除了提供对数据源进行排序的功能之外,还提供了最终用户排序功能,最终用户可以对报表进行区域内排序和整个数据源排序,结合数据钻取.过滤等功能可以让用户更方便地分析报表数据 ...
- 小白学Linux(五)--VI/VIM编辑器
我们操作文件,终究离不开编辑文件,对文件内容的编辑,Linux系统下,我们通常使用VI/VIM来编辑文件.VI是每个Linux都会自带的文本编辑器,VIM是VI的增强版,可能有些发行版本没有自带,可以 ...
- Mongoose 框架初学使用记录
嘛.... 最近由于需要使用HTTP服务端,原先是使用的Qt框架实现的HTTP服务端,然后发现有些缺陷导致我不得不放弃这个框架,也不是完全放弃,只是HTTP服务端这里不再使用Qt,用Qt做高并发真的有 ...
- 泛函编程(10)-异常处理-Either
上节我们介绍了新的数据类型Option:一个专门对付异常情况出现时可以有一致反应所使用的数据类型.Option可以使编程人员不必理会出现异常后应该如何处理结果,他只是获得了一个None值,但这个Non ...
- mysql 64 zip download
open the url :: http://dev.mysql.com/downloads/file/?id=461109 and click the location "no tha ...
- ahjesus解决win下U盘无法写入的问题
可能是由于不同品牌的U盘出厂时磁盘分区和格式化方式不同而引起的兼容性问题.解决方案如下 启动cmd.输入diskpart,启动DISKPART工具 在DISKPART窗口中输入以下命令: >li ...
- 为阿里云存储开发的PHP PEAR 包:Services_Aliyun_OSS
阿里云开放存储服务 OSS:用于存储图片.apk等静态资源,使用阿里云带宽,不占用开发者服务器带宽. 阿里云官方PHP SDK: http://aliyun.com/product/oss/#help ...
- SharePoint 2013 点击"关注" 报错
现象: 点击"关注" 报错. 解决办法: 1.确保bin文件夹下的.dll版本与web.config一致. 2.设置user porfile权限. 2.重启iis 结果如下:
- iOS设计模式之代理模式
代理模式 基本理解 代理模式(Proxy),为其他对象提供一种代理以控制对这个对象的访问. 代理模式的应用 远程代理:就是为一个对象在不同的地址空间提供据不代表.这样可以隐藏一个对象存在于不同地址空间 ...