NanoPi NEO4
Contents
- 1 Introduction
- 2 Hardware Spec
- 3 Diagram, Layout and Dimension
- 4 Get Started
- 5 Access hardware
- 6 Work with FriendlyDesktop
- 6.1 Account & Password
- 6.2 WiFi Connection
- 6.3 HDMI/DP LCD Resolution
- 6.4 Adjust HDMI overscan
- 6.5 eDP LCD Display Rotation
- 6.6 Test OpenGL ES
- 6.7 4K Video Playing
- 6.8 Work with USB Camera
- 6.9 File Transfer with Bluetooth
- 6.10 Install OpenCV
- 6.11 Develop Qt Applications
- 6.12 WiringPi and Python Wrapper
- 6.13 Switch audio default output device
- 6.14 Play RTSP video stream (or IP Camera)
- 6.15 Chromium web browser
- 6.16 Screen saver and auto sleep related settings
- 6.17 Install Scratch
- 6.18 Install Arduino IDE
- 6.19 Start the program automatically at startup
- 6.20 Login to the desktop as the root user
- 6.21 Using Camera on Linux (MIPI Camera OV13850 & OV4689, and webcam logitect C920)
- 7 Work with FriendlyCore
- 7.1 Introduction
- 7.2 System Login
- 7.3 Configure System with npi-config
- 7.4 Develop Qt Application
- 7.5 Setup Program to AutoRun
- 7.6 Extend TF Card's Section
- 7.7 Transfer files using Bluetooth
- 7.8 WiFi
- 7.9 Ethernet Connection
- 7.10 WiringPi and Python Wrapper
- 7.11 Custom welcome message
- 7.12 Modify timezone
- 7.13 Select the system default audio device
- 7.14 Run the X11 application
- 7.15 Using Camera on Linux (MIPI Camera OV13850 & OV4689, and webcam logitect C920)
- 8 Work with Lubuntu
- 8.1 Introduction to Lubuntu
- 8.2 Lubuntu Default User Account
- 8.3 OpenGL ES
- 8.4 Video Playing with Hardware Decoding
- 8.5 eDP LCD Rotation
- 8.6 Connect USB Camera
- 8.7 5G WiFi
- 8.8 Develop Qt Application
- 8.9 Chromium web browser
- 8.10 Cancel automatic login
- 8.11 Screen saver and auto sleep related settings
- 8.12 Select the system default audio device
- 9 Work with Android 8.1
- 9.1 Connect MIPI Camera to NanoPi-NEO4
- 9.2 Use dual MIPI camera preview and video
- 9.3 Change system language
- 9.4 Android8.1 hardware access
- 9.5 Android Neural Networks SDK Sample
- 9.6 Using the adb
- 9.7 HDMI resolution and overscan setting
- 9.8 Screen rotation
- 9.9 Hide Navigation bar
- 9.10 Switch audio output channel
- 9.11 Adjust the volume of the recording
- 9.12 Custom logo and boot animation
- 9.13 Remove Google Framework
- 9.14 Work with USB Camera to Take Pictures and Record Video
- 10 Work with Android7.1
- 10.1 Build Openwrt/Friendlywrt
- 10.2 Build Buildroot
- 10.3 Build Other Linux
- 10.4 Build the code using scripts
- 10.5 Building AOSP from source
- 11 The usage of eMMC module
- 12 Using On-Board Hardware Resources
- 13 Source code repositories
- 14 Link to Rockchip Resources
- 15 Schematic, PCB CAD File
- 16 Update Log
1 Introduction
- The NanoPi NEO4 is a RK3399 SoC based ARM board. Its PCB size is only 60 x 45 mm and has rich hardware resources. These features make it a good platform for rapid product prototyping and various applications.
- NanoPi NEO4 has 1GB RAM, an onboard 2.4G wireless module, and rich hardware resources, such as USB3.0, USB2.0, PCIe, GbE, HDMI, MIPI-CSI, eMMC socket, SPI, GPIO, I2C, PWM, RTC, UART, etc.
- NanoPi NEO4 can be booted from either a TF card or an external eMMC module.
- The NanoPi NEO4 supports Ubuntu Desktop 18.04(64-bit), Lubuntu 16.04(32-bit), Ubuntu Core 18.04(64-bit) and Lubuntu Desktop with GPU and VPU acceleration. With these rich resources and powerful performance it can be widely used in applications of machine learning, AI, deep learning, robots, industrial control, industrial cameras, advertisement machines, game machines, blockchain and etc.
2 Hardware Spec
- SoC: Rockchip RK3399
- CPU: big.LITTLE,Dual-Core Cortex-A72(up to 2.0GHz) + Quad-Core Cortex-A53(up to 1.5GHz)
- GPU: Mali-T864 GPU,supports OpenGL ES1.1/2.0/3.0/3.1, OpenVG1.1, OpenCL, DX11, and AFBC
- VPU: 4K VP9 and 4K 10bits H265/H264 60fps decoding, Dual VOP, etc
- PMU: RK808-D PMIC, cooperated with independent DC/DC, enabling DVFS, solfware power-down, RTC wake-up, system sleep mode
- RAM: 1GB DDR3-1866
- Flash: no Onboard eMMC, but has a eMMC socket
- Ethernet: Native Gigabit Ethernet
- Wi-Fi/BT: 802.11 b/g/n, Bluetooth 4.0 combo module
- Video Input: one 4-Lane MIPI-CSI, up to 13MP
- Video output: HDMI: HDMI 2.0a, supports 4K@60Hz,HDCP 1.4/2.2
- Audio Out: HDMI
- USB 3.0: 1x USB 3.0 Host Type-A
- USB 2.0: 2x USB 2.0 Host, one is Type-A, the other is 2.54mm header
- USB Type-C: Supports USB2.0 OTG and Power input
- microSD Slot x 1
- GPIO1, 40Pin GPIO:
- 2 X 3V I2C, 1x 3V UART/SPI, 1 x SPDIF_TX, up to 8 x 3V GPIOs
- PCIe x2
- PWM x1, PowerKey
- GPIO2:
- 1 x 1.8V 8ch-I2S
- GPIO3:
- debug uart, 3V level, 1500000bps
- USB 2.0 x1
- LED: 1 x power LED and 1 x GPIO Controled LED
- RTC Battery: 2 Pin 2.54mm pitch through-hole pads
- Power supply: 5V/3A
- PCB: 8 Layer, 60 mm x 45 mm
- Ambient Operating Temperature: -20℃ to 70℃
3 Diagram, Layout and Dimension
3.1 Layout
- GPIO1,40-Pin Spec
Pin# Assignment Pin# Assignment 1 VCC3V3_SYS 2 VDD_5V 3 I2C2_SDA(3V) 4 VDD_5V 5 I2C2_SCL(3V) 6 GND 7 GPIO1_A0(3V) 8 GPIO4_C1/I2C3_SCL(3V) 9 GND 10 GPIO4_C0/I2C3_SDA(3V) 11 GPIO1_A1(3V) 12 GPIO1_C2(3V) 13 GPIO1_A3(3V) 14 GND 15 GPIO1_A4(3V) 16 GPIO1_C6(3V) 17 VCC3V3_SYS 18 GPIO1_C7(3V) 19 SPI1_TXD/UARNEO4_TX(3V) 20 GND 21 SPI1_RXD/UARNEO4_RX(3V) 22 GPIO1_D0(3V) 23 SPI1_CLK(3V) 24 SPI1_CSn0(3V) 25 GND 26 GPIO4_C5/SPDIF_TX(3V) 27 PCIE_REF_CLKP 28 GPIO4_C6/PWM1(3V) 29 PCIE_REF_CLKN 30 PWR_KEY 31 GND 32 GND 33 PCIE_TX0P 34 PCIE_TX1P 35 PCIE_TX0N 36 PCIE_TX1N 37 PCIE_RX0_P 38 PCIE_RX1_P 39 PCIE_RX0_N 40 PCIE_RX1_N
- GPIO2,8-Pin I2S Spec
- I2S signals is 1.8V level
Pin# Assignment Pin# Assignment 1 GND 2 I2S0_SDI0 3 VCC5V0_SYS 4 I2S0_SDI1SDO3 5 I2S0_LRCK_RX 6 I2S0_SDI2SDO2 7 I2S0_SCLK 8 I2S0_SDI3SDO1
- GPIO3,8-Pin UART/USB Spec
- debug uart is 3V level, 1500000bps
Pin# Assignment Description Pin# Assignment Description 1 UART2DBG_RX debug uart intput 2 VCC5V0_SYS 5V power output 3 UART2DBG_TX debug uart output 4 HOST1_DM USB 2.0 data - 5 VCC5V0_SYS 5V power output 6 HOST1_DP USB 2.0 data + 7 GND 0V 8 GND 0V
- MIPI-CSI Interface Pin Spec
- 0.5mm FPC Connector
Pin# MIPI-CSI1 Description 1 VCC5V0_SYS 5V Power ouput 2 VCC5V0_SYS 5V Power ouput 3 GND Return current path 4 VCC_CSI_AF2.8V 2.8V Power for VCM 5 VCC_CSI_1.2V 1.2V Power for image sensor core circuit 6 VCC1V8_CAM 1.8V power for I/O circuit 7 VCC_CSI_2.8V 2.8V power for image sensor analog circuit 8 VCC_CSI_1.0V 1.0V Power for image sensor core circuit 9 I2C1_SCL 1.8V I2C clock signal 10 I2C1_SDA 1.8V I2C data signal 11 MIPI_CSI0_RST reset camera module 12 MIPI_CSI0_PWN Power down camera module 13 GND Return current path 14 GPIO2_B3_CIF_CLKOUTA MCLK to camera module 15 GND Return current path 16 MIPI_RX0_D3P MIPI CSI positive differential data line transceiver output 17 MIPI_RX0_D3N MIPI CSI negative differential data line transceiver output 18 GND Return current path 19 MIPI_RX0_D2P MIPI CSI positive differential data line transceiver output 20 MIPI_RX0_D2N MIPI CSI negative differential data line transceiver output 21 GND Return current path 22 MIPI_RX0_D1P MIPI CSI positive differential data line transceiver output 23 MIPI_RX0_D1N MIPI CSI negative differential data line transceiver output 24 GND Return current path 25 MIPI_RX0_CLKP MIPI CSI positive differential clock line transceiver output 26 MIPI_RX0_CLKN MIPI CSI negative differential clock line transceiver output 27 GND Return current path 28 MIPI_RX0_D0P MIPI CSI positive differential data line transceiver output 29 MIPI_RX0_D0N MIPI CSI negative differential data line transceiver output 30 GND Return current path
- eMMC Socket Pin Spec
Pin# Assignment Pin# Assignment 1 EMMC_D0 2 EMMC_D1 3 EMMC_D2 4 EMMC_D3 5 EMMC_D4 6 EMMC_D5 7 EMMC_D6 8 EMMC_D7 9 EMMC_STRB 10 GND 11 EMMC_CMD 12 EMMC_CLKO 13 N/C 14 GND 15 N/C 16 VCC1V8_S3 17 eMMC_RST 18 VCC3V3_S3 19 GND 20 GND
- USB Port
- USB Type-A has 2A overcurrent protection.
- RTC
- RTC backup current is 27uA.
- Notes
- Power Input : 5V/3A, via USB Type-C or Pin2&Pin4 of the 40-pin GPIO1 header
- For more details refer to the Schematic: NanoPi-NEO4-1808-Schematic.pdf
3.2 Board Dimension
- For more details refer to the CAD document: NanoPi-NEO4-1808-Drawing(dxf).zip
4 Get Started
4.1 Essentials You Need
Before starting to use your NanoPi-NEO4 get the following items ready
- NanoPi-NEO4
- Type-C cable
- TF Card: Class 10 or Above, minimum 8GB SDHC
- USB to serial adapter(optinal, for debugging or access from PC host)
- 5V/3A Power adapter
- HDMI monitor or LCD
- USB keyboard, mouse and possible a USB hub(or a TTL to serial board)
- A host computer running Ubuntu 18.04 64-bit system
4.2 Boot from SD Card
Get the following files from here download link:
- Get an 8G SDHC card and backup its data if necessary.
Image Files | |
rk3399-sd-debian-bullseye-core-4.19-arm64-YYYYMMDD.img.gz | Debian 11(Bullseye) Core, No desktop environment, command line only, Kernel version 4.19.y |
rk3399-sd-debian-buster-desktop-arm64-YYYYMMDD.img.gz | Debian 10(buster) Desktop, Uses LXDE as default desktop, Supports hardware acceleration, Kernel version 4.19.y |
rk3399-sd-buildroot-linux-4.19-arm64-YYYYMMDD.img.zip | Buildroot image file with Qt5-wayland (base on Rockchip Linux SDK) |
rk3399-sd-friendlydesktop-bionic-4.4-arm64-YYYYMMDD.img.zip | FriendlyDesktop image file with X Window (base on Ubuntu 18.04 64bit) |
rk3399-sd-friendlycore-bionic-4.4-arm64-YYYYMMDD.img.gz | FriendlyCore with Qt 5.10.0 (base on Ubuntu core 18.04) image file, kernel 4.4 |
rk3399-sd-friendlycore-focal-4.19-arm64-YYYYMMDD.img.gz | FriendlyCore with Qt 5.10.0 (base on Ubuntu core 20.04) image file, kernel 4.19 |
rk3399-sd-friendlycore-lite-focal-5.15-arm64-YYYYMMDD.img.gz | Lite version, No pre-installed Qt, Base on Ubuntu core 20.04, kernel 5.15 |
rk3399-sd-lubuntu-desktop-xenial-4.4-armhf-YYYYMMDD.img.zip | Lubuntu Desktop image file with X Window |
rk3399-sd-android10-YYYYMMDD.img.gz | Android 10 |
rk3399-sd-friendlywrt-YYYYMMDD.img.zip | FriendlyWrt image file, based on OpenWrt 21.02, kernel version 5.15.y |
rk3399-sd-friendlywrt-21.02-docker-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 21.02, Pre-installed Docker,kernel version 5.15.y |
rk3399-sd-friendlywrt-22.03-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 22.03,kernel version 5.15.y |
rk3399-sd-friendlywrt-22.03-docker-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 22.03, Pre-installed Docker,kernel version 5.15.y |
rk3399-sd-friendlywrt-kernel4-YYYYMMDD.img.zip | FriendlyWrt image file, based on OpenWrt 21.02, kernel version 4.19.y |
Flash Utility: | |
win32diskimager.rar | Windows utility. Under Linux users can use "dd" |
- Extract these files. Insert an SD card(at least 8G) into a Windows PC and run the win32diskimager utility as administrator. On the utility's main window select your SD card's drive, the wanted image file and click on "write" to start flashing the SD card.
- Insert this card into your board's boot slot and power on, If the PWR LED is on and LED1 is blinking this indicates your board has successfully booted.
- The Android system does not support starting from the SD card. If you need to run the Android system, please buy the eMMC module, and then burn the Android system to the eMMC to run, referring to the following section.
5 Access hardware
5.1 Access Serial Interface
For now only UART4 is available for users:
Serial Interface Serial Device UART0 Used by Bluetooth UART1 Used by Gbps Ethernet UART2 Used by Serial Debug Port UART3 Used by Gbps Ethernet UART4 Available, device name is /dev/ttyS4 (note: this is only applicable for ROM released after 20180618)
6 Work with FriendlyDesktop
FriendlyDesktop is a light-weighted Ubuntu desktop system. It is based on LXDE and has the following features:
Latest Version - Based on Ubuntu 18.04 64
Various Development Utilities - It is compatible with FriendlyCore and has integrated an optimized Qt5.10, QtCreator and Arduino IDE.
Light-weighted - it consumes relatively less CPU resources than a common desktop system. When a system's RAM is sufficient it can achieve much better performance.
Less Power Consumption - it consumes relatively less power or resources than a common desktop system to achieve the same performance.
Compact and Neat - its desktop is based on GTK+ 2 and it supports multiple languages.
Easy to Use - its GUI looks similar to MS Windows'.
Customizable - Users can customize LXDE's GUI.
Compatible - it is compatible with freedesktop.org.
FriendlyELEC has optimized support for Mali GPU and VPU in FriendlyDesktop for RK3399 and integrated drivers for X.org. FriendlyDesktop supports Hardware Cursor, OpenGL graphic acceleration, 4K video playing with hardware decoding.
6.1 Account & Password
Regular Account:
User Name: pi Password: pi
Root:
User Name: root Password: fa
6.2 WiFi Connection
Click on the icon on the top right in the FriendlyDesktop's main window, select your wanted WiFi hotspot and proceed with prompts
6.3 HDMI/DP LCD Resolution
Open the system's menu and go to Perferences -> Monitor Settings to customize your settings.
Recommended resolution: 1920x1080@60Hz
6.4 Adjust HDMI overscan
Open the command line terminal and enter the command to operate, Note:
1) You need to login to the desktop;
2) If you are using ssh terminal, please use the same username as the desktop login. The default is pi. You cannot use the root user. you also need to assign the DISPLAY variable:
export DISPLAY=:0.0
6.4.1 Query which resolutions the display supports
xrandr -q
6.4.2 Set resolution
For example set to 1920X1080@60Hz:
xrandr --output HDMI-1 --mode 1920x1080 --refresh 60
6.4.3 Adjust the HDMI overscan
For example, the transformation scaling horizontal coordinates by 0.8, vertical coordinates by 1.04 and moving the screen by 35 pixels right and 19 pixels down:
xrandr --output HDMI-1 --transform 0.80,0,-35,0,1.04,-19,0,0,1
6.4.4 Automatic adjustment at boot
Edit ~/.config/autostart/lxrandr-autostart.desktop,Write the full xrandr command to the key at the beginning of "Exec= as shown below:
[Desktop Entry] Type=Application Name=LXRandR autostart Comment=Start xrandr with settings done in LXRandR Exec=sh -c 'xrandr --output HDMI-1 --mode 1920x1080 --refresh 50 --transform 1.04,0,-35,0,1.05,-30,0,0,1' OnlyShowIn=LXDE
6.5 eDP LCD Display Rotation
If you want to rotate an eDP LCD's display you can do it by commanding "xrotate.sh" to rotate its display to 90/180/270 degrees. You can rotate display clockwise by 90 degrees by running the following command as root. This command calls lightdm to make your change effective immediately:
sudo xrotate.sh -m CW -r
For more details about its options you can run "xrotate -h".
Note: this command doesn't support HDMI display's rotation. If you want to rorate an HDMI's display you need to refer to X11's tech documents and make changes in "/etc/X11/xorg.conf".
Note: when you play a video with hardware decoding your player's display window doesn't rotate with your LCD's display
6.6 Test OpenGL ES
You can test it by clicking on the Terminator icon to start a commandline utility in the System Tools and run the following commands:
taskset -c 4-5 glmark2-es2
6.7 4K Video Playing
6.7.1 Play with Qt Player with Hardware Decoding
FriendlyDesktop has integrated a Qt5-VideoPlayer utility. This utility has support for Rockchip's gstreamer plug-in and supports 4K video playing with hardware decoding. You can start it by following the steps below:
On FriendlyDesktop's main window open "Sound & Video" and click on "Qt5-VideoPlayer".
On the player's main window click on the bottom left's "Open" button to load a video file and double-click on its name on the file list to start video playing. Here is how it looks like. You can set the display window to full screen and adjust the volume:
Qt5-VideoPlayer source code: https://github.com/friendlyarm/rk-player-qt
6.7.2 Play with Linux Command
You can play it by running the following command in a commandline utility:
gst-player.sh
By default its voice will be output to audio jack. You can locate this script by commanding "which gst-player.sh". You can customize its behavior by making changes in this script.
6.8 Work with USB Camera
Insert the USB camera (such as Logitech C270/C920) into the development board. Double click the "USB Camera" icon on desktop will pop up the luvcview gui (need to use the 2019/05/11+ version firmware).
the luvcview tool is an open source software that you can compile yourself:
git clone https://github.com/ksv1986/luvcview cd luvcview make
View the usage of luvcview:
./luvcview -h
Parameter Description:
luvcview version 0.2.1 Usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r] -h print this message -d /dev/videoX use videoX device -g use read method for grab instead mmap -w disable SDL hardware accel. -f video format default jpg others options are yuv jpg -i fps use specified frame interval -s widthxheight use specified input size -c enable raw frame capturing for the first frame -C enable raw frame stream capturing from the start -S enable raw stream capturing from the start -o avifile create avifile, default video.avi -L query valid video formats -l query valid controls and settings -r read and set control settings from luvcview.cfg
To preview USB camera (640x360@30fps), you can use the following command:
./luvcview -d /dev/video8 -i 30 -s 640x360
As you can see from the output of luvcview, hardware acceleration has been turned on:
pi@NanoPC-T4:/etc/xrdp$ luvcview -d /dev/video8 -i 30 -s 640x360 luvcview version 0.2.1 interval: 30 fps Hardware acceleration available video /dev/video8
6.9 File Transfer with Bluetooth
Click on the "Preferences" in the main window's menu to start Bluetooth Manager and click on "Search" to search surrounding Bluetooth devices. Click on your wanted device, pair the device with your board and you will be able to do file transfer, here is how it looks like:
6.10 Install OpenCV
OpenCV has been pre-installed in FriendlyCore/FriendlyDesktop (Version after 201905) and does not require manual installation.
Please refre this link: https://github.com/friendlyarm/install-opencv-on-friendlycore/blob/rk3399/README.md
6.11 Develop Qt Applications
FriendlyDesktop has a Qt 5.10.0 which supports RK3399's OpenGL ES and Gstreamer 1.0 hardware acceleration and a QtCreator IDE which is ready and can be used to compile and run applications. Here is how it looks like:
When running the Qt app, you need to specify the platform parameter to xcb as follows:
./HelloQt --platform xcb
6.12 WiringPi and Python Wrapper
6.13 Switch audio default output device
6.13.1 View the current default output device
On the terminal of the non-root user, enter the following command:
pactl info -vvv
The information displayed contains the following, indicating that the current audio output is directed to the headset:
Default Sink: alsa_output.platform-rt5651-sound.stereo-fallback
The information displayed contains the following, indicating that the current audio output is to HDMI:
Default Sink: alsa_output.platform-hdmi-sound.stereo-fallback
6.13.2 Set headphone jack as the default output device
On the terminal of the non-root user, enter the following command:
pactl set-default-sink alsa_output.platform-rt5651-sound.stereo-fallback
Set default volume to 20%:
pactl -- set-sink-volume alsa_output.platform-rt5651-sound.stereo-fallback 20%
6.13.3 Set hdmi as the default output device
On the terminal of the non-root user, enter the following command:
pactl set-default-sink alsa_output.platform-hdmi-sound.stereo-fallback
6.13.4 View settings have taken effect
cat /var/lib/pulse/*-default-sink
6.13.5 Temporary switching during playback
This method is only valid for the current playback process:
Open the menu "Sound & Video" -> "PulseAudio Volume Control", click the "Built-in Audio Stereo" button on the interface to switch between different output devices, such as switching between HDMI and headphone jack.
6.14 Play RTSP video stream (or IP Camera)
Open a command line terminal and enter the following command:
gst-launch-1.0 rtspsrc location="rtsp://admin:12345@192.168.1.120:554/live/main" ! rtph264depay ! decodebin ! rkximagesink
Change the address after rtsp:// to the real address.
6.15 Chromium web browser
Chromium web browser has enabled hardware acceleration by default, supports WebGL, and can view hardware acceleration details by entering the URL chrome://gpu, as shown below:
The screen saver configuration file is /etc/xdg/autostart/xset_command.desktop. The default factory settings are that the screen saver and DPMS are both closed. You can change the configuration by modifying this file.
6.17 Install Scratch
enter the following command:
sudo apt-get install scratch:arm64
6.18 Install Arduino IDE
enter the following command:
sudo apt-get install arduino:arm64
6.19 Start the program automatically at startup
Put the desktop file in the ~/.config/autostart/ directory, for example:
cp /usr/share/applications/org.qt-project.qtcreator.desktop ~/.config/autostart/
6.20 Login to the desktop as the root user
Edit the /root/.profile file:
sudo vim /root/.profile
Replace with the following:
if [ -n "$BASH_VERSION" ]; then if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi
Run the following command to modify the lightdm configuration file and change the automatically logged-in user name to root:
sudo sed -i 's/autologin-user=pi/autologin-user=root/g' /usr/share/lightdm/lightdm.conf.d/20-defaultsession.conf
Run the reboot command to restart:
sudo reboot
If you want to log in, the desktop icons and configuration are the same as the pi user, you can copy the relevant directory from the /home/pi directory:
sudo rm -rf /root/Desktop /root/Pictures /root/.config sudo cp -af /home/pi/Desktop /home/pi/Pictures /home/pi/.config /root/ sudo chown root:root /root/Desktop /root/Pictures /root/.config
6.21 Using Camera on Linux (MIPI Camera OV13850 & OV4689, and webcam logitect C920)
Hardware Setting:
The Camera module can be connected to a MIPI port:
FriendlyELEC provides some scripts use to test a camera's functions. You can run it in a commandline to test picture taking and video recording.
You may try update this script to the lastest version by using the following commands:
cd /tmp/ git clone https://github.com/friendlyarm/gst-camera-sh.git sudo cp gst-camera-sh/*.sh /usr/bin/
There are three scripts:
gst-camera.sh: preview, photo and video of a single camera
dual-camera.sh: preview two cameras
stop-gst-camera.sh: stop preview
6.21.1 Options in "gst-camera.sh"
Options Comment --index or -i Camera's index, it can be either 0 or 1. When two cameras are connected to a board you need to specify 1 to access the second camera. --action or -a Specify an action, it can be "preview" to preview, "photo" to take a picture or "video" to record video --output or -o Specify an output file to save a picture when taking a picture or video file when recording video --verbose or -v If it is specified as "yes" it will output the complete command when "gst-launch-1.0" is called -x Using the rkximagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems -g Using the glimagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems -k Using the kmssink plugin, the preview image will be output directly to the screen for the FriendlyCore system
The script gst-camera.sh will automatically recognize OV13850, OV4689 and C920 camera, and then pass the appropriate parameters to gst-launch-1.0.
6.21.2 Usage of gst-camera.sh
- Preview
gst-camera.sh --action preview
- Picture Taking
You can run the following command to take a picture and save it as a "1.jpg" file,
gst-camera.sh -a photo -o 1.jpg
- Preview and Record
You can run the following command to record video and save your video to a "1.ts" file. Hardware encoding is activated when it is recording video.
gst-camera.sh --action video -output 1.ts
- Show Complete Command
If you add the "--verbose yes" option it will show a complete gsteamer command.
gst-camera.sh --action video --output 1.ts --verbose yes
Here is the complete gsteamer command you will see:
gst-launch-1.0 rkisp num-buffers=512 device=/dev/video0 io-mode=1 ! \ video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \ mpph264enc ! queue ! h264parse ! mpegtsmux ! \ filesink location=/tmp/camera-record.ts
- Preview dual camera
Connect two mipi cameras, or one mipi camera and one usb camera (tested only: Logitech C920 pro), call the following command:
dual-camera.sh
Note: It is recommended to test this on FriendlyDesktop.
6.21.3 gst-launch-1.0 parameter description
Preview camera on FriendlyDesktop:
gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink
Important parameters
parameter description device preview device(selfpath): /dev/video1 and /dev/video5, picture device(mainpath): /dev/video0 and /dev/video4, webcam device: /dev/video8 io-mode 1: memory map, 4:dmabuf rkximagesink/glimagesink/kmssink rkximagesink for FriendlyDesktop, kmssink for FriendlyCore, glimagesink for webcam on FriendlyDesktop
6.21.4 Access the camera in OpenCV
MIPI camera:
cv.VideoCapture('rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
USB camera:
cv.VideoCapture('rkisp device=/dev/video8 io-mode=4 ! videoconvert ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
Please refer to the sample code here for details:https://github.com/friendlyarm/install-opencv-on-friendlycore/tree/rk3399/examples
6.21.5 Camera application tutorial: Push video stream
Please refre this guide: How to setup RTMP server on NanoPC-T4
6.21.6 Reference resource
http://blog.iotwrt.com/media/2017/10/01/camera/ http://www.360doc.com/content/16/1019/17/496343_599664458.shtml
7 Work with FriendlyCore
7.1 Introduction
FriendlyCore is a Ubuntu core based OS which doesn't have X Desktop. Its current version is 18.04
FriendlyCore targets enterprise users and is customized for industrial applications. FriendlyCore and Ubuntu base target different users. FriendlyCore has both a commandline utility and a two GUI utilities:
1)Qt 5.10.0 cuustomized for ROCKCHIP3399. It supports GPU and VPU acceleration and has modules like: QtQuick/QtWebEngine/QtMultimedia/WebGL and three display plug-ins:KMS, EGLFS and XCB;
2) Xorg system. It can run X11 applications and supports hardware acceleration;
FriendlyCore for RK3399 has the following features:
- supports FriendlyElec's 7"LCD with capacitive touch - HD702. If a board is connected to both an LCD and an HDMI monitor the LCD and the HDMI monitor can be set to display either differently or the same;
- supports Gstreamer 1.0 multi-media framework;
- supports hard encoding video playing with either commandline utility or Qt player;
- supports Qt5 WebGL;
- supports Qt5 VNC and runs a Qt application as a VNC Server allowing remote control;
- supports bluetooth. It has preinstalled bluez packages;
7.2 System Login
- If your board is connected to an HDMI monitor you need to use a USB mouse and keyboard.
- If you want to do kernel development you need to use a serial communication board, ie a PSU-ONECOM board, which will
You can use a USB to Serial on NanoPi-NEO4:
- FriendlyCore User Accounts:
Non-root User:
User Name: pi Password: pi
Root:
User Name: root Password: fa
The system is automatically logged in as "pi". You can do "sudo npi-config" to disable auto login.
- Update packages
$ sudo apt-get update
7.3 Configure System with npi-config
The npi-config is a commandline utility which can be used to initialize system configurations such as user password, system language, time zone, Hostname, SSH switch , Auto login and etc. Type the following command to run this utility.
$ sudo npi-config
Here is how npi-config's GUI looks like:
7.4 Develop Qt Application
The Qt 5.10.0 FriendlyELEC ported for RK3399 supports the following plug-ins:KMS, EGLFS and XCB. All these three plug-ins support OpenGL ES and GPU hardware acceleration but in different ways:
- KMS - it calls Linux kernel's DRM interface to display
- EGLFS - it calls OpenGL ES interface to display
- XCB - it runs on X11 server and is integrated in X11 windows system
Three plug-ins support different Qt features and here is a table:
Plug-in OpenGL ES QtWebEngine QtMultimedia Video Playing with Hardware Decoding Different Display KMS Yes No Yes No Yes EGLFS Yes No Yes No No XCB Yes Yes Yes Yes Yes
We recommend to use KMS or XCB.
FriendlyCore has four scripts for setting Qt environmental variables for users and here is a table:
Script Comment /usr/bin/setqt5env-kms set kms' environmental variables /usr/bin/setqt5env-eglfs set eglfs' environmental variables /usr/bin/setqt5env-xcb set xcb's environmental variables /usr/bin/setqt5env-nogui set environmental variables for a system without a Qt GUI
For instance, if you want to use KMS to display you can run the following commands:
. setqt5env-kms
./apps
(Note:there is a space between '.' and 's')
7.4.1 Setup Qt Development Envronment
FriendlyELEC developed two methods for RK3399 to cross-compile a Qt program:
- 1:Use Docker. For more details you can refer to github :http://github.com/friendlyarm/friendlyelec-ubuntu18-docker
- 2:Setup a local cross-compiler. You need to run a Ubuntu 18.04 64-bit OS and you can refer to :How to Build and Install Qt Application for FriendlyELEC Boards/zh
7.4.2 Qt Demo
FriendlyCore has several Qt demo programs:
- Qt QML: CinematicExperience
CinematicExperience is a utility for selecting a video file and it is developed with Qt QML.
This demo uses Qt QML's various features and runs very smoothly on RK3399. This performance is achieved by hardware and software optimization.
You can start it in a commandline utility by running the following commands:
cd /opt/Qt5_CinematicExperience ./run.sh
- QQt WebEngine: web browser
Qt WebEngine uses Chromium and supports HTML5.
You can start it by running the following commands:
cd /opt/qt5-brower ./run.sh
Note:Qt WebEngine depends on the Xcb plug-in.
- Qt Different Display
This demo shows that when a board is connected to an HDMI monitor and an eDP LCD these two devices display differently. You can start it by running the following commands:
cd /opt/qt5-multi-screen-demo ./run.sh
- Qt Multimedia: qt5-player with hard decoding
The qt5-player works with Rockchip's gstreamer plug-in and supports 4K video playing. Since Rockchip's plug-in only supports output images to an X11 window the qt5-player needs to use XCB for display.
You can start the demo by running the following commands:
cd /opt/qt5-player ./run.sh
Here is what it looks like. You can set it to display in full-screen and adjust the voice's volume:
- Qt WebGL demo: nmapper
Qt WebGL allows you to remotely access a Qt program running on your board.
Before you run the demo you need to connect your board to the internet and run the following commands:
cd /opt/qt5-nmapper ./run-with-webgl.sh
You can open a browser on another device, type the IP address of your board on the browser's address bar, enter and you will be able to see a Qt GUI. Here is what it looks like:
- Qt VNC demo: Smart home applicance GUI
Qt VNC allows you to run a program as a VNC Server on your board and you can access the program from a VNC client on another device. This program can be developed with either QtWidgets or QML.
You can start it by running the following commands:
cd /opt/qt5-smarthome ./run-with-vnc.sh
Start a VNC viewer on a smart phone or mobile device and type your board's IP address and port number 5900. For instance if your board's IP address is 192.168.1.100 you can type "192.168.1.100:5900", enter and you will see the following GUI:
7.4.3 Play with Dual Cameras under Qt
This sample shows how to connect dual cameras to the board and play with them. Before run the sample make sure you connect dual cameras and an LCD to your board. In general popular UVC cameras should work however we suggest users use the following modules which we have tested:
Index Model 1 Logitech C270 2 Logitech C270i 3 Logitech C922 Pro
Run the following commands:
cd /opt/dual-camera ./run.sh
Here is what you expect to observe:
7.5 Setup Program to AutoRun
You can setup a program to autorun on system boot with npi-config:
sudo npi-config
Go to Boot Options -> Autologin -> Qt/Embedded, select Enable and reboot.
7.6 Extend TF Card's Section
When FriendlyCore is loaded the TF card's section will be automatically extended.You can check the section's size by running the following command:
$ df -h
7.7 Transfer files using Bluetooth
Take the example of transferring files to the mobile phone. First, set your mobile phone Bluetooth to detectable status, then execute the following command to start Bluetooth search.:
hcitool scan
Search results look like:
Scanning ... 2C:8A:72:1D:46:02 HTC6525LVW
This means that a mobile phone named HTC6525LVW is searched. We write down the MAC address in front of the phone name, and then use the sdptool command to view the Bluetooth service supported by the phone:
sdptool browser 2C:8A:72:1D:46:02
Note: Please replace the MAC address in the above command with the actual Bluetooth MAC address of the mobile phone.
This command will detail the protocols supported by Bluetooth for mobile phones. What we need to care about is a file transfer service called OBEX Object Push. Take the HTC6525LVW mobile phone as an example. The results are as follows:
Service Name: OBEX Object Push Service RecHandle: 0x1000b Service Class ID List: "OBEX Object Push" (0x1105) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 12 "OBEX" (0x0008) Profile Descriptor List: "OBEX Object Push" (0x1105) Version: 0x0100
As can be seen from the above information, the channel used by the OBEX Object Push service of this mobile phone is 12, we need to pass it to the obexftp command, and finally the command to initiate the file transfer request is as follows:
obexftp --nopath --noconn --uuid none --bluetooth -b 2C:8A:72:1D:46:02 -B 12 -put example.jpg
Note: Please replace the MAC address, channel and file name in the above command with the actual one.
After executing the above commands, please pay attention to the screen of the mobile phone. The mobile phone will pop up a prompt for pairing and receiving files. After confirming, the file transfer will start.
Bluetooth FAQ:
1) Bluetooth device not found on the development board, try to open Bluetooth with the following command:
rfkill unblock 0
2) Prompt can not find the relevant command, you can try to install related software with the following command:
apt-get install bluetooth bluez obexftp openobex-apps python-gobject ussp-push
7.8 WiFi
For either an SD WiFi or a USB WiFi you can connect it to your board in the same way. The APXX series WiFi chips are SD WiFi chips. By default FriendlyElec's system supports most popular USB WiFi modules. Here is a list of the USB WiFi modules we tested:
Index Model 1 RTL8188CUS/8188EU 802.11n WLAN Adapter 2 RT2070 Wireless Adapter 3 RT2870/RT3070 Wireless Adapter 4 RTL8192CU Wireless Adapter 5 mi WiFi mt7601 6 5G USB WiFi RTL8821CU 7 5G USB WiFi RTL8812AU
You can use the NetworkManager utility to manage network. You can run "nmcli" in the commandline utility to start it. Here are the commands to start a WiFi connection:
- Change to root
$ su root
- Check device list
$ nmcli dev
Note: if the status of a device is "unmanaged" it means that device cannot be accessed by NetworkManager. To make it accessed you need to clear the settings under "/etc/network/interfaces" and reboot your system.
- Start WiFi
$ nmcli r wifi on
- Scan Surrounding WiFi Sources
$ nmcli dev wifi
- Connect to a WiFi Source
$ nmcli dev wifi connect "SSID" password "PASSWORD" ifname wlan0
The "SSID" and "PASSWORD" need to be replaced with your actual SSID and password.If you have multiple WiFi devices you need to specify the one you want to connect to a WiFi source with iface
If a connection succeeds it will be automatically setup on next system reboot.
For more details about NetworkManager refer to this link: Use NetworkManager to configure network settings
If your USB WiFi module doesn't work most likely your system doesn't have its driver. For a Debian system you can get a driver from Debian-WiFi and install it on your system. For a Ubuntu system you can install a driver by running the following commands:
$ apt-get install linux-firmware
In general all WiFi drivers are located at the "/lib/firmware" directory.
7.9 Ethernet Connection
If a board is connected to a network via Ethernet before it is powered on it will automatically obtain an IP with DHCP activated after it is powered up. If you want to set up a static IP refer to: Use NetworkManager to configure network settings。
7.10 WiringPi and Python Wrapper
7.11 Custom welcome message
The welcome message is printed from the script in this directory:
/etc/update-motd.d/
For example, to change the FriendlyELEC LOGO, you can change the file /etc/update-motd.d/10-header. For example, to change the LOGO to HELLO, you can change the following line:
TERM=linux toilet -f standard -F metal $BOARD_VENDOR
To:
TERM=linux toilet -f standard -F metal HELLO
7.12 Modify timezone
For exampe, change to Shanghai timezone:
sudo rm /etc/localtime sudo ln -ls /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
7.13 Select the system default audio device
You can set the system default audio device by following the steps below.
Use the following command to view all the sound card devices in the system (Note: different development boards will have different results):
pi@NanoPi:~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: realtekrt5651co [realtek,rt5651-codec], device 0: ff880000.i2s-rt5651-aif1 rt5651-aif1-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: rockchiphdmi [rockchip,hdmi], device 0: ff8a0000.i2s-i2s-hifi i2s-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: ROCKCHIPSPDIF [ROCKCHIP,SPDIF], device 0: ff870000.spdif-dit-hifi dit-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
As you can see, the following sound card devices are available on the hardware:
Sound card device Sound card number Description realtekrt5651co 0 Realtek sound card's default output interface (through 3.5mm jack interface) rockchiphdmi 1 HDMI ROCKCHIPSPDIF 2 SPDIF (Note: temporarily unavailable, because the hardware is not exported)...
To configure the audio output to the 3.5mm jack, modify the configuration file /etc/asound.conf and modify it to the following:
defaults.pcm.card 0 defaults.pcm.device 0
To configure to output audio to HDMI, change the defaults.pcm.card above to 1.
Note that some boards do not have a Realtek sound card (no 3.5mm jack interface), so the card number of the HDMI device will be 0, so the configuration should be based on the result of the aplay -l command.
7.14 Run the X11 application
FriendlyCore system built-in lightweight Xorg,although there is no window manager, you can still run a single X-Windows application,For example, the program to run is ~/YourX11App,use the following command:
. /usr/bin/setqt5env-xcb startx ~/YourX11App -geometry 1280x800
Note that there is a space between "." and /usr/bin/setqt5env-xcb. In addition, the resolution after -geometry should be changed to the actual resolution of your screen.
7.15 Using Camera on Linux (MIPI Camera OV13850 & OV4689, and webcam logitect C920)
Hardware Setting:
The Camera module can be connected to a MIPI port:
FriendlyELEC provides some scripts use to test a camera's functions. You can run it in a commandline to test picture taking and video recording.
You may try update this script to the lastest version by using the following commands:
cd /tmp/ git clone https://github.com/friendlyarm/gst-camera-sh.git sudo cp gst-camera-sh/*.sh /usr/bin/
There are three scripts:
gst-camera.sh: preview, photo and video of a single camera
dual-camera.sh: preview two cameras
stop-gst-camera.sh: stop preview
7.15.1 Options in "gst-camera.sh"
Options Comment --index or -i Camera's index, it can be either 0 or 1. When two cameras are connected to a board you need to specify 1 to access the second camera. --action or -a Specify an action, it can be "preview" to preview, "photo" to take a picture or "video" to record video --output or -o Specify an output file to save a picture when taking a picture or video file when recording video --verbose or -v If it is specified as "yes" it will output the complete command when "gst-launch-1.0" is called -x Using the rkximagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems -g Using the glimagesink plugin, the preview image will be output to the X11 window for the FriendlyDesktop and Lubuntu systems -k Using the kmssink plugin, the preview image will be output directly to the screen for the FriendlyCore system
The script gst-camera.sh will automatically recognize OV13850, OV4689 and C920 camera, and then pass the appropriate parameters to gst-launch-1.0.
7.15.2 Usage of gst-camera.sh
- Preview
gst-camera.sh --action preview
- Picture Taking
You can run the following command to take a picture and save it as a "1.jpg" file,
gst-camera.sh -a photo -o 1.jpg
- Preview and Record
You can run the following command to record video and save your video to a "1.ts" file. Hardware encoding is activated when it is recording video.
gst-camera.sh --action video -output 1.ts
- Show Complete Command
If you add the "--verbose yes" option it will show a complete gsteamer command.
gst-camera.sh --action video --output 1.ts --verbose yes
Here is the complete gsteamer command you will see:
gst-launch-1.0 rkisp num-buffers=512 device=/dev/video0 io-mode=1 ! \ video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \ mpph264enc ! queue ! h264parse ! mpegtsmux ! \ filesink location=/tmp/camera-record.ts
- Preview dual camera
Connect two mipi cameras, or one mipi camera and one usb camera (tested only: Logitech C920 pro), call the following command:
dual-camera.sh
Note: It is recommended to test this on FriendlyDesktop.
7.15.3 gst-launch-1.0 parameter description
Preview camera on FriendlyDesktop:
gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! rkximagesink
Important parameters
parameter description device preview device(selfpath): /dev/video1 and /dev/video5, picture device(mainpath): /dev/video0 and /dev/video4, webcam device: /dev/video8 io-mode 1: memory map, 4:dmabuf rkximagesink/glimagesink/kmssink rkximagesink for FriendlyDesktop, kmssink for FriendlyCore, glimagesink for webcam on FriendlyDesktop
7.15.4 Access the camera in OpenCV
MIPI camera:
cv.VideoCapture('rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
USB camera:
cv.VideoCapture('rkisp device=/dev/video8 io-mode=4 ! videoconvert ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1 ! videoconvert ! appsink', cv.CAP_GSTREAMER)
Please refer to the sample code here for details:https://github.com/friendlyarm/install-opencv-on-friendlycore/tree/rk3399/examples
7.15.5 Camera application tutorial: Push video stream
Please refre this guide: How to setup RTMP server on NanoPC-T4
7.15.6 Reference resource
http://blog.iotwrt.com/media/2017/10/01/camera/ http://www.360doc.com/content/16/1019/17/496343_599664458.shtml
8 Work with Lubuntu
8.1 Introduction to Lubuntu
LUbuntu is a light-weighted Ubuntu desktop system. It is based on LXDE and has the following features:
Light-weighted - it consumes relatively less CPU resources than a common desktop system. When a system's RAM is sufficient it can achieve much better performance.
Less power consumption - it consumes relatively less power or resources than a common desktop system to achieve the same performance.
Compact & neat - its desktop is based on GTK+ 2 and supports multiple languages.
Easy to use - its GUI looks similar to MS Windows'.
Customizable - Users can customize LXDE's GUI.
Compatible - it is compatible with freedesktop.org.
The Lubuntu Desktop has been optimized for adopting Mali GPU. It has driver support for X.org and supports Hardware Cursor, OpenGL acceleration and etc.
8.2 Lubuntu Default User Account
Non-root User:
User Name: pi Password: pi
Root:
User Name: root Password: fa
8.3 OpenGL ES
Open a command line utility and run the following command:
glmark2-es2
8.4 Video Playing with Hardware Decoding
8.4.1 Video Playing with Qt Player
Lubuntu is preinstalled with Qt5-Player which has Rockchip's gstreamer plug-in and supports playing 4K video stream. Here are the steps to start it:
On Lubuntu's main window open "Other" and click on Qt5-Player
Here is how this player looks like. It can display in full screen. You can adjust its volume:
8.4.2 Video Playing with Commandline Utility
Open a commandline utility and type the following command:
gst-player.sh
Your selected video file will be played in Overlay and its voice will be output to the earphone. You can use "which gst-player.sh" to locate this script and customize it.
8.5 eDP LCD Rotation
If your board is connected to an eDP LCD and you want to rotate its display by 90/180/270 degrees you can do it with "xrotate.sh". You can run the following command as root to rotate its display by 90 degrees clockwise. It will start the lightdm service to make it effective:
sudo xrotate.sh -m CW -r
You can get more details by running "xrotate -h".
However this command cannot rotate HDMI display. If you want to rotate HDMI display you may need to make changes in "/etc/X11/xorg.conf"
8.6 Connect USB Camera
Connect a USB camera (e.g. Logitech C270) to NanoPi-NEO4, run the following commands:
++export DISPLAY=:0.0 +guvcview -d /dev/video10 +
8.7 5G WiFi
Click on the network icon on top right of the Lubuntu GUI, select a WiFi hotspot and proceed with prompts.
8.8 Develop Qt Application
Lubuntu has Qt 5.10.0 which can be used to develop an X11 application. For details about SDK download and compilation refer to :How to Build and Install Qt Application for FriendlyELEC Boards
When running the Qt app, you need to specify the platform parameter to xcb as follows:
./HelloQt --platform xcb
8.9 Chromium web browser
Chromium web browser has enabled hardware acceleration by default, supports WebGL, and can view hardware acceleration details by entering the URL chrome://gpu, as shown below:
8.10 Cancel automatic login
Edit the file /usr/share/lightdm/lightdm.conf.d/20-lubuntu.conf and delete the line "autologin-user=pi"
The screen saver configuration file is /etc/xdg/autostart/xset_command.desktop. The default factory settings are that the screen saver and DPMS are both closed. You can change the configuration by modifying this file.
8.12 Select the system default audio device
You can set the system default audio device by following the steps below.
Use the following command to view all the sound card devices in the system (Note: different development boards will have different results):
pi@NanoPi:~$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: realtekrt5651co [realtek,rt5651-codec], device 0: ff880000.i2s-rt5651-aif1 rt5651-aif1-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: rockchiphdmi [rockchip,hdmi], device 0: ff8a0000.i2s-i2s-hifi i2s-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: ROCKCHIPSPDIF [ROCKCHIP,SPDIF], device 0: ff870000.spdif-dit-hifi dit-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0
As you can see, the following sound card devices are available on the hardware:
Sound card device Sound card number Description realtekrt5651co 0 Realtek sound card's default output interface (through 3.5mm jack interface) rockchiphdmi 1 HDMI ROCKCHIPSPDIF 2 SPDIF (Note: temporarily unavailable, because the hardware is not exported)...
To configure the audio output to the 3.5mm jack, modify the configuration file /etc/asound.conf and modify it to the following:
defaults.pcm.card 0 defaults.pcm.device 0
To configure to output audio to HDMI, change the defaults.pcm.card above to 1.
Note that some boards do not have a Realtek sound card (no 3.5mm jack interface), so the card number of the HDMI device will be 0, so the configuration should be based on the result of the aplay -l command.
9 Work with Android 8.1
FriendlyElec provides a full Android8.1 BSP for NanoPi-NEO4. The source code is hosted at gitlab.com and is open source. The BSP supports GPU and VPU hardware acceleration.
9.1 Connect MIPI Camera to NanoPi-NEO4
FriendlyElec developed a MIPI camera CAM1320 for board and it works under Android. You can use this camera to take pictures and record video. The operation is straightforward. You just need to connect the camera at your board's MIPI interface, boot your board to Android and start Android's camera app.
The board has one MIPI interfaces:
MIPI-CSI1 <--> Android rear camera
How to connect:
9.2 Use dual MIPI camera preview and video
Download the sample source code below from github and compile and run it:
git clone https://github.com/friendlyarm/Dual-Camera.git -b working-branch
After the application is installed, you need to Set Android permissions to make the demo run normally. The method is enter system ui: Settings -> Apps & notifications -> Dual Camera -> Permissions, Select the following permissions:
Camera Microphone Storage
The gui looks like this:
Click the "CAPTURE VIDEO" button on the gui to record the video (two cameras at the same time), and the video file will be saved to the following location.:/storage/emulated/0/Download/dualcamera_h264.mp4.
Known issue:
Recorded video file will play faster than normal, may need to adjust some parameters of mediacodec.
9.3 Change system language
The default system language of Android system is English. For example, if we want to set it to Chinese, the steps are as follows:
1) Go to Android settings:Settings -> System -> Languages & Input -> Languages;
2)Click "Add a language", Select "简体中文", and then select "中国";
3) At this time, there will be two languages, Chinese and English. Drag the Chinese item to the top of the list. Note that if you are using a mouse, drag it by placing the mouse pointer on the right side of the list item. On the icon and then press the middle mouse button to drag;
9.4 Android8.1 hardware access
You can use the FriendlyThings SDK to access and control hardware resources on the motherboard in the Android App, such as Uart, SPI, I2C, GPIO and other interfaces. For details, please refer to the following two documents.:
9.5 Android Neural Networks SDK Sample
Android8.1 BSP comes pre-installed with Rockchip's Android NN SDK for Android 8.1, supporting GPU acceleration.。
Sample program for Android NN pre-installed in the Android8 firmware we provide:TfLiteCameraDemo,This is a MobileNet classifier demo using Rockchip AndroidNN GPU acceleration,The camera module is required to be connected to the motherboard during operation. The USB camera and CSI camera are supported,The sample program is launched by clicking the "TfLiteCameraDemo" icon on the home page. The running effect is as follows:
For a detailed description of the Android NN SDK, you can refer to this document:[RK3399_Android8.1_AndroidNN_SDK_V1.0_20180605发布说明.pdf]
TfLiteCameraDemo sample source code download link:[TfLiteCameraDemo source code]
9.6 Using the adb
1. The first time you start the system, if you need to change the system files, you need to turn off security verification (note: apk installation does not need to be closed), and restart after turning off security verification
adb root adb disable-verity adb reboot
2. After restarting, get root and remount /system to enable write permissions
adb root adb remount
3. Upload a file
adb push example.txt /system/
9.7 HDMI resolution and overscan setting
If an HDMI display device is connected, go to Android Settings -> Display -> Advanced -> HDMI & Rotation to set it up.
HDMI Resolution The default is Auto, you can manually set the display resolution, up to 4K resolution Screen Zoom click the four arrow buttons in the middle to adjust the zoom Display Rotation for horizontal and vertical screen switching
9.8 Screen rotation
go to Android Settings -> Display -> Advanced -> HDMI & Rotation to set it up.
Use the following command in shell to test screen rotation (Settings not saved):
wm rotation 90
Enter Settings -> Accessibility, Turn on immersive mode, and then open an Android application, For example: Lightning, it will be in full screen mode.
9.10 Switch audio output channel
You can configure the audio output to the HDMI or headphone jack, Setting interface entry method: Android Settings -> Accessibility -> Force audio output. If the Force audio output menu item is gray, that is, it is in an unselectable state, the hardware you are using will automatically detect the headphone plug-in status and automatically switch the audio channel without setting.
9.11 Adjust the volume of the recording
1) First use the amix command to adjust the volume of the recording through the serial port or the adb shell with root privileges, for example:
Amix "IN2 Boost" Amix "ADC Capture Volume"
The above command is used to view the current settings.
2) After debugging, modify the value of the corresponding configuration item in the rt5651_main_mic_capture_controls array in the hardware/rockchip/audio/tinyalsa_hal/codec_config/rt5651_config.h file, compile the Android source code and test it.
9.12 Custom logo and boot animation
9.12.1 On/Off
Change:
BOOT_SHUTDOWN_ANIMATION_RINGING := false
to:
BOOT_SHUTDOWN_ANIMATION_RINGING := true
in device/rockchip/common/BoardConfig.mk file.
9.12.2 Boot animation
Create or replace the following files in the Android source code directory:
kernel/logo.bmp
kernel/logo_kernel.bmp
device/rockchip/common/bootshutdown/bootanimation.zip
9.12.3 Shutdown animation
Create or replace the following files in the Android source code directory:
device/rockchip/common/bootshutdown/shutdownanimation.zip
9.12.4 How to make animation
Please refre to:http://blog.sina.com.cn/s/blog_4960586c0100vu5v.html
9.13 Remove Google Framework
If you don't need to use the google service, you can delete the Google framework to save system resources by deleting the following directory in the Android source code and recompiling Android:
vendor/google
9.14 Work with USB Camera to Take Pictures and Record Video
FriendlyELEC's Android system supports picture taking and video recording with a USB camera, Android's camera app has these functions. When you use the app to take pictures or record video you need to be aware of the following two things:
1) Make sure your camera's resolution works. We suggest you try a camera with a lower CIF resolution first. If it works you may switch to a camera with a higher resolution:
;
2)A USB camera cannot work simultaneously with a MIPI camera. Plug and play is not supporter for camera modules. After you connect a camera to a board you need to reboot your board to enable the camera.
Here are the camera modules we tested: Logitech C270 and LogitechC922 PRO
In our test the resolution was 1080P when we used a Logitech C922 PRO to take pictures or record video.
10 Work with Android7.1
See here: Android7
10.1 Build Openwrt/Friendlywrt
10.1.1 Download Code
Two versions are available, please choose as required:
10.1.1.1 FriendlyWrt 21.02
mkdir friendlywrt21-rk3399 cd friendlywrt21-rk3399 git clone https://github.com/friendlyarm/repo --depth 1 tools tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v21.02 \ -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle tools/repo sync -c --no-clone-bundle
10.1.1.2 FriendlyWrt 23.05
mkdir friendlywrt23-rk3399 cd friendlywrt23-rk3399 git clone https://github.com/friendlyarm/repo --depth 1 tools tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \ -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle tools/repo sync -c --no-clone-bundle
10.1.2 First compilation step
./build.sh rk3399.mk # or rk3399-docker.mk
All the components (including u-boot, kernel, and friendlywrt) are compiled and the sd card image will be generated, then execute the following command to generate the image file for installing the system into the emmc:
./build.sh emmc-img
After making changes to the project, the sd card image needs to be repackaged by running the following command:
./build.sh sd-img
10.1.3 Secondary compilation steps
cd friendlywrt make menuconfig rm -rf ./tmp make -j${nproc} cd ../ ./build.sh sd-img ./build.sh emmc-img
10.1.4 Build u-boot only
./build.sh uboot
10.1.5 Build kernel only
./build.sh kernel
10.1.6 Build friendlywrt only
./build.sh friendlywrt
Or go to the friendlywrt directory and follow the standard openwrt commands. If you get an error with the above command, try using the following command to compile in a single thread:
cd friendlywrt make -j1 V=s
10.2 Build Buildroot
please refer to: Buildroot
10.3 Build Other Linux
10.3.1 Kernel and u-boot versions
Operating System | Kernel Version | U-boot version | Cross-compiler | Partition type | Packaging Tool | Kernel branch | Kernel configuration | U-boot branch | U-boot configuration |
---|---|---|---|---|---|---|---|---|---|
lubuntu | linux v4.4.y | u-boot v2014.10 | 6.4-aarch64 |
MBR | sd-fuse | nanopi4-linux-v4.4.y | nanopi4_linux_defconfig | nanopi4-v2014.10_oreo | rk3399_defconfig |
friendlycore-arm64 | |||||||||
friendlydesktop-arm64 | |||||||||
eflasher | |||||||||
buildroot | linux v4.19.y | u-boot v2017.09 |
11.3-aarch64 | GPT | sd-fuse | nanopi4-v4.19.y | nanopi4_linux_defconfig | nanopi4-v2017.09 | nanopi4_defconfig |
ubuntu-focal-desktop-arm64 | |||||||||
debian-bullseye-desktop-arm64 | |||||||||
debian-bullseye-minimal-arm64 | |||||||||
friendlycore-focal-arm64 | |||||||||
debian-bookworm-core-arm64 | |||||||||
ubuntu-noble-core-arm64 | |||||||||
openmediavault-arm64 | linux v6.1.y | u-boot v2017.09 |
11.3-aarch64 | GPT | sd-fuse |
nanopi-r2-v6.1.y |
nanopi4_linux_defconfig | ||
friendlywrt21 | GPT | nanopi4_linux_defconfig +friendlywrt.config | |||||||
friendlywrt21-docker | |||||||||
friendlywrt23 | |||||||||
friendlywrt23-docker |
- Kernel git repo:https://github.com/friendlyarm/kernel-rockchip
- U-boot git repo:https://github.com/friendlyarm/uboot-rockchip
- The cross-compile toolchain is located in the path: /opt/FriendlyARM/toolchain/
- The SD-Fuse is a helper script to make bootable SD card image.
- Click on MBR and GPT in the table to view the partition layout (configuration file) for each system.
10.3.2 Build kernel linux-v4.4.y
This section applies to the following operating systems:
lubuntu | eflasher | friendlydesktop-arm64 | friendlycore-arm64 |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip cd kernel-rockchip export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH touch .scmversion # Load configuration make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig # Optionally, if you want to change the default kernel config # make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig # Start building kernel make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc) # Start building kernel modules mkdir -p out-modules make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc) make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease) rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/ [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
After the compilation, the following files will be generated:
kernel.img | resource.img | The kernel modules are located in the out-modules directory |
Run your build:
Please refre to #Running the build
10.3.3 Build u-boot v2014.10
This section applies to the following operating systems:
lubuntu | eflasher | friendlydesktop-arm64 | friendlycore-arm64 |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2014.10_oreo cd uboot-rockchip export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH make CROSS_COMPILE=aarch64-linux- rk3399_defconfig make CROSS_COMPILE=aarch64-linux-
After the compilation, the following files will be generated:
uboot.img | trust.img | rk3399_loader_v1.22.119.bin (aka MiniLoaderAll.bin) |
Installing the u-boot:
Please refre to #Running the build
10.3.4 Build kernel linux-v4.19.y
This section applies to the following operating systems:
ubuntu-focal-desktop-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 | friendlycore-focal-arm64 | ubuntu-noble-core-arm64 | debian-bookworm-core-arm64 | buildroot |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-v4.19.y kernel-rockchip cd kernel-rockchip export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH touch .scmversion # Configuring the Kernel # Load default configuration make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig # Optionally, load configuration for FriendlyWrt # make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig friendlywrt.config # Optionally, if you want to change the default kernel config # make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig # Start building kernel make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc) # Start building kernel modules mkdir -p out-modules make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc) make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease) rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/ [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
After the compilation, the following files will be generated:
kernel.img | resource.img | The kernel modules are located in the out-modules directory |
Run your build:
Please refre to #Running the build
10.3.5 Build kernel linux-v6.1.y
This section applies to the following operating systems:
friendlywrt21 | friendlywrt21-docker | friendlywrt23 | friendlywrt23-docker | openmediavault-arm64 |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi-r2-v6.1.y kernel-rockchip cd kernel-rockchip export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH touch .scmversion # Configuring the Kernel # Load default configuration make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig # Optionally, load configuration for FriendlyWrt # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig friendlywrt.config # Optionally, if you want to change the default kernel config # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig # Start building kernel make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j$(nproc) # Start building kernel modules mkdir -p out-modules && rm -rf out-modules/* make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc) make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules_install KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease) [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
Pack the kernel.img and resource.img:
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/tools/mkkrnlimg && chmod 755 mkkrnlimg wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/tools/resource_tool && chmod 755 resource_tool wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/prebuilt/boot/logo.bmp wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/prebuilt/boot/logo_kernel.bmp ./mkkrnlimg arch/arm64/boot/Image kernel.img mkdir kernel-dtbs cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev09.dtb cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev0a.dtb cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4se.dtb kernel-dtbs/rk3399-nanopi4-rev0b.dtb cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb kernel-dtbs/rk3399-nanopi4-rev00.dtb ./resource_tool --dtbname kernel-dtbs/*.dtb logo.bmp logo_kernel.bmp
After the compilation, the following files will be generated:
kernel.img | resource.img | The kernel modules are located in the out-modules directory |
Run your build:
Please refre to #Running the build
10.3.6 Build u-boot v2017.09
This section applies to the following operating systems:
ubuntu-focal-desktop-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 | friendlycore-focal-arm64 | ubuntu-noble-core-arm64 | debian-bookworm-core-arm64 | buildroot |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b friendlyelec git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2017.09 export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH cd uboot-rockchip/ ./make.sh nanopi4
After the compilation, the following files will be generated:
uboot.img | trust.img | rk3399_loader_v1.24.126.bin (aka MiniLoaderAll.bin) |
Run your build:
Please refre to #Running the build
10.3.7 Running the build
10.3.7.1 Install to target board
10.3.7.1.1 MBR partition
This section applies to the following operating systems:
lubuntu | eflasher | friendlydesktop-arm64 | friendlycore-arm64 |
The MBR partitioning is only used by the Linux v4.4 kernel. You can check the partition layout by clicking on this link: partmap. To write an image file, you can use the dd command. For example, in the parameter.template file, "0x00014000@0x00014000(kernel)" specifies that the kernel partition starts at 0x00014000, which is equivalent to 81920 in decimal. Therefore, the dd command should be as follows:
dd if=kernel.img of=/dev/mmcblk0 seek=81920
10.3.7.1.2 GPT partition
This section applies to the following operating systems:
ubuntu-focal-desktop-arm64 | debian-bookworm-core-arm64 | debian-bullseye-desktop-arm64 | debian-bullseye-minimal-arm64 |
friendlycore-focal-arm64 | ubuntu-noble-core-arm64 | friendlywrt21-kernel4 | buildroot |
friendlywrt21 | friendlywrt21-docker | friendlywrt23 | friendlywrt23-docker |
The OS uses GPT partitions by default which is using the Linux v4.19 and Linux v5.15 kernel, you can use the dd command, but be careful to choose the right output device:
- The SD/TF Card device node: /dev/mmcblk0
- The eMMC device node: /dev/mmcblk2
The following is an example of how to update the kernel to eMMC:
Use the 'parted' command to view the partition layout:
parted /dev/mmcblk2 print
Sample outputs:
Model: MMC BJTD4R (sd/mmc) Disk /dev/mmcblk2: 31.3GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 8389kB 12.6MB 4194kB uboot 2 12.6MB 16.8MB 4194kB trust 3 16.8MB 21.0MB 4194kB misc 4 21.0MB 25.2MB 4194kB dtbo 5 25.2MB 41.9MB 16.8MB resource 6 41.9MB 83.9MB 41.9MB kernel 7 83.9MB 134MB 50.3MB boot 8 134MB 2500MB 2366MB ext4 rootfs 9 2500MB 31.3GB 28.8GB ext4 userdata
as shown above, the resource partition is located at 5 and the kernel partition is located at 6. Use the dd command to write the resource.img and kernel.img files to these partitions, the commands are as follows:
dd if=resource.img of=/dev/mmcblk2p5 bs=1M dd if=kernel.img of=/dev/mmcblk2p6 bs=1M
If you want to update u-boot:
dd if=uboot.img of=/dev/mmcblk2p1 bs=1M
To update new driver modules, copy the newly compiled driver modules to the appropriate directory under /lib/modules.
10.3.7.2 Packaging and creating an SD image
To create a new OS image file, you need to use the "sd-fuse" packaging tool.
"sd-fuse" is a collection of scripts that can be used to create bootable SD card images for FriendlyElec boards. Its main features include:
- Creation of root filesystem images from a directory
- Building of bootable SD card images
- Simple compilation of kernel, U-Boot, and third-party drivers
Please click on the following link to find out more:
Kernel version | Packaging Tool |
---|---|
linux v4.4.y | sd-fuse |
linux v4.19.y | sd-fuse_rk3399/kernel-4.19 |
linux v6.1.y | sd-fuse_rk3399/kernel-6.1.y |
10.3.7.3 USB flashing
Note: kernel v4.4.y is not supported
10.3.7.3.1 Linux
Reboot the board and enter loader mode with the following command:
sudo reboot loader
To flash U-Boot and kernel using the "upgrade_tool_v2.17_for_linux" tool, please use the following command:
sudo upgrade_tool di -k kernel.img sudo upgrade_tool di -re resource.img sudo upgrade_tool di -u uboot.img sudo upgrade_tool RD
Note: "upgrade_tool" is a command-line tool provided by Rockchip for Linux operating systems (Linux_Upgrade_Tool).
10.4 Build the code using scripts
10.4.1 Download scripts and image files
git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b kernel-4.19 cd sd-fuse_rk3399 wget http://112.124.9.243/dvdfiles/RK3399/images-for-eflasher/friendlycore-focal-arm64-images.tgz tar xvzf friendlycore-focal-arm64-images.tgz
10.4.2 Compile the kernel
Download the kernel source code and compile it. the relevant image files in the friendlycore-focal-arm64 directory will be automatically updated, including the kernel modules in the file system:
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-v4.19.y kernel-rk3399 KERNEL_SRC=$PWD/kernel-rk3399 ./build-kernel.sh friendlycore-focal-arm64
10.4.3 Compile the kernel headers
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-v4.19.y kernel-rk3399 MK_HEADERS_DEB=1 BUILD_THIRD_PARTY_DRIVER=0 KERNEL_SRC=$PWD/kernel-rk3399 ./build-kernel.sh friendlycore-focal-arm64
10.4.4 Compile the uboot
Download the uboot source code and compile it. the relevant image files in the friendlycore-focal-arm64 directory will be automatically updated:
git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi4-v2017.09 UBOOT_SRC=$PWD/uboot-rockchip ./build-uboot.sh friendlycore-focal-arm64
10.4.5 Generate new image
Repackage the image file in the friendlycore-focal-arm64 directory into sd card image:
./mk-sd-image.sh friendlycore-focal-arm64
After the command is completed, the image is in the out directory, you can use the dd command to make the SD boot card, for example:
dd if=out/rk3399-sd-friendlycore-focal-4.19-arm64-YYYYMMDD.img of=/dev/sdX bs=1M
10.5 Building AOSP from source
10.5.1 Hardware and Software Requirements
- Your computer should have at least 16GB of RAM and 300GB of disk space. We recommend using a machine with 32GB of RAM and a large-capacity, high-speed SSD, and we do not recommend using virtual machines.
- If you encounter compilation errors, they may be caused by problems with the compilation environment. We recommend using the following Docker container for compilation: docker-cross-compiler-novnc.
10.5.2 Compile Android10
10.5.2.1 Download Android10 Source Code
There are two ways to download the source code:
- repo archive file on netdisk
Netdisk URL: Click here
File location on netdisk:"07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz" (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
tar xf "/path/to/netdisk/07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz" cd rk3399-android-10 ./sync.sh
- git clone from gitlab
NanoPi-NEO4 source code is maintained in gitlab, You can download it by running the following command:
git clone --recursive https://gitlab.com/friendlyelec/rk3399-android-10.git -b main
Note: If the following error "error: unknown option `recurse-submodules'" appears, please upgrade git to v2.0.0 or above.
10.5.2.2 Generate Image File
You can compile an Android source code and generate an image file (non-root user is recommended):
cd rk3399-android-10 ./build-nanopc-t4.sh -F -M
If you need to include google apps, you need to set an environment variable and then compile, as shown below:
cd rk3399-android-10 export INSTALL_GAPPS_FOR_TESTING=yes ./build-nanopc-t4.sh -F -M
10.5.2.3 Make OTA Packages
If you need the support of A/B (Seamless) System Updates, you need to do the following:
a) Build your own update server for http download of update files;
b) Customize the Updater application, the code is located in packages/apps/Updater, let it connect and download file from your server;
c) Use the quick compilation script parameter -O or --ota to compile OTA Packages, as shown below:
cd rk3399-android-10 ./build-nanopc-t4.sh -F -O -M
After the compilation is successfully completed, the OTA update related packages are located in the directory: rockdev/otapackage/ ,Please do not delete this directory.
After you have made some changes, compiling again with the parameter -O will generate ota-update-XXXXXXXX.zip, which is an incremental update package.
OTA Packages decides whether to generate incremental update package according to BUILD_NUMBER, for details, please refer to build-nanopc-t4.sh.
To disable the A/B feature, you can refer to the following to modify device/rockchip/rk3399/nanopc-t4/BoardConfig.mk, and then recompile uboot and android:
BOARD_USES_AB_IMAGE := false
10.5.2.4 Update System with New Image
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 10's source code directory. You can follow the steps below to update the OS in NanoPi-NEO4:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android10 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-NEO4 and reflash Android
When flashing Android 10, EFlasher requires v1.3 or above. When flashing with Type-C, please use the tool AndroidTool v2.71 or Linux_Upgrade_Tool v1.49 provided by Rockchip.
10.5.3 Compile Android8.1
10.5.3.1 Download Android8.1 Source Code
There are two ways to download the source code:
- repo archive file on netdisk
Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-8.1.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
tar xvzf /path/to/netdisk/sources/rk3399-android-8.1.git-YYYYMMDD.tgz cd rk3399-android-8.1 ./sync.sh
- git clone from gitlab
NanoPi-NEO4 source code is maintained in gitlab, You can download it by running the following command:
git clone https://gitlab.com/friendlyelec/rk3399-android-8.1 --depth 1 -b master
10.5.3.2 Generate Image File
You can compile an Android source code and generate an image file:
cd rk3399-android-8.1 ./build-nanopc-t4.sh -F -M
10.5.3.3 Update System with New Image
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 8.1's source code directory. You can follow the steps below to update the OS in NanoPi-NEO4:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-NEO4 and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399
10.5.4 Compile Android7
10.5.4.1 Download Android7 Source Code
There are two ways to download the source code:
- repo archive file on netdisk
Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-7.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
tar xvzf /path/to/netdisk/sources/rk3399-android-7.git-YYYYMMDD.tgz cd rk3399-nougat ./sync.sh
- git clone from gitlab
NanoPi-NEO4 source code is maintained in gitlab, You can download it by running the following command:
git clone https://gitlab.com/friendlyelec/rk3399-nougat --depth 1 -b nanopc-t4-nougat
10.5.4.2 Generate Image File
You can compile an Android7 source code and generate an image file:
cd rk3399-nougat ./build-nanopc-t4.sh -F -M
10.5.4.3 Update System with New Image
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android7's source code directory. You can follow the steps below to update the OS in NanoPi-NEO4:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-NEO4 and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399
11 The usage of eMMC module
11.1 Flash Image to eMMC
11.1.1 Download Image and Utilities
Visit download link to download image files and utilities.
Android OS | |
rk3399-eflasher-android10-YYYYMMDD.img.zip | Android10 image file |
rk3399-eflasher-android8-YYYYMMDD.img.zip | Android8.1 image file |
rk3399-eflasher-android7-YYYYMMDD.img.zip | Android7.1.2 image file |
Linux OS | |
rk3399-eflasher-debian-bullseye-core-4.19-arm64-YYYYMMDD.img.gz | Debian 11(Bullseye) Core No desktop environment, command line only Kernel version 4.19.y |
rk3399-eflasher-debian-buster-desktop-arm64-YYYYMMDD.img.gz | Debian 10(buster) Desktop, Uses LXDE as default desktop, Supports hardware acceleration, Kernel version 4.19.y |
rk3399-eflasher-buildroot-4.19-arm64-YYYYMMDD.img.gz | Buildroot image file with Qt5-wayland (base on Rockchip Linux SDK) |
rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-YYYYMMDD.img.zip | 64-bit FriendlyDesktop image file based on Ubuntu desktop 18.04 64bit |
rk3399-eflasher-friendlycore-focal-4.19-arm64-YYYYMMDD.img.gz | 64-bit FriendlyCore image file(Qt 5.10.0) based on Ubuntu core 20.04 64bit |
rk3399-eflasher-friendlycore-bionic-4.4-arm64-YYYYMMDD.img.gz | 64-bit FriendlyCore image file(Qt 5.10.0) based on Ubuntu core 18.04 64bit |
rk3399-eflasher-lubuntu-desktop-xenial-4.4-armhf-YYYYMMDD.img.zip | Lubuntu Desktop(with Qt 5.10.0) |
Linux Lite OS | |
rk3399-eflasher-friendlycore-lite-focal-5.10-arm64-20211029.img.zip | 64-bit FriendlyCore Lite image file based on Ubuntu core 20.04 64bit, kernel version 5.15.y |
rk3399-eflasher-friendlycore-lite-focal-4.19-arm64-20211029.img.zip | 64-bit FriendlyCore Lite image file based on Ubuntu core 20.04 64bit, kernel version 4.19.y |
FriendlyWrt | |
rk3399-eflasher-friendlywrt-21.02-YYYYMMDD.img.gz | FriendlyWrt image file, based on OpenWrt 21.02, kernel version 5.15.y |
rk3399-eflasher-friendlywrt-21.02-docker-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 21.02, Pre-installed Docker,kernel version 5.15.y |
rk3399-eflasher-friendlywrt-22.03-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 22.03,kernel version 5.15.y |
rk3399-eflasher-friendlywrt-22.03-docker-YYYYMMDD.img.gz | FriendlyWrt image file,based on OpenWrt 22.03, Pre-installed Docker,kernel version 5.15.y |
rk3399-eflasher-friendlywrt-kernel4-YYYYMMDD.img.zip | FriendlyWrt image file, based on OpenWrt 21.02, kernel version 4.19.y |
Flash Utility: | |
win32diskimager.rar | Windows utility. Under Linux users can use "dd" |
11.1.2 Flash Image to eMMC with eflasher and SD card
- Get an 8G SDHC card and backup its data if necessary;
- Download and extract the rk3399-eflasher-OSNAME-YYYYMMDD.img.zip and win32diskimager;
- Run the win32diskimager utility under Windows as administrator. On the utility's main window select your SD card's drive, the wanted image file EFlasher and click on "write" to start flashing the SD card. Under Linux run "dd" to flash the rk3399-eflasher-OSNAME-YYYYMMDD.img file to your SD card;
- Take out the SD and insert it to NanoPi-NEO4's microSD card slot;
- Power on NanoPi-NEO4 and it will be booted from your SD card and the EFlasher utility will be automatically launched. You can work with the EFlasher in multiple ways:
1: Connect an HDMI monitor and a USB mouse to your board and work with EFlasher's GUI;
2: Connect your board to a LAN, login onto the board with SSH and type "eflasher" in a commandline utility and proceed with prompts;(Note: when you login with SSH the username is root and the password is fa. Your board's IP address can be found by checking the router's system)
3: Login onto your board via a serial terminal and type "eflasher" to proceed;
4: Connect a lcd2usb to NanoPi-NEO4, press the K1 button on the LCD2USB board to select your wanted OS and press the K2 button to confirm. The installation process will be shown on lcd2usb;
- After installation is done turn off the board and take out the SD card from NanoPi-NEO4, power on the board and it will be booted from eMMC;
12 Using On-Board Hardware Resources
12.1 Access Serial Interface
For now only UART4 is available for users:
Serial Interface Serial Device UART0 Used by Bluetooth UART1 Used by Gbps Ethernet UART2 Used by Serial Debug Port UART3 Used by Gbps Ethernet UART4 Available, device name is /dev/ttyS4 (note: this is only applicable for ROM released after 20180618)
13 Source code repositories
NanoPi-NEO4's source code repositories Android 8.1 Uboot https://gitlab.com/friendlyelec/rk3399-android-8.1/tree/master/u-boot
Android 8.1 Linux-4.4.y Kernel https://gitlab.com/friendlyelec/rk3399-android-8.1/tree/master/kernel
Android 8.1 BSP https://gitlab.com/friendlyelec/rk3399-android-8.1
netdisk location: sources/rk3399-android-8.1.git-YYYYMMDD.tgzAndroid 7.1.2 Uboot https://gitlab.com/friendlyelec/rk3399-nougat/tree/nanopc-t4-nougat/u-boot
Android 7.1.2 Linux-4.4.y Kernel https://gitlab.com/friendlyelec/rk3399-nougat/tree/nanopc-t4-nougat/kernel
Android 7.1.2 BSP https://gitlab.com/friendlyelec/rk3399-nougat
netdisk location: sources/rk3399-android-7.git-YYYYMMDD.tgzFriendlyCore/FriendlyDesktop/Lubuntu Uboot https://gitlab.com/friendlyelec/rk3399-android-8.1/tree/master/u-boot
FriendlyCore/FriendlyDesktop/Lubuntu Linux-4.4.y Kernel
14 Link to Rockchip Resources
15 Schematic, PCB CAD File
- Schematic: NanoPi-NEO4-1808-Schematic.pdf
- CAD document: NanoPi-NEO4-1808-Drawing(dxf).zip
16 Update Log
16.1 Oct-9-2018
- Released English version