0% found this document useful (0 votes)
128 views131 pages

OrangePi 5 Pro 03 (302-432)

The document provides a user manual for the range Pi development board, detailing the setup and usage of CAN communication and PWM functionality. It includes instructions for wiring connections, software setup, and command-line operations for testing CAN message transmission and PWM adjustments. Additionally, it outlines the installation and usage of the wiringOP-Python library for hardware resource management in Python programming.

Uploaded by

gerardo51251
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views131 pages

OrangePi 5 Pro 03 (302-432)

The document provides a user manual for the range Pi development board, detailing the setup and usage of CAN communication and PWM functionality. It includes instructions for wiring connections, software setup, and command-line operations for testing CAN message transmission and PWM adjustments. Additionally, it outlines the installation and usage of the wiringOP-Python library for hardware resource management in Python programming.

Uploaded by

gerardo51251
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 131

range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co.

, Ltd

the 40pin development board


d. The CAN RX pin of the CAN transceiver needs to be connected to the RX pin of
the CAN bus in the 40pin development board
e. The CANH pin of the CAN transceiver needs to be connected to the H interface
of the analyzer
f. The CANL pin of the CAN transceiver needs to be connected to the L interface
of the analyzer

8) Then you can open the USB-CAN software

9) Then click Start Device

302
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

10) Then click OK

11) Set the baud rate to 1000k bps

12) After successful opening, the USB-CAN software will display the serial number and
other information

303
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

13) Development board receives CAN message test


a. First set the baud rate of the CAN bus to 1000kbps in the Linux system of the
development board
orangepi@orangepi:~$ sudo ip link set can0 down
orangepi@orangepi:~$ sudo ip link set can0 type can bitrate 1000000
orangepi@orangepi:~$ sudo ip link set can0 up
b. Then run the candump can0 command to prepare to receive messages

orangepi@orangepi:~$ sudo candump can0


c. Then send a message to the development board in the USB-CAN software

d. If the development board can receive messages sent by the analyzer, it means
that the CAN bus can be used normally
orangepi@orangepi5pro:~$ sudo candump can0
can0 001 [8] 01 02 03 04 05 06 07 08

304
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

14) Development board sends CAN message test


a. First set the CAN baud rate to 1000kbps in the Linux system
orangepi@orangepi:~$ sudo ip link set can0 down
orangepi@orangepi:~$ sudo ip link set can0 type can bitrate 1000000
orangepi@orangepi:~$ sudo ip link set can0 up
b. Execute the cansend command in the development board to send a message
orangepi@orangepi:~$ sudo cansend can0 123#1122334455667788
c. If the USB-CAN software can receive the message from the development board,
the communication is successful

3.19. wiringOP Hardware PWM Usage Method

Before using wiringOP to operate PWM, please ensure that wiringOP is


installed on the Linux system. If the gpio readall command can be used normally, it
means wiringOP has been installed. If prompted that the command cannot be found,
please refer to the instructions in the section on installing wiringOP to install

305
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

wiringOP first.

3.19.1. Method of setting PWM using the gpio command of wiringOP

3.19.1.1. Set the corresponding pin to PWM mode

1) As can be seen from the following table, there are six pwm channels available on the
development board: pwm0, pwm1, pwm3, pwm13, pwm14 and pwm15. PWM14_M1
and PWM14_M2, PWM15_M1 and PWM15_M3 can only use one of them at the same
time, can not be used at the same time, they are the same PWM, but connected to
different pins, please do not think that they are two different PWM buses.

2) The wPi serial number corresponding to the PWM pin is as follows:


PWM Pin wPi Serial Pin Serial GPIO Serial
number number number
PWM0_M2 17 27 34
PWM1_M2 18 28 35
PWM3_M3 6 12 39
PWM13_M2 2 7 47
PWM14_M1 5 11 138
PWM14_M2 21 32 62
PWM15_M1 7 13 139
PWM15_M3 22 33 63

3) The command to set the pin to PWM mode is as follows, take PWM0_M2 as an
example, where the third parameter needs to enter the wPi number corresponding to the
PWM0_M2 pin.
orangepi@orangepi:~$ gpio mode 17 pwm

306
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) After the pin is set to PWM mode, a square wave with a frequency of 200Hz, a period
of 5ms, and a duty cycle of 50% will be output by default. At this time, we use an
oscilloscope to measure the corresponding PWM pin, and the following waveform can be
seen.

3.19.1.2. Methods for Adjusting PWM Frequency

The calculation formula for PWM frequency is as follows:

PWM frequency = clock frequency / (division factor * The value of the


periodic register)

IN:
1. The default value for clock frequency is 24000000Hz。
2. The range of values for the frequency division coefficient is even numbers
between 2 ~ 512, with a default value of 120. If the set frequency division coefficient
is odd, the actual frequency division coefficient is the set value minus one.
3. The default value of the cycle register is 1000。
4. The default value for PWM frequency is 24000000 / (120 * 1000) = 200Hz。

307
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.19.1.2.1. Method of adjusting PWM frequency by setting the


frequency division factor

1) We can use the following command to set the frequency division factor of PWM0_M2
pin to 4.
orangepi@orangepi:~$ gpio pwmc 17 4

2) According to the above formula, the calculated value of PWM frequency is 6000Hz,
and it can be observed that the measured value of PWM frequency is 6010Hz through the
oscilloscope, and the error can be ignored.

3.19.1.2.2. Method of setting PWM frequency directly

1) We can use the gpio pwmTone command to set the frequency of the PWM pin, for
example, the following command can be used to set the PWM frequency of the
PWM0_M2 pin to 500Hz.
orangepi@orangepi:~$ gpio pwmTone 17 500

When setting the PWM frequency, it is necessary to ensure that:

308
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Set frequency value < 24000000 / (division factor * 2)。

For example, the default division factor is 120, and without modifying the
division factor, the set frequency value should be less than 100000Hz.
If the setting value is too large, the following error message will appear:
gpio: The PWM frequency you set is too high to be possible

2) Then, through an oscilloscope, it can be observed that the PWM frequency has
changed to 500Hz.

3.19.1.3. Methods for Adjusting PWM Duty Cycle

1) The calculation formula for PWM duty cycle is as follows. We can adjust the PWM
duty cycle by setting the values of the duty cycle register and the period register.
PWM Duty cycle = The value of the duty cycle register / The value of the periodic
register

IN:
The default value of the duty cycle register is 500.
The default value of the cycle register is 1000.

309
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

It should be noted that the value of the duty cycle register needs to be smaller
than the value of the cycle register, as the duty cycle cannot be greater than 1.
When the value of the duty cycle register is set to be greater than the value of
the cycle register, the following error message will be prompted:
gpio: CCR should be less than or equal to ARR (XXX)
When the value of the cycle register is set to be less than the value of the duty
cycle register, the following error message will be prompted:
gpio: ARR should be greater than or equal to CRR (XXX)

2) We can use the following command to set the value of the period register for the
PWM0_M2 pin to 2000.
orangepi@orangepi:~$ gpio pwmr 17 2000

3) After running the above command, it can be observed through the oscilloscope that
the PWM duty cycle has changed from the default 50% (500/1000) to 25% (500/2000).

4) We can use the following command to set the duty cycle register value of the
PWM0_M2 pin to 1000.
orangepi@orangepi:~$ gpio pwm 17 1000

5) After running the above command, it can be observed through the oscilloscope that

310
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

the PWM duty cycle changes from 25% (500/2000) to 50% (1000/2000).

3.19.2. Usage of PWM Test Program


1) In the example directory of wiringOP, there is a program called pwm.c that
demonstrates the use of PWM related API in wiringOP to operate PWM.
orangepi@orangepi:~$ cd /usr/src/wiringOP/examples/
orangepi@orangepi:/usr/src/wiringOP/examples$ ls pwm.c
pwm.c

2) The command to compile pwm.c into an executable program is as follows:


orangepi@orangepi:/usr/src/wiringOP/examples$ gcc -o pwm pwm.c -lwiringPi

3) Then you can execute the PWM test program. When executing the PWM test program,
you need to specify the PWM pin. For example, you can use the following command to
test the PWM0_M2 pin:
orangepi@orangepi:/usr/src/wiringOP/examples$ sudo ./pwm 17

4) After the pwm program is executed, the following contents will be tested sequentially:
a. Adjust the PWM duty cycle by setting the value of the cycle register.
b. Adjust the PWM duty cycle by setting the value of the duty cycle register.
c. Adjust the PWM frequency by setting the division factor.
d. Directly set the PWM frequency.

311
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) After completing each test, the output of pwm waveform will be stopped for 5 seconds.
After completing all test contents, a new round of testing will be restarted.

6) The detailed execution process of the PWM test program is as follows:


a. By setting the value of the cycle register to adjust the PWM duty cycle: Through
an oscilloscope, it can be observed that the PWM waveform changes every 0.5
seconds. After 8 changes, the PWM duty cycle changes from 50% to 25% and
remains for 5 seconds. Then, the PWM waveform changes every 0.5 seconds.
After 8 changes, the PWM duty cycle changes from 25% to 50% and remains for
5 seconds.
b. By setting the value of the duty cycle register to adjust the PWM duty cycle: The
oscilloscope can observe that the PWM waveform changes every 0.5 seconds.
After 8 changes, the PWM duty cycle changes from 50% to 100% and remains
for 5 seconds. Then, the PWM waveform changes every 0.5 seconds. After 8
changes, the PWM duty cycle changes from 100% to 50% and remains for 5
seconds.
c. By setting the frequency division coefficient to adjust the PWM frequency:
Through an oscilloscope, it can be observed that the PWM waveform changes
every 0.5 seconds. After 9 changes, the PWM frequency will change from
2000Hz to 200Hz and remain for 5 seconds. Then, the PWM waveform changes
every 0.5 seconds. After 9 changes, the PWM frequency will change again to
2000Hz and remain for 5 seconds.
d. Directly setting the PWM frequency: Through the oscilloscope, it can be
observed that the PWM frequency first changes to 2000Hz, and then increases
by 2000Hz every two seconds. After 9 changes, the PWM frequency changes to
20000Hz and remains for 5 seconds.

3.20. How to install and use wiringOP-Python

wiringOP-Python is the Python language version of wiringOP, which is used to


operate the hardware resources of the development board, such as GPIO, I2C, SPI
and UART, in the Python program.

In addition, please note that all the following commands are operated under the

312
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

root user.
3.20.1. How to install wiringOP-Python
1) First install the dependency package
root@orangepi:~# sudo apt-get update
root@orangepi:~# sudo apt-get -y install git swig python3-dev python3-setuptools

2) Then use the following command to download the source code of wiringOP-Python
Note that the following git clone --recursive command will automatically
download the source code of wiringOP, because wiringOP-Python depends on
wiringOP. Please make sure that the download process does not report errors due to
network problems.

If there is a problem downloading the code from GitHub, you can directly use
the wiringOP-Python source code that comes with the Linux image. The storage
location is: /usr/src/wiringOP-Python.
root@orangepi:~# git clone --recursive https://github.com/orangepi-xunlong/wiringOP-Python -b next
root@orangepi:~# cd wiringOP-Python
root@orangepi:~/wiringOP-Python# git submodule update --init --remote

3) Then use the following command to compile wiringOP-Python and install it into the
Linux system of the development board
root@orangepi:~# cd wiringOP-Python
root@orangepi:~/wiringOP-Python# python3 generate-bindings.py > bindings.i
root@orangepi:~/wiringOP-Python# sudo python3 setup.py install

4) Then enter the following command, if there is help information output, it means that
wiringOP-Python is installed successfully, press the q key to exit the help information
interface
root@orangepi:~/wiringOP-Python# python3 -c "import wiringpi; help(wiringpi)"
Help on module wiringpi:

NAME
wiringpi

DESCRIPTION

313
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

# This file was automatically generated by SWIG (http://www.swig.org).


# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

