Howto Setup armbian on Orange PI 5 Plus with SPI and i2c Interfaces

This blog post describes howto install armbian on an Orange PI 5 Plus (UNENCRYPTED HTTP LINK!). Sadly the chinese company behind Orange PI does not provide a httpS website.

IMPORTANT SECURITY NOTICE! The website orangepi.org does not provide httpS. This means that all traffic from your computer to this website is not encrypted and can potentially be manipulated by a man in the middle attack . This blogpost contains multiple links to this website.

Introduction

The Orange PI 5 Plus is a faster and stronger competitor to the Raspberry PI 5 - it has more ressources and ports with up to 32 GB RAM, an the octa core ARM CPU Rockchip RK3588, up to 256 GB eMMC storage and two 2.5G ethernet ports it overpowers the Raspberry Pi 5s performance with ease.

The downside in comparison to the Raspberry Pi 5 is that it has much less public content, from forum questions and answers to blog posts, online chat rooms and github libraries and tools. It is hence a bit for advanced users.

The operating system provided by the company Orange Pi, which to our pleasure can be downloaded with httpS, is based on arch Linux and we did not investigate it further. For a Debian Linux based solution we chose armbian.

Installing armbian

Armbian provides images specifically for the Orange Pi 5 Plus. The download link on top of the page labeled "Armbian 23.11.1 Bookworm CLI" however is for the Orange Pi 5 and not 5 Plus version of the board. To get the correct image for the 5 Plus board you have to scroll down a bit and click the link that says "For Orange Pi 5 Plus model, images can be downloaded here":

armbian website screenshot for Orange Pi 5 Plus download link

The image can be downloaded and written to the micro SD card using the command line like follows.

Download the image using wget and verify the checksum:

wget https://mirror-eu-de1.armbian.airframes.io/dl/orangepi5-plus/archive/Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz

Compare the checksum:

wget https://mirror-eu-de1.armbian.airframes.io/dl/orangepi5-plus/archive/Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz.sha

user@workstation:~$ sha256sum Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz
3b8f8ace0c4ca62d87fad4f83392ebb7d0412a45891d7c2e4f5d15e6a8c22e5c

user@workstation:~$ cat Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz.sha
3b8f8ace0c4ca62d87fad4f83392ebb7d0412a45891d7c2e4f5d15e6a8c22e5c Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz

Extract the .xz compressed archive:

unxz Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img.xz

Write the image to the SD card:

sudo dd if=Armbian_23.11.1_Orangepi5-plus_bookworm_legacy_5.10.160.img of=/dev/mmcblk0 status=progress && sudo sync

We noticed that the OpenSSH server did not start on boot, which requires an external monitor that can be connected via one of two available HDMI ports. The four USB ports, or the single USB-C port allow for attaching a mouse and a keyboard.

The default Login credentials for armbian are:
Username: root
Password: 1234

Fixing kernel panic occuring after a few minutes

We noticed that the fresh installation was often crashed with a kernel panic a few minutes after booting the Orange Pi. The solution to this is described in this Github issue:

dd if=/dev/zero of=/dev/mtdblock0 count=4096 bs=512

We found that the Operating System provided by Orange PI based on Arch Linux runs without stability issues out of the box. You can run the dd command from this distribution before installing armbian.

The ROCK 5 chip features an onboard SPI flash device that is presented as /dev/mtdblock0:

user@orange-pi-5-plus:~$ sudo fdisk -l /dev/mtdblock0
Disk /dev/mtdblock0: 16 MiB, 16777216 bytes, 32768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

This MTD (Memory Technology Devices) block device stores a bootloader for auxiliary boot purposes. This enables the device to boot from media types not directly supported by the SoC's maskrom mode, including NVMe or USB 3. Using this, a fingernail sized NVMe SSD with up to 256 GB size can be attached to the Orange Pi 5 Plus board directly:

user@orange-pi-5-plus:~$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 232.96 GiB, 250139901952 bytes, 488554496 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

More information about managing the SPI can be found at wiki.radxa.com/Rock5/install/spi.

First steps and basic configuration

After the first login we recommend to perform the following basic tasks. First replace all default apt repositories configured for http with httpS:

sed -i 's@http://@https://@g' /etc/apt/sources.list
sed -i 's@http://@https://@g' /etc/apt/sources.list.d/*list
apt update
apt upgrade
The configure automatic security upgrades:
apt install unattended-upgrades
dpkg-reconfigure unattended-upgrades

Additionally you should take a look at armbians version of Raspberry PIs raspi-config:

armbian-config

Configuring i2c devices

The Orange Pi 5 Plus comes with a 40 Pin header to attach all sorts of devices and sensors: Orange Pi 5 Plus 40 PIN description

The board has four groups of i2c buses, but I2C2_M0 and I2C2_M4 are connected to the same bus and can not be used at the same time. Luckily you can attach multiple devices to one i2c bus.

In order to activate the first i2c bus open armbian-config and select System -> Hardware -> rk3588-i2c2-m0, save and reboot the device. These changes are saved in /boot/armbianEnv.txt, for example overlays=rk3588-i2c2-m0. The i2c-dev module also has to be loaded on boot:

user@orange-pi-5-plus:~$ cat /etc/modules
i2c-dev
user@orange-pi-5-plus:~$ modprobe i2c-dev

To run i2cdetect against all devices matching /dev/i2c* use the following command:

ls /dev/i2c* | while read line; do
    id="$(echo $line | cut -d '-' -f 2)"
    echo -e "\n## Detecting i2c ID: $id"
    sudo i2cdetect -y $id
done

On our device, two i2c devices are connected and detected - in our example 68 is a BME 280 thermometer and 76 a MPU 5060 gyroscope:

## Detecting i2c ID: 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 --  

You can then address the sensors in python using smbus for example:

import smbus

bus = smbus.SMBus(2)
Device_Address = 0x68

More information on configuring i2c is available in the Orange Pi Wiki Page.

Configuring the SPI interface

First the apt package spi-tools is required:

sudo apt install spi-tools

Add the following lines to /boot/armbianEnv.txt:

overlays=rk3588-i2c2-m0 rk3588-spi4-m2-cs0-spidev
param_spidev_spi_bus=0
param_spidev_max_freq=100000000

Load the spidev kernel module:

sudo modprobe -r spidev
sudo modprobe spidev

Create udev rules inside /etc/udev/rules.d/50-spi.rules to create devices devices files for SPI devices like /dev/spidev4.0:

SUBSYSTEM=="spidev", GROUP="spiuser", MODE="0660"

And reload the udev rules:

sudo udevadm control --reload-rules

Then add a Linux group to grant access for managing SPI devices and add your current Linux user to it. Make sure not to execute this command as the root user but as your regular user:

sudo groupadd spiuser
sudo adduser "$USER" spiuser

Note that you have to open a new login shell (logout and log back in again) for the group changes to take effect. You can then list available SPI buses like so:

user@orange-pi-5-plus:~$ ls /dev/spi*
/dev/spidev4.0

The github repository github.com/mcgurk/Arduino-WS2811-rotary-RGB-led-strip/ gives further examples on how to setup a WS2811 RGB LED strip on an Orange Pi.




Would you like to learn more about
customizing single board computers like Orange Pi and Raspberry Pi?

Call us Today!

+49 30 / 629 318 76 | info@blunix.com
Encrypted Communication