dhruvvyas90 / qemu-rpi-kernel

Qemu kernel for emulating Rpi on QEMU
2.04k stars 357 forks source link

Any chance of kernels that will work with Ubuntu 64 bit? #100

Open bolind opened 4 years ago

bolind commented 4 years ago

Ubuntu recently added support for 64bit Linux on Raspberry Pi 3 and 4. I'm guessing these kernels will not work with Ubuntu. Would it be very involved to also release kernels for this distro?

guysoft commented 4 years ago

Duplicate of #99 which I posted two weeks ago

dhruvvyas90 commented 4 years ago

I believe that one should be able to use Qemu's aarch64 (qemu-system-aarch64) emulation to emulate 64 bit Raspberry pi with raspi2 machine option with shipped kernel and image without modification. I haven't tried it, though.

Kernels on this repo are specifically tweaked so that it works with qemu's versatilepb machine since at that time (2015-16), qemu didn't allow Rpi2 machine emulation.

Hope it helps.

guysoft commented 4 years ago

RaspberryPi 2 is not 64-bit. Only 3 and so on are

dhruvvyas90 commented 4 years ago

Right. Qemu now allows emulation for rpi2 (qemu-system-arm) and rpi3 (qemu-system-aarch64).

guysoft commented 4 years ago

Can you give me an example execution? Been fiddling with it and I am not sure what args to pass for cpu, kernel, machine and dtb and so on.

sfantree commented 4 years ago

64bit os can refer this link https://github.com/wimvanderbauwhede/limited-systems/wiki/Debian-%22buster%22-for-Raspberry-Pi-3-on-QEMU

guysoft commented 4 years ago

@sfantree Thanks, that might be what I need. But it want you to fiddle with the fstab. Would need to script that, since my lib uses this at the moment: https://github.com/guysoft/CustomPiOS/blob/devel/src/qemu_boot.sh

sfantree commented 4 years ago

@guysoft For newly release zipfile of Rapbian distribution ,/etc/fstab use PARTUUID instead of special devname /dev/sdx. it still work without modification, like #97 said

guysoft commented 4 years ago

Hey, took a look at it and it seems to boot, and then gets stuck. Also - the instructions had listed an initrd which does not exist in Raspberry Pi, which seems odd. As the same for the kernel image is called vmlinux there, which is again, not the convention in the Raspberry Pi images.

Script I am using: https://github.com/guysoft/CustomPiOS/blob/devel/src/qemu_boot64.sh

Here is a screenshot of what I get: Screenshot_20200406_155228

console log:

[  OK  ] Reached target NFS client services.
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Remote File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctl default" or "exit"
to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.

Reloading system manager configuration
Starting default target
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctl default" or "exit"
to boot into default mode.

Cannot open access to console, the root account is locked.
See sulogin(8) man page for more details.

Press Enter to continue.
guysoft commented 4 years ago

Ok, update - I removed the sda1 mount and it works. Keyboard grab does not work on the display because some kernel module break, info below. That guide says:

QEMU supports many physical hardware platforms, and has recently added support for the Raspberry Pi 3 with the raspi3 model. However, this is only for 64-bit distributions, and there is currently no emulation of the BCM2835 USB controller, so there is no USB support and also, more critically, no networking support.

Which would make me urge @dhruvvyas90 to add a 64bit image that does have networking + USB. Because this configuration is mostly useless without networking.

Screenshot_20200406_161012

One more thing though, the kernel crashes with lots of errors on the way, but it recovers:

