简体   繁体   English

在为ARM创建Linux uImage之后,QEMU显示黑屏

[英]QEMU Showing Black Screen After Creating Linux uImage for ARM

So I have been following this article: 所以我一直在关注这篇文章:

https://opensourceforu.com/2011/06/qemu-for-embedded-systems-development-part-1/ https://opensourceforu.com/2011/06/qemu-for-embedded-systems-development-part-1/

I first made sure that I enabled the “Use the ARM EABI to compile the kernel” option in the menuconfig and saved it as .config 我首先确保在menuconfig中启用了“使用ARM EABI编译内核”选项,并将其保存为.config

After that I ran the following command and got the following output: 之后,我运行以下命令并获得以下输出:

ivan@UbuntuMATE:~/Programming/linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- uImage -s LOADADDR=0x00008000
<stdin>:1332:2: warning: #warning syscall io_pgetevents not implemented [-Wcpp]
Image Name:   Linux-4.18.0-10986-g778a33959a8a
Created:      Mon Aug 20 23:09:46 2018
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2816048 Bytes = 2750.05 kB = 2.69 MB
Load Address: 00008000
Entry Point:  00008000

Now the problem happens when I try to test the image with the following command: 现在,当我尝试使用以下命令测试图像时,就会发生问题:

ivan@UbuntuMATE:~/Programming/linux$ qemu-system-arm -M versatilepb -m 256M -kernel arch/arm/boot/uImage

I get a black screen. 我出现黑屏。 I understand that the kernel will crash, but I still expect to see text on the screen. 我知道内核将崩溃,但是我仍然希望在屏幕上看到文本。 After reading comments and several questions similar to this online, I try the following command: 在阅读注释和一些与此在线相似的问题之后,我尝试以下命令:

ivan@UbuntuMATE:~/Programming/linux$ qemu-system-arm -M versatilepb -m 256M -kernel arch/arm/boot/uImage -append "console=ttyAMA0"

I have also tried with tty1 and even tried what this link suggested: 我也尝试过tty1,甚至尝试了此链接的建议:

Just black screen after running Qemu 运行Qemu后只是黑屏

Please advise as to how to proceed. 请告知如何进行。 Thanks in advance! 提前致谢!

EDIT: I figured it out!! 编辑:我想通了! Thank you @bornfree for the starting point in guiding me to the answer! 感谢@bornfree作为指导我做出答案的起点!

Low and behold I no longer get a blank screen but I still get an error: 低,请注意,我不再显示黑屏,但仍然收到错误消息:

Error: invalid dtb and unrecognized/unsupported machine ID
  r1=0x00000183, r2=0x00000100
  r2[]=05 00 00 00 01 00 41 54 01 00 00 00 00 10 00 00 Available machine support:

ID (hex)    NAME
ffffffff    Generic DT based system
ffffffff    ARM-Versatile (Device Tree Support)

Please check your kernel config and/or bootloader.

So after doing some research, I learned that the reason why my old commands didn't work was because back in the day they had all the code for the different boards in the kernel. 因此,在进行了一些研究之后,我了解到我的旧命令不起作用的原因是因为它们早在内核中就具有用于不同板的所有代码。 So they decided to separate it out into device tree files (which is what I believe you were referring to in your last email?) So I noticed that the board files are included in /arch/arm/dts folder but they were just source files. 因此,他们决定将其分离为设备树文件(我相信您在上一封电子邮件中指的是什么?)所以我注意到主板文件包含在/ arch / arm / dts文件夹中,但它们只是源文件。 。 So I had to find a way to compile the board to a dtb to be able to include it to qemu using -dtb. 因此,我必须找到一种方法将板编译为dtb,以便能够使用-dtb将其包含到qemu中。 At first I found this command: 最初我发现以下命令:

ivan@UbuntuMATE-VBox:~/linux/scripts/dtc$ ./dtc -I dts -O dtb -o versatile-pb.dtb /home/ivan/linux/arch/arm/boot/dts/versatile-pb.dts
Error: /home/ivan/linux/arch/arm/boot/dts/versatile-pb.dts:2.1-2 syntax error FATAL ERROR: Unable to parse input tree

