环境介绍

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内核的更多相关文章

  1. Linux内核设计第三周学习总结 跟踪分析Linux内核的启动过程

    陈巧然 原创作品 转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 实验步骤 登陆实验楼虚 ...

  2. qemu通过命令行直接引导linux内核启动

    qemu -kernel vmlinuz-3.14.0 -hda img_custom -append root=/dev/sda1

  3. 用QEMU模拟运行uboot从SD卡启动Linux

    平台:Qemu + vexpress-a9 u-boot:u-boot-2019.10 Linux:linux-4.14.13       之前介绍过用Qemu模拟运行uboot,然后从网络启动lin ...

  4. qemu模拟vexpress-a9及u-boot引导 linux

    前言 本文讲述使用 qemu 来模拟 vexpress-a9 开发板 ,同时介绍使用 u-boot 引导 linux 的流程.整个坐下来对 qemu 和 u-boot 以及嵌入式 linux 的工作方 ...

  5. 用Qemu模拟vexpress-a9 (二) --- 搭建u-boot调试环境

    参考: http://blog.csdn.net/caspiansea/article/details/12986565 环境介绍 Win7 64 + Vmware 11 + ubuntu14.04 ...

  6. 《Linux内核分析》课程第三周学习总结

    姓名:何伟钦 学号:20135223 ( *原创作品转载请注明出处*) ( 学习课程:<Linux内核分析>MOOC课程http://mooc.study.163.com/course/U ...

  7. Linux内核分析作业三

    构造一个简单的Linux系统MenuOS 复习 计算机三大法宝 存储程序计算机 函数调用堆栈 中断 操作系统两把宝剑 中断上下文的切换 进程上下文的切换 一.Linux内核源代码简介 函数目录 Lin ...

  8. 《Linux内核分析》第三周:Linux系统启动过程

    杨舒雯 原创作品转载请注明出处 Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.实验--使用gdb跟踪调试内 ...

  9. 作业三--Linux内核分析

    一.Linux内核源码 arch目录支持不同CPU的源代码,是内核源码中比较大的文件. fs文件系统Linux内核的源码放在kernel目录中. 二.构造一个简单的Linux系统MenuOS 三.使用 ...

随机推荐

  1. 设计 api, url 的原则

    设计 api, url 的原则 做微信公众号的项目,账号体系使用微信的 openid.现在增加需求,要求适应 web 端--做成普通的 web 项目.然后 url 的变化:我想给现有的 url 加上 ...

  2. codeforces 689 E. Mike and Geometry Problem 组合数学 优先队列

    给定一个函数: f([l,r]) = r - l + 1; f(空集) = 0; 即f函数表示闭区间[l,r]的整点的个数 现在给出n个闭区间,和一个数k 从n个区间里面拿出k个区间,然后对这k个区间 ...

  3. 7款超酷HTML5 3D动画精选应用及源码

    对以前来讲,3D动画拿到网页上展示是一件非常奢侈的事情,第一是浏览器不够先进,第二是大部分只能用flash实现伪3D.HTML5的出现,让实现网页3D动画变得非常简单,当然前提是你不要再使用像IE67 ...

  4. Silverlight动画的基本知识、关键帧动画

    基础知识 (一)动画:是快速播放一系列图像(其中每个图像与下一个图像略微不同)给人造成的一种幻觉 (二)动画类型:两类    (1)From/To/By动画:在起始值和结束值之间进行动画处理.     ...

  5. Android-WizardPager

    https://github.com/HeinrichReimer/Android-WizardPager

  6. phpstudy配置虚拟主机

    配置 phpstudy 虚拟主机 1在httpd.conf中  把#Include conf/extra/httpd-vhosts.conf前面的#去掉 2在站点域名管理 添加 要配置的 虚拟主机 添 ...

  7. .NET到Node.js

    从.NET到Node.js谈前后端分离实践(by vczero)   一.最初的[无分离]实践 11年末的时候,用winForm开发程序,拖拖控件,点点按钮,连接数据库,做一些基本的管理系统:Java ...

  8. 使用deb 打包开发的postgres extension

    昨天写过一个使用rpm 打包分发pg 扩展的demo,今天使用deb 进行打包分发,同时使用checkinstall 生成我们的deb包 安装deb 依赖 sudo apt-get install c ...

  9. 28-1-LTDC显示中英文

    1.字符编码 由于计算机只能识别 0 和 1,文字也只能以 0 和 1 的形式在计算机里存储,所以我们需要对文字进行编码才能让计算机处理,编码的过程就是规定特定的 01 数字串表示特定的文字,最简单的 ...

  10. gensim使用方法以及例子

    来自:https://blog.csdn.net/u014595019/article/details/52218249 gensim是一个Python的自然语言处理库,能够将文档根据TF-IDF,L ...