作者信息

作者: 彭东林

邮箱: 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. boneCP的连接管理

    boneCP连接的实现 boneCP自己实现了标准的java.sql.Connection接口,除了会持有Connection对象之外,还会拥有一些属性用于标记连接的创建时间,空闲时间等. 比较重要的 ...

  2. MVC 5 on Windows Server 2008/IIS 7

    将网站部署在2008上,结果出现了 HTTP Error 403.14 - Forbidden The Web server is configured to not list the content ...

  3. Omi原理-Hello Omi

    Hello Omi Omi框架的每个组件都继承自Omi.Component,本篇会去完成Omi的Component的基本锥形,让其能够渲染第一个组件. omi.js实现 var Omi = {}; O ...

  4. esri-leaflet入门教程(1)-leaflet介绍

    esri-leaflet入门教程(1)-esri leaflet介绍 by 李远祥 关于leaflet,可能很多人比较陌生,如果搭上esri几个字母,可能会有更多的人关注.如果没有留意过leaflet ...

  5. CSS3知识点整理(一)----基本样式

    (一) 在编写CSS3样式时,不同的浏览器可能需要不同的前缀.它表示该CSS属性或规则尚未成为W3C标准的一部分,是浏览器的私有属性,虽然目前较新版本的浏览器都是不需要前缀的,但为了更好的向前兼容前缀 ...

  6. 转自scutan 常用的Linux编程库

    库                       头文件                       描述libGL.so                                        ...

  7. uml系列图(一)——与uml的第一次约会

    uml视频终于开始看了,再看之前先大概了解了一下uml都有啥. 老规矩,有图有真相: 暂时的理解就这么多,等到uml看完的时候总结跟现在这张图比一下,应该是有很大的区别吧. uml是一种可视化的建模语 ...

  8. context:annotation-config, mvc:annotation-driven, context:compont-scan 区别

    当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...

  9. github在windows下的安装和基本使用

    1.在win下安装github时花费的时间是非常长的,有时还会出现因各种原因安装不成功.离线包本地安装方便的解决了此问题.点击http://pan.baidu.com/s/1boGrNLP可下载,解压 ...

  10. Azure机器学习入门(三)创建Azure机器学习实验

    在此动手实践中,我们将在Azure机器学习Studio中一步步地开发预测分析模型,首先我们从UCI机器学习库的链接下载普查收入数据集的样本并开始动手实践: http://archive.ics.uci ...