Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rockpi4/Ubuntu"

(Bluetooth)
 
(11 intermediate revisions by one other user not shown)
Line 15: Line 15:
 
Linux as root or use Etcher in Windows
 
Linux as root or use Etcher in Windows
  
  gunzip -c rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz | dd of=/dev/mmcblk0
+
gunzip -c rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz | dd of=/dev/mmcblk0
  
 
=== Default username/password ===
 
=== Default username/password ===
  
    default username: rock
+
default username: rock
    default password: rock
+
default password: rock
  
 
rock is sudo user and switch to root can be done with the following command as user rock:
 
rock is sudo user and switch to root can be done with the following command as user rock:
  
    sudo su
+
sudo su
 +
 
 +
=== Root mode ===
 +
 
 +
rock is sudo user and switch to root can be done with the following command as user rock:
 +
 
 +
sudo su
 +
 
 +
For example:
 +
 
 +
rock@rockpi-4b:~$
 +
rock@rockpi-4b:~$ sudo su
 +
[sudo] password for rock:
 +
root@rockpi-4b:/home/rock#
 +
 
 +
There is no password for root user by default. You can set the password via 'passwd root'.
 +
 
 +
root@rockpi-4b:/home/rock# passwd root
 +
New password:
 +
Retype new password:
 +
passwd: password updated successfully
 +
root@rockpi-4b:/home/rock#
 +
 
 +
=== Access from the Host PC/Laptop ===
 +
 
 +
==== Option 1: Serial console ====
 +
 
 +
Check [[rockpi4/dev/serial-console | Serial Console]]
 +
 
 +
==== Option 2: SSH ====
 +
SSH server  is enabled on port 22 of ROCK Pi 4 default image.
 +
 
 +
