incomplete.io

Odroid XU-4 Preferences

In the previous section, we made sure that the relevant hardware is correctly configured. We also have another Odroid XU-4 Cloudshell playbook fragment that covers tasks around our preferences for running systems. The hardware works just fine without these, but these tweaks suit our needs and illustrate some more orchestration and hardware control.

Simply add another include statement to include a new file called odroid-xu4-preferences.yml and give it the following content:

    - name: Configure Odroid Cloudshell Blinkenlights controls
      template:
          src: ./templates/xu4-cloudshell/blinkenlights.service
          dest: /etc/systemd/system/blinkenlights.service
          owner: root
          group: root
          mode: 0644

    - name: Configure Odroid Cloudshell LCD blanking
      template:
          src: ./templates/xu4-cloudshell/lcdbacklight.service
          dest: /etc/systemd/system/lcdbacklight.service
          owner: root
          group: root
          mode: 0644

    # Ansible 2.2+ has a systemd module, we're using 2.1....
    - name: Reload systemd
      command: /bin/systemctl daemon-reload

    - name: Enable blinkenlights service
      command: /bin/systemctl enable blinkenlights

    - name: Enable LCD backlight service
      command: /bin/systemctl enable lcdbacklight

Some of these apply to our other XU-4 systems too (blinkenlights for example), so at some point, we'll be looking to abstract these out, but in the meantime, they're fine here.

Each of these tasks simply copies a systemd service definition to the XU-4s and enables it. The service files themselves are also very trivial and follow the same pattern -- write some magic values to some /sys files to control hardware behaviour. Here's what they do specifically:

  1. The standard heartbeat sequence for the blue LED isn't something we especially care for. Instead, we've set it to flash when there's I/O to /dev/mmcblk1. This lets us know when the eMMC device is being utilised. It generally only flashes when we're doing updates to the distribution, which can be a useful indicator.
  2. We don't use the LCD displays very often (we'll cover that content later), so we start out by blanking the LCD once the system has booted.

These services could probably be better defined and we'll probably end up writing an odroid-control tool at some point that given the right arguments will allow simple control of these kinds of things and be a little more systemd friendly. What we have at the moment is fine though.

Note: The systemd Ansible module requires Ansible 2.2, which is not part of the Ubuntu 16.10 distribution we're controlling this from, so we've had to manually drop files in and call systemctl.

Each of these Ansible playbook tasks works in the same way, so we'll walk through the first one and then just provide the templates for the others.

/etc/systemd/system/blinkenlights.service

The same goes for the blinkenlights service. A systemd service definition and then enable the service.

[Unit]
Description=MMC Blinkenlights

[Service]
Type=oneshot
# Note the typo in the word 'heartbeat' below to match the typo in the kernel
# sysfs registration code.
ExecStart=/bin/sh -c "echo mmc1 > /sys/devices/leds.15/leds/blue:heartbeart/trigger"
ExecStop=/bin/sh -c "echo none > /sys/devices/leds.15/leds/blue:heartbeart/trigger"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

/etc/systemd/system/lcdbacklight.service

Finally the systemd service definition to switch off the LCD backlight.

[Unit]
Description=LCD Blackout

[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo 1 > /sys/class/backlight/fb_ili9340/bl_power"
ExecStop=/bin/bash -c "echo 0 > /sys/class/backlight/fb_ili9340/bl_power"
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Go Back

Twitter: @IncompleteIO