2023/5/22

esp32s3 eye : led control

esp32-s3-eye 的 led 接在 GPIO3:


esp-idf 的 example 都是 esp32s3-devkit 的,所以 led 控制的 gpio 都不對。
所以要改成 gpio3

以 esp-idf 的 example : blink,要
idf.py menuconfig
Example Configuration --->
    Blink LED type (GPIO)
(3) Blink GPIO number
這樣build 完,燒錄到 eye 上,就可以看到 camera 旁邊的 綠色 led 一秒的間隔亮滅。

如果是 esp-matter 的 example : lighting-app。
一樣,用 menuconfig,改
Demo ---->
   LED type (GPIO)
(3) LED GPIO number
這樣build 完,綠色led 才可以用 chip-tool 控制亮滅。

2023/5/16

usbip -- usb over ip

usb over ip 在 linux 上已經進入 kernel 了(?)。
所以安裝 ap 層就可以。 叫做 usbip

在 ubuntu ,是包含在 linux-tools-common
apt install 後,就會多出 usbip, usbipd 等 usbip 的 command

2023/5/12

esp32 matter, and chip-tool

ref: 其中的這一篇 好像是 pc 端的 tool。
說明如何經由 ble 和 matter device 連線,並且把他註冊到? 的步驟。

照著 espressif for matter 的 install 會出現 Error: -- 感覺好麻煩...
結果都是因為 shallow 的關係,用
..

蠻混亂的,說明都只有一部分。
參考這一篇,是 connectedhomeip github 上的。

以 lighting-app 為例,要在原始 source code 位置 build,不能像m hello-world 一樣 copy 出來。

開機 log 中有:
I (1860) chip[DIS]: Advertise commission parameter vendorID=65521 productID=32768 discriminator=3840/15 cm=1
用 chip-tool command:
./chip-tool pairing ble-wifi 12345 mywifi-ssid mywifi-password 20202021 3840
看 esp32s3 的 log 出現 error:
I (103690) chip[DL]: Confirm received for CHIPoBLE TX characteristic indication (con 1) status= 14 
I (103740) CHIP[DL]: Write request received for CHIPoBLE RX characteristic con 1 12
I (103750) chip[EM]: >>> [E:43723r S:0 M:140331429] (U) Msg RX from 0:4180DA542811AAF9 [0000] --- Type 0000:22 (SecureChannel:PASE_Pake1)
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x42071f58  PS      : 0x00060730  A0      : 0x82077f2b  A1      : 0x3fcc5140  
A2      : 0x3fcc5174  A3      : 0x3fcc5180  A4      : 0x00000020  A5      : 0x3fca3694  
A6      : 0xce016445  A7      : 0x38eff6c3  A8      : 0x159f5221  A9      : 0x3fcc50e0  
A10     : 0xce016445  A11     : 0x3fcc5160  A12     : 0x00000020  A13     : 0x00000020  
A14     : 0x3fcd5d1c  A15     : 0x00000004  SAR     : 0x00000009  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x159f5225  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0x00000000  


Backtrace: 0x42071f55:0x3fcc5140 0x42077f28:0x3fcc5160 0x42077f68:0x3fcc51d0 0x4204d8be:0x3fcc5220 0x4204278b:0x3fcc5250 0x420424c5:0x3fcc5290
0x420426ab:0x3fcc52d0 0x4205ff46:0x3fcc5350 0x42060832:0x3fcc5490 0x420608b7:0x3fcc54b0 0x420485df:0x3fcc54d0 0x42048805:0x3fcc5520 0x420dc243:0x3fcc5540
0x42048c1a:0x3fcc5570 0x4204c279:0x3fcc5640 0x4204c2c9:0x3fcc56d0 0x4204c3a9:0x3fcc5740 0x4205be1b:0x3fcc57b0 0x4205be2c:0x3fcc57f0 0x42063ac5:0x3fcc5810
0x42042045:0x3fcc5850 0x420517bc:0x3fcc5870 0x42050525:0x3fcc58d0 0x4205056c:0x3fcc58f0 0x42050888:0x3fcc5910 0x420508c9:0x3fcc5980 0x403830c5:0x3fcc59a0
ref: brian build 的 lighting-app 沒有 exception 問題,查他的 esp-idf 是 v4.4.2,我的是 latest。
esp-idf 切換版本,之後再 git submodule update --init --recursive
然後記得刪除自己home 下的 ~/.espressif ,不然 install.sh 會有 Error

果然,esp-idf 換成 v4.4.2 後,build esp-matter 的 lighting-app,使用 chip-tool 做 pairing 的時候,就不會出現 exception 了.



感覺很多都是要用 chip-tool (host tool)

2023/5/10

esp32s3,sdk. toolchain and hello-world

也不知道是不是這樣。sdk (framework, library) 跟 toolchain: 結果 build toolchain 就 failed:
 Connecting to isl.gforge.inria.fr (isl.gforge.inria.fr)|128.93.193.15|:80... failed: Connection timed out.
S3 的要看: run 這個,依照你要用的 chip 版本 (以 S3 為例):
./install.sh esp32s3
就會 download 對應的 toolchain (不用自己 build)

一樣,要 access 到 install 的 toolchain,要先
All done! You can now run:

  . ./export.sh
