dhruvvyas90 / qemu-rpi-kernel

Qemu kernel for emulating Rpi on QEMU
2.05k stars 362 forks source link

Running on Windows? #153

Closed sdbbs closed 1 year ago

sdbbs commented 1 year ago

I have installed https://qemu.weilnetz.de/w64/qemu-w64-setup-20221230.exe ( via https://www.qemu.org/download/#windows ) in C:\bin\qemu. I would like to emulate run Raspbian Stretch.

Due to the error:

C:\bin\qemu\qemu-system-aarch64.exe: Invalid SD card size: 1.68 GiB
SD card size has to be a power of 2, e.g. 2 GiB.
You can resize disk images with 'qemu-img resize <imagefile> <new-size>'
(note that this will lose data if you make the image smaller than it currently is).

I did the following:

copy 2019-04-08-raspbian-stretch-lite.img 2019-04-08-raspbian-stretch-lite-resize-2G.img
C:\bin\qemu\qemu-img.exe resize 2019-04-08-raspbian-stretch-lite-resize-2G.img 2G

If I run the following .bat file:

:: MUST NOT HAVE  .bat continuation character caret ^ on last line, else: : drive with bus=0, unit=0 (index=0) exists
:: MUST NOT use single quotes in .bat file, only double quotes are interpreted as a string delimiter

C:\bin\qemu\qemu-system-aarch64.exe  -machine type=raspi3b  -m 1G -smp 4 ^
-kernel ./kernel7.img ^
-dtb ./bcm2710-rpi-3-b-plus.dtb ^
-append "rw earlycon=pl011,0x3f201000 console=ttyAMA0 loglevel=8 root=/dev/mmcblk0p2 fsck.repair=yes net.ifnames=0 rootwait memtest=1 dwc_otg.fiq_fsm_enable=0" ^
-usb ^
-serial stdio ^
-netdev user,id=net0,hostfwd=tcp::5022-:22,hostfwd=tcp::5080-:80,hostfwd=tcp::5069-:8069,hostfwd=tcp::5443-:443 ^
-device usb-hub ^
-device usb-kbd ^
-device usb-net,netdev=net0 ^
-drive id=hd-root,format=raw,file=./2019-04-08-raspbian-stretch-lite-resize-2G.img

... then I see a QEMU window start, but it is blank/black; also in command prompt there are messages:

(C:\bin\qemu\qemu-system-aarch64.exe:20836): Gdk-WARNING **: 02:00:20.678: Could not open registry key 'SYSTEM\CurrentControlSet\Control\Keyboard Layouts\D0010409'. Error code: 2

(qemu:20836): Gtk-WARNING **: 02:00:22.701: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.

If I use this command in the .bat file instead:

:: MUST NOT HAVE  .bat continuation character caret ^ on last line, else: : drive with bus=0, unit=0 (index=0) exists
:: MUST NOT use single quotes in .bat file, only double quotes are interpreted as a string delimiter

C:\bin\qemu\qemu-system-arm.exe -M versatilepb -m 256M -cpu arm1176 ^
  -kernel ./qemu-rpi-kernel_git/kernel-qemu-4.19.50-buster ^
  -dtb ./qemu-rpi-kernel_git/versatile-pb-buster.dtb ^
  -net user,hostfwd=tcp::5022-:22 ^
  -hda ./2019-04-08-raspbian-stretch-lite.img ^
  -append "root=/dev/sda2 panic=1" ^
  -no-reboot

... then QEMU actually boots Raspian Stretch - with these messages in terminal:

(C:\bin\qemu\qemu-system-arm.exe:23060): Gdk-WARNING **: 02:06:19.799: Could not open registry key 'SYSTEM\CurrentControlSet\Control\Keyboard Layouts\D0010409'. Error code: 2
WARNING: Image format was not specified for './2019-04-08-raspbian-stretch-lite.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
dsound: Could not initialize DirectSound
dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID
sdl: SDL_OpenAudioDevice for playback failed
sdl: Reason: WASAPI can't find requested audio endpoint: Element not found.
sdl: SDL_OpenAudioDevice for playback failed
sdl: Reason: WASAPI can't find requested audio endpoint: Element not found.
audio: Failed to create voice `lm4549.out'
C:\bin\qemu\qemu-system-arm.exe: warning: hub 0 with no nics

(qemu:23060): Gtk-WARNING **: 02:06:22.452: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
vpb_sic_write: Bad register offset 0x2c

... and after I log in into Raspbian in Qemu, there is no network:

pi@raspberry:~ $ ping yahoo.com
ping: yahoo.com: Temporary failure in name resolution

pi@raspberry:~ $ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever

So, I would like to ask the following:

sdbbs commented 1 year ago

OK, found how to get network with default emulation ( via https://superuser.com/questions/297162/how-to-access-internet-from-qemu#comment794384_297828 ):

:: MUST NOT HAVE  .bat continuation character caret ^ on last line, else: : drive with bus=0, unit=0 (index=0) exists
:: MUST NOT use single quotes in .bat file, only double quotes are interpreted as a string delimiter

C:\bin\qemu\qemu-system-arm.exe -M versatilepb -m 256M -cpu arm1176 ^
  -kernel ./qemu-rpi-kernel_git/kernel-qemu-4.19.50-buster ^
  -dtb ./qemu-rpi-kernel_git/versatile-pb-buster.dtb ^
  -net nic -net user ^
  -hda ./2019-04-08-raspbian-stretch-lite.img ^
  -append "root=/dev/sda2 panic=1" ^
  -no-reboot
dhruvvyas90 commented 1 year ago

The user found a solution to the problem.