5) The steps to test whether wiringOP-Python is successfully installed under the python
command line are as follows:
a. First use the python3 command to enter the command line mode of python3
root@orangepi:~# python3
b. Then import the python module of wiringpi
>>> import wiringpi;
c. Finally, enter the following command to view the help information of
wiringOP-Python, and press the q key to exit the help information interface
>>> help(wiringpi)
Help on module wiringpi:

NAME
wiringpi

DESCRIPTION
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

CLASSES
builtins.object
GPIO
I2C
Serial
nes

class GPIO(builtins.object)

314
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

| GPIO(pinmode=0)
|

>>>
3.20.2. 40pin GPIO Port Test
wiringOP-Python is the same as wiringOP, you can also determine which GPIO
pin to operate by specifying the wPi number, because there is no command to check
the wPi number in wiringOP-Python, so you can only use the gpio command in
wiringOP to check the correspondence between the board wPi number and the
physical pin.

1) The following pin 7 —— corresponding to GPIO is GPIO1_C6 —— corresponding


to wPi serial number is 2 —— as an example to demonstrate how to set the high and
low level of GPIO port

315
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

2) The steps to test directly with the command are as follows:


a. First set the GPIO port to the output mode, where the first parameter of the
pinMode function is the serial number of the wPi corresponding to the pin, and
the second parameter is the GPIO mode
root@orangepi:~/wiringOP-Python# python3 -c "import wiringpi; \
from wiringpi import GPIO; wiringpi.wiringPiSetup() ; \
wiringpi.pinMode(2, GPIO.OUTPUT) ; "
b. Then set the GPIO port to output low level. After setting, you can use a
multimeter to measure the voltage value of the pin. If it is 0v, it means that the
low level is set successfully.
root@orangepi:~/wiringOP-Python# python3 -c "import wiringpi; \
from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\
wiringpi.digitalWrite(2, GPIO.LOW)"
c. Then set the GPIO port to output a high level. After setting, you can use a
multimeter to measure the voltage value of the pin. If it is 3.3v, it means that the
high level is set successfully.
root@orangepi:~/wiringOP-Python# python3 -c "import wiringpi; \
from wiringpi import GPIO; wiringpi.wiringPiSetup() ;\
wiringpi.digitalWrite(2, GPIO.HIGH)"

3) The steps to test in the command line of python3 are as follows:


a. First use the python3 command to enter the command line mode of python3
root@orangepi:~# python3
b. Then import the python module of wiringpi
>>> import wiringpi
>>> from wiringpi import GPIO
c. Then set the GPIO port to output mode, where the first parameter of the

316
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

pinMode function is the serial number of the wPi corresponding to the pin, and
the second parameter is the GPIO mode
>>> wiringpi.wiringPiSetup()
0
>>> wiringpi.pinMode(2, GPIO.OUTPUT)
d. Then set the GPIO port to output a low level. After setting, you can use a
multimeter to measure the voltage value of the pin. If it is 0v, it means that the
low level is set successfully.
>>> wiringpi.digitalWrite(2, GPIO.LOW)
e. Then set the GPIO port to output a high level. After setting, you can use a
multimeter to measure the voltage value of the pin. If it is 3.3v, it means that the
high level is set successfully.
>>> wiringpi.digitalWrite(2, GPIO.HIGH)

4) The method of wiringOP-Python to set GPIO high and low levels in python code can
refer to the blink.py test program in the examples below. The blink.py test program will
set the voltage of all GPIO ports in the 26 pins of the development board to change
continuously.
root@orangepi:~/wiringOP-Python# cd examples
root@orangepi:~/wiringOP-Python/examples# ls blink.py
blink.py
root@orangepi:~/wiringOP-Python/examples# python3 blink.py
3.20.3. 40pin SPI test
1) As can be seen from the following figure, the available spi of Orange Pi 5 Pro are spi0
and spi4

2) The corresponding pins of SPI0 and SPI4 in 40pin are shown in the table below.
SPI0_M2 corresponds to 40pin SPI4_M2 corresponds to 40pin
MOSI Pin 19 Pin 16

317
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

MISO Pin 21 Pin 18


CLK Pin 23 Pin 27
CS0 Pin 24 Pin 28
CS1 Pin 26 无
Dtbo spi0-m2-cs0-spidev spi4-m2-cs0-spidev
configuration spi0-m2-cs1-spidev
spi0-m2-cs0-cs1-spidev

3) In the linux system, the SPI in 40 pin is turned off by default and needs to be opened
manually. The detailed steps are as follows:
a. First run orangepi-config, ordinary users remember to add sudo permission
orangepi@orangepi:~$ sudo orangepi-config
b. Then choose System

c. Then choose Hardware

d. Then use the arrow keys on the keyboard to locate the position shown in the
following figure, and then use the space to select the SPI configuration that you
want to open

318
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

e. Then select <Save> to save

f. Then select <Back>

g. Then select <Reboot> to restart the system for the configuration to take effect

4) After the restart, go to the system and check whether spidevx.x device nodes exist in
the linux system. If nodes exist, the SPI is set and can be used directly.
orangepi@orangepi:~$ ls /dev/spidev*
/dev/spidev0.0 /dev/spidev0.1 /dev/spidev4.0

The above is the result displayed after opening spi0-m2-cs0-cs1-spidev and


spi4-m2-cs0-spidev.

319
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) Then you can use the spidev_test.py program in the examples to test the loopback
function of the SPI. The spidev_test.py program needs to specify the following two
parameters:
a. --channel:Specifies the channel number of the SPI
b. --port:Specify the port number of the SPI

6) Do not short-circuit the mosi and miso pins of SPI4, the output result of running
spidev_test.py is as follows, you can see that the data of TX and RX are inconsistent
The x after the --channel and --port arguments needs to be replaced with the
channel number and the port number of the SPI specific.
root@orangepi:~/wiringOP-Python# cd examples
root@orangepi:~/wiringOP-Python/examples# python3 spidev_test.py \
--channel x --port x
spi mode: 0x0
max speed: 500000 Hz (500 KHz)
Opening device /dev/spidev0.0
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF F0 0D |......@..........|
RX | FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF |.................|

7) Then use the Dupont wire to short connect the two pins of SPI txd (pin 19 in the 40pin
interface) and rxd (pin 21 in the 40pin interface) and run spidev_test.py as follows. You
can see that the sent and received data are the same, indicating that the SPI loop test is
normal
The x after the --channel and --port arguments needs to be replaced with the
channel number and the port number of the SPI specific.
root@orangepi:~/wiringOP-Python# cd examples
root@orangepi:~/wiringOP-Python/examples# python3 spidev_test.py \
--channel x --port x
spi mode: 0x0
max speed: 500000 Hz (500 KHz)
Opening device /dev/spidev0.0
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF F0 0D |......@..........|

320
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF F0 0D |......@..........|

3.20.4. 40pin I2C 测试


1) As can be seen from the following table, there are four i2c buses available for Orange
Pi 5 Pro: i2c1, i2c4, i2c5 and i2c8

2) The pins corresponding to the four groups of I2C buses in the 40pin are shown in the
following table. I2C5_M2 and I2C5_M3 can only use one group at the same time, can not
be used at the same time, they are the same I2C5, just received a different pin up, please
do not think that they are two different groups of I2C5 bus.
I2C Bus SDA corresponds to SCL corresponds to Dtbo corresponding
40pin 40pin configuration
I2C1_M4 Pin 3 Pin 5 i2c1-m4
I2C4_M3 Pin 27 Pin 28 i2c4-m3
I2C5_M2 Pin 35 Pin 37 i2c5-m2
I2C5_M3 Pin 7 Pin 15 i2c5-m3
I2C8_M2 Pin 33 Pin 32 i2c8-m2

3) In Linux systems, the I2C bus in 40 pins is turned off by default and needs to be
manually turned on to use. The detailed steps are as follows:
a. First, run orangepi-config. Regular users should remember to add sudo
privileges
orangepi@orangepi:~$ sudo orangepi-config
b. Then choose System

321
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

c. Then choose Hardware

d. Then use the directional keys on the keyboard to locate the position shown in the
figure below, and use the space to select the I2C configuration you want to open

a) Then select <Save> to save

e. Then select <Back>

322
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

f. Then select <Reboot> to restart the system for the configuration to take effect

4) After starting the Linux system, first confirm the existence of i2c device nodes in /dev
orangepi@orangepi:~$ ls /dev/i2c-*

5) Then connect an i2c device to the i2c pin of the 40pin connector, here we take the
ds1307 RTC module as an example

6) Then use the i2cdetect -y command, if the address of the connected i2c device can
be detected, it means that i2c can be used normally
orangepi@orangepi:~$ sudo i2cdetect -y 1 #i2c1 command
orangepi@orangepi:~$ sudo i2cdetect -y 4 #i2c4 command
orangepi@orangepi:~$ sudo i2cdetect -y 5 #i2c5 command
orangepi@orangepi:~$ sudo i2cdetect -y 8 #i2c8 command

323
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

7) Then you can run the ds1307.py test program in the examples to read the RTC time
root@orangepi:~/wiringOP-Python# cd examples
root@orangepi:~/wiringOP-Python/examples# python3 ds1307.py --device \
"/dev/i2c-1"
Thu 2023-01-05 14:57:55
Thu 2023-01-05 14:57:56
Thu 2023-01-05 14:57:57
^C
exit
3.20.5. 40pin UART test
1) As can be seen from the following table, there are five uart buses available for Orange
Pi 5 Pro: uart0, uart3, uart4, uart6 and uart7

2) The corresponding pins of the five UART buses in the 40 pin configuration are shown
in the table below
UART Bus RX corresponds to TX corresponds to Dtbo corresponding
40pin 40pin configuration
UART0_M2 Pin 38 Pin 36 uart0-m2
UART3_M2 Pin 37 Pin 40 uart3-m2

324
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

UART4_M0 Pin 3 Pin 5 uart4-m0


UART4_M2 Pin 19 Pin 23 uart4-m2
UART6_M1 Pin 18 Pin 16 uart6-m1
UART7_M2 Pin 24 Pin 26 uart7-m2

3) In Linux systems, UART in 40 pins is turned off by default and needs to be manually
turned on to use. The detailed steps are as follows:
a. First, run orangepi-config. Regular users should remember to add sudo
privileges
orangepi@orangepi:~$ sudo orangepi-config
b. Then choose System

c. Then choose Hardware

d. Then use the directional keys on the keyboard to locate the position shown in the
figure below, and use the space to select the UART configuration you want to
turn on

325
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

e. Then choose <Save> to save

f. Then choose <Back>

g. Then choose <Reboot> to restart the system for the configuration to take effect

4) After entering the linux system, first confirm whether there is a device node
corresponding to uart in /dev
orangepi@orangepi:~$ ls /dev/ttyS*

5) Then start testing the uart interface, first use the DuPont wire to short-circuit the rx
and tx of the uart interface to be tested

326
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

6) Test the loopback function of the serial port using the serialTest.py program in the
examples as shown below. If you can see the print below, it indicates that the serial
communication is normal
/dev/ttySX needs to be replaced with the serial number of the specific uart device node.

root@orangepi:~/wiringOP-Python/examples# python3 serialTest.py --device \


"/dev/ttySX"

Out: 0: -> 0
Out: 1: -> 1
Out: 2: -> 2
Out: 3: -> 3
Out: 4:^C
exit

3.21. Hardware watchdog test

The watchdog_test program is pre-installed in the Linux system released by Orange Pi


and can be tested directly

The method to run the watchdog_test program is as follows:


a. The second parameter 10 represents the counting time of the watchdog. If the
dog is not fed within this time, the system will restart.
b. We can feed the dog by pressing any key on the keyboard (except ESC). After
feeding the dog, the program will print a line of keep alive to indicate that the
dog feeding is successful.
orangepi@orangepi:~$ sudo watchdog_test 10
open success
options is 33152,identity is sunxi-wdt
put_usr return,if 0,success:0
The old reset time is: 16
return ENOTTY,if -1,success:0
return ENOTTY,if -1,success:0
put_user return,if 0,success:0
put_usr return,if 0,success:0
keep alive

