So I have been following this article:
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
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:
Just black screen after running 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!
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. So I had to find a way to compile the board to a dtb to be able to include it to qemu using -dtb. 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. 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:
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. 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"
User contributions licensed under CC BY-SA 3.0