Open4

ESP32 rust on mac

tesshytesshy

brew install rust

# https://github.com/esp-rs/esp-idf-template?tab=readme-ov-file#prerequisites
cargo install cargo-generate
cargo install ldproxy
cargo install espup
cargo install espflash
cargo install cargo-espflash # Optional
cargo generate esp-rs/esp-idf-template cargo

https://github.com/espressif/esp-idf/issues/12127

devcontainer.json

  // "runArgs": [
  //   "--mount",
  //   "type=bind,source=/run/udev,target=/run/udev,readonly"
  // ],

Dev container起動

> remote-containers.rebuildAndReopenInContainer

とりあえずビルド

cargo build

Finished `dev` profile [optimized + debuginfo] target(s) in 2m 39s

できたっぽい

tesshytesshy

メモ: 意味ないっぽい・・・

なんかビルドできる環境とできない環境があってナンジャコレと思って悩んだ結果、どうもarm64環境だとコンテナ内部のPythonがスタックするようで、Dockerfile内部でplatformをlinux/x86_64に固定してしまうことにした。.devcontainer.jsonのrunArgsで--platform=linux/x86_64をやってみたがなんか上手く動かん(原因までは追ってないがImageが無いと怒られる)

FROM debian:${VARIANT}FROM --platform=linux/x86_64 debian:${VARIANT}
tesshytesshy
espup install
cargo build

# espflash動作確認
# C6の場合、--no-stubじゃないとtimeoutするっぽい
espflash board-info -c esp32c6 --no-stub
# フラッシュ
espflash flash --no-stub target/riscv32imac-esp-espidf/debug/tripticon-esp32

通った。これはDocker諦めた方が早い気がしてきた・・・

tesshytesshy

macOSのDockerだと--deviceオプションが使えない(こともなかった気がするけどクソ面倒だった記憶)ので、ホスト(macOS)側で > esp_rfc2217_server.py 動かしてTCP経由でFlashする。

ホスト側

# https://docs.espressif.com/projects/esptool/en/latest/esp32/remote-serial-ports.html
brew install esptool
esp_rfc2217_server.py -p 4000 /dev/tty.usbmodem101
# espflash flash target/<mcu-target>/debug/<your-project-name>

espflash flash --port rfc2217://host.docker.internal:4000?ign_set_control target/riscv32imac-esp-espidf/debug/tripticon-esp32

espflash flash target/riscv32imac-esp-espidf/debug/tripticon-esp32

・・・できないお