0. はじめに
docker: Error response from daemon: error gathering device information while adding custom device "/dev/tty.usbmodem51850109041": no such file or directory↩
コンテナからMacのUSBシリアルにアクセスするために、/dev/tty.usb* をマウントしたいのだが、macOSの仮想デバイスでは それができないようである。仕方ないので、docker cpでホストOSにコピーしてから、write_flashしている。
前回の記事でできなかったことは、どうやら仕様(制約)らしい。
そこで、リモートシリアルポート を使って、同様なことを実現する。
1. ホスト側
ポート番号とシリアルポート(/dev/tty.*)を関連付ける。
( コンテナからの接続を待ち続ける(打ち切る場合はCtrl+C) )
$ esp_rfc2217_server.py -p 4000 /dev/cu.wchusbserial51850109041
INFO: RFC 2217 TCP/IP to Serial redirector - type Ctrl-C / BREAK to quit
INFO: Serving serial port: /dev/cu.wchusbserial51850109041
INFO: TCP/IP port: 4000
INFO: Waiting for connection ...
2. コンテナ側
シリアルポートに、rfc2217://host.docker.internal:4000?ign_set_control を指定する。ポート番号は、ホスト側の指定に合わせる(4000以外も可)。
$ esptool.py --chip auto -b 460800 --port rfc2217://host.docker.internal:4000?ign_set_control chip_id
esptool.py v4.10.0
Serial port rfc2217://host.docker.internal:4000?ign_set_control
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.
Detecting chip type... ESP32-S3
Chip is ESP32-S3 (QFN56) (revision v0.1)
Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
Crystal is 40MHz
MAC: 34:85:18:99:b5:ac
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Warning: ESP32-S3 has no Chip ID. Reading MAC instead.
MAC: 34:85:18:99:b5:ac
Hard resetting via RTS pin...
INFO: Waiting for connection ... use the 'rfc2217://127.0.0.1:4000?ign_set_control' as a PORT
.....INFO: Connected by 127.0.0.1:57864
INFO: Disconnected
.. ^C
# Ctrl-C するまで終わらない
3. 性能
-
chip_id
ホスト直% time esptool.py --chip esp32s3 --port /dev/cu.usbmodem51850109041 chip_id esptool.py v4.10.0 Serial port /dev/cu.usbmodem51850109041 Connecting... Chip is ESP32-S3 (QFN56) (revision v0.1) Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3) Crystal is 40MHz MAC: 34:85:18:99:b5:ac Stub is already running. No upload is necessary. Warning: ESP32-S3 has no Chip ID. Reading MAC instead. MAC: 34:85:18:99:b5:ac Hard resetting via RTS pin... 0.09s user 0.03s system 19% cpu 0.602 totalコンテナにてリモートシリアルポート指定$ time esptool.py --chip esp32s3 --port rfc2217://host.docker.internal:4000?ign_set_control chip_id esptool.py v4.10.0 Serial port rfc2217://host.docker.internal:4000?ign_set_control Connecting... Device PID identification is only supported on COM and /dev/ serial ports. Chip is ESP32-S3 (QFN56) (revision v0.1) Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3) Crystal is 40MHz MAC: 34:85:18:99:b5:ac Stub is already running. No upload is necessary. Warning: ESP32-S3 has no Chip ID. Reading MAC instead. MAC: 34:85:18:99:b5:ac Hard resetting via RTS pin... real 0m18.672s user 0m0.183s sys 0m0.129s
-
write_flash
ホスト直% time esptool.py --chip esp32s3 --port /dev/cu.wchusbserial51850109041 -b 460800 --before default_reset --after no_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3_N16R8_TWAI/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3_N16R8_TWAI/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3_N16R8_TWAI/micropython.bin esptool.py v4.10.0 Serial port /dev/cu.wchusbserial51850109041 Connecting.... Chip is ESP32-S3 (QFN56) (revision v0.1) Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3) Crystal is 40MHz MAC: 34:85:18:99:b5:ac Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Flash will be erased from 0x00000000 to 0x00004fff... Flash will be erased from 0x00008000 to 0x00008fff... Flash will be erased from 0x00010000 to 0x001aefff... SHA digest in image updated Compressed 19072 bytes to 12390... Wrote 19072 bytes (12390 compressed) at 0x00000000 in 0.5 seconds (effective 292.6 kbit/s)... Hash of data verified. Compressed 3072 bytes to 117... Wrote 3072 bytes (117 compressed) at 0x00008000 in 0.1 seconds (effective 491.3 kbit/s)... Hash of data verified. Compressed 1699616 bytes to 1141280... Wrote 1699616 bytes (1141280 compressed) at 0x00010000 in 26.1 seconds (effective 520.3 kbit/s)... Hash of data verified. Leaving... Staying in bootloader. 0.39s user 0.12s system 1% cpu 31.532 totalコンテナにてリモートシリアルポート指定% time esptool.py --chip esp32s3 --port rfc2217://host.docker.internal:4000?ign_set_control -b 460800 --before default_reset --after no_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3_N16R8_TWAI/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3_N16R8_TWAI/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3_N16R8_TWAI/micropython.bin esptool.py v4.10.0 Serial port rfc2217://host.docker.internal:4000?ign_set_control Connecting... Device PID identification is only supported on COM and /dev/ serial ports. . Chip is ESP32-S3 (QFN56) (revision v0.1) Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3) Crystal is 40MHz MAC: 34:85:18:99:b5:ac Uploading stub... Running stub... Stub running... Changing baud rate to 460800 Changed. Configuring flash size... Flash will be erased from 0x00000000 to 0x00004fff... Flash will be erased from 0x00008000 to 0x00008fff... Flash will be erased from 0x00010000 to 0x001aefff... SHA digest in image updated Compressed 19072 bytes to 12390... Wrote 19072 bytes (12390 compressed) at 0x00000000 in 0.9 seconds (effective 165.1 kbit/s)... Hash of data verified. Compressed 3072 bytes to 117... Wrote 3072 bytes (117 compressed) at 0x00008000 in 0.6 seconds (effective 38.7 kbit/s)... Hash of data verified. Compressed 1699616 bytes to 1141280... Wrote 1699616 bytes (1141280 compressed) at 0x00010000 in 48.5 seconds (effective 280.4 kbit/s)... Hash of data verified. Leaving... Staying in bootloader. real 1m21.520s user 0m0.822s sys 0m0.455s
| 機能 | ホスト直 | リモートシリアルポート | 比 |
|---|---|---|---|
| chip_id | 0.602s | 18.672s | 31.02 |
| write_flash | 31.532s | 81.520s | 2.58 |
コンテナからホストのシリアルポートをアクセスするため、当然ながら 処理時間は長い。
対象ファイルをホストにコピーする手間が不要になるメリットを天秤に掛けて、使い分けるとする。
以上