User avatar
RET80
Posts: 22
Joined: Mon Dec 19, 2016 10:52 pm

Raspberry Pi 4 and QEMU (x86/x64)

Fri Jul 26, 2019 1:47 am

Hello folks!

So I've been trying to get any x86-based OS working using QEMU and AQEMU as the front-end GUI and for the life of me, I have not been able to install any operating system. Be it any windows distribution from 95 onwards, to Linux or ReactOS. It seems as if the tinycode translator is not translating the x86 code properly and causing faults. Just about every single OS install breaks.

Has anyone here attempted to use Qemu at all with the Pi 4 and had any success? Or is Qemu's tinycode translator totally broken?

Or maybe any workarounds?

Depending on the OS install, it will fail, fault or lockup at various places during the install process.

Any help would be amazing.
"Just because you invested your valuable time in compensating for a software designer’s madness, does not mean the software is good. It means you don’t value your own time as much as you should. "

User avatar
RET80
Posts: 22
Joined: Mon Dec 19, 2016 10:52 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Fri Jul 26, 2019 10:15 pm

Sorry to push a thread back up - but anyone? I've been desperately trying to find a solution to this. Someone had to have run into this by now in some way?

Is there anything you'd like for me to run to any info to give to the forum/thread?
"Just because you invested your valuable time in compensating for a software designer’s madness, does not mean the software is good. It means you don’t value your own time as much as you should. "

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Sat Jul 27, 2019 1:25 am

No one knows, because no one has done it?

Most will be able to help with ARM QEMU on a x86 box.
You want to do x86 QEMU on a ARM box.

That might take longer to answer as only the Pi4 is perhaps good enough to do it and not enough have been out in the wild long enough.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
RET80
Posts: 22
Joined: Mon Dec 19, 2016 10:52 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Sat Jul 27, 2019 5:23 am

Gavinmc42 wrote:
Sat Jul 27, 2019 1:25 am
No one knows, because no one has done it?

Most will be able to help with ARM QEMU on a x86 box.
You want to do x86 QEMU on a ARM box.

That might take longer to answer as only the Pi4 is perhaps good enough to do it and not enough have been out in the wild long enough.
Right, I think so as well. The Pi 4 is still just so new, there haven't been enough people fiddling with x86 emulation on its latest ARM platform.
Well I'll keep hammering away at it and see if anyone has anything to add.

I might just compile from source, I just need to find the repo to get the absolute latest.
"Just because you invested your valuable time in compensating for a software designer’s madness, does not mean the software is good. It means you don’t value your own time as much as you should. "

User avatar
RET80
Posts: 22
Joined: Mon Dec 19, 2016 10:52 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Wed Jul 31, 2019 3:57 pm

Here is the solution.

Compile it right from source.
https://github.com/qemu/qemu

It will take about 4 hours to compile on a Pi 4.
Just be sure to read the instructions and be sure to call a 'make install' after it successfully compiles (with sudo preferably) to install it in the proper directories so that libvirt or AQEMU can see that QEMU exists.


In short, the QEMU from the Raspberry Pi 4 from aptitude repositories are completely broken (e.g. the apt-get install of qemu). Compile it yourself to fix it.
"Just because you invested your valuable time in compensating for a software designer’s madness, does not mean the software is good. It means you don’t value your own time as much as you should. "

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Thu Aug 01, 2019 5:52 am

Make sure your swap file is big enough when compiling.
I have mine set at 1GB on a 4B1.

I think the Pi4B4 can only handle upto to 3GB at the moment, USB driver conflict?
Use the other 1GB as swap?

One day Win95/98?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

jdonald
Posts: 449
Joined: Fri Nov 03, 2017 4:36 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Wed Aug 14, 2019 4:27 am

I ended up cross-compiling to save those four hours. In a Buster x86_64 container:

Code: Select all

