MirageOS support for Raspberry Pi 4 GPIO

Hi,

I am trying to execute a Virtual Machine running MirageOS on top of a RPi 4 and access its GPIO to read/write.

Does MirageOS supports access to the RPi GPIO? How can that be achieved?

Thanks

1 Like

Hi,

MirageOS has several targets and, depending on the target, can run into several environments. For instance, at Robur, we essentially wants to provide unikernels for Linux KVM/OpenBSD VMM/FreeBSD BHyve via the Solo5/hvt target. In that case, MirageOS provides an operating system which can be virtualised via the Solo5 tender (a program which launches the unikernel and do the link between the unikernel and the host OS). Solo5 allows 5 hypercalls (it’s in the name) to allow interactions between the unikernel and the host OS (read, write on net/block devices & exit).

So, for the Solo5 target, it is not possible, by design1, to communicate with GPIO (this would require other hypercalls).

Having said that, however, there is a way to create an entire operating system in OCaml that would run on RBPi and currently communicate via GPIO. However, I should point out that the project is experimental and that there is a terrible lack of drivers.

Gilbraltar has been developed (in reference to the strait allowing Europeans to reach the MirageOS retreat), and is a modified OCaml compiler enabling an OCaml program to be compiled into an operating system capable of running on an RBPi 4B+. @Engil & @pitag have already experimented with the support thanks to the help of @Lortex and myself. You can read a report here and here.

However, even if it is possible to use GPIO and refer to the firmware documentation to go further, the OS is cruelly lacking in drivers: no ethernet, USB or even file system.

So there is currently no MirageOS support for RBPi (but it could be). The problem lies in developing drivers to enable Gilbraltar to use the devices at its disposal. So it’s not necessarily fun work (nobody wants to develop drivers) and I don’t have the time to do it. However, I am available for any help in compiling and deploying Gilbraltar :slightly_smiling_face: !


1: If I specify “by design”, it’s because there’s always a way around the limitations that MirageOS can impose :wink: .

6 Likes

I really appreciate you taking your time to reply with such a rich answer.
I will look into the links you shared and meditate about it :slight_smile:

Thanks

I also had a look at the driver issue for both Gilbraltar and rpi-boot-ocaml a while back. Xvisor (GitHub - xvisor/xvisor: Xvisor: eXtensible Versatile hypervISOR) is interesting insofar as it has split the booting/init (intel, some arm platforms and risc-v), linux drivers and the control, essentially an interface for dealing with virtual image deployment. One possible way forward would be to sit Gibraltar on top of xvisor - or, in fact, sitting any ocaml scheduler + mirageOS on top of xvisor.

Another set of interesting articles was written by Stefan Kowkalski who was faced with the same dilemma of supporting drivers for genode (Linux device driver ports - Breaking new ground).

1 Like