Skip to content

Commit

Permalink
Merge pull request #561 from wu-yue-yu/main
Browse files Browse the repository at this point in the history
Lpi4a docs update
  • Loading branch information
Zepan authored Nov 3, 2023
2 parents d1c4591 + 083b668 commit 6c1786a
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 19 deletions.
16 changes: 9 additions & 7 deletions docs/hardware/en/lichee/th1520/lpi4a/10_test_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ update:

| Scene (Static) | Voltage | Current | Power Consumption | Note |
| -------------- | ----- | ----- | ----- | ------------------------------------ |
| Standby | 5.11V | 0.46A | 2.35W | Fan on, fan not turned off in all subsequent tests |
| Single port to network cable | 5.06V | 0.52A | 2.63W | |
| Dual port to network cable | 5.08V | 0.53A | 2.69W | |
| Connecting an HDMI Display | 5.04V | 0.53A | 2.67W | |
| Standby | 12V | 0.3A | 3.6W | No peripheral connected |
| Standby | 12V | 0.32A | 3.84W | Fan on, fan not turned off in all subsequent tests |
| Single port to network cable | 12V | 0.36A | 4.32W | |
| Dual port to network cable | 12V | 0.39A | 4.68W | |
| Connecting an HDMI Display | 12V | 0.33A | 3.96W | |

### Dynamic Power Consumption

| Scene (Dynamic) | Voltage | Current | Power Consumption | Note |
| -------------------------- | ----- | ----- | ----- | ----------------------------------- |
| Standby | 5.04V | 0.71A | 3.58W | Connecting a monitor, keyboard, and mouse Using a network port |
| STRESS-NG Pressure testing <br>(CPU matrix operations) | 4.95V | 1.22A | 6.04W | CPU frequency limit 1.845GHz, voltage 1V |
| Play video in browser | 4.96V | 1.06A | 5.26W | Using GPU, no hardware decoding, firefox browser |
| NPU Calculate | 12V | 0.39A | 4.68W | Connecting serial port, fan, NPU frequency upper limit 0.792GHz |
| Standby | 12V | 0.43A | 5.16W | Connecting a monitor, keyboard, and mouse Using a network port |
| STRESS-NG Pressure testing <br>(CPU matrix operations) | 12V | 0.65A | 7.8W | CPU frequency limit 1.845GHz, voltage 1V |
| Play video in browser | 12V | 0.6A | 7.2W | Using GPU, no hardware decoding, chromium browser |

## eMMC

