Install 64 OS on Raspberry Pi zero 2 - Q-engineering
Q-engineering
Q-engineering
Go to content
images/empty-GT_imagea-1-.png
64-bit OS Raspberry Pi 4

Install 64 bit OS on Raspberry Pi zero 2 W

64-OS RPi 3 + 4
Last updated: February 14, 2022

Introduction.

This article explores the possible use of a 64-bit operating system on the new Raspberry Pi Zero 2, which is not immediately apparent given the limited RAM (512 MB) on board. So we'll start with a benchmark so you can decide if you want to install a 64-bit OS. Then the memory usage is covered, followed by the installation guides of three possible 64-bit candidates.


We conclude with overclocking capabilities for the Raspberry Pi Zero 2.

Deep learning benchmark.

It would be interesting to see how well the Raspberry Pi Zero 2 performs in deep learning tasks.
We have established a benchmark for this purpose. The devices used are listed in the table below.
They all have a Buster operating system, except for the Banana Pi, having a specially modified Armbian operating system.
Missing is the original Raspberry Pi Zero. With its one-core ARMv6 CPU and without NEON, it is no match to the others.
DeviceCPUArchitectureRAM
Clock
Overclocking
Raspberry Pi 4
4x Cortex-A72 CPU
ARMv82 GB15001950
Raspberry Pi 3B+
4x Cortex-A53 CPU
ARMv7-l1 GB1400-
Raspberry Pi
Zero 2 W
4x Cortex-A53 CPU
ARMv7-l
512 MB10001250
Banana Pi
M2 Zero
4x Cortex-A7 CPU
ARMv7-A512 MB1008-
The RPi zero 2 will probably be more or less compatible with the RPi 3B+ as both have the same processor.
The first test was the well-known Jame Bond intro with TensorFlow Lite SSD. The yellow bar indicates overclocking.
TF_Lite_timing


The second test was face detection with the ncnn framework. The ncnn framework makes heavy use of the NEON acceleration. The RPi zero 2 equals the the RPi 3B+. Once overclocked, it's even slightly faster.
ncnn_timing


The final test was the MobileV2 SSD performed only by OpenCV. Again, no surprise here. The RPi zero 2 equals the results of the RPi 3B+.
opencv_timing

As you can see, there is almost no difference between the 32- and 64-bit operating systems. Both performances are identical. Sometimes the 64-bit version is a bit faster (TensorFlow Lite). Sometimes a bit slower, as is the case with ncnn.

There is no real reason to use a 64-bit OS if you look at the benchmark results. Unless you have software only running on a 64 system. Moreover, a 64-bit operating system comes with a price, as you will see.

Memory.

If there's one thing that can be said about the Raspberry Pi Zero 2, it's the lack of sufficient RAM. With the original RPi Zero, with its one core ARMv6, it wasn't so much of a deal. Now, with a powerful CPU fully compatible with the RPi 3B+, insufficient memory is a real showstopper.
We examined some operating systems suitable for the RPi Zero 2 to measure memory requirements. The results are shown in the table below. The most interesting column is the last one. This number represents the amount of free memory available to applications.
$ free -m
totalusedfree
shared
cacheavailable
32-bit Lite
427
432000183334
32-bit Desktop
427
1557810194212
64-bit Lite
414
64
2250121289
64-bit Desktop411248501012299
And here's the problem in its full glory: almost no application will run with just 99 MB of RAM. If you would use the 32-bit desktop version, you'd have twice as much free RAM. These 242 MB RAM is sufficient for daily use, so one or two simple apps, not an intensive search on the net with Chromium.

Lite versions are missing a desktop; it's only a command prompt. Hence a relative large amount of free memory. That's why the Raspberry team advises the 64-bit Lite version over the desktop operating system. However, not everyone is as comfortable with the old fashion blinking cursor as with the GUI.

