Running OGN Receiver in Balena.io Node?

Manual maintenance could be a lot of hassle especially when one keeps multiple OGN receivers running. You need to update one thing on the first location. Then you decide to do something similar on the second while the third one wants to be kept up to date too. You really don’t want tame differently configured receivers anyway. Later on, when everything is nicely set up and in sync a friend wants to receive a local weather station or something completely else..

Just a few days ago I hit in my podcast listening queue to a CZPodcast‘s (Czech only) an episode about something called balena.io. As I am skipping the tracks in the queue randomly and I’ve already noticed this balena-thingy to be mentioned a couple of times, it became obvious I have to give it a try. Not only by listening that particular episode but also by installing it on my (surprisingly supported) Raspberry Pi of the very first generation!

It all starts with creating an account (eh, another password to remember) on balena.io website. I was pleased those guys support so many devices, even my Pi 1. To install the “balena os” you need to pre-configure an image that you then just download and flash on the SD card. An old two-gig card was just fine and I was running a Balena node in (almost) few steps (well, this tutorial looks lengthy but is is not that bad, really).

Now: what about the app? Before installing the OGN receiver binaries I’ve decided to run a simple script that would send just some messages across the net just to have a starting point for a more complicated setup. The experimental script was really simple:

#!/bin/bash
id=`hostname`

mqHost=$MQ_HOST
mqPort=$MQ_PORT
mqUser=$MQ_USER
mqPassword=$MQ_PASSWORD

i=0
while true
do
    ((i++))
    msg="ahoj '$i' from '$id'"
    echo "Sending msg"
    echo "  $msg"
    mosquitto_pub -h $mqHost -p $mqPort -u $mqUser -P $mqPassword -t testing/pi1 -m "$msg"
    sleep 4
done

Creating a Dockerfile based on the example was a bit trickier. The documentation describes there can be multiple dockerfiles and the order in which they are processed. There is also something called Dockerfile.template which ought to help you with multi-architecture setups and some other matters. And here was the spot I hit a wall. The example Dockerfile.template did not work due to the first line “FROM balenalib/%%BALENA_MACHINE_NAME%%-node:10-stretch-run” – on git push the hook on the server complained something about uppercase letters in this line. Googling it was helpful only to that extent that there shall be another – dockerfile.template (with lowercase D!). Solved by creating a symlink. However, the git hook complained the ‘Dockerfile’ is missing (had to make a copy of Dockerfile.template; yet another symlink didn’ help). And the initial image had to be changed. The resulting Dockerfile/Dockerfile.template/dockerfile.template is then as follows:

#FROM balenalib/%%BALENA_MACHINE_NAME%%-node:10-stretch-run
FROM balenalib/rpi-debian:stretch-run

RUN apt-get update
RUN apt-get install mosquitto-clients -y

RUN mkdir -p /opt/app
WORKDIR /opt/app

COPY testScript.sh .

ENTRYPOINT ["/opt/app/testScript.sh"]

Concequently, by calling git commit & git push the image gets build on the balena cloud server and after seeing blue unicorn you know it got through successfully. In the project dashboard you can observe the docker-image update progress on all your devices (you can have as many as the free quota (10) or your wallet allows).

So far so good. A neat great on the device detail page is you can seamlessly connect straight to the shell and also into a running docker image (or images if there are more of them). But wait – what is that device load? 18? I understand it is only Pi 1 but..!? The ACT LED on the board indicates there is no disk IO (which is a good sign – the card is old, slow and I don’t want it to die by wear too early). It could be caused by the docker image update process. The Pi is connected to the Balena cloud servers through a VPN and the update itself could be a bit demanding. Lets wait for some time for things to settle down..

After an hour the load was still around 12. I guess the 256MB of RAM is just too little. The Compute Module 1 has double of that and it may do the difference. This is a dead end for my Pi 1 in combination with Balena. Our most powerful receiver runs on quad-core Pi 3 is currently down and I will have to climb the hangar roof anyway – will try that ONE very soon!

OGN Cube Control Is Out!

It did not take that long to push the application to the Android Play store (thank you, Petr!) and hence I can proudly announce the OGN Cube Control app is now available for download!

