再续【从零使用qemu模拟器搭建arm运行环境】_海枫的博客-程序员宝宝_arm模拟器

技术标签: kernel  linux  qemu  C/C++/linux  arm  

动机

我在2015年编写博文《从零使用qemu模拟器搭建arm运行环境》介绍在 Ubuntu 14.04系统如何一步步构造arm+qemu的运行环境。该文的主要问题是读者有运行环境不一定是Ubuntu 14.04,会遇到不少的软件包安装和编译错误问题,我也没有办法构造复现。另一方面,当前再次构造这个环境时,也会遇到类似的问题需要处理,特别是换成Centos发行版之后,处理起来更复杂。

既然每位朋友的发行版都不一样,那可以使用Docker统一构建环境,这是本项目的主要动机,使用Docker基于Ubuntu14.04镜像,再安装相应的软件包,一步步构建整个Linux kernel, busybox软件包,这样可以屏蔽构建环境的差异,同时也可以使用Dockerfile将整个过程自动化。

所以本项目利用容器技术,标准化构造环境,自动化构建整个过程,最后在容器内运行qemu+arm kernel。

完整的github目项:qemu-arm-linux.git

安装Docker工具

请参考Docker官方文档安装Docker软件:https://docs.docker.com/engine/install/

构建docker镜像

可以直接使用 yongting/arm-kernel-3.16-qemu:v1
这个镜像而跳过本步骤,直接从下个步骤开始操作。

下载本项目

git clone https://github.com/ivanalgo/qemu-arm-linux.git

构建Docker镜像

直接运行下面命令:

# cd qemu-arm-linux

# ./build-docker-image.sh

构建成功后,请使用docker images来检查是否生成 arm-kernel-3.16-qemu 镜像

比如:

# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             SIZE
arm-kernel-3.16-qemu   latest              db5c6750bbe4        About an hour ago   2.29GB
ubuntu                 14.04               df043b4f0cf1        2 weeks ago         197MB

创建一个特权容器,运行qemu+arm

直接运行下面命令:

docker run -it --privileged arm-kernel-3.16-qemu /bin/bash
或者
docker run -it --privileged yongting/arm-kernel-3.16-qemu:v1 /bin/bash
从docker hub上直接利用我已发布的镜像。

# docker run -it --privileged  arm-kernel-3.16-qemu /bin/bash
[email protected]:/#

在容器内创建一个ext3磁盘文件

在上面的容器里运行:/opt/create_image.sh 直创建给qemu使用磁盘,里面包含qemu+arm系统需要的rootfs,过程如下所示:

[email protected]:/# /opt/create_image.sh 
32+0 records in
32+0 records out
33554432 bytes (34 MB) copied, 0.0122017 s, 2.7 GB/s
mke2fs 1.42.9 (4-Feb-2014)
/opt/a9rootfs.ext3 is not a block special device.
Proceed anyway? (y,n) Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
8192 inodes, 32768 blocks
1638 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33554432
4 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193, 24577

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

在容器内运行qemu+arm kernel

在上面的容器里运行:/opt/start_qemu.sh 运行启动一个qemu+arm系统,直接进入命令对arm linux进行命令操作,过程如下:

