利用QEMU运行ARM开发环境
来源:互联网 发布:linux qt usb 编辑:程序博客网 时间:2024/05/20 09:46
*
* (c) 光明工作室 2017-2037 COPYRIGHT
*
* 光明工作室团队成员大部分来自全国著名985、211工程院校。具有丰富的工程实践经验,
*本工作室热忱欢迎大家的光临。工作室长期承接嵌入式开发、PCB设计、算法仿真等软硬件设计。
*
*
*1)基于C8051、AVR、MSP430单片机开发。
*2)基于STM32F103、STM32F407等ARM处理器开发。(IIC、SPI、485、WIFI等相关设计)
*3)基于C6678、DM388等DSP处理器开发。(视频、网络、通信协议相关设计)
*4)基于QT、C#软件开发。
*5)基于OPENCV、OPENGL图像处理算法开发。(基于LINUX、WINDOWS、MATLAB等)
*6)无人机飞控、地面站程序开发。(大疆、PIX、 qgroundcontrol、missionplanner、MAVLINK)
*7) ROS机器人操作系统下相关开发。
*8)LINUX、UCOSII、VXWORKS操作系统开发。
*
*
* 联系方式:
* QQ:2468851091 call:18163325140
* Email:2468851091@qq.com
*
/ ****************************************************************************/
一直以来都想开发一些基于ARM、DSP的应用。但是当下各系列、各个厂商的平台都很多。如果一一来测试,势必会花费很多不必要的支出。因为各个厂商都是基于相应的ARM核 来做的芯片,于是就想到是否有仿真器是否能够模拟ARM,在LINUX下调试UBOOT、LINUX。最后我找到了QEMU。我在LINUX14.04 32位环境下加载了u-boot12.04 .在此过程中出现了很多问题,如图所示:
上图出现的错误,都是在LINUX16.04 64位下,用arm-linux-gcc编译时出现的错误。我们知道ARM是32位的处理器,所以大家最好在32位环境下来编译UBOOT。最后,UBOOT编译通过后,用QEMU来起动加载UBOOT,会得到如下的效果。(起动命令:qemu-system-arm -M vexpress-a9 -m 256M -serial stdio -kernel u-boot)
用 printenv指令来打印消息,可以得到关于VExpress板卡相应的参数:
然后下一步就要加载LINUX内核了。
编译和运行Linux内核:
到http://www.kernel.org/下载最新的Linux内核源码,我下载的是linux-3.4.4.tar.bz2. 解压后修改Makefile, ARCH = arm, CROSS_COMPILE=arm-linux-gnueabi-
make vexpress_defconfig
(可以到 arch/arm/configs/ 目录看到所有自带的配置文件, 我们使用vexpress板卡默认的配置文件)
然后 make menuconfig --> System Type 编译LINUX内核。
1,安装工具
sudo apt-get install gcc-arm-linux-gnueabi
sudo apt-get install qemu
2,下载Linux内核
从kernel.org下载压缩包
tar -xf linux-3.16.45.tar.xz
3,编译内核
make mrproper #可选,保证原始干净环境
生成vexpress开发板子的config文件:
make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm vexpress_defconfig
编译:make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm
生成的内核镱像位于arch/arm/boot/zImage, qemu启动时须要使用该镜像。
4,測试qemu和内核是否能执行成功
cp arch/arm/boot/zImage myImage
qemu-system-arm -M vexpress-a9 -m 512M -kernel myImage -nographic -append "console=ttyAMA0"
-M vexpress-a9 模拟vexpress-a9单板,你能够使用-M ?參数来获取该qemu版本号支持的全部单板
-m 512M 单板执行物理内存512M
-kernel /home/ivan/kernel_git/linux/arch/arm/boot/zImage 告诉qemu单板执行内核镜像路径
-nographic 不使用图形化界面,仅仅使用串口
-append "console=ttyAMA0" 内核启动參数。这里告诉内核vexpress单板执行。串口设备是哪个tty。
事实上在上面的測试中,你会发现内核报panic,由于内核找不到根文件系统,无法启init进程。如下图所示:
5,下载、编译和安装busybox
make defconfig
make CROSS_COMPILE=arm-linux-gnueabi-
make install CROSS_COMPILE=arm-linux-gnueabi-
安装完毕后。会在busybox文件夹下生成_install文件夹。该文件夹下的程序就是单板执行所须要的命令。
loginutils/passwd.c:175:12: error: ‘RLIMIT_FSIZE’ undeclared (first use in this function)
busybox-1.20.2 编译不过解决
- 要不会出现如下错误:
- loginutils/passwd.c: In function ‘passwd_main’:
- loginutils/passwd.c:104:16: error: storage size of ‘rlimit_fsize’ isn’t known
- loginutils/passwd.c:188:2: warning: implicit declaration of function ‘setrlimit’ [-Wimplicit-function-declaration]
- loginutils/passwd.c:188:12: error: ‘RLIMIT_FSIZE’ undeclared (first use in this function)
- loginutils/passwd.c:188:12: note: each undeclared identifier is reported>for each function it appears in
- loginutils/passwd.c:104:16: warning: unused variable ‘rlimit_fsize’ [-Wunused-variable]
6,形成根文件夹结构
1. 创建rootfs文件夹(根文件夹),根文件系统内的文件全部放到这里
sudo mkdir rootfs
2. 拷贝busybox命令到根文件夹下
sudo cp busybox-1.20.2/_install/* -r rootfs/
3. 从工具链中拷贝执行库到lib文件夹下
sudo mkdir rootfs/lib
sudo mkdir rootfs/dev
sudo cp -P /usr/arm-linux-gnueabi/lib/* rootfs/lib/
4. 创建4个tty端终设备
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
执行上面的命令后,得到如下图的文件:(左边窗口为执行的命令,右边窗口为相应的结果。)
7,制作根文件系统镜像
1. 生成32M大小的镜像
dd if=/dev/zero of=a9rootfs.ext3 bs=1M count=32
2. 格式化成ext3文件系统
mkfs.ext3 a9rootfs.ext3
格式化后的图片如下:
3. 将文件复制到镜像中
sudo mkdir tmpfs
sudo mount -t ext3 a9rootfs.ext3 tmpfs/ -o loop
sudo cp -r rootfs/* tmpfs/
sudo umount tmpfs
8,系统启动执行
qemu-system-arm -M vexpress-a9 -m 512M -kernel myImage -nographic -append "root=/dev/mmcblk0 console=ttyAMA0" -sd a9rootfs.ext3
9,linux启动信息
derek@ubox:~/share$ qemu-system-arm -M vexpress-a9 -m 512M -kernel myImage -nographic -append "root=/dev/mmcblk0 console=ttyAMA0" -sd a9rootfs.ext3WARNING: Image format was not specified for 'a9rootfs.ext3' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.pulseaudio: set_sink_input_volume() failedpulseaudio: Reason: Invalid argumentpulseaudio: set_sink_input_mute() failedpulseaudio: Reason: Invalid argumentBooting Linux on physical CPU 0x0Initializing cgroup subsys cpusetLinux version 3.16.45 (derek@ubox) (gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) ) #1 SMP Sun Jul 16 21:32:51 CST 2017CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c53c7dCPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cacheMachine: ARM-Versatile ExpressMemory policy: Data cache writebackCPU: All CPU(s) started in SVC mode.sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956969942nsPERCPU: Embedded 7 pages/cpu @9fbed000 s6976 r8192 d13504 u32768Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048Kernel command line: root=/dev/mmcblk0 console=ttyAMA0PID 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: 513184K/524288K available (4650K kernel code, 191K rwdata, 1292K rodata, 246K init, 149K bss, 11104K 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 - 0x805d5ba4 (5943 kB) .init : 0x805d6000 - 0x80613b40 ( 247 kB) .data : 0x80614000 - 0x80643ea0 ( 192 kB) .bss : 0x80643ea8 - 0x80669528 ( 150 kB)SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1Hierarchical RCU implementation. RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1NR_IRQS:16 nr_irqs:16 16GIC CPU mask not found - kernel will fail to boot.GIC CPU mask not found - kernel will fail to boot.smp_twd: clock not found -2L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000L2C-310 enabling early BRESP for Cortex-A9L2C-310 full line of zeros enabled for Cortex-A9L2C-310 dynamic clock gating disabled, standby mode disabledL2C-310 cache controller enabled, 8 ways, 128 kBL2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001Console: colour dummy device 80x30Calibrating local timer... 97.02MHz.Calibrating delay loop... 852.78 BogoMIPS (lpj=4263936)pid_max: default: 32768 minimum: 301Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)CPU: Testing write buffer coherency: okmissing device node for CPU 0CPU0: thread -1, cpu 0, socket 0, mpidr 80000000Setting up static identity map for 0x604712a8 - 0x60471300Brought up 1 CPUsSMP: Total of 1 processors activated (852.78 BogoMIPS).CPU: All CPU(s) started in SVC mode.devtmpfs: initializedVFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 0futex hash table entries: 256 (order: 2, 16384 bytes)regulator-dummy: no parametersNET: Registered protocol family 16DMA: preallocated 256 KiB pool for atomic coherent allocationscpuidle: using governor laddercpuidle: using governor menuhw-breakpoint: debug architecture 0x4 unsupported.Serial: AMBA PL011 UART drivermb:uart0: ttyAMA0 at MMIO 0x10009000 (irq = 37, base_baud = 0) is a PL011 rev1console [ttyAMA0] enabledmb:uart1: ttyAMA1 at MMIO 0x1000a000 (irq = 38, base_baud = 0) is a PL011 rev1mb:uart2: ttyAMA2 at MMIO 0x1000b000 (irq = 39, base_baud = 0) is a PL011 rev1mb:uart3: ttyAMA3 at MMIO 0x1000c000 (irq = 40, base_baud = 0) is a PL011 rev1fixed-dummy: no parametersSCSI subsystem initializedusbcore: registered new interface driver usbfsusbcore: registered new interface driver hubusbcore: registered new device driver usbAdvanced Linux Sound Architecture Driver Initialized.Switched to clocksource v2m-timer1NET: Registered protocol family 2TCP 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 registeredUDP hash table entries: 256 (order: 1, 8192 bytes)UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)NET: Registered protocol family 1RPC: Registered named UNIX socket transport module.RPC: Registered udp transport module.RPC: Registered tcp transport module.RPC: Registered tcp NFSv4.1 backchannel transport module.CPU PMU: probing PMU on CPU 0hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 1 counters availablesquashfs: version 4.0 (2009/01/31) Phillip Lougherjffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.9p: Installing v9fs 9p2000 file system supportmsgmni has been set to 1002io scheduler noop registered (default)clcd-pl11x ct:clcd: PL111 rev2 at 0x10020000clcd-pl11x ct:clcd: CT-CA9X4 hardware, XVGA displayConsole: switching to colour frame buffer device 128x48physmap platform flash device: 04000000 at 40000000physmap-flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000Intel/Sharp Extended Query Table at 0x0031Using buffer write methodphysmap platform flash device: 04000000 at 44000000physmap-flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000Intel/Sharp Extended Query Table at 0x0031Using buffer write methodConcatenating MTD devices:(0): "physmap-flash"(1): "physmap-flash"into device "physmap-flash"libphy: smsc911x-mdio: probedsmsc911x smsc911x eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=smsc911x-fffffff:01, irq=-1)smsc911x smsc911x eth0: MAC Address: 52:54:00:12:34:56isp1760 isp1760: NXP ISP1760 USB Host Controllerisp1760 isp1760: new USB bus registered, assigned bus number 1isp1760 isp1760: Scratch test failed.isp1760 isp1760: can't setup: -19isp1760 isp1760: USB bus 1 deregisteredisp1760: Failed to register the HCD deviceusbcore: registered new interface driver usb-storagemousedev: PS/2 mouse device common for all micertc-pl031 mb:rtc: rtc core: registered pl031 as rtc0mmci-pl18x mb:mmci: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 41,42 (pio)ledtrig-cpu: registered to indicate activity on CPUsusbcore: registered new interface driver usbhidusbhid: USB HID core drivermmc0: host does not support reading read-only switch. assuming write-enable.mmc0: new SD card at address 4567input: AT Raw Set 2 keyboard as /devices/mb:kmi0/serio0/input/input0mmcblk0: mmc0:4567 QEMU! 32.0 MiB mmcblk0: unknown partition tableaaci-pl041 mb:aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43aaci-pl041 mb:aaci: FIFO 512 entriesoprofile: using arm/armv7-ca9TCP: cubic registeredNET: Registered protocol family 179pnet: Installing 9P2000 supportrtc-pl031 mb:rtc: setting system clock to 2017-07-16 13:59:34 UTC (1500213574)ALSA device list: #0: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43input: ImExPS/2 Generic Explorer Mouse as /devices/mb:kmi1/serio1/input/input2kjournald starting. Commit interval 5 secondsEXT3-fs (mmcblk0): mounted filesystem with writeback data modeVFS: Mounted root (ext3 filesystem) readonly on device 179:0.Freeing unused kernel memory: 244K (805d6000 - 80613000)random: nonblocking pool is initializedcan't run '/etc/init.d/rcS': No such file or directoryPlease press Enter to activate this console. / # uname -aLinux (none) 3.16.45 #1 SMP Sun Jul 16 21:32:51 CST 2017 armv7l GNU/Linux/ # / #
最后,LINUX内核在QEMU虚拟机上运行了起来。qemu-system-arm -kernel /zouyu/rootfs/zImage -serial stdio -M vexpress-a9 -append "root=/dev/mmcblk0 console=ttyAMA0 console=tty0" -sd a9rootfs.ext3
- 利用QEMU运行ARM开发环境
- qemu模拟器搭建arm运行环境
- 利用qemu搭建arm cortex a9开发环境以及gdb调试
- QEMU模拟Mini2440开发板运行环境
- QEMU模拟Mini2440开发板运行环境
- QEMU模拟Mini2440开发板运行环境
- 从零使用qemu模拟器搭建arm运行环境
- 从零使用qemu模拟器搭建arm运行环境
- 从零使用qemu模拟器搭建arm运行环境
- 从零使用qemu模拟器搭建arm运行环境
- 从零使用QEMU模拟器搭建ARM运行环境
- 从零使用qemu模拟器搭建arm运行环境
- qemu模拟器搭建arm运行环境搭建笔记
- 从零使用qemu模拟器搭建arm运行环境
- arm qemu环境构建
- Ubuntu 16.04 利用qemu模拟ARM开发板
- Ubuntu 16.04 利用qemu模拟ARM开发板
- Ubuntu 16.04 利用qemu模拟ARM开发板
- 为什么我博客里的插图都不见了???!!!
- java学习第24天(续),学习几个API,indexOf(),charAt(),toUpperCase(),toLowerCase(),subString(),trim()
- nginx 反向代理
- 每天学些redis命令(3)
- Java:如何利用两个栈实现队列
- 利用QEMU运行ARM开发环境
- 7-38 支票面额(15 分)
- 数组
- sql语句优化
- 初识Hibernate之关联映射
- IP地址 网关 子网掩码
- php使用QueryList轻松采集JavaScript动态渲染页面
- 反激式开关电源中PC817与TL431的配合电路探讨
- 人类已经无法控制的相机:谷歌AI相机Clips解密