Presently you need to be online to fetch the firmwares while they are not stored anywhere in the phone. Though, offline storage for people without a data plan (like me) is considerably high on the todo list.

OGN Cube Control

The dry February in conjunction with forthcoming season kicked me out of winter dormancy and resulted into unexpected programming hyperactivity. The idea, or rather necessity of an application which could update firmware in the Cubes outside my lair wirelessly and seamlessly was forcing its way for quite long time.

I had already started with its development the previous spring based on my somewhat limited experience gained from programming the Outlanded and VFR Manual apps some years ago. However, this has been disrupted after several weeks due to hitting a dead end. Some communication problems with bluetooth devices originating from my probably deep misunderstanding of the Java-based Android API made me to suspend the app development indefinitely . Approximately six months later I circumstantially participated on Brmo conference where some weirdly-looking and talking chap was demonstrating cross-platform mobile development based on Flutter and Dart. It looked kinda neat, straightforward, simply made a very positive impression on me. All right, I really loved it! But another four months have passed till the day when I finally convinced myself into FINALLY MAKING IT! And that day has happened to be circa 96 hours ago..

I have spent 14 straight hours on Saturday, 12 on Sunday (I seriously needed to eat something), 4 hours on Monday night and 4 more today morning and now can boldly announce that it WORKS like a charm! πŸ™‚

It still needs some polishing but we already plan to publish it it into the Play store very soon so you guys and gals can upgrade your lovely little trackers to the most recent firmware there is! πŸ™‚ The other features like logbook or flights overview will come out a bit later.

Big Trouble with LittleFs

Full track recording is one of the nice-to-have functionalities of the CUBEs. The problem here, however, is that the SD card which is used to keep the data gets easily damaged as data flushes to the FAT filesystem cause considerably high wear, especially in the file allocation table (file size & last modification time). The latter could be avoided by disabling the last file updates time in code. Still, the file size and number of sectors allocated is updated every time a block is added to the file. Keeping the data in memory and flushing in larger chunks may seem to be obvious solution, but when taking the MCU’s RAM size of 20kB (while a lot is already allocated) and FAT sector size of 512B into consideration, one can see there is not much maneuvering space.

Hence, the LittleFS seemed to be the perfect solution. Power resilience and wear leveling make it an exact fit for this troubles until you realize its code base is over 4000 lines and make it considerably spacious after compilation – 8KB, even when forcing size optimisation and omitting unused routines in the compiler settings.

In combination with the pending problem of the rest of my code being already a tight fit into the F103CB’s 128kB FLASH (there is also a custom 8kB bluetooth boot loader for firmware updates), the size of resulting binary with LittleFS included has reached the point it does not fit into the program memory space.

Well, what now? There are two options. The first one is to use an F103 MCU with more FLASH like the STM32F103RB. The catch here, are its 64 pins on the larger footprint while the current PCBs is layed-out only for 48 pins of the CB variant. And as I don’t really want to be redesigning the PCB at this moment another option seem to be quite feasible – to replace the MCU with another one. The nice thing with STM’s controllers is they tend to have compatible pinouts. And as I already have some supply of STM32F030CCs in my drawer (and have big plans with that one in another project), this one seem to be the right fit for replacement. It’s got 256kB of FLASH and 32kB of RAM (comparing to 20kB of the F103CB). Some of the libraries I use will have to be extended to support the F030’s architecture (ARM Cortex M0 vs. M3, the buses and peripherals are organised in a bit different manner) but it would keep the footprint small while opening the opportunities for further development! πŸ™‚

But as things never can go easy, there is another problem. In the recent months the Standard Periperal Libraries (SPL) are for some reason not available for download for the System Workbench for STM32 (sw4stm32) and I cannot make it work even when downloaded them manually from the STM’s web. I have reported the problem on the openstm32.org forum already in two posts (the first, the second) with no success so far. Even the SPL firmware for the F103 doesn’t work now for me.

(Edit) I’ve eventually found a workaround. It’s crude, but it does the job! πŸ™‚

(Edit2) Here you can find backup of all STM32 firmwares that were still available from the stm32targets.xml file.

CUBE3s Available for Ordering

