From 7dafe2c716ba8e8071b6199edb95eaefeaa4f442 Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Sat, 4 Nov 2023 15:30:51 +0100 Subject: [PATCH 1/3] update devcontainer setting format Co-authored-by: John Sarracco --- cargo/.devcontainer/devcontainer.json | 53 +++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/cargo/.devcontainer/devcontainer.json b/cargo/.devcontainer/devcontainer.json index 0d299bb..543ebe9 100644 --- a/cargo/.devcontainer/devcontainer.json +++ b/cargo/.devcontainer/devcontainer.json @@ -10,35 +10,40 @@ "ESP_BOARD": "{{ mcu }}" } }, - "settings": { - "editor.formatOnPaste": true, - "editor.formatOnSave": true, - "editor.formatOnSaveMode": "file", - "editor.formatOnType": true, - "lldb.executable": "/usr/bin/lldb", - "files.watcherExclude": { - "**/target/**": true - }, - "rust-analyzer.checkOnSave.command": "clippy", - "rust-analyzer.checkOnSave.allTargets": false, - "[rust]": { - "editor.defaultFormatter": "rust-lang.rust-analyzer" + "containerUser": "esp", + "customizations": { + "vscode": { + "settings": { + "editor.formatOnPaste": true, + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", + "editor.formatOnType": true, + "lldb.executable": "/usr/bin/lldb", + "files.watcherExclude": { + "**/target/**": true + }, + "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.checkOnSave.allTargets": false, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + } + }, + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "serayuzgur.crates", + "mutantdino.resourcemonitor", + "yzhang.markdown-all-in-one", + "ms-vscode.cpptools", + "actboy168.tasks", + "Wokwi.wokwi-vscode" + ] } }, - "extensions": [ - "rust-lang.rust-analyzer", - "tamasfe.even-better-toml", - "serayuzgur.crates", - "mutantdino.resourcemonitor", - "yzhang.markdown-all-in-one", - "ms-vscode.cpptools", - "actboy168.tasks", - "Wokwi.wokwi-vscode" - ], "forwardPorts": [ 3333, 8000 ], "workspaceMount": "source=${localWorkspaceFolder},target=/home/esp/{{ crate_name }},type=bind,consistency=cached", "workspaceFolder": "/home/esp/{{ crate_name }}" -} +} \ No newline at end of file From a6bfb713b12029c03b02f50578877d522b31c225 Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Sat, 4 Nov 2023 18:12:52 +0100 Subject: [PATCH 2/3] upgrade to bookworm rust nightly image --- cargo/.devcontainer/Dockerfile | 52 ++++++++++++--------------- cargo/.devcontainer/devcontainer.json | 3 ++ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/cargo/.devcontainer/Dockerfile b/cargo/.devcontainer/Dockerfile index 215cf02..45d05e9 100644 --- a/cargo/.devcontainer/Dockerfile +++ b/cargo/.devcontainer/Dockerfile @@ -1,5 +1,4 @@ -ARG VARIANT=bullseye -FROM debian:${VARIANT} +FROM ghcr.io/rust-lang/rust:nightly-bookworm ENV DEBIAN_FRONTEND=noninteractive ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 @@ -10,47 +9,42 @@ ARG CONTAINER_GROUP=esp ARG ESP_BOARD=all ARG GITHUB_TOKEN -# Install dependencies +ARG RUST_INSTALL_DIR=/usr/local/cargo + +# Install dependencies needed for esp-idf + clang for riscv rust RUN apt-get update \ - && apt-get install -y git curl gcc clang ninja-build libudev-dev unzip xz-utils\ - python3 python3-pip python3-venv libusb-1.0-0 libssl-dev pkg-config libpython2.7 \ - && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + && apt-get install -y flex bison gperf python3-pip python3-venv cmake ninja-build ccache dfu-util clang \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* /tmp/library-scripts # Set users RUN adduser --disabled-password --gecos "" ${CONTAINER_USER} USER ${CONTAINER_USER} WORKDIR /home/${CONTAINER_USER} -# Install rustup -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ - --default-toolchain none -y --profile minimal - -# Update envs -ENV PATH=${PATH}:/home/${CONTAINER_USER}/.cargo/bin - # Install extra crates -RUN ARCH=$($HOME/.cargo/bin/rustup show | grep "Default host" | sed -e 's/.* //') && \ - curl -L "https://github.com/esp-rs/espup/releases/latest/download/espup-${ARCH}" -o "${HOME}/.cargo/bin/espup" && \ - chmod u+x "${HOME}/.cargo/bin/espup" && \ - curl -L "https://github.com/esp-rs/espflash/releases/latest/download/cargo-espflash-${ARCH}.zip" -o "${HOME}/.cargo/bin/cargo-espflash.zip" && \ - unzip "${HOME}/.cargo/bin/cargo-espflash.zip" -d "${HOME}/.cargo/bin/" && \ - rm "${HOME}/.cargo/bin/cargo-espflash.zip" && \ - chmod u+x "${HOME}/.cargo/bin/cargo-espflash" && \ - curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-${ARCH}.zip" -o "${HOME}/.cargo/bin/ldproxy.zip" && \ - unzip "${HOME}/.cargo/bin/ldproxy.zip" -d "${HOME}/.cargo/bin/" && \ - rm "${HOME}/.cargo/bin/ldproxy.zip" && \ - chmod u+x "${HOME}/.cargo/bin/ldproxy" && \ - curl -L "https://github.com/bjoernQ/esp-web-flash-server/releases/latest/download/web-flash-${ARCH}.zip" -o "${HOME}/.cargo/bin/web-flash.zip" && \ - unzip "${HOME}/.cargo/bin/web-flash.zip" -d "${HOME}/.cargo/bin/" && \ - rm "${HOME}/.cargo/bin/web-flash.zip" && \ - chmod u+x "${HOME}/.cargo/bin/web-flash" +RUN ARCH=$(${RUST_INSTALL_DIR}/bin/rustup show | grep "Default host" | sed -e 's/.* //') && \ + {% if arch != "riscv" -%} + curl -L "https://github.com/esp-rs/espup/releases/latest/download/espup-${ARCH}" -o "${RUST_INSTALL_DIR}/bin/espup" && \ + chmod u+x "${RUST_INSTALL_DIR}/bin/espup" && \ + {% endif -%} + curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-${ARCH}.zip" -o "${RUST_INSTALL_DIR}/bin/ldproxy.zip" && \ + unzip "${RUST_INSTALL_DIR}/bin/ldproxy.zip" -d "${RUST_INSTALL_DIR}/bin/" && \ + rm "${RUST_INSTALL_DIR}/bin/ldproxy.zip" && \ + chmod u+x "${RUST_INSTALL_DIR}/bin/ldproxy" && \ + curl -L "https://github.com/bjoernQ/esp-web-flash-server/releases/latest/download/web-flash-${ARCH}.zip" -o "${RUST_INSTALL_DIR}/bin/web-flash.zip" && \ + unzip "${RUST_INSTALL_DIR}/bin/web-flash.zip" -d "${RUST_INSTALL_DIR}/bin/" && \ + rm "${RUST_INSTALL_DIR}/bin/web-flash.zip" && \ + chmod u+x "${RUST_INSTALL_DIR}/bin/web-flash" # Install Xtensa Rust +{% if arch != "riscv" -%} RUN if [ -n "${GITHUB_TOKEN}" ]; then export GITHUB_TOKEN=${GITHUB_TOKEN}; fi \ - && ${HOME}/.cargo/bin/espup install\ + && ${RUST_INSTALL_DIR}/bin/espup install\ --targets "${ESP_BOARD}" \ --log-level debug \ --export-file /home/${CONTAINER_USER}/export-esp.sh +{% endif %} # Set default toolchain {% if arch == "riscv" -%} diff --git a/cargo/.devcontainer/devcontainer.json b/cargo/.devcontainer/devcontainer.json index 543ebe9..b75fa1a 100644 --- a/cargo/.devcontainer/devcontainer.json +++ b/cargo/.devcontainer/devcontainer.json @@ -10,6 +10,9 @@ "ESP_BOARD": "{{ mcu }}" } }, + "runArgs": [ + "--userns=keep-id" // needed for podman compatibility + ], "containerUser": "esp", "customizations": { "vscode": { From 5fa306708e23e74ba98956736084d8b44c2108ba Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Sun, 5 Nov 2023 09:35:26 +0100 Subject: [PATCH 3/3] only source file if espup installed --- cargo/.devcontainer/Dockerfile | 2 ++ cargo/.devcontainer/devcontainer.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cargo/.devcontainer/Dockerfile b/cargo/.devcontainer/Dockerfile index 45d05e9..aae938b 100644 --- a/cargo/.devcontainer/Dockerfile +++ b/cargo/.devcontainer/Dockerfile @@ -53,7 +53,9 @@ RUN rustup default nightly RUN rustup default esp {% endif %} +{% if arch != "riscv" -%} # Activate ESP environment RUN echo "source /home/${CONTAINER_USER}/export-esp.sh" >> ~/.bashrc +{% endif %} CMD [ "/bin/bash" ] diff --git a/cargo/.devcontainer/devcontainer.json b/cargo/.devcontainer/devcontainer.json index b75fa1a..121f1c9 100644 --- a/cargo/.devcontainer/devcontainer.json +++ b/cargo/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "{{ crate_name }}", - // Select between image and build propieties to pull or build the image. + // Select between image and build properties to pull or build the image. // "image": "docker.io/espressif/idf-rust:{{ mcu }}_latest", "build": { "dockerfile": "Dockerfile",