OrangePiZero2 UserManual

88
Orange Pi Zero 2 User Manual

Transcript of OrangePiZero2 UserManual

Page 1: OrangePiZero2 UserManual

Orange Pi Zero 2User Manual

Page 2: OrangePiZero2 UserManual

1

Content

1. Basic features of Orange Pi Zero 2.................................................................................................. 31.1. What is Orange Pi Zero 2?.................................................................................................31.2. The uses of Orange Pi Zero 2...............................................................................................31.3. Who’s it for?.........................................................................................................................31.4. Hardware Specification of Orange Pi Zero 2.......................................................................41.5. Top and bottom views of Orange Pi Zero 2.........................................................................51.6. Orange Pi Zero 2 interface details....................................................................................... 6

2. Introduction to the use of the development board.......................................................................... 72.1. Prepare the necessary accessories........................................................................................72.2. Download the image and relevant documents...................................................................102.3. Method to flash Linux image to MicroSD card based on Windows PC........................... 112.4. Method to flash Linux image to MicroSD card based on Ubuntu PC.............................. 132.5. Method of flashing Android firmware to MicroSD card...................................................152.6. Start the Orange Pi development board.............................................................................182.7. How to use the debug serial port?......................................................................................19

2.7.1. Debug serial port connection instructions.............................................................. 192.7.2. How to use the debug serial port on the Ubuntu platform?....................................202.7.3. How to use the debug serial port on the Windows platform?................................ 22

3. Linux OS instructions....................................................................................................................253.1. Supported Linux distribution types and kernel versions................................................... 253.2. linux4.9 kernel driver adaptation status.............................................................................253.3. Linux OS default login account and password..................................................................253.4. Onboard LED light display description.............................................................................253.5. Instructions for the automatic login of Linux desktop version OS................................... 263.6. Start the rootfs in the auto-expanding TF card for the first time.......................................273.7. How to modify the linux log level (loglevel)?...................................................................273.8. Ethernet port test................................................................................................................ 283.9. SSH remote login development board...............................................................................29

3.9.1. SSH remote login development board under Ubuntu.............................................293.9.2. SSH remote login development board under Windows......................................... 30

3.10. HDMI display test............................................................................................................313.11. HDMI resolution setting.................................................................................................. 313.12. How to modify the width and height of Framebuffer?..................................................323.13. WIFI connection test........................................................................................................34

3.13.1. Test method of Linux server version image......................................................... 343.13.2. Test method of Linux desktop version image.......................................................37

3.14. How to use Bluetooth?...................................................................................................393.14.1. Test method of desktop version image................................................................. 393.14.2. How to use the server version image?................................................................42

3.15. USB interface test............................................................................................................ 44

Page 3: OrangePiZero2 UserManual

2

3.15.1. Connect mouse or keyboard test...........................................................................443.15.2. Connect USB storage device test..........................................................................44

3.16. USB camera test...............................................................................................................453.17. 13 Pin transfer board interface pin description................................................................473.18. Audio test..........................................................................................................................48

3.18.1. Headphone jack play audio test............................................................................ 483.18.2. HDMI audio playback test....................................................................................50

3.19. IR receiving test............................................................................................................... 503.20. Hardware watchdog test...................................................................................................513.21. Temperature sensor.......................................................................................................... 523.22. How to install Docker...................................................................................................... 533.23. 26pins GPIO, I2C, UART, SPI test..................................................................................54

3.23.1. 26 Pins description................................................................................................543.23.2. Install wiringOP....................................................................................................543.23.3. Test common GPIO port....................................................................................... 553.23.4. SPI test.................................................................................................................. 573.23.5. I2C test.................................................................................................................. 583.23.6. UART test..............................................................................................................59

3.24. Method of redirecting kernel console output to serial port ttyS5....................................603.25. SPI Nor Flash test............................................................................................................ 61

4. Linux SDK instructions.................................................................................................................634.1. Get the source code of Linux SDK....................................................................................634.2. Download the compilation toolchain.................................................................................644.3. Compile u-boot...................................................................................................................654.4. Compile the Linux kernel.................................................................................................. 694.5. Compile rootfs....................................................................................................................734.6. Compile linux image..........................................................................................................75

5. Android OS instructions................................................................................................................ 775.1. Supported Android version................................................................................................ 775.2. Android 10 feature adaptation............................................................................................775.3. Onboard LED light display description.............................................................................785.4. How to use ADB?...............................................................................................................78

5.4.1. Open USB debugging option..................................................................................785.4.2. Use data cable to connect adb debugging...............................................................795.4.3. Use network connection adb debugging.................................................................80

5.5. How to use a USB camera................................................................................................. 815.6. Android OS ROOT description..........................................................................................82

6. Android SDK instructions.............................................................................................................846.1. Download the source code of android SDK...................................................................... 846.2. Build android compilation environment............................................................................856.3. Compile android image......................................................................................................86

6.3.1. Compile the kernel..................................................................................................866.3.2. Compile android source code................................................................................. 87

Page 4: OrangePiZero2 UserManual

3

1. Basic features of Orange Pi Zero 2

1.1. What is Orange Pi Zero 2?

Orange Pi is an open-source single board computer, a new generation of ARM64development board, which can run OS such as Android 10.0, Ubuntu and Debian, andso on. Orange Pi Zero 2 uses the Allwinner H616 system-on-chip and has512MB/1GB DDR3 memory

1.2. The uses of Orange Pi Zero 2

We can use it to build:

●A computer●Awireless server●Games●Music and Sounds●HD video●A Speaker......

Pretty much anything else, because Orange Pi Zero2 is open source

1.3. Who’s it for?

Orange Pi Zero 2 is for anyone who wants to start creating with technology – not justconsuming it. It's a simple, fun, useful tool that you can use to start taking control ofthe world around you.

Page 5: OrangePiZero2 UserManual

4

1.4. Hardware Specification of Orange Pi Zero 2

Hardware Specification

CPU Allwinner H616 64-bit 1.5GHz high-performance Quad-core Cortex-A53 processor

GPU Mali G31 MP2Supports OpenGL ES 1.0/2.0/3.2、OpenCL 2.0

Memory(SDRAM) 512MB/1GB DDR3 (Shared with GPU)

Onboard Storage MicroSD card slot、2MB SPI Flash

Onboard Network Support 1000M/100M/10M Ethernet

Onboard WIFI+BT• AW859A Chip• Support IEEE 802.11 a/b/g/n/ac• Support BT5.0

Video Outputs• Micro HDMI 2.0a up to 4K@60fps• TV CVBS output, Support PAL/NTSC ( Via 13pin interfaceboard)

Audio output • Micro HDMI• 3.5mm audio port (Via 13pin interface board)

Power Source Type-C interface 5V/2A input

USB 2.0 Ports 3*USB 2.0 HOST(Two of them are via 13pin interface board)

26pin header with I2C, SPI, UART and multiple GPIO ports

13pin header with 2*USB Host, IR pin, Tv-out、Audio (no MIC) and 3 GPIOports

Debug serial port UART-TX、UART-RX and GND

LED Power led & Status led

IR receiver Support IR remote control (via 13pin interface board)

Supported OS Android10.0、Ubuntu、Debian

Appearance specification

Dimension 85mm×56mm

Weight 30g

range Pi™ is a trademark of the Shenzhen Xunlong Software CO., Limited

Page 6: OrangePiZero2 UserManual

5

1.5. Top and bottom views of Orange Pi Zero 2

Top view

Bottom view:

Page 7: OrangePiZero2 UserManual

6

1.6. Orange Pi Zero 2 interface details

Page 8: OrangePiZero2 UserManual

7

2. Introduction to the use of the development board

2.1. Prepare the necessary accessories

1) MicroSD card, a high-speed card above class 10 with a minimum capacity of 8GB,it is recommended to use SanDisk’s MicroSD card. Orange Pi uses SanDisk’sMicroSD card with all the tests. Other brands of TF cards may cause the OS to fail tostart.

2) TF card reader used to read and write MicroSD card

3) Micro HDMI to HDMI cable used to connect the development board to an HDMImonitor or TV for display

Page 9: OrangePiZero2 UserManual

8

4) Power Supply: Using a USB Type C interface data cable and a 5V/2A or 5V/3Ahigh-quality power adapter

5) 13-Pin expansion boarda. The expansion board is as shown in the following picture

b. The 13-Pin header on the Orange Pi Zero 2 development board can beconnected to an expansion board to expand the functions that are not on thedevelopment board. The expansion board includes functions

1 MIC Not Support2 Analog audio and

video output interfaceCan be used to connect headphones to play music,or connect to the TV through AV cable to outputanalog audio and video signals (Android OS only)

3 USB2.0 x 2 Used to connect USB keyboard, mouse and USBstorage device

4 IR function Android OS can be controlled by IR remote controlc. The schematic diagram of the 13-Pin header on the Orange Pi Zero 2

development board is shown below

Page 10: OrangePiZero2 UserManual

9

6) USB mouse and keyboard, as long as it is a standard USB mouse and keyboard, themouse and keyboard can be used to control the Orange Pi development board

7) IR remote control mainly used to control the Android OS

8) 100M or 1000M network cable used to connect the development board to theInternet

9) AV cable, if you want to display video through the CVBS interface instead ofHDMI interface, then you need to connect the development board to the TV throughthe AV cable

10) USB to TTL module and DuPont cable. When using the serial port debugging

Page 11: OrangePiZero2 UserManual

10

function, you need USB to TTL module and DuPont cable to connect the developmentboard and the computer

11) A personal computer with Ubuntu and Windows operating OS1 Ubuntu14.04 PC Optional, used to compile Android source code2 Ubuntu18.04 PC Optional, used to compile Linux source code3 Windows PC Used to flash Android and Linux images

2.2. Download the image and relevant documents

1) The download URL of the Chinese version ishttp://www.orangepi.cn/downloadresourcescn/

2) The download URL of the English version ishttp://www.orangepi.org/downloadresources/

3) The information mainly containsa. Android source code: saved on Baidu Cloud Disk and Google Cloud Diskb. Linux source code: saved on GitHub, the link URL is

https://github.com/orangepi-xunlong/orangepi-buildc. User manual and schematic diagram: chip related data manual will also be

placed here

Page 12: OrangePiZero2 UserManual

11

d. Official tools: mainly include the software needed during the use of thedevelopment board

e. Android image: saved on Baidu Cloud Disk and Google Cloud Diskf. Ubuntu image: saved on Baidu Cloud Disk and Google Cloud Diskg. Debian image: saved on Baidu Cloud Disk and Google Cloud Disk

2.3. Method to flash Linux image to MicroSD card based on

Windows PC

1) First, prepare a MicroSD card with 8GB or larger capacity. The transmission speedof the MicroSD card must be above class10. It is recommended to use a brandMicroSD card such as SanDisk.

2) Then use a card reader to insert the MicroSD card into the computer

3) Then format the MicroSD carda. You can use the SD Card Formatter software to format the MicroSD card, the

download URL ishttps://www.sdcard.org/downloads/formatter/eula_windows/SDCardFormatterv5_WinEN.zip

b. After downloading, just unzip and install, then open the software

