无法在 qemu 上启动为 vexpress-a9 构建的内核映像:空白屏幕

Unable to boot kernel image built for vexpress-a9 on qemu : Blank Screen

我使用以下步骤编译了 linux 内核 v4.9:

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make vexpress_defconfig
make all -j40

然后我用一个简单的 hello world 程序创建了 ramdisk 作为 init 进程

#include <stdio.h> 

void main() {
  printf("Hello World!\n");
  while(1);
}

//compile and pack
arm-linux-gnueabi-gcc -static init.c -o init
echo init|cpio -o --format=newc > initramfs

现在,当我尝试 运行 使用 qemu 时,出现黑屏,没有其他问题

qemu-system-arm -M vexpress-a9 -kernel linux-4.9/arch/arm/boot/zImage -initrd initramfs -append "console=tty1"

此外,在我启动 qemu 的终端上,我得到了以下打印(看起来无关紧要)

pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument

这是我的 qemu 屏幕(完全空白):

我是第一次使用Qemu,正在使用this article作为参考。

"QEMU does nothing with a black screen" 几乎总是意味着 "QEMU is running fine, but the guest code crashed or stopped early in the boot process without sending any output".

您的命令行最明显的问题是您没有通过 -dtb 向 QEMU 传递设备树 blob。较旧的 Arm 内核将仅使用内核和 initrd 启动,但较新的内核需要 dtb,否则它们将无法启动。您正在查看的教程使用的内核版本早于此更改,但看起来您使用的是需要 dtb 的更高版本。您应该能够在内核构建树的 arch/arm/boot/dts/ 中找到相关的 dtb(可能是 vexpress-v2p-ca9.dtb)。您可能需要专门告诉内核 makefile 从 dts 构建它——我忘记了。如有必要,请查看内核构建文档以了解如何执行此操作。

我得到了上面的工作

qemu-system-arm -monitor none -nographic -M vexpress-a9 -kernel linux/arch/arm/boot/zImage -initrd initramfs -dtb linux/arch/arm/boot/dts/vexpress-v2p-ca9.dtb -serial stdio
kernel version v5.8-rc7
arm-linux-gnueabi-gcc --version (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0