QEMU搭建arm Linux开发环境

本文档详细介绍了如何在QEMU上搭建ARM Linux开发环境,包括内核编译、配置开发板、制作根文件系统、启动内核、处理VFS报错、使用busybox构建基本系统、配置QEMU网络功能、以及加载u-boot。通过这些步骤,最终能够在QEMU中运行Linux内核,并进行进一步的开发和测试。
摘要由CSDN通过智能技术生成

先搭建必要的开发工具和下载源码

https://blog.csdn.net/skyleemon/article/details/78360241

内核编译,使用的内核版本分支如下:

guang@guang-kylin:~/Develop/linux-stable$ git branch
* master

1 修改顶层目录下的makefile:

guang@guang-kylin:~/Develop/linux-stable$ vi Makefile

ARCH ?= $(SUBARCH)

CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:”%”=%)
修改为:
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-gnueabi-

2 配置对应的开发板,这里用的是vexpress-a9,如下:

make vexpress_defconfig

3 编译zImage,module以及dtb:

make zImage
make modules
make dtbs
zImage生成路径:
arch/arm/boot/zImage
modules生成路径:
drivers/video/backlight/*.ko
dtbs生成路径:
arch/arm/boot/dts/vexpress-v2p-ca9.dtb

4 qemu启动内核,看看效果,由于还未挂载根文件系统,所以VFS会有报错

guang@guang-kylin:~/Develop/linux-stable$ qemu-system-arm -M vexpress-a9 -m 512M -kernel arch/arm/boot/zImage -dtb arch/arm/boot/dts/vexpress-v2p-ca9.dtb -nographic -append “console=ttyAMA0”
/****************************************************************/
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
Booting Linux on physical CPU 0x0
Linux version 4.17.0+ (guang@guang-kylin) (gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-16ubuntu3)) #1 SMP Mon Jun 11 05:05:41 CST 2018
……// 省略了很多打印信息
VFS: Cannot open root device “(null)” or unknown-block(0,0): error -6
Please append a correct “root=” boot option; here are the available partitions:
1f00 131072 mtdblock0
(driver?)
1f01 32768 mtdblock1
(driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.17.0+ #1
Hardware name: ARM-Versatile Express
[<8011074c>] (unwind_backtrace) from [<8010cd4c>] (show_stack+0x10/0x14)
[<8010cd4c>] (show_stack) from [<80694dd4>] (dump_stack+0x88/0x9c)
[<80694dd4>] (dump_stack) from [<8011ff6c>] (panic+0xf0/0x25c)
[<8011ff6c>] (panic) from [<80901588>] (mount_block_root+0x1ec/0x2d8)
[<80901588>] (mount_block_root) from [<809017b8>] (mount_root+0x144/0x160)
[<809017b8>] (mount_root) from [<80901924>] (prepare_namespace+0x150/0x198)
[<80901924>] (prepare_namespace) from [<80901174>] (kernel_init_freeable+0x340/0x350)
[<80901174>] (kernel_init_freeable) from [<806a91f8>] (kernel_init+0x8/0x114)
[<806a91f8>] (kernel_init) from [<801010e8>] (ret_from_fork+0x14/0x2c)
Exception stack(0x9f48ffb0 to 0x9f48fff8)
ffa0: 00000000 00000000 00000000 00000000
ffc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffe0: 00000000 00000000 00000000 00000000 00000013 00000000
—[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]—

用kill杀死对应的qemu-system-arm进程,咱们开始制作根文件系统

/****************************************************************/

5 busybox制作根文件系统
5.1 修改Makefile,新的busybox的makefile下面的选项是空配置的,需要修改如下:

CROSS_COMPILE ?= arm-linux-gnueabi-
ARCH ?= arm

5.2 配置

make defconfig或者make menuconfig
如果是menuconfig,下图选*:
Settings —>
— Build Options
[ ] Build static binary (no shared libs)
这里写图片描述
这里写图片描述
这里写图片描述

可以看到生成的.config文件

guang@guang-kylin:~/Develop/busybox$ ls -al .config
-rw-rw-r– 1 guang guang 27083 6月 11 12:34 .config

参考文档:

https://blog.csdn.net/qq_36788698/article/details/76647347
https://www.cnblogs.com/PengfeiSong/p/6443149.html
https://unix.stackexchange.com/questions/120198/how-to-fix-boot-into-initramfs-prompt-and-mount-cant-read-etc-fstab-no-su

5.3 编译 && 安装

make
make install

如下提示安装成功

*————————————————–
You will probably n

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值