balena releases first fully functional 64-bit OS for the Raspberry Pi 4

Today, we are excited to announce the release of 64-bit balenaOS for the Raspberry Pi 4, providing support for the full 4GB of memory and allowing the simultaneous, side-by-side running of 32-bit and 64-bit Docker containers - a first for the Raspberry Pi 4!

BalenaOS is an open-source, minimal, Yocto Linux-based host OS tailored for containers. It enables a fast and modern workflow for many different embedded device types, now including the Raspberry Pi 4, in a delicious new 64-bit flavor.

Raspberry Pi 4 × balenaOS

With big improvements in processor speed, data throughput, and graphics handling, the hardware of the latest Pi opens up a new world of possibilities for Pi fans (in more ways than one!). With the release of balenaOS for the Raspberry Pi 4, we’re combining this great new hardware with brand-new software to take full advantage and expand those possibilities even further. We’ve ensured that you can use the full 4GB RAM (where available), that the GPU is supported for hardware video acceleration, and of course that all the features of balenaOS you know and love are present.

BalenaOS provides a development workflow allowing you to push containers to your device, along with everything necessary to reliably support operation of the Docker engine (balenaEngine) in embedded scenarios; that means resilience against harsh networking conditions and unstable power conditions alongside reduced bandwidth requirements. To get you started, we also built a library of over 26,000 base images with a wide variety of distributions and languages, including build and run variants of each.

All of this means that today, you can download the latest balenaOS and immediately get started running a mix of 32-bit and 64-bit containers on one Raspberry Pi 4 device. BalenaOS gives you a platform to start experimenting with Docker containers on the Pi 4 and includes a great local development experience via the balena CLI, with hot reloading of your container code as you work.

Want to see it in action?

We’ve created a sample project to demonstrate that for the first time ever, you can now install 64-bit balenaOS on the Raspberry Pi 4, and run a combination of both 32-bit and 64-bit containers together simultaneously; notably the exclusively 64-bit MongoDB image. Our starter project features a few different technologies and provides a great example of the unique features balenaOS offers for you to expand upon and develop your own projects.

Pushing a project to your Raspberry Pi 4 running balenaOS is as simple as:

 balena push mydevice.local 

For a more detailed walkthrough follow along in our balenaOS getting started guide.

How did we do it?

Attempting to run the Raspberry Pi 4 with a 64-bit kernel presented various challenges because the new device includes significant hardware changes compared to earlier versions. These differences required Yocto Board Support Package (BSP) changes, both in the kernel and bootloader (in our case u-boot), and in various other components.

On the bootloader side, the majority of the work was in figuring out the undocumented memory mapping for the devices. For example, the base address of the devices is different on each system-on-chip (SoC) used on the different Raspberry Pi versions; the bcm2835, bcm2836, bcm2837 and bcm2838, the latter being the one used on the Raspberry Pi 4. Other changes target board configuration, clock definition, and aarch64 memory map, all of which needed hardware-specific information without having access to a datasheet. It was challenging, but with help from the Raspberry Pi Foundation, and the existing dts for 32-bit, we managed to obtain all the missing pieces. Most of this work is available in our u-boot fork, and as of this week, this support was merged in upstream.

On the Linux side, we started with the existing support created by the foundation for the 32-bit kernel. Kickstarting the work of running a 64-bit kernel revealed a series of issues; for example, the system direct-memory-access (DMA) needs to be limited to the first 1GB. This was only completed for 32-bit and required the same change for 64-bit as well.

Another example was the implementation of bouncing buffers for the PCIe driver. This support was 32-bit specific and required porting to 64-bit. To solve these DMA issues (which on the user side translate into RAM limitations) we added another set of changes on the kernel defconfig side for selecting the right support. All these fixes were pushed upstream and are available in the main Raspberry Pi Linux repository.

Along with kernel and u-boot support, various changes were needed in other components as well. For example, the Raspberry Pi 4 has a small difference in the NVRAM configuration for WiFi. Without this change in boardflags3, the WiFi driver didn’t work. On the graphics side, mesa needed a specific configuration to enable hardware acceleration.

Andrei Gherzan of team balena (who is also the maintainer of the Yocto Board Support Package (BSP) layer for the Raspberry Pi boards), has done the bulk of the work on this. After much effort and a series of incremental workarounds, we now have a fully supported 64-bit OS for Raspberry Pi 4 that can use the full 4GB RAM when available. All of the 64-bit support work has been contributed upstream and is now part of the respective projects.

Side note: if you found the technical journey we described above of interest and would like to work on challenging and impactful projects like this one, we are currently looking for more talented people to join the balenaOS team! Please get in touch via our open call.

balenaOS + balenaCloud

As an added bonus, balenaOS for the Pi 4 works great with balenaCloud and openBalena. If you’re scaling up your project and need to manage an entire fleet of devices, these options will help you take care of the management of all your balenaOS devices by allowing you to remotely deploy code, carry out OS updates, debugging, logging and more.

If you decide to give balenaOS for the Pi 4 a try, we’d love to hear how you get on! As always, you can find us in our forums at https://forums.balena.io, on Twitter @balena_io, on Instagram @balena_io or on Facebook.

comments powered by Disqus
Terms of Service | Privacy Statement | Master agreement | Copyright 2019 Balena | All Rights Reserved