|
|
中文 / EN
|
The RK1808 artificial intelligence computing stick is a member of Rockchip’s Toybrick series of products. The computing stick is equipped with Rockchip’s RK1808 neural network processor. It has low power consumption and high performance, and can be used in various artificial intelligence applications. . The host computer can obtain powerful deep learning reasoning ability through the RK1808 artificial intelligence computing stick. With the powerful computing power of the RK1808 artificial intelligence computing stick, embedded devices can build artificial intelligence algorithms on the edge of the network, allowing traditional embedded devices to easily complete artificial intelligence upgrades.
The RK1808 artificial intelligence computing stick can be used to assist inference calculations, and it also supports the completion of independent artificial intelligence calculation functions through secondary development.
CPU | RK1808 |
---|---|
RAM | 1GB LPDDR |
storage | 8GB EMMC |
size | 82×31×13mm |
interface | USB3.0 Type-A |
Minimum system requirements | X86_64 computer with Ubuntu 16.04 or win 7; USB 2.0 Type-A port; 2 GB RAM; 4 GB available storage space; |
temperature | 0℃~40℃ |
Note: The calculation stick is in passive mode by default. Do not modify the configuration of the calculation stick, which means that the calculation stick does not need to change the mode, and the default passive mode is uniformly fixed.
In passive mode: RK1808 artificial intelligence computing stick is a general AI accelerator. The upper computer transmits the model and pre-processed data to the RK1808 artificial intelligence computing stick through RKNN-Toolkit. The RK1808 artificial intelligence computing stick completes the inference and returns the result to the upper computer, which performs post-processing and display operations.
Currently the following platforms and systems support passive mode:
PC Linux system, Windows system, Mac OS
RK3399, RK3399Pro platform Linux system, Android system
For other platforms and systems that do not support passive mode, users can use active mode. For active mode, please refer to the Wiki tutorial--TB-RK1808S0--active mode development
The passive mode development flow chart is as follows:
The overall data flow diagram of the passive mode is as follows:
In passive mode, two sets of APIs, python and C, are provided for host computer programming.
This section mainly describes how to use RKNN-Toolkit to quickly run the deep neural network model mobilenet_v1 on an Ubuntu 18.04 PC based on python3.6.
• Intel Core i3 or higher x86 64-bit PC with ubuntu 18.04 operating system (CPU instruction set needs to support SSE4.2 AVX AVX2, if not, the user needs to download the tensorflow source code by himself, remove the instruction set dependency and then compile and install).
• RK1808 artificial intelligence computing stick.
• Insert the RK1808 AI Compute Stick into the USB port of the PC, and use the lsusb command to view it, as follows (the red font 2207:0018 is our RK1808 AI Compute Stick):
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 009: ID 2207:0018
RKNN-Toolkit is an NPU development kit for model conversion, reasoning and performance evaluation based on python interface programming provided by Rockchip for users. In this section, an x86 64-bit PC with ubuntu 18.04 operating system is used as an example to illustrate when the Python version is How to install RKNN-Toolkit when it is 3.6, the following are the commands executed in the terminal:
• Install Python3.6
sudo apt-get install python3.6
• Install OpenCV
sudo apt-get install -y python3-opencv
• Install pip3
sudo apt-get install python3-pip
• Insert the TB-RK1808 artificial intelligence computing stick, the U disk device will be displayed on the PC, and the directory structure of the U disk device is as follows:
• Perform the following steps:(note:the following software versions are for demonstration purposes only. Due to version iteration updates, please install the latest version yourself. https://github.com/rockchip-linux/rknn-toolkit)
mkdir ~/rknncd ~/rknn
sudo apt-get install -y wget
wget http://repo.rock-chips.com/python/rknn_toolkit-1.2.1-cp36-cp36m-linux_x86_64.whl
pip3 install --user tensorflow==1.13.1
pip3 install --user rknn_toolkit-1.2.1-cp36-cp36m-linux_x86_64.whl
Note: RKNN-Toolkit package must be consistent with python version, ubuntu18.04 defaults to python3.6 by default.
1)Enter the following command in the terminal:
python3
2)Enter the following code in the python3 operating environment to import the RKNN module:
from rknn.api import RKNN
(a) The successful import of RKNN module is as follows:
$ python3
>>> from rknn.api import RKNN
>>>
(b) If no error is reported when importing the RKNN module, then enter quit() to exit Python3 (skip the following step (3)).
(c) If the following error is reported when importing the RKNN module, this is because the Tensorflow installation package that RKNN relies on uses the SSE4.2 instruction set. These instructions cannot run on the old version of the CPU. Please check and replace it with one that supports SSE4.2 PC with instruction set.
$ python3
>>> from rknn.api import RKNN
2019-06-25 20:10:25.255397: F tensorflow/core/platform/cpu_feature_guard.cc:37] The TensorFlow library was compiled to use SSE4.2 instructions, but these aren't available on your machine.
1) Return to the root directory of the USB flash drive, copy tool/update_rk1808_ai_cs_rule.sh to the rknn directory of the current HOME directory, and modify update_rk1808_ai_cs_rule.sh to executable permissions.
cp tool/update_rk1808_ai_cs_rule.sh ~/rknn -f
chmod +x ~/rknn/update_rk1808_ai_cs_rule.sh
2) Return to the rknn directory, update_rk1808_ai_cs_rule.sh must be executed with root privileges.
cd ~/rknnsudo
./update_rk1808_ai_cs_rule.sh
Note: This step only needs to be executed once during the installation, and does not need to be executed in the future.
1) Enter the following command:
lsusb
2) The execution results are as follows:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 009: ID 2207:0018
Note: Bus 003 Device 009 is the device number of the calculation stick.
1) Enter the following command:
ls -l /dev/bus/usb/003/009
Note: For the above 003/009, different PCs may get different numbers, depending on the specific situation.
2) The execution result is as follows (the correct read and write permissions are shown in red font):
crw-rw-rw- 1 root root 189, 264 6 月 14 16:02 /dev/bus/usb/003/009
Take mobilenet_v1 as an example. The function implemented by the mobilenet_v1 example is to perform feature extraction on a picture and identify the category of the picture.
The following is the directory structure of the mobilenet_v1 example and the description is as follows:
• dataset.txt: A text file containing the path of the test image.
• dog_224x224.jpg: test picture as an example of mobilenet_v1.
• mobilenet_v1.tflite: TensorFlow Lite model file.
• mobilenet_v1.rknn: rknn model file. The rknn model file generated by the RKNN-Toolkit model conversion from a non-rknn model file (here is the TensorFlow Lite model).
• test.py: sample running script (including rknn model conversion part).
• test_inference.py: sample running script (only load the rknn model for inference).
The sample operation steps are as follows:
mobilenet_v1
compressed package from the official FTP file server and unzip it:wget http://repo.rock-chips.com/rk1808/mobilenet_v1.tar.gz
tar xvf mobilenet_v1.tar.gz
cd mobilenet_v1/
python3 test.py
\3. Get the following results
--> config model
done
--> Loading model
done
--> Building model
done
--> Export RKNN model
done
--> Init runtime environment
done
--> Running modelmobilenet_v1
-----TOP 5-----
[156]: 0.8837890625
[155]: 0.0677490234375
[188 205]: 0.00867462158203125
[188 205]: 0.00867462158203125
[263]: 0.0057525634765625
done
--> Begin evaluate model performance
======================================================================== Performance ========================================================================
Total Time(us): 7140FPS: 140.06
========================================================================
done
This section mainly describes how to run the RK1808 AI computing stick on RK3399ProD (fedora system), and use RKNN-Toolkit to quickly run the deep neural network model mobilenet_v1 based on python3.6.
• Toybrick RK3399ProD development board (firmware version is V1.5), rk1808 artificial intelligence computing stick (firmware version is V1.3.4).
• Insert the RK1808 AI Compute Stick into the USB interface of RK3399ProD and use the lsusb command to view it as follows (the red font part 2207:0018 is our RK1808 Artificial Intelligence Compute Stick):
lsusb
Bus 004 Device 004: ID 2207:0018
*Bus 004 Device 003: ID 2207:1808*
sudo dnf install -y cmake gcc gcc-c++ protobuf-devel protobuf-compiler lapack-devel opencv-devel
sudo dnf install -y python3-devel python3-opencv python3-numpy-f2py python3-h5py python3-lmdb python3-grpcio
• Insert the TB-RK1808 artificial intelligence computing stick, and the U disk device will be displayed on the RK3399ProD development board. The directory structure of the U disk device is as follows:
• Perform the following steps:
mkdir ~/rknncd ~/rknn
sudo dnf install wget
wget http://repo.rock-chips.com/python/rknn_toolkit-1.2.1-cp36-cp36m-linux_aarch64.whl
pip3 install --user tensorflow
pip3 install --user rknn_toolkit-1.2.1-cp36-cp36m-linux_aarch64.whl
Note: The RKNN-Toolkit package must be consistent with the python version. The current development board fedora system defaults to python3.6 by default.
1) Enter the following command in the terminal:
python3
2) Enter the following code in the python3 operating environment to import the RKNN module:
from rknn.api import RKNN
(a) The successful import of RKNN module is as follows:
$ python3
>>> from rknn.api import RKNN
>>>
(b) If no error is reported when importing the RKNN module, then enter quit() to exit Python3.
1) Return to the root directory of the USB flash drive, copy tool/update_rk1808_ai_cs_rule.sh to the rknn directory of the current HOME directory, and modify update_rk1808_ai_cs_rule.sh to executable permissions.
cp tool/update_rk1808_ai_cs_rule.sh ~/rknn -f
chmod +x ~/rknn/update_rk1808_ai_cs_rule.sh
2) Return to the rknn directory, update_rk1808_ai_cs_rule.sh must be executed with root privileges.
cd ~/rknn
sudo
./update_rk1808_ai_cs_rule.sh
Note: This step only needs to be executed once during the installation, and does not need to be executed in the future.
1) Enter the following command:
lsusb
2) The execution results are as follows:
Bus 004 Device 004: ID 2207:0018
Bus 004 Device 003: ID 2207:1808
Note: Bus 004 Device 004 is the device number of the computing stick, * *Bus 004 Device 003 is the internal NPU number of rk3399proD** .
1) Enter the following command:
ls -l /dev/bus/usb/004/004
Note: For the above 004/004, different equipment may get different numbers, depending on the specific situation.
2) The execution result is as follows (the correct read and write permissions are shown in red font):
crw-rw-rw- 1 root root 189, 387 Sep 23 21:49 /dev/bus/usb/004/004
Take mobilenet_v1 as an example. The function implemented by the mobilenet_v1 example is to perform feature extraction on a picture and identify the category of the picture.
The following is the directory structure of the mobilenet_v1 example and the description is as follows:
• dataset.txt: A text file containing the path of the test image.
• dog_224x224.jpg: test picture as an example of mobilenet_v1.
• mobilenet_v1.tflite: TensorFlow Lite model file.
• mobilenet_v1.rknn: rknn model file. The rknn model file generated by the RKNN-Toolkit model conversion from a non-rknn model file (here is the TensorFlow Lite model).
• test.py: sample running script (including rknn model conversion part).
• test_inference.py: sample running script (only load the rknn model for inference).
The sample operation steps are as follows:
wget http://repo.rock-chips.com/rk1808/mobilenet_v1.tar.gztar xvf mobilenet_v1.tar.gz
cd mobilenet_v1/
python3 test.py
E More than 1 device detected to usb ntb. Please specify the device to use with device id parameter.
This is because there are 2 NPUs, and the code does not specify which NPU to use.
Modify test.py to specify the device id, where TS018080000000055 is the device id of the computing stick, each computing stick is different, the user can modify it according to his own device
ret = rknn.init_runtime(target='rk1808', device_id='TS018080000000055')
If the user wants to enumerate the device id of all the computing stick devices, you can add it in the code
_, ntb_devices = rknn.list_devices()
--> config model
done
--> Loading model
done
--> Building model
done
--> Export RKNN model
done
--> Init runtime environment
done
--> Running model
mobilenet_v1
-----TOP 5-----
[156]: 0.8837890625
[155]: 0.0677490234375
[188 205]: 0.00867462158203125
[188 205]: 0.00867462158203125
[263]: 0.0057525634765625
done
--> Begin evaluate model performance
======================================================================== Performance ========================================================================
Total Time(us): 7140FPS: 140.06
========================================================================
done
For more detailed usage and interface description of RKNN-Toolkit, please refer to the "Rockchip_RK1808_AI_Compute_Stick_User_manual_CN.pdf" manual.
This chapter explains how to use RKNN-Toolkit in Windows system and Python 3.6 environment.
Installation file download address: Click here to download
Connect the TB-RK1808 AI computing stick to the PC via USB
A camera is required to run the demonstration. If the machine does not have a camera, an external USB camera is required
Download the environment package: win_rknn_env.zip
Introduction to environmental package files:
• download.bat: Double-click to run, it will automatically download related software packages to packages, and demo (yolov3) for demonstration
• install.bat: first manually install the ntb driver in the packages directory and python3.6.8; then double-click to run install.bat, it will automatically install rknn-toolkit
• run_yolov3.bat: Double-click to run, it will automatically run yolov3 demo, this file will be generated after running install.bat
Installation package download
Driver Installation
Enter the packages directory and run the zadig-2.3.exe program as an administrator to install the driver of the computing stick, as shown in the following figure:
Note: The USB ID of the device to be installed should be 2207:0018; select libusb-win32 (v1.2.6.0) as the driver to be installed, and click Install Driver to start installing the driver after confirmation.
After the installation is complete, if there is no exclamation mark in the USB of the Windows Device Manager, and the following is shown, the installation is successful:
Note: You need to restart the computer after installing the driver.
Install Python 3.6
Enter the packages directory.
Double-click python-3.6.8-amd64.exe to install, and you must check Add PATH.
Install RKNN-Toolkit
Before installing RKNN-Toolkit, you need to make sure that Python 3.6 has been installed in the system. This can be determined by executing python -version in cmd, as shown below, the system has Python 3.6 installed:
Double-click install.bat and wait for the automatic installation to complete.
Run the demo
Make sure the computing stick has been inserted, make sure there is a camera on the computer, if there is no built-in camera, you need to insert a USB camera.
Double-click run_yolov3.bat (this file is generated after running install.bat), wait for a while, show the screen, if you want to exit, click the display box with the mouse, and press the'Esc' key to exit.
This chapter explains how to use RKNN-Toolkit in the MacOS-system and Python3.6 environment.
Installation file download address: Click here to download
Operating system confirmation: MacOS 10.12 (x64) and above
Connect the TB-RK1808 AI computing stick to the PC via USB
A camera is required to run the demonstration. If the machine does not have a camera, an external USB camera is required.
Download the environment package: mac_rknn_env.zip
Put mac_rknn_env.zip in the Downloads directory of the PC and decompress it
Introduction to environmental package files:
• download.sh.command: automatically download related software packages to packages, and demo (yolov3) for demonstration
• install.sh.commad: first manually install the Horndis driver and python3.6.8; then double-click to run install.sh.commad, it will automatically install rknn-toolkit
• rknn_camera_tiny.py.command: automatically run yolov3 demo
Double-click to run download.sh.command, the computer will install some programs at this time, and a pop-up window will prompt to install the software. After entering the password, click Confirm
Wait for the download to complete. During the download process, the download tool will be installed automatically. You may need to enter a password. The download tool installation will take a long time. After the download is complete, a new package directory will be added.
If there is an error that the third-party application cannot be installed, you need to execute sudo spctl --master-disable to allow any source application to be installed
Driver Installation
Enter the packages directory
Double-click to install HoRNDIS-9.2.pkg
Install Python 3.6
Enter the packages directory
Double-click to install python-3.6.8-macosx10.9.pkg
Install RKNN-Toolkit
Double-click to run install.sh.command, the computer will automatically install some program packages, please be patient and wait for the installation to complete.
Run the demo
After the above steps are installed, you only need to run the following operations to start the demo program.
Make sure the computing stick is plugged in, make sure there is a camera on the computer, if there is no built-in camera, you need to insert a USB camera.
Double-click to run run_yolov3.sh.command (this file is generated after running install.sh.command)
After waiting for a while, the demo screen will appear. If you want to exit, click the display box with the mouse and press the'Esc' key to exit.
Note: Do not modify the configuration of the computing stick, which means that the computing stick does not need to change the mode, and the default passive mode can be uniformly fixed.
In active mode, RK1808 artificial intelligence computing stick is a dedicated AI application module. RK1808 artificial intelligence computing stick is an active device. rknn-toolkit and rknn-api are installed by default inside the RK1808 artificial intelligence computing stick. The upper computer (also called host) does not need to install rknn-toolkit and rknn-api. The model and algorithm are solidified in RK1808. In the artificial intelligence computing stick, the upper computer only needs to input data (such as pictures and video streams) to the computing stick through the USB port. The RK1808 artificial intelligence computing stick automatically completes the pre-processing, inference, and post-processing of the data, and then passes the processing results through the USB port Output to the host computer. The host computer here can be any platform with USB interface and any operating system, including x86/x64/arm32/arm64 linux/windows/mac os and single-chip microcomputer, raspberry pie, etc...
In order to facilitate users to transfer data through the USB port, the RK1808 artificial intelligence computing stick will virtualize the USB port into a standard device such as a network card. Users only need to operate the standard device interface (such as network socket programming) to complete the RK1808 artificial intelligence computing stick. Data input and output.
Details as follow
After the RK1808 computing stick is inserted into the host computer, it will be virtualized as a network card device
The host computer configures the virtual network card, and the IP is 192.168.180.1 to ensure that the network connection between the host computer and 1808 is normal
The default IP of the computing stick is 192.168.180.8, and the account password is toybrick. Users can log in to the computing stick with SSH, and copy the model and server service program to the computing stick.
The computing stick end runs the server service program to receive the connection request from the upper computer, call RKNN for processing, and then return the result
The host computer runs the client program and after successfully connecting to the server, it sends a reasoning request and obtains the return result from the 1808 end
Overall flow chart of active development mode:
The AI program developed in the active mode is divided into two parts: the computing stick server program and the host computer client application.
• The model is pre-deployed on the storage of the computing stick. The computing stick server program initializes the environment and loads the model, starts the socket server, receives the data pushed by the host computer, performs inference, and then returns the result of the inference to the host computer.
• The host computer client application collects data (such as capturing camera data), pushes the data to the computing stick through the socket client, and receives the processing results returned by the computing stick through the socket client, and performs further processing (such as display).
RKNN API call reference on RK1808 artificial intelligence computing stick in active mode: "Rockchip_RK1808_Developer_Guide_Linux_RKNN".
The RK1808 artificial intelligence computing stick has provided the libraries and header files required by the RKNN API C/C++ language, and also pre-installed the RKNN API python 3.6 library. Users can develop and deploy C/C++ or C/C++ on the RK1808 artificial intelligence computing stick. Active AI program for python.
In the active mode, SSH login is provided for development and debugging: the linux operating system of the RK1808 artificial intelligence computing stick is fedora, and users can log in to the fedora system through SSH for development and debugging. The password of the root user is toybrick, and the password of the ordinary user toybrick is toybrick .
As a network card device (rndis), RK1808 artificial intelligence computing stick is configured into active mode through the web. For details, please refer to the web configuration introduction (if you need to restore the passive mode, please reset and select the passive mode).
Set the toybrick_deploy login password.
Use the active mode development tool toybrick_deployc to upgrade the system software package in the RK1808 artificial intelligence computing stick to ensure that the system software package in the RK1808 artificial intelligence computing stick is at the latest version. Toybrick maintains its own source server, and will update the system software package from time to time to increase system stability. This step depends on the user's needs to choose whether to update or not. If the existing system can meet the development needs, it may not be updated.
The RK1808 artificial intelligence computing stick communicates with the upper computer through the network socket, writing the upper computer service program and the lower computer program of the RK1808 artificial intelligence computing stick, and installing the rpm and python dependency packages in the RK1808 artificial intelligence computing stick through the active mode development tool toybrick_deployc (If necessary), solidify the model and running program on the RK1808 artificial intelligence computing stick, and run the inference and related processing programs on the RK1808 artificial intelligence computing stick. The upper computer program receives the inference and related data processing results in the RK1808 artificial intelligence computing stick. .
Use the active mode development tool toybrick_deployc to set the program solidified in the RK1808 artificial intelligence computing stick to start up, and restart the RK1808 artificial intelligence computing stick to verify whether the setting is successful and prepare for deployment.
Fix the model and algorithm on the RK1808 artificial intelligence calculation stick, and set the program solidified in the RK1808 artificial intelligence calculation stick to start automatically.
Insert the RK1808 artificial intelligence computing stick into the target device, such as web camera equipment, PC, drone, smart car, etc.
Run the host computer service program on the target device and display the processing result.
For specific cases, please refer to the yolov3 active mode case in the wiki tutorial.
Operating system confirmation: Android 8.1.0 (the demonstration device is Toybrick TB-RK3399ProD V1.3 version of the Android system, the development process of other Android platforms is for reference only).
Connect the TB-RK1808 AI Compute Stick to a PC (win, Mac, Linux) via USB, configure the TB-RK1808 AI Compute Stick server environment, copy the server program that needs to be run to the TB-RK1808 AI Compute Stick and Set to start the server program at boot.
Connect the TB-RK1808 AI Compute Stick to the Android device via USB, configure the TB-RK1808 AI Compute Stick and Android local network sharing (before configuration, please make sure that the Android device has installed the rndis driver to correctly identify the Compute Stick network card).
A camera is required to run the demonstration. If the Android device does not have a built-in camera, an external USB camera is required.
Install master_yolov3_demo.apk and run the demo program
For details, please refer directly to: yolov3 active mode Android platform development process
The active mode is suitable for any system on any platform. The upper computer only needs to be able to communicate via USB. rknn-toolkit and rknn-api are installed by default in the RK1808 artificial intelligence computing stick. The upper computer does not need to install rknn-toolkit and rknn-api. , The host computer only needs to send data to the computing stick through the Socket, the computing stick receives the data and infers, the computing stick sends the inference result to the host computer through the socket, and the host computer displays the result.
For active mode development, please directly refer to the related Demo of the active mode in the "Sample".
For the Raspberry Pi development board using the RK1808 computing stick, users can refer to http://t.rock-chips.com/forum.php?mod=viewthread&tid=1380&extra=page%3D1
RK1808 artificial intelligence computing stick can share the network by configuring the NAT function and bridging function of the Linux host computer to realize computing stick networking. NAT is recommended.
1) Open "Preferences" -> "Network Connections", open "Settings" -> "Network Connections" in Ubuntu system, "Wired connection 1" is the local network card link, "Wired connection 2" is the RK1808 artificial intelligence computing stick network card link, Select "Wired connection 2" and click "Configuration" as shown in the figure below.
2) Enter the "Wired connection 2" configuration interface, select "IPv4 Settings", select the "Manual" mode of connection, click "Add", enter Address and Netmask, as shown in Figure 5 below. Click "Save" to save and exit.
1) Run ifconfig, you can see that eno1 is a local network card for accessing the external network, and enp0s20u12u2i1 is a USB network card (RK1808 artificial intelligence computing stick virtual network card). The name of the network card in different systems may be different, and the actual network card name shall prevail.
2) In command line mode, execute the following command, where enp0s20u12u2i1 needs to be modified to the user's local actual value; under normal circumstances, it only needs to be set once. If the network card name is changed or the user manually deletes the network card, it needs to be reset.
sudo nmcli connection add con-name toybrick type ethernet ifname enp0s20u12u2i1 autoconnect yes ip4 192.168.180.1/24
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
The calculation stick needs to turn on DHCP. Refer to point 8 of the main function introduction on the WEB page to set it.
Create the configuration script bridge-setup.sh with the following content:
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Invalid argument"
exit 0
fi
count=`nmcli con show | awk '$(NF-1)=="bridge"' | wc -l`
for i in $(seq 1 $count)
do
uuid=`nmcli con show | awk '$(NF-1)=="bridge"' | awk '{print $(NF-2)}'`
sudo nmcli con del $uuid
sleep 1
done
count=`nmcli con show | awk '$(NF-1)=="802-3-ethernet" || $(NF-1)=="ethernet"' | wc -l`for i in $(seq 1 $count)
do
uuid=`nmcli con show | awk '$(NF-1)=="802-3-ethernet" || $(NF-1)=="ethernet"' | awk 'NR==1{print $(NF-2)}'`
sudo nmcli con del $uuid
sleep 1
done
nmcli con add con-name br0 type bridge ifname br0 -- ipv4.routes 192.168.180.0/24 ipv4.method auto bridge.stp no
#nmcli con add con-name $1 type bridge-slave ifname $1 master br0
#nmcli con add con-name $2 type bridge-slave ifname $2 master br0
for var in $@
do
nmcli con add con-name $var type bridge-slave ifname $var master br0
donen
mcli con up br0
ip addr add 192.168.180.1/24 dev br0
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Invalid argument"
exit 0
fi
count=`nmcli con show | awk '$(NF-1)=="bridge"' | wc -l
`for i in $(seq 1 $count)
do
uuid=`nmcli con show | awk '$(NF-1)=="bridge"' | awk '{print $(NF-2)}'`
nmcli con del $uuid
sleep 1
done
count=`nmcli con show | awk '$(NF-1)=="802-3-ethernet" || $(NF-1)=="ethernet"' | wc -l`
for i in $(seq 1 $count)
do
uuid=`nmcli con show | awk '$(NF-1)=="802-3-ethernet" || $(NF-1)=="ethernet"' | awk 'NR==1{print $(NF-2)}'`
nmcli con del $uuid
sleep 1
done
nmcli con add con-name $1 type ethernet ifname $1
nmcli con up $1
nmcli con add con-name $2 type ethernet ifname $2 ipv4.addr 192.168.180.1/24 ipv4.method manual
nmcli con up $2
sudo ./bridge-setup.sh eno1 enp0s20u12u2i1
If there are multiple USB network cards, you can configure the bridge function with the USB network card name as a parameter according to actual needs.
sudo ./bridge-clean.sh eno1 enp0s20u12u2i1
Precautions:
*1. Calculation** In the DHCP mode, if there is an abnormality in obtaining the address, please execute *
sudo rm /var/lib/dhclient/dhclient.leases
Delete the record, and then restart the Compute Stick.
2. If the NAT or bridge configuration of the host computer fails and the computing stick cannot be connected to the Internet, please find a host computer with a newly installed system to configure the NAT or bridge to avoid the failure of the NAT or bridge configuration due to the unclean system of the host computer.
RK1808 artificial intelligence computing stick can share the network by configuring the NAT function and bridging function of the Windows host computer to realize computing stick networking. It is recommended to use NAT.
Note: If the Windows 10 system may not have the "Local Connection 2" option, please change to another Windows 10 computer and re-configure.
The calculation stick needs to turn on DHCP. Refer to point 8 of the main function introduction on the WEB page to set it.
Open "Control Panel" -> "Network and Sharing Center" and enter "Change Adapter Configuration".
Among them, "local connection" is the local network card, and "local connection 2" is the computing stick network card.
Open the command prompt window with administrator privileges. For example, the IP address of the computing stick is 192.168.180.8, and enter "route ADD 192.168.180.8 MASK 255.255.255.255 192.168.180.8 IF 51" to add routing information.
If the PC is not connected to the external network to configure the bridge, you need to configure the bridge interface to a static address: 192.168.180.1.
Precautions:
If the nat or bridge configuration of the host computer fails, and the computing stick cannot be connected to the Internet, please find a host computer with a newly installed system to configure the nat or bridge to avoid the nat or bridge configuration failure due to the dirty system of the host computer.
Open "System Preference" and select "Network".
Select RK1808S0, configure ip address
sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet6.ip6.forwarding=1
nat on en0 from en6:network to any -> (en0)
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
nat-anchor "toybrick"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
anchor "toybrick"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "toybrick" from "/etc/pf.anchors/toybrick"
sudo pfctl -ef /etc/pf.conf
The calculation stick needs to turn on DHCP. Refer to point 8 of the main function introduction on the WEB page to set it.
Open "System Preference" and select "Network".
Click "Create" to create the bridge configuration, and finally click "Apply" to complete the bridge configuration.
Configure the IP address:
ifconfig *** alias 192.168.180.1
Note: *** refers to the actual Bridge Name
Precautions:
If the nat or bridge configuration of the host computer fails, and the computing stick cannot be connected to the Internet, please find a host computer with a newly installed system to configure the nat or bridge to avoid the nat or bridge configuration failure due to the dirty system of the host computer.
The demonstration device is the Android system of Toybrick TB-RK3399ProD V1.3. The development process of other Android platforms is for reference only.
Note: Android configuration network commands need to root the Android machine. Please make sure that the Android machine correctly obtains root privileges and installs the rndis driver. If you need to run the script on startup, you need to modify the Android source code to re-write the Android firmware according to the standard Android startup process. If you do not set the startup, you need to reset it every time you restart.
The calculation stick needs to turn on DHCP. Refer to point 8 of the main function introduction on the WEB page to set it.
Download the script and download it to the Android device
Configuration script: cfgainetd.sh
Network tool: ethtool
Download link :cfgainetd.zip
Use adb push to push the script to the Android device
adb root && adb remount
adb push cfgainetd.sh /data
adb push ethtool /data
The script file that uses adb push does not have executable permissions. We need to use the chmod command to add executable permissions
E:\master_yolov3_demo>adb shell
rk3399_mid:/ # cd data/
rk3399_mid:/data # ls -la cfgainetd.sh ethtool
-rw-rw-rw- 1 root root 2052 2020-01-02 08:01 cfgainetd.sh
-rw-rw-rw- 1 root root 1369842 2019-12-31 09:42 ethtool
rk3399_mid:/data # chmod a+x cfgainetd.sh ethtool
rk3399_mid:/data # ls -la cfgainetd.sh ethtool
-rwxrwxrwx 1 root root 2052 2020-01-02 08:01 cfgainetd.sh
-rwxrwxrwx 1 root root 1369842 2019-12-31 09:42 ethtool
rk3399_mid:/data #
Insert the RK1808 artificial intelligence computing stick into the Android device. Then execute the script in the background.
E:\master_yolov3_demo>adb shell
rk3399_mid:/ # nohup /data/cfgainetd.sh > /dev/null 2>&1 &
[1] 4180
rk3399_mid:/ #
When the RK1808 artificial intelligence computing stick is inserted and the script is executed normally, you can see through ifconfig that the network card of the RK1808 artificial intelligence computing stick is assigned to ip, and if there is an abnormality, it is not assigned to ip.
Failure conditions:
rk3399_mid:/ # ifconfig -a
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:29981 errors:0 dropped:0 overruns:0 frame:0
TX packets:29981 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:2752109 TX bytes:2752109
eth1 Link encap:Ethernet HWaddr ec:26:ae:2a:b6:e4
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 TX bytes:0
eth0 Link encap:Ethernet HWaddr f2:16:66:a4:5b:0b
inet addr:172.16.9.10 Bcast:172.16.9.255 Mask:255.255.255.0
inet6 addr: fe80::f016:66ff:fea4:5b0b/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1585 errors:0 dropped:0 overruns:0 frame:0
TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:118419 TX bytes:8392
Interrupt:24
rk3399_mid:/ # route //或者 busybox route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.9.0 * 255.255.255.0 U 0 0 0 eth0
rk3399_mid:/ #
The configuration is successful, you can see inet addr:192.168.180.1
130|rk3399_mid:/ # ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:36959 errors:0 dropped:0 overruns:0 frame:0
TX packets:36959 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:3391375 TX bytes:3391375
eth1 Link encap:Ethernet HWaddr ec:26:ae:2a:b6:e4
inet addr:192.168.180.1 Bcast:192.168.180.255 Mask:255.255.255.0
inet6 addr: fe80::ee26:aeff:fe2a:b6e4/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:59 errors:0 dropped:0 overruns:0 frame:0
TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2048 TX bytes:4978
eth0 Link encap:Ethernet HWaddr f2:16:66:a4:5b:0b
inet addr:172.16.9.10 Bcast:172.16.9.255 Mask:255.255.255.0
inet6 addr: fe80::f016:66ff:fea4:5b0b/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1854 errors:0 dropped:0 overruns:0 frame:0
TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:139777 TX bytes:8392
Interrupt:24
rk3399_mid:/ # route //或者 busybox route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.9.0 * 255.255.255.0 U 0 0 0 eth0
192.168.180.0 * 255.255.255.0 U 0 0 0 eth1
rk3399_mid:/ #
Precautions:
If the nat or bridge configuration of the host computer fails, and the computing stick cannot be connected to the Internet, please find a host computer with a newly installed system to configure the nat or bridge to avoid the nat or bridge configuration failure due to the dirty system of the host computer.
Note: The web of the computing stick is disabled by default. To enable web, you can log in to the computing stick through SSH and modify the configuration file /etc/toybrick.conf under root privileges, setting web=on;
RK1808 artificial intelligence computing stick supports the use of web interface for system configuration. The following describes how to access this configuration interface and the main functions of the interface.
Insert RK1808 artificial intelligence computing stick.
Open the device manager, and in the network adapter module, "Remote NDIS based Internet Sharing Device" will appear.
Note: Some computers will have unrecognized devices. Uninstall the unrecognized devices and wait for the RNDIS driver to be reinstalled.
1.png)
Open "System Preference" and select "Network".
Select RK1808S0 and configure the ip address.
If you forget the password, please click the link below. This operation will not only reset the password, but also restore the computing stick web configuration to the factory settings. Please operate with caution:
In order to protect the model stored in emmc from being illegally copied, some customers need a method of encrypting the model to protect the model. Rockchip provides users with a unified data encryption and decryption interface. The encryption and decryption keys of each device are different. Customers can use this interface to encrypt and decrypt models. Hackers copy the model illegally to other devices and it will not work properly.
To use this function, you need a computing stick to burn the firmware v1.4.1 and above, or use the sudo dnf update command to update
Follow "Wiki Tutorial"-"TB-RK1808S0"-"Configure Compute Stick Network Sharing" to confirm that the Compute Stick can be connected to the Internet normally
ssh toybrick@192.168.180.8 login to the computing stick
sudo dnf install rk-tee-service
vi test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rockchip/rk_tee_service_host.h"
int main(int argc, char *argv[])
{
int test_size = 64*1024+110;
unsigned char *plaint = malloc(test_size);
memset(plaint, 0x11, test_size);
unsigned char *cipher = malloc(test_size);
unsigned int cipher_len = test_size;
unsigned char *plaint2 = malloc(test_size);
unsigned int plaint2_len = test_size;
rk_encrypt_data(plaint, test_size, cipher, &cipher_len);
printf("cipher_len=%d\n", cipher_len);
rk_decrypt_data(cipher, cipher_len, plaint2, &plaint2_len);
printf("plaint2_len=%d\n", plaint2_len);
if (memcmp(plaint, plaint2, plaint2_len) == 0)
printf("success!\n");
else
printf("fail!\n");
}
gcc test.c -o test -lrktee_service
sudo ./test
Online upgrade can upgrade the firmware of the computing stick to the latest version.
First, configure the host computer to connect to the external network according to "Configure Compute Stick Network Sharing", and then insert the computer stick into the USB port of the host computer. After the computer stick is started, there are two ways to perform the calculation stick upgrade:
One way is to log in to the webpage http://192.168.180.8 of the computing stick through the web , and click the Update button on the Update page to upgrade;
Another way is to log in to the computing stick through ssh and execute the sudo dnf update -y command in the shell to upgrade;
After the upgrade is complete, check the software version information on the web page, or check the version information by executing rpm -qa | grep toybrick-server under the shell.
Online upgrade of python wheel pack for rknn toolkit lite:
ssh login computing stick: ssh toybrick@192.168.180.8
, password toybrick;
execute the pip3 upgrade in the following order: (Note: must be under the root user)
sudo su;
pip3 install --upgrade pip;
ln -s /usr/local/bin/pip /usr/bin/pip;
ln -s /usr/local/bin/pip3 /usr/bin/pip3;
ln -s /usr/local/bin/pip3.6 /usr/bin/pip3.6;
exit;
execute pip3 install rknn-toolkit-lite --user --upgrade
in shell. (Note: Must be under the toybrick user)
Note: When the upgrade is unsuccessful, first check whether the computing stick is available through the upper computer network, you can log in to the computing stick with SSH, and execute sudo pingwww.baidu.com on the computing stick to see if you can ping the external network.
Windows needs to install the USB driver first
Downloaddownload burning tool and firmware.
First insert the calculation stick into the PC for 1 minute to confirm that the PC recognizes the calculation stick, and then plug and unplug the calculation stick on the PC for 5 times. Each insertion time is 3 to 8 seconds, and the calculation stick becomes a burnable maskrom state.
Then perform the following programming steps:
Under windows: Double-click to run windows_flash.exe in the windows directory, open the flashing tool, click the execute button, start flashing, and wait for the flashing to complete.
Under Mac: Double-click to run mac_flash.sh.command in the unix directory, and according to the prompt, enter the password for booting, and wait for the programming to be completed.
Under Linux: In the command line, cd unix, then run ./linux_flash.sh, follow the prompts, enter the sudo password, and wait for the programming to be completed.
If the user plugs and unplugs on the PC 5 times, the maskrom state cannot be entered
Users can refer to "wiki--WEB configuration introduction" to set the host network configuration, then windows users open cmd.exe and enter ssh toybrick@192.168.180.8 to log in to the computing stick (win7 needs to install openssh first), linux users enter ssh toybrick on the command line @192.168.180.8 Log in to the computing stick, execute sudo reboot loader on the computing stick to make the computing stick enter the loader mode, and then perform the above burning steps.
note:
1. Flashing firmware is risky. Please be cautious. Please do not cut off the power during the firmware programming process. Please strictly follow the official operation steps. It is forbidden to burn firmware other than the official release.
2. It is recommended to upgrade the firmware online.