c. If the computer has only inserted a MicroSD card, the “Select card” columnwill display the drive letter of the MicroSD card. If the computer has multipleUSB storage devices inserted, you can select the drive letter corresponding tothe MicroSD card through the drop-down box

d. Then click "Format", a warning box will pop up before formatting, andformatting will start after selecting "Yes (Y)"

Page 13: OrangePiZero2 UserManual

12

e. After formatting the MicroSD card, the message shown below will pop up,click OK

4) Download the Linux operating OS image file compression package you want toflash from download page of the Orange Pi official website, and then use thedecompression software to decompress it. In the decompressed file, the file endingwith ".img" is the operating OS image file, with a normal size Are above 1GB

5) Use Win32Diskimager to burn Linux image to MicroSD carda. The download page of Win32Diskimager is

http://sourceforge.net/projects/win32diskimager/files/Archive/

b. Install directly after downloading, the Win32Diskimager interface is shownbelowa) First, select the path of the image fileb) Then confirm that the drive letter of the MicroSD card is consistent with

the one displayed in the "Device" columnc) Finally, click "write" to start flash

Page 14: OrangePiZero2 UserManual

13

c. After the image is written, click the "Exit" button to exit, and then you canpull out the MicroSD card and insert it into the development board to boot

2.4. Method to flash Linux image to MicroSD card based on

Ubuntu PC

1) First, prepare a Micro card with 8GB or larger capacity. The transmission speed ofthe MicroSD card must be above class10. It is recommended to use a brand MicroSDcard such as SanDisk.

2) Then use a card reader to insert the MicroSD card into the computer

3) Download balenaEtcher software, the download URL ishttps://www.balena.io/etcher/

4) After entering the balenaEtcher download page, please select the Linux version ofthe software through the drop-down box to download

Page 15: OrangePiZero2 UserManual

14

5) After downloading, use unzip to decompress. The decompressed balenaEtcher-1.5.109-x64.AppImage is the software needed to burn Linux imagetest@test:~$ unzip balena-etcher-electron-1.5.109-linux-x64.zipArchive: balena-etcher-electron-1.5.109-linux-x64.zipinflating: balenaEtcher-1.5.109-x64.AppImagetest@test:~$ lsbalenaEtcher-1.5.109-x64.AppImage balena-etcher-electron-1.5.109-linux-x64.zip

6) Download the Linux operating OS image file compression package you want toburn from the Orange Pi data download page, and then use the decompressionsoftware to decompress it. In the decompressed file, the file ending with ".img" is theoperating OS image file. The size is generally above 1GB

a. The decompression command of the compressed package at the end of 7z isas follows:

test@test:~$ 7z x Orangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.7ztest@test:~$ ls Orangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.*Orangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.7zOrangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.img.sha # Checksum fileOrangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.img #Image file

7) After decompressing the image, you can first use the sha256sum -c *.sha commandto calculate whether the checksum is correct. If the prompt is successful, it means thatthe downloaded image is correct, and you can safely flash it to the MicroSD card. Ifthe checksum does not match, it means there is a problem with the downloaded image,please try to download againtest@test:~$ sha256sum -c *.shaOrangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.img: success

8) Then double-click balenaEtcher-1.5.109-x64.AppImage on the graphical interfaceof Ubuntu PC to open balenaEtcher (no installation required), the opened interface isas shown in the figure below

a. First, select the path of the Linux image fileb. Then select the device number of the TF cardc. Finally, click Flash to start burning

Page 16: OrangePiZero2 UserManual

15

9) The writing process will prompt the writing speed and remaining time

10) After burning, the following interface will be displayed, then you can unplug theMicroSD card from the computer and insert it into the development board to start

2.5. Method of flashing Android firmware to MicroSD card

The Android image can only be flashed to MicroSD card using PhoenixCard

Page 17: OrangePiZero2 UserManual

16

software under the Windows platform, but cannot be burned under Linuxplatform

1) First, prepare a MicroSD card with 8GB or larger capacity. The transmission speedof the TF card must be above class10. It is recommended to use a brand MicroSDcard such as SanDisk.

2) Then use a card reader to insert the MicroSD card into the computer

3) Download the Android 10 OS and PhoenixCard flashing tool from Orange Pi's datadownload page. Please make sure that the PhonenixCard tool version isPhonenixCard-v4.2.3. Tools below this version will have problems flashing to theAndroid 10 OS.

4) Use the decompression software to decompress the downloaded Android OScompressed package. In the decompressed file, the file ending with ".img" is theAndroid image file

5) Use decompression software to decompress PhonenixCard-v4.2.3.zip, this softwaredoes not need to be installed, you can find PhoenixCard in the decompressed folderand open it

6) After opening PhoenixCard, if the MicroSD card is recognized normally, the driveletter and capacity of the MicroSD card will be displayed in the middle list. Pleasemake sure that the displayed drive letter is consistent with the drive letter of theMicroSD card you want to burn. If there is no display, you can try to remove andinsert the MicroSD card, or click the Refresh Drive letter button in PhoenixCard

7)After confirming the drive letter, format the MicroSD card first, click the "Restore"button in PhoenixCard, or use the aforementioned SD Card Formatter to format the

Page 18: OrangePiZero2 UserManual

17

MicroSD card

8) Then start to write the Android OS to MicroSD carda. First, select the path of the Android image in the "Image" columnb. Select "Start up" in "Type of Making Card"c. Then click the "Burn" button to start burning

Page 19: OrangePiZero2 UserManual

18

9)After burning, the PhoenixCard will display as shown in the figure below. At thistime, click the "Close" button to exit PhoenixCard, and then you can unplug theMicroSD card from the computer and insert it into the development board to start

2.6. Start the Orange Pi development board

1) Insert MicroSD card with well-flashed image into the MicroSD card slot of theOrange Pi development board2) The development board has a Micro HDMI interface, you can connect thedevelopment board to a TV or HDMI display through a Micro HDMI to HDMI cable3) Connect the USB mouse and keyboard to control the Orange Pi development board4) The development board has an Ethernet port, which can be plugged into thenetwork cable for Internet access5) A high-quality power adapter with a 5V/2A (5V/3A is also available) USB Type Cinterface

a. Remember not to plug in the 12V power adapter, if you plug in the12V power adapter, it will burn the development board

b. Many unstable phenomena during OS power-on and startup arecaused by power supply problems, so a reliable power adapter and USBType C data cable are very important

6) Then turn on the power adapter switch, if everything is normal, the HDMI display

Page 20: OrangePiZero2 UserManual

19

can see the OS startup screen at this time

7) If you want to view the output information of the OS through the debug serial port,please use the serial cable to connect the development board to the computer. For theconnection method of the serial port, please refer to the section on the use of thedebug serial port

2.7. How to use the debug serial port?

2.7.1. Debug serial port connection instructions1) First, you need to prepare a USB to TTL module. This module can be bought inOrange Pi stores. If there are other similar USB to TTL modules, you can also insertthe USB end of the USB to TTL module into the USB port of the computer

2) The corresponding relationship between the debug serial port GND, TX, and RXpins of the development board is shown in the figure below

3) The GND, TX, and RX pins of the USB to TTL module need to be connected to thedebug serial port of the development board through a Dupont cable

a. Connect the GND of the USB to TTL module to the GND of the boardb. Connect the RX of the USB to TTL module to the TXD of the boardc. Connect the TX of the USB to TTL module to the RX of the board

4) The schematic diagram of connecting the USB to TTL module to the computer andthe Orange Pi development board is shown below

Page 21: OrangePiZero2 UserManual

20

2.7.2. How to use the debug serial port on the Ubuntu platform?1) If the USB to TTL module is connected normally, you can see the correspondingdevice node name under /dev of Ubuntu PC, remember this node name, you will use itwhen setting up the serial port software latertest@test:~$ ls /dev/ttyUSB*/dev/ttyUSB0

2) Many serial debugging tools that can be used under Linux, such as putty, minicom,etc. The following shows how to use putty

3) First, install putty on Ubuntu PCtest@test:~$ sudo apt updatetest@test:~$ sudo apt install putty

4) Then run putty, remember to add sudo permissionstest@test:~$ sudo putty

5) After executing the putty command, the following interface will pop up

Page 22: OrangePiZero2 UserManual

21

6) First, select the setting interface of the serial port

7) Then set the parameters of the serial porta. Set the Serial line to connect to /dev/ttyUSB0 (modify to the corresponding

node name, generally /dev/ttyUSB0)b. Set Speed(baud) to 115200 (baud rate of the serial port)c. Set Flow control to None

8)After setting the serial port setting interface, return to the Session interfacea. First, select the Connection type as Serialb. Then click the Open button to connect to the serial port

Page 23: OrangePiZero2 UserManual

22

9)After starting the development board, you can see the Log information output by theOS from the opened serial terminal

2.7.3. How to use the debug serial port on the Windows platform?1) Many serial debugging tools that can be used under Windows, such as SecureCRT,MobaXterm, etc. The following shows how to use MobaXterm. This software has afree version and can be used without purchasing a serial number.

2) Download MobaXterma. Download MobaXterm URL as follows

https://mobaxterm.mobatek.net/b. After entering the MobaXterm download page, click GET XOBATERM

NOW!

Page 24: OrangePiZero2 UserManual

23

c. Then choose to download the Home version

d. Then select the Portable version. After downloading, you don’t need to installit, you can open it directly

3) After downloading, use the decompression software to decompress the downloadedcompressed package, you can get the executable software of MobaXterm, and thendouble-click to open it

Page 25: OrangePiZero2 UserManual

24

4) After opening the software, the steps to set the serial connection are as followsa. Open the session setting interfaceb. Select the serial port typec. Select the port number of the serial port (choose the corresponding port number

according to the actual situation), if you cannot see the port number, please use the360 driver master to scan and install the driver for the USB to TTL serial chip

d. Select the baud rate of the serial port to be 115200e. Finally click the "OK" button to complete the setting

5)After clicking the "OK" button, you will enter the following interface, and you cansee the output information of the serial port after starting the development board

Page 26: OrangePiZero2 UserManual

25

3. Linux OS instructions

3.1. Supported Linux distribution types and kernel versions

Release version Kernel version Server version desktop versionUbuntu 18.04 linux4.9 Support SupportUbuntu 20.04 linux4.9 Support SupportDebian 10 linux4.9 Support Support

3.2. linux4.9 kernel driver adaptation status

Orange Pi Zero 2 currently only supports the linux 4.9 version of the kernel, andthe driver adaptation is shown in the table below

Function StatusHDMI video OKHDMI Audio OKUSB2.0 x 3 OKTF card boot OKNetwork card OKIR receiver OK

WIFI OKBT OK

Headphone audio OKUSB camera OKLED light OK26pin GPIO OK

I2C OKSPI OK

UART OKTemperature Sensor OKHardware watchdog OK

Mali GPU NOVideo codec NO

3.3. Linux OS default login account and password

Account Passwordroot orangepiorangepi orangepi

3.4. Onboard LED light display description

Green Light Red Lightu-boot startup phase Turn off bright

Page 27: OrangePiZero2 UserManual

26

Kernel boot to enter system bright Turn offGPIO port PC13 PC12

3.5. Instructions for the automatic login of Linux desktop

version OS

1) The desktop version of the OS will automatically log in to the desktop after it isstarted by default, without entering a password