[    1.720651] io scheduler kyber registered
[    1.748514] brcmvirt-gpio soc:virtgpio: Failed to set gpiovirtbuf, trying to get err:0
[    1.749986] ------------[ cut here ]------------
[    1.751193] WARNING: CPU: 0 PID: 1 at arch/arm64/mm/ioremap.c:58 __ioremap_caller+0xc4/0xf8
[    1.751848] Modules linked in:
[    1.752525] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.97-v8+ #1294
[    1.752991] Hardware name: Raspberry Pi 3 Model B (DT)
[    1.753598] pstate: 80000005 (Nzcv daif -PAN -UAO)
[    1.753976] pc : __ioremap_caller+0xc4/0xf8
[    1.754296] lr : __ioremap_caller+0xc4/0xf8
[    1.754596] sp : ffffff8008023ae0
[    1.754881] x29: ffffff8008023ae0 x28: ffffff8008c46578 
[    1.755337] x27: ffffff8008b606ac x26: 00000000fb840000 
[    1.755715] x25: ffffff800803d000 x24: ffffff80088c7010 
[    1.756121] x23: 0068000000000707 x22: ffffff80085006bc 
[    1.756491] x21: 0000000000000000 x20: 000000003b840000 
[    1.756857] x19: 0000000000001000 x18: ffffff8008c68688 
[    1.757245] x17: 0000000000000000 x16: 0000000000000000 
[    1.757585] x15: ffffff8088d6f48f x14: 0000000000000006 
[    1.757869] x13: ffffff8008d6f49d x12: 7562747269766f69 
[    1.758302] x11: ffffff8008c7d000 x10: 0000000005f5e0ff 
[    1.758629] x9 : ffffff80080237c0 x8 : 0000000000000000 
[    1.758884] x7 : ffffff8008c68688 x6 : ffffff8008c68000 
[    1.759387] x5 : ffffff8008c68de0 x4 : ffffff8008104b6c 
[    1.759780] x3 : ffffff80080238d0 x2 : db4e1c3d3410e900 
[    1.760174] x1 : 0000000000000000 x0 : 0000000000000024 
[    1.760754] Call trace:
[    1.761008]  __ioremap_caller+0xc4/0xf8
[    1.761324]  __ioremap+0x3c/0x50
[    1.761588]  brcmvirt_gpio_probe+0x2e4/0x480
[    1.761905]  platform_drv_probe+0x54/0xb0
[    1.762284]  really_probe+0x218/0x2c8
[    1.762572]  driver_probe_device+0x60/0x108
[    1.762877]  __driver_attach+0x104/0x108
[    1.763189]  bus_for_each_dev+0x78/0xe0
[    1.763470]  driver_attach+0x30/0x40
[    1.763748]  bus_add_driver+0x1d0/0x238
[    1.764038]  driver_register+0x68/0x118
[    1.764338]  __platform_driver_register+0x54/0x60
[    1.764689]  brcmvirt_gpio_driver_init+0x20/0x28
[    1.765010]  do_one_initcall+0x54/0x250
[    1.765309]  kernel_init_freeable+0x2a4/0x3c0
[    1.765630]  kernel_init+0x18/0x110
[    1.765890]  ret_from_fork+0x10/0x18
[    1.766316] ---[ end trace d6aed98684eed47d ]---
[    1.767394] brcmvirt-gpio soc:virtgpio: Failed to map physical address
[    1.768009] brcmvirt-gpio: probe of soc:virtgpio failed with error -2
[    1.771505] bcm2708_fb soc:fb: More displays reported from firmware than supported in driver (4294967168 vs 3)
[    1.772171] bcm2708_fb soc:fb: FB found 3 display(s)
[    1.812202] Console: switching to colour frame buffer device 100x30
[    1.819514] bcm2708_fb soc:fb: Registered framebuffer for display 0, size 800x480
[    1.823489] bcm2708_fb soc:fb: Registered framebuffer for display 1, size 800x480
[    1.830215] bcm2708_fb soc:fb: Registered framebuffer for display 2, size 800x480
[    1.872326] bcm2835-rng 3f104000.rng: hwrng registered
[    1.874832] vc-mem: phys_addr:0x00000000 mem_base=0x00000000 mem_size:0x00000000(0 MiB)
[    1.885802] gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
[    1.889807] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    2.007233] brd: module loaded
[    2.075696] loop: module loaded
[    2.079567] bcm2835-power bcm2835-power: ASB register ID returned 0x00000000
[    2.081301] Loading iSCSI transport class v2.0-870.
[    2.096307] libphy: Fixed MDIO Bus: probed
[    2.098400] usbcore: registered new interface driver r8152
[    2.099421] usbcore: registered new interface driver lan78xx
[    2.100125] usbcore: registered new interface driver smsc95xx
[    2.102514] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    2.107402] dwc_otg 3f980000.usb: base=(____ptrval____)
[    2.315219] Core Release: 0.000
[    2.315747] Setting default values for core params
[    2.318741] Finished setting default values for core params
[    2.320176] dwc_otg 3f980000.usb: Bad value for SNPSID: 0x00000000
[    2.322518] dwc_otg: probe of 3f980000.usb failed with error -22
[    2.323701] dwc_otg: FIQ enabled
[    2.323999] dwc_otg: NAK holdoff enabled
[    2.324318] dwc_otg: FIQ split-transaction FSM enabled
[    2.324712] Module dwc_common_port init
[    2.327536] usbcore: registered new interface driver uas
[    2.328974] usbcore: registered new interface driver usb-storage
[    2.332673] mousedev: PS/2 mouse device common for all mice
[    2.351582] bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
[    2.391721] sdhci: Secure Digital Host Controller Interface driver
[    2.392335] sdhci: Copyright(c) Pierre Ossman
[    2.406521] mmc-bcm2835 3f300000.mmcnr: could not get clk, deferring probe
[    2.414519] sdhost-bcm2835 3f202000.mmc: could not get clk, deferring probe
[    2.416410] sdhci-pltfm: SDHCI platform and OF driver helper
[    2.435373] ledtrig-cpu: registered to indicate activity on CPUs
[    2.437017] hidraw: raw HID events driver (C) Jiri Kosina
[    2.439817] usbcore: registered new interface driver usbhid
[    2.440312] usbhid: USB HID core driver
[    2.446594] vchiq: vchiq_init_state: slot_zero = (____ptrval____), is_master = 0
[    2.454402] bcm2835_vchiq 3f00b840.mailbox: failed to set channelbase
[    2.455244] vchiq: could not load vchiq
[    2.459599] Initializing XFRM netlink socket
[    2.460722] NET: Registered protocol family 17
[    2.462758] Key type dns_resolver registered
[    2.468183] registered taskstats version 1
[    2.468573] Loading compiled-in X.509 certificates
[    2.584263] bcm2835-clk 3f101000.cprman: plla: couldn't lock PLL
[    2.585538] ------------[ cut here ]------------
[    2.585986] Enabling unprepared plla
[    2.586564] WARNING: CPU: 1 PID: 34 at drivers/clk/clk.c:888 clk_core_enable+0xc0/0x280
[    2.587219] Modules linked in:
[    2.587739] CPU: 1 PID: 34 Comm: kworker/1:1 Tainted: G        W         4.19.97-v8+ #1294
[    2.588392] Hardware name: Raspberry Pi 3 Model B (DT)
[    2.592712] Workqueue: events deferred_probe_work_func
[    2.593335] pstate: 80000085 (Nzcv daIf -PAN -UAO)
[    2.593773] pc : clk_core_enable+0xc0/0x280
[    2.594180] lr : clk_core_enable+0xc0/0x280
[    2.594542] sp : ffffff8008f4ba10
[    2.594862] x29: ffffff8008f4ba10 x28: 0000000000000000 
[    2.595354] x27: 0000000000000001 x26: ffffff8008aca748 
[    2.595817] x25: 00000000006000c0 x24: ffffffc0391bb300 
[    2.596306] x23: 0000000000000001 x22: ffffffc03a256b00 
[    2.596779] x21: ffffff8008ac9f10 x20: ffffff8008e38000 
[    2.597253] x19: ffffffc03a256b00 x18: ffffff8008c68688 
[    2.597662] x17: 0000000000000000 x16: 0000000000000000 
[    2.598144] x15: ffffff8088d6f48f x14: 0000000000000006 
[    2.598630] x13: ffffff8008d6f49d x12: 0000000000000018 
[    2.599126] x11: ffffff8008c7d000 x10: 0000000005f5e0ff 
[    2.599566] x9 : ffffff8008f4b6b0 x8 : 2064657261706572 
[    2.600013] x7 : 706e7520676e696c x6 : 00000000000000d3 
[    2.600470] x5 : 0000000000000012 x4 : 0000000000000000 
[    2.600855] x3 : 0000000000000000 x2 : 0000004032b46000 
[    2.601244] x1 : db4e1c3d3410e900 x0 : 0000000000000000 
[    2.601616] Call trace:
[    2.601832]  clk_core_enable+0xc0/0x280
[    2.602128]  clk_register+0x53c/0x6f0
[    2.602402]  devm_clk_hw_register+0x50/0xb0
[    2.602711]  bcm2835_register_pll+0xb8/0xf8
[    2.603014]  bcm2835_clk_probe+0x1c0/0x280
[    2.603320]  platform_drv_probe+0x54/0xb0
[    2.603613]  really_probe+0x218/0x2c8
[    2.603898]  driver_probe_device+0x60/0x108
[    2.604221]  __device_attach_driver+0x98/0xe8
[    2.604546]  bus_for_each_drv+0x80/0xe0
[    2.604829]  __device_attach+0xe8/0x148
[    2.605116]  device_initial_probe+0x24/0x30
[    2.605445]  bus_probe_device+0xa0/0xa8
[    2.605746]  deferred_probe_work_func+0x74/0xa8
[    2.606096]  process_one_work+0x158/0x458
[    2.606538]  worker_thread+0x244/0x460
[    2.606838]  kthread+0x104/0x130
[    2.607123]  ret_from_fork+0x10/0x18
[    2.607350] ---[ end trace d6aed98684eed47f ]---
[    2.708907] bcm2835-clk 3f101000.cprman: pllc: couldn't lock PLL
[    2.709324] ------------[ cut here ]------------

That might need fixing. Anywyay this script lets you open an image and boot from it: https://github.com/guysoft/CustomPiOS/blob/devel/src/qemu_boot64.sh

dhruvvyas90 commented 3 years ago

@guysoft : Qemu 5.1+ supports usb controller with raspi machines. Can you follow instructions under native-emulation subfolder and see if it allows you to emulate ubuntu 64 bit ? Thanks.

guysoft commented 3 years ago

Saw now, will try when I get time, which I am not sure when that is.