327
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

keep alive
keep alive

3.22. Check the serial number of the RK3588S chip

The command to view the serial number of the RK3588S chip is as follows. The serial
number of each chip is different, so the serial number can be used to distinguish multiple
development boards
orangepi@orangepi:~$ cat_serial.sh
Serial : 1404a7682e86830c

3.23. How to install Docker

1) The linux image provided by Orange Pi has Docker pre-installed, but the Docker
service is not turned on by default.

2) Use the enable_docker.sh script to enable the docker service, and then you can start
using the docker command, and the docker service will be automatically started the next
time you start the system.
orangepi@orangepi:~$ enable_docker.sh

3) Then you can use the following command to test docker. If hello-world can be run,
docker can be used normally.
orangepi@orangepi:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
256ab8fe8778: Pull complete
Digest:
sha256:7f0a9f93b4aa3022c3a4c147a449ef11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest

Hello from Docker!


This message shows that your installation appears to be working correctly.
.....

328
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.24. How to download and install arm64 version


balenaEtcher
1) The download address of balenaEtcher arm64 version is
a. The download address of the a.deb installation package is as follows. It needs to
be installed before it can be used
https://github.com/Itai-Nelken/BalenaEtcher-arm/releases/download/v1.7.9/balena-e
tcher-electron_1.7.9+5945ab1f_arm64.deb
b. The download address of the AppImage version that does not require installation
is as follows:
https://github.com/Itai-Nelken/BalenaEtcher-arm/releases/download/v1.7.9/balenaE
tcher-1.7.9+5945ab1f-arm64.AppImage

2) How to install and use deb version balenaEtcher:


a. The installation command for the a.deb version of balenaEtcher is as follows:
orangepi@orangepi:~$ sudo apt install -y \
--fix-broken ./balena-etcher-electron_1.7.9+5945ab1f_arm64.deb
b. After the b.deb version of balenaEtcher is installed, it can be opened in
Application

329
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

c. The interface after opening balenaEtcher is as follows:

3) How to use the AppImage version of balenaEtcher:


a. First add permissions to balenaEtcher
orangepi@orangepi:~/Desktop$ chmod +x balenaEtcher-1.7.9+5945ab1f-arm64.AppImage
b. Then select the AppImage version balenaEtcher, right-click the mouse, and click
Execute to open balenaEtcher

330
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.25. How to install the Pagoda Linux panel

Pagoda Linux panel is a server management software that improves operation


and maintenance efficiency. It supports more than 100 server management functions
such as one-click LAMP/LNMP/cluster/monitoring/website/FTP/database/JAVA
(excerpted from Pagoda official website)

1) The recommended order for Pagoda Linux system compatibility is


Debian11 > Ubuntu 22.04 > Debian12

2) Then enter the following command in the linux system to start the installation of the
pagoda
orangepi@orangepi:~$ sudo install_bt_panel.sh

3) Then the Pagoda installation program will prompt whether to install Bt-Panel to the
/www folder. At this time, enter y
+----------------------------------------------------------------------
| Bt-WebPanel FOR CentOS/Ubuntu/Debian
+----------------------------------------------------------------------
| Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.
+----------------------------------------------------------------------
| The WebPanel URL will be http://SERVER_IP:8888 when installed.
+----------------------------------------------------------------------

Do you want to install Bt-Panel to the /www directory now?(y/n): y

4) The next thing to do is to wait patiently. When you see the terminal outputting the
following print information, it means that the Pagoda has been installed. The entire
installation process takes about 12 minutes. There may be some differences depending on
the network speed.

331
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) At this time, enter the panel address shown above in the browser to open the login
interface of the Pagoda Linux panel, and then enter the username and password shown
above in the corresponding positions to log in to the Pagoda

6) After successfully logging into the Pagoda, the following welcome interface will pop
up. First, please drag the user instructions in the middle to the bottom after reading them.
Then you can select "I have agreed and read the User Agreement", and then click "Enter
Panel" You can enter the pagoda

332
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

7) After entering the pagoda, you will first be prompted to bind an account on the
pagoda's official website. If you don't have an account, you can go to the pagoda's official
website (https://www.bt.cn) to register one.

8) The final displayed interface is as shown in the figure below. You can intuitively see
some status information of the development board's Linux system, such as load status,
CPU usage, memory usage, storage space usage, etc

333
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

9) Test Pagoda’s SSH terminal login


a. After opening the SSH terminal of Pagoda, you will first be prompted to enter
the password of the development board system. At this time, enter orangepi (the
default password, if there is any modification, please fill in the modified one) in
the password box.

b. The display after successful login is as shown below

334
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

10) In Pagoda’s software store, you can install software such as Apache, MySQL, and
PHP, and you can also deploy various applications with one click. Please explore these
functions by yourself, and I will not demonstrate them one by one here

11) Pagoda command line tool test

335
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

12) You can refer to the following information to explore more functions of the pagoda
Manual:http://docs.bt.cn
Forum address:https://www.bt.cn/bbs
GitHub Link:https://github.com/aaPanel/BaoTa

3.26. Set up the Chinese environment and install the Chinese


input method

Note, before installing the Chinese input method, please make sure that the
Linux system used by the development board is the desktop version.
3.26.1. Debian system installation method
1) First set the default locale to Chinese
a. Enter the following command to start configuring locale
orangepi@orangepi:~$ sudo dpkg-reconfigure locales
b. Then select zh_CN.UTF-8 UTF-8 in the pop-up interface (use the up and down

336
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

keys on the keyboard to move up and down, use the space bar to select, and
finally use the Tab key to move the cursor to <OK>, and then return Car is
enough)

c. Then set the default locale to zh_CN.UTF-8

d. After exiting the interface, the locale setting will begin. The output displayed on
the command line is as follows:
orangepi@orangepi:~$ sudo dpkg-reconfigure locales
Generating locales (this might take a while)...
en_US.UTF-8... done
zh_CN.UTF-8... done
Generation complete.

2) Then open Input Method

337
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3) Then select OK

4) Then select Yes

338
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) Then select fcitx

6) Then select OK

7) Then restart the Linux system to make the configuration take effect.

339
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

8) Then ope Fcitx configuration

9) Then click the + sign as shown in the picture below

10) Then search Google Pinyin and click OK

340
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

11) Then put Google Pinyin on top

12) Then open the Geany editor to test the Chinese input method

341
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

13) The Chinese input method test is as follows

14) You can switch between Chinese and English input methods through the Ctrl+Space
shortcut key

15) If you need the entire system to be displayed in Chinese, you can set all variables in
/etc/default/locale to zh_CN.UTF-8
orangepi@orangepi:~$ sudo vim /etc/default/locale
# File generated by update-locale
LC_MESSAGES=zh_CN.UTF-8
LANG=zh_CN.UTF-8

342
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

LANGUAGE=zh_CN.UTF-8

16) Then restart the system and you will see that the system is displayed in Chinese.

3.26.2. Installation method of Ubuntu 20.04 system


1) First open Language Support

343
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

2) Then find the Chinese (China) option

3) Then please use the left button of the mouse to select Chinese (China) and hold it
down, then drag it up to the starting position. After dragging, the display will be as shown
below:

Note that this step is not easy to drag, please be patient and try it a few times.

344
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) Then select Apply System-Wide to apply the Chinese settings to the entire system

5) Then set the Keyboard input method system to fcitx

6) Then restart the Linux system to make the configuration take effect

7) After re-entering the system, please select Do not ask me again in the following
interface, and then please decide according to your own preferences whether the standard

345
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

folder should also be updated to Chinese

8) Then you can see that the desktop is displayed in Chinese

9) Then we can open Geany to test the Chinese input method. The opening method is as
shown in the figure below

346
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

10) After opening Geany, the English input method is still the default. We can switch to
the Chinese input method through the Ctrl+Space shortcut key, and then we can input
Chinese.

3.26.3. Installation method of Ubuntu 22.04 system


1) First open Language Support

347
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

2) Then find the Chinese (China) option

3) Then please use the left button of the mouse to select Chinese (China) and hold it
down, then drag it up to the starting position. After dragging, the display will be as shown
below:

348
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Note that this step is not easy to drag, please be patient and try it a few times.

4) Then select Apply System-Wide to apply the Chinese settings to the entire system

5) Then restart the Linux system to make the configuration take effect

349
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

6) After re-entering the system, please select Do not ask me again on the following
interface, and then please decide whether the standard folder should also be updated to
Chinese according to your own preferences.

7) Then you can see that the desktop is displayed in Chinese

8) Then open the Fcitx5 configuration program

350
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

9) Then choose to use Pinyin input method

10) The interface after selection is as shown below, then click OK

351
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

11) Then we can open Geany to test the Chinese input method. The opening method is
as shown in the figure below

12) After opening Geany, the English input method is still the default. We can switch to
the Chinese input method through the Ctrl+Space shortcut key, and then we can enter
Chinese.

352
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.27. How to remotely log in to the Linux system desktop

The Ubuntu Gnome Wayland image does not support remote login to the
desktop using Nomachine and VNC as described here.
3.27.1. Remote login using NoMachine
Please ensure that the Ubuntu or Debian system installed on the development
board is a desktop version of the system. In addition, NoMachine also provides
detailed usage documentation. It is strongly recommended to read this document
thoroughly to become familiar with the use of NoMachine. The document link is as
follows:
https://knowledgebase.nomachine.com/DT10R00166

NoMachine supports Windows, Mac, Linux, iOS and Android platforms, so we


can remotely log in and control the Orange Pi development board through
NoMachine on a variety of devices. The following demonstrates how to remotely log

353
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

in to the Linux system desktop of the Orange Pi development board through


NoMachine in Windows. For installation methods on other platforms, please refer to
NoMachine’s official documentation.

Before operating, please make sure that the Windwos computer and the
development board are in the same LAN, and that you can log in to the Ubuntu or
Debian system of the development board through ssh normally.

1) First download the installation package of the NoMachine software Linux arm64 deb
version, and then install it into the Linux system of the development board
a. Since RK3588S is an ARMv8 architecture SOC, the system we use is Ubuntu or
Debian, so we need to download the NoMachine for ARM ARMv8 DEB
installation package. The download link is as follows:
Note that this download link may change, please look for the Armv8/Arm64
version of the deb package.
https://downloads.nomachine.com/download/?id=114&distro=ARM

b. In addition, you can also download the NoMachine installation package from
the official tool.

First enter the remote login software-NoMachine folder

354
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Then download the arm64 version of the deb installation package

c. Then upload the downloaded nomachine_x.x.x_x_arm64.deb to the Linux


system of the development board
d. Linux 系 Then use the following command to install NoMachine in the Linux
system of the development board
orangepi@orangepi:~$ sudo dpkg -i nomachine_x.x.x_x_arm64_arm64.deb

2) Then download the installation package of the Windows version of the NoMachine
software. The download address is as follows
Note that this download link may change.
https://downloads.nomachine.com/download/?id=9

3) Then install NoMachine in Windows. Please restart your computer after


installation

4) Then open NoMachine in Window

5) After NoMachine is started, it will automatically scan other devices with NoMachine

355
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

installed on the LAN. After entering the main interface of NoMachine, you can see that
the development board is already in the list of connectable devices, and then click on the
location shown in the red box in the picture below You can now log in to the Linux
system desktop of the development board.

6) Then click OK

7) Then enter the username and password of the development board Linux system in the
corresponding positions in the figure below, and then click OK to start logging in.

8) Then click OK in the next interface.

356
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

9) Finally you can see the desktop of the development board Linux system

3.27.2. Remote login using VNC


Before operating, please make sure that the Windwos computer and the
development board are in the same LAN, and that you can log in to the Ubuntu or
Debian system of the development board through ssh normally.
There are many problems with VNC testing in Ubuntu20.04, please do not use
this method.

1) First run the set_vnc.sh script to set up vnc, remember to add sudo permissions
orangepi@orangepi:~$ sudo set_vnc.sh
You will require a password to access your desktops.