Let's take a look at the possible solution if you still want to install a 64-bit desktop on your Raspberry Pi Zero 2.
A swap mechanism is unavoidable if you want to ease the memory shortage.
Swapping by compressing files in memory (zram) is not an option because we don't have any RAM.
With merely free memory on the SD card, file-swapping is the only option left. As is well known, intensive writing will eventually wear out the SD, resulting in a decreasing transfer speed. By the way, swapping always results in a performance loss as data has to be stalled temporarily from RAM to other locations for the sole purpose of making memory available. That's the price for the 64-bit desktop.
Overlay.
It is common to protect the SD card from corruption in industrial environments. As explained here, sudden power cuts during writing to the SD card can be disastrous. The overlay mechanism is often used. You read data from the SD card, but writing is re-routed to a mirror file in RAM.
It disables swapping because you now write to the RAM instead of the SD card. The only solution is the 64-bit Lite version. Hopefully, the 289 MB free RAM is enough for your app.

Overlay

Swapping.

Most people know the dphys-swapfile as all Raspberry Pi operating systems use it. It works well. There's only one drawback; it seems to pre-check SD integrity when you see the green LED blink for minutes while booting the Bullseye OS.
To keep wear and startup time at a minimum, we suggest replacing the dphys-swapfile with the traditional Linux swap mechanism. It works just as good as dphys-swapfile, but your startup time is much shorter.

Check your free space on your SD card with $ df -h. You need at least 2 GB of swapping space, not the tiny default 100 MB. If possible, 4 GB or, even better, 6 GB is preferred. Without, of course, taking up the entire card. You can install the original Linux swap mechanism with the following commands once you have your favourite 64-bit desktop installed. Obviously, you can also install the swap if you are using a Lite version.
# stop the dphys swap
$ sudo /etc/init.d/dphys-swapfile stop
# remove the old dphys version
$ sudo apt-get remove --purge dphys-swapfile
# remove the old swap file
$ sudo rm /var/swap
# make a new swap file (4 GB in this case)
$ sudo fallocate -l 4G /var/swapfile
# change permission to root
$ sudo chmod 600 /var/swapfile
# make Linux swap area
$ sudo mkswap /var/swapfile
# start the swap service
$ sudo swapon /var/swapfile
# make the service permantent
$ sudo nano /etc/fstab
# add the following line
/var/swapfile   swap    swap     defaults   0       0
# while we're in fstab, reduce the shared memory to 100 MB
tmpfs     /dev/shm       tmpfs     defaults,size=100M     0      0
# close with <Ctrl>+<X>, <Y>, <Enter>
$ sudo reboot
# you can test the swap with
$ swapon -s
FstabSwap

SwapTest

With the swapping expanded to 4 GByte, we have done some tests to get an impression of the preforance of the Raspberry Pi Zero 2 with its 64-bit OS.
Here are the results.

gcc Timing

Some notable results.
The Raspberry Pi Zero 2 with a 32-bit desktop equals the RPi 3. Considering its 30% lower clock frequency, this is not bad.
When it comes to the 64-bit versions, things get worse. The best was the Ubuntu 20.04. However, this is a Lite version without the desktop. The new 64-bit Bullseye desktop is the second best. You can see the effect of swapping to an SD-card; it took about 68% of the compilation time. The other 64-bit desktops were even worse.
Keep this in mind if you decide to run a 64-bit operating system on your RPi Zero 2.

Bullseye.

On January 22, 2022, the Raspberry Foundation has released the first Bullseye 64-bit operating system suitable for the Raspberry Pi Zero 2. You can read all about it in this article.

One of the most important changes is the new camera driver. Bullseye uses the standard Linux libcamera API and has dropped the previous Userland video engine. It means that any camera software ever written for the 'old' Raspberry Pi Buster OS will most likely stop working! To ease the pain, on December 2nd, the Raspberry Foundation restored some of the 'old' camera features with a legacy version of the Raspberry Pi Buster OS. The release is frozen and unsupported. You can install this plugin by using the raspi-config tool. Find more information here. In due course, most software will undoubtedly be ported to libcamera.

The installation is straight forwards and identical to the Raspberry Pi 4 installation. Download the new Raspberry Imager here, and after you select the correct OS, you can flash your SD card.

👉 Once the Bullseye 64-bit OS is up and running, you have to replace the dphys-swapfile with the original Linux swapping as described previously.

Buster.

To get the 'old' 64-bit Buster operating system working on a Raspberry Pi Zero 2 involves more than flashing an SD-card. Due to a missing device tree blob some tricks are needed to get everything working.