2) Modify the configuration in /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf to prohibit the desktop version OS from automatically logging in to thedesktop. The modification command is as follows, or you can open the configurationfile to modify directlyroot@orangepis:~# sed -i "s/autologin-user=orangepi/#autologin-user=orangepi/"/etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf

3) The configuration of /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf aftermodification is as followsroot@orangepis:~# cat /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf[Seat:*]#autologin-user=orangepiautologin-user-timeout=0user-session=xfce

4) Then restart the OS and a login dialog box will appear, at this time you need toenter a password to enter the OS

Page 28: OrangePiZero2 UserManual

27

3.6. Start the rootfs in the auto-expanding TF card for the first

time

1)When the TF card starts the Linux OS for the first time, it will call theorangepi-resize-filesystem script through the orangepi-resize-filesystem.servicesystemd service to automatically expand the rootfs, so there is no need tomanually expand

2) After logging in to the OS, you can use the df -h command to check the size ofrootfs. If it is consistent with the actual capacity of the TF card, it means that theautomatic expansion is running correctlyroot@orangepi:~# df -hFilesystem Size Used Avail Use% Mounted onudev 430M 0 430M 0% /devtmpfs 100M 5.6M 95M 6% /run/dev/mmcblk0p1 15G 915M 14G 7% /tmpfs 500M 0 500M 0% /dev/shm

3.7. How to modify the linux log level (loglevel)?

1) The log level of the Linux OS is set to 1 by default. When using the serial port toview the startup information, the kernel output log is as follows, basically all shieldedStarting kernel ...

Uncompressing Linux... done, booting the kernel.

Orange Pi 2.0.8 Bionic ttyS0orangepi login:

Page 29: OrangePiZero2 UserManual

28

2) When there is a problem with the OS startup, you can use the following method tomodify the value of log level, to print more log information to the serial port display,which is convenient for debuggingroot@orangepi:~# sed -i "s/verbosity=1/verbosity=7/" /boot/orangepiEnv.txtroot@orangepi:~# sed -i "s/console=both/console=serial/" /boot/orangepiEnv.txt

3) The above commands are actually to set the variables in /boot/orangepiEnv.txt.After setting, you can open /boot/orangepiEnv.txt to checkroot@orangepi:~# cat /boot/orangepiEnv.txtverbosity=7bootlogo=falseconsole=serial

4) Then restart the development board, the output information of the kernel will beprinted to the serial port for output

3.8. Ethernet port test

1) First insert the network cable into the Ethernet interface of the development board,and ensure that the network is unblocked

2) After the OS starts, it will automatically assign an IP address to the Ethernet cardthrough DHCP

3) The command to view the IP address is as followsroot@orangepi:~# ifconfig eth0eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.1.47 netmask 255.255.255.0 broadcast 192.168.1.255inet6 fe80::e56:c34d:62f0:8d6e prefixlen 64 scopeid 0x20<link>ether 02:81:3e:a8:58:d8 txqueuelen 1000 (Ethernet)RX packets 2165 bytes 177198 (177.1 KB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 312 bytes 40435 (40.4 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0device interrupt 39

4) The command to test network connectivity is as followsroot@orangepi:~# ping www.baidu.com -I eth0PING www.a.shifen.com (14.215.177.38) from 192.168.1.12 eth0: 56(84) bytes ofdata.64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=56 time=6.74 ms64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=56 time=6.80 ms

Page 30: OrangePiZero2 UserManual

29

64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=56 time=6.26 ms64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=56 time=7.27 ms^C--- www.a.shifen.com ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3002msrtt min/avg/max/mdev = 6.260/6.770/7.275/0.373 ms

3.9. SSH remote login development board

Linux OS have SSH remote login enabled by default, and allow root users to login to the OS. Before ssh login, you need to make sure that the Ethernet or wifinetwork is connected, and then use the ifconfig command or check the router toobtain the IP address of the development board

3.9.1. SSH remote login development board under Ubuntu1) Get the IP address of the development board2) Then you can log in to the Linux OS remotely through the ssh commandtest@test:~$ ssh [email protected] (Need to be replaced with the IP addressof the development board)[email protected]'s password: (Enter the password here, the default password isorangepi)

3) The display after successfully logging in to the OS is shown in the figure below

4) If the following error is prompted during ssh logintest@test:~$ ssh [email protected] reset by 192.168.1.149 port 22lost connection

Page 31: OrangePiZero2 UserManual

30

You can enter the following command on the development board and try toconnectroot@orangepi:~# rm /etc/ssh/ssh_host_*root@orangepi:~# dpkg-reconfigure openssh-server

3.9.2. SSH remote login development board underWindows1) First, get the IP address of the development board

2) MobaXterm can be used to remotely log in to the development board underwindows, first create a new ssh sessiona. Open Sessionb. Then select SSH in Session Settingc. Then enter the IP address of the development board in Remote hostd. Then enter the username root or orangepi of the Linux OS in Specify usernamee. Finally, click OK

3)Then you will be prompted to enter a password, the default passwords for root andorangepi users are orangepi

4)The display after successfully logging in to the OS is shown in the figure below

Page 32: OrangePiZero2 UserManual

31

3.10. HDMI display test

1) Use Micro HDMI to HDMI cable to connect Orange Pi development board andHDMI display

2) If the HDMI display has image output after starting the Linux OS, it means that theHDMI interface is working normally

3.11. HDMI resolution setting

1) There is a disp_mode variable in the /boot/orangepiEnv.txt of the Linux OS, whichcan be used to set the HDMI resolution. The default resolution of the Linux OS is1080p60root@orangepi:/boot# cat orangepiEnv.txtverbosity=1

Page 33: OrangePiZero2 UserManual

32

console=bothdisp_mode=1080p60

2) The disp_mode variable supports setting values as shown in the following tabledisp_mode supported value HDMI Resolution HDMI refresh rate

480i 720x480 60576i 720x480 50480p 720x480 60576p 720x576 60720p50 1280x720 50720p60 1280x720 601080i50 1920x1080 501080i60 1920x1080 601080p24 1920x1080 241080p50 1920x1080 501080p60 1920x1080 60

3) Modify the value of the disp_mode variable to the resolution you want to output,and then restart the OS, HDMI will display the set resolution

3.12. How to modify the width and height of Framebuffer?

1) There are two variables fb0_width and fb0_height in the /boot/orangepiEnv.txt ofthe Linux OS, which can be used to set the width and height of the Framebuffer. TheLinux OS defaults to fb0_width=1280, fb0_height=720root@orangepi:~# cat /boot/orangepiEnv.txtverbosity=1console=bothdisp_mode=720p60fb0_width=1280fb0_height=720

2) The reference values corresponding to different resolutions of fb0_width andfb0_height are as follows

HDMI resolution fb0_width fb0_height480p 720 480576p 720 576720p 1280 7201080p 1920 1080

3) Under the same HDMI resolution, the display of different fb0_width andfb0_height is as follows

a. HDMI resolution is 1080p60, fb0_width and fb0_height are 1920x1080

Page 34: OrangePiZero2 UserManual

33

b. HDMI resolution is 1080p60, fb0_width and fb0_height are 1280x720display

c. HDMI resolution is 1080p60, fb0_width and fb0_height are 720x576

Page 35: OrangePiZero2 UserManual

34

d. HDMI resolution is 1080p60, fb0_width and fb0_height are 720x480 display

3.13. WIFI connection test

3.13.1. Test method of Linux server version image1) Log in to the Linux OS first, there are three waysa. If the development board is connected to the network cable, you can log in to the

Linux OS remotely via SSHb. If the debug serial port is connected, you can use the serial terminal to log in to

the Linux OS (use MobaXterm for the serial port software, and the graphical interfacecannot be displayed using minicom)

Page 36: OrangePiZero2 UserManual

35

c. If you connect the development board to the HDMI display, you can log in to theLinux OS through the HDMI display terminal

2)Then enter nmtui in the command line to open the wifi connection interfaceroot@orangepi:~# nmtui

3)Enter nmtui to open the interface as shown below

4)Select Activate a connect and press Enter

5)Then you can see all the searched WIFI hotspots

Page 37: OrangePiZero2 UserManual

36

6)Select the WIFI hotspot you want to connect to, then use the Tab key to position thecursor on Activate and press Enter

7)Then a dialog box for entering the password will pop up, enter the correspondingpassword in Password and press Enter to start connecting to WIFI

8)After the WIFI connection is successful, a "*" will be displayed before theconnected WIFI name

Page 38: OrangePiZero2 UserManual

37

9)The wifi IP address can be viewed through the ifconfig commandroot@orangepi:~# ifconfig wlan0wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 192.168.1.49 netmask 255.255.255.0 broadcast 192.168.1.255inet6 fe80::76bb:f67d:ef98:2f9a prefixlen 64 scopeid 0x20<link>ether 12:81:3e:a8:58:d8 txqueuelen 1000 (Ethernet)RX packets 185 bytes 109447 (109.4 KB)RX errors 0 dropped 61 overruns 0 frame 0TX packets 27 bytes 14783 (14.7 KB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

10)Use the ping command to test the connectivity of the wifi networkroot@orangepipcplus:~# ping www.orangepi.org -I wlan0PING www.orangepi.org (182.92.236.130) from 192.168.1.49 wlan0: 56(84) bytes ofdata.64 bytes from 182.92.236.130 (182.92.236.130): icmp_seq=1 ttl=52 time=43.5 ms64 bytes from 182.92.236.130 (182.92.236.130): icmp_seq=2 ttl=52 time=41.3 ms64 bytes from 182.92.236.130 (182.92.236.130): icmp_seq=3 ttl=52 time=44.9 ms64 bytes from 182.92.236.130 (182.92.236.130): icmp_seq=4 ttl=52 time=45.6 ms64 bytes from 182.92.236.130 (182.92.236.130): icmp_seq=5 ttl=52 time=48.8 ms^C--- www.orangepi.org ping statistics ---5 packets transmitted, 5 received, 0% packet loss, time 4006msrtt min/avg/max/mdev = 41.321/44.864/48.834/2.484 ms

3.13.2. Test method of Linux desktop version image1) Click the network configuration icon in the upper right corner of the desktop(please do not connect the network cable when testing WIFI)

Page 39: OrangePiZero2 UserManual

38

2) Click More networks in the pop-up drop-down box to see all scanned WIFIhotspots, and then select the WIFI hotspot you want to connect to

3) Then enter the password of the WIFI hotspot, and then click Connect to startconnecting to WIFI

4) After connecting to the WIFI, you can open the browser to check whether you can

Page 40: OrangePiZero2 UserManual

39

surf the Internet. The entrance of the browser is shown in the figure below

5) After opening the browser, if you can see the page of the OrangePi website, or youcan open other web pages, the WIFI connection is normal

3.14. How to use Bluetooth?

3.14.1. Test method of desktop version image1) Click the Bluetooth icon in the upper right corner of the desktop

Page 41: OrangePiZero2 UserManual

40

2) Then select the adapter

3) Set Visibility Setting to Always visible in the Bluetooth adapter setting interface,and then click close to close

4) Then open the configuration interface of the Bluetooth device

5) Click Search to start scanning surrounding Bluetooth devices

Page 42: OrangePiZero2 UserManual

41