Password: #Set the vnc password here, 8 characters


Verify: #Set the vnc password here, 8 characters
Would you like to enter a view-only password (y/n)? n
xauth: file /root/.Xauthority does not exist

New 'X' desktop is orangepi5pro:1

Creating default startup script /root/.vnc/xstartup


Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Orangepi5pro:1.log

357
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Killing Xtightvnc process ID 3047

New 'X' desktop is orangepi5pro:1

Starting applications specified in /root/.vnc/xstartup


Log file is /root/.vnc/orangepi5pro:1.log

2) The steps to use MobaXterm software to connect to the development board Linux
system desktop are as follows::
a. First click Session, then select VNC, then fill in the IP address and port of the
development board, and finally click OK to confirm.

b. Then enter the VNC password set earlier

c. After successful login, the interface is displayed as shown below, and then you
can remotely operate the desktop of the development board Linux system.

358
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.28. Testing of some programming languages supported by


Linux system

3.28.1. Debian Bullseye system


1) Debian Bullseye is installed with the gcc compilation tool chain by default, which can
directly compile C language programs in the Linux system of the development board.
a. The version of a.gcc is as follows
orangepi@orangepi:~$ gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
b. Write the hello_world.c program in C language
orangepi@orangepi:~$ vim hello_world.c
#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

359
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

return 0;
}
c. Then compile and run hello_world.c
orangepi@orangepi:~$ gcc -o hello_world hello_world.c
orangepi@orangepi:~$ ./hello_world
Hello World!

2) Debian Bullseye has Python3 installed by default


a. The specific version of Python is as follows
orangepi@orangepi:~$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
b. Write the hello_world.py program in Python language
orangepi@orangepi:~$ vim hello_world.py
print('Hello World!')
c. The result of running hello_world.py is as follows
orangepi@orangepi:~$ python3 hello_world.py
Hello World!

3) Debian Bullseye does not install Java compilation tools and operating environment by
default.
a. You can use the following command to install openjdk. The latest version in
Debian Bullseye is openjdk-17
orangepi@orangepi:~$ sudo apt install -y openjdk-17-jdk
b. After installation, you can check the Java version
orangepi@orangepi:~$ java --version
c. Write a hello_world.java of Java version
orangepi@orangepi:~$ vim hello_world.java
public class hello_world
{
public static void main(String[] args)
{
System.out.println("Hello World!");

360
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

}
}
d. Then compile and run hello_world.java
orangepi@orangepi:~$ javac hello_world.java
orangepi@orangepi:~$ java hello_world
Hello World!
3.28.2. Debian Bookworm system
1) Debian Bookworm is installed with the gcc compilation tool chain by default, which
can directly compile C language programs in the Linux system of the development board.
a. The version of gcc is as follows
orangepi@orangepi:~$ gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
b. Write the hello_world.c program in C language
orangepi@orangepi:~$ vim hello_world.c
#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}
c. Then compile and run hello_world.c
orangepi@orangepi:~$ gcc -o hello_world hello_world.c
orangepi@orangepi:~$ ./hello_world
Hello World!

2) Debian Bookworm has Python3 installed by default


a. The specific version of Python is as follows
orangepi@orangepi:~$ python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux

361
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Type "help", "copyright", "credits" or "license" for more information.


>>>
Use the Ctrl+D shortcut key to exit python's interactive mode.
b. Write the hello_world.py program in Python language
orangepi@orangepi:~$ vim hello_world.py
print('Hello World!')
c. The result of running hello_world.py is as follows
orangepi@orangepi:~$ python3 hello_world.py
Hello World!

3) Debian Bookworm does not install Java compilation tools and operating environment
by default.
a. You can use the following command to install openjdk. The latest version in
Debian Bookworm is openjdk-17
orangepi@orangepi:~$ sudo apt install -y openjdk-17-jdk
b. After installation, you can check the Java version.
orangepi@orangepi:~$ java --version
c. Write a Java version of hello_world.java
orangepi@orangepi:~$ vim hello_world.java
public class hello_world
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
d. Then compile and run hello_world.java
orangepi@orangepi:~$ javac hello_world.java
orangepi@orangepi:~$ java hello_world
Hello World!
3.28.3. Ubuntu Focal system
1) Ubuntu Focal is installed with the gcc compilation tool chain by default, which can
directly compile C language programs in the Linux system of the development board.
a. The version of gcc is as follows
orangepi@orangepi:~$ gcc --version

362
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0


Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
b. Write the hello_world.c program in C language
orangepi@orangepi:~$ vim hello_world.c
#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}
c. Then compile and run hello_world.c
orangepi@orangepi:~$ gcc -o hello_world hello_world.c
orangepi@orangepi:~$ ./hello_world
Hello World!

2) Ubuntu Focal has Python3 installed by default


a. The specific version of Python3 is as follows
orangepi@orangepi:~$ python3
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
b. Write the hello_world.py program in Python language
orangepi@orangepi:~$ vim hello_world.py
print('Hello World!')
c. The result of running hello_world.py is as follows
orangepi@orangepi:~$ python3 hello_world.py
Hello World!

3) Ubuntu Focal does not have Java compilation tools and running environment installed

363
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

by default.
a. You can use the following command to install openjdk-17
orangepi@orangepi:~$ sudo apt install -y openjdk-17-jdk
b. After installation, you can check the Java version.
orangepi@orangepi:~$ java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Ubuntu-120.04, mixed mode, sharing)
c. Write a Java version of hello_world.java
orangepi@orangepi:~$ vim hello_world.java
public class hello_world
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
d. Then compile and run hello_world.java
orangepi@orangepi:~$ javac hello_world.java
orangepi@orangepi:~$ java hello_world
Hello World!
3.28.4. Ubuntu Jammy system
4) Ubuntu Jammy is installed with the gcc compilation tool chain by default, which can
directly compile C language programs in the Linux system of the development board.
a. The version of gcc is as follows
orangepi@orangepi:~$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
b. Write the hello_world.c program in C language
orangepi@orangepi:~$ vim hello_world.c
#include <stdio.h>

364
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

int main(void)
{
printf("Hello World!\n");

return 0;
}
c. Then compile and run hello_world.c
orangepi@orangepi:~$ gcc -o hello_world hello_world.c
orangepi@orangepi:~$ ./hello_world
Hello World!

5) Ubuntu Jammy has Python3 installed by default


a. The specific version of Python3 is as follows
orangepi@orangepi:~$ python3
Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
b. Write the hello_world.py program in Python language
orangepi@orangepi:~$ vim hello_world.py
print('Hello World!')
c. The result of running hello_world.py is as follows
orangepi@orangepi:~$ python3 hello_world.py
Hello World!

6) Ubuntu Jammy does not install Java compilation tools and operating environment by
default.
a. You can use the following command to install openjdk-18
orangepi@orangepi:~$ sudo apt install -y openjdk-18-jdk
b. After installation, you can check the Java version.
orangepi@orangepi:~$ java --version
openjdk 18-ea 2022-03-22
OpenJDK Runtime Environment (build 18-ea+36-Ubuntu-1)
OpenJDK 64-Bit Server VM (build 18-ea+36-Ubuntu-1, mixed mode, sharing)
c. Write a Java version of hello_world.java
orangepi@orangepi:~$ vim hello_world.java

365
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

public class hello_world


{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
d. Then compile and run hello_world.java
orangepi@orangepi:~$ javac hello_world.java
orangepi@orangepi:~$ java hello_world
Hello World!

3.29. QT installation method

1) Use the following script to install QT5 and QT Creator


orangepi@orangepi:~$ install_qt.sh

2) After installation, the QT version number will be automatically printed.


a. The qt version that comes with Ubuntu20.04 is 5.12.8
orangepi@orangepi:~$ install_qt.sh
......
QMake version 3.1
Using Qt version 5.12.8 in /usr/lib/aarch64-linux-gnu
b. The QT version that comes with Ubuntu22.04 is 5.15.3
orangepi@orangepi:~$ install_qt.sh
......
QMake version 3.1
Using Qt version 5.15.3 in /usr/lib/aarch64-linux-gnu
c. The QT version that comes with Debian11 is 5.15.2
orangepi@orangepi:~$ install_qt.sh
......
QMake version 3.1
Using Qt version 5.15.2 in /usr/lib/aarch64-linux-gnu
d. The QT version that comes with Debian12 is 5.15.8
orangepi@orangepi:~$ install_qt.sh

366
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

......
QMake version 3.1
Using Qt version 5.15.8 in /usr/lib/aarch64-linux-gnu

3) Then you can see the QT Creator startup icon in Applications

You can also use the following command to open QT Creator


orangepi@orangepi:~$ qtcreator

During the startup process of QT and QT applications, if the following error is


prompted, please ignore it. This error will not affect the operation of the application.

libGL error: failed to create dri screen


libGL error: failed to load driver: rockchip
libGL error: failed to create dri screen
libGL error: failed to load driver: rockchip

4) The interface after QT Creator is opened is as follows

367
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) The version of QT Creator is as follows


a. The default version of QT Creator in Ubuntu20.04 is as follows

b. The default version of QT Creator in Ubuntu22.04 is as follows

c. The default version of QT Creator in Debian11 is as follows

368
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

d. The default version of QT Creator in Debian12 is as follows

6) Then set up QT
a. Open first Help->About Plugins...

b. Then remove the check mark of ClangCodeModel

369
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

c. After setting up, you need to restart QT Creator


d. Then make sure the GCC compiler used by QT Creator. If the default is Clang,
please change it to GCC.
Debian12 please skip this step.

370
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

7) Then you can open a sample code

8) After clicking on the sample code, the corresponding instruction document will
automatically open. You can read the instructions carefully.

371
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

9) Then click Configure Project

10) Then click the green triangle in the lower left corner to compile and run the sample
code

372
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

11) After waiting for a period of time, the interface shown in the figure below will pop
up, which means that QT can compile and run normally.

12) References
https://wiki.qt.io/Install_Qt_5_on_Ubuntu
https://download.qt.io/archive/qtcreator
https://download.qt.io/archive/qt

373
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.30. ROS installation method

3.30.1. How to install ROS 1 Noetic on Ubuntu20.04


1) The currently active version of ROS 1 is as follows, the recommended version is
Noetic Ninjemys

http://docs.ros.org
https://wiki.ros.org/Distributions

2) The link to the official installation documentation of ROS 1 Noetic Ninjemys is as


follows:
http://wiki.ros.org/noetic/Installation/Ubuntu

3) In the official installation documentation of ROS Noetic Ninjemys, Ubuntu


recommends using Ubuntu20.04, so please ensure that the system used by the

374
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

development board is Ubuntu20.04 desktop system.


http://wiki.ros.org/noetic/Installation

4) Then use the script below to install ros1


orangepi@orangepi5pro:~$ install_ros.sh ros1

5) Before using the ROS tool, you first need to initialize rosdep. Then when compiling
the source code, you can quickly install some system dependencies and some core
components in ROS.
Note that when running the following command, you need to ensure that the
development board can access github normally, otherwise an error will be reported
due to network problems.

The install_ros.sh script will try to modify /etc/hosts and automatically run the
following commands. However, this method cannot guarantee that github can be
accessed normally every time. If install_ros.sh prompts the following error after
installing ros1, please find other ways to allow the linux system of the development
board to access github normally, and then manually run the following Order.

https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
ERROR: error loading sources list:
The read operation timed out
orangepi@orangepi:~$ source /opt/ros/noetic/setup.bash
orangepi@orangepi:~$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

375
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

rosdep update
orangepi@orangepi:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index
https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/orangepi/.ros/rosdep/sources.cache

6) Then open a command line terminal window on the desktop, and then use the
test_ros.sh script to start a small turtle routine to test whether ROS can be used normally.
orangepi@orangepi:~$ test_ros.sh

7) After running the test_ros.sh script, a small turtle as shown in the picture below will
pop up.

376
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

8) Then please keep the terminal window you just opened at the top

