# raspi5 + Kneron KL520 KL720 config issue
update self ref: (更新正確的資訊)
https://hackmd.io/llrJpGEHSA-lFsulhCaYQQ
## raspberry pi5 install pios bookworm

## lsusb (kl520,kl720)
已經根據上面參考連結內容,在windows裡面更新韌體,然後裝到raspberry pi5中lsusb顯示正確的型號與數量(kl520,kl720)
```
richard@raspberrypi5:~ $ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 32e4:0234 Global Shutter Camera Global Shutter Camera
Bus 003 Device 003: ID 3231:0720 Kneron Kneron KL720
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 3231:0100 Kneron Kneron KL520
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
richard@raspberrypi5:~ $
```
## 建立python環境
```
python -m venv ~/kneron/env
cd ~/kneron
richard@raspberrypi5:~/kneron $ pwd
/home/richard/kneron
richard@raspberrypi5:~/kneron $ ls
env
richard@raspberrypi5:~/kneron $ source env/bin/activate
(env) richard@raspberrypi5:~/kneron $ python --version
Python 3.11.2
(env) richard@raspberrypi5:~/kneron $ pip install kneron_plus/python/package/ubuntu/KneronPLUS-2.3.0-py3-none-any.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./kneron_plus/python/package/ubuntu/KneronPLUS-2.3.0-py3-none-any.whl
Collecting numpy
Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.2/14.2 MB 10.3 MB/s eta 0:00:00
Installing collected packages: numpy, KneronPLUS
Successfully installed KneronPLUS-2.3.0 numpy-1.26.4
(結果報錯)
OSError: /home/richard/kneron/env/lib/python3.11/site-packages/kp/KPBaseClass/../../kp/lib/libusb-1.0.so.0: cannot open shared object file: No such file or directory
pip install kneron_plus/python/package/raspbianpi4/KneronPLUS-2.3.0-py3-none-any.whl
(結果報錯)
OSError: /home/richard/kneron/env/lib/python3.11/site-packages/kp/KPBaseClass/../../kp/lib/libusb-1.0.so.0: wrong ELF class: ELFCLASS32
```

## 選擇安裝 ubuntu/KneronPLUS-2.3.0-py3-none-any.whl並繼續
```
(env) richard@raspberrypi5:~/kneron $ pip install kneron_plus/python/package/ubuntu/KneronPLUS-2.3.0-py3-none-any.whl
# pip install libusb # (這沒用)
```
https://doc.kneron.com/docs/#plus_c/introduction/install_dependency/