Expand Down
10 changes: 10 additions & 0 deletions docs/hardware/en/lichee/th1520/lpi4a/12_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: FAQ
keywords: Linux, Lichee, TH1520, SBC, RISCV, Debian, Desktop
update:
- date: 2023-10-30
version: v1.2
author: ztd
content:
- Update official development docs.
- date: 2023-10-23
version: v1.1
author: ztd
Expand Down Expand Up @@ -29,6 +34,7 @@ update:
## Burn image
- When flashing on Windows, please confirm if the driver is installed correctly first. If the driver is installed correctly but there is still no reaction during flashing, try changing the USB cable. Note that the USB cable used must be able to supply power and transmit data, and try not to use the USB ports on the front panel of the PC case when flashing, or the data ports on a laptop, otherwise the device may not be recognized due to power supply issues.
- To switch boot modes, for example to boot from SD card, formal version boards can switch via dip switches (note a dedicated image is needed), beta version boards can also switch by passing boot arguments, see[Board Boot Process](https://en.wiki.sipeed.com/hardware/en/lichee/th1520/lpi4a/4_burn_image.html#Board-Boot-Process).
- After 20231023, large image burning support has been updated. From this version, burning requires using the latest version of fastboot, which can be found in the image collection's [cloud disk link](https://mega.nz/folder/phoQlBTZ#cZeQ3qZ__pDvP94PT3_bGA). The file's name is `burn_tools_support_bigimage.zip`.

## Desktop Usage
- If the icons in the desktop bottom launcher are not working properly, you can manually configure them as desired, or use the following command to restore the default configuration. See [Web Browser](https://en.wiki.sipeed.com/hardware/en/lichee/th1520/lpi4a/5_desktop.html#Web-Browser) for the default configuration.
Expand Down Expand Up @@ -132,3 +138,7 @@ update:
Build sandboxing disabled due to nsjail error.
```
This error can be ignored for now, it does not affect subsequent build steps. To run nsjail, you can try upgrading the kernel version to 5.XX or passing these parameters when starting docker: `--security-opt apparmor=unconfined --security-opt seccomp=unconfined --security-opt systempaths=unconfined` or `--privileged`.

## Development Documentation

The development documentation can be found at [this link](https://dl.sipeed.com/shareURL/LICHEE/licheepi4a/09_Doc).
1 change: 1 addition & 0 deletions docs/hardware/en/lichee/th1520/lpi4a/4_burn_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The following burning method takes Debian single-screen image `LPI4A_20230721.zi
### Get the burning tool
The burning tool can be obtained from the Mega cloud disk and is found in the `burn_tool.zip` file.
After decompresseion the fastboot binary is found in the win/linux/mac subfolders.
**Note:** Images from 20231023 and later versions have added support for burning large image files, which require using the latest version of fastboot. You can find the latest version of fastboot in the [cloud disk link](https://mega.nz/folder/phoQlBTZ#cZeQ3qZ__pDvP94PT3_bGA). The file name is `burn_tools_support_bigimage.zip`.

## How to enter burning mode

Expand Down
14 changes: 13 additions & 1 deletion docs/hardware/en/lichee/th1520/lpi4a/5_desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,19 @@ sudo apt install firefox ffmpeg

## Media Player

There are some open source players built into the system, and we recommend using VLC Player as the video player:
There are some open source players built in the system. The default player is Parole, which supports playing 4K videos. The effect of playing 4K videos with Parole is as follows:

![4k_video_play](./../../../../zh/lichee/th1520/lpi4a/assets/desktop/4k_video_play.png)

Also supports kodi, using the effect as follows:

![kodi_homepage](./../../../../zh/lichee/th1520/lpi4a/assets/desktop/kodi_homepage.png)

![kodi_iconmenu](./../../../../zh/lichee/th1520/lpi4a/assets/desktop/kodi_iconmenu.png)

![kodi_settings](./../../../../zh/lichee/th1520/lpi4a/assets/desktop/kodi_settings.png)

In addition, also preinstalled VLC Player player:

![player](./../../../../zh/lichee/th1520/lpi4a/assets/desktop/player.png)

Expand Down
70 changes: 69 additions & 1 deletion docs/hardware/en/lichee/th1520/lpi4a/6_peripheral.md
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ When playing video with Chromium browser, the state of GPU is as follows:
## NPU
> **Note**: To use the NPU driver, you need to upgrade to the [20230920](https://mega.nz/folder/phoQlBTZ#cZeQ3qZ__pDvP94PT3_bGA) version image, this image will automatically load NPU related drivers on boot.
> **Note**: To use the NPU driver, you need to upgrade to the [20230920](https://mega.nz/folder/phoQlBTZ#cZeQ3qZ__pDvP94PT3_bGA) or newer version image, this image will automatically load NPU related drivers on boot.
LicheePi4A contains a 1GHz NPU supporting 4TOPS@INT8 general purpose NNA computing power. The Wiki contains examples of NPU support as follows:
Expand All @@ -889,6 +889,67 @@ In order to cross-compile the models in the above examples into executables on L
### Installation
**LPi4A setup**
#### SHL Library Installation
To install the SHL library, you can use pip:
```shell
pip3 install shl-python
```
After the installation, you can use the `--whereis` option to check the installation location. For example:
```shell
python3 -m shl --whereis th1520
# Replace with
# python3 -m shl --whereis c920
# if using CPU inference only
```
Based on the printed location, copy the dynamic library files from that directory to the `/usr/lib` directory. For example, if the printed location is:
```shell
/home/sipeed/ort/lib/python3.11/site-packages/shl/install_nn2/th1520
```
You can use the following copy command:
```shell
sudo cp /home/sipeed/ort/lib/python3.11/site-packages/shl/install_nn2/th1520/lib/* /usr/lib/
```
#### Python Virtual Environment
Before installing the Python package, you need to set up a Python virtual environment. Use the following commands to install the `venv` package for creating a Python virtual environment (here, creating a Python virtual environment in the root directory):
```shell
sudo -i
apt install python3.11-venv
cd /root
python3 -m venv ort
source /root/ort/bin/activate
```
#### HHB-onnxruntime Installation
HHB-onnxruntime is a ported backend (execution providers) for SHL, enabling onnxruntime to reuse the high-performance optimization code for XuanTie CPUs.
For CPU version:
```shell
wget https://github.com/zhangwm-pt/onnxruntime/releases/download/riscv_whl_v2.6.0/hhb_onnxruntime_c920-2.6.0-cp311-cp311-linux_riscv64.whl
pip install hhb_onnxruntime_c920-2.6.0-cp311-cp311-linux_riscv64.whl
```
For NPU version:
```shell
wget https://github.com/zhangwm-pt/onnxruntime/releases/download/riscv_whl_v2.6.0/hhb_onnxruntime_th1520-2.6.0-cp311-cp311-linux_riscv64.whl
pip install hhb_onnxruntime_th1520-2.6.0-cp311-cp311-linux_riscv64.whl
```
**x86 Hosts setup**
First, we need to install Docker on our own computer. Uninstall any existing Docker version:
```shell
sudo apt-get remove docker docker-engine docker.io containerd runc
Expand Down Expand Up @@ -929,9 +990,16 @@ Once you are in the Docker image, you need to configure the cross-compile enviro
export PATH=/tools/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-light.1/bin/:$PATH
```
clone NPU example code:
```shell
git clone https://github.com/zhangwm-pt/lpi4a-example.git
```
At this point, the HHB environment is preliminarily built. You can try the following NPU examples:
[Mobilenetv2 for image classification](https://wiki.sipeed.com/hardware/eh/lichee/th1520/lpi4a/8_application.html#MobilenertV2)
[YOLOv5 for object detection](https://wiki.sipeed.com/hardware/eh/lichee/th1520/lpi4a/8_application.html#Yolov5n)
For further infomation please check [hhb-tools doc](https://www.yuque.com/za4k4z).
## Other
Contributions are welcome~ You can get ¥5~150 ($1~20) coupon if your contribution is accepted!
16 changes: 9 additions & 7 deletions docs/hardware/zh/lichee/th1520/lpi4a/10_test_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ update:

| 场景(静态) | 电压 | 电流 | 功耗 | 备注 |
| -------------- | ----- | ----- | ----- | ------------------------------------ |
| 待机 | 5.11V | 0.46A | 2.35W | 开启风扇,后续所有测试中风扇均不关闭 |
| 单网口连接网线 | 5.06V | 0.52A | 2.63W | |
| 双网口连接网线 | 5.08V | 0.53A | 2.69W | |
| 连接 HDMI 显示器 | 5.04V | 0.53A | 2.67W | |
| 待机 | 12V | 0.3A | 3.6W | 不接任何外设 |
| 待机 | 12V | 0.32A | 3.84W | 开启风扇,后续所有测试中风扇均不关闭 |
| 单网口连接网线 | 12V | 0.36A | 4.32W | |
| 双网口连接网线 | 12V | 0.39A | 4.68W | |
| 连接 HDMI 显示器 | 12V | 0.33A | 3.96W | |

### 动态功耗

| 场景(动态) | 电压 | 电流 | 功耗 | 备注 |
| -------------------------- | ----- | ----- | ----- | ----------------------------------- |
| 待机 | 5.04V | 0.71A | 3.58W | 连接显示器、键盘、鼠标 使用一个网口 |
| STRESS-NG 压测<br>( CPU 矩阵运算) | 4.95V | 1.22A | 6.04W | CPU 频率上限 1.845GHz,电压 1V |
| 浏览器播放视频 | 4.96V | 1.06A | 5.26W | 使用 GPU、无硬件解码, firefox 浏览器 |
| NPU运算 | 12V | 0.39A | 4.68W | 仅连接串口、风扇,NPU 频率上限 0.792GHz |
| 待机 | 12V | 0.43A | 5.16W | 连接HDMI显示器、键盘、鼠标 使用一个网口 |
| STRESS-NG 压测<br>( CPU 矩阵运算) | 12V | 0.65A | 7.8W | CPU 频率上限 1.845GHz,电压 1V |
| 浏览器播放视频 | 12V | 0.6A | 7.2W | 使用 GPU、无硬件解码, chromium 浏览器 |

## eMMC

Expand Down
10 changes: 10 additions & 0 deletions docs/hardware/zh/lichee/th1520/lpi4a/12_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: 常见问题
keywords: Linux, Lichee, TH1520, SBC, RISCV, Debian, Desktop
update:
- date: 2023-10-30
version: v1.2
author: ztd
content:
- Update official development docs.
- date: 2023-10-23
version: v1.1
author: ztd
Expand Down Expand Up @@ -29,6 +34,7 @@ update:
## 烧录镜像
- Windows系统下烧录,请先确认驱动是否按照正确安装。若正确安装驱动,烧录时还是没有反应,可尝试更换 USB 线,注意使用的 USB 线必须是能供电和传输数据的线,并且烧录时使用的 USB 口尽量不要使用主机前面板的 USB 口,也不要使用笔记本电脑中的数据口,否则会因为供电原因导致识别不到设备。
- 想要切换启动模式,比如切换为从 SD 卡启动,正式版底板可以通过拨码开关(注意需要制作专用镜像)来切换,非正式版也可以通过传递启动参数来切换,详见[烧录镜像的对应章节](https://wiki.sipeed.com/hardware/zh/lichee/th1520/lpi4a/4_burn_image.html#U-Boot)
- 20231023后更新了大镜像烧录支持,从该版本起,烧录需要使用最新版本的 fastboot,可以在镜像集合的[网盘链接](https://pan.baidu.com/e/1xH56ZlewB6UOMlke5BrKWQ)中找到,文件名为 `burn_tools_support_bigimage.zip`

## 桌面系统基础使用
- 若桌面下方启动器的图标功能异常,可以自己手动配置为自己想要的方案,也可以使用如下命令恢复为默认配置,默认配置效果参考[桌面系统基础使用相关章节](https://wiki.sipeed.com/hardware/zh/lichee/th1520/lpi4a/5_desktop.html#%E6%B5%8F%E8%A7%88%E5%99%A8)
Expand Down Expand Up @@ -137,3 +143,7 @@ update:
Build sandboxing disabled due to nsjail error.
```
这个报错可以暂时忽略,不影响后面的编译步骤。若想运行 nsjail,可以尝试升级内核版本至5.XX或者启动 docker 时传入这些参数 `--security-opt apparmor=unconfined --security-opt seccomp=unconfined --security-opt systempaths=unconfined` 或 `--privileged`。

## 开发文档

请在[该链接](https://dl.sipeed.com/shareURL/LICHEE/licheepi4a/09_Doc)中下载。
1 change: 1 addition & 0 deletions docs/hardware/zh/lichee/th1520/lpi4a/4_burn_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ update:
### 获取烧录工具

在镜像集合的网盘内可以获得 `burn_tool.zip`, 解压可得 win/linux/mac 三个系统下的 fastboot 烧录工具。
**注意:**20231023及之后版本的镜像,添加了大镜像文件烧录支持,需要配合最新版本的 fastboot 使用,最新版本的 fastboot 可以在[网盘链接](https://pan.baidu.com/e/1xH56ZlewB6UOMlke5BrKWQ)中找到,文件名为`burn_tools_support_bigimage.zip`

## 进入烧录模式

Expand Down
14 changes: 13 additions & 1 deletion docs/hardware/zh/lichee/th1520/lpi4a/5_desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,19 @@ sudo apt install firefox ffmpeg
## 播放器
系统内置了一些开源播放器,我们建议使用 VLC Player 作为视频播放器:
系统内置了一些开源播放器,默认使用的播放器是支持播放 4K 视频的 Parole,使用 Parole 播放 4K 视频的效果如下:
![4k_video_play](./assets/desktop/4k_video_play.png)
同时还支持 kodi,使用效果如下:
![kodi_homepage](./assets/desktop/kodi_homepage.png)
![kodi_iconmenu](./assets/desktop/kodi_iconmenu.png)
![kodi_settings](./assets/desktop/kodi_settings.png)
此外,还预装了 VLC Player 播放器:
![player](./assets/desktop/player.png)
Expand Down
67 changes: 65 additions & 2 deletions docs/hardware/zh/lichee/th1520/lpi4a/6_peripheral.md
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ sudo watch cat /sys/kernel/debug/pvr/status
## NPU
> **注意**:使用 NPU 驱动,需要升级到[20230920](https://pan.baidu.com/e/1xH56ZlewB6UOMlke5BrKWQ)版本镜像,该镜像开机会自动加载 NPU 相关驱动。
> **注意**:使用 NPU 驱动,需要使用[20230920](https://pan.baidu.com/e/1xH56ZlewB6UOMlke5BrKWQ)以上版本镜像,该镜像开机会自动加载 NPU 相关驱动。
LicheePi4A 板载了一颗支持 4TOPS@INT8 通用 NNA 算力,主频 1GHz 的 NPU。Wiki 中包含的支持 NPU 的示例如下:
Expand All @@ -872,7 +872,63 @@ LicheePi4A 板载了一颗支持 4TOPS@INT8 通用 NNA 算力,主频 1GHz 的
为了将上述示例中的模型交叉编译为 LicheePi4A 上的可执行程序,我们首先需要在自己的电脑上搭建 HHB 开发环境。
> 推荐环境:ubuntu20.04 系统,Docker 使用20.10.21版本。推荐使用 Docker 镜像来搭建环境。
### 安装
### 环境配置
**开发板配置**
#### SHL 库安装
使用 pip 安装
```shell
pip3 install shl-python
```
安装后,使用 --whereis 查看安装位置
```shell
python3 -m shl --whereis th1520
# 若使用纯 CPU 推理,则替换为 python3 -m shl --whereis c920
```
根据打印的位置,将目录中的动态库复制到 /usr/lib 目录中,比如,打印的是:
```shell
/home/sipeed/ort/lib/python3.11/site-packages/shl/install_nn2/th1520
```
可以使用复制命令:
```shell
sudo cp /home/sipeed/ort/lib/python3.11/site-packages/shl/install_nn2/th1520/lib/* /usr/lib/
```
#### python 虚拟环境
需要先安装 python 虚拟环境,再使用 pip3 安装 python 包。
使用如下命令,安装 venv 包,用于创建python虚拟环境(以在 root 目录中创建 python 虚拟环境为例):
```shell
sudo -i
apt install python3.11-venv
cd /root
python3 -m venv ort
source /root/ort/bin/activate
```
#### HHB-onnxruntime 安装
HHB-onnxuruntime 是移植了 SHL 后端(execution providers),让 onnxruntime 能复用到 SHL 中针对玄铁 CPU 的高性能优化代码。
CPU 版本
```shell
wget https://github.com/zhangwm-pt/onnxruntime/releases/download/riscv_whl_v2.6.0/hhb_onnxruntime_c920-2.6.0-cp311-cp311-linux_riscv64.whl
pip install hhb_onnxruntime_c920-2.6.0-cp311-cp311-linux_riscv64.whl
```
NPU 版本
```shell
wget https://github.com/zhangwm-pt/onnxruntime/releases/download/riscv_whl_v2.6.0/hhb_onnxruntime_th1520-2.6.0-cp311-cp311-linux_riscv64.whl
pip install hhb_onnxruntime_th1520-2.6.0-cp311-cp311-linux_riscv64.whl
```
**x86主机配置**
首先要在自己的电脑上安装 Docker,先卸载可能存在的 Docker 版本:
```shell
sudo apt-get remove docker docker-engine docker.io containerd runc
Expand Down Expand Up @@ -917,10 +973,17 @@ hhb --version
export PATH=/tools/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-light.1/bin/:$PATH
```
clone NPU 示例代码:
```shell
git clone https://github.com/zhangwm-pt/lpi4a-example.git
```
至此,HHB 环境初步搭建完成。可以尝试以下的 NPU 示例:
[Mobilenetv2 做图像分类](https://wiki.sipeed.com/hardware/zh/lichee/th1520/lpi4a/8_application.html#MobilenertV2)
[YOLOv5 做目标检测](https://wiki.sipeed.com/hardware/zh/lichee/th1520/lpi4a/8_application.html#Yolov5n)
NPU 相关 API 等其他信息,请查看[hhb-tools 语雀文档](https://www.yuque.com/za4k4z)。
## 其它
欢迎投稿~ 投稿接受后可得¥5~150($1~20)优惠券!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c1786a

Please sign in to comment.