9) At this time, press the direction keys on the keyboard to control the little turtle to
move up, down, left, and right.

377
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.30.2. How to install ROS 2 Galactic on Ubuntu20.04


1) The currently active version of ROS 2 is as follows, the recommended version is
Galactic Geochelone

378
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

http://docs.ros.org
http://docs.ros.org/en/galactic/Releases.html

2) The link to the official installation documentation of ROS 2 Galactic Geochelone is


as follows:
docs.ros.org/en/galactic/Installation.html
http://docs.ros.org/en/galactic/Installation/Ubuntu-Install-Debians.html

3) In the official installation documentation of ROS 2 Galactic Geochelone,


Ubuntu Linux recommends using Ubuntu20.04, so please ensure that the system
used by the development board is the Ubuntu20.04 desktop system. There are
several ways to install ROS 2. The following demonstrates how to install ROS
2 Galactic Geochelone through Debian packages.

4) Use the install_ros.sh script to install ros2


orangepi@orangepi:~$ install_ros.sh ros2

5) The install_ros.sh script will automatically run the ros2 -h command after installing
ros2. If you can see the following print, it means that the ros2 installation is complete.
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

379
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

optional arguments:
-h, --help show this help message and exit

Commands:
action Various action related sub-commands
bag Various rosbag related sub-commands
component Various component related sub-commands
daemon Various daemon related sub-commands
doctor Check ROS setup and other potential issues
interface Show information about ROS interfaces
launch Run a launch file
lifecycle Various lifecycle related sub-commands
multicast Various multicast related sub-commands
node Various node related sub-commands
param Various param related sub-commands
pkg Various package related sub-commands
run Run a package specific executable
security Various security related sub-commands
service Various service related sub-commands
topic Various topic related sub-commands
wtf Use `wtf` as alias to `doctor`

Call `ros2 <command> -h` for more detailed usage.

6) Then you can use the test_ros.sh script to test whether ROS 2 is installed successfully.
If you can see the following print, it means ROS 2 can run normally.
orangepi@orangepi5pro:~$ test_ros.sh
[INFO] [1671174101.200091527] [talker]: Publishing: 'Hello World: 1'
[INFO] [1671174101.235661048] [listener]: I heard: [Hello World: 1]
[INFO] [1671174102.199572327] [talker]: Publishing: 'Hello World: 2'
[INFO] [1671174102.204196299] [listener]: I heard: [Hello World: 2]
[INFO] [1671174103.199580322] [talker]: Publishing: 'Hello World: 3'
[INFO] [1671174103.204019965] [listener]: I heard: [Hello World: 3]

7) Run the following command to open rviz2

380
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

orangepi@orangepi:~$ source /opt/ros/galactic/setup.bash


orangepi@orangepi:~$ ros2 run rviz2 rviz2

8) For how to use ROS, please refer to the documentation of ROS 2.


http://docs.ros.org/en/galactic/Tutorials.html
3.30.3. How to install ROS 2 Humble on Ubuntu22.04
1) Use the install_ros.sh script to install ros2
orangepi@orangepi:~$ install_ros.sh ros2

2) The install_ros.sh script will automatically run the ros2 -h command after installing
ros2. If you can see the following print, it means that the ros2 installation is complete.
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
-h, --help show this help message and exit

Commands:
action Various action related sub-commands
bag Various rosbag related sub-commands

381
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

component Various component related sub-commands


daemon Various daemon related sub-commands
doctor Check ROS setup and other potential issues
interface Show information about ROS interfaces
launch Run a launch file
lifecycle Various lifecycle related sub-commands
multicast Various multicast related sub-commands
node Various node related sub-commands
param Various param related sub-commands
pkg Various package related sub-commands
run Run a package specific executable
security Various security related sub-commands
service Various service related sub-commands
topic Various topic related sub-commands
wtf Use `wtf` as alias to `doctor`

Call `ros2 <command> -h` for more detailed usage.

3) Then you can use the test_ros.sh script to test whether ROS 2 is successfully installed.
If you can see the following print, it means ROS 2 can run normally.
orangepi@orangepi5pro:~$ test_ros.sh
[INFO] [1671174101.200091527] [talker]: Publishing: 'Hello World: 1'
[INFO] [1671174101.235661048] [listener]: I heard: [Hello World: 1]
[INFO] [1671174102.199572327] [talker]: Publishing: 'Hello World: 2'
[INFO] [1671174102.204196299] [listener]: I heard: [Hello World: 2]
[INFO] [1671174103.199580322] [talker]: Publishing: 'Hello World: 3'
[INFO] [1671174103.204019965] [listener]: I heard: [Hello World: 3]

4) Run the following command to open rviz2


orangepi@orangepi:~$ source /opt/ros/humble/setup.bash
orangepi@orangepi:~$ ros2 run rviz2 rviz2

382
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5) Reference documentation
http://docs.ros.org/en/humble/index.html
http://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html

3.31. How to install kernel header files

1) The Linux image released by OPi comes with the deb package of the kernel header
file by default, and the storage location is /opt/
orangepi@orangepi:~$ ls /opt/linux-headers*
/opt/linux-headers-legacy-rockchip-rk3588_x.x.x_arm64.deb

2) Use the following command to install the deb package of the kernel header file
The name of the kernel header file deb package needs to be replaced with the
actual name, please do not copy it.
orangepi@orangepi:~$ sudo dpkg -i /opt/linux-headers-legacy-rockchip-rk3588_1.x.x_arm64.deb

3) After installation, you can see the folder where the kernel header file is located under
/usr/src.
orangepi@orangepi:~$ ls /usr/src
linux-headers-5.10.160-rockchip-rk3588

383
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) Then you can write a hello kernel module to test the kernel header file
a. First write the code of hello kernel module, as shown below:
orangepi@orangepi:~$ vim hello.c
#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void)


{
printk("Hello Orange Pi -- init\n");

return 0;
}
static void hello_exit(void)
{
printk("Hello Orange Pi -- exit\n");

return;
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
b. Then write the Makefile that compiles the hello kernel module, as shown below:
orangepi@orangepi:~$ vim Makefile
ifneq ($(KERNELRELEASE),)
obj-m:=hello.o
else
KDIR :=/lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
rm -f *.ko *.o *.mod.o *.mod *.symvers *.cmd *.mod.c *.order

384
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

endif
c. Then use the make command to compile the hello kernel module. The output of
the compilation process is as follows:
If you have problems compiling the code you copied here, please download the
source code from the official tool and upload it to the Linux system of the
development board for testing.

orangepi@orangepi:~$ make
make -C /lib/modules/5.10.160-rockchip-rk3588/build M=/home/orangepi modules
make[1]: Entering directory '/usr/src/linux-headers-5.10.160-rockchip-rk3588'
CC [M] /home/orangepi/hello.o
MODPOST /home/orangepi/Module.symvers
CC [M] /home/orangepi/hello.mod.o
LD [M] /home/orangepi/hello.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.10.160-rockchip-rk3588'
d. After compilation, the hello.k kernel module will be generated.
orangepi@orangepi:~$ ls *.ko
hello.ko
e. Use the insmod command to insert the hello.ko kernel module into the kernel.
orangepi@orangepi:~$ sudo insmod hello.ko
f. Then use the demsg command to view the output of the hello.ko kernel module.
If you can see the following output, it means that the hello.ko kernel module is
loaded correctly.
orangepi@orangepi:~$ dmesg | grep "Hello"
[ 2871.893988] Hello Orange Pi -- init
g. Use the rmmod command to uninstall the hello.ko kernel module
orangepi@orangepi:~$ sudo rmmod hello
orangepi@orangepi:~$ dmesg | grep "Hello"
[ 2871.893988] Hello Orange Pi -- init
[ 3173.800892] Hello Orange Pi -- exit

385
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.32. 10.1-inch MIPI LCD screen usage method

3.32.1. 10.1 inch MIPI screen assembly method


1) First prepare the necessary accessories
a. 10.1 inch MIPI LCD display + touch screen

b. Screen adapter board + 31pin to 40pin cable

c. 30pin MIPI cable

d. 12pin touch screen cable

2) Connect the 12pin touch screen cable, 31pin to 40pin cable, and 30pin MIPI cable to
the screen adapter board as shown below. Note that the blue insulated side of the touch
screen cable is facing down, and the insulated side of the other two cables is facing up. ,

386
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

if connected incorrectly, it will cause no display or inability to touch.

3) Place the adapter board connected with the cable on top of the MIPI LCD screen as
shown below, and connect the MIPI LCD screen and the adapter board through a 31pin to
40pin cable.

4) Then connect the touch screen and the adapter board through the 12pin touch screen
cable, paying attention to the orientation of the insulation surface

5) Finally, connect it to the LCD interface of the development board through a 30pin
MIPI cable.

387
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.32.2. How to open the 10.1-inch MIPI LCD screen configuration


1) The Linux image does not have the configuration to open the mipi LCD screen by
default. If you need to use the mipi LCD screen, you need to open it manually.

2) The location of the interface of the mipi lcd screen on the development board is as
shown in the figure below

3) The steps to open mipi lcd configuration are as follows:


a. First run orangepi-config. Ordinary users remember to add sudo permissions.
orangepi@orangepi:~$ sudo orangepi-config
b. Then select System

388
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

c. Then select Hardware

d. Then use the keyboard ’ s arrow keys to locate opi5pro-lcd and then use the
space to select it.

e. Then select <Save>to save

f. Then select <Back>

g. Then select <Reboot> to restart the system to make the configuration take
effect.

389
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

The above settings will eventually add overlays=opi5pro-lcd to


/boot/orangepiEnv.txt. You can check it first after setting it up. If this line of
configuration does not exist, there is something wrong with the settings.
If you find it troublesome to use orangepi-config, you can also use the vim editor
to open /boot/orangepiEnv.txt, and then add the line configuration
overlays=opi5pro-lcd.

orangepi@orangepi:~$ cat /boot/orangepiEnv.txt | grep "lcd"


overlays=opi5pro-lcd #Example configuration

4) After startup, you can see the LCD screen display as follows (default is vertical
screen):

3.32.3. How to rotate the display direction of the server version image
1) Add extraargs=fbcon=rotate: the direction of rotation to /boot/orangepiEnv.txt to
set the direction displayed by the server version of Linux system, where fbcon=rotate:
The following number can be set to:

390
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

a. 0: Normal screen (default is vertical screen)


b. 1:Turn clockwise 90 degrees
c. 2:Flip 180 degrees
d. 3:Rotate 270 degrees clockwise
orangepi@orangepi:~$ sudo vim /boot/orangepiEnv.txt
overlays=lcd1
extraargs=cma=64M fbcon=rotate:3

Note that if the configuration line extraargs=cma=64M is included by default in


/boot/orangepiEnv.txt, the configuration fbcon=rotate:3 can be added to the end of
extraargs=cma=64M (need to be separated by spaces)。

2) Then restart the Linux system and you will see that the direction of the LCD screen
display has rotated.
3.32.4. How to mirror the rotation display and touch direction of the
desktop version
1) First open the Display settings in the linux system

2) Then select the direction you want to rotate in Rotation


a. None: No rotation
b. Left: Rotate 90 degrees to the left
c. Inverted: Flip up and down, equivalent to rotating 180 degrees
d. Right: Rotate 90 degrees to the right

391
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3) Then click Apply

4) Then select Keep this configuration

5) At this point, the screen display has been rotated, and then close the Display program.

6) The above steps will only select the display direction, and will not rotate the touch
direction. Use the set_lcd_rotate.sh script to rotate the touch direction. After this script is
set, it will automatically restart, and then you can test whether the touch can be used

392
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

normally
a. None: No rotation
orangepi@orangepi:~$ set_lcd_rotate.sh none
b. Left: Rotate 90 degrees to the left
orangepi@orangepi:~$ set_lcd_rotate.sh left
c. Inverted: Flip up and down, equivalent to rotating 180 degrees
orangepi@orangepi:~$ set_lcd_rotate.sh inverted
d. Right: Rotate 90 degrees to the right
orangepi@orangepi:~$ set_lcd_rotate.sh right