Few weeks ago I had silently added the Choose & Buy option in the menu above but somehow forgot to announce that aloud. I have just noticed mu last post is from April and since that time this site looks kinda dead. But I am telling you – it is NOT! πŸ™‚

We have made twenty five more Cubes (yes another 25!) and those are now being shipped around the world! I wanted to speed up the production process a bit, hence this batch is partially machine-populated. This helped significantly but not as much as I hoped – mainly due to my mistrust and doubts – which were, again, completely unnecessary as it turned out in the lucky end.

I plan to write a longer post about this endeavor later on – a story about going to small production without any prior experience. Yet, the season is on, let’s do some soaring first! πŸ™‚

A LOT of Cubes

Long time no see, right? Over the last month I have been busy with some modifications on the PCB (oh snap!) as well as parts ordering, sorting, reordering missing ones, soldering and finally enclosure printing in order to finish a bit larger order of these little sweet boxes.

As thorough testing is part of the process I have been driving this load around the county for some time. I only wonder what the passersby might have been thinking.

All units passed with flying colours and hence could be nested into their new home.

Do you love it as much as I do? Great job, Ibisek, great job indeed! πŸ™‚

First Two CUBE3s Are Out!

The great day on which two units equipped with three-axis accelerometers and new flight-logbook recording feature have finally reached their happy owners. The first one is about to start its fruitful career in a Piper 28 while the second found its home in an (to me) odd-looking Morane-Saulnier MS.880 πŸ™‚

Despite their confusing micro-USB connector they can be powered directly from the 12V power rail (4 to 15V to be exact). Naturally they sport all the sweet features like the previous development stages – here I’d like to highlight bluetooth communication delivering surrounding traffic information, over-the-air updates and logbook downloads directly to an Android-based phone or tablet (the app will come later, I promise πŸ˜‰ ).

Currently I’m experimenting with various models of the enclosure: from the top – slim (for simple micro USB-power, 17mm of height), regular (RJ45, 20mm) and finally a thick boxes for the battery-powered variant (24mm).

Back on Track

Are you familiar with saying “I have a friend who has a friend..?”

I have a friend who has a friend who can solder.. and I mean really, really well! Using a microscope in combination infra-heating chamber he managed to solder that tiny 3x3mm chip with 24 (no-)legs and it works in all three specimen he produced. I have never seen such a great and clean job before! Awesome!!

It’s so delightful! Just look at that beauty!

This also means we could verify the PCB design is correct and thus we can start truly “massive” production. Even after some had indicated they have no use for such a lovely accelerometer and wish the board to be unpopulated in that spot (complications, grrrr!) But for the other not-so-blindfolded individuals I presume this would be a nice to have extended functionality πŸ™‚

Stay tuned as further detail on OGN CUBE3s build will come shortly!

Soldering Hell

Soldering of the U8 chip went exactly as anticipated. Having spent already more than 10 hours and damaged three chips this job seems to be unreasonably hard.

The QFN24 package is just 3x3mm with 0.2mm legs. Actually they are not legs, there are L-shaped surfaces below and partially on the side of the chip. I’ve already discovered the right amount of soldering paste, the chip seems to be right in place and all the visible side surfaces seem to be soldered just right only the chip does not respond. The design seems to be right and I measured the contacts to be just fine on both sides the chip and the micro. It is still possible I had it overheated during the soldering as I was getting pretty upset at the end of the day..

The rest of the board seems the work as intended, especially the new switched DC-DC step-down converter makes me particularly happy. You can also spot the new super-capacitor (C10) backing up power for the GPS receiver.

There are three different designs on the board – the 12V-powered model “A” with micro USB connector (as you can see here), battery powered model “B” (depending on which parts are populated) charged by the same uUSB connector and model “A” with RJ45 socket for which a large cutout in place of the uUSB (P7) is made (that needs to be made as a separate PCB).

Right – now just to find a way how (or someone) to solder that bloody U8 and we can fire up the wheels of a production line! πŸ™‚

OGN CUBE 3 Prototype 1 PCBs

It is mid January I finally got the message they finished my PCBs so without any thought of hesitation I left my work in mid day and I hurried to pick them up right away.

Top view
Bottom view

To be honest I am a bit frightened of the U8. Obviously not the chip itself but of the soldering fun (I really mean hell) to be expected..