6) Then select the Bluetooth device you want to connect to, and then click the rightmouse button to pop up the operation interface of the Bluetooth device. Select Pair tostart pairing. Here is a demonstration of pairing with an Android phone

7) When pairing with a mobile phone, a pairing confirmation box will pop up in theupper right corner of the desktop, select Confirm to confirm. At this time, the mobilephone also needs to be confirmed

8) After pairing with the phone, you can select the paired Bluetooth device, then right-click and select Send a File to start sending a picture to the phone

Page 43: OrangePiZero2 UserManual

42

9) The interface for sending pictures is as follows

3.14.2. How to use the server version image?1) When the linux OS starts, the aw859a-bluetooth.service service will be run toinitialize the Bluetooth device. After entering the OS, you can use the hciconfigcommand to check whether there is a Bluetooth device node. If it exists, the Bluetoothinitialization is normalroot@orangepi:~# hciconfig -ahci0: Type: Primary Bus: UART

BDAddress: 10:11:12:13:14:15 ACLMTU: 1021:8 SCO MTU: 240:3UP RUNNINGRX bytes:646 acl:0 sco:0 events:37 errors:0TX bytes:2650 acl:0 sco:0 commands:37 errors:0Features: 0xbf 0xff 0x8d 0xfe 0xdb 0x3d 0x7b 0xc7Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3Link policy:

Page 44: OrangePiZero2 UserManual

43

Link mode: SLAVEACCEPTName: 'orangepizero2'Class: 0x000000Service Classes: UnspecifiedDevice Class: Miscellaneous,HCI Version: 5.0 (0x9) Revision: 0x400LMPVersion: 5.0 (0x9) Subversion: 0x400Manufacturer: Spreadtrum Communications Shanghai Ltd (492)

2) Use bluetoothctl to scan for Bluetooth devicesroot@orangepi:~# bluetoothctl[NEW] Controller 10:11:12:13:14:15 orangepizero2 [default]Agent registered[bluetooth]# power on # Enable controllerChanging power on succeeded[bluetooth]# discoverable on # Set the controller to be discoverableChanging discoverable on succeeded[CHG] Controller 10:11:12:13:14:15 Discoverable: yes[bluetooth]# pairable on # Set the controller to be pairableChanging pairable on succeeded[bluetooth]# scan on # Start scanning for surrounding Bluetooth devicesDiscovery started[CHG] Controller 10:11:12:13:14:15 Discovering: yes[NEW] Device 76:60:79:29:B9:31 76-60-79-29-B9-31[NEW] Device 9C:2E:A1:42:71:11 Xiaomi mobile phone[NEW] Device DC:72:9B:4C:F4:CF orangepi[bluetooth]# scan off # After scanning the Bluetooth device you want toconnect, you can turn off the scan, and then write down the MAC address of theBluetooth device. The Bluetooth device tested here is an Android phone, theBluetooth name is orangepi, and the corresponding MAC address isDC:72:9B:4C :F4:CFDiscovery stopped[CHG] Controller 10:11:12:13:14:15 Discovering: no[CHG] Device DC:72:9B:4C:F4:CF RSSI is nil

3) After scanning the device you want to pair, you can pair it. Pairing requires theMAC address of the device[bluetooth]# pair DC:72:9B:4C:F4:CF # Use the scanned MAC address of theBluetooth device for pairingAttempting to pair with DC:72:9B:4C:F4:CF[CHG] Device DC:72:9B:4C:F4:CF Connected: yesRequest confirmation[leeb1m[agent] Confirm passkey 764475 (yes/no): yes # Enter yes here, you alsoneed to confirm on the phone

Page 45: OrangePiZero2 UserManual

44

[CHG] Device DC:72:9B:4C:F4:CF Modalias: bluetooth:v010Fp107Ed1436[CHG] Device DC:72:9B:4C:F4:CF UUIDs: 0000046a-0000-1000-8000-00805f9b34fb[CHG] Device DC:72:9B:4C:F4:CF ServicesResolved: yes[CHG] Device DC:72:9B:4C:F4:CF Paired: yesPairing successful #Prompt for successful pairing[CHG] Device DC:72:9B:4C:F4:CF ServicesResolved: no[CHG] Device DC:72:9B:4C:F4:CF Connected: no

4) After the pairing is successful, the Bluetooth interface of the mobile phone will bedisplayed as shown below

3.15. USB interface test

3.15.1. Connect mouse or keyboard test1) Insert the keyboard of the USB interface into the USB interface of the Orange Pidevelopment board

2) Connect the Orange Pi development board to the HDMI display

3) If the mouse or keyboard can operate normally, the USB interface is workingnormally (the mouse can only be used in the desktop version of the OS)

3.15.2. Connect USB storage device test1) First, insert the U disk into the USB port of the Orange Pi development board

2) Execute the following command, if you can see the output of sdX, it means that theU disk is successfully recognizedroot@orangepi:~# cat /proc/partitions | grep "sd*"major minor #blocks name8 0 30044160 sda

Page 46: OrangePiZero2 UserManual

45

8 1 30043119 sda1

3) Use the mount command to mount the U disk to /mnt, and then you can view thefiles in the U diskroot@orangepi:~# mount /dev/sda1 /mnt/root@orangepi:~# ls /mnt/test.txt

4) After mounting, you can view the capacity usage and mount point of the U diskthrough the df -h commandroot@orangepi:~# df -h | grep "sd"/dev/sda1 29G 208K 29G 1% /mnt

3.16. USB camera test

1) First insert the USB camera into the USB port of the Orange Pi development board

2) Then through the lsmod command, you can see that the kernel has automaticallyloaded the following modulesroot@orangepi:~# lsmodModule Size Used byuvcvideo 106496 0videobuf2_vmalloc 16384 1 uvcvideovideobuf2_memops 16384 1 videobuf2_vmallocvideobuf2_v4l2 32768 1 uvcvideovideobuf2_core 53248 2 uvcvideo,videobuf2_v4l2

3) Through the v4l2-ctl (note that l in v4l2 is a lowercase letter l, not a number 1)command, you can see that the device node information of the USB camera is/dev/video0root@orangepi:~# apt updateroot@orangepi:~# apt install v4l-utilsroot@orangepi:~# v4l2-ctl --list-devicesUSB 2.0 Camera (usb-sunxi-ehci-1):

/dev/video0

4) Use fswebcam to test the USB cameraa. Install fswebcam

root@orangepi:~# apt updateroot@orangepi:~# apt-get install fswebcam

b. After installing fswebcam, you can use the following command to takepictures

a) -d option is used to specify the device node of the USB camera

Page 47: OrangePiZero2 UserManual

46

b) --no-banner is used to remove watermark from photosc) -r option is used to specify the resolution of the photod) -S option is used to skip the previous frame numbere) ./image.jpg is used to set the name and path of the generated photo

root@orangepi:~# fswebcam -d /dev/video0 --no-banner -r 1280x720 -S5 ./image.jpg

c. In the server version of the Linux OS, after taking the picture, you can usethe scp command to transfer the picture to the Ubuntu PC for image andviewing

root@orangepi:~# scp image.jpg [email protected]:/home/test (Modify the IPaddress and path according to the actual situation)

d. desktop version of Linux OS, you can directly view the captured picturesthrough the HDMI display

5) Use motion to test the USB cameraa. Install the camera test software motion

root@orangepi:~# apt updateroot@orangepi:~# apt install motion

b. Modify the configuration of /etc/default/motion, changestart_motion_daemon=no to start_motion_daemon=yes

root@orangepi:~# sed -i"s/start_motion_daemon=no/start_motion_daemon=yes/" \/etc/default/motion (This is a command)

c. Modify the configuration of /etc/motion/motion.confroot@orangepi:~# sed -i "s/stream_localhost on/stream_localhost off/" \/etc/motion/motion.conf (This is a command)

d. Then restart the motion serviceroot@orangepi:~# /etc/init.d/motion restart[ ok ] Restarting motion (via systemctl): motion.service.

e. Before using motion, please make sure that the Orange Pi development boardcan connect to the network normally, and then obtain the IP address of thedevelopment board through the ifconfig command

f. Then enter the [IP address of the development board: 8081] in the Ubuntu PCor Windows PC on the same LAN as the development board or the Firefoxbrowser of the mobile phone to see the video output by the camera

Page 48: OrangePiZero2 UserManual

47

3.17. 13 Pin transfer board interface pin description

1) Please refer to the figure below for the sequence of the orange Pi Zero 2development board 13 pin adapter board interface pins

2) The schematic diagram of the 13pin interface of the Orange Pi Zero 2 developmentboard is shown below

Page 49: OrangePiZero2 UserManual

48

3) The function description of the 13 pin adapter board interface pins of the Orange PiZero 2 development board is as follows

a. When the 13pin is connected to the adapter board, it can be additionallyprovideda) 2 USB2.0 Hostb) Headphone left and right channel audio outputc) TV-OUT video outputd) IR receiving functione) After connecting the adapter board, pins 10, 11 and 12 of the 13pin

interface cannot be usedf) Also, note that the MIC on the 13pin adapter board cannot be used

on Orange Pi Zero2

b. When the 13pin is not connected to the adapter board, the 10, 11, and 12 pinscan be used as ordinary GPIO ports

GPIO serial number Function Pin5V 1GND 2

USB2-DM 3USB2-DP 4USB3-DM 5USB3-DP 6

LINEOUTR 7LINEOUTL 8TV-OUT 9

65 PC1 10272 PI16 11262 PI6 12

IR-RX 13

3.18. Audio test

3.18.1. Headphone jack play audio test1) First, you need to insert the 13pin adapter board into the 13pin interface of the

Orange Pi development board, and then insert the headset into the audio interface

Page 50: OrangePiZero2 UserManual

49

2) Through the aplay -l command, you can view the sound card devices supportedby the Linux OS, where card 0: audiocodec is the sound card device required forheadset playback

root@orangepi:~# aplay -l**** List of PLAYBACK Hardware Devices ****card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sun50iw9-codec-0 []Subdevices: 1/1Subdevice #0: subdevice #0

3) Upload the audio files that need to be played to the /root folder of the Linux OS.You can use the scp command to upload in the Ubuntu PC (the IP address in thecommand is the IP address of the Orange Pi development board), or copy it witha USB flash drive

test@test:~/AudioTest$ scp audio.wav [email protected]:/root (Modify the IPaddress and path according to the actual situation)

4) Then use the aplay command to play the audio, the headset can hear the soundroot@orangepi:~# aplay -D hw:0,0 audio.wavPlaying WAVE 'audio.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

5) The volume of the headset can be adjusted through the alsamixer commanda. Enter the alsamixer command in the terminal

root@orangepi:~# alsamixerb. After entering the alsamixer command, the following audio setting interface

will pop up, and then you can adjust the size of the audio through the up,down, left, and right direction keys. The specific steps are shown in thefigure below

Page 51: OrangePiZero2 UserManual

50

3.18.2. HDMI audio playback test1) First use the Micro HDMI to HDMI cable to connect the Orange Pi developmentboard to the TV (other HDMI displays need to ensure that they can play audio)

