Building the rpi-dispmanx platform

For various reasons we don’t have autobuilds of the rpi-dispmanx platform published. We want to test this each release, though, so here’s some documentation on how to build it:

Native Compile

If you happen to have an armhf system to build on, you can simply install the normal build-dependencies via apt build-dep mir, install the rpi-userland snap via snap install --edge rpi-userland for the RPi-specific stuff, and then build Mir with

PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:/snap/rpi-userland/current/ cmake .. -DMIR_PLATFORM=rpi-dispmanx

(adding any other options you may wish).

The PKG_CONFIG_PATH needs both the default /usr/lib/arm-linux-gnueabihf/pkgconfig/ path and the rpi-userland path as we need to pull libraries from the default path whenever possible, only using the rpi-userland libs where they don’t exist (particularly, for bcm_host).

Cross Compilation

If you don’t have an armhf builder handy, or your armhf builder happens to be a Raspberry Pi with limited CPU and terrible IO performance to the crappy SDCard you’re running from then you might want to cross-compile Mir on a more beefy machine.

This is possible, but requires a bit of setup.

To make things simpler, we’ll do this in an LXD container:

> lxc launch ubuntu:20.04 rpi-builder

Now, let’s get a Mir source tree in there

> lxc config device add rpi-builder mir-source disk source=$PATH_TO_MIR path=/home/ubuntu/mir

Now, sadly, Mir doesn’t quite build with a read-only source tree, so, for convenience, we’re just going to make it world-writable so the user in the LXD container can write to it.

> chmod -R a+w $PATH_TO_MIR

And now we can start poking around in the LXD environment.

First, we install the cross-builder toolchain and some debian packaging tools

> lxc shell rpi-builder
> su ubuntu
> sudo apt install sudo apt install g{cc,++}-arm-linux-gnueabihf devscripts equivs

(cue tons of console output)
Now add the armhf architecture:

> sudo dpkg --add-architecture armhf

And replace /etc/apt/sources.list with

deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-proposed main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal-proposed main restricted universe multiverse
deb [arch=amd64] http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse

And now we’ve got all the pieces ready to build.

Finally, before grabbing the build dependencies, we need to edit debian/control to replace eglexternalplatform-dev with eglexternalplatform-dev:all. Otherwise, apt gets confused about dependencies.

Now we can pull in our build-deps and actually build!

> mk-build-deps --install --arch=armhf $PATH_TO_MIR/debian/control
> mkdir build
> cd build
> CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:/snap/rpi-userland/current/opt/vc/lib/pkgconfig/ cmake .. -DMIR_PLATFORM=rpi-dispmanx -DCMAKE_BUILD_TYPE=Debug -DMIR_ENABLE_WLCS_TESTS=OFF

And you’ve now got an armhf build of Mir, with the rpi-dispmanx platform, in your build tree.

2 Likes