作者信息

作者: 彭东林

邮箱: pengdonglin137@163.com

QQ: 405728433

软件平台

主机: Ubuntu14.04 64位版本

模拟器:Qemu-2.8.0

Linux内核版本: Linux-4.10

Busybox版本:busybox-1.24.2

工具链: arm-none-linux-gnueabi-gcc  (gcc version 4.8.3 20140320)

具备的功能

模拟一个vexpress 双核或者单核的环境,采用NFS跟Host共享一些文件,为了简单起见,根文件系统使用的是ramdisk格式。

正文

1、编译Qemu模拟器

请参考博文用qemu搭建aarch64学习环境

2、下载工具链

登录这个网址:http://www.veryarm.com/arm-none-linux-gnueabi-gcc

我们这里使用的是最新的Linux解压版:

3、下载编译最新的Linux内核

登录https://www.kernel.org/,   下载最新的Linux版本,目前最新的是Linux-4.10

下面是编译下面要用的kernel的命令:

     #!/bin/bash
cross_compile=/home/pengdonglin/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-
#make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 vexpress_defconfig
make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 menuconfig
make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 zImage -j4
make CROSS_COMPILE=$cross_compile ARCH=arm O=./out_aarch32 dtbs -j4

编译之前可以对kernel进行一下配置

     Kernel Features  --->
Memory split (3G/1G user/kernel split) --->
[*] High Memory Support
Device Drivers --->
[*] Block devices --->
<*> RAM block device support
() Default RAM disk size (kbytes)

这里我们给ramdisk设置的默认大小是8MB,不能比后面我们实际生成的ramdisk.img的size小。

这样就有了我们下面要用到的内核镜像zImage。

4、制作根文件系统

登录https://busybox.net/downloads/下载要用的busybox版本,这里我下的是busybox-1.24.2

要设置的不多:

执行make menuconfig,配置下面几项:

 Build Options  --->
[*] Build BusyBox as a static binary (no shared libs)
(/home/pengdonglin/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-) Cross Compiler prefix

然后执行make && make install命令

下面制作启动用的ramdisk,我把这个过程写成了脚本,如下:

 #!/bin/bash
