简体   繁体   English

在启动时,ARM Linux内核如何将控制台输出映射到硬件设备?

[英]How does the ARM Linux kernel map console output to a hardware device on boot?

I'm currently struggling to determine how I can get an emulated environment via QEMU to correctly display output on the command line. 我目前正在努力确定如何通过QEMU获得仿真环境,以在命令行上正确显示输出。 I have an environment that displays perfectly well using the virt reference board, a cortex-a9 CPU, and the 4.1 Linux kernel cross-compiled for ARM. 我有一个环境,可以使用virt参考板, cortex-a9 CPU和为ARM交叉编译的4.1 Linux内核完美显示。 However, if I swap out the 4.1 kernel for 2.6 or 3.1, suddenly I can no longer see console output. 但是,如果我将4.1内核换成2.6或3.1,突然我将看不到控制台输出。

While solving this issue is my main goal, I feel like I lack a critical understanding of how Linux and the hardware initially integrate before userspace configurations via boot scripts and whatnot have a chance to execute. 解决这个问题是我的主要目标,但我觉得我对Linux和硬件如何在通过引导脚本进行用户空间配置之前进行初始集成以及如何执行没有足够的了解。 I am aware of the device tree, and have a loose understanding of how it works. 我知道设备树,并对它的工作原理有一个松散的了解。 But the issue I ran into where a different kernel version broke console availability entirely confounds me. 但是我遇到的一个问题是,另一个内核版本破坏了控制台的可用性,这完全使我感到困惑。 Can someone explain how Linux initially maps console output to a hardware device on the ARM architecture? 有人可以解释Linux最初如何将控制台输出映射到ARM体系结构上的硬件设备吗?

Thank you! 谢谢!

The answer depends quite a bit on which kernel version, what config options are set, what hardware, and also possibly on kernel command line arguments. 答案很大程度上取决于哪个内核版本,设置了哪些配置选项,什么硬件以及可能还取决于内核命令行参数。

For modern kernels, the answer is that it looks in the device tree blob it is passed for descriptions of devices, some of which will be serial ports, and it initializes those. 对于现代内核,答案是它在设备树blob中查找以传递设备描述,其中一些将是串行端口,并对其进行初始化。 The kernel config or command line will specify which of those is to be used for the console. 内核配置或命令行将指定将哪个控制台用于控制台。 For earlier kernels, especially if you go all the way back to 2.6, use of device tree was less universal, and for some hardware the boot loader simply said "this is a versatile express board" (for instance) and the kernel had compiled-in data structures to tell it where the devices were for each board that it supported. 对于较早的内核,尤其是如果您一直回到2.6,则使用设备树的通用性较差,对于某些硬件,引导加载程序只是说“这是一个通用的Express Board”(例如),并且内核已编译-数据结构告诉它所支持的每个板卡的设备位置。 As the transition to device tree progressed, boards were converted one by one, and sometimes a few devices at a time, so what exactly the situation was for any specific kernel version depends on which board you're using. 随着向设备树的过渡,电路板被一个接一个地转换,有时一次被转换成几个设备,因此,对于任何特定内核版本,确切的情况取决于您使用的是哪个板。

The other thing that I rather suspect you're running into is that if the kernel crashes early in bootup (ie before it finds the serial port at all) then it will never output anything. 我宁愿怀疑您遇到的另一件事是,如果内核在启动早期崩溃(即在根本找不到串行端口之前崩溃),那么它将永远不会输出任何东西。 So if the kernel is just too early to support the "virt" board properly at all, or if your kernel config is missing something important, then the chances are good that it crashes in early boot without being able to print you a useful message. 因此,如果内核为时过早以至于不能完全正确地支持“ virt”板,或者内核配置缺少重要内容,那么很有可能在早期启动时崩溃而无法打印有用的消息。 (Sometimes "earlycon" or "earlyprintk" kernel arguments can assist here, but not always.) (有时“ earlycon”或“ earlyprintk”内核参数可以在这里提供帮助,但并非总是如此。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM