Arm Mac Virtualbox

I recently started flipping through The MagPi back-issues, and came across an article where someone talked about setting up a virtual Raspberry Pi environment. At the time he wrote his article, I don’t think the Pi was even really available to the public yet.

It got me thinking though. I’ve been playing around a lot on the Pi itself, but it’d be convenient to have an environment setup where I could experiment with code even when I don’t have access to the Pi.

Good news: A new version of Parallels Desktop for Mac that can run on Mac with Apple M1 chip is already in active development. When Apple Silicon Mac was first announced during the keynote at WWDC on June 22 of this year, Apple demoed a Parallels Desktop for Mac prototype running a Linux virtual machine flawlessly on Apple Silicon. While the OS and the hardware support virtualisation, you cannot currently run Virtual Box or similar virtualisation software on an ARM Mac. And more importantly, none of the commonly used guest operating systems can run on an ARM Mac. Virtualbox is not an emulator, so it cannot translate ARM instructions to an x86 computer, nor x86 instructions to an ARM computer. Virtualbox is not officially compiled for ARM. Regrettably this means that Virtualbox in its present form will not run on the ARM-based Macs.

  1. Right now (mid November 2020), for all practical purposes, no. While the OS and the hardware support virtualisation, you cannot currently run Virtual Box or similar virtualisation software on an ARM Mac. And more importantly, none of the commonly used guest operating systems can run on an ARM Mac.
  2. I've been using the 'beta' version of Parallels on my M1 Air running Windows 10 (Arm), it works very well and I'm impressed with Parallels in general, given I have been a licensed VMware Fusion user for lots of years. I read that the official release of Parallels for M1 was today, but I am far from impressed on there software licensing model.

Goal: Setup a virtual machine with Debian (from which Raspbian is derived). Install Python and other libraries and installers, so I can code solutions that can be migrated to the Pi.

Limitations: The RPi.GPIO library expects the GPIO pins to be available. If you’re not on the Pi, you can’t execute code that directly accesses them. It’ll complain loudly that you can only run your code on an actual Pi.

We’ll contemplate work-arounds later. Just wanted to state this upfront though – this solution is not a complete virtual Pi.

Also, this is an attempt to closely emulate Raspbian, not the ARM processor found on the Pi. If you’re interested in trying to emulate the processor, check out QEMU. It looked a little complicated to tackle, so I’m holding off for now, but I’d like to revisit it.

(Even better, reader kriss seems to have gotten QEMU to work, and left a helpful comment below.)

Install VirtualBox

I already use VirtualBox for emulating Windows and Ubuntu on a Mac, so I wanted to stick with that if possible.

Why not Raspbian?

Unfortunately, although Raspbian images are available for download, you can’t use them to create a VM in VirtualBox. From what I could find, it’s apparently because the Pi runs on an ARM processor, but VirtualBox is designed to emulate OS’s that support X86 processors.

Whatever the reason, all I could get was a black screen with the message:

“FATAL: No bootable medium found! System halted.”

Raspbian is based off of Debian though, so let’s use Debian.

Install Debian

Go to https://www.debian.org/distrib and download the 64-bit PC netinst iso.

Create a new VirtualBox instance. Type the name “Debian” and it should auto-select type Linux and version Debian (64-bit) – if not, select them.

Set the settings according to the minimum requirements, which should pretty closely mirror the Pi. The current release is jessie. Using the graphical desktop, the recommended RAM is 1GB and hard drive space is 10GB.

Choose the ISO file you downloaded earlier and install in VirtualBox, keeping all the defaults.

Leave the network stuff the same, keeping the default hostname as-is and the domain name empty. Create passwords when prompted, and choose ‘yes’ when it asks you “write the changes to disks?”. Go get a cup of coffee. And a sandwich. It’s going to unpackage and install a lot of files, which can take 10-15 minutes.

When you finally get to the “device for boot loader installation” prompt, select the “/dev/sda” option from the list and continue. It’ll reboot and finally let you login.

When you finally get into Debian, click “Activities” in the upper-left and type in “term” to find the Terminal application.

Verify Python is Installed

You can verify that python2 and python3 are already installed by starting each shell.

Upgrading Packages

From time to time, you may want to upgrade the packages installed on your new VM. To do that, you’ll need to be logged in as root, but “sudo” isn’t installed by default. You can follow this tutorial to install sudo, or just type “su” and enter your password. Personally, I’d recommend installing sudo. Every example you find is going to tell you to use it, not to type “su”.

To upgrade installed packages, run:

Get Git

Once you start developing code, the easiest way to migrate it to the Pi will be to commit it to GitHub in your VM, and then pull it from GitHub on the Pi. For that, you’ll need to install git:

Virtualbox

Try Out a Script

Let’s clone a project from GitHub and try out a script. There’s a repo on GitHub that’s full of “hello world” scripts in different languages. Let’s use that.

Create a new directory and clone “https://github.com/leachim6/hello-world.git”. Run the “p/python.py” file.

Installing Other Dependencies

You can install whatever else you’d normally install on Raspbian too.

Do you use Pibrella? Follow “Emulating a Raspberry Pi on Virtualbox”, starting half-way down under the header “Pibrella Module Installation” and “Python 3 Addition”.

Arm Mac Virtualbox

If you typically use the pip package manager, you can easily install that too.

What about the GPIO pins and RPi.GPIO?

I use the RPi.GPIO library for easily communicating with the GPIO pins from my Python scripts.

You can install the RPi.GPIO library using pip install RPi.GPIO.

If you get the following error message, it can’t find some file. Run apt-get install python-dev to make it happy.

It should install okay, but if you try to run a script that takes advantage of it, you’ll get the loud error message I posted up at the top of this post. It wants the GPIO pins to be present.

I can think of an easy fix and a hard fix.

The hard fix would be to somehow trick Debian into thinking the hardware is present. I have no idea how to do that, but I’d love to find a way to trick it, and have an app that shows a Raspberry Pi. And every time RPi.GPIO tries to enable or disable a pin, the app intercepted it and indicated what was going on.

The easy(ier) fix is to write a GPIO script that mirrors all the functions in the official RPi.GPIO library, but just outputs a message to the console saying that a pin has been turned on, or off, or adjusted somehow. Tedious, but doable. I already made one with just a few functions for one of my scripts.

Arm mac virtualbox download

Make sure you include a line like this at the top of your scripts:

Virtualbox

Then create a mock script called MyMockedGpio or whatever you want. When you want to test things without the Pi, just replace the above line with:

And the rest of your code should be none the wiser.

If you didn’t know where to start, hopefully this helps you out. And if you manage to take this to the next level, I’d love to hear from you! Feel free to leave a comment below...

With M1 Macs mere days away for early adopters, those who need to run virtual machines on their Macs may have a bumpy time ahead.

It is important to note that currently available versions of Parallels® Desktop for Mac cannot run virtual machines on Mac with Apple M1 chip. Good news: A new version of Parallels Desktop for Mac that can run on Mac with Apple M1 chip is already in active development.

When Apple Silicon Mac was first announced during the keynote at WWDC on June 22 of this year, Apple demoed a Parallels Desktop for Mac prototype running a Linux virtual machine flawlessly on Apple Silicon. Since WWDC, our new version of Parallels Desktop which runs on Mac with Apple M1 chip has made tremendous progress. We switched Parallels Desktop to universal binary and optimized its virtualization code; and the version that we are eager to try on these new MacBook Air, Mac mini and MacBook Pro 13″ looks very promising.

VMWare Fusion isn’t ready yet either, according to this tweet:

So excited for todays announcements from @Apple!

While we're not quite ready to announce our timeline, we're happy to say that we are committed to delivering VMware virtual machines on #AppleSilicon! pic.twitter.com/en1FNorxrM

— VMware Fusion (@VMwareFusion) November 10, 2020

Virtualbox Apple Silicon

Even when these and other virtualization tools are ready,1 running Windows as a VM atop a M1 Mac probably isn’t going to be. So far, all the public has seen running virtually on M1 Macs is ARM-based Linux, back at WWDC.

Microsoft has a version of Windows running on ARM chips, but as of this summer, things didn’t look great for getting it to run virtually on the new Macs:

“Microsoft only licenses Windows 10 on ARM to OEMs,” says a Microsoft spokesperson in a statement to The Verge. We asked Microsoft if it plans to change this policy to allow Windows 10 on ARM-based Macs, and the company says “we have nothing further to share at this time.”

That said, ARM Windows is getting better. Back in September, Microsoft announced that the ARM version of Windows 10 is gaining x64 emulation:

Arm Mac Virtualbox Free

We are excited about the momentum we are seeing from app partners embracing Windows 10 on ARM, taking advantage of the power and performance benefits of Qualcomm Snapdragon processors. We heard your feedback and are making Microsoft Edge faster while using less battery, and announced that we will soon release a native Microsoft Teams client optimized for Windows 10 on ARM. We will also expand support for running x64 apps, with x64 emulation starting to roll out to the Windows Insider Program in November. Because developers asked, Visual Studio Code has also been updated and optimized for Windows 10 on ARM. For organizations, we’re committed to helping them ensure their apps work with Windows 10 and Microsoft 365 Apps on ARM64 devices with App Assure.

Before this, the ARM version of Windows could only emulate 32-bit applications. It’s a nice improvement, and maybe one day it will matter to Mac users.

Virtualbox Arm Linux

  1. Oh, and Boot Camp is totes dead. Docker is currently busted, but should work in the future. ↩