Wayland for Kids

Educational Computing

What do you get if you combine Wayland, in-car minimonitor and Raspberry Pi? In my case, a perfect setup for our daughter who just loves computers.

Background

Our daughter has been infatuated with computers since before she could crawl. A physical keyboard which produces immediate effects on the screen is a particular favourite. Since it's impossible to draw the little lady away from computers, we might as well let her have one of her own.

The idea for this project was to build a simple computer we could let our daughter to play with, and which would automatically boot to a kiosk-like state. There were only a few requirements:

  • Cheap
  • Low power consumption
  • Movable around the house as needed
  • Easy to hack

The computer part was easy: Raspberry Pi fits all the specifications. If it breaks, replacement cost won't even exceed that of a few beers. I still wanted the setup to be simple, so any monitor I chose would have to have HDMI input and relatively small physical size. I found the answer in a rather unexpected place - small in-car monitors. They fit the physical specifications - and they come with HDMI inputs by default. In comparison, cheapest desktop monitors are heavier, way bigger, and tend to omit HDMI. (At least for the hardware available where I live.)

One thing still missing is the enclosure for RPi. It's a work-in-progress, made of a leftover piece of 3mm thick acrylic plate which cost next to nothing. The piece is also big enough to provide material for a dozen setups.

Construction

The setup looks and behaves like this:

? (Click image for video)

As a base, I used a thick(ish) piece of plywood.

The monitor's power adapter is literally strapped down with large zip ties. The keyboard and cables are set in their place with smaller ones and matching stick-on hooks.

For powering the RPi, I simply used a quality 1.2A/5V µUSB charger.

When the system starts, it boots directly into a native Wayland session. Instructions for building Wayland+Weston (reference compositor) can be read here, and followed with a just couple of tiny modifications.

  1. install autoconf, libpam0g-dev (+ vim-nox) in addition to other packages
  2. add --disable-documentation to wayland build configuration
  3. if necessary, rebuild cairo with --enable-glesv2
  4. build weston with --enable-weston-launch
  5. after weston install, change mode on weston-launch:

    -rwsr-xr-x 1 root root 37289 Jan 15 16:41 bin/weston-launch

Session startup scripts

For the automatic session launch, I use a few simple scripts.

** Wayland Environment: **

pi@raspberrypi ~ $ cat wayland-env-setup.sh #!/bin/sh export WLD="$HOME/local" export PATH="$WLD/bin:$PATH" export LD_LIBRARY_PATH="$WLD/lib:/opt/vc/lib" export PKG_CONFIG_PATH="$WLD/lib/pkgconfig:$WLD/share/pkgconfig" export ACLOCAL="aclocal -I $WLD/share/aclocal" export XDG_RUNTIME_DIR="/run/shm/wayland" export XDG_CONFIG_HOME="$WLD/etc" if [ ! -d $WLD/share/aclocal ]; then mkdir -p $WLD/share/aclocal fi if [ ! -d $XDG_RUNTIME_DIR ]; then mkdir -p $XDG_RUNTIME_DIR fi chmod 700 $XDG_RUNTIME_DIR chown pi.pi $XDG_RUNTIME_DIR

** Weston Compositor Launch **

pi@raspberrypi ~ $ cat W #!/bin/bash source ${HOME}/wayland-env-setup.sh exec weston-launch -- --max-planes=0 --idle-time=99999

** Terminal Launch **

pi@raspberrypi ~ $ cat T #!/bin/bash source ${HOME}/wayland-env-setup.sh exec weston-terminal

** Modified /etc/rc.local **

pi@raspberrypi ~ $ cat /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi # Launch Weston as 'pi' if [ -e /home/pi/W ]; then su -l -c '/home/pi/W &' pi fi # Launch terminal inside weston session # but wait until the compositor is ready if [ -e /home/pi/T ]; then printf "Waiting for Weston session..\n" while true; do sleep 1 if [ -e /run/shm/wayland/wayland-0 ]; then break fi done printf "Socket found, compositor ready!\n" su -l -c '/home/pi/T &' pi fi exit 0

Known problems/oddities

The monitor supposedly has a native resolution of 800x480, but the EDID data does not expose this setting. Trying to force this resolution in /boot/config.txt results in black screen and no video output at all. The automatically chosen nearest-match resolution is larger than what the monitor supports, and so the desktop does not fit on screen.

The monitor has to be on when the RPi is booted. Apparently RPi only tries a HDMI handshake at boot time. (Fixed by hdmi_force_hotplug=1 in config.txt)

Disclosure

Some of the fascination for Wayland and car monitors comes from my place of work, Nomovok. Our dealings with bleeding-edge stuff and embedded systems have had an effect on me.