Orange Pi PC Setup

This page is for the Orange Pi PC only!

Once armbian is installed, its easy to tell what board you have, simply cat /etc/armbian-release and look for BOARD_NAME

Install ARMbian on your Orange Pi

We're only going to be using armbian, other distros could be made to work but you'd probably need to figure out how to detect the platform since we rely on /etc/armbian-release existing.

Download and install the latest armbian, for example we're using https://www.armbian.com/orange-pi-pc-plus/

There's some documentation to get started at https://docs.armbian.com/User-Guide_Getting-Started/

Blinka only supports ARMbian because that's the most stable OS we could find and it's easy to detect which board you have

We've found the easiest way to connect is through a console cable, wired to the debug port, and then on your computer, use a serial monitor at 115200 baud.

Logging in

USB to TTL Serial Cable - Debug / Console Cable for Raspberry Pi

PRODUCT ID: 954
The cable is easiest way ever to connect to your microcontroller/Raspberry Pi/WiFi router serial console port. Inside the big USB plug is a USB<->Serial conversion chip and at...
OUT OF STOCK

Once powered correctly and with the right SD card you should get a login prompt

After logging in you may be asked to create a new username, we recommend pi - if our instructions end up adding gpio access for the pi user, you can copy and paste em

Once installed, you may want to enable mdns so you can ssh [email protected] instead of needing to know the IP address:

  • sudo apt-get install avahi-daemon

then reboot

Set your Python install to Python 3 Default

There's a few ways to do this, we recommend something like this

  • sudo apt-get install -y python3 git python3-pip
  • sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
  • sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
  • sudo update-alternatives --config python

Of course change the version numbers if newer Python is distributed

Install libgpiod

libgpiod is what we use for gpio toggling, it doesn't come in installations yet but its easy to add by running our script. You'll probably need to run this as root, so sudo bash before you...

  • cd ~
  • wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.sh
  • chmod +x libgpiod.sh
  • ./libgpiod.sh

After installation you should be able to import gpiod from within Python3

Update Your Board and Python

Run the standard updates:

sudo apt-get update

sudo apt-get upgrade

and

sudo pip3 install --upgrade setuptools

Update all your python 3 packages with

pip3 freeze - local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U

and

sudo bash

pip3 freeze - local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U

Enable UART, I2C and SPI

A vast number of our CircuitPython drivers use UART, I2C and SPI for interfacing so you'll want to get those enabled.

You only have to do this once per board but by default all three interfaces are disabled!

Install the support software with

  • sudo apt-get install -y python-smbus python-dev i2c-tools
  • sudo adduser pi i2c

Read /etc/armbian-release to figure out your board family, in this case its a sun8i

Edit /boot/armbianEnv.txt and add these lines at the end, adjusting the overlay_prefix for your particular board

overlay_prefix=sun8i-h3
overlays=uart3 i2c0 spi-spidev
param_spidev_spi_bus=0

Once you're done with both and have rebooted, verify you have the I2C and SPI devices with the command ls /dev/i2c* /dev/spi*

You should see at least one i2c device and one spi device

You can test to see what I2C addresses are connected by running sudo i2cdetect -y 0 (on PA11/PA12) or sudo i2cdetect -y 1 (on PA18/PA19)

In this case I do have a sensor on the 'standard' i2c port i2c-0 under address 0x77

You can also install WiringOP and then run gpio readall to see the MUX status. If you see ALT3 next to a pin, its a plain GPIO. If you see ALT4 or ALT5, its an SPI/I2C/UART peripheral

Install Python libraries

Now you're ready to install all the python support

Run the following command to install adafruit_blinka

pip3 install adafruit-blinka

The computer will install a few different libraries such as adafruit-pureio (our ioctl-only i2c library), spidev (for SPI interfacing), Adafruit-GPIO (for detecting your board) and of course adafruit-blinka

That's pretty much it! You're now ready to test.

Create a new file called blinkatest.py with nano or your favorite text editor and put the following in:

Download: file
import board
import digitalio
import busio

print("Hello blinka!")

# Try to great a Digital input
pin = digitalio.DigitalInOut(board.PA6)
print("Digital IO ok!")

# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")

# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")

print("done!")

Save it and run at the command line with

sudo python3 blinkatest.py

You should see the following, indicating digital i/o, I2C and SPI all worked

This guide was first published on Dec 02, 2018. It was last updated on Dec 02, 2018. This page (Orange Pi PC Setup) was last updated on Dec 05, 2019.