The first step is still downloading correct 64-bit OS and flash it. At the moment, the latest release is the 2021-05-07-raspios-buster-arm64 version. You can find the old Buster.zip file here.

The slideshow below shows the ease of the entire image writing process.

Device tree blob.

After writing your 64-bit image, you have to copy and rename a file in the boot partition. There is no special *.dtb, a device tree blob file, for the RPi Zero 2.
However, the new Raspberry Pi Zero 2 and the Raspberry Pi 3 are almost identical twins. Given this fact, we can luckily use the RPi 3 dtb file for the RPi Zero 2.

  • Remove the SD card from your computer once flashed.
  • Next, insert it again, so Windows or Linux can scan the contents.
  • Copy the bcm2710-rpi-3-b.dtb file in the /boot folder
  • Rename it to bcm2710-rpi-zero-2.dtb.

Zero.dtb

Tip: Use a micro USB hub to connect both your keyboard and mouse to the Raspberry Pi Zero 2. It makes life a lot easier!
USB hub
Insert the SD card into the Raspberry Pi Zero 2 and boot. Once the Wi-Fi connection is established, exit the Updater by selecting the Skip and Done button.
Do not get any new software. Some old packages block the automatic upgrade. Ultimately, if you continue now, your Raspberry Pi Zero 2 will not boot.
Also, do not reboot as the system will hang during startup.

NoUpdateSoftwareZero2

We will now install the required upgrades manually. Follow the steps carefully.
First, open a terminal and update with the new release with the command $ sudo apt-get update --allow-releaseinfo-change.
Then you need to uninstall the VLC player as its components interfere with the new software. VLC can be restored at the end of the procedure.

VLCerrorZero

Once done, delete the other redundant libraries and clean up your system $ sudo apt-get autoremove.
Now it's time for the upgrade $ sudo apt-get upgrade.
Most likely, your local data is lost in the process.

NoLocalInfo

You can fix it using the raspi-config tool, as shown in the slideshow below.
Now is the time to reboot, not before. After the reboot, you may want to restore the VLC player.
All instructions are below the slideshow.
# allow new releases
$ sudo apt-get update --allow-releaseinfo-change
# now you have only four sources
$ sudo apt-get update
# VLC blocks the upgrade, remove it for now
$ sudo apt-get remove --purge vlc
$ sudo apt-get autoremove
$ sudo apt-get clean
# The major upgrade (± 30 min)
$ sudo apt-get upgrade
# restore your locale information
$ sudo raspi-config
# ready
$ sudo reboot
# if you want restore VLC
$ sudo apt-get install vlc
👉 Once the Buster 64-bit OS is up and running, you have to replace the dphys-swapfile with the original Linux swapping as described previously.

Install 64-bit Ubuntu 20.04 server.

In thissection, we discuss the installation of the 64-bit Ubuntu 20.04 server on the Raspberry Pi Zero 2. There is no official release available, so we need to create workarounds.

You will need a Raspberry Pi 3 to get started. Download and flash the official Ubuntu server on a fresh SD card.

UbuntuSDcard

Next, use the Raspberry Pi 3 to complete the initial setup. Do not enable WiFi yet. Just insert the card and follow the steps until you have a working prompt. If you like, you can change the password. (Default - login: ubuntu - password: ubuntu)

Remove the SD card from the RPi 3 and insert it into a Linux machine. You have two partitions. We are interested in the boot partition. In this location, you will find the file bcm2710-rpi-3.dtb. Copy and rename this file to bcm2710-rpi-zero-2.dtb.

UbuntuBoot

Then open the config.txt and add the two extra lines to the file. Make sure you use a Unix editor, not the Windows CR-LF endings.

UbuntuConfigZero

Plug the card into your Raspberry Pi Zero 2. If all goes well, it will boot.

The last action is to set up WiFi. You must edit the 50-cloud-init.yaml file in /etc/netplan with nano.
In the wlan0 section, you can enter your WiFi SSID and password. In the example below, the SSID was FRITZ!Box 7590 VM, the password starts with 96. Use spaces, not tabs, to indent the text. Save and reboot.

UbuntuWiFi

