Ubuntu 22.04 LTS Support

Ubuntu Logo

We’re pleased to announce support of Ubuntu 22.04 LTS OS, as we continue to look for ways that we can help you integrate the Red Reactor into your projects.

The 22.04 LTS release now supports the 2GB RAM Raspberry Pi 4, and we successfully tested the Red Reactor setup and software on the 64-bit Desktop installation. Ubuntu provides configurations optimised for Raspberry Pi to give you a full desktop and server experience, including long term support for more mission critical use cases. It has a fantastic UI with many similarities to MAC and Windows systems, whilst giving easy access to the latest Linux features, as well as a server version focused on heavy duty processing.

In fact, a big advantage of being able to mount the Red Reactor underneath your Raspberry Pi is that you can take full advantage of any cooling systems you want to place on top, from simple heat sinks to easy to install fans and perhaps more to enable overclocking. A simple fan is amazingly effective at keeping CPU temperature down to avoid temperature throttling, even our simple DIY setup was pretty good at keeping the CPU running at 100%!

Of course, it also means your batteries are not directly exposed to the CPU/GPU heat and can therefore operate more efficiently, and it will give you a much longer battery life!

Ubuntu Server with Red Reactor and DIY Fan!
Our simple DIY setup for the Ubuntu Server!

Installing on Ubuntu 22.04

There are a few additional instructions to follow in order to configure the OS for the Red Reactor. The Ubuntu OS has some differences to the Raspberry Pi OS (Buster, Bullseye etc), but it is easy to get everything set up.

Enabling I2C and GPIO Access

We found that by default, the I2C interface is already enabled on a fresh Ubuntu 22.04 LTS 64-bit Desktop installation. But the default access permissions do not allow user account access, and although there are a number of internet examples that create a new I2C user group to which your user account can be added, and then assigned as owner of the I2C interface, we found that using a udev rule to enforce this on re-booting did not persist.

Hence, you may find that these example instructions, at luxruee, work for you but it turned out to be very easy instead to add your user account to the existing ‘DIALOUT‘ group already assigned to the I2C and GPIO interfaces, so we would recommend to use the following commands:

ls -l /dev/i2c-1                 This will show you the groups assigned to this interface, and should include 'dialout')
sudo adduser $(whoami) dialout   This will add your user account to the dialout group
getent group dialout             This should show your user account name as a member of dialout group, e.g. dialout:x:20:pascal

To test access to the I2C interface, you’ll need to install the I2C-tools as follows:

sudo apt install i2c-tools       This will download the tools incl. i2cdetect
i2cdetect -y 1                   This will show you the Red Reactor attached to the I2C bus at address 0x40

The dialout group also gives you access to the GPIO interface (use ls -l /dev/gpiomem to see the dialout group listed), used for monitoring the status of the ON button interface of the Red Reactor. Please follow our existing GitHub instructions on installing and running the Red Reactor software.

Configuring Power ON and OFF functions

Unlike the Raspberry Pi OS, which stores its config.txt file in the /boot directory, Ubuntu uses the /boot/firmware directory. However, although Ubuntu 20.04 advises to add user configurations to the usercfg.txt file, read by an include statement in config.txt, this is no longer the case for the 22.04 LTS 64-bit desktop release, and you can simply follow the instructions for adding the gpio-poweroff overlay in our instruction manual, using the /boot/firmware folder instead.

You’ll need this to configure the TXD signal controlling the Red Reactor (timeout now should read 8000ms as below):

echo dtoverlay=gpio-poweroff,gpiopin=14,active_low=1,timeout_ms=8000 | sudo tee -a /boot/firmware/config.txt > /dev/null

You can optionally enable the OS to use the same button interface to trigger a safe shutdown as follows:

echo dtoverlay=gpio-shutdown,gpio_pin=13,debounce=3000 | sudo tee -a /boot/firmware/config.txt > /dev/null

Enable SUDO privileges for Red Reactor Applications

Nearly there! Because it is critical that your Pi will execute a safe shutdown when the battery is at its minimum set voltage, the Red Reactor applications will use the OS shutdown command but this requires root privileges, achieved by using the sudo command. (The Red Reactor applications also use the sudo reboot command.)

On Ubuntu, the default is for sudo to require an explicit password entry which would not be practical in this situation. You could make all sudo commands ‘password-less‘ (as per the default on Pi OS, and if you have already done so here you can ignore this section), but it is recommended to explicitly enable password-less operation only for the functions needed here.

To do so, please follow these instructions. Please note that username should be changed to your actual user account name!

First, type:

sudo visudo

(and enter your password!) This will open a special editor session for the sudoers file. Scroll down until you see the line:

%sudo ALL=(ALL:ALL) ALL

Then directly below that line, insert the following entry (changing username):

username ALL=(ALL) NOPASSWD: /usr/sbin/shutdown, /usr/sbin/reboot

then press CTRL + X and then ‘Y‘ to save the changes. (It would also be possible to use the full paths to the actual Python applications instead, if you prefer not to make these 2 commands themselves password-less).

One final step if you’re using our RR_WebMonitor or RR_MQTT Applications, which also use the vcgencmd to get additional status information, is to add your user account to the video group to enable the correct access rights (again, change username !):

sudo usermod -aG video username

You can test this last step by simply typing the following to see the temperature output

vcgencmd measure_temp

Now you’re good to go!

Yeah! With this setup you are able to run our Red Reactor applications such as RR_WebMonitor for remote web access through your browser, RR_BatMonitor for remote updates by email, and RR_MQTT for all your home automation projects! However, Ubuntu does not support task bar status icons as implemented in our pi-battery-widget for the Raspberry Pi OS, but we will update you as soon as we can.

It is exciting to be able to support Ubuntu users, especially in enterprise applications where the Red Reactor battery power supply solution is a must have!

One thought on “Ubuntu support

  1. Pascal says:

    Do let us know if you come across any differences with your setup. We’ll be happy to add this and we’ll update our manual as well!

Leave a Reply

Your email address will not be published. Required fields are marked *

thirteen − 6 =