Sunday, April 5, 2020

Using Orange Pi

Orange Pi is a cheap alternative to Raspberry. They can be bought at their online store Shenzhen Xunlong at Aliexpress. There are many Orange Pi models. For example, Orange Pi One costs only ~USD 10. Another model called Orange Pi PC Plus even has 8 GB eMMC onboard and costs ~USD 25 only.


Figure. Orange Pi One





Setting Up

I will use Orange Pi PC Plus as an example to discuss about using OPis. It is recommended to buy power supply together when you buy the board. Unlike Raspberry Pi, micro USB on the board cannot be used to supply power to the board. Its power jack is neither a standard 5 mm barrel jack. Although, you can power it using 5V and GND pins on the header, the best way is to use a proper power supply. DC 5V 3A power supply for OPi, can also be bought from third party suppliers such as Power Wholesale Factory.


Figure. Orange Pi PC Plus


There are Android and Linux system images available for OPis to dowonload at Orange Pi Resources Page. After trying a few different Linux system images, I found Armbian Buster (mainline based kernel 5.4.y as of now) is the most convenient one for my needs. As it downloads 7z file, you need to extract it to a folder and make .zip again using 7-Zip software. And then use Etcher to burn the image into a SD card.

After insering the SD into the SBC, and supplying power, the device will boot and ask for root user name and password. The default username and password are as follows [1].

Default username: root
Default password: 1234


Desktop

The default Ambian interface is command line interface. To install desktop environment, use the following commands.

$ sudo apt update
$ sudo apt upgrade armbian-config
$ sudo armbian-config


And then when the configuration utility appears, choose

System - system and security settings


and click OK. Thereafter, choose

Default - Install desktop with browser and extras


eMMC

To flash the system on the SD card into the eMMC, launch the armbian-config again.

$ sudo armbian-config


Choose

System - system and security settings


Thereafter,

Install - Install to/update boot loader


and, choose

2 Boot from eMMC - system on eMMC


VNC Server

In the armbian-config utility, in 'Software - System and 3rd party software install', there is an option 'RDP - Enable remote desktop access from Windows'. Alternatively, you can use x11vnc as follows.

$ sudo apt update
$ sudo apt install x11vnc


After installing x11vnc, edit its configuration file using nano editor.

$ sudo nano /etc/X11/xorg.conf


In the editor,

Section "Screen"
        Identifier      "Default Screen"
        Device          "Mali-Fbdev"
        DefaultDepth    24
        SubSection "Display"
                Virtual 1280 720
        EndSubSection
EndSection


And then save and exit. To start the VNC server, use

$ sudo x11vnc -display :0 -auth guess


The next step is to create password and setup service so that the server will start automatically.

$ sudo x11vnc -storepasswd YOURVNCPWD /etc/x11vnc.pass
$ sudo nano /etc/systemd/system/x11vnc.service


When x11vnc.service file is opened in nano editor, enter the following lines, save, and exit.

[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2

[Install]
WantedBy=multi-user.target


Then, enable the service,

$ sudo systemctl daemon-reload
$ sudo systemctl enable x11vnc
$ sudo systemctl start x11vnc
$ systemctl status x11vnc.service


Linux headers

In the armbian-config utility, in 'Software - System and 3rd party software install', choose 'Headers - Install kernel headers'. It is important to update apt before using armbian-config to get correct version of kernel headers.

$ sudo apt update


Alternatively, you can try using

$ sudo apt install linux-headers-current-sunxi


or

$ sudo apt install linux-headers-next-sunxi


GPIO

The GIPO number for orange pi is as follows [2].

gpio_number = ('bank_letter' - 'A') * 32 + number





Figure. Orange Pi PC+ header (Image from orangepi.org)


For example, if you want to use pin 7 (PA6), its gpio number is

gpio_number = ('A' - 'A') * 32 + 6
gpio_number = 6


Then, you can export and use the pin similar to RPi.

$ cd /sys/class/gpio
$ sudo sh -c "echo 6 > export"
$ cd gpio6
$ sudo sh -c "echo out > direction"
$ sudo sh -c "echo 1 > value"
$ sudo sh -c "echo 0 > value"


References

[1] Armbian. Linux for ARM development boards.
url: https://docs.armbian.com/.

[1] Armbian forum. Button connection via GPIO Header on Orange Pi 3.
url: https://forum.armbian.com/topic/11134-button-connection-via-gpio-header-on-orange-pi-3/.

No comments:

Post a Comment

Comments are moderated and don't be surprised if your comment does not appear promptly.