After login, the Ubuntu server tries to connect to the internet. If successful, the upgrade will start in the background. It can take hours to complete! Be patient, even after four hours. Once you can run sudo apt-get update and sudo apt-get upgrade, your system is ready.
Since the Ubuntu server does not have a desktop, the need to extend the swap memory is not so much. Just do what's suits you right

Overclocking the Raspberry Pi Zero 2 W.

The Raspberry Pi Zero 2 has two devices in one housing. You have the BM2710 SoC and literally, on top of this die, you have the LPDDR2 RAM chip.
This very compact design has a drawback. It is not the best thermal solution because the RAM chip will act as an insulation blanket. It will prevent heat to flow from the four CPU cores to the top of the case. That's why this device comes in a plastic package and not in a metal housing like the Raspberry Pi 3. And of course, the plastic housing is also cheaper, a key factor in this design.

Obvious, you need a heat sink. This can be a metal case like the FLIRC, if you don't use the camera. Or a dedicated heatsink for the Raspberry Pi zero like the one below. Be sensible and choose a solution that suits you. Ultimately, we will only achieve about 20% speed gain. Don't spend a fortune on cooling, while it contributes little to nothing to the final result.
FLIRC
Heat RPiZero
Heat isn't the overclocking showstopper, though. It's the hardware itself. Those familiar with the Raspberry Pi 3 B+ will know the DDR2 RAM with its relatively low clock frequency and subsequently the transfer speed. In this design, it is the same. You can overclock up to 1100 MHz without any special precautions. Above 1100 MHz, you also have to overclock the DDR2 RAM.

Overvoltage, including the DDR2, is recommended in this case. See our tutorial on how to overclock the RPi 4 for more information on this topic.
In contrast to the RPi 4, we would recommend overruling the governor overvoltage choice. It is too prudent and let your Rasberry Pi Zero 2 chrash too often.
In the case of RPi Zero 2, the governor still switches between default and over-voltage depending on the clock frequency. It's another point of difference with the RPi 4, which always selects the over-voltage once it's set, regardless of the governor's choice of clock frequency.

If you have a special use for the GPU, such as gaming, you can also overclock it. We were able to reach 700 MHz. Otherwise it will just generate unnecessary heat. The GPU frequency seems to interfere with the VNC connection. After the GPU was overclocked, the VNC connection did not always start.

One last remark: there is a reason why the RPi programmers have chosen these settings. If the ARM core could safely run on above the 1000 MHz under all circumstances, they have sold the Raspberry Pi Zero 2 with this higher clock frequency.

Below is a list of default settings. Most have to do with other hardware. Those related to overclocking are highlighted.

VCgencmd_zero

With too aggressive overclocking, it can happen that your Raspberry Pi Zero 2 will not complete its boot. You see most of the time only a blank screen without a cursor. You can alter your settings without flashing the SD card again. Insert it on a Linux or Windows PC and modify the /boot/config.txt with an editor. Use only Notepad++ in Windows, as it supports the Unix line endings. See also this example.

Open the Nano text editor with the following command and place your lines at the end of the file. Close the session with the <Ctrl+X> key combination. With <Y> and <Enter> changes are being saved. Now reboot and your Raspberry Pi Zero 2 runs at the new speed. Please note, the figures given are only examples. You can adjust them to your own good.
$ sudo nano /boot/config.txt

# Add your lines at the end of the config.txt file.
# this is an example.
arm_freq=1300
gpu_freq=500
sdram_freq=500
over_voltage_sdram=3
# over_voltage is done by the governor.
# set the parameter to overrule its moderate choice.
over_voltage=5

# Ctrl+X, Y, Enter to save the session
# Reboot to run at the new clock frequency
$ sudo reboot

Tip.

noneThe installation of the 64-bit Raspberry Pi operating system on a Raspberry Pi Zero 2 is somewhat cumbersome as you will see in this article. That's why we have placed a SD image our GitHub page.
Download the zip file from our GDrive site, unzip and flash the image on a 16 GB SD-card, and enjoy!
Raspberry 64 OS
Raspberry 32 OS
Raspberry and alt
Raspberry Pi 4
Jetson Nano
images/GithubSmall.png
images/YouTubeSmall.png
images/SDcardSmall.png
Back to content