2) Upload the audio files that need to be played to the /root folder of the Linux OS.You can use the scp command to upload in the Ubuntu PC (the IP address in thecommand is the IP address of the Orange Pi development board), or copy using aUSB flash drivetest@test:~/AudioTest$ scp audio.wav [email protected]:/root (Modify the IPaddress and path according to the actual situation)

3) HDMI audio playback does not require other settings, just use the aplay commandto play directlyroot@orangepi:~# aplay -D hw:1,0 audio.wav

3.19. IR receiving test

1) First, you need to insert the 13pin adapter board into the 13pin interface of theOrange Pi development board. After the adapter board is inserted, the Orange Pi Zero2 can use the IR receiving function

2) Install ir-keytable IR test softwareroot@orangepi:~# apt updateroot@orangepi:~# apt-get install ir-keytable

3) Then execute ir-keytable to view the information of the IR deviceroot@orangepi:~# ir-keytableFound /sys/class/rc/rc0/ (/dev/input/event1) with:

Driver: sunxi-rc-recv, table: rc_map_sunxilirc device: /dev/lirc0Supported protocols: lirc necEnabled protocols: lirc necName: sunxi_ir_recv

Page 52: OrangePiZero2 UserManual

51

bus: 25, vendor/product: 0001:0001, version: 0x0100Repeat delay = 500 ms, repeat period = 125 ms

4) An IR remote controller needs to be prepared before testing the IR receivingfunction

5) Then enter the ir-keytable -t command in the terminal, and then use the IR remotecontrol to press the button against the IR receiving head of the Orange Pi developmentboard to see the received key code in the terminalroot@orangepi:/# ir-keytable -tTesting events. Please, press CTRL-C to abort.1598339152.260376: event type EV_MSC(0x04): scancode = 0xfb04131598339152.260376: event type EV_SYN(0x00).1598339152.914715: event type EV_MSC(0x04): scancode = 0xfb0410

3.20. Hardware watchdog test

1) Download the code of wiringOProot@orangepi:~# apt updateroot@orangepi:~# apt install gitroot@orangepi:~# git clone https://github.com/orangepi-xunlong/wiringOP

2) Compile wiringOProot@orangepi:~# cd wiringOProot@orangepi:~/wiringOP# ./build cleanroot@orangepi:~/wiringOP# ./build

3) Compile the watchdog test programroot@orangepi:~/wiringOP# cd examples/root@orangepi:~/wiringOP/examples# make watchdog[CC] watchdog.c[link]

Page 53: OrangePiZero2 UserManual

52

4) Run the watchdog test programsystema. The second parameter 10 represents the counting time of the watchdog. If

there is no dog feeding within this time, the will restartb. 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 indicatethat the dog is successfully fed

root@orangepi:~/wiringOP/examples# ./watchdog 10open successoptions is 33152,identity is sunxi-wdtput_usr return,if 0,success:0The old reset time is: 16return ENOTTY,if -1,success:0return ENOTTY,if -1,success:0put_user return,if 0,success:0put_usr return,if 0,success:0keep alivekeep alivekeep alive

3.21. Temperature sensor

1) H616 has a total of 4 temperature sensors, the command to check the temperature isas follows

a. sensor0:CPUroot@orangepi:~# cat /sys/class/thermal/thermal_zone0/typecpu_thermal_zoneroot@orangepi:~# cat /sys/class/thermal/thermal_zone0/temp57734

b. sensor1:GPUroot@orangepi:~# cat /sys/class/thermal/thermal_zone1/typegpu_thermal_zoneroot@orangepi:~# cat /sys/class/thermal/thermal_zone1/temp57410

c. sensor2:VEroot@orangepi:~# cat /sys/class/thermal/thermal_zone2/typeve_thermal_zoneroot@orangepi:~# cat /sys/class/thermal/thermal_zone2/temp59273

d. sensor3:DDRroot@orangepi:~# cat /sys/class/thermal/thermal_zone3/typeddr_thermal_zoneroot@orangepi:~# cat /sys/class/thermal/thermal_zone3/temp58949

Page 54: OrangePiZero2 UserManual

53

3.22. How to install Docker

1) Uninstall the old version of docker that may exist firstroot@orangepi:~# apt remove docker docker-engine docker-ce docker.io

2) Then install the following packagesroot@orangepi:~# apt updateroot@orangepi:~# apt install -y apt-transport-https ca-certificates curl \software-properties-common

3) Add the key of Alibaba Cloud dockerroot@orangepi:~# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg \| sudo apt-key add -

4) Add the corresponding docker source in the OS source of ubunturoot@orangepi:~# add-apt-repository "deb [arch=arm64] \

https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

5) nstall the latest version of docker-ceIroot@orangepi:~# apt updateroot@orangepi:~# apt install docker-ce

6) Verify the status of dockerroot@orangepi:~# systemctl status docker● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset:

enabled)Active: active (running) since Mon 2020-08-24 10:29:22 UTC; 26min agoDocs: https://docs.docker.com

Main PID: 3145 (dockerd)Tasks: 15CGroup: /system.slice/docker.service

└─3145 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

7) Test dockerroot@orangepi:~# docker run hello-worldUnable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-world256ab8fe8778: Pull completeDigest:sha256:7f0a9f93b4aa3022c3a4c147a449ef11e0941a1fd0bf4a8e6c9408b2600777c5Status: Downloaded newer image for hello-world:latest

Page 55: OrangePiZero2 UserManual

54

Hello from Docker!This message shows that your installation appears to be working correctly.

3.23. 26pins GPIO, I2C, UART, SPI test

3.23.1. 26 Pins description1) Please refer to the figure below for the sequence of the 26 pins of the Orange PiZero 2 development board

2) The function of the 26 pins of the Orange Pi Zero 2 development board is shown inthe table belowGPIONo.

GPIO Function Pin Pin Function GPIO GPIONo.

3.3V 1 2 5V229 PH5 TWI3-SDA 3 4 5V228 PH4 TWI3-SCK 5 6 GND73 PC9 PC9 7 8 UART5_TX PH2 226

GND 9 10 UART5_RX PH3 22770 PC6 PC6 11 12 PC11 PC11 7569 PC5 PC5 13 14 GND72 PC8 PC8 15 16 PC15 PC15 79

3.3V 17 18 PC14 PC14 78231 PH7 SPI1_MOSI 19 20 GND232 PH8 SPI1_MISO 21 22 PC7 PC7 71230 PH6 SPI1_CLK 23 24 SPI1_CS PH9 233

GND 25 26 PC10 PC10 74

3.23.2. Install wiringOP

Page 56: OrangePiZero2 UserManual

55

1) WiringOP has been adapted to the Orange Pi Zero 2 development board, usingwiringOP can test the functions of GPIO, I2C, UART, and SPI

2)Download the code of wiringOProot@orangepi:~# apt updateroot@orangepi:~# apt install gitroot@orangepi:~# git clone https://github.com/orangepi-xunlong/wiringOP

3) Compile wiringOProot@orangepi:~# cd wiringOProot@orangepi:~/wiringOP# ./build cleanroot@orangepi:~/wiringOP# ./build

4) The output of the test gpio readall command is as followsa. There is a one-to-one correspondence between pins 1 to 26 and 26 Pins on thedevelopment boardb. Pin 27 corresponds to pin 10 of 13pins on the development boardc. Pin 29 corresponds to pin 11 of 13pins on the development boardd. Pin 31 corresponds to pin 12 of 13pins on the development boarde. 28, 30, 32 pins are empty, please ignore directly

3.23.3. Test common GPIO port1) The following is an example of how to set the high and low level of the GPIO portwith pin No. 7-corresponding to GPIO as PC9-corresponding to wPi number as 2-

Page 57: OrangePiZero2 UserManual

56

2) First set the GPIO port to output mode, and the third parameter needs to inputthe serial number of the wPi corresponding to the pinroot@orangepi:~/wiringOP# gpio mode 2 out

3) Then set the GPIO port to output low level. After setting, you can use a multimeterto measure the value of the pin voltage. If it is 0v, it means that the low level is setsuccessfullyroot@orangepi:~/wiringOP# gpio write 2 0

Use gpio readall to see that the value (V) of pin 7 has become 0

4) Then set the GPIO port to output high level. After setting, you can use a multimeterto measure the value of the pin voltage. If it is 3.3v, it means that the high level is setsuccessfully

root@orangepi:~/wiringOP# gpio write 2 1

Use gpio readall to see that the value (V) of pin 7 has become 1

5) The setting method of other pins is similar, just modify the serial number of wPi tothe serial number corresponding to the pin.

Page 58: OrangePiZero2 UserManual

57

3.23.4. SPI test1) According to the schematic diagram of the 26pins connector, the available SPI forOrange Pi Zero2 is SPI1

2) First check whether there is a spidev1.1 device node in the Linux OS. If it exists, itmeans that SPI1 has been set up and can be used directlyroot@orangepi:~/wiringOP/examples# ls /dev/spidev1*/dev/spidev1.1

3) Compile the spidev_test test program in the examples of wiringOP

root@orangepi:~/wiringOP/examples# make spidev_test[CC] spidev_test.c[link]

4)Do not short-circuit the mosi and miso pins of SPI1 first, and the output result ofrunning spidev_test is as follows, you can see that the data of TX and RX areinconsistentroot@orangepi:~/wiringOP/examples# ./spidev_test -v -D /dev/spidev1.1spi mode: 0x0bits per word: 8max speed: 500000 Hz (500 KHz)TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FFFF 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 FFFF FF FF FF FF FF FF FF FF | ................................

5) Then short-circuit the two pins of SPI1's mosi (the 19th pin in 26pins) and miso(the 21st pin in 26pins) and run the output of spidev_test as follows, you can see thatthe sent and received data are the sameroot@orangepi:~/wiringOP/examples# ./spidev_test -v -D /dev/spidev1.1spi mode: 0x0

Page 59: OrangePiZero2 UserManual

58

bits per word: 8max speed: 500000 Hz (500 KHz)TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FFFF FF FF FF FF FF F0 0D | ......@....▒..................▒.RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FFFF FF FF FF FF FF F0 0D | ......@....▒..................▒.

3.23.5. I2C test1) According to the schematic diagram of 26pins, the i2c available for Orange Pi Zero2 is i2c3

2) After starting the linux OS, first confirm that there is an i2c3 device node under/devroot@orangepi:~# ls /dev/i2c-*/dev/i2c-3 /dev/i2c-5

3) Then start to test i2c, first install i2c-toolsroot@orangepi:~# apt updateroot@orangepi:~# apt install i2c-tools

4) Then connect an i2c device to the i2c3 pin of the 26pins connectori2c3

Sda Pin Corresponding to pin 3Sck Pin Corresponding to pin 5vcc Pin Corresponding to pin 1gnd Pin Corresponding to pin 6

5) Then use the i2cdetect -y 3 commands if the address of the connected i2c devicecan be detected, it means that i2c can be used normally

Page 60: OrangePiZero2 UserManual

59

3.23.6. UART test1) According to the schematic diagram of 26pins, the uart available for Orange PiZero 2 is UART5

2) After starting the linux OS, first confirm that there is a UART5 device node under/devroot@orangepi:~# ls /dev/ttyS*/dev/ttyS0 /dev/ttyS1 /dev/ttyS5

3) Then start to test the UART5 interface, first use the Dupont line to short-circuit therx and tx of the UART5 interface to be tested

