作者信息

作者: 彭东林

邮箱: 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. IE6支持透明PNG图片解决方案:DD_belatedPNG.js

    DD_belatedPNG.js 是一个能是IE6支持p显示ng透明图片,而且还支持背景循环(background-repeat)和定位(backgrond-position) ,支持focus,Ho ...

  2. Android几行代码实现实时监听微信聊天

    实现效果: 实时监听当前聊天页面的最新一条消息,如图:            实现原理: 同样是利用AccessibilityService辅助服务,关于这个服务类还不了解的同学可以先看下我上一篇关于 ...

  3. 计算机 计算机语言 常见的DOS命令

    你好 我是大福 你现在看的是大福笔记 我jie的女儿 8年级 在QQ上问我寒假作业 0度的水和0度的冰哪个更冷 什么? 0度水 0度冰这温度不是一样的么? 不可能 肯定没这么简单 她问的意思是不是手放 ...

  4. 从并发处理谈PHP进程间通信(一)外部介质

    .container { margin-right: auto; margin-left: auto; padding-left: 15px; padding-right: 15px } .conta ...

  5. 根据dba_hist_osstat统计CPU占用情况

    在11g里面,视图dba_hist_osstat用来记录OS级别的time时间指标.视图dba_hist_osstat_name显示了相关的指标名称. SYS@/dzgddb> select * ...

  6. JAVA--可变长参数

    可变长参数: 可变长参数可以接受任意个数的实参,形参实际上是一个数组. 语法形式: 方法名称(类型 参数1,类型 参数2,类型...可变长参数) *可变长参数一定是方法的最后一个参数 public v ...

  7. JAVA高级编程序——JDBC(连接mysql数据库)——(一)

    java要想连接数据库,就要用JDBC(java database connection),用这个jar包 (mysql-connector-java-xxx-xx-bin.jar) sun公司为我们 ...

  8. FTP与TFTP

    文件传输协议如今有了很大的广泛,他屏蔽了计算机内部的实现细节,因为可以适用于各种计算机之间文件的传输. 文件咋网络中传输其实是一件很复杂的事情,涉及的问题有很多,比如 (1)计算机存储数据的格式不同 ...

  9. win8 wifi开关显示关闭,且设置里面wifi开关显示灰色的解决办法

    只要从华硕官网下载驱动,电源管理驱动,安装下面显示的几个软件即可,然后重启电脑,即可看见wifi热点,另外设置里面的wifi开关也将显示正常(刚开始安装了个驱动人生根本没用,最后在华硕官网下载了个电源 ...

  10. C++待解

    //[要求]按以下描述和要求建立一个含有对象成员的类TeleBook,用类Record定义的数组是TeleBook的数据成员. // 写出所有定义成员函数的代码.执行主函数对其测试. Record私有 ...