Buyers of the 64-bit Raspberry Pi 4 now have a new software toy to play with, thanks to the Xen Project porting its hypervisor to the popular single-board computer.
As The Register reports, the idea to port Xen to Raspberry Pi 4 won the support of George Dunlap, chairman of the Xen Project's Advisory Board, who discovered that 40% of the roughly 600,000 Raspberry Pi devices sold each month since March are to businesses working on IoT projects and industrial applications.
The technical hurdles crossed to bring Xen to Raspberry Pi 4 are detailed in a blogpost on The Linux Foundation Projects' website by Stefano Stabellini, tech lead of US semiconductor outfit Xilinx and creator of Xen on Arm, and Roman Shaposhnik, creator of the Edge Virtualization Engine, or Project EVE.
SEE: Research: Why Industrial IoT deployments are on the rise (TechRepublic Premium)
Addressing quirks of the Raspberry Pi 4 has required the creation of several Xen patches and even patches coming in the soon-to-be-released Linux kernel version 5.9.
The most significant of these issues is that the Raspberry Pi 4, rather uniquely, has different physical addresses from DMA addresses, which required an address translation solution.
DMA addresses are used to program devices and could be different from physical addresses but aren't different on most 64-bit Arm, Arm and x86 devices. That caused a problem for the Xen subsystem in Linux.
"In practice, none of the x86, Arm, and Arm64 platforms where Xen could run had DMA addresses different from physical addresses. The Xen subsystem in Linux is exploiting the DMA/physical address duality for its own address translations. It uses it to convert physical addresses, as seen by the guest, to physical addresses, as seen by Xen," the pair of software engineers explain.
"To our surprise and astonishment, the Raspberry Pi 4 was the very first platform to have physical addresses different from DMA addresses, causing the Xen subsystem in Linux to break. It wasn't easy to narrow down the issue. Once we understood the problem, a dozen patches later, we had full support for handling DMA/physical address conversions in Linux."
The Linux patches are in master and will be available in Linux 5.9, the pair write.
"With the Xen and Linux patches applied, Xen and Dom0 work flawlessly. Once Linux 5.9 is out, we will have Xen working on RPi4 out of the box."
The other oddity they discovered was that the Raspberry Pi 4 only allows for memory allocations below 1GB.
"This lower-than-1GB limitation is uncommon, but now that it is fixed, it is just going to work," the pair write. A patch that fixes it is now present in Xen 4.14.
SEE: Programming languages: Developers reveal what they love and loathe, and what pays best
The pair have prepared a tutorial explaining how to set up and configure a TFTP server to get Xen up and running. Users also need to download the appropriate UBoot binary for RPi4. Links to the tutorial are contained within the blogpost linked to above.
For developers interested in building rugged computers or devices used in the field, the pair also recommend using the Project EVE operating system, which supports running edge containers on computers and devices deployed in the field, such as IoT gateways, industrial PCs, or general-purpose ruggedized computers.