The set_lcd_rotate.sh script mainly does four things:

1. Rotate the direction of framebuffer display


2. Rotate the direction of touch
3. Turn off the startup logo
4. Restart the system

The direction of rotation touch is achieved by adding the Option


"TransformationMatrix" "x x x x x x x x x" line configuration to
/usr/share/X11/xorg.conf.d/40-libinput.conf. Among them, "x x x x x x x x x" has
different configurations in different directions.

7) Touch to rotate reference material


https://wiki.ubuntu.com/X/InputCoordinateTransformation

3.33. Instructions for using the logo on and off the machine

1) The power on/off logo will only be displayed on the desktop version of the system by
default.

2) Set the bootlogo variable to false in /boot/orangepiEnv.txt to turn off the switch
logo.
orangepi@orangepi:~$ vim /boot/orangepiEnv.txt
verbosity=1

393
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

bootlogo=false

3) Set the bootlogo variable to true in /boot/orangepiEnv.txt to enable the power on/off
logo.
orangepi@orangepi:~$ vim /boot/orangepiEnv.txt
verbosity=1
bootlogo=true

4) The location of the boot logo picture in the Linux system is


/usr/share/plymouth/themes/orangepi/watermark.png

5) After replacing the boot logo image, you need to run the following command to take
effect
orangepi@orangepi:~$ sudo update-initramfs -u

3.34. Testing methods for OV13850 and OV13855 MIPI


cameras

Currently, the development board supports two MIPI cameras, OV13850 and
OV13855. The specific pictures are as follows:
a. OV13850 camera with 13 million MIPI interface

b. OV13855 camera with 13 million MIPI interface

The adapter board and FPC cable used by the OV13850 and OV13855 cameras are

394
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

the same, but the locations where the two cameras are connected to the adapter board are
different. The FPC cable is shown in the figure below. Please note that the FPC cable has
a direction. The end marked TO MB needs to be plugged into the camera interface of the
development board, and the end marked TO CAMERA needs to be plugged into the
camera adapter board.

There are a total of 3 camera interfaces on the camera adapter board, and only one
can be connected and used at the same time, as shown in the figure below, among which:
a. Connect the OV13850 camera to interface 1
b. Connect the OV13855 camera to interface 2
c. Interface No. 3 is not used, just ignore it.

There are a total of 2 camera interfaces on the Orange Pi 5 Pro development board.
We define the positions of Cam1 and Cam2 as shown in the figure below:

The method of plugging the camera into the Cam1 interface of the development

395
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

board is as follows:

The method of plugging the camera into the Cam2 interface of the development
board is as follows:

After connecting the camera to the development board, we can use the following
method to test the camera:
a. First run orangepi-config. Ordinary users remember to add sudo permissions.
orangepi@orangepi:~$ sudo orangepi-config
b. Then select System

c. Then select Hardware

396
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

d. Then use the keyboard's arrow keys to locate the position shown in the figure
below, and then use the space to select the camera you want to open, where
opi5pro-cam1 means using the ov13850 or ov13855 camera in the Cam1
interface of the development board, and opi5pro-cam2 means Use the ov13850
or ov13855 camera in the Cam2 interface of the development board.

e. Then select <Save>to save

f. Then select <Back>

g. Then select <Reboot> restart the system to make the configuration take effect

h. Then open a terminal on the desktop system and run the following script

397
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

orangepi@orangepi:~$ test_camera.sh
i. Then you can see the preview screen of the camera

In addition to a single camera, we can also use two cameras at the same time
(supporting ov13850 and ov13855 mix and match). After connecting the dual cameras,
open the configuration of Cam1+Cam2 through orangepi-config as in the previous steps,
then restart the system, then open the terminal on the desktop and run the test_camera.sh
script to see the previews of the two cameras, as follows As shown in the figure:

398
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

Please refer to the link below for camera dts configuration. You can modify it
yourself if necessary;
https://github.com/orangepi-xunlong/linux-orangepi/blob/orange-pi-5.10-rk35xx/arc
h/arm64/boot/dts/rockchip/rk3588s-orangepi-5-pro-camera1.dtsi

https://github.com/orangepi-xunlong/linux-orangepi/blob/orange-pi-5.10-rk35xx/arc
h/arm64/boot/dts/rockchip/rk3588s-orangepi-5-pro-camera2.dtsi

The configuration of dt overlay is in the following directory:


https://github.com/orangepi-xunlong/linux-orangepi/tree/orange-pi-5.10-rk35xx/arc
h/arm64/boot/dts/rockchip/overlay

3.35. How to use the ZFS file system

3.35.1. How to install ZFS


Before installing zfs, please make sure that the Linux image you are using is the
latest version. In addition, if zfs is already installed in the system, there is no need to
install it again.

Before installing zfs, you first need to install the kernel header files. For how to
install the kernel header files, please refer to the instructions in the section "How to
Install the Kernel Header Files".
In Ubuntu20.04, Ubuntu22.04 and Debian11 systems, zfs cannot be installed directly
through apt. This is because the zfs version in the default apt source is lower than 2.1.6
and is incompatible with the rk linux5.10 kernel. This problem is fixed in zfs 2.1.6 and
later versions.
In order to solve this problem, we provide a deb package of zfs that can be installed
normally, which can be downloaded from the official tool of the development board.
Open the official tool and enter the zfs related deb package folder used by Ubuntu and
Debian systems. You can see three types of deb packages for Ubuntu20.04, Ubuntu22.04
and Debian11. Please download the required version.

399
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