```
$ sudo apt install cmake
$ sudo apt install libusb-1.0-0-dev
$ sudo apt install build-essential
cd /home/richard/kneron/kneron_plus
sudo bash install_libusb.sh
```
Note: [Ubuntu][Raspberry Pi] Please update Kneron device USB permission before following steps on Ubuntu. [See the Installation for details.](https://doc.kneron.com/docs/#plus_python/introduction/install_dependency/)

## 嘗試用C語言build (結果成功)


https://doc.kneron.com/docs/#plus_c/getting_started/
```
richard@raspberrypi5:~ $ pwd
/home/richard
richard@raspberrypi5:~ $ cd kneron_plus/
richard@raspberrypi5:~/kneron_plus $ ls
app_lib CMakeLists.txt examples_legacy ex_common include python res thirdparty touch
build examples examples_model_zoo firmware_development install_libusb.sh README.md src tools VERSION
richard@raspberrypi5:~/kneron_plus $ cd build
richard@raspberrypi5:~/kneron_plus/build $ make -j4
...
```
build後的結果
```
richard@raspberrypi5:~/kneron_plus/build $ cd bin
richard@raspberrypi5:~/kneron_plus/build/bin $ ls
connect_devices kl720_demo_customize_inf_multiple_models
DFUT_console kl720_demo_customize_inf_single_model
generic_command kl720_demo_generic_data_inference
kl520_demo_customize_inf_multiple_models kl720_demo_generic_image_inference
kl520_demo_customize_inf_single_model kl720_demo_generic_image_inference_crop
kl520_demo_customize_inf_single_model_debug kl720_demo_generic_image_inference_fifoq_config
kl520_demo_customize_inf_single_model_profile kl720_demo_generic_image_inference_flash_model
kl520_demo_generic_data_inference kl720_demo_generic_image_inference_multithread
kl520_demo_generic_image_inference kl720_demo_generic_image_inference_post_yolo
kl520_demo_generic_image_inference_crop kl720_demo_generic_inference
kl520_demo_generic_image_inference_fifoq_config kl720_demo_generic_inference_bypass_pre_proc
kl520_demo_generic_image_inference_flash_model kl720_demo_generic_inference_crop
kl520_demo_generic_image_inference_multithread kl720_demo_generic_inference_flash_model
kl520_demo_generic_image_inference_post_yolo kl720_demo_generic_inference_multithread
kl520_demo_generic_inference kl720_demo_generic_inference_post_yolo
kl520_demo_generic_inference_bypass_pre_proc kl720_demo_user_define_api
kl520_demo_generic_inference_crop kl720_kn-model-zoo_generic_image_inference_classification
kl520_demo_generic_inference_flash_model kl720_kn-model-zoo_generic_image_inference_post_fcos
kl520_demo_generic_inference_multithread kl720_kn-model-zoo_generic_image_inference_post_yolov5
kl520_demo_generic_inference_post_yolo kl730_demo_customize_inf_multiple_models
kl520_demo_user_define_api kl730_demo_customize_inf_single_model
kl520_kn-model-zoo_generic_image_inference_classification kl730_demo_generic_data_inference
kl520_kn-model-zoo_generic_image_inference_post_fcos kl730_demo_generic_image_inference
kl520_kn-model-zoo_generic_image_inference_post_yolov5 kl730_demo_generic_image_inference_crop
kl630_demo_customize_inf_multiple_models kl730_demo_generic_image_inference_fifoq_config
kl630_demo_customize_inf_single_model kl730_demo_generic_image_inference_flash_model
kl630_demo_generic_data_inference kl730_demo_generic_image_inference_multithread
kl630_demo_generic_image_inference kl730_demo_generic_image_inference_post_yolo
kl630_demo_generic_image_inference_crop kl730_demo_user_define_api
kl630_demo_generic_image_inference_fifoq_config libkapp_yolo.so
kl630_demo_generic_image_inference_flash_model libkplus.so
kl630_demo_generic_image_inference_multithread library
kl630_demo_generic_image_inference_post_yolo scan_devices
kl630_demo_user_define_api
richard@raspberrypi5:~/kneron_plus/build/bin $ ./scan_devices
scanning kneron devices ...
number of Kneron devices found: 2
listing devices infomation as follows:
[0] scan_index: '0'
[0] port ID: '7'
[0] product_id: '0x720' (KL720)
[0] USB link speed: 'High-Speed'
[0] USB port path: '3-1'
[0] kn_number: '0xB9061A4C'
[0] Connectable: 'True'
[0] Firmware: 'KDP2 Comp/F'
[1] scan_index: '1'
[1] port ID: '5'
[1] product_id: '0x100' (KL520)
[1] USB link speed: 'High-Speed'
[1] USB port path: '1-1'
[1] kn_number: '0xC8062934'
[1] Connectable: 'True'
[1] Firmware: 'KDP2 Loader'
richard@raspberrypi5:~/kneron_plus/build/bin $
```
### kl520
```
richard@raspberrypi5:~/kneron_plus/build/bin $ ./kl520_kn-model-zoo_generic_image_inference_post_yolov5 -h
connect device ... OK
upload firmware ... OK
upload model ... OK
read image ... OK
starting inference loop 1 times:
.
inference loop is done
detectable class count : 80
box count : 19
Box 0 (x1, y1, x2, y2, score, class) = 372.0, 351.0, 508.0, 750.0, 0.813594, 0
Box 1 (x1, y1, x2, y2, score, class) = 744.0, 67.0, 796.0, 200.0, 0.545809, 0
Box 2 (x1, y1, x2, y2, score, class) = 86.0, 32.0, 134.0, 77.0, 0.286376, 0
Box 3 (x1, y1, x2, y2, score, class) = 375.0, 520.0, 479.0, 767.0, 0.522091, 1
Box 4 (x1, y1, x2, y2, score, class) = 457.0, 149.0, 721.0, 345.0, 0.787428, 2
Box 5 (x1, y1, x2, y2, score, class) = 137.0, 160.0, 476.0, 436.0, 0.784818, 2
Box 6 (x1, y1, x2, y2, score, class) = 706.0, 188.0, 796.0, 492.0, 0.732149, 2
Box 7 (x1, y1, x2, y2, score, class) = 84.0, 118.0, 301.0, 314.0, 0.727577, 2
Box 8 (x1, y1, x2, y2, score, class) = 172.0, 3.0, 318.0, 95.0, 0.708510, 2
Box 9 (x1, y1, x2, y2, score, class) = 427.0, 113.0, 624.0, 238.0, 0.677018, 2
Box 10 (x1, y1, x2, y2, score, class) = 237.0, 44.0, 401.0, 162.0, 0.637863, 2
Box 11 (x1, y1, x2, y2, score, class) = 32.0, 80.0, 177.0, 276.0, 0.604174, 2
Box 12 (x1, y1, x2, y2, score, class) = 0.0, 52.0, 35.0, 156.0, 0.522445, 2
Box 13 (x1, y1, x2, y2, score, class) = 23.0, 79.0, 131.0, 212.0, 0.265722, 2
Box 14 (x1, y1, x2, y2, score, class) = 326.0, 7.0, 454.0, 140.0, 0.223205, 2
Box 15 (x1, y1, x2, y2, score, class) = 320.0, 3.0, 449.0, 142.0, 0.304492, 7
Box 16 (x1, y1, x2, y2, score, class) = 240.0, 43.0, 400.0, 162.0, 0.227759, 7
Box 17 (x1, y1, x2, y2, score, class) = 166.0, 0.0, 320.0, 99.0, 0.212633, 7
Box 18 (x1, y1, x2, y2, score, class) = 0.0, 636.0, 61.0, 686.0, 0.351036, 8
output bounding boxes on 'output_one_bike_many_cars_800x800.bmp'
```

### kl720
```
richard@raspberrypi5:~/kneron_plus/build/bin $ ./kl720_kn-model-zoo_generic_image_inference_post_yolov5
[warning] device is not run at super speed.
connect device ... OK
upload model ... OK
read image ... OK
starting inference loop 1 times:
.
inference loop is done
detectable class count : 80
box count : 18
Box 0 (x1, y1, x2, y2, score, class) = 371.0, 354.0, 510.0, 747.0, 0.805185, 0
Box 1 (x1, y1, x2, y2, score, class) = 742.0, 60.0, 794.0, 211.0, 0.515536, 0
Box 2 (x1, y1, x2, y2, score, class) = 87.0, 31.0, 135.0, 76.0, 0.265722, 0
Box 3 (x1, y1, x2, y2, score, class) = 89.0, 189.0, 121.0, 300.0, 0.208385, 0
Box 4 (x1, y1, x2, y2, score, class) = 373.0, 516.0, 480.0, 763.0, 0.528667, 1
Box 5 (x1, y1, x2, y2, score, class) = 139.0, 146.0, 474.0, 449.0, 0.805632, 2
Box 6 (x1, y1, x2, y2, score, class) = 458.0, 149.0, 719.0, 346.0, 0.762070, 2
Box 7 (x1, y1, x2, y2, score, class) = 173.0, 2.0, 319.0, 94.0, 0.731227, 2
Box 8 (x1, y1, x2, y2, score, class) = 706.0, 186.0, 799.0, 489.0, 0.726494, 2
Box 9 (x1, y1, x2, y2, score, class) = 95.0, 117.0, 290.0, 315.0, 0.717568, 2
Box 10 (x1, y1, x2, y2, score, class) = 244.0, 44.0, 407.0, 163.0, 0.661910, 2
Box 11 (x1, y1, x2, y2, score, class) = 428.0, 115.0, 623.0, 233.0, 0.656740, 2
Box 12 (x1, y1, x2, y2, score, class) = 37.0, 79.0, 175.0, 277.0, 0.581318, 2
Box 13 (x1, y1, x2, y2, score, class) = 0.0, 53.0, 33.0, 156.0, 0.493920, 2
Box 14 (x1, y1, x2, y2, score, class) = 24.0, 79.0, 132.0, 212.0, 0.245957, 2
Box 15 (x1, y1, x2, y2, score, class) = 319.0, 0.0, 449.0, 152.0, 0.303165, 7
Box 16 (x1, y1, x2, y2, score, class) = 235.0, 43.0, 410.0, 161.0, 0.226067, 7
Box 17 (x1, y1, x2, y2, score, class) = 0.0, 636.0, 62.0, 686.0, 0.206850, 8
output bounding boxes on 'output_one_bike_many_cars_800x800.bmp'
```

## 使用 miniconda
```
richard@raspberrypi5:~ $ uname -a
Linux raspberrypi5 6.6.28+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.28-1+rpt1 (2024-04-22) aarch64 GNU/Linux
cd ~/Downloads
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
bash Miniconda3-latest-Linux-aarch64.sh
nano ~/.bashrc
(文件中添加)
export PATH="/home/richard/miniconda3/bin:$PATH"
source ~/.bashrc
richard@raspberrypi5:~/Downloads $ source ~/.bashrc
richard@raspberrypi5:~/Downloads $ conda
usage: conda [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda is a tool for managing and deploying applications, environments and packages.
options:
-h, --help Show this help message and exit.
-v, --verbose Can be used multiple times. Once for detailed output,
twice for INFO logging, thrice for DEBUG logging, four
times for TRACE logging.
--no-plugins Disable all plugins that are not built into conda.
-V, --version Show the conda version number and exit.
```
## 建立python環境
```
conda create --name kneron_py39 python=3.9
conda init --all
conda activate kneron_py39
pip install opencv-python
```
## kp/lib/libusb-1.0.so.0: cannot open shared issue
```
# 檢查 raspi version
richard@raspberrypi5:~ $ uname -a
Linux raspberrypi5 6.6.20+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux
# 下載 miniconda
https://docs.anaconda.com/free/miniconda/
sudo /bin/bash Miniconda3-latest-Linux-aarch64.sh
# 初始化 conda
./conda init
# 建立環境
conda create --name kneron python=3.9
# 先更新 pip
python -m pip install --upgrade pip
(kneron) richard@raspberrypi5:~/kneron_plus/python/package/ubuntu $ pwd
/home/richard/kneron_plus/python/package/ubuntu
(kneron) richard@raspberrypi5:~/kneron_plus/python/package/ubuntu $ ls
KneronPLUS-2.3.0-py3-none-any.whl
(kneron) richard@raspberrypi5:~/kneron_plus/python/package/ubuntu $ pip install KneronPLUS-2.3.0-py3-none-any.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./KneronPLUS-2.3.0-py3-none-any.whl
Collecting numpy (from KneronPLUS==2.3.0)
Downloading numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB)
???????????????????????????????????????? 62.3/62.3 kB 853.8 kB/s eta 0:00:00
Downloading numpy-1.26.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.2 MB)
???????????????????????????????????????? 14.2/14.2 MB 9.0 MB/s eta 0:00:00
Installing collected packages: numpy, KneronPLUS
Successfully installed KneronPLUS-2.3.0 numpy-1.26.4
```

## install kp/lib/libusb-1.0.so.0
```
(kneron) richard@raspberrypi5:~/kneron_plus/python $ pwd
/home/richard/kneron_plus/python
(kneron) richard@raspberrypi5:~/kneron_plus/python $ ls
example example_legacy example_model_zoo install_libusb.sh package
(kneron) richard@raspberrypi5:~/kneron_plus/python $ sudo bash ./install_libusb.sh
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libraspberrypi0 libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libusb-1.0-doc
The following NEW packages will be installed:
libusb-1.0-0-dev libusb-1.0-doc
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 276 kB of archives.
After this operation, 1,965 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bookworm/main arm64 libusb-1.0-0-dev arm64 2:1.0.26-1 [83.0 kB]
Get:2 http://deb.debian.org/debian bookworm/main arm64 libusb-1.0-doc all 2:1.0.26-1 [193 kB]
Fetched 276 kB in 0s (845 kB/s)
Selecting previously unselected package libusb-1.0-0-dev:arm64.
(Reading database ... 147649 files and directories currently installed.)
Preparing to unpack .../libusb-1.0-0-dev_2%3a1.0.26-1_arm64.deb ...
Unpacking libusb-1.0-0-dev:arm64 (2:1.0.26-1) ...
Selecting previously unselected package libusb-1.0-doc.
Preparing to unpack .../libusb-1.0-doc_2%3a1.0.26-1_all.deb ...
Unpacking libusb-1.0-doc (2:1.0.26-1) ...
Setting up libusb-1.0-doc (2:1.0.26-1) ...
Setting up libusb-1.0-0-dev:arm64 (2:1.0.26-1) ...
```
## issue
```
(kneron) richard@raspberrypi5:~/kneron_plus/python $ python
Python 3.9.19 (main, May 6 2024, 19:46:57)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import kp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/__init__.py", line 5, in <module>
from .KP import *
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KP.py", line 6, in <module>
from .Legacy import V1 as v1
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/Legacy/V1/__init__.py", line 5, in <module>
from .KP import *
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/Legacy/V1/KP.py", line 5, in <module>
from .KPInference import KPInference as inference
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/Legacy/V1/KPInference.py", line 6, in <module>
from .KPValue import \
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/Legacy/V1/KPValue.py", line 16, in <module>
from ...KPValue import \
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPValue.py", line 6, in <module>
from .KPWrapperUtils import KPWrapperUtils as wrapper_utils
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPWrapperUtils.py", line 10, in <module>
class KPWrapperUtils:
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPWrapperUtils.py", line 11, in KPWrapperUtils
__KP_WRAPPER = KPWrapper()
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPBaseClass/WrapperBase.py", line 16, in __call__
instance = super(Singleton, cls).__call__(*args, **kwargs)
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPWrapper.py", line 34, in __init__
super(KPWrapper, self).__init__(lib_loader=KPLibLoader())
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPBaseClass/WrapperBase.py", line 25, in __init__
self._load_libKP()
File "/home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPBaseClass/WrapperBase.py", line 33, in _load_libKP
ctypes.CDLL(share_lib, mode=ctypes.RTLD_GLOBAL)
File "/home/richard/.conda/envs/kneron/lib/python3.9/ctypes/__init__.py", line 382, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/richard/.conda/envs/kneron/lib/python3.9/site-packages/kp/KPBaseClass/../../kp/lib/libusb-1.0.so.0: cannot open shared object file: No such file or directory
>>> exit()
```
## python 3.10
```
(kneron_py310) richard@raspberrypi5:~/kneron_plus/python $ pwd
/home/richard/kneron_plus/python
(kneron_py310) richard@raspberrypi5:~/kneron_plus/python $ ls -l
total 20
drwxrwxr-x 3 richard richard 4096 May 7 11:29 example
drwxrwxr-x 2 richard richard 4096 May 7 11:29 example_legacy
drwxrwxr-x 2 richard richard 4096 May 7 11:29 example_model_zoo
-rw-rw-r-- 1 richard richard 1859 May 7 11:29 install_libusb.sh
drwxrwxr-x 6 richard richard 4096 May 7 11:29 package
(kneron_py310) richard@raspberrypi5:~/kneron_plus/python $ sudo bash ./install_libusb.sh
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libusb-1.0-0-dev is already the newest version (2:1.0.26-1).
The following packages were automatically installed and are no longer required:
libraspberrypi0 libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
```

## 原廠資訊
https://www.kneron.com/forum/discussion/445/raspberry-pi5-kneron-plus-2-3-0-python-issue
```
是的,raspberry pi的套件支持pi 4 32-bit。我和同事確認過了,只能請您用C去做開發,不好意思!
```
## 舊的資訊
根據古早教材(y2020)中說明下載host_lib__v0.8,但是官網已經停更,並說明改用PLUS

### Kneron Plus

```
sudo apt install cmake
sudo apt install libusb-1.0-0-dev
sudo apt install build-essential
sudo bash install_libusb.sh
vi /etc/udev/rules.d/10-local.rules
ERNEL=="ttyUSB*",ATTRS{idVendor}=="067b",ATTRS{idProduct}=="2303",MODE="0777",SYMLINK+="kneron_uart"
KERNEL=="ttyUSB*",ATTRS{idVendor}=="1a86",ATTRS{idProduct}=="7523",MODE="0777",SYMLINK+="kneron_pwr"
SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL520",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0100",MODE="0666"
SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720l",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0200",MODE="0666"
SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL720",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0720",MODE="0666"
SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL630",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0630",MODE="0666"
SUBSYSTEM=="usb",ATTRS{product}=="Kneron KL730",ATTRS{idVendor}=="3231",ATTRS{idProduct}=="0732",MODE="0666"
```

Build Code
```
$ cd kneron_plus/
$ mkdir build
$ cd build
$ cmake ..
$ make -j
```
```
richard@raspberrypi5:~/kneron_plus/build $ cmake ..
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_CROSSCOMPILE OFF
-- USB_LIB: []
-- PACK_PYTHON
-- Build for UNIX environment
-- Configuring done
-- Generating done
-- Build files have been written to: /home/richard/kneron_plus/build
richard@raspberrypi5:~/kneron_plus/build $ ls
app_lib bin CMakeCache.txt CMakeFiles cmake_install.cmake examples examples_legacy examples_model_zoo Makefile src tools
richard@raspberrypi5:~/kneron_plus/build $ ls -l
total 108
drwxr-xr-x 4 richard richard 4096 May 10 14:48 app_lib
drwxr-xr-x 3 richard richard 4096 May 10 14:48 bin
-rw-r--r-- 1 richard richard 14212 May 10 14:48 CMakeCache.txt
drwxr-xr-x 5 richard richard 4096 May 10 14:48 CMakeFiles
-rw-r--r-- 1 richard richard 2175 May 10 14:48 cmake_install.cmake
drwxr-xr-x 53 richard richard 4096 May 10 14:48 examples
drwxr-xr-x 17 richard richard 4096 May 10 14:48 examples_legacy
drwxr-xr-x 9 richard richard 4096 May 10 14:48 examples_model_zoo
-rw-r--r-- 1 richard richard 56766 May 10 14:48 Makefile
drwxr-xr-x 3 richard richard 4096 May 10 14:48 src
drwxr-xr-x 4 richard richard 4096 May 10 14:48 tools
richard@raspberrypi5:~/kneron_plus/build $
```
```
richard@raspberrypi5:~/kneron_plus/build/bin $ sudo ./scan_devices
scanning kneron devices ...
number of Kneron devices found: 1
listing devices infomation as follows:
[0] scan_index: '0'
[0] port ID: '7'
[0] product_id: '0x100' (KL520)
[0] USB link speed: 'High-Speed'
[0] USB port path: '3-1'
[0] kn_number: '0x 0' (invalid)
[0] Connectable: 'True'
[0] Firmware: 'KDP'
richard@raspberrypi5:~/kneron_plus/build/bin $
```
其中 [0] kn_number: '0x 0' (invalid)
那個是Key, 綁定AI model 用,需用DFUT 工具更新
(在 windows 做比較容易)
```
richard@raspberrypi5:~/kneron_plus $ cd build/
richard@raspberrypi5:~/kneron_plus/build $ sudo ./bin/scan_devices
scanning kneron devices ...
number of Kneron devices found: 1
listing devices infomation as follows:
[0] scan_index: '0'
[0] port ID: '7'
[0] product_id: '0x100' (KL520)
[0] USB link speed: 'High-Speed'
[0] USB port path: '3-1'
[0] kn_number: '0xC8062934'
[0] Connectable: 'True'
[0] Firmware: 'KDP2 Loader'
richard@raspberrypi5:~/kneron_plus/build $
```
### Kneron_DFUT
結果還是要安裝Kneron_DFUT_ubuntu_2.3.0因為要指定port id
雖然是raspi 但是要用Kneron_DFUT_ubuntu
https://doc.kneron.com/docs/#plus_c/introduction/upgrade_ai_device_to_kdp2/#2-download-kneron-dfut