Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

arm - QEMU - No kernel output after "Booting kernel"

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

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

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.

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...".

And there i have a black screen.

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.

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.

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

Any clues?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>";
};

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.

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().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...