futurice/rusty-build-light

Name: rusty-build-light

Owner: Futurice

Description: Light up your build status

Created: 2018-01-12 15:35:29.0

Updated: 2018-04-12 09:23:13.0

Pushed: 2018-04-12 09:23:12.0

Homepage: null

Size: 12849

Language: Rust

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Rusty Build Light

It's a build light for Raspberry Pi. In Rust! Designed for the Finavia projecte, and set up to talk to its Jenkins, Team City and Unity Cloud CI pipelines.

Requirements

If you don't have them already, you'll need OpenSSL development headers. On Ubuntu and its derivatives, they can be acquired by: sudo apt-get install libssl-dev. You'll also need pkg-config: sudo apt-get install pkg-config.

When compiling locally, you should enable the WiringPi crate's feature flag, which stubs out calls to the GPIO pins, and replaces them with print-to-console.

Then, it should just be

rgo build --features wiringpi/development

If you have set up you environment for cross-compilation (see below), it would be:

rgo build --target=arm-unknown-linux-gnueabihf
Building for ARM
Cross-compilation from x86 to ARM

The easiest path is to use Docker.

With Docker

Build the docker image from the Dockerfile

 docker
cker build . --tag "rust-arm-openssl"
cker run --rm --name "rust-arm-openssl" -v /absolute/path/to/source/folder:/source rust-arm-openssl

Now, run the created container:

cker start -a rust-arm-openssl
Without Docker

Yikes. You sure?

Okay.

First off, don't even try this on Windows. It's not worth the pain. WSL aka Bash On Windows works fine though.

Step one is acquire a version of OpenSSL comaptible with v0.9.23 (or whatever we have in Cargo.lock) of the openssl crate. As of this writing, that's 1.1.0g.


Step two is to compile OpenSSL for an ARM architecture. You'll need to get some things for that. The package names that follow are for Ubuntu. Substitue as necessary for your distro:


Step three Set up the OpenSSL build environment. Untar/unzip the sources you got back in step one somewhere. Let's say into ~/src/openssl-src, for convenience sake. Make another folder for the output. Something like ~/src/arm-openssl-output. Yeah, that sounds good.


Step four Let's get cracking.

d ~/src/openssl-src
/Configure linux-generic32 shared --prefix=/home/<your-username>/src/arm-openssl-output --openssldir=~/src/arm-openssl-output/openssl --cross-compile-prefix=/user/bin/arm-linux-gnueabihf-      

Explanation:


Step five Install rust via rustup:

url https://sh.rustup.rs -sSf | sh

…and add the arm-unknown-linux-gnueabihf target:

ustup target add arm-unknown-linux-gnueabihf

Step six Configure cargo

This repository includes it by default, but I'm noting it here for posterity:

Three things are required: an OpenVPN profile with access to the CI servers, auto-reconnect to Wi-Fi on boot, and Pi needs to be set up to autostart the program on boot.

OpenVPN
Wi-Fi

Done!

Autostarting the Program on Pi Boot

If we're using Raspbian “Jessie” or later, we can use systemd. If you're using something earlier…Google it, I dunno.

To create a new systemd service, create a file named build-light.service in /lib/systemd/system. Its contents will need to look something like the following:

t]
ription=The Finavia Project build light.

vice]
Start=/bin/bash -c /absolute/path/to/the/rusty/build/light/executable
ingDirectory=/absolute/path/to/directory/containing/rusty/build/light/and/its/config/files
art=always
artSec=3

tall]
edBy=multi-user.target

Then, register and start the service:

do systemctl enable build-light.service
do systemctl start build-light.service

The build light can now be entirely controlled by systemctl, and its system-level logs can be viewed with journalctl -u build-light.service.

Running and Configuring the Build Light

The application can be configured through the use of two configuration files:

Both of these files are necessary, and must be in the same directory as the rusty_build_light executable. They are copied from /config to the output directory as part of the build process (see build.rs).

The repository includes an example config.toml which is mostly blank, and commented to assist with usage.

Once the files are in place, running the application is as simple as:

rusty_build_light
Circuit diagram

TBD. Text for now:

The build light assumes 3 RGB LEDs, one with each color LED being driven by a Raspberry Pi GPIO pin. The pins used are configurable in config.toml and given in RGB order.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.