git clone git://git.qemu-project.org/qemu.git
cd qemu
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y g++-arm-linux-gnueabihf flex bison libglib2.0-dev:armhf # and possibly some other lib*-dev:armhf deps
./configure --cross-prefix=arm-linux-gnueabihf- --prefix=/usr/local --target-list="i386-softmmu i386-linux-user x86_64-softmmu x86_64-linux-user " --enable-linux-user --enable-user --enable-system
make
sudo make install
# then copy installed /usr/local contents to the Pi
Windows 95 then installed properly as I followed the wiki on qemu.org. Took about 30 minutes step-by-step which felt a lot faster than I recall from doing this on a Pi 3B+ long ago.

I didn't test any Raspbian qemu binaries but I believe you RET80. Thanks for letting us all know before we have that heartache after a long wait on a slow emulated OS install.
Gavinmc42 wrote:
Thu Aug 01, 2019 5:52 am
I think the Pi4B4 can only handle upto to 3GB at the moment, USB driver conflict?
That was only for the 64-bit kernel. For the purpose of this thread users can compile on 32-bit Raspbian even if intending to emulate 64-bit Intel.

snowballEarth
Posts: 95
Joined: Wed Feb 18, 2015 9:05 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Fri Aug 14, 2020 3:41 pm

Will anyone kindly upload the working, compiled qemu to the repositories?

Using dosbox-x to emulate win9x is painfully slow

fruitoftheloom
Posts: 27225
Joined: Tue Mar 25, 2014 12:40 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Fri Aug 14, 2020 4:33 pm

snowballEarth wrote:
Fri Aug 14, 2020 3:41 pm
Will anyone kindly upload the working, compiled qemu to the repositories?

Using dosbox-x to emulate win9x is painfully slow

https://github.com/ptitSeb/box86

https://www.hackster.io/news/run-x86-ga ... ab2ebefd51
Take what I advise as advice not the utopian holy grail, and it is gratis !!

snowballEarth
Posts: 95
Joined: Wed Feb 18, 2015 9:05 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Fri Aug 14, 2020 5:38 pm

Thanks for the help. Box86 will eventually be the best way to run individual x86 programs on arm, if it isn't already.

I'm following the latest magpi96 guide to run the entire windows 98 operating system on the pi 4, using dosbox-x. It takes hours just to install one set of drivers. From what I've played with so far win98 is kind of usable after initial setup, if you stick to simple apps.

I've seen reports and watched YouTube videos of win 98 running better through qemu though. So if anyone has a guide on installing win9x on qemu

itainelken
Posts: 24
Joined: Tue Oct 20, 2020 3:12 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Wed Feb 24, 2021 4:45 pm

snowballEarth wrote:
Fri Aug 14, 2020 3:41 pm
Will anyone kindly upload the working, compiled qemu to the repositories?

Using dosbox-x to emulate win9x is painfully slow
I have compiled and packaged debian packages of qemu 5.2.50:
armhf: https://archive.org/download/macos_921_ ... -armhf.deb
arm64: https://archive.org/download/macos_921_ ... _arm64.deb

if you don't want to download those debs because of security reasons, I compiled qemu using those steps:
armhf:
compiled and packaged using my script: https://github.com/Itai-Nelken/qemu2deb ... ses/latest
if you want to see the exact steps to compile, see the arm64 steps or read my script.
arm64:
the following steps will compile all qemu machine types, and will take ~1 hour on a ssd and ~1-2 hours on a sd card.

Code: Select all

sudo apt install build-essential ninja-build libepoxy-dev libdrm-dev libgbm-dev libx11-dev libvirglrenderer-dev libpulse-dev libsdl2-dev git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libepoxy-dev libdrm-dev libgbm-dev libx11-dev libvirglrenderer-dev libpulse-dev libsdl2-dev git
git clone https://git.qemu.org/git/qemu.git
cd qemu
git submodule init
git submodule update --recursive
./configure --enable-sdl  --enable-opengl --enable-virglrenderer --enable-system --enable-modules --audio-drv-list=pa --enable-kvm
ninja -C build
sudo ninja install -C build
to make a deb, I used checkinstall (from here: https://github.com/giuliomoro/checkinstall, I have made a deb for it here:
armhf: https://archive.org/download/macos_921_ ... _armhf.deb
arm64: https://archive.org/download/macos_921_ ... _arm64.deb)
replace 'sudo ninja install -C build' with 'sudo checkinstall'.

WarrenUK
Posts: 16
Joined: Sat Dec 26, 2020 5:25 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Wed Aug 18, 2021 5:24 pm

itainelken wrote:
Wed Feb 24, 2021 4:45 pm
snowballEarth wrote:
Fri Aug 14, 2020 3:41 pm
Will anyone kindly upload the working, compiled qemu to the repositories?

Using dosbox-x to emulate win9x is painfully slow
I have compiled and packaged debian packages of qemu 5.2.50:
armhf: https://archive.org/download/macos_921_ ... -armhf.deb
arm64: https://archive.org/download/macos_921_ ... _arm64.deb

if you don't want to download those debs because of security reasons, I compiled qemu using those steps:
armhf:
compiled and packaged using my script: https://github.com/Itai-Nelken/qemu2deb ... ses/latest
if you want to see the exact steps to compile, see the arm64 steps or read my script.
arm64:
the following steps will compile all qemu machine types, and will take ~1 hour on a ssd and ~1-2 hours on a sd card.

Code: Select all

sudo apt install build-essential ninja-build libepoxy-dev libdrm-dev libgbm-dev libx11-dev libvirglrenderer-dev libpulse-dev libsdl2-dev git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libepoxy-dev libdrm-dev libgbm-dev libx11-dev libvirglrenderer-dev libpulse-dev libsdl2-dev git
git clone https://git.qemu.org/git/qemu.git
cd qemu
git submodule init
git submodule update --recursive
./configure --enable-sdl  --enable-opengl --enable-virglrenderer --enable-system --enable-modules --audio-drv-list=pa --enable-kvm
ninja -C build
sudo ninja install -C build
to make a deb, I used checkinstall (from here: https://github.com/giuliomoro/checkinstall, I have made a deb for it here:
armhf: https://archive.org/download/macos_921_ ... _armhf.deb
arm64: https://archive.org/download/macos_921_ ... _arm64.deb)
replace 'sudo ninja install -C build' with 'sudo checkinstall'.
Hi,

I'm trying to get qemu working on the pi 400. I am running Ubuntu Mate 21.04. Do you know if the official repos contain a working qemu or are they still broke? Anyway I went ahead and installed it anyway.

I tried downloading your compiled qemu 5.2.50 from your post but the link is dead.

I am running this from the cmd line:

$ qemu-system-aarch64 -m 512 -nic user,model=virtio -drive file=alpine.qcow2,media=disk,if=virtio -cdrom alpine-standard-3.14.1-aarch64.iso -sdl

I get 'qemu-system-aarch64: -sdl: SDL support is disabled'

When I remove the sdl switch I get:

'qemu-system-aarch64: No machine specified, and there is no default. Use -machine help to list supported machines'

I'm pretty new to qemu as you can tell but I would love to get it working on my pi 400.

Any ideas?

Cheers.

cleverca22
Posts: 7791
Joined: Sat Aug 18, 2012 2:33 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Wed Aug 18, 2021 6:32 pm

WarrenUK wrote:
Wed Aug 18, 2021 5:24 pm
'qemu-system-aarch64: No machine specified, and there is no default. Use -machine help to list supported machines'
your running the aarch64 qemu, but this thread is about the x86 qemu

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Thu Aug 19, 2021 12:44 am

I compiled QEMU 6.0.9 arm/aarch64 recently, easier than I expected.
Have not tried the x86 version.
Would be fun if I had the time, maybe next lockdown?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

WarrenUK
Posts: 16
Joined: Sat Dec 26, 2020 5:25 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Thu Aug 19, 2021 10:51 am

cleverca22 wrote:
Wed Aug 18, 2021 6:32 pm
WarrenUK wrote:
Wed Aug 18, 2021 5:24 pm
'qemu-system-aarch64: No machine specified, and there is no default. Use -machine help to list supported machines'
your running the aarch64 qemu, but this thread is about the x86 qemu
Ok I'm confused. Does x86 Qemu work on pi 4? What am I missing? So if I want to run an x86 distro under pi 4 with Qemu I need to use x86 Qemu?

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Thu Aug 19, 2021 12:01 pm

QEMU on Pi can easy do arm and aarch64.

Need to have a x86 "guest" to emulate a PC.
Plenty of search results for arm/aarch64 "guest on PC/x86x64...

For 32bit Pi's - Arm Platform with x86 guest.
Should be able to do DOS/Win3?

I think I used this and ended up with arm and aarch64 guests.
https://www.qemu.org/download/

Play a bit more with configure and get an X86 guest too?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Thu Aug 19, 2021 12:18 pm

Very interesting had a look at./configure again, lots of guest

"qemu-x86_64 -h" popped up the help and so did many others
Seems like I have a lot of guests.
Do I have cross compilers for all of them :shock:

Code: Select all

 aarch64-softmmu alpha-softmmu arm-softmmu avr-softmmu cris-softmmu hppa-softmmu i386-softmmu m68k-softmmu microblaze-softmmu microblazeel-softmmu mips-softmmu mips64-softmmu mips64el-softmmu mipsel-softmmu nios2-softmmu or1k-softmmu ppc-softmmu ppc64-softmmu riscv32-softmmu riscv64-softmmu rx-softmmu s390x-softmmu sh4-softmmu sh4eb-softmmu sparc-softmmu sparc64-softmmu tricore-softmmu x86_64-softmmu xtensa-softmmu xtensaeb-softmmu aarch64-linux-user aarch64_be-linux-user alpha-linux-user arm-linux-user armeb-linux-user cris-linux-user hexagon-linux-user hppa-linux-user i386-linux-user m68k-linux-user microblaze-linux-user microblazeel-linux-user mips-linux-user mips64-linux-user mips64el-linux-user mipsel-linux-user mipsn32-linux-user mipsn32el-linux-user nios2-linux-user or1k-linux-user ppc-linux-user ppc64-linux-user ppc64le-linux-user riscv32-linux-user riscv64-linux-user s390x-linux-user sh4-linux-user sh4eb-linux-user sparc-linux-user sparc32plus-linux-user sparc64-linux-user x86_64-linux-user xtensa-linux-user xtensaeb-linux-user
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

WarrenUK
Posts: 16
Joined: Sat Dec 26, 2020 5:25 pm

Re: Raspberry Pi 4 and QEMU (x86/x64)

Fri Aug 20, 2021 6:14 pm

Gavinmc42 wrote:
Thu Aug 19, 2021 12:01 pm
QEMU on Pi can easy do arm and aarch64.

Need to have a x86 "guest" to emulate a PC.
Plenty of search results for arm/aarch64 "guest on PC/x86x64...

For 32bit Pi's - Arm Platform with x86 guest.
Should be able to do DOS/Win3?

I think I used this and ended up with arm and aarch64 guests.
https://www.qemu.org/download/

Play a bit more with configure and get an X86 guest too?
Thanks for your help.

So I could use aarch64 qemu on my pi 4 to run a VM of Ubuntu 21.04 arm64 version?

User avatar
Gavinmc42
Posts: 7691
Joined: Wed Aug 28, 2013 3:31 am

Re: Raspberry Pi 4 and QEMU (x86/x64)

Sat Aug 21, 2021 12:07 am

So I could use aarch64 qemu on my pi 4 to run a VM of Ubuntu 21.04 arm64 version?
Probably, but don't expect a desktop.
I have not run a 64bit VM on Pi OS 32.

I did run 7 small Ultibo VMs at once, so one bigger VM OS should work.
Try it out and seen what happens.
This is all pretty new territory to explore.

I do know running 32 bit on Aarch64 is easier, so maybe use the 64bit Beta Raspberry OS.
Or just use the latest Ubuntu on Pi.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Troubleshooting”