[email protected]:/# /opt/start_qemu.sh 
Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.16.0 ([email protected]) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) ) #1 SMP Wed Oct 7 10:26:41 UTC 2020
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
PERCPU: Embedded 7 pages/cpu @9fbcf000 s7552 r8192 d12928 u32768
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: root=/dev/mmcblk0  console=ttyAMA0
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 513116K/524288K available (4563K kernel code, 190K rwdata, 1288K rodata, 247K init, 150K bss, 11172K reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xffe00000   (2048 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    modules : 0x7f000000 - 0x80000000   (  16 MB)
      .text : 0x80008000 - 0x805bf0a0   (5853 kB)
      .init : 0x805c0000 - 0x805fdd80   ( 248 kB)
      .data : 0x805fe000 - 0x8062dac0   ( 191 kB)
       .bss : 0x8062dac8 - 0x806532e8   ( 151 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Hierarchical RCU implementation.
	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
NR_IRQS:16 nr_irqs:16 16
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
L2C: device tree omits to specify unified cache
L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating disabled, standby mode disabled
L2C-310 cache controller enabled, 8 ways, 128 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956969942ns
Console: colour dummy device 80x30
Calibrating delay loop... 895.79 BogoMIPS (lpj=4478976)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x60454520 - 0x60454578
CPU1: failed to boot: -38
CPU2: failed to boot: -38
CPU3: failed to boot: -38
Brought up 1 CPUs
SMP: Total of 1 processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0
regulator-dummy: no parameters
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
of_amba_device_create(): amba_device_add() failed (-19) for /[email protected]
of_amba_device_create(): amba_device_add() failed (-19) for /[email protected]
of_amba_device_create(): amba_device_add() failed (-19) for /[email protected]
of_amba_device_create(): amba_device_add() failed (-19) for /smb/motherboard/[email protected],00000000/[email protected]
of_amba_device_create(): amba_device_add() failed (-19) for /smb/motherboard/[email protected],00000000/[email protected]
hw-breakpoint: debug architecture 0x0 unsupported.
Serial: AMBA PL011 UART driver
10009000.uart: ttyAMA0 at MMIO 0x10009000 (irq = 37, base_baud = 0) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = 38, base_baud = 0) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = 39, base_baud = 0) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = 40, base_baud = 0) is a PL011 rev1
3V3: 3300 mV 
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 arm,sp804
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP: reno registered
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 1 counters available
futex hash table entries: 1024 (order: 4, 65536 bytes)
squashfs: version 4.0 (2009/01/31) Phillip Lougher
jffs2: version 2.2. (NAND)  2001-2006 Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
msgmni has been set to 1002
io scheduler noop registered (default)
clcd-pl11x: probe of 10020000.clcd failed with error -22
clcd-pl11x: probe of 1001f000.clcd failed with error -22
VD10: at 1000 mV 
VD10_S2: at 1000 mV 
VD10_S3: at 1000 mV 
VCC1V8: at 1800 mV 
DDR2VTT: at 900 mV 
VCC3V3: at 3300 mV 
VIO: at 3300 mV 
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
NOR chip too large to fit in mapping. Attempting to cope...
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Reducing visibility of 131072KiB chip to 65536KiB
40000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
NOR chip too large to fit in mapping. Attempting to cope...
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Reducing visibility of 131072KiB chip to 65536KiB
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "40000000.flash"
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:01, irq=-1)
smsc911x 4e000000.ethernet eth0: MAC Address: 52:54:00:12:34:56
nxp-isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
nxp-isp1760 4f000000.usb: new USB bus registered, assigned bus number 1
nxp-isp1760 4f000000.usb: Scratch test failed.
nxp-isp1760 4f000000.usb: can't setup: -19
nxp-isp1760 4f000000.usb: USB bus 1 deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
rtc-pl031 10017000.rtc: rtc core: registered pl031 as rtc0
mmci-pl18x 10005000.mmci: Got CD GPIO #244.
mmci-pl18x 10005000.mmci: Got WP GPIO #245.
mmci-pl18x 10005000.mmci: No vqmmc regulator found
mmci-pl18x 10005000.mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 41,42 (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
mmc0: new SD card at address 4567
mmcblk0: mmc0:4567 QEMU! 32.0 MiB 
 mmcblk0: unknown partition table
aaci-pl041 10004000.aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
aaci-pl041 10004000.aaci: FIFO 512 entries
oprofile: using arm/armv7-ca9
TCP: cubic registered
NET: Registered protocol family 17
9pnet: Installing 9P2000 support
rtc-pl031 10017000.rtc: setting system clock to 2020-10-07 11:47:19 UTC (1602071239)
ALSA device list:
  #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
input: AT Raw Set 2 keyboard as /devices/smb/smb:motherboard/smb:motherboard:[email protected],00000000/10006000.kmi/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/smb/smb:motherboard/smb:motherboard:[email protected],00000000/10007000.kmi/serio1/input/input2
kjournald starting.  Commit interval 5 seconds
EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 179:0.
Freeing unused kernel memory: 244K (805c0000 - 805fd000)
random: nonblocking pool is initialized

Please press Enter to activate this console.  
/ # ls
bin         etc         linuxrc     proc        usr
dev         lib         lost+found  sbin

欢迎您的贡献

欢迎到github上提issue,也可以发起request,RP也一样欢迎。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/linyt/article/details/108960410

智能推荐

ubuntu上搭建postfix+extmail(实战笔记) _scnjl007的博客-程序员宝宝

 sudo aptitube install postfix-mysql courier-authlib-mysql courier-pop libsasl2-modules-sql maildrop apache2-suexec-custom libunix-syslog-perl rsync mailgraph ntpdate apache2 libapache2-mod-fcgid sa...

JSON的parse()和stringfy()方法_莫等闲_W的博客-程序员宝宝

1.JSON.parse;作用:将JavaScript对象表示法的JSON字符串转换为对象(字符串转对象)语法:JSON.parse(text [, reviver])text 必选。 一个有效的 JSON 字符串。reviver 可选。 一个转换结果的函数。 将为对象的每个成员调用此函数。返回值:JSON对象实例:var jsonStr = '{"name":"leinov"...

对封装、继承、多态概念的个人形象理解_weixin_30268071的博客-程序员宝宝

从前有一家IT公司,里面有很多人,每个人都有自己的年龄、身高、性别,等等。这些人在这家IT公司里从事着不同的职业,有负责接待的前台,有负责销售的业务员,有负责招聘的HR,有负责扫地的清洁工,还有很多很多负责敲代码的码农。___________________________________________________________________________对象A:前台小妹/属性...

超级计算机性能测试,高性能计算机评测框架及其在"神威"蓝光上的实践_会计星球的博客-程序员宝宝

摘要:系统性的评测工作是全面评价和优化HPC系统的重要手段,作用日益突出.当前,针对HPC的评测缺乏专门的评价体系,缺乏对可靠性,功耗,复杂性,扩展性等瓶颈问题的系统性评测方法,以及自动化水平低的问题.本文在总结历代"神威"超级计算机评测的基础上,从测试级别,功能模块和测试类型三个维度,研究并实现了HPC系统评测框架[email protected],包括HPC评测技术体系和基于该评测技术体系的自动化测试系统两...

达梦MPP主备搭建_AbigTT的博客-程序员宝宝

1、环境说明:本文档以192.168.1.105/192.168.1.106两节点搭建MPP主备集群为例 机器名 IP 实例名 PORT_NUM/MAL_INST_PORT MAL_INST_DW_PORT MAL_PORT MAL_DW_PORT A 192.168.1.105 GRP1_MPP_E

Android Studio / Gradle_rxh_rxh的博客-程序员宝宝

http://www.csdn.net/article/2013-05-16/2815320-Google-IO-2013-Android-Studiohttp://zhidao.baidu.com/link?url=c2VxAlbEZci4_v1UEZRm6c0DGFKiK79bIgfmRtcwA6vC1E8MQQbdNmCLKloRs2_SFuj31OtcPmIXnv3AdRaZIVS

随便推点

layui劝退_Sherlock_Holmes_lv的博客-程序员宝宝_layui react

之前没有接触过layui, 这次项目中尝试了一下,巨坑。而且 现在 react、vue大行其道,心得:作为程序员应该尝试流行的技术需求:上传图片的时候需要检查图片的宽高比,使用layui的upload模块,即使拦截了,也会上传,而且无需请求后端。我怀着急躁的心情只好在后端检测了layui:upload.render({ elem: '#layuiadmin-upload-list' , url: '/books/uploadImg' .

CentOS 7 镜像文件各个版本区别_叶落无痕123的博客-程序员宝宝_centos7everything 区别

CentOS ISO 镜像文件的功能引导安装 CentOSISO 镜像文件包含有安装程序,官方称其为 Anaconda,用来引导安装 CentOS提供 CentOS 的安装文件镜像文件不一定包含我们安装所需要 CentOS,可能只有安装程序,用以引导安装 提供额外软件不只是在安装过程中可以提供额外软件,在已经安装使用的系统中也可以挂载该 ISO 镜像文件,使用其中的软件安装...

让Python中类的属性具有惰性求值的能力_Python中文社区的博客-程序员宝宝

起步我们希望将一个只读的属性定义为 property 属性方法,只有在访问它时才进行计算,但是,又希望把计算出的值缓存起来,不要每次访问它时都重新计算。解决方案定义一个惰...

python 小说下载_Python3----下载小说代码_weixin_39919195的博客-程序员宝宝

前言该文章主要分析编写爬虫小说的思路,文章代码使用语言Python3.72020-03-20天象独行第一部分:面对过程编程1;首先我们确定目标,我们将要从网页:“https://www.biqukan.com/38_38836”下载小说“沧元图”。这里我们先设定URL以及请求头(后面会进行调整,让程序与人进行交互),且程序所需要的库:from urllib importrequestfrom bs...

JZ6 旋转数组的最小数字_qq_41273406的博客-程序员宝宝_jz6 旋转数组的最小数字

JZ6 旋转数组的最小数字题目描述:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。示例:输入:[3,4,5,1,2]返回值:1方法一:暴力法1.思路:因为题目最后结果是要输出最小值直接遍历所有的数组,找出最小值即可。2.复杂度:时间复杂度:O(n)空间复杂度: O(1)3.代码:import java.util.ArrayLi

推荐文章

热门文章

相关标签