UART5tx Pin Corresponding to pin 8rx Pin Corresponding to pin 10

4) Then modify the serial device node name opened by the serial test programserialTest in wiringOP to /dev/ttyS5root@orangepizero2:~/wiringOP/examples# vim serialTest.c

Page 61: OrangePiZero2 UserManual

60

5) Recompile the serial test program serialTest in wiringOProot@orangepi:~/wiringOP/examples# make serialTest[CC] serialTest.c[link]root@orangepi:~/wiringOP/examples#

6) Finally, run serialTest, if you can see the following print, it means that the serialcommunication is normalroot@orangepi:~/wiringOP/examples# ./serialTest

Out: 0: -> 0Out: 1: -> 1Out: 2: -> 2Out: 3: -> 3Out: 4: -> 4Out: 5: -> 5Out: 6: -> 6Out: 7: -> 7Out: 8: -> 8^C

3.24. Method of redirecting kernel console output to serial port

ttyS5

The kernel console outputs to ttyS0 by default, which is the 3pin debug serial port onthe development board. We can also set the kernel console output to be redirected tothe 26pins connector UART5, the method is as follows:

1) Modify console=ttyS0 in /boot/boot.cmd to console=ttyS5root@orangepi:~# vim /boot/boot.cmd

Page 62: OrangePiZero2 UserManual

61

2) Then compile and recompile /boot/boot.cmd to /boot/boot.scrroot@orangepi:~# mkimage -C none -A arm -T script -d /boot/boot.cmd/boot/boot.scrImage Name:Created: Tue Nov 3 01:45:17 2020Image Type: ARM Linux Script (uncompressed)Data Size: 2247 Bytes = 2.19 KiB = 0.00 MiBLoad Address: 00000000Entry Point: 00000000Contents:Image 0: 2239 Bytes = 2.19 KiB = 0.00 MiB

3) Then connect the USB to TTL module to the 26pins UART5 pin through theDuPont cable

a. Connect the GND of the USB to TTL module to the GND of the 26pins ofthe development board

b. Connect the RX of the USB to TTL module to the TX of the developmentboard UART5

c. Connect the TX of the USB to TTL module to the RX of the developmentboard UART5

4) Then restart the development board, you can see that the kernel console outputs tottyS5 by default. Note that the output log of u-boot is still output to ttyS0, not ttyS5

3.25. SPI Nor Flash test

1) In the Orange Pi Zero 2 development board, SPI0 is connected to the onboard 2MBSPI Nor Flash. WiringOP can be used to test it. At present, it can only test the dataread and write of the SPI Nor Flash chip to ensure that the hardware is okay. , Can’tuse SPI Nor Flash to run U-boot

Page 63: OrangePiZero2 UserManual

62

2) The SPI Flash test program in wiringOP is w25q64_test.croot@orangepi:~/wiringOP# cd examples/root@orangepi:~/wiringOP/examples# ls w25q64_test.cw25q64_test.c

3) First make sure that both SPI_CHANNEL and SPI_PORT in w25q64_test.c are setto 0#define SPI_CHANNEL 0#define SPI_PORT 0

4) Then check whether there is a device node of spidev0.0 in the Linux OS. If itexists, it means that SPI0 has been set up and can be used directlyroot@orangepi:~/wiringOP/examples# ls /dev/spidev0*/dev/spidev0.0

5) Then compile w25q64_testroot@orangepi:~/wiringOP/examples# make w25q64_test[CC] w25q64_test.c[link]

6) Test SPI Nor Flash, if you can see data output (not all 0 or ff), it means that SPINor Flash reads and writes normallyroot@orangepi:~/wiringOP/examples# ./w25q64_testOpening device /dev/spidev0.0JEDEC ID : c2 20 16Unique ID : ff ff ff ff ff ff ffRead Data: n=256----------------------------------------------------------00000: 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 |a200010: 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 |e800020: 57 58 59 5a ff ff ff ff ff ff ff ff ff ff ff ff |5600030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f000040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f000050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f000060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0

Page 64: OrangePiZero2 UserManual

63

00070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f000080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f000090: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0000f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |f0----------------------------------------------------------

c1 c4 c7 ca 71 73 75 77 79 7b 84 86 88 8a 8c 8e |10......

4. Linux SDK instructions

The compilation of the Linux SDK is done on a PC with Ubuntu 18.04 installed.Other versions of Ubuntu OS may have some differences

4.1. Get the source code of Linux SDK

1) First download the code of orangepi-build, the code of orangepi-build is modifiedbased on the armbian build OS

a. Currently the Orange Pi Zero 2 development board only supports the legacybranch

b. The kernel version is linux4.9c. u-boot version is v2018.05

test@test:~$ sudo apt updatetest@test:~$ sudo apt install gittest@test:~$ git clone https://github.com/orangepi-xunlong/orangepi-build.git

2) Orangepi-build will contain the following files and folders after downloadinga. build.sh: Compile the startup scriptb. external: Contains the configuration files needed to compile the image,specific scripts, and the source code of some programs, etc.c. LICENSE: GPL 2 license filed. README.md: orangepi-build instruction filee. scripts: general scripts for compiling linux images

test@test:~/orangepi-build$ lsbuild.sh external LICENSE README.md scripts

3) The orangepi-build repository does not contain the source code of the Linux kerneland u-boot after the first download. They are stored in a separate git repository

Page 65: OrangePiZero2 UserManual

64

(please do not download the source code of the kernel and u-boot separately,unless you know how to use), when orangepi-build runs for the first time, it willautomatically download the kernel and u-boot source code

a. The repository where the Linux kernel source code is stored is as follows,where sun50iw9 is the code name of the H616 SOC chip

https://github.com/orangepi-xunlong/linux-orangepi/tree/orange-pi-4.9-sun50iw9b. The repository where u-boot source code is stored is as follows, wheresun50iw9 is the code name of the H616 SOC chip

https://github.com/orangepi-xunlong/u-boot-orangepi/tree/v2018.05-sun50iw9

4) Orangepi-build will download the cross-compilation toolchain, u-boot, and Linuxkernel source code during the process of compiling the image. After successfullycompiling the image once, the files and folders that can be seen in orangepi-build area. build.sh: Compile the startup scriptb. external: Contains the configuration files needed to compile the image, scripts

for specific functions, and the source code of some programs. The rootfscompressed package cached during the compiling of the image is also stored inexternal

c. external: Stores the source code of the Linux kernel, the folder named orange-pi-4.9-sun50iw9 stores the kernel source code of Orange Pi Zero 2 (sun50iw9 is thecode name of the H616 SOC chip)

d. LICENSE: GPL 2 license filee. README.md: orangepi-build instruction filef. output: store the compiled u-boot, linux and other deb packages, compilation

logs, and compiled images and other files scripts: general scripts for compilinglinux images

g. toolchains: store cross-compilation toolchainsh. u-boot: Store the source code of u-boot, the folder named v2018.05-sun50iw9

inside stores the u-boot source code of Orange Pi Zero 2 (sun50iw9 is the codename of the H616 SOC chip)

i. userpatches: store configuration files needed to compile scriptstest@test:~/orangepi-build$ lsbuild.sh external kernel LICENSE output README.md scripts toolchainsu-boot userpatches

4.2. Download the compilation toolchain

1) When orangepi-build is run for the first time, it will automatically download thecross-compilation toolchains and place it in the toolchains folder. Every time theorangepi-build build.sh script is run, it will check whether the cross-compilationtoolchain in toolchains exists. If it does not exist, it will restart the download, if itexists, it will be used directly, and the download will not be repeated

Page 66: OrangePiZero2 UserManual

65

2) The image URL of the cross-compilation tool chain in China is the open sourcesoftware image site of Tsinghua Universityhttps://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/

3) After toolchains is downloaded, it will contain multiple versions of cross-compilation toolchainstest@test:~/orangepi-build$ ls toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabigcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf gcc-linaro-aarch64-none-elf-4.8-2013.11_linuxgcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linuxgcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu gcc-linaro-arm-none-eabi-4.8-2014.04_linux

4) The cross-compilation toolchains used to compile the Orange Pi Zero 2 linux4.9kernel source code isgcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu

5) The cross-compilation toolchain used to compile the Orange Pi Zero 2 u-bootv2018.05 source code isgcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi

4.3. Compile u-boot

1) First of all, it should be noted that there is no boot0 source code in the u-bootsource code, this part of the source code is currently not open, only the bin file of

Page 67: OrangePiZero2 UserManual

66

boot0 is provided

2) Run the build.sh script, remember to add sudo permissionstest@test:~/orangepi-build$ sudo ./build.sh

3) Select U-boot package, then press Enter

4) Then select the model of the development board

5) Then it will start to compile u-boot, some of the information prompted duringcompilation are explained as followsa.u-boot source version[ o.k. ] Compiling u-boot [ v2018.05 ]

b. The version of the cross-compilation toolchain[ o.k. ] Compiler version [ arm-linux-gnueabi-gcc 7.4.1 ]

c. Compile the generated u-boot deb package path[ o.k. ] Target directory [ orangepi-build/output/debs/u-boot ]

d. Package name of u-boot deb package generated by compiling[ o.k. ] File name [ linux-u-boot-legacy-orangepizero2_2.0.8_arm64.deb ]

e. Compilation time[ o.k. ] Runtime [ 1 min ]

f. Repeat the command to compile u-boot, use the following command without

Page 68: OrangePiZero2 UserManual

67

selecting through the graphical interface, you can start compiling u-boot directly[ o.k. ] Repeat Build Options [ sudo ./build.sh BOARD=orangepizero2BRANCH=legacy BUILD_OPT=u-boot KERNEL_CONFIGURE=no ]

6) View the compiled u-boot deb packagetest@test:~/orangepi-build$ ls output/debs/u-boot/linux-u-boot-legacy-orangepizero2_2.0.8_arm64.deb

7) The files contained in the generated u-boot deb package are as followsa. Use the following command to unzip the deb packagetest@test:~/orangepi-build$ cd output/debs/u-boottest@test:~/orangepi_build/output/debs/u-boot$ $ dpkg -x \linux-u-boot-legacy-orangepizero2_2.0.8_arm64.deb . (Note that there is a “.” atthe end of the command.)

test@test:~/orangepi_build/output/debs/u-boot$ lslinux-u-boot-current-orangepizero_2.0.8_armhf.deb usrb. The decompressed file is as followstest@test:~orangepi-build/output/debs/u-boot$ tree usr/usr/└── lib├── linux-u-boot-legacy-orangepizero2_2.0.8_arm64│ ├── boot0_sdcard.fex│ └── boot_package.fex└── u-boot├── LICENSE├── orangepi_zero2_defconfig├── orangepizero2-u-boot.dts└── platform_install.sh

3 directories, 6 files

8) When the orangepi-bulid build OS compiles the u-boot source code, it firstsynchronizes the u-boot source code with the u-boot source code of the github server,so if you want to modify the u-boot source code, you first need to turn off thedownload and update function of the source code (You need to compile u-boot onceto turn off this function, otherwise you will be prompted to find the source codeof u-boot), otherwise, the changes made will be restored, the method is as follows:

Set the IGNORE_UPDATES variable in userpatches/config-default.conf to "yes"test@test:~/orangepi-build$ vim userpatches/config-default.confIGNORE_UPDATES="yes"

