Home A quick start to the Orange Pi 3B
Post
Cancel

A quick start to the Orange Pi 3B

Orange Pi 3B is a single-board computer with a Rockchip RK3566 (aarch64) and different RAM options (2GB, 4GB, 8GB). What sets this board apart is its builtin M.2 M-KEY slot port which can be used for SATA3 or NVME SSDs, so we don’t need to use the SD card. Everyone that have used Raspberry Pis for a while know that SD cards are always dying. Thus , having other storage option is a must to use a board like this 24/7.

Unfortunately, when we choose something else than a Raspberry Pi, we know that software support might not be the best. In this post, I hope to assist anyone who would like to use it, by discussing potential operating systems, and explaining how to use the GPIO, I2C and SPI interfaces outside the Orange Pi environment.

Operating systems

The Orange Pi company provides official images specifically tailored for their boards, which can be found here. However, I personally prefer using a standard OS or at least one not controlled by the hardware manufacturer. These companies tend to develop custom solutions rather than adhering to standard practices. Therefore, the ultimate goal is to make the board EBBR compliant.

EBBR, or Embedded Base Boot Requirements, is a subset of the EFI boot services that allows compliant devices to load standard distributions supporting EFI. The usability of the operating system will depend on the availability of drivers. The key to making a board EBBR compliant is to find the correct bootloader. The Orange Pi 3B ships with an older version of the U-Boot bootloader, specific to Rockchip SoCs, which does not implement EBBR. The mainline U-Boot bootloader supports EBBR, so if we are able to upgrade this bootloader, we achieve our goal. Basically, we need an U-Boot image for this SBC with the following configs enabled:

1
2
CONFIG_CMD_BOOTEFI=y
CONFIG_EFI_LOADER=y

The simplest way I found to retrieve and install an U-Boot image complying with this settings was to use Armbian. Armbian is an ultralight linux build specially for SBCs. This is a community-driven project and creates images based of Debian and Ubuntu. So, if we want a linux image that is not controlled by the hardware developer, Armbian is an option by itself.

To upgrade the default bootloader with Armbian, first we need to install the latest Armbian image on an SD card and boot into Armbian. After that is as simple as running armbian-config, select system and then choosing upgrade firmware . With this, our bootloader is upgraded, allowing us to load distributions that support EFI mode.

If your image doesn’t have the command armbian-config, you can install it by running sudo apt update && sudo apt install -y armbian-config.

After this, I was able to boot Fedora IoT 39 on this board by simply flashing a disk image with the correct architecture (aarch64) onto an NVME disk and inserting it into the Orange Pi 3B. You can use other distributions; however, the compatibility of components like Wi-Fi depends on driver availability. (In Fedora, the Wi-Fi wasn’t recognized.) The Orange Pi 3B utilizes a Motorcomm YT8531 Ethernet controller. Its driver was only included in kernel 6.3, so you should consider this when selecting a distribution.

Failed attempt: Before using the Armbian U-boot boot, I attempt to use a port of the EDK II for this family of CPUs. EDK II is a full UEFI implementation and I was able to boot several distros such as Fedora and Manjaro, however I wasn’t able to have the ethernet port recognized. This may have changed since the last time I tried but I didn’t repeat my experiments.

GPIO

The Orange Pi 3B documentation explains how to utilize the SBC’s 40 pin interface. However, it only targets a library created and maintained by the Orange Pi company for GPIO control, the wiringOP. While you are able to install this software on Armbian, most applications rely on libgpiod , the kernel’s GPIO library, to control these pins.

In libgpiod, a GPIO pin is represented by a channel in a GPIO controller. After analyzing the board schematic and conducting experiments, I was able to identify the mapping between pins and channels.

GPIO ControllerChannelNamePhysical PinPhysical PinNameChannelGPIO Controller
  3.3V125V  
/dev/gpiochip412SDA2345V  
/dev/gpiochip413SCL256GND  
/dev/gpiochip44PWM1578RXD.225/dev/gpiochip0
  GND910TXD.224/dev/gpiochip0
/dev/gpiochip322GPIO3_C61112GPIO3_C723/dev/gpiochip3
/dev/gpiochip40GPIO4_A01314GND  
/dev/gpiochip42TXD.71516RXD.73/dev/gpiochip4
  3.3V1718GPIO4_A11/dev/gpiochip4
/dev/gpiochip410SPI3_TXD1920GND  
/dev/gpiochip48SPI3_RXD2122TXD.99/dev/gpiochip4
/dev/gpiochip411SPI3_CLK2324SPI3_CS16/dev/gpiochip4
  GND2526GPIO4_A77/dev/gpiochip4
/dev/gpiochip10SDA.32728SCL.31/dev/gpiochip1
/dev/gpiochip45RXD.92930GND  
/dev/gpiochip328GPIO3_D43132PWM1116/dev/gpiochip4
/dev/gpiochip331GPIO3_D73334GND  
/dev/gpiochip324GPIO3_D03536GPIO3_D529/dev/gpiochip3
/dev/gpiochip327GPIO3_D33738GPIO3_D226/dev/gpiochip3
  GND3940GPIO3_D125/dev/gpiochip3

I2C and SPI on armbian

The I2C and SPI buses exposed in the GPIO pins are not enabled by default. They can be enabled by applying a DTS overlay. I was able to enable both buses with the following overlays:

I2C bus overlay

1
2
3
4
5
6
7
8
/dts-v1/;
/plugin/;

&i2c2 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&i2c2m1_xfer>;
};

SPI bus overlay

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/dts-v1/;
/plugin/;



/ {
        fragment@0 {
                target = <&spi3>;

                __overlay__ {
                        status = "okay";
                        #address-cells = <1>;
                        #size-cells = <0>;
                        #cs-gpio = <0>,<0>;

                        spidev: spidev@0 {
                                status = "okay";
                                compatible = "armbian,spi-dev";
                                reg = <0>;
                                /* spi default max clock 100Mhz */
                                spi-max-frequency = <100000000>;
                        };
                };
        };
};

To enable these overlays you can run armbian-add-overlay <overlay_file.dts>.

It’s possible that by changing the driver used by spidev from armbian,spi-dev to rockchip,rk3066-spi, and adjusting the u-boot settings, both buses could be enabled in other operating systems. However, I haven’t had the opportunity to try it yet due to time constraints.

This post is licensed under CC BY 4.0 by the author.
Trending Tags