Something I ‘made’, electronics related, part of one of my projects, but software in nature.
Last year I bought a MangoPI MQ-Pro, a risc-v single board computer in the Raspberry Pi Zero form-factor.
It has ‘one’ of everything; One Core, One Gigaherz, One Gigabyte. Also a SD card slot, onboard wifi/bt, usbC for power and a GPIO connector. It runs Linux quite well, so long as you dont ask too much of it.
I want to use this board as a LoRa basestation on my balcony, talking to my boat. But… first I needed to get a proper, updated and updatable linux distribution on it, then I need to control the GPIO pins.
The LoRa module is on a pi-zero HAT, it needs serial and three digital lines for use. Serial can be jumpered to either standard pi pins, or elsewhere, but the three pins are ‘fixed’ on the connector.
Also… I want to run a I2C based environment sensor (bme280), have a local I2C lcd display and control the backlight to that.
A lot of work later and I have:
A full on guide to getting the MQ-Pro up and running with Ubuntu server 24.04.1.
- This is a LTS+ release, should be good for 5+ years
- I’m normally a Fedora/RH guy, but Canonical are embarassingly far ahead of RH with regards to risc-v support.
- WiFi is working (and is very stable even with the onboard antenna)
- The board is running with the correct Device Tree
The last point is the hard one… And what my documentation is all about.
There is no official Ubuntu release for this board, but they do support a couple of other boards based on the same Allwinner D1 soc. The SD images for these can be booted and mostly work, even WiFi is detected.
But the device tree is not correct for the board and some things are not properly configured; Bluetooth is not detected and the GPIO pin header assignments are wrong.
- Device Trees inform the boot process and then the kernel about the hardware it is running on.
- Each Chipset has a set of device tree headers and drivers (provided by manufacturers), and then each board needs a device tree built on that.
- And I do mean ‘built’; device trees are source. You have to compile them against the headers for your kernel and the manufacturers drivers.
The guide starts by getting a ‘vanilla’ board running; showing how to reconfigure for the correct device tree (the correct tree is already present in the linux-firmware package, it just needs to be configured as the default)
Then I show how to go further; enabling hardware interfaces (I2C, SPI, PWM, etc) in the device tree and mapping them to GPIO pins. There is tooling to build and install custom modified device trees and some examples.
And my prototype rig has life: Sensors, displays, pwm LED and a button. Linux based GPIO can be tricky, but things have been getting better lately.
I need to make the two ‘end nodes’ next; the sailing season is over so this is a new years plan.