9) When debugging u-boot code, you can use the following method to update u-bootin the linux image for testinga. Upload the compiled u-boot deb package to the linux OS of the development board

Page 69: OrangePiZero2 UserManual

68

test@test:~/orangepi-build$ cd output/debs/u-boottest@test:~/orangepi_build/output/debs/u-boot$ scp \linux-u-boot-legacy-orangepizero2_2.0.8_arm64.deb [email protected]:/root

b. Then log in to the development board, uninstall the installed deb package of u-bootroot@orangepi:~# apt purge -y linux-u-boot-orangepizero2-legacy

c. Install the new u-boot deb package just uploadedroot@orangepi:~# dpkg -i linux-u-boot-legacy-orangepizero2_2.0.8_arm64.deb

d. Then run the nand-sata-install scriptroot@orangepi:~# nand-sata-install

e. Then select 5 Install/Update the bootloader on SD/eMMC

f. After pressing the Enter key, a Warring will pop up first

g. Press Enter again to start updating u-boot, and the following information will bedisplayed after the update

Page 70: OrangePiZero2 UserManual

69

h. Then you can restart to test whether the u-boot modification has taken effect

4.4. Compile the Linux kernel

1) Run the build.sh script, remember to add sudo permissionstest@test:~/orangepi-build$ sudo ./build.sh

2) Select Kernel package, then press Enter

3) Then select the model of the development board

4) Then the kernel configuration interface opened through make menuconfig willpop up. At this time, you can directly modify the kernel configuration. If you don’tneed to modify the kernel configuration, just exit directly. After exiting, the kernelsource code will be compiled

Page 71: OrangePiZero2 UserManual

70

a. If you do not need to modify the configuration options of the kernel, when you runthe build.sh script, pass in KERNEL_CONFIGURE=no to temporarily block thepop-up kernel configuration interfacetest@test:~/orangepi-build$ sudo ./build.sh KERNEL_CONFIGURE=nob. You can also set KERNEL_CONFIGURE=no in the orangepi-build/userpatches/config-default.conf configuration file to disable this featurepermanentlyc. If the following error is prompted when compiling the kernel, this is because theterminal interface of the Ubuntu PC is too small and the make menuconfig interfacecannot be displayed. Please adjust the terminal of the Ubuntu PC to the maximum,and then rerun the build.sh script

5 ) When compiling the kernel source code, the following information will beprompteda. The version of the kernel source code[ o.k. ] Compiling legacy kernel [ 4.9.170 ]

Page 72: OrangePiZero2 UserManual

71

b. The version of the cross-compilation toolchain[ o.k. ] Compiler version [ aarch64-none-linux-gnu-gcc 9.2.1 ]

c. The default configuration file used by the kernel and its storage path[ o.k. ] Using kernel config file [ config/kernel/linux-sun50iw9-legacy.config ]

d. If KERNEL_CONFIGURE=yes, the final configuration file .config used by thekernel will be copied to output/config. If the kernel configuration is not modified, thefinal configuration file is consistent with the default configuration file[ o.k. ] Exporting new kernel config [ output/config/linux-sun50iw9-legacy.config ]

e. The path of the deb package related to the compiled kernel[ o.k. ] Target directory [ output/debs/ ]

f. The package name of the compiled kernel image deb package[ o.k. ] File name [ linux-image-legacy-sun50iw9_2.0.8_arm64.deb ]

g. Compilation time[ o.k. ] Runtime [ 5 min ]

h. In the end, it will display the compiling command to recompile the kernel selectedlast time. Use the following command without selecting through the graphicalinterface, you can directly start compiling the kernel source code[ o.k. ] Repeat Build Options [ sudo ./build.sh BOARD=orangepizero2BRANCH=legacy BUILD_OPT=kernel KERNEL_CONFIGURE=yes ]

6) View the deb package related to the kernel generated by the compilationa. linux-dtb-legacy-sun50iw9_2.0.8_arm64.deb is not used yet, don’t care about itb. linux-headers-legacy-sun50iw9_2.0.8_arm64.deb contains kernel header filesc. linux-image-legacy-sun50iw9_2.0.8_arm64.deb contains kernel image and

kernel moduletest@test:~/orangepi-build$ ls output/debs/linux-*output/debs/linux-dtb-legacy-sun50iw9_2.0.8_arm64.deboutput/debs/linux-headers-legacy-sun50iw9_2.0.8_arm64.deboutput/debs/linux-image-legacy-sun50iw9_2.0.8_arm64.deb

7) The files contained in the generated linux-image deb package are as followsa. Use the following command to unzip the deb packagetest@test:~/orangepi-build$ cd output/debstest@test:~/orangepi_build/output/debs$mkdir testtest@test:~/orangepi_build/output/debs$ cp \linux-image-legacy-sun50iw9_2.0.8_arm64.deb test/test@test:~/orangepi_build/output/debs$ cd testtest@test:~/orangepi_build/output/debs/test$ dpkg -x \

Page 73: OrangePiZero2 UserManual

72

linux-image-legacy-sun50iw9_2.0.8_arm64.deb .test@test:~/orangepi_build/output/debs/test$ lsboot etc lib linux-image-legacy-sun50iw9_2.0.8_arm64.deb usr

b. The decompressed file is as followstest@test:~/orangepi_build/output/debs/test$ tree -L 2.├── boot│ ├── config-4.9.170-sun50iw9│ ├── System.map-4.9.170-sun50iw9│ └── vmlinuz-4.9.170-sun50iw9├── etc│ └── kernel├── lib│ └── modules├── linux-image-legacy-sun50iw9_2.0.8_arm64.deb└── usr├── lib└── share

8 directories, 4 files

8) When the orangepi-bulid build OS compiles the linux kernel source code, it firstsynchronizes the linux kernel source code with the linux kernel source code of thegithub server, so if you want to modify the source code of the linux kernel, you firstneed to turn off the source code update function (you need to complete thecompilation once This function can only be turned off after the linux kernelsource code, otherwise it will be prompted that the source code of the linuxkernel cannot be found), otherwise the changes made will be restored.Set the IGNORE_UPDATES variable in userpatches/config-default.conf to "no"test@test:~/orangepi-build$ vim userpatches/config-default.confIGNORE_UPDATES="no"

9) If you modify the kernel, you can use the following methods to update the kerneland kernel modules of the Linux OS on the development boarda. Upload the compiled linux deb package to the linux OS of the development boardtest@test:~/orangepi-build$ cd output/debstest@test:~/orangepi-build/output/debs$ scp \linux-image-legacy-sun50iw9_2.0.8_arm64.deb [email protected]:/root

b. Then log in to the development board, uninstall the installed deb package of u-bootroot@orangepi:~# apt purge -y linux-image-legacy-sun50iw9

c. Install the new u-boot deb package just uploaded

Page 74: OrangePiZero2 UserManual

73

root@orangepi:~# dpkg -i linux-image-legacy-sun50iw9_2.0.8_arm64.deb

d. Then restart the development board, and then check whether the kernel-relatedchanges have taken effect

4.5. Compile rootfs

1) Run the build.sh script, remember to add sudo permissionstest@test:~/orangepi-build$ sudo ./build.sh

2) Select Rootfs and all deb packages, then press Enter

3) Then select the model of the development board

4) Then select the type of rootfsa. bustermeans Debian 10b. bionic means Ubuntu 18.04

5) Then select the type of imagea. Image with console interface represents the image of the server version, which

is relatively smallb. Image with the desktop environment means that the image with a desktop

version is relatively large

Page 75: OrangePiZero2 UserManual

74

6) If you are compiling the server version of the image, you can also choose tocompile the Standard version or the Minimal version. The pre-installed software ofthe Minimal version will be much less than the Standard version

7) After selecting the type of image, rootfs will be compiled, and the followinginformation will be prompted during the compilationa.Type of rootfs[ o.k. ] local not found [ Creating new rootfs cache for bionic ]

b. The storage path of the compiled rootfs compressed package[ o.k. ] Target directory [ external/cache/rootfs ]

e. The name of the rootfs compressed package generated by the compilation[ o.k. ] File name [ bionic-cli-arm64.153618961f14c28107ca023429aa0eb9.tar.lz4 ]

f. Compilation time[ o.k. ] Runtime [ 13 min ]

g. Repeat the command to compile rootfs, use the following command withoutselecting through the graphical interface, you can directly start compiling rootfs[ o.k. ] Repeat Build Options [ sudo ./build.sh BOARD=orangepizero2BRANCH=legacy BUILD_OPT=rootfs RELEASE=bionicBUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_CONFIGURE=yes ]

8) View the compiled rootfs compressed packagea. bionic-cli-arm64.153618961f14c28107ca023429aa0eb9.tar.lz4 is a compressedpackage of rootfs, the meaning of each field of the name isa. bionic represents the type of linux distribution of rootfsb. cli means rootfs is the server version type, if it is desktop, it means the desktop

version typec. arm64 represents the architecture type of rootfsd. 153618961f14c28107ca023429aa0eb9 is the MD5 hash value generated by the

package names of all software packages installed by rootfs. As long as the list ofsoftware packages installed by rootfs is not modified, this value will not change.The compilation script will use this MD5 hash value. Determine whether you

Page 76: OrangePiZero2 UserManual

75

need to recompile rootfsb. bionic-cli-arm64.153618961f14c28107ca023429aa0eb9.tar.lz4.list lists the packagenames of all packages installed by rootfstest@test:~/orangepi-build$ ls external/cache/rootfs/bionic-cli-arm64.153618961f14c28107ca023429aa0eb9.tar.lz4 bionic-cli-arm64.153618961f14c28107ca023429aa0eb9.tar.lz4.list

9) If the required rootfs already exists under external/cache/rootfs, then compilingthe rootfs again will skip the compilation process and will not restart the compilation.When compiling the image, it will also go to external/cache/rootfs to check whetherit is already Rootfs with cache available, if available, use it directly, which can save alot of download and compilation time

4.6. Compile linux image

1) Run the build.sh script, remember to add sudo permissionstest@test:~/orangepi-build$ sudo ./build.sh

2) Select Full OS image for flashing, then press Enter

3) Then select the model of the development board

4) Then select the type of rootfsa. buster means Debian 10b. bionic means Ubuntu 18.04

Page 77: OrangePiZero2 UserManual

76

4) Then select the type of imagea. Image with console interface represents the image of the server version, which isrelatively smallb. Image with the desktop environment means that the image with a desktopversion is relatively large

5) If you are compiling the server version of the image, you can also choose tocompile the Standard version or the Minimal version. The pre-installed software ofthe Minimal version will be much less than the Standard version.

6) After selecting the type of image, it will start to compile the Linux image. Thegeneral process of compilation is as followsa. Initialize the compilation environment of Ubuntu PC and install the softwarepackages needed for the compilation processb. Download the source code of u-boot and linux kernelc. Compile u-boot, generate u-boot deb packaged. Compile linux source code and generate linux related deb packagee. Make deb package of linux firmwaref. Make deb package of orangepi-config toolg. Make board-level support deb packageh. If it is to compile the desktop version image, it will also make desktop related debpackagesi. Check whether the rootfs has been cached, if there is no cache, then re-create therootfs, if it has been cached, directly unzip and usej. Install the previously generated deb package into rootfsk. Make some specific settings for different development boards and different types ofimages, such as pre-installing additional software packages, modifying configurationfiles, etc.l. Then make an image file and format the partition, the default type is ext4m. Copy the configured rootfs to the image partitionn. Then update the initramfs