After downloading the corresponding version of the zfs deb package, please upload
them to the Linux system of the development board. For the upload method, please refer
to the instructions in the Methods of Uploading Files to the Development Board Linux
System.
After the upload is completed, use the cd command on the command line of the
development board Linux system to enter the directory of the deb package, and then use
the following command to install the zfs deb package.
orangepi@orangepi:~$ sudo apt install ./*.deb

After the installation is complete, use the following command to see the zfs-related
kernel modules:
orangepi@orangepi:~$ ls /lib/modules/5.10.160-rockchip-rk3588/updates/dkms/
icp.ko spl.ko zavl.ko zcommon.ko zfs.ko zlua.ko znvpair.ko zunicode.ko
zzstd.ko

Then restart the Linux system and you will see that the zfs kernel module will be
automatically loaded.:
orangepi@orangepi:~$ lsmod | grep "zfs"
zfs 2801664 0
zunicode 327680 1 zfs
zzstd 471040 1 zfs
zlua 139264 1 zfs
zcommon 69632 1 zfs
znvpair 61440 2 zfs,zcommon
zavl 16384 1 zfs
icp 221184 1 zfs
spl 77824 6 zfs,icp,zzstd,znvpair,zcommon,zavl

400
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

In Debian12, the default version of zfs is 2.1.11, so we can install zfs directly through
the following command. Again, before installation, you need to ensure that the system
has installed the deb package of the kernel header file.
orangepi@orangepi:~$ sudo apt install -y zfsutils-linux zfs-dkms
3.35.2. How to create a ZFS pool
ZFS is based on storage pools. We can add multiple physical storage devices to
the pool and then allocate storage space from this pool.
The following content is demonstrated based on the development board being
connected to an NVMe SSD and a USB flash drive.

1) First, we can use the lsblk command to view all storage devices on the development
board. Currently, the development board is connected to an NVMe SSD and a USB flash
drive. The output is as follows:

2) Then enter the following command to create a ZFS pool, including two storage
devices: NVMe SSD and USB flash drive.
orangepi@orangepi:~$ sudo zpool create -f pool1 /dev/nvme0n1 /dev/sda

3) Then use the zpool list command to see that the system has created a ZFS pool named
pool1, and the size of ZFS pool pool1 is the size of the NVME SSD plus the size of the
USB flash drive.

401
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) Then execute df -h and you can see that pool1 is mounted to the /pool1 directory.
orangepi@orangepi:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.6G 18M 1.6G 2% /run
/dev/mmcblk0p2 29G 6.0G 22G 22% /
tmpfs 7.7G 46M 7.7G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 7.7G 944K 7.7G 1% /tmp
/dev/mmcblk0p1 1022M 115M 908M 12% /boot
/dev/zram1 188M 4.5M 169M 3% /var/log
tmpfs 1.6G 80K 1.6G 1% /run/user/1000
pool1 489G 9.3M 489G 1% /pool1

5) Use the following command to see that the file system type of pool1 is zfs
orangepi@orangepi:~$ mount | grep pool1
pool1 on /pool1 type zfs (rw,xattr,noacl)

6) Then we can test copying a file to the ZFS pool


orangepi@orangepi:~$ sudo cp -v /usr/local/test.mp4 /pool1/
'/usr/local/test.mp4' -> '/pool1/test.mp4'
3.35.3. Test the data deduplication function of ZFS
1) The data deduplication function of ZFS is turned off by default. We need to execute
the following command to turn it on.
orangepi@orangepi:~$ sudo zfs set dedup=on pool1

2) Then do a simple test, first enter pool1, and then execute the following command to
generate a random file of 1G size
orangepi@orangepi:~$ cd /pool1/
root@orangepi:/pool1$ sudo dd if=/dev/urandom of=test.1g bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 5.04367 s, 213 MB/s

3) Then use the following command to copy 1000 copies of a random file of 1G size
root@orangepi:/pool1$ for ((i=0; i<1000; i++)); do sudo cp test.1g $i.test.1g; done

402
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) Then use du -lh to see that there is currently a total of 1002G of data in the pool, but
in fact the size of the ZFS pool is only 504GB (the total capacity of SSD + U disk),
which cannot hold such large data.
root@orangepi:/pool1$ du -lh
1002G

5) Then use the zpool list command to see that only 1.01G is actually occupied, because
these 1001 files are duplicates, indicating that the data deduplication function is effective.

3.35.4. Test the data compression function of ZFS


1) Because the stored data is different, the disk space saved by compression will also be
different, so we choose to compress a relatively large plain text file for the compression
test. Execute the following command to package the /var/log/ and /etc/ directories. into
tarball
orangepi@orangepi:~$ cd /pool1/
root@orangepi:/pool1$ sudo tar -cf text.tar /var/log/ /etc/

2) Then the file size that can be seen through the ls -lh command and the space occupied
in the ZFS pool are both 27M

3) Then we enable compression in ZFS pool pool1


root@orangepi:/pool1$ sudo zfs set compression=lz4 pool1

4) Then execute the following command again to package the /var/log/ and /etc/
directories into a tar package
root@orangepi:/pool1$ sudo tar -cf text.tar /var/log/ /etc/

5) At this time, you can see that the text.tar file size is still 27M, but it only occupies
9.47M space in the ZFS pool, indicating that the file is compressed.

403
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.36. How to install and use CasaOS

CasaOS is an open source home cloud system based on the Docker ecosystem,
which allows you to run a variety of home applications on your own development
board, such as NAS, home automation, media servers, etc.

3.36.1. CasaOS installation method


1) First you need to install docker. Docker is already pre-installed in the system released
by Orangepi Pi. This step can be skipped. You can use the following command to check
the version of docker installed.
orangepi@orangepi:~$ docker --version
Docker version 24.0.2, build cb74dfc # Output of Ubuntu Jammy system

2) Then enter the following command in the linux system to start the installation of
CasaOS
orangepi@orangepi:~$ curl -fsSL https://get.casaos.io | sudo bash

3) When you see the terminal outputting the following print information, it means that
CasaOS has been installed.

404
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.36.2. How to use CasaOS


1) After installing CasaOS, enter http://the IP address of the development board in the
browser to open CasaOS

2) After opening CasaO, the following welcome interface will pop up. Click "Go" to
proceed to the next step.

3) When you log in to CasaOS for the first time, the login interface is the interface for
setting the account and password. When you log in again, only the interface for entering
the account and password will appear. After setting the account and password, click

405
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

"Create" to proceed to the next step.

4) Click "Accept" directly in the interface below to proceed to the next step.

5) Now enter the main page of CasaOS. There are three icons in the upper left corner for
function settings. On the left is the performance panel, which can display the current time
and status information of CPU, RAM, storage, and network. On the right is the function
panel. It has functions such as search, application recommendation, application store and
file management.

406
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

6) You can click the first icon in the upper left corner to modify the account number and
password

7) You can click the second icon to set basic functions

407
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

8) The third icon in the upper left corner mainly has two functions, namely switching to
command line mode and printing log information. When switching to command line
mode, you need to enter your account and password. The account and password here refer
to the development board. Linux system account and password, the port system defaults
to number 22

9) Then click "Connect" to enter the command line interface:

408
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

10) Another function under the third icon is to print CasaOS logs. Click "Logs" to enter.
The interface is as follows:

11) Click "Widget settings" in the lower left corner to set whether to display the widgets
of the performance panel on the main page.

409
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

12) Click "APP Store" on the main interface to open the app store. Currently, there are a
total of 70+ APPs available in the app store.

13) Here we take Home Assistant as an example to download, find Home Assistant in
the APP Store, and then click the corresponding "install"

410
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

14) After the download is completed, HostAssitant will appear on the main page.

15) Click "Files" in the main interface to open the file system that comes with CasaOS,
and then you can upload and save files.
Please ensure that other devices and the development board are in the same
LAN.

411
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

16) When uploading files, you need to switch to the target folder, then drag the local file
to the indicated area in the picture, or click "Upload or Create" in the upper right corner
to select the file to upload.

412
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

17) If you want to uninstall CasaOS, you can use the following command:
orangepi@orangepi5pro:~$ casaos-uninstall

3.37. Methods of using NPU

3.37.1. Prepare tools


1) A PC with Ubuntu 20.04 operating system installed
According to the official documentation of RKNN-Toolkit2, the current version
of RKNN-Toolkit2 supports the following operating systems:
a. Ubuntu18.04 (x64)
b. Ubuntu20.04 (x64)
c. Ubuntu22.04 (x64)
In this document, we demonstrate using the Ubuntu20.04 (x64) operating
system. Please test other versions of the operating system yourself.

2) An Orange Pi 5 Plus development board with Debian 11 system installed

3) A Type-C interface data cable for using adb function

413
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.37.2. Installing RKNN-Toolkit2 on Ubuntu PC


Toolkit2 is a development kit used on the Ubuntu PC platform. Users can easily
complete functions such as model conversion, inference, and performance
evaluation using the Python interface provided by the tool.

1) On the Ubuntu PC side, open a command-line window and enter the following
command to install python3 and pip3
test@test:~$ sudo apt-get install python3 python3-dev python3-pip

2) You can use the following command to view the installed version of python3
test@test:~$ python3 --version
Python 3.8.10

3) Then enter the following command to install the dependency package of


RKNN-Toolkit2
test@test:~$ sudo apt-get update
test@test:~$ sudo apt-get install libxslt1-dev zlib1g-dev libglib2.0 \
libsm6 libgl1-mesa-glx libprotobuf-dev gcc

4) Then enter the following command to download RKNN-Toolkit2 version 1.5.2


test@test:~$ git clone git clone https://github.com/airockchip/rknn-toolkit2 -b v1.5.2

5) Then enter the following command to install the dependency package for the
corresponding version of python3. This command will use the dependencies listed in the
pip3 installation file requirements_cp38-1.5.2.txt. If the dependency installation is
incomplete, do not specify the installation source and install each package separately.
test@test:~$ pip3 install -r rknn-toolkit2/doc/requirements_cp38-1.5.2.txt -i \

414
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

https://mirror.baidu.com/pypi/simple

6) Then enter the following command to use pip3 to install the RKNN-Toolkit2 package.
After installation, you can use RKNN-Toolkit2
test@test:~$ pip3 install rknn-toolkit2/packages/rknn_toolkit2-1.5.2+b642f30c-cp38-cp38-linux_x86_64.whl

3.37.3. Use RKNN-Toolkit2 for model transformation and model


inference
RKNN-Toolkit2 supports converting models such as Caffe, TensorFlow, Te
nsorFlow Lite, ONNX, DarkNet, PyTorch, etc. into RKNN models, and then r
unning the RKNN models through simulation or using the NPU of the develo
pment board on Ubuntu PC for inference.
The example folder in RKNN-Toolkit2 provides relevant examples to help
users better understand how to operate. We take the ONNX model with yolo
v5 functionality as an example for illustration.

3.37.3.1. Simulating and Running Models on Ubuntu PC

RKNN-Toolkit2 is equipped with a built-in simulator that allows users to


simulate the inference process of models on Rockchip NPU on Ubuntu PC.
This way, both model conversion and inference can be completed on Ubu
ntu PC, helping users test and validate their models faster.

1) First, switch to the rknn-toolkit2/examples/onnx/yolov5 directory


test@test:~$ cd rknn-toolkit2/examples/onnx/yolov5/

2) Then run the test.py script, which first converts the yolov5s_relu.onnx model into an
RKNN model that can be run on the simulator, and then uses the simulator to simulate
and run the model to infer the bus.jpg image in the current directory
test@test:~/rknn-toolkit2/examples/onnx/yolov5$ python3 test.py

3) After the test. py script runs successfully, the following print message will be seen,
indicating that the model has successfully detected four people and a bus in the bus.jpg
image
done
--> Running model

415
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

W inference: The 'data_format' has not been set and defaults is nhwc!
done
class: person, score: 0.884139358997345
box coordinate left,top,right,down: [209.1040009856224, 244.4304337501526, 286.5742521882057,
506.7466902732849]
class: person, score: 0.8676778078079224
box coordinate left,top,right,down: [478.5757632255554, 238.58572268486023, 559.5273861885071,
526.479279756546]
class: person, score: 0.8246847987174988
box coordinate left,top,right,down: [110.57257843017578, 238.58099019527435,
230.54625701904297, 534.0008579492569]
class: person, score: 0.3392542004585266
box coordinate left,top,right,down: [79.96397459506989, 354.9062474966049, 122.13020265102386,
516.2529321908951]
class: bus , score: 0.7012234926223755
box coordinate left,top,right,down: [94.43931484222412, 129.53470361232758, 553.1492471694946,
468.0852304697037]
D NPUTransfer: Transfer client closed, fd = 3

4) The converted model file yolov5s_relu.rknn and the inferred image result result.jpg
are saved in the current directory

5) The result.jpg image shows the object categories and confidence rates detected in the
bus.jpg image using the yolov5s_relu.rknn model

416
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.37.3.2. NPU running model using development board on


Ubuntu PC

RKNN-Toolkit2 provides users with a Python interface for inference using


the NPU of the development board through adb, allowing users to run mode
ls for inference on Ubuntu PC using the NPU of the development board.
In this way, Ubuntu PC can optimize and adjust the model based on its
actual performance when running on the NPU of the development board, usin
g the machine learning library provided by Python.

3.37.3.2.1. Connect adb using Type-C data cable

Operate the development board through adb on Ubuntu PC, please refer to the
section on ADB usage for instructions on how to use adb

417
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.37.3.2.2. Update the rknn_server and librknnrt.so of the


development board

librknnrt.so is a runtime library on the board.


rknn_server is a backend proxy service running on the development boar
d, used to receive protocols transmitted from the PC via USB, execute the co
rresponding interface in the runtime library on the board, and return the res
ults to the PC.

1) First, enter the following command on Ubuntu PC to download RKNPU2 version


1.5.2
test@test:~$ git clone https://github.com/rockchip-linux/rknpu2 -b v1.5.2

2) Then, on the Ubuntu PC side, enter the following command to update the rknn_server
of the development board through the adb tool
test@test:~$ adb push rknpu2/runtime/RK3588/Linux/rknn_server/aarch64/usr/bin/* /usr/bin

3) Then enter the following command on Ubuntu PC to update the librknnrt.so library of
the development board through adb tool
test@test:~$ adb push rknpu2/runtime/RK3588/Linux/librknn_api/aarch64/librknnrt.so /usr/lib

4) Open the terminal of the development board through the adb tool
test@test:~$ adb shell

5) Open the rknn_server service on the development board


root@orangepi:/# sudo restart_rknn.sh
root@orangepi:/# start rknn server,version:1.5.2(8babfeabuild@2023-08-25T10:30:31)
I NPUTransfer: Starting NPU TransferServer,Transfer version 2.1.0(b5861e7@2020-
11-23T11:50:51)

6) You can use the following command to check. If the process ID of rknn_server
appears, it means that rknn_server is already open, and the running environment of the
development board is set up
root@orangepi:/# pgrep rknn_server

418
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3131

3.37.3.2.3. Modify parameters in the example

1) On the Ubuntu PC side, you can view the device ID of the development board
connected to the Ubuntu PC using the following command. This ID will be used below
test@test:~$ adb devices
List of devices attached
4f9f859e5a120324 device

2) Switch to the rknn-toolkit2/examples/onnx/yolov5 directory


test@test:~$ cd rknn-toolkit2/examples/onnx/yolov5/

3) Use Vim editor to modify the test.py file


test@test:~/rknn-toolkit2/examples/onnx/yolov5$ vim test.py

4) In the test.py file, we need to make modifications to the following content:


a. In the preprocessing configuration, modify the target platform to rk3588, so that
the resulting model is an RKNN model suitable for NPU on the RK3588
development board

b. In the initialization running environment, add explanations for the target


platform and device ID. The target platform is rk3588, and the device ID is the
device ID obtained from the development board through adb. The inference
operation of the running model will be performed on the NPU of the RK3588
development board

419
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

c. After modification, save and exit

3.37.3.2.4. Running Examples on Ubuntu PC

1) Enter the following command to run the test.py script, which first converts the
yolov5s_relu.onnx model to an RKNN model, and then loads the model onto the NPU of
the development board to infer the out.jpg image in the current directory
test@test:~/rknn-toolkit2/examples/onnx/yolov5$ python3 test.py

2) Enter the following command to run the test. py script, which first converts the
yolov5s_relu.onnx model to an RKNN model, and then loads the model onto the NPU of
the development board to infer the out.jpg image in the current directory
--> Init runtime environment
I target set by user is: rk3588
I Check RK3588 board npu runtime version
I Starting ntp or adb, target is RK3588
I Device [4f9f859e5a120324] not found in ntb device list.
I Start adb...
I Connect to Device success!
I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0
(b5861e7@2020-11-23T11:50:36)

3) After the test.py script runs successfully, the converted model file yolov5s_relu.rknn
and the inferred image result result.jpg are saved in the current directory

4) The result of running is the same as the section on simulating the running model on
Ubuntu PC

420
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.37.4. Call the C interface to deploy the RKNN model to the


development board and run it
RKNPU2 provides a C programming interface for chip platforms with Ro
ckchip NPU, which can help users deploy RKNN models exported from RKN
N-Toolkit2 and accelerate the implementation of AI applications.
In the example folder of RKNPU2, there are examples of deploying RKN
N models with different functionalities to the development board. We take the
deployment of an RKNN model with yolov5 functionality to the RK3588 Deb
ian 11 platform as an example for illustration.

3.37.4.1. Download Cross Compile Tool

Due to the development board running a Linux system, it is necessary to use


the gcc cross compiler for compilation. Recommend using the gcc-9.3.0-x86_64_a
rrch64-linux-gnu version of gcc
Enter the following command to download this version of gcc. After downloa
ding, you will receive a folder named gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-r
ockchip-linux-gnu
test@test:~$ git clone https://github.com/airockchip/gcc-buildroot-9.3.0-2020.03-x86_64_aarch
64-rockchip-linux-gnu

3.37.4.2. Modify the compilation tool path in the script

1) Switch to the rknpu2/examples/rknn_yolov5_demo directory


test@test:~$ cd ~/rknpu2/examples/rknn_yolov5_demo

2) Modify the contents of the build-linux_RK3588.sh file using the vim editor
test@test:~/rknpu2/examples/rknn_yolov5_demo$ vim build-linux_RK3588.sh

3) In the build-linux_RK3588.sh file, we need to change the value of the variable


TOOL_CAIN to the path of the gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockc
hip-linux-gnu folder. In this way, when running the build-android_RK3588.sh script,
the cross compilation tool in the gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockc
hip-linux-gnu folder will be used for compilation

421
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4) After modification, save and exit

3.37.4.3. Compiling rknn_yolov5_demo

1) Run build-linux_RK3588.sh, which generates a program suitable for the RK3588


development board and capable of running RKNN models for inference through cross
compilation
test@test:~/rknpu2/examples/rknn_yolov5_demo$ sudo apt install cmake
test@test:~/rknpu2/examples/rknn_yolov5_demo$ sudo apt-get install g++-aarch64-linux-gnu
test@test:~/rknpu2/examples/rknn_yolov5_demo$ ./build-linux_RK3588.sh

2) After running build-linux_RK3588.sh, an additional folder named install will appear


in the current directory. The rknn_yoov5_demo_Linux folder in this folder contains
programs generated through cross compilation and related files
test@test:~/rknpu2/examples/rknn_yolov5_demo$ ls install
rknn_yolov5_demo_Linux

3.37.4.4. Deploy rknn_yolov5_demo to the development


board

On the Ubuntu PC side, the following command can be used to upload the r
knn_yolov5_demo_Linux folder to the development board through the adb tool, the
reby achieving the deployment of rknn_yolov5_demo on the development board
test@test:~/rknpu2/examples/rknn_yolov5_demo$ adb push \
install/rknn_yolov5_demo_Linux /data/rknn_yolov5_demo_Linux

422
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.37.4.5. Running rknn_yolov5_demo on the development


board

1) Accessing the file system of the development board through adb shell on Ubuntu PC
test@test:~$ adb shell
root@orangepi:/#

2) Switch to the rknn_yolov5_demo_Linux directory


root@orangepi:/# cd /data/rknn_yolov5_demo_Linux/
root@orangepi:/data/rknn_yolov5_demo_Linux# ls
lib model rknn_yolov5_demo rknn_yolov5_video_demo

3) Then run the rknn_yolov5_demo program for inference. In the following command,
the program uses the yolov5s-640-640.rknn model to infer bus.jpg images. The entire
running process will be completed on the development board
root@orangepi:/data/rknn_yolov5_demo_Linux# ./rknn_yolov5_demo \
./model/RK3588/yolov5s-640-640.rknn ./model/bus.jpg

4) After running, the inference result out.jpg image is saved in the current directory
root@orangepi:/data/rknn_yolov5_demo_Linux# ls
lib model out.jpg rknn_yolov5_demo rknn_yolov5_video_demo

5) On the Ubuntu PC side, we can use the following command to download out.jpg
images through the adb tool, and then use an image viewer to view them
test@test:~$ adb pull /data/rknn_yolov5_demo_Linux/out.jpg ~/Desktop/
/data/rknn_yolov5_demo_Linux/out.jpg: ...led. 1.9 MB/s (191507 bytes in 0.095s)

6) The out.jpg image shows the object categories and confidence rates detected in the
bus.jpg image using the yolov5s-640-640.rknn model

423
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.38. RK3588 method of using PaddlePaddle

Using PaddlePaddle on the rk3588 development board, including converting


the pdmodel model to the rknn model on the PC and deploying the rknn model on
the board using PaddlePaddle FastDeploy deployment tool. The following content
was implemented in an environment with Ubuntu22.04 on the PC side and Debian
11 on the board side. Please test it yourself in other environments.
3.38.1. Ubuntu PC environment setup
The tools and purposes that need to be installed on Ubuntu PC are as follows
Tool Name Purpose
Used for creating and managing Python
Anaconda3
environments
Used to convert pdmodel model to
Paddle2ONNX
ONNX model
Used to convert ONNX models to RKNN
RKNN-Toolkit2
models

3.38.1.1. Installing Anaconda3 on PC

1)Open a browser on Ubuntu PC and enter the following URL in the address bar to

424
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

download and install the Anaconda3 script. After downloading, you will receive the
Anaconda3-2023.07-1-Linux-x86_64.sh file
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.07-1-Linux
-x86_64.sh

2)Then open the terminal and run the Anaconda3-2023.07-1-Linux-x86_64.sh script to


install Anaconda3
test@test:~/Downloads$ sh Anaconda3-2023.07-1-Linux-x86_64.sh

3)Then the installation script will output the following prompt message. Click the enter
key to continue the installation

4)After clicking the enter key, some introduction information about Anaconda3 will
appear. Keep clicking the "↓" key

425
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

5)Then the installation script will prompt whether to accept the license terms. At this
point, enter yes and press enter to proceed

6)Then the installation script will remind you to install Anaconda3 to your home
directory. Press Enter to confirm

426
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

7)Then the installation script will prompt whether to initialize Anaconda3. Enter yes
and press enter

8)When the following print appears on the terminal, it indicates that Anaconda3 has
been successfully installed

3.38.1.2. PC installation of RKNN-Toolkit2

1)Open the terminal on Ubuntu PC and create an environment with Python version 3.8
using Anaconda3 tool
(base)test@test:~$ conda create -n fastdeploy python=3.8

2)Activate the environment of python3.8 that was just created


(base)test@test:~$ conda activate fastdeploy

3)Then install the pip3 development tool and package management tool
(fastdeploy)test@test:~$ sudo apt-get install python3-dev python3-pip

427
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

4)Then install the dependency package for RKNN-Toolkit2


(fastdeploy)test@test:~$ sudo apt-get install libxslt1-dev zlib1g-dev libglib2.0 libs
m6 libgl1-mesa-glx libprotobuf-dev gcc

5)rknn_toolkit2 has a specific dependency on numpy, so numpy==1.16.6 needs to be


installed first
(fastdeploy)test@test:~$ pip install numpy==1.16.6

6)Install git tools


(fastdeploy)test@test:~$ sudo apt install git

7)Then execute the following command to download RKNN-Toolkit2. After


downloading, you will receive the rknn-toolkit2 folder
(fastdeploy)test@test:~$ git clone https://github.com/rockchip-linux/rknn-toolkit2

8)Then execute the following command to install RKNN-Toolkit2 corresponding to


Python 3.8 version
(fastdeploy)test@test:~$ pip install rknn-toolkit2/rknn-toolkit2/packages/rknn_tool
kit2-1.6.0+81f21f4d-cp38-cp38-linux_x86_64.whl

3.38.1.3. Installing Paddle2ONNX on PC

You can execute the following command to install paddle2onnx


(fastdeploy)test@test:~$ pip install paddle2onnx
3.38.2. Board end environment setup
The tools and purposes that need to be installed at the board end are as follows
Tool Name Purpose
Used for creating and managing Python
Anaconda3
environments
rknpu2 The basic driver of rknpu2
Compile to obtain FastDeploy inference
FastDeploy
library

428
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

3.38.2.1. Board end installation of Anaconda3

1)Open a browser on the board and enter the following URL in the address bar to
download and install the Anaconda3 script. After downloading, you will receive the
Anaconda3-2023.07-1-Linux-aarch64.sh
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.07-1-Linux
-aarch64.sh

2)Open the terminal and run the Anaconda3-2023.07-1-Linux-aarch64.sh script to


install Anaconda3
orangepi@orangepi:~/Downloads$ sh Anaconda3-2023.07-1-Linux-aarch64.sh

3)Then the installation script will output the following prompt message, click enter to
continue the installation

4)After clicking the enter key, some introduction information about Anaconda3 will
appear. Keep clicking the "↓" key

5)Then the installation script will prompt whether to accept the license terms. At this
point, enter 'yes' and press enter to proceed

429
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

6)Then the installation script will remind you to install Anaconda3 to your home
directory. Press Enter to confirm

7)Then the installation script will prompt whether to initialize Anaconda3. Enter yes
and press enter

8)When the following print appears on the terminal, it indicates that Anaconda3 has
been successfully installed

9)If you use the conda command on the terminal and it shows that the command does
not exist, you need to modify the ~/.bashrc file
orangepi@orangepi:~$ vi ~/.bashrc

10)Add the following code at the end of the ~/.bashrc file


export PATH=/home/orangepi/anaconda3/bin:$PATH

11)Then enter the following command in the terminal to make the previous
modification effective
orangepi@orangepi:~$ source ~/.bashrc

12)Then enter the following command in the terminal to initialize conda


(base)orangepi@orangepi:~$ conda init bash

430
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

13)Then close the current terminal and reopen another terminal, and you can use the
conda command normally now

3.38.2.2. Board end installation of rknpu2 driver

1)Open the terminal on the board and create an environment with python version 3.9
using the Anaconda3 tool
(base)orangepi@orangepi:~$ conda create -n fastdeploy python=3.9

2)Activate the environment of python3.9 that was just created


(base)orangepi@orangepi:~$ conda activate fastdeploy

3)Download the rknpu2_device_install_1.4.0.zip file through wget


(fastdeploy)orangepi@orangepi:~$ wget https://bj.bcebos.com/fastdeploy/third_libs/r
knpu2_device_install_1.4.0.zip

4)Then the following command is executed to decompress


rknpu2_device_install_1.4.0.zip, which will result in the rknpu2_device_install_1.4.0
folder and the __MACOSX folder
(fastdeploy)orangepi@orangepi:~$ unzip rknpu2_device_install_1.4.0.zip

5)Switch to the directory rknpu2_device_install_1.4.0


(fastdeploy)orangepi@orangepi:~$ cd rknpu2_device_install_1.4.0/

6)There is the rknn_install_rk3588.sh script in this directory. Running this script will
complete the installation of the rknpu2 driver on the board
(fastdeploy)orangepi@orangepi:~/rknpu2_device_install_1.4.0$ sudo bash rknn_install_r
k3588.sh

3.38.2.3. Board side compilation FastDeploy C++ SDK

1)During compilation, the cmake command is required. You can execute the following
command to install the cmake tool
(fastdeploy)orangepi@orangepi:~$ sudo apt-get install -y cmake

431
range Pi User Manual Copyright reserved by Shenzhen Xunlong Software Co., Ltd

2)Then download the FastDeploy SDK, and after the command is executed, you will
receive the FastDeploy folder
(fastdeploy)orangepi@orangepi:~$ git clone https://github.com/PaddlePaddle/FastD
eploy.git

3)Switch to FastDeploy directory


(fastdeploy)orangepi@orangepi:~$ cd FastDeploy

4)Create the build directory and switch to the build directory


(fastdeploy)orangepi@orangepi:~/FastDeploy$ mkdir build && cd build

5)Before compilation, cmake needs to be used to configure the project information that
needs to be compiled. After executing the following command, some additional files will
appear in the current directory, including the Makefile file file used for compilation
(fastdeploy)orangepi@orangepi:~/FastDeploy/build$ cmake .. -DENABLE_ORT_BACKEND=ON \
-DENABLE_RKNPU2_BACKEND=ON \
-DENABLE_VISION=ON \
-DRKNN2_TARGET_SOC=RK3588 \
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-0.0.3

6)Execute the following command to start compiling


(fastdeploy)orangepi@orangepi:~/FastDeploy/build$ make -j8

7)After compilation, use the following command to install the compiled file to the
specified path
(fastdeploy)orangepi@orangepi:~/FastDeploy/build$ make install

8)After the compilation is completed, the main folder obtained is fastdeploy-0.0.3. In


this folder, there is a script file called fastdeploy_init.sh for configuring environment
variables. After using this script to configure environment variables, you can use some of
the compiled library files
(fastdeploy)orangepi@orangepi:~/FastDeploy/build$ source fastdeploy-0.0.3/fastdeploy_init.sh
3.38.3. Deploying Model Example with FastDeploy
The ResNet50_vd model is a model used for object classification. Taking the
ResNet50_vd model as an example, we will explain the process of deploying the

432

You might also like