sudo rm -rf rootfs
sudo rm -rf tmpfs
sudo rm -rf ramdisk*
sudo mkdir rootfs
sudo cp ../busybox-1.24./_install/* rootfs/ -raf
sudo mkdir -p rootfs/proc/
sudo mkdir -p rootfs/sys/
sudo mkdir -p rootfs/tmp/
sudo mkdir -p rootfs/root/
sudo mkdir -p rootfs/var/
sudo mkdir -p rootfs/mnt/
sudo cp etc rootfs/ -arf
sudo cp -arf ../arm-2014.05/arm-none-linux-gnueabi/libc/lib rootfs/
sudo rm -rf rootfs/lib/*.a
sudo ../arm-2014.05/bin/arm-none-linux-gnueabi-strip rootfs/lib/*
sudo mkdir -p rootfs/dev/
sudo mknod rootfs/dev/tty1 c 4 1
sudo mknod rootfs/dev/tty2 c 4 2
sudo mknod rootfs/dev/tty3 c 4 3
sudo mknod rootfs/dev/tty4 c 4 4
sudo mknod rootfs/dev/console c 5 1
sudo mknod rootfs/dev/null c 1 3
sudo dd if=/dev/zero of=ramdisk bs=1M count=8
sudo mkfs.ext4 -F ramdisk
sudo mkdir -p tmpfs
sudo mount -t ext4 ramdisk ./tmpfs/ -o loop
sudo cp -raf rootfs/* tmpfs/
sudo umount tmpfs
sudo gzip --best -c ramdisk > ramdisk.gz
sudo mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img

制作ramdisk用到的文件到这里下载。

5、Qemu支持网络

请参考博客:

用Qemu模拟vexpress-a9 --- 配置 qemu 的网络功能

用Qemu模拟vexpress-a9 (三)--- 实现用u-boot引导Linux内核

6、测试

支持网络的启方法:

     sudo qemu-system-arm \
-M vexpress-a9 \
-m 1024M \
-smp \
-kernel ./linux-4.10/out_aarch32/arch/arm/boot/zImage \
-nographic \
-append "root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel" \
-initrd ./rootfs/ramdisk.img \
-dtb ./linux-4.10/out_aarch32/arch/arm/boot/dts/vexpress-v2p-ca9.dtb \
-net nic,vlan= -net tap,vlan=,ifname=tap0
nfs挂载:
mount -t nfs -o nolock 192.168.1.6:/nfsroot /mnt

下面是启动信息:

    $./run.sh
sudo tunctl -u root -t tap0
TUNSETIFF: Device or resource busy
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl addif br0 tap0
brctl show
bridge name bridge id STP enabled interfaces
br0 .eada212d369f no eth0
tap0
Booting Linux on physical CPU 0x0
Linux version 4.10. (pengdonglin@pengdonglin-dell) (gcc version 4.8. (prerelease) (Sourcery CodeBench Lite 2014.05-) ) # SMP Sat Feb :: CST
CPU: ARMv7 Processor [410fc090] revision (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
OF: fdt:Machine model: V2P-CA9
debug: ignoring loglevel setting.
Memory policy: Data cache writealloc
On node totalpages:
free_area_init_node: node , pgdat c092af80, node_mem_map ef7fa000
Normal zone: pages used for memmap
Normal zone: pages reserved
Normal zone: pages, LIFO batch:
HighMem zone: pages, LIFO batch:
percpu: Embedded pages/cpu @ef7b9000 s23424 r8192 d21632 u53248
pcpu-alloc: s23424 r8192 d21632 u53248 alloc=*
pcpu-alloc: [] [] [] []
Built zonelists in Zone order, mobility grouping on. Total pages:
Kernel command line: root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel
log_buf_len individual max cpu contribution: bytes
log_buf_len total cpu_extra contributions: bytes
log_buf_len min size: bytes
log_buf_len: bytes
early log buf free: (%)
PID hash table entries: (order: , bytes)
Dentry cache hash table entries: (order: , bytes)
Inode-cache hash table entries: (order: , bytes)
Memory: 1028136K/1048576K available (5120K kernel code, 174K rwdata, 1224K rodata, 1024K init, 177K bss, 20440K reserved, 0K cma-reserved, 262144K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( kB)
fixmap : 0xffc00000 - 0xfff00000 ( kB)
vmalloc : 0xf0800000 - 0xff800000 ( MB)
lowmem : 0xc0000000 - 0xf0000000 ( MB)
pkmap : 0xbfe00000 - 0xc0000000 ( MB)
modules : 0xbf000000 - 0xbfe00000 ( MB)
.text : 0xc0008000 - 0xc0600000 ( kB)
.init : 0xc0800000 - 0xc0900000 ( kB)
.data : 0xc0900000 - 0xc092bb80 ( kB)
.bss : 0xc092d000 - 0xc0959448 ( kB)
SLUB: HWalign=, Order=-, MinObjects=, CPUs=, Nodes=
Hierarchical RCU implementation.
Build-time adjustment of leaf fanout to .
RCU restricting CPUs from NR_CPUS= to nr_cpu_ids=.
RCU: Adjusting geometry for rcu_fanout_leaf=, nr_cpu_ids=
NR_IRQS: nr_irqs:
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C- enabling early BRESP for Cortex-A9
L2C- full line of zeros enabled for Cortex-A9
L2C- dynamic clock gating disabled, standby mode disabled
L2C- cache controller enabled, ways, kB
L2C-: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
smp_twd: clock not found -
sched_clock: bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: ns
Failed to initialize '/smb@04000000/motherboard/iofpga@7,00000000/timer@12000': -
Console: colour dummy device 80x30
Calibrating local timer... .23MHz.
Calibrating delay loop... 746.70 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
CPU0: thread -, cpu , socket , mpidr
Setting up static identity map for 0x60100000 - 0x60100058
smp: Bringing up secondary CPUs ...
CPU1: thread -, cpu , socket , mpidr
CPU2: failed to boot: -
CPU3: failed to boot: -
smp: Brought up node, CPUs
SMP: Total of processors activated (1487.66 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.: implementor architecture part variant rev
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: ns
futex hash table entries: (order: , bytes)
NET: Registered protocol family
DMA: preallocated KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
OF: amba_device_add() failed (-) for /memory-controller@100e0000
OF: amba_device_add() failed (-) for /memory-controller@100e1000
OF: amba_device_add() failed (-) for /watchdog@100e5000
irq: type mismatch, failed to map hwirq- for /interrupt-controller@1e001000!
.uart: ttyAMA0 at MMIO 0x10009000 (irq = , base_baud = ) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = , base_baud = ) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = , base_baud = ) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = , base_baud = ) is a PL011 rev1
OF: amba_device_add() failed (-) for /smb@/motherboard/iofpga@,/wdt@0f000
SCSI subsystem initialized
libata version 3.00 loaded.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family
TCP established hash table entries: (order: , bytes)
TCP bind hash table entries: (order: , bytes)
TCP: Hash tables configured (established bind )
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.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
Freeing initrd memory: 2528K
hw perfevents: enabled with armv7_cortex_a9 PMU driver, counters available
workingset: timestamp_bits= max_order= bucket_order=
squashfs: version 4.0 (//) Phillip Lougher
jffs2: version 2.2. (NAND) © - Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
bounce: pool size: pages
io scheduler noop registered (default)
clcd-pl11x .clcd: PL111 designer rev2 at 0x10020000
clcd-pl11x .clcd: /clcd@ hardware, 1024x768@ display
Console: switching to colour frame buffer device 128x48
clcd-pl11x 1001f000.clcd: PL111 designer rev2 at 0x1001f000
clcd-pl11x 1001f000.clcd: /smb@/motherboard/iofpga@,/clcd@1f000 hardware, 640x480@ display
brd: module loaded
.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
erase region : offset=0x0,size=0x80000,blocks=
.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
erase region : offset=0x0,size=0x80000,blocks=
Concatenating MTD devices:
(): "40000000.flash"
(): "40000000.flash"
into device "40000000.flash"
libphy: Fixed MDIO Bus: probed
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: MAC Address: :::::
isp1760 4f000000.usb: bus width: , oc: digital
isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
isp1760 4f000000.usb: new USB bus registered, assigned bus number
isp1760 4f000000.usb: Scratch test failed.
isp1760 4f000000.usb: can't setup: -19
isp1760 4f000000.usb: USB bus deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/ mouse device common for all mice
rtc-pl031 .rtc: rtc core: registered pl031 as rtc0
mmci-pl18x .mmci: Got CD GPIO
mmci-pl18x .mmci: Got WP GPIO
mmci-pl18x .mmci: mmc0: PL181 manf rev0 at 0x10005000 irq , (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
input: AT Raw Set keyboard as /devices/platform/smb@/smb@:motherboard/smb@:motherboard:iofpga@,/.kmi/serio0/input/input0
aaci-pl041 .aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
aaci-pl041 .aaci: FIFO entries
oprofile: using arm/armv7-ca9
NET: Registered protocol family
9pnet: Installing 9P2000 support
Registering SWP/SWPB emulation handler
rtc-pl031 .rtc: setting system clock to -- :: UTC ()
ALSA device list:
#: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 33
input: ImExPS/ Generic Explorer Mouse as /devices/platform/smb@/smb@:motherboard/smb@:motherboard:iofpga@,/.kmi/serio1/input/input2
RAMDISK: gzip image found at block
EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device :.
Freeing unused kernel memory: 1024K
Generic PHY 4e000000.etherne:: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:, irq=-)
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xf1420000, IRQ:
Please press Enter to activate this console.
[root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]# mount -t nfs -o nolock 192.168.1.6:/nfsroot /mnt
[root@vexpress ]# cd /mnt
[root@vexpress mnt]# ls
a.out interrupt_gpm4_0.ko passwd
dmesg.log interrupt_xeint14_15.ko shadow3
fdt interrupt_xeint26_29.ko trace

完。

用Qemu搭建aarch32学习环境的更多相关文章

  1. 用Qemu搭建x86_64学习环境

    作者信息 作者:彭东林 邮箱:pengdonglin137@163.com QQ:405728433 软件平台 主机: Ubuntu14.04 64位版本 模拟器:Qemu-2.8.0 Linux内核 ...

  2. 用Qemu搭建x86学习环境

    作者信息 作者:彭东林 邮箱:pengdonglin137@163.com QQ:405728433 软件平台 主机: Ubuntu14.04 64位版本 模拟器:Qemu-2.8.0 Linux内核 ...

  3. 用qemu搭建aarch64学习环境

    作者信息 作者: 彭东林 邮箱: pengdonglin137@163.com QQ: 405728433 软件平台 主机: Ubuntu14.04 64位版本 模拟器:Qemu-2.8.0 Linu ...

  4. 使用Qemu运行Ubuntu文件系统 —— 搭建SVE学习环境(2)

    开发环境 PC:ubuntu18.04 Qemu:4.1 Kernel:Linux-5.2 概述 由于要学习ARM的SVE技术,但是目前还没有支持SVE指令的板子,所以只能用Qemu来模拟,但是发现Q ...

  5. 云端搭建Linux学习环境 链接https://edu.aliyun.com/article/19 (阿里云ECS服务器 )课堂

    云端搭建Linux学习环境 链接https://edu.aliyun.com/article/19 1. 开通云服务器 2 1.包年包月   按量付费(适合测试数据的时候) 2 2.地域   服务器数 ...

  6. 基于Ubuntu+Python+Tensorflow+Jupyter notebook搭建深度学习环境

    基于Ubuntu+Python+Tensorflow+Jupyter notebook搭建深度学习环境 前言一.环境准备环境介绍软件下载VMware下安装UbuntuUbuntu下Anaconda的安 ...

  7. 【MIT6.828】centos7下使用Qemu搭建xv6运行环境

    title:[MIT6.828]centos7下使用Qemu搭建xv6运行环境 date: "2020-05-05" [MIT6.828]centos7下搭建xv6运行环境 1. ...

  8. 使用 qemu 搭建内核开发环境

    本文主要介绍在 MacOS 上使用 qemu 搭建 Linux Kernel 的开发环境.(在开始之前需要注意的是,本文中的 Linux 开发环境是一个远程服务器,而 qemu 被安装在本地的 Mac ...

  9. ubuntu18.04下搭建深度学习环境anaconda2+ cuda9.0+cudnn7.0.5+tensorflow1.7【原创】【学习笔记】

    PC:ubuntu18.04.i5.七彩虹GTX1060显卡.固态硬盘.机械硬盘 作者:庄泽彬(欢迎转载,请注明作者) 说明:记录在ubuntu18.04环境下搭建深度学习的环境,之前安装了cuda9 ...

随机推荐

  1. 小学生之Hibernate插入数据修改数据使用数据库默认值的实现

    最近在写一个案例,定时任务对数据库进行更新操作,废话不多说,上代码: @Component("taskJob") public class TaskJob extends Hibe ...

  2. 关于echarts地图下钻。

     在去年十二月份,前端老大交代个任务,关于地图下钻.这里做了个简单的青岛地图下钻,初学echarts,做的不精,凑合看看吧. 第一步呢,先引入echarts等文件,这是最基本的.  第二步,到官网下载 ...

  3. TFS 测试用例导入、导出工具

    TFS的测试管理提供了测试规划.创建.运行以及进度跟踪等功能.测试人员通过浏览器就几乎可以完成手个测试的全部过程. 用过TFS测试用例的朋友们,很多人应该都知道,在TFS的Portal中以及相应的数据 ...

  4. BOM之history对象(转)

    前面的话 history对象保存着用户上网的历史记录,从窗口被打开的那一刻算起.由于安全方面的考虑,开发人员无法得到用户浏览器的URL,但借由用户访问过的页面列表,可以在不知道实际URL的情况下实现后 ...

  5. Android Studio 提高工作效率的奇技

    1.ctrl+f12 ctrl+f12此快捷键可以调出当前文件的大纲,并通过模糊匹配快速跳转至指定的方法.勾选上“show anonymous classes”后其功能相当于Eclipse中的ctrl ...

  6. Java编程规范(一)

    最近在看一本有关Java编程规范的书,书中精炼阐述了使用java语言时应该遵循的一些原则.接下来的一段时间我将在这里总结我的学习内容,也希望这一系列文章能够对有需要的人有所帮助. 不考虑任何编码规范的 ...

  7. C# 6 与 .NET Core 1.0 高级编程 - 40 ASP.NET Core(下)

    译文,个人原创,转载请注明出处(C# 6 与 .NET Core 1.0 高级编程 - 40 章  ASP.NET Core(下)),不对的地方欢迎指出与交流. 章节出自<Professiona ...

  8. 利用Flume采集IIS日志到HDFS

    1.下载flume 1.7 到官网上下载 flume 1.7版本 2.配置flume配置文件 刚开始的想法是从IIS--->Flume-->Hdfs 但在采集的时候一直报错,无法直接连接到 ...

  9. redux 初识

    前言 Redux 试图让 state 的变化变得可预测 react/react-native 将组件的更新交给了状态机(state),想要更新页面活着页面的某个组件就必须得通过改变state的方式.页 ...

  10. Hadoop基本开发环境搭建(原创,已实践)

    软件包: hadoop-2.7.2.tar.gz hadoop-eclipse-plugin-2.7.2.jar hadoop-common-2.7.1-bin.zip eclipse  jdk1.8 ...