QEMU - “启动内核"后没有内核输出; [英] QEMU - No kernel output after "Booting kernel"

查看:39
本文介绍了QEMU - “启动内核"后没有内核输出;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 QEMU 自创机器上启动预编译内核.

I try to boot precompiled kernel in QEMU self-created machine.

串口外设已配置,我可以成功启动本机预编译的U-boot镜像.

Serial peripherial is configured and I sucessfully can boot precompiled U-boot image for this machine.

在 U-Boot 中,所有串行 IO 都运行良好(内存寻址和 UART 地址也在机器设置中准备好).使用选项 -nographic 我可以在 UBoot 命令提示符下读写.

In U-Boot all serial IO works great (memory adressing and UART address is also prepared in machine setup). Using option -nographic i can read and write in UBoot command prompt.

我可以在 Uboot 中发出 bootm 命令来将内核加载到 RAM 并启动它.我看到的最后一个字符串是正在解压缩 Linux...完成.正在启动内核...".

I can issue a bootm command in Uboot to load kernel to RAM and boot it. Last string i see is "Uncompressing Linux...done. Booting kernel...".

然后我有一个黑屏.

主要区别在于内核可以工作,因为使用远程 GDB 会话,我看到它使用 printk 函数打印像 Banner 这样的输出和更多信息.但是在 QEMU 屏幕上我没有.

The main difference is that kernel WORKS because using a remote GDB session i see that it prints output like Banner and more information using printk functions. But on a QEMU screen i have none.

问题:在早期内核中,console=ttyS0,115200 的设置是在什么地方完成的?我试图在内核源代码中搜索,但找不到调试问题的地方.

Question: Where in kernel in early stage is a setup of console=ttyS0,115200 setup being done? I tried to search in kernel sources and cannot find a place to debug the problem.

内核如何在设置之前知道要传递给串行的内容?有 RAM 环形缓冲区吗?

How kernel knows what to pass to serial before setting one up? Is there a RAM Ring buffer?

有什么线索吗?

推荐答案

当您为 ARM 机器启动预编译的 U-Boot 映像时,它已经包含:内核、initramfs/initrd 文件和编译的设备树二进制文件(.dtb) 文件卷成 U-Boot 可以识别、解压缩、加载到内存并用于启动启动过程的图像格式.在这种情况下,console=ttyS0,115200 信息包含在原始设备树规范 (DTS) 文件的 .dtb 文件中,该文件将包含如下所示的部分:

When you boot your precompiled U-Boot image for an ARM machine, it already includes: a kernel, an initramfs/initrd file, and a compiled device tree binary (.dtb) file rolled into an image format which U-Boot can recognise, unpack, load into memory and use to kick off the booting process. In this case, the console=ttyS0,115200 information is included in the .dtb file from the original device tree specification (DTS) file which will contain a section that looks like:

chosen {
    bootargs = "console=ttyS0,115200n8 maxcpus=2, envaddr = <0xfa0f0000>";
};

最终 U-Boot 将二进制 .dtb 文件加载到内存中,并将指向它的指针传递给内核,然后内核可以推导出控制台参数并显示控制台输出.

Ultimately U-Boot loads the binary .dtb file into memory and passes a pointer to it to the kernel, which can then deduce the console parameters and display console output.

当您更喜欢将内核加载到内存中并使用 U-Boot bootm 命令时,您必须自己确保 initramfs/initrd 和 .dtb 文件已加载到内存中(可能通过 tftp)并且地址是作为参数传递给 bootm.一旦完成,内核就有机会从 .dtb 中获取控制台参数,就像它在 U-Boot 映像案例中所做的那样,然后您应该会看到您的控制台输出.执行此操作的内核代码在 4.19 内核中位于 drivers/of/base.c of_console_check() 中.

When instead you prefer to load the kernel into memory and use the U-Boot bootm command, you must yourself ensure that the initramfs/initrd and .dtb file have been loaded into memory (perhaps via tftp) and that the addresses are passed as arguments to bootm. Once that has been done, the kernel has the opportunity to fetch the console parameters from the .dtb as it did in the U-Boot image case and you should then see your console output. The kernel code to do this was, in the 4.19 kernel, located in drivers/of/base.c of_console_check().

这篇关于QEMU - “启动内核"后没有内核输出;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