Running BalenaOS on Blue Chip Technology SBCs 

19th June 2024 by David Thomson

Author: Chris Richardson – Embedded Software Engineer at Blue Chip Technology

1. Introduction 

BalenaOS is a custom Linux distribution built using Yocto, which helps minimise its size. It provides IoT estate management through an easy to configure and use cloud interface.  Our TM3 and DB1 boards currently support BalenaOS.  

It uses dual rootfs partitions so that if an upgrade fails it is possible for Balena to switch to the alternate partition. OTA’s are handled via incremental updates to minimise data consumption.  

BalenaOS makes extensive use of docker containers for user applications which rely on the BalenaOS userspace for cloud connectivity. 

Balena makes use of a customised version of docker, referred to as balenaEngine, which claims to have a 3.5x smaller footprint than Docker CE (see https://engine-docs.balena.io/). 

Some of the benefits of BalenaOS include enhanced security as “processes that run inside these containers are not allowed to communicate or share resources with any other namespace, including processes run on the host OS or other containers” (see https://docs.balena.io/learn/more/masterclasses/docker-masterclass/ for further information). 

The images for our single board computers can be downloaded from the Balena Cloud website – https://dashboard.balena-cloud.com, these can be written to an SD card.  Once booted they write the BalenaOS to the SBC’s internal eMMC.  This website also enables your fleet of SBCs to be managed, for example you can see which computers are live and accessible and read telemetry information form the OS and containers. 

2. Cloud functionality 

Using the BalenaOS cloud website first create a new fleet.  Then click the ‘Add device’ button.  Use the ‘development’ option, so that it will be possible to SSH easily to the SBC, without needing to worry about using a password/key.  Download the BalenaOS image and write to an SD card, using either BalenaEtcher or the Linux command ‘dd’. 

 

unzip balena-cloud-bcttm3-bluechiptechnology-tm3-5.3.10-v16.3.8.img.zip 

sudo dd if= balena-cloud-bcttm3-bluechiptechnology-tm3-5.3.10-v16.3.8.img bs=4M of=/dev/<SD card device> 

sync 

The SD card should be inserted into the TM3 and upon powerup it will begin flashing BalenaOS to the TM3’s internal eMMC.   After this process has finished, remove the power lead and SD card, then re-insert the power lead. 

Once a TM3 running Balena OS connects to the cloud, you should see several graph bars depicting various metrics, for example the amount of memory the device has free and the amount of CPU utilisation. 

It is also possible to connect to an SSH terminal via the web interface and to inspect which docker containers are currently running on a TM3. 

 

3. Pushing a docker container example to a TM3 

In this example we push a simple docker container example to a TM3 running a development version of BalenaOS. 

It is first necessary to download the Balena command line client, which can be obtained from – https://github.com/balena-io/balena-cli/releases. 

Then clone the example using git – 

git clone https://github.com/balenalabs/multicontainer-getting-started.git 

The example containers serve to obtain the memory and CPU usage of the single board computer.  They transmit this information over WebSockets to the user’s web browser where the information is then graphed. 

cd multicontainer-getting-started 

The following will open a web browser, where you can login to the Balena cloud service and authorise this login attempt – 

~/balena-cli/balena login    

~/balena-cli/balena push <Fleet name> 

 

You should then be able to connect to the webserver and application it runs by using a web browser to connect to the IP address of the SBC.  You will see graphs of the CPU and memory usage. 

 

 

It is possible to connect to the TM3 via SSH, running the following command. 

~/balena-cli/balena ssh <IP address> 

Once you’ve pushed a docker container, it is possible to get a list of containers and their ID by using the previous command to ssh to the host, then using: 

balena ps 

The following command can then be used to ssh to one of the containers chosen from the previous command: 

ssh -t -p 22222 root@<IP address> “balena-engine exec -it <Docker container ID> /bin/sh”

4. Conclusion 

In conclusion we’ve demonstrated bringing up a TM3 single board computer with BalenaOS and pushing a docker container to it.   

About Blue Chip Technology

At Blue Chip Technology (BCT) we specialise in design and manufacture of embedded electronics systems, Hardware, Firmware and Applications.  Our typical customer will usually have a proof of concept and will work with Blue Chip to engineer what is often a complex collection of circuit boards into a commercialised solution. 

The Beta HMI platform offers an opportunity to develop those prototypes with a validated, field proven integrated SBC, LCD and touch platform, saving several design and development iterations. BCT’s in house manufacturing and commitment to full life cycle support offers a unique proposition to dramatically reduce time to market, approvals and start-up costs.

www.bluechiptechnology.com                                                  sales@bluechiptechnology.com


ISO 9001 Quality Management certified by BSI under certificate number FM 33069