The Raspberry Pi is at the time of this writing (November 2022) very difficult to get. And if you can get one, it sometimes comes at an absurd price. I've seen prices of €250+ for a Raspberry Pi 3B+!!! That's just pure theft and has nothing to do anymore with shortage of chips on the world market.
But I recently stumbled upon an alternative which is much cheaper and -maybe even more important - much more available. The name? Libre Computer.
It gets even better when I saw it has the exact same form factor as the Raspberry Pi! It also has the 40 pin header although the pins are not matching the pins of the Raspberry Pi and they seem to use an own wiring numbering. I'm still on the discovering tool, so I think I have to find it out myself.
There are 5 versions of the Libre Computer:
Tritium, based on a AllWinner SoC with a quad core ARM Cortex-A7 or quad core ARM Cortex-A53 CPU
The Tritium has 3 different flavours.
Le Potato, based on the AML (Am Logic) S905X SoC with a quad core ARM Cortex-A53 CPU running @ 1.51GHz and can have a max. of 2GB RAM
La Frite (what's in a name...), based also on the AML (Am Logic) Soc, but this time the S805C Soc with also a quad core Cortex-A53 CPU running @ 1.2GHz and can have a max. of 1GB RAM
Renegade, based on the RockChip RK3328 SoC with a quad core ARM Cortex-A53 CPU running @ 1.4GHz and can have a max. of 4GB RAM
Renegade Elite, based on the RockChip RK3399 SoC with a dual core ARM Cortex-A72 and a quad core ARM Cortex-A53 CPU and has 4GB of RAM. It's also the only one in the family that has USB 3.0 on board
The Renegade versions are the only ones that have USB 3.0 on board and have a gigabit ethernet connection.
You can see an overview of the different versions on the Libre Computer website.
To see a comparison between the different boards, visit this webpage.
The Libre Computer version "Le Potato" is the flagship. It's also the one I bought recently. See further.
It has the following specs (more detailed info can be found on the link given above):
Amlogic S905X SoC
4 ARM Cortex-A53 @ 1.512GHz
Cryptography Extension
2G + 3P ARM Mali-450 @ 750MHz
OpenGL ES 1.1 / 2.0
OpenVG 1.1
Amlogic Video Engine 10
Decoders
VP9 P2 4K60
H.265 MP10 @L5.1 4K60
H.264 HP @L5.1 4K30
JPEG / MJPEG
Encoders
H.264 1080P60
JPEG
Up to 2GB DDR3 SDRAM
4 USB 2.0 Type A
100 Mb Fast Ethernet
3.5mm TRRS AV Jack
HDMI 2.0
MicroUSB Power In
MicroSD Card Slot
eMMC Interface
IR Receiver
U-Boot Button
40 Pin Low Speed Header (PWM, I2C, SPI, GPIO)
Audio Headers (I2S, ADC, SPDIF)
UART Header
Yes, you read it right: up to 2GB of DDR3 SRAM, so double the size of a Raspberry Pi 3B+.
The only drawback: it has no WiFi or Bluetooth on board. But for me, I don't care since I don't use that anyway.
Price? Well, as of November 18th, 2022 it's only $US35 for the 2GB version! Unfortunately, it has to come from the US, so you also have to add shipment costs + VAT to it, making it still rather cheap: some $US55 for one board. But then you get 2GB of RAM, a faster running board, less power consumption compared to the Raspberry Pi 3B+ and so on.
Beware: there's a dedicated image availble for this SBC. You can't just flash the Raspbian Lite image to it, since it's another processor that is used on the SBC board.
For the rest, I hope it will be compatible to a certain (high) degree, but that's still to be found out.
Activating a functionality on a Libre Computer is slightly (well, a lot) different compared to a Raspberry Pi. While for the Raspberry Pi it's sufficient to add a dtoverlay line into the /boot/config.txt file to activate a functionality (e.g. I2C, or the I2C mux PCA9548), that's not working for Le Potato. The config file is something dedicated for the Raspberry Pi and doesn't work on any other SBC.
For example, if you run raspi-config on a Le Potato then you can activate e.g. I2C but nothing happens in the background. You might think I2C is activated, but it's not. When you search for an I2C device in the device directory /dev you won't find any!
No worries, though. There's also the possibility to activate things in Le Potato. Only, the way to reach the goal is different. Below is explained how you can achieve this for I2C (but other functionality like SPI should be similar).
LibreComputer has something called Libretech Wiring Tool, a GitHub repository which can be found here. This tool serves two goals:
Activating/installing device tree overlays through the tool ldto (libre device tree overlay)
Manipulating GPIO pins through the tool lgpio (libre general purpose input output)
The tools are installed in /opt/librecomputer/libretech-wiring-tool/ through a couple of links:
It all starts with /usr/bin where there's a ldto and lgpio:
ldto is linked to /etc/alternatives/ldto
lgpio is linked to /etc/alternatives/lgpio
In the /etc/alternatives directory there's again links to another destination:
ldto is linked to /opt/librecomputer/libretech-wiring-tool/ldto
lgpio is linked to /opt/librecomputer/libretech-wiring-tool/lgpio
That's the final destination. So, when running the command ldto or lgpio you end up in the /opt/librecomputer/libretech-wiring-tool directory.
How to (de)activate I2C DTs?
Run the command ldto list => an overview of possible DTOs will be shown
Choose a DTO, e.g. i2c-ao and load that one: sudo ldto enable i2c-ao
From here onwards, you should have an I2C device in the device tree: /dev/i2c-0 (should be detected by e.g. the i2cdetect -l command)
Same way of working is to be applied for the other DTOs.
To compile a device tree source into a device tree object, the following steps have to be taken:
Clone the Libre Wiring Tool on the Le Potato board:
git clone https://github.com/libre-computer-project/libretech-wiring-tool.git
Go to the directory libretech-wiring-tool and run the command make.
If you want a clean start, run make clean first.
This command will remove all .dbto files from the subdirectory ./libre-computer/<processor>/dt.
In case of Le Potato that is the subdirectory ./libre-computer/aml-s905x-cc/dt
Once all the DTS files are compiled into DTO files, they still have to be installed in the directory
/opt/librecomputer/libretech-wiring-tool/.
To accomplish this, the following command must be run: sudo make install
This will update all the .dtbo files into the beforementioned directory.
If the installation is done, you can again use ldto to see a list of updated/added devices.
Now that we now how the device tree works on a Le Potato and how to compile a DTS into a DTO, we can try to add the I2C mux PCA9548 to the system just like we can for the Raspberry Pi.
First, we have to create a DTS file for the PCA9548. We will name the file i2c-ao-pca9548.dts. The file should be put in the directory ./libre-computer/aml-s905x-cc/dt. This is a subdirectory of the libretech-wiring-tool Github repository already downloaded (see section above).
Below is the source file:
/*
* Author: Geert Vancompernolle
*/
/*
* Overlay to add the PCA9548 I2C mux (or equivalent) to the system giving the user an extra
* 8 I2C busses /dev/i2c-1 .. /dev/i2c-8.
* Default address of the I2C mux = 0x70 (all 3 address pins grounded).
*/
/dts-v1/;
/plugin/;
/{
compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";
fragment@1 {
target = <&i2c_AO>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pca9548: mux@70 {
compatible = "nxp,pca9548";
reg = <0x70>;
#address-cells = <1>;
#size-cells = <0>;
i2c@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
};
i2c@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;
};
i2c@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;
};
i2c@3 {
#address-cells = <1>;
#size-cells = <0>;
reg = <3>;
};
i2c@4 {
#address-cells = <1>;
#size-cells = <0>;
reg = <4>;
};
i2c@5 {
#address-cells = <1>;
#size-cells = <0>;
reg = <5>;
};
i2c@6 {
#address-cells = <1>;
#size-cells = <0>;
reg = <6>;
};
i2c@7 {
#address-cells = <1>;
#size-cells = <0>;
reg = <7>;
};
};
};
};
__overrides__ {
addr = <&pca9548>,"reg:0";
bus = <&i2c_AO>,"reg:0";
};
};
This will create an I2C mux on address 0x70 and will activate the code which is standard available in the Linux kernel so that at start up the kernel will sense if there's such device connected to the I2C bus and will install the functionality of it so that we have an extra 8 (!!!) I2C busses available.
Once we have the file and if not done yet, put/move it into the ./libre-computer/aml-s905x-cc/dt subdirectory of the libretech-wiring-tool we cloned from the GitHub web site.
Then run the command make from within the source root directory of the Libretech Wiring Tool directory. Once the make is finished, you should see an extra .dbto file added into the ./libre-computer/aml-s905x-cc/dt directory called i2c-ao-pca9548.dtbo. dtbo stands for device tree binary object, by the way.
The last step is to install all dtbo files using the command sudo make install.
Once the installation is done, run the command ldto list again and now you should see that the i2c-ao-pca9548 module is added to the list of modules.
To activate the module, run the command sudo ldto enable i2c-ao-pca9548. When you have an extra window open and run the command dmesg -w in there, you will/should see the following feedback:
[11187.388418] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/bus@c8100000/i2c@500/status
[11187.396214] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /__symbols__/pca9548
[11187.408093] i2c i2c-0: Added multiplexed i2c bus 1
[11187.409717] i2c i2c-0: Added multiplexed i2c bus 2
[11187.415068] i2c i2c-0: Added multiplexed i2c bus 3
[11187.419424] i2c i2c-0: Added multiplexed i2c bus 4
[11187.424594] i2c i2c-0: Added multiplexed i2c bus 5
[11187.434363] i2c i2c-0: Added multiplexed i2c bus 6
[11187.439602] i2c i2c-0: Added multiplexed i2c bus 7
[11187.441331] i2c i2c-0: Added multiplexed i2c bus 8
[11187.445061] pca954x 0-0070: registered 8 multiplexed busses for I2C switch pca9548
Ignore the memory leak messages as they appear for almost each and every I2C related module.
If you run the command i2cdetect -l, the following output is shown:
pi@librecomputer:/opt/librecomputer/libretech-wiring-tool $ i2cdetect -l | sort
i2c-0 i2c Meson I2C adapter I2C adapter
i2c-1 i2c i2c-0-mux (chan_id 0) I2C adapter
i2c-2 i2c i2c-0-mux (chan_id 1) I2C adapter
i2c-3 i2c i2c-0-mux (chan_id 2) I2C adapter
i2c-4 i2c i2c-0-mux (chan_id 3) I2C adapter
i2c-5 i2c i2c-0-mux (chan_id 4) I2C adapter
i2c-6 i2c i2c-0-mux (chan_id 5) I2C adapter
i2c-7 i2c i2c-0-mux (chan_id 6) I2C adapter
i2c-8 i2c i2c-0-mux (chan_id 7) I2C adapter
So, indeed, 8 extra I2C busses!
If you have I2C devices connected to one or more of the I2C mux outputs, use the correct I2C bus to communicate with them. If you have, for instance, an IO expander connected to the SDA/SCL1 (the outputs on the PCA9548 start at 0 and end at 7) you have to access it using the /dev/i2c-2 bus.
From now on, you can attach multiple devices with same addresses on different I2C busses. It's just a matter of selecting the correct I2C output on the I2C mux.
I've added some more explanation this website.
Some useful directories (different setup compared to Raspberry Pi):
/sys/firmware/devicetree/base
In here, lots of information is divided in subdirectories. Some of the useful files/subdirectories are:
model: a file containing the name of the board
soc: a directory in which you can find more information about the different busses and their addresses. Example: bus@c8100000 where I2C is hooked upon (i2c@500 is a subdirectory into the bus@c8100000 subdirectory)
Below are some useful links to the Libre Computer website.
https://hub.libre.computer/t/raspbian-11-bullseye-for-libre-computer-boards/82: link to the different distros
https://hub.libre.computer/t/libre-computer-wiring-tool/40: link to the lgpio and ldto commands
https://hub.libre.computer/t/aml-s905x-cc-wiring-tool-overlays-description/62: link to all the existing device tree overlay modules
https://hub.libre.computer/t/aml-s905x-cc-overview-resources-and-guides/288: link to general information about the Le Potato board (AML-S905X)
https://github.com/libre-computer-project: link to the Libre Computer github repository where you can find all toolings and more
https://github.com/libre-computer-project/libretech-raspbian-portability: link to the tool to convert a genuine Raspberry Pi image to one more tailored to the Libre Computer alternative.