Page 78: OrangePiZero2 UserManual

77

o. Finally, the bin file of u-boot is written to the image through the dd command

7) After compiling the image, the following information will be prompteda. The storage path of the compiled image[ o.k. ] Done building[ output/images/Orangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170/Orangepizero2_2.0.8_ubuntu_bionic_server_linux4.9.170.img ]

b. Compilation time[ o.k. ] Runtime [ 19 min ]

c. Repeat the command to compile the image, use the following command withoutselecting through the graphical interface, you can directly start to compile the image[ o.k. ] Repeat Build Options [ sudo ./build.sh BOARD=orangepizero2BRANCH=legacy BUILD_OPT=image RELEASE=bionicBUILD_MINIMAL=no BUILD_DESKTOP=no KERNEL_CONFIGURE=yes ]

5. Android OS instructions

5.1. Supported Android version

Android version kernel versionAndroid 10.0 linux4.9

5.2. Android 10 feature adaptation

Features StatusHDMI video OKHDMI audio OKUSB2.0 x 3 OKTF card boot OKNetwork card OK

IR OKWIFI OK

WIFI hotsport OKBluetooth OK

Bluetooth earphone OKBLE Bluetooth OKCVBS audio OKCVBS video OKUSB camera OKLED lights OK

Temperature Sensor OK

Page 79: OrangePiZero2 UserManual

78

Hardware watchdog OKMali GPU OKVideo codec OK

5.3. Onboard LED light display description

Green light Red lightU-boot startup phase OFF ONKernel boot to enter system ON OFFGPIO PC13 PC12

5.4. How to use ADB?

5.4.1. Open USB debugging option1) Select Settings

2) Then select Device Preferences

3) Then select Developer options

Page 80: OrangePiZero2 UserManual

79

4) Finally find USB debugging, make sure it is turned on

5.4.2. Use data cable to connect adb debugging

1) First make sure to turn on the USB debugging option

2) Prepare a USB Type C interface data cable. One end of the USB interface isinserted into the USB interface of the computer, and the other end of the Type Cinterface is inserted into the power interface of the development board. In this case,the USB interface of the computer supplies power to the development board, so pleaseensure that the USB interface of the computer can provide the powerful to drive thedevelopment board.

3) Install adb tool on Ubuntu PCtest@test:~$ sudo apt updatetest@test:~$ sudo apt install adb

Page 81: OrangePiZero2 UserManual

80

4) View the identified ADB devicetest@test:~$ adb devicesList of devices attached8c00141167058911ccd device

5) Then you can log in to the android OS through adb shell on the Ubuntu PCtest@test:~$ adb shellcupid-p2:/ #

5.4.3. Use network connection adb debugging1) Using the network adb does not require a USB Typc C interface data cable toconnect the computer and the development board, but communicates through thenetwork, so first make sure that the wired or wireless network of the developmentboard is connected, and then obtain the IP address of the development board for to beused next

2) Make sure that the USB debugging option is turned on

3) Make sure that the service.adb.tcp.port of the Android OS is set to port number5555cupid-p2:/ # getprop | grep "adb.tcp"[service.adb.tcp.port]: [5555]

5) If service.adb.tcp.port is not set, you can use the following command to set the portnumber of the network adbcupid-p2:/ # setprop service.adb.tcp.port 5555cupid-p2:/ # stop adbdcupid-p2:/ # start adbd

6) Install adb tool on Ubuntu PCtest@test:~$ sudo apt updatetest@test:~$ sudo apt install adb

7) Then connect to the network adb on Ubuntu PCtest@test:~$ adb connect 192.168.1.xxx (The IP address needs to be modified tothe IP address of the development board)* daemon not running; starting now at tcp:5037* daemon started successfullyconnected to 192.168.1.xxx:5555

test@test:~$ adb devicesList of devices attached192.168.1.xxx:5555 device

Page 82: OrangePiZero2 UserManual

81

6) Then you can log in to the android OS through adb shell on Ubuntu PCtest@test:~$ adb shellcupid-p2:/ #

5.5. How to use a USB camera

1) First insert the USB camera into the USB interface of the development board, andthen confirm that the kernel module related to the USB camera has been loadednormallyconsole:/ # lsmodModule Size Used bysprdwl_ng 405504 0sprdbt_tty 36864 2uwe5622_bsp_sdio 274432 2 sprdwl_ng,sprdbt_ttyuvcvideo 102400 0videobuf2_v4l2 28672 1 uvcvideovideobuf2_vmalloc 16384 1 uvcvideovideobuf2_memops 16384 1 videobuf2_vmallocvideobuf2_core 49152 2 uvcvideo,videobuf2_v4l2mali_kbase 532480 7

2) If the USB camera is recognized normally, the corresponding video device nodewill be generated under /dev

3) Then make sure that the adb connection between the Ubuntu PC and thedevelopment board is normal

4) Download the USB camera test APP from the official tool on the page below theOrange Pi Zero 2 information

5) Then use the adb command to install the USB camera test APP to the Android OS,of course, you can also use the U disk copy method to installtest@test:~$ adb install usbcamera.apk

Page 83: OrangePiZero2 UserManual

82

6) After installation, you can see the startup icon of the USB camera on the Androiddesktop

7) Then double-click to open the USB camera APP and you can see the output videoof the USB camera

5.6. Android OS ROOT description

The Android 10.0 OS released by Orange Pi is already ROOT, you can use thefollowing method to test

1) Download rootcheck.apk from the official tool on the Orange Pi Zero 2 datadownload page

2) Then make sure that the adb connection between the Ubuntu PC and thedevelopment board is normal

3) Then use the adb command to install rootcheck.apk to the Android OS, of course,you can also use the U disk copy to installtest@test:~$ adb install rootcheck.apk

4) After installation, you can see the startup icon of the ROOT test tool on theAndroid desktop

Page 84: OrangePiZero2 UserManual

83

5) The display interface after opening the ROOT test tool for the first time is asshown in the figure below

6) Then you can click "Check now" to start the inspection of the ROOT status of theAndroid OS. The display after the inspection is as follows, you can see that theAndroid OS has obtained ROOT permission

Page 85: OrangePiZero2 UserManual

84

6. Android SDK instructions

1) The compilation of the Android SDK is performed on a PC with Ubuntu 14.04installed, and other versions of Ubuntu OS may have some differences

2) Android SDK is the original SDK released by the chip manufacturer. If you want touse the Android image compiled by the Android SDK on the Orange Pi developmentboard, you need to adapt to different boards to ensure that all functions are usednormally

6.1. Download the source code of android SDK

1) The android source code of H616 contains the following 4 filesa. android.tar.gzxx: android source codeb. android.tar.gz.md5sum:MD5 checksum file of android.tar.gzxxc. longan.tar.gz: Contains u-boot, linux kernel source code (does not include boot0

source code)d. longan.tar.gz.md5sum:MD5 checksum file of longan.tar.gz

2) After downloading the android source code, first check whether the MD5checksum is correct, if not, please download the source code againtest@test:~$ md5sum -c android.tar.gz.md5sumandroid.tar.gzaa: OKandroid.tar.gzab: OKandroid.tar.gzac: OKandroid.tar.gzad: OKandroid.tar.gzae: OKandroid.tar.gzaf: OKandroid.tar.gzag: OK

Page 86: OrangePiZero2 UserManual

85

android.tar.gzah: OKandroid.tar.gzai: OKandroid.tar.gzaj: OKandroid.tar.gzak: OKtest@test:~$ md5sum -c longan.tar.gz.md5sumlongan.tar.gz: OK

3) Then unzip the android source codea. android: store android-related source codeb. longan: store the source code of the linux kernel and u-boot (not including thesource code of boot0), and other configuration filestest@test:~$ cat android.tar.gza* | tar -zxtest@test:~$ tar -zxf longan.tar.gztest@test:~$ lsandroid longan

6.2. Build android compilation environment

1) Install JDKtest@test:~$ sudo add-apt-repository ppa:openjdk-r/ppatest@test:~$ sudo apt-get updatetest@test:~$ sudo apt-get install openjdk-8-jdk

2) Configure JAVA environment variablesa. First determine the installation path of java, generallytest@test:~$ ls /usr/lib/jvm/java-8-openjdk-amd64ASSEMBLY_EXCEPTION bin docs include jre lib man src.zipTHIRD_PARTY_README

b. Then use the following command to export java environment variablestest@test:~$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64test@test:~$ export PATH=$JAVA_HOME/bin:$PATHtest@test:~$ exportCLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

3) Use Ubuntu 14.04 to compile the source code of android 10, you need to ensurethat Ubuntu 14.04 uses the linux 4.4 kernel, otherwise an error will be reported whencompiling, if the kernel is not linux 4.4, please upgrade the kerneltest@test:~$ uname -aLinux ubuntu 4.4.0-142-generic #168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

4) Install platform support software

Page 87: OrangePiZero2 UserManual

86

test@test:~$ sudo apt-get updatetest@test:~$ sudo apt-get install git gnupg flex bison gperf build-essential \zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache \libgl1-mesa-dev libxml2-utils xsltproc unzip

test@test:~$ sudo apt-get install u-boot-tools

6.3. Compile android image

6.3.1. Compile the kernel1) First configure the compilation environmenttest@test:~$ cd longantest@test:~/longan$ ./build.sh config

Welcome to mkscript setup progressAll available platform:0. android1. linux

Choice [android]: 0All available ic:0. h3131. h6162. h700

Choice [h616]: 1All available board:0. fpga1. ft2. p13. p24. perf15. perf1_axp1526. perf27. perf38. qa

Choice [p2]: 3INFO: kernel defconfig: generate /wspace2/H616/Android_10/longan/kernel/linux-4.9/.config by /wspace2/H616/Android_10/longan/kernel/linux-4.9/arch/arm64/configs/sun50iw9p1smp_h616_android_defconfig*** Default configuration is based on 'sun50iw9p1smp_h616_android_defconfig'## configuration written to .config

Page 88: OrangePiZero2 UserManual

87

#

2) Then start compilingtest@test:~/longan$ ./build.sh

3) The output after compilation is as followssun50iw9p1 compile Kernel successful

INFO: build kernel OK.INFO: build rootfs ...INFO: skip make rootfs for androidINFO: ----------------------------------------INFO: build lichee OK.INFO: ----------------------------------------

6.3.2. Compile android source code1) The command to compile android is as followstest@test:~$ cd androidtest@test:~/android$ source build/envsetup.shtest@test:~/android$ lunch cupid_p2-engtest@test:~/android$ extract-bsptest@test:~/android$ make -j8

2) After compiling, the following information will be printed#### build completed successfully (01:51 (mm:ss)) ####

3) Then use the pack command to package and generate the android imagetest@test:~/android$ pack......----------image is at----------

longan/out/h616_android10_p2_uart0.img

pack finishuse pack4dist for release

4) The storage path of the generated Android image islongan/out/h616_android10_p2_uart0.img