這個 env script 會出現:
Setting IDF_PATH to '/home/charles-chang/esp/esp-idf'
Detecting the Python interpreter
Checking "python" ...
Checking "python3" ...
Python 3.8.10
"python3" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in /home/charles-chang/.espressif/python_env/idf4.3_py3.8_env/bin/python
Checking if Python packages are up to date...
Python requirements from /home/charles-chang/esp/esp-idf/requirements.txt are satisfied.
Added the following directories to PATH:
  /home/charles-chang/esp/esp-idf/components/esptool_py/esptool
  /home/charles-chang/esp/esp-idf/components/espcoredump
  /home/charles-chang/esp/esp-idf/components/partition_table
  /home/charles-chang/esp/esp-idf/components/app_update
  /home/charles-chang/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin
  /home/charles-chang/.espressif/tools/xtensa-esp32s2-elf/esp-2020r3-8.4.0/xtensa-esp32s2-elf/bin
  /home/charles-chang/.espressif/tools/xtensa-esp32s3-elf/esp-2020r3-8.4.0/xtensa-esp32s3-elf/bin
  /home/charles-chang/.espressif/tools/riscv32-esp-elf/1.24.0.123_64eb9ff-8.4.0/riscv32-esp-elf/bin
  /home/charles-chang/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin
  /home/charles-chang/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin
  /home/charles-chang/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/bin
  /home/charles-chang/.espressif/python_env/idf4.3_py3.8_env/bin
  /home/charles-chang/esp/esp-idf/tools
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

依照這個getting start guide. copy hello-world, 要 build 的話...
都是用 idf.py 這個 tool.
idf.py set-target esp32s3
idf.py menuconfig
這個 menuconfig 包含很多東西,例如 bt, wifi, rtos, network-stack...etc
之後,用
idf.py build
build 完就會告訴你燒錄的command.



esp32-s3 的話,要 v4.4 以上才有 support,
ref:

使用 v4.3 的化,idf.py -p /dev/ttyUSB1 flash 會出現 Error:
A fatal error occurred: This chip is ESP32-S3(beta3) not ESP32. Wrong --chip argument?
改用 latest (master) 後,就 OK 了:
~/esp/hello_world$ idf.py -p /dev/ttyUSB1 flash
Executing action: flash
Running ninja in directory /home/charles-chang/esp/hello_world/build
Executing "ninja flash"...
[1/5] cd /home/charles-chang/esp/hello_world/build/esp-idf/esptool_py && /home/charles-chang/.espressif/python_env/idf5.2_py3.8_env/bin/python /home/charles-chang/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 partition --type app /home/charles-chang/esp/hello_world/build/partition_table/partition-table.bin /home/charles-chang/esp/hello_world/build/hello_world.bin
hello_world.bin binary size 0x314a0 bytes. Smallest app partition is 0x100000 bytes. 0xceb60 bytes (81%) free.
[2/5] Performing build step for 'bootloader'
[1/1] cd /home/charles-chang/esp/hello_world/build/bootloader/esp-idf/esptool_py && /home/charles-chang/.espressif/python_env/idf5.2_py3.8_env/bin/python /home/charles-chang/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x0 /home/charles-chang/esp/hello_world/build/bootloader/bootloader.bin
Bootloader binary size 0x5250 bytes. 0x2db0 bytes (36%) free.
[2/3] cd /home/charles-chang/esp/esp-idf/components/esptool_py && /usr/bin/cmake -D IDF_PATH=/home/charles-chang/esp/esp-idf -D "SERIAL_TOOL=/home/charles-chang/.espressif/python_env/idf5.2_py3.8_env/bin/python;;/home/charles-chang/esp/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32s3" -D "SERIAL_TOOL_ARGS=--before=default_reset;--after=hard_reset;write_flash;@flash_args" -D WORKING_DIRECTORY=/home/charles-chang/esp/hello_world/build -P /home/charles-chang/esp/esp-idf/components/esptool_py/run_serial_tool.cmake
esptool esp32s3 -p /dev/ttyUSB1 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x0 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin
esptool.py v4.5.1
Serial port /dev/ttyUSB1
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 34:85:18:98:db:8c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00005fff...
Flash will be erased from 0x00010000 to 0x00041fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 21072 bytes to 13405...
Writing at 0x00000000... (100 %)
Wrote 21072 bytes (13405 compressed) at 0x00000000 in 0.7 seconds (effective 253.4 kbit/s)...
Hash of data verified.
Compressed 201888 bytes to 109664...
Writing at 0x00010000... (14 %)
Writing at 0x0001cc87... (28 %)
Writing at 0x0002271e... (42 %)
Writing at 0x00028d61... (57 %)
Writing at 0x0002f274... (71 %)
Writing at 0x00037197... (85 %)
Writing at 0x0003cd0d... (100 %)
Wrote 201888 bytes (109664 compressed) at 0x00010000 in 2.6 seconds (effective 618.5 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 396.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Done
devkti 上有兩個 microusb port,flash command 的 option,接 UART 時,是 /dev/ttyUSB0,接 USB 時,是 /dev/ttyACM0

燒錄好 hello-world 後,用 picocom -b 115200 /dev/ttyUSB0(ACM0) 就可以看到 hello world console output

燒錄的時候,只要下command 就好,竟然不用按reset...
但是說明有說。如果沒有bootloader,就要手動進入 download mode :
接 UART,按著 BOOT 然後 reset. 如果用 picocom 來看,就會看到:
ESP-ROM:esp32s3-20210327
build: Mar 27 2021
rst:0x1 (POWERON),boot:0x23 (DOWNLOAD(USB/UARTR0))
waiting for download

wifi-ble 測試可以用 blufi,包含android apk 和 esp32 sample code.
是利用手機經由 ble 連線後,設定 wifi ssid/password 的example

Android apk 可以用 AndroidStudio build OK
esp32 sample 一樣,用
idf.py set-target esp32s3
idf.py build
idf.py -p /dev/ttyACM0 flash


要build matter app 的話,先參考: 依照他說的,除了上面的 idf 要裝,還要裝chip environment
猜的,一樣在 ~/esp/ 下:
git clone --recurse-submodules git@github.com:project-chip/connectedhomeip.git