So that was a bit discouraging until I found out there is a way with make to make the image I need. 因此,这有点令人气make,直到我发现可以通过make制作所需的图像。 First to generate the config file. 首先生成配置文件。

ivan@UbuntuMATE-VBox:~/linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- versatile_defconfig

Then to generate the dtb file: 然后生成dtb文件:

ivan@UbuntuMATE-VBox:~/linux$ make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- dtbs

(Before continuing I should mention that I built the simple root file system mentioned in the original tutorial I was following. You'll see below what I mean). (在继续之前,我应该提到我构建了我所遵循的原始教程中提到的简单根文件系统。您将在下面看到我的意思)。

Then I tried running the command again: 然后我尝试再次运行该命令:

qemu-system-arm -M versatilepb -m 256M -nographic -kernel /home/ivan/linux/arch/arm/boot/uImage -initrd /home/ivan/opt/test/rootfs -dtb dts/versatile-pb.dtb -append "root=/dev/ram rdinit=/hello console= ttyS0"

Then I get another error: 然后我得到另一个错误:

vpb_sic_write: Bad register offset 0x2c

So I found out that ttyS0 emulates PC-style 8250/16550 serial ports where QEMU uses AMBA PL011 for the versatile machines so it uses ttyAMA0, which was originally what I tested with. 因此,我发现ttyS0模拟PC样式的8250/16550串行端口,其中QEMU使用AMBA PL011作为多功能机器,因此它使用ttyAMA0,这是我最初测试的。 Since my line has changed I figured I should change it... 由于我的路线已更改,因此我认为应该进行更改...

qemu-system-arm -M versatilepb -m 256M -nographic -kernel /home/ivan/linux/arch/arm/boot/uImage -initrd /home/ivan/opt/test/rootfs -dtb dts/versatile-pb.dtb -append "root=/dev/ram rdinit=/hello console= ttyAMA0"

Low and behold....it finally worked!!! 低点,瞧瞧...。终于奏效了!!!

vpb_sic_write: Bad register offset 0x2c
Booting Linux on physical CPU 0x0
Linux version 4.18.0+ (ivan@UbuntuMATE-VBox) (gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-16ubuntu3)) #1 Tue Aug 21 15:56:30 PDT 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
OF: fdt: Machine model: ARM Versatile PB Memory policy: Data cache writeback
random: get_random_bytes called from start_kernel+0x7c/0x3e4 with crng_init=0 Built 1 zonelists, mobility grouping on.  Total pages: 65024 Kernel command line: root=/dev/ram rdinit=/hello console=ttyAMA0 Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 253796K/262144K available (3935K kernel code, 144K rwdata, 964K rodata, 176K init, 130K bss, 8348K reserved, 0K cma-reserved) Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xd0800000 - 0xff800000   ( 752 MB)
    lowmem  : 0xc0000000 - 0xd0000000   ( 256 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0x(ptrval) - 0x(ptrval)   (3937 kB)
      .init : 0x(ptrval) - 0x(ptrval)   ( 176 kB)
      .data : 0x(ptrval) - 0x(ptrval)   ( 145 kB)
       .bss : 0x(ptrval) - 0x(ptrval)   ( 131 kB)
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 VIC @(ptrval): id 0x00041190, vendor 0x41 FPGA IRQ chip 0 "intc" @ (ptrval), 20 irqs, parent IRQ: 47
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns Failed to initialize '/amba/timer@101e3000': -22
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
Console: colour dummy device 80x30
Calibrating delay loop... 290.20 BogoMIPS (lpj=1451008)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x8400 - 0x8458 VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns futex hash table entries: 256 (order: -1, 3072 bytes)
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
OF: amba_device_add() failed (-19) for /amba/smc@10100000
OF: amba_device_add() failed (-19) for /amba/mpmc@10110000
OF: amba_device_add() failed (-19) for /amba/sctl@101e0000
OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000
OF: amba_device_add() failed (-19) for /amba/sci@101f0000
OF: amba_device_add() failed (-19) for /amba/ssp@101f4000
OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000
Serial: AMBA PL011 UART driver
101f1000.uart: ttyAMA0 at MMIO 0x101f1000 (irq = 28, base_baud = 0) is a PL011 rev1 console [ttyAMA0] enabled
101f2000.uart: ttyAMA1 at MMIO 0x101f2000 (irq = 29, base_baud = 0) is a PL011 rev1
101f3000.uart: ttyAMA2 at MMIO 0x101f3000 (irq = 30, base_baud = 0) is a PL011 rev1
uart-pl011 10009000.uart: aliased and non-aliased serial devices found in device tree. Serial port enumeration may be unpredictable.
10009000.uart: ttyAMA3 at MMIO 0x10009000 (irq = 54, base_baud = 0) is a PL011 rev1
clocksource: Switched to clocksource arm,sp804
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes) TCP established hash table entries: 2048 (order: 1, 8192 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048) UDP hash table entries: 256 (order: 0, 4096 bytes) UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
Freeing initrd memory: 492K
NetWinder Floating Point Emulator V0.97 (double precision)
workingset: timestamp_bits=30 max_order=16 bucket_order=0 Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) io scheduler mq-deadline registered io scheduler kyber registered pl061_gpio 101e4000.gpio: PL061 GPIO chip @0x101e4000 registered pl061_gpio 101e5000.gpio: PL061 GPIO chip @0x101e5000 registered pl061_gpio 101e6000.gpio: PL061 GPIO chip @0x101e6000 registered pl061_gpio 101e7000.gpio: PL061 GPIO chip @0x101e7000 registered versatile-tft-panel 10000000.sysreg:display@0: no panel detected
drm-clcd-pl111 dev:20: set up callbacks for Versatile PL110
brd: module loaded
of-flash 34000000.flash: versatile/realview flash protection
34000000.flash: Found 1 x32 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000 Intel/Sharp Extended Query Table at 0x0031 Using buffer write method
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net> smc91x 10010000.net eth0: SMC91C11xFD (rev 1) at (ptrval) IRQ 41 smc91x 10010000.net eth0: Ethernet addr: 52:54:00:12:34:56
rtc-ds1307 0-0068: registered as rtc0
versatile reboot driver registered
mmci-pl18x fpga:05: mmc0: PL181 manf 41 rev0 at 0x10005000 irq 59,60 (pio) mmci-pl18x fpga:0b: mmc1: PL181 manf 41 rev0 at 0x1000b000 irq 49,50 (pio) leds-syscon 10000000.core-module:led@08.0: registered LED versatile:0 leds-syscon 10000000.core-module:led@08.1: registered LED versatile:1 leds-syscon 10000000.core-module:led@08.2: registered LED versatile:2 leds-syscon 10000000.core-module:led@08.3: registered LED versatile:3 leds-syscon 10000000.core-module:led@08.4: registered LED versatile:4 leds-syscon 10000000.core-module:led@08.5: registered LED versatile:5 leds-syscon 10000000.core-module:led@08.6: registered LED versatile:6 leds-syscon 10000000.core-module:led@08.7: registered LED versatile:7
ledtrig-cpu: registered to indicate activity on CPUs
NET: Registered protocol family 17
input: AT Raw Set 2 keyboard as /devices/platform/amba/amba:fpga/10006000.kmi/serio0/input/input0
drm-clcd-pl111 dev:20: set up callbacks for Versatile PL110
drm-clcd-pl111 dev:20: set up callbacks for Versatile PL110
rtc-ds1307 0-0068: setting system clock to 2018-08-22 23:24:34 UTC (1534980274) Freeing unused kernel memory: 176K This architecture does not have kernel memory protection.
Hello World!random: fast init done
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/amba/amba:fpga/10007000.kmi/serio1/input/input2
drm-clcd-pl111 dev:20: set up callbacks for Versatile PL110

Hello World!
Hello World!

Try using the below command. 尝试使用以下命令。

qemu-system-arm -M versatilepb -m 256M -nographic -kernel arch/arm/boot/uImage -append "console=ttyS0" qemu系统臂-M多用途pb -m 256M -nographic-内核arch / arm / boot / uImage-附加“ console = ttyS0”

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

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