1. 开发板套件
收到聆思CSK6系视觉开发套件,开箱:
开发板资料:https://docs.listenai.com/chips/600X/overview/read_guide
2. Ubuntu 22.04开发环境搭建
环境Ubuntu 22.04:
cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.1 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.1 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy
安装必要工具包:git, wget, curl等
3. 下载开发包
方式有:curl/wget及离线方式,curl方式如下:
curl -o- [https://cdn.iflyos.cn/public/cskTools/lisa-zephyr-install.sh](https://cdn.iflyos.cn/public/cskTools/lisa-zephyr-install.sh) | bash
安装过程中会自动补充其他工具包:
>✔ exec exit >✔ exec exit
环境安装
=> Some housekeeping
HEAD is now at 3e15ca75 Merge branch 'backport/esp\_hosted' into 'milestone/v1.1.1'
=> Completed with GREAT SUCCESS! Try and run command 'lisa info zephyr'
这里把开发包安装到 ~/.listenai
tree -L 1 ~/.listenai/ /home/xxxxx/.listenai/ ├── csk-sdk ├── lisa └── lisa-zephyr 3 directories, 0 files
4. 检查环境
执行lisa info zephyr :
Operating System - #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022, version 5.15.0-52-generic x64
@listenai/lisa - 2.4.5
Account - 未登录或登录已过期
Node.js environment
Node.js - v16.14.0
npm - 8.3.1
yarn - 1.22.19Global environment
git - git version 2.34.1Plugin info
zephyr - 1.6.7 (latest: 1.6.8)Plugin environment
env - csk6
west - West version: v0.14.0
venv - Python 3.9.7
cmake - cmake version 3.21.4
dtc - Version: DTC 1.6.0
gperf - GNU gperf 3.1
mklfs - v1.0.0 (3640bfb)
ninja - 1.10.2
protoc - libprotoc 3.19.1
xz - xz (XZ Utils) 5.2.5
cskburn - v1.18.1 (265)
zephyr-sdk-0.14.2 - arm-zephyr-eabi-gcc (Zephyr SDK 0.14.2) 10.3.0
gcc-arm-none-eabi-10.3 - arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)
jlink-venus - V7.58
ZEPHYR_BASE - /home/xxxxx/.listenai/csk-sdk/zephyr (版本: v1.1.1-alpha.2, commit: 3e15ca75)
PLUGIN_HOME - /home/xxxxx/.listenai/lisa-zephyr
VIRTUAL_ENV - /home/xxxxx/.listenai/lisa-zephyr/venv
ZEPHYR_TOOLCHAIN_VARIANT - zephyr
ZEPHYR_SDK_INSTALL_DIR - /home/xxxxx/.listenai/lisa-zephyr/packages/node_modules/@binary/zephyr-sdk-0.14.2/binary
GNUARMEMB_TOOLCHAIN_PATH - /home/xxxxx/.listenai/lisa-zephyr/packages/node_modules/@binary/gcc-arm-none-eabi-10.3/binary发现 'lisa zep 命令行工具' 有可更新的版本: 1.6.8,是否需要更新(Y/N )?: Y
更新启动...... 开始更新@lisa-plugin/zephyr@1.6.8
⸨#########⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠏ idealTree:lib: timing idealTree:#root Completed in 148392ms
npm WARN deprecated cli-ux@5.6.7: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm WARN deprecated @sentry/apm@5.20.0: Please migrate to @sentry/tracing; see: https://www.npmjs.com/package/@sentry/apmremoved 2 packages, and changed 589 packages in 2h
2 packages are looking for funding
runnpm fund
for details
成功
其中发现新zephyr,升级。若升级过程有失败则重复。
5. App体验之shell
在工作目录下执行 lisa zep create
~/Workspace$ lisa zep create
? 选择sample. (
左右键/空格键
展开文件夹,回车键
确定选择)↓ subsys → console → fs → ipc → [nvs] ↓ shell → [shell_module] → usb
↓ samples
(Move up and down to reveal more choices)
用空格键选中shell_module。
编译:
lisa zep build -b csk6011a_nano
-- west build: building application
[1/218] Preparing syscall dependency handling[2/218] Generating include/generated/version.h
-- Zephyr version: 3.1.0 (/home/xxxxx/.listenai/csk-sdk/zephyr), build: v1.1.1-alpha.2
[208/218] Linking C executable zephyr/zephyr_pre0.elf[212/218] Linking C executable zephyr/zephyr_pre1.elf
[218/218] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age UsedFLASH: 82704 B 16 MB 0.49% SRAM: 17752 B 320 KB 5.42% ITCM: 4612 B 16 KB 28.15% DTCM: 0 GB 16 KB 0.00% PSRAMAP: 0 GB 1 MB 0.00% IDT_LIST: 0 GB 2 KB 0.00%
✔ 构建成功
由DebugUSB/DAPLink USB连接开发板,烧录:
lisa zep flash --runner pyocd
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner pyocd
-- runners.pyocd: Flashing file: /home/xxxxx/Workspace/shell_module/build/zephyr/zephyr.hex
0000641 W [Errno 13] Access denied (insufficient permissions) while trying to interrogate a USB device (VID=0d28 PID=0204). This can probably be remedied with a udev rule. See https://github.com/pyocd/pyOCD/tree/master/udev for help. [pyusb_backend]
这里出错,需要先为USB设备添加udev规则
在 /etc/udev/rules.d 目录下创建一个名为 99-listenai.rules 的文件,在文件中添加以下内容并保存:
KERNEL=="ttyACM[0-9]*",MODE="0666"
KERNEL=="ttyUSB[0-9]*",MODE="0666"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0d28", ATTR{idProduct}=="0204", MODE="0666"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0483", ATTR{idProduct}=="7918", MODE="0666"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="77a1", ATTR{idProduct}=="7919", MODE="0666"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="2fe3", ATTR{idProduct}=="000a", MODE="0666"
再执行
sudo udevadm control --reload-rules && sudo udevadm trigger
烧录成功:
~/Workspace/shell_module$ lisa zep flash --runner pyocd
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner pyocd
-- runners.pyocd: Flashing file: /home/xxxxx/Workspace/shell_module/build/zephyr/zephyr.hex
0000572 I Loading /home/xxxxx/Workspace/shell_module/build/zephyr/zephyr.hex at 0x18000000 [load\_cmd]
[==================================================] 100%
0010714 I Erased 86016 bytes (21 sectors), programmed 82944 bytes (324 pages), skipped 0 bytes (0 pages) at 8.06 kB/s [loader]✔ 结束
在连上DebugUSB/DAPLink USB后,主机可以看到添加了一下新的串口/dev/ttyACM0,这个调试串口:
[ 5128.685666] usb 2-2.4: new full-speed USB device number 8 using xhci_hcd
[ 5128.789195] usb 2-2.4: New USB device found, idVendor=0d28, idProduct=0204, bcdDevice= 1.00
[ 5128.789210] usb 2-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 5128.789216] usb 2-2.4: Product: LISTENAI CSK-6-NanoKit CMSIS-DAP
[ 5128.789220] usb 2-2.4: Manufacturer: Arm
[ 5128.789224] usb 2-2.4: SerialNumber: 0000000200190034540000134e535036a5a5a5a597969908
[ 5128.807593] usb-storage 2-2.4:1.0: USB Mass Storage device detected
[ 5128.808146] scsi host4: usb-storage 2-2.4:1.0
[ 5128.811322] usbhid 2-2.4:1.3: couldn't find an input interrupt endpoint
[ 5128.834696] cdc_acm 2-2.4:1.1: ttyACM0: USB ACM device
[ 5128.834830] usbcore: registered new interface driver cdc_acm
[ 5128.834834] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 5129.838784] scsi 4:0:0:0: Direct-Access MBED VFS 0.1 PQ: 0 ANSI: 2
[ 5129.839506] sd 4:0:0:0: Attached scsi generic sg2 type 0
[ 5129.839842] sd 4:0:0:0: [sdc] 131200 512-byte logical blocks: (67.2 MB/64.1 MiB)
[ 5129.840119] sd 4:0:0:0: [sdc] Write Protect is off
[ 5129.840124] sd 4:0:0:0: [sdc] Mode Sense: 03 00 00 00
[ 5129.840365] sd 4:0:0:0: [sdc] No Caching mode page found
[ 5129.840372] sd 4:0:0:0: [sdc] Assuming drive cache: write through
[ 5129.851109] sdc:
[ 5129.852023] sd 4:0:0:0: [sdc] Attached SCSI removable disk
用串口终端连上开发板:
~/Workspace/shell\_module$ picocom --baud 115200 /dev/ttyACM0
picocom v3.1port is : /dev/ttyACM0
flowcontrol : none
baudrate is : 115200
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
hangup is : no
nolock is : no
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
logfile is : none
initstring : none
exit_after is : not set
exit is : noType [C-a] [C-h] to see available commands
Terminal readyuart:~$ version
Zephyr version 3.1.0
uart:~$ help
Please press the <Tab> button to see all available commands.
You can also use the <Tab> button to prompt or auto-complete all commands or its subcommands.
You can try to call commands with <-h> or <--help> parameter for more information.Shell supports following meta-keys:
Ctrl + (a key from: abcdefklnpuw)
Alt + (a key from: bf)
Please refer to shell documentation for more details.Available commands:
bypass :Bypass shell
clear :Clear screen.
date :Date commands
demo :Demo commands
device :Device commands
devmem :Read/write physical memory"devmem address [width [value]]
dynamic :Demonstrate dynamic command usage.
help :Prints the help message.
history :Command history.
kernel :Kernel commands
log :Commands for controlling logger
log_test :Log test
resize :Console gets terminal screen size or assumes default incase the readout fails. It must be executed after each terminal width change to ensure correct text display.
section_cmd :Demo command using section for subcommand registration
shell :Useful, not Unix-like shell commands.
shell_uart_release :Uninitialize shell instance and release uart, startloopback on uart. Shell instance is reinitialized when 'x' is pressed
stats :Stats commands
version :Show kernel version
uart:~$
6. App体验之视觉AI
开发板支持2种:头肩&首肩识别、人脸识别。
拉取头肩&首肩识别 AI sample:
lisa zep create --from-git https://cloud.listenai.com/zephyr/applications/app_algo_hsd_sample_for_csk6.git
到工作目录。
在使用PC端图像预览工具前,需要将prj.conf中USB数据传输配置 CONFIG_WEBUSB=y 设置为y
编译:
\-- west build: building application \[1/243\] Preparing syscall dependency handling
[2/243] Generating include/generated/version.h
-- Zephyr version: 3.1.0 (/home/xxxxx/Workspace/app_algo_hsd_sample_for_csk6/.sdk/zephyr), build: e32aeccd52a1
[233/243] Linking C executable zephyr/zephyr_pre0.elf[237/243] Linking C executable zephyr/zephyr_pre1.elf
[243/243] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age UsedFLASH: 213112 B 16 MB 1.27% SRAM: 147856 B 320 KB 45.12% ITCM: 5532 B 16 KB 33.76% DTCM: 0 GB 16 KB 0.00% PSRAMAP: 3108136 B 3968 KB 76.49% IDT_LIST: 0 GB 2 KB 0.00%
✔ 构建成功
若编译过程中出现:
prj.conf:41: warning: attempt to assign the value 'y' to the undefined symbol LICAK_MODULES_ALG_HSD
则需要把 west.yml
中声明所需的模块再拉取到目录中:
lisa zep init-app
lisa zep update
烧录应用程序,在连上DebugUSB/DAPLink USB后执行:
lisa zep flash --runner pyocd
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner pyocd
-- runners.pyocd: Flashing file: /home/xxxxx/Workspace/app_algo_hsd_sample_for_csk6/build/zephyr/zephyr.hex
0000741 I Loading /home/xxxxx/Workspace/app_algo_hsd_sample_for_csk6/build/zephyr/zephyr.hex at 0x18000000 [load_cmd]
[==================================================] 100%
0026686 I Erased 217088 bytes (53 sectors), programmed 213248 bytes (833 pages), skipped 0 bytes (0 pages) at 8.10 kB/s [loader]✔ 结束
再烧录资源,出现错误:
lisa zep exec cskburn -s /dev/ttyACM0 -C 6 0x400000 ./resource/cp.bin -b 748800
Partition 1: 0x00400000 (751.35 KB) - ./resource/cp.bin
Waiting for device...
Entering update mode...
Entering update mode...
Entering update mode...
Entering update mode...
ERROR: Failed entering update mode✖ Command failed : cskburn -s /dev/ttyACM0 -C 6 0x400000 ./resource/cp.bin -b 748800
› Error: Command failed : cskburn -s /dev/ttyACM0 -C 6 0x400000 ./resource/cp.bin -b 748800
则必须先退出串口终端程序,重新进行烧录资源,成功:
lisa zep exec cskburn -s /dev/ttyACM0 -C 6 0x400000 ./resource/cp.bin -b 748800
Partition 1: 0x00400000 (751.35 KB) - ./resource/cp.bin
Waiting for device...
Entering update mode...
Detected flash size: 16 MB
Burning partition 1/1... (0x00400000, 751.35 KB)
751.35 KB / 751.35 KB (100.00%)
Finished✔ exec exit
继续烧录另一资源:
lisa zep exec cskburn -s /dev/ttyACM0 -C 6 0x500000 ./resource/res.bin -b 748800
Partition 1: 0x00500000 (2338.53 KB) - ./resource/res.bin
Waiting for device...
Entering update mode...
Detected flash size: 16 MB
Burning partition 1/1... (0x00500000, 2338.53 KB)
2338.53 KB / 2338.53 KB (100.00%)
Finished✔ exec exit
开启串口终端程序,复位开发板:
* Booting Zephyr OS build e32aeccd52a1
- Device name: DVPI
[00:00:03.164,000] <inf> hsd: Setup resource [head_thinker] which in <0x18500060,0xa6ce0>
[00:00:03.164,000] <inf> hsd: Setup resource [gesture_thinker] which in <0x185a6d40,0x135d40>
[00:00:03.322,000] <inf> hsd: fmt: [VYUY] width [640] height [480]
[00:00:03.322,000] <inf> hsd: Alloc video buffer: 921600
[00:00:03.322,000] <inf> hsd: Alloc video buffer: 921600
[00:00:03.322,000] <inf> hsd: Alloc video buffer: 921600
连上csk6 USB,弹出:
或者 kernel输出:
[18394.947885] usb 2-2.1: new full-speed USB device number 12 using xhci\_hcd
[18395.053746] usb 2-2.1: New USB device found, idVendor=2fe3, idProduct=000a, bcdDevice= 3.01
[18395.053758] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[18395.053762] usb 2-2.1: Product: CSK View Finder
[18395.053766] usb 2-2.1: Manufacturer: ZEPHYR
[18395.053769] usb 2-2.1: SerialNumber: 0123456789ABCDEF
下载PC查看工具,
git clone https://cloud.listenai.com/zephyr/applications/csk_view_finder_spd.git
使用 Chrome 内核的浏览器,打开项目 csk_view_finder_spd/src 目录下的 index.html
Connect CSK View Finder 设备。
捕捉:
7. 总结
这里初步体验了CSK6开发板入门和AI能力,后面会继续研究。