Please use [https://angryip.org/ angryip] to find your board IP address.
 +
 
 +
$ ping ip-of-device
 +
$ ssh rock@ip-of-device
  
 
=== Add Radxa APT ===
 
=== Add Radxa APT ===
Line 31: Line 66:
  
 
We suggest that you add '''bionic-testing''' APT Source to get the newest packages.
 
We suggest that you add '''bionic-testing''' APT Source to get the newest packages.
 
=== Unminimize the system ===
 
 
  sudo unminimize
 
  
 
=== Network Connection ===
 
=== Network Connection ===
Line 72: Line 103:
 
* Test WIFI perpormance by tool iperf.
 
* Test WIFI perpormance by tool iperf.
  
=== Bluetooth ===
+
=== BT ===
  
 
Update necessary packages
 
Update necessary packages
  
 
   $ sudo apt-get update
 
   $ sudo apt-get update
   $ sudo apt-get install -y rockchip-fstab rockchip-overlay
+
   $ sudo apt-get install -y rockchip-overlay
 
   $ sudo apt-get install -y linux-4.4-latest # kernel version(>=4.4.154.100)
 
   $ sudo apt-get install -y linux-4.4-latest # kernel version(>=4.4.154.100)
 
   $ sudo apt-get install -y broadcom-wifibt-firmware(>=0.6)
 
   $ sudo apt-get install -y broadcom-wifibt-firmware(>=0.6)
  
Check bluetooth service
+
Check BT service
  
 
   $ systemctl status bluetooth
 
   $ systemctl status bluetooth
  
Run bluetooth service
+
Run BT service
  
 
   $ systemctl start bluetooth
 
   $ systemctl start bluetooth
  
Check bluetooth device
+
Check BT device
  
 
   $ hciconfig
 
   $ hciconfig
Line 98: Line 129:
 
           TX bytes:217746 acl:380 sco:0 commands:102 errors:0
 
           TX bytes:217746 acl:380 sco:0 commands:102 errors:0
  
Example: Connect to Bluetooth Speaker
+
Example: Connect to BT Speaker
  
 
Install pulseaudio packages
 
Install pulseaudio packages
Line 144: Line 175:
  
 
Play songs and enjoy it.
 
Play songs and enjoy it.
 +
 +
=== <span id="gpio">General purpose input-output (GPIO) </span> ===
 +
 +
* ROCK Pi 4 has one 40-pin expansion header. To control them, see [[rockpi4/hardware/gpio | ROCK Pi 4 GPIO Pinout]].
  
 
=== <span id="common_hardware_interface">Common Hardware Interfaces, I2C, PWM, SPI, UART, etc</span> ===
 
=== <span id="common_hardware_interface">Common Hardware Interfaces, I2C, PWM, SPI, UART, etc</span> ===
Line 176: Line 211:
 
   intfc:spi1=on
 
   intfc:spi1=on
 
   intfc:spi2=on
 
   intfc:spi2=on
 +
  intfc:dtoverlay=devspi1
 +
  intfc:dtoverlay=devspi2
  
 
==== UART ====
 
==== UART ====
Line 183: Line 220:
 
   intfc:uart2=on
 
   intfc:uart2=on
 
   intfc:uart4=on
 
   intfc:uart4=on
 +
 +
And add "#" to line "intfc:dtoverlay=console-on-ttyS2"
 +
 +
  #intfc:dtoverlay=console-on-ttyS2
 +
  #intfc:dtoverlay=console-on-ttyS4
 +
 +
Please note that when ROCK Pi 4 uart2 is connected with your devices like Raspberry Pi CAN/RS485 hat sending some data to uart2 on ROCK Pi 4. Please do the following step.
 +
 +
Check the file /boot/extlinux/extlinux.conf. And delete the following line.
 +
 +
  menu title select kernel
  
 
==== Debug console ====
 
==== Debug console ====
Line 267: Line 315:
 
   $ sudo apt install -y git gcc g++ libpng-dev libjpeg-dev pkg-config libx11-dev libdrm-dev libgbm-dev libgbm1 libudev-dev
 
   $ sudo apt install -y git gcc g++ libpng-dev libjpeg-dev pkg-config libx11-dev libdrm-dev libgbm-dev libgbm1 libudev-dev
 
   $ mkdir -p /home/rock/work
 
   $ mkdir -p /home/rock/work
   $ cd /homne/rock/work
+
   $ cd /home/rock/work
 
   $ git clone https://github.com/glmark2/glmark2.git
 
   $ git clone https://github.com/glmark2/glmark2.git
 
   $ ./waf configure --with-flavors=drm-glesv2
 
   $ ./waf configure --with-flavors=drm-glesv2

Latest revision as of 03:18, 29 September 2022

    ROCK Pi 4 >  Ubuntu

Work with Rock Pi 4 Ubuntu Server

Introduction

The Ubuntu server image for Rock Pi 4 target for minimal, fast and customization.

Create Image

Linux as root or use Etcher in Windows

gunzip -c rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz | dd of=/dev/mmcblk0

Default username/password

default username: rock
default password: rock

rock is sudo user and switch to root can be done with the following command as user rock:

sudo su

Root mode

rock is sudo user and switch to root can be done with the following command as user rock:

sudo su

For example:

rock@rockpi-4b:~$ 
rock@rockpi-4b:~$ sudo su
[sudo] password for rock: 
root@rockpi-4b:/home/rock# 

There is no password for root user by default. You can set the password via 'passwd root'.

root@rockpi-4b:/home/rock# passwd root
New password: 
Retype new password: 
passwd: password updated successfully
root@rockpi-4b:/home/rock#

Access from the Host PC/Laptop

Option 1: Serial console

Check Serial Console

Option 2: SSH

SSH server is enabled on port 22 of ROCK Pi 4 default image.

Please use angryip to find your board IP address.

$ ping ip-of-device
$ ssh rock@ip-of-device

Add Radxa APT

Follow the Guide of Radxa APT to add Radxa APT.

We suggest that you add bionic-testing APT Source to get the newest packages.

Network Connection

There are two methods for network connection. One is Ethernet and the other is WIFI.

Ethernet Connection

You can use a network cable (one end connected to the external network port or route) to connect your ROCK Pi 4 to the network. The ROCK Pi 4 will automatically configure the network for your surfing on the Internet.

To test the Ethernet, we need to follow the steps:

  • Switch to super user mode by command
 $ sudo su
  • Check whether the Ethernet is normal by command, ifconfig, which would show us a network card, eth0, and the Ethernet IP address. Also, use tool, ping, to connect to a normal domain.
 $ ifconfig
 $ ping www.baidu.com

WIFI Connection

When there is not a network cable for your ROCK Pi 4 the WIFI connection is another good choice. ROCK Pi 4 supports 2.4G/5G WIFI wireless network.

To test the WIFI performance, we need to follow the steps:
  • Switch to super user mode
 $ sudo su
  • Open the WIFI
 $ nmcli r wifi on
  • Scan WIFI
 $ nmcli dev wifi
  • Connect to WIFI network
 $ nmcli dev wifi connect "wifi_name" password "wifi_password"
  • Test WIFI perpormance by tool iperf.

BT

Update necessary packages

 $ sudo apt-get update
 $ sudo apt-get install -y rockchip-overlay
 $ sudo apt-get install -y linux-4.4-latest # kernel version(>=4.4.154.100)
 $ sudo apt-get install -y broadcom-wifibt-firmware(>=0.6)

Check BT service

 $ systemctl status bluetooth

Run BT service

 $ systemctl start bluetooth

Check BT device

 $ hciconfig
 hci0:   Type: Primary  Bus: UART
         BD Address: AD:B8:A0:DA:A3:27  ACL MTU: 1021:8  SCO MTU: 64:1
         UP RUNNING 
         RX bytes:7900 acl:35 sco:0 events:387 errors:0
         TX bytes:217746 acl:380 sco:0 commands:102 errors:0

Example: Connect to BT Speaker

Install pulseaudio packages

 $ sudo apt-get install -y pulseaudio-module-bluetooth pulseaudio

Run pulseaudio, otherwise ROCK Pi 4 will not be able to connect to device.

 $ pulseaudio --start

Connect using bluetoothctl

 $ bluetoothctl
 
 [bluetooth]# default-agent 
 Default agent request successful
 
 [bluetooth]# power on
 Changing power on succeeded
 
 [bluetooth]# scan on
 Discovery started
  
[bluetooth]# trust 77:EC:79:4F:6B:AC
 [CHG] Device 77:EC:79:4F:6B:AC Trusted: yes
 Changing 77:EC:79:4F:6B:AC trust succeeded
 
 [bluetooth]# pair 77:EC:79:4F:6B:AC
 Attempting to pair with 77:EC:79:4F:6B:AC
 [CHG] Device 77:EC:79:4F:6B:AC Connected: yes
 [CHG] Device 77:EC:79:4F:6B:AC UUIDs: 00001101-0000-1000-8000-00805f9b34fb
 [CHG] Device 77:EC:79:4F:6B:AC UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
 [CHG] Device 77:EC:79:4F:6B:AC UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
 [CHG] Device 77:EC:79:4F:6B:AC UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
 [CHG] Device 77:EC:79:4F:6B:AC UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
 [CHG] Device 77:EC:79:4F:6B:AC ServicesResolved: yes
 [CHG] Device 77:EC:79:4F:6B:AC Paired: yes
 Pairing successful
 
 [bluetooth]# connect 77:EC:79:4F:6B:AC
 Attempting to connect to 77:EC:79:4F:6B:AC
 [CHG] Device 77:EC:79:4F:6B:AC Connected: yes
 Connection successful
 [CHG] Device 77:EC:79:4F:6B:AC ServicesResolved: yes

Play songs and enjoy it.

General purpose input-output (GPIO)

Common Hardware Interfaces, I2C, PWM, SPI, UART, etc

The ROCK Pi 4 system images use hw_intfc.conf, provided by the package rockpi4-dtbo, to configure interfaces.

For more details about device tree overlays, see ROCK Pi 4 Device Tree Overlays.

Install essential package

 sudo apt-get install -y rockpi4-dtbo

I2C

Modify file /boot/hw_intfc.conf. Set "on" to enable the optional hardware interfaces while set "off" to disable.

 intfc:i2c2=on
 intfc:i2c6=on
 intfc:i2c7=on

PWM

Modify file /boot/hw_intfc.conf. Set "on" to enable the optional hardware interfaces while set "off" to disable.

 intfc:pwm0=on
 intfc:pwm1=on

SPI

Modify file /boot/hw_intfc.conf. Set "on" to enable the optional hardware interfaces while set "off" to disable.

 intfc:spi1=on
 intfc:spi2=on
 intfc:dtoverlay=devspi1
 intfc:dtoverlay=devspi2

UART

Modify file /boot/hw_intfc.conf. Set "on" to enable the optional hardware interfaces while set "off" to disable.

 intfc:uart2=on
 intfc:uart4=on

And add "#" to line "intfc:dtoverlay=console-on-ttyS2"

 #intfc:dtoverlay=console-on-ttyS2
 #intfc:dtoverlay=console-on-ttyS4

Please note that when ROCK Pi 4 uart2 is connected with your devices like Raspberry Pi CAN/RS485 hat sending some data to uart2 on ROCK Pi 4. Please do the following step.

Check the file /boot/extlinux/extlinux.conf. And delete the following line.

 menu title select kernel

Debug console

Modify file /boot/hw_intfc.conf. Set ttyS2 as debug console.

Disable UART2

 intfc:uart2=off

And uncomment the following line.

 intfc:dtoverlay=console-on-ttyS2

Use SPI Flash on board

Modify file /boot/hw_intfc.conf. Disable UART4 and enable SPI1. Besides, need to load spi1-flash overlay.

 intfc:uart4=off
 intfc:spi1=on
 intfc:dtoverlay=spi1-flash

Additional software

OpenCV

There are two ways to get OpenCV. One is building OpenCV by yourself (Option one) and the other is installing opencv4.0 package (Option two).

Option 1: Manually build

Build OpenCV by yourself. See Install OpenCV.

Option 2: Install pre-built binaries
Install Ubuntu desktop

To use OpenCV, an OS desktop is necessary. If your ROCK Pi 4 is running Ubuntu but without desktop, you can install Ubuntu mate desktop.

   $ sudo apt install ubuntu-mate-core && sudo apt install ubuntu-mate-desktop
Install all the recommended packages

Required:

   $ sudo apt-get update && sudo apt-get upgrade
   $ sudo apt-get install build-essential
   $ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

Recommended optional packages:

   $ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
   $ sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libavresample-dev
   $ sudo apt install tesseract-ocr cmake-data liblept5

Install OpenCV package:

   $ sudo apt-get install opencv4.0
Step 3: Test OpenCV

To check the version of your installed OpenCV, try this:

   rock@linux:~$ python
   Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
   [GCC 7.3.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import cv2
   >>> cv2.__version__
   '4.0.1'
   >>>

Obtain OpenCV sample:

   $ cd ~
   $ wget -O opencv.zip https://github.com/opencv/opencv/archive/4.0.1.zip
   $ unzip opencv.zip
   
   $ cd ~/opencv-4.0.1/samples/python
   $ python watershed.py

OpenGL ES

Install glmark2
 $ sudo apt update
 $ sudo apt install -y git gcc g++ libpng-dev libjpeg-dev pkg-config libx11-dev libdrm-dev libgbm-dev libgbm1 libudev-dev
 $ mkdir -p /home/rock/work
 $ cd /home/rock/work
 $ git clone https://github.com/glmark2/glmark2.git
 $ ./waf configure --with-flavors=drm-glesv2
 $ ./waf build -j 4
 $ ./waf install
Install mali packages
 $ sudo apt install -y rockchip-mali-midgard14=1.6-2
 $ sudo apt install -y rockchip-mali-midgard-dev=1.6-2
Test OpenGL via glmark2-es2-drm
 $ glmark2-es2-drm
 =======================================================
    glmark2 2021.02
=======================================================
    OpenGL Information
    GL_VENDOR:     ARM
    GL_RENDERER:   Mali-T860
    GL_VERSION:    OpenGL ES 3.2 v1.r14p0-01rel0-git(966ed26).f44c85cb3d2ceb87e8be88e7592755c3
=======================================================
[build] use-vbo=false: FPS: 59 FrameTime: 16.949 ms                             
[build] use-vbo=true: FPS: 60 FrameTime: 16.667 ms                              
[texture] texture-filter=nearest: FPS: 60 FrameTime: 16.667 ms                  
[texture] texture-filter=linear: FPS: 60 FrameTime: 16.667 ms                   
[texture] texture-filter=mipmap: FPS: 60 FrameTime: 16.667 ms                   
[shading] shading=gouraud: FPS: 60 FrameTime: 16.667 ms                         
[shading] shading=blinn-phong-inf: FPS: 60 FrameTime: 16.667 ms                 
[shading] shading=phong: FPS: 60 FrameTime: 16.667 ms                           
[shading] shading=cel:^C^V FPS: 60 FrameTime: 16.667 ms
=======================================================
                                  glmark2 Score: 59 
=======================================================

Networking

Since bionic networking has moved to netplan /etc/netplan netplan

Changelogs

2019.11.27

rockpi4b-ubuntu-bionic-minimal-20191127_1942-gpt.img.gz

  • Kernel version updated to linux-4.4.154-95-rockchip-gd2ab1f26e1b3
  • U-Boot version updated to 2017.09-00013-g6d910b7
  • systemd version: 237
  • Support SSH

2019.01.04

rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz

  • Add radxa apt repository in the release image
  • Rockchip hardware overylay are now managed by deb package
  • New DRM hotplug management script fix screen resolution change issue
  • Kernel version updated to linux-4.4.154-59-rockchip-g5e70f14
    • Kernel modules support AppArmor, Docker, WireGuard and UFW
    • Support USB gadget network, see USB Net
    • Support TP-Link UE300 ethernet adapter
    • A lot of kernel features are enabled as modules
  • Uboot version updated to 2017.09-02085-g5a6aeld
    • Support kernel boot menu selection(serial console only)
    • Support device tree directory boot
    • Support manually flash uboot in running system
  • Fix ethernet is not managed by Network Manager issue
  • Kernel package installation automatically adds to the boot menu