Skip to content

Commit 1f49511

Browse files
committed
init
0 parents  commit 1f49511

File tree

18 files changed

+2045
-0
lines changed

18 files changed

+2045
-0
lines changed

.cargo/config.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[target.xtensa-esp32-none-elf]
2+
runner = "espflash flash --monitor --chip esp32 --log-format defmt"
3+
4+
[env]
5+
DEFMT_LOG = "info"
6+
7+
[build]
8+
target = "xtensa-esp32-none-elf"
9+
rustflags = ["-C", "link-arg=-nostartfiles"]
10+
11+
[unstable]
12+
build-std = ["alloc", "core"]

.devcontainer/Dockerfile

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# syntax=docker.io/docker/dockerfile:1.19
2+
# shellcheck shell=bash
3+
4+
# see https://github.com/rust-lang/rustup/tags/
5+
# renovate: datasource=github-releases depName=rust-lang/rustup
6+
ARG RUSTUP_INIT_VERSION='1.28.2'
7+
8+
# see https://github.com/cargo-bins/cargo-binstall/releases
9+
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
10+
ARG CARGO_BINSTALL_VERSION='1.15.9'
11+
12+
# see https://github.com/esp-rs/espup/releases/
13+
# renovate: datasource=github-releases depName=esp-rs/espup
14+
ARG ESPUP_VERSION='0.16.0'
15+
16+
# see https://github.com/rust-lang/rust/releases
17+
# NB to make things simpler. keep this in sync with ESP_RUST_VERSION bellow.
18+
# renovate: datasource=github-tags depName=rust-lang/rust
19+
ARG RUST_VERSION='1.90.0'
20+
21+
# see https://github.com/esp-rs/rust-build/releases
22+
# renovate: datasource=github-releases depName=esp-rs/rust-build
23+
ARG ESP_RUST_VERSION='1.90.0.0'
24+
25+
# see https://crates.io/crates/espflash
26+
# see https://github.com/esp-rs/espflash/releases
27+
# renovate: datasource=github-releases depName=esp-rs/espflash
28+
ARG ESPFLASH_VERSION='4.2.0'
29+
30+
# see https://crates.io/crates/esp-generate
31+
# see https://github.com/esp-rs/esp-generate/releases
32+
# renovate: datasource=github-releases depName=esp-rs/esp-generate
33+
ARG ESP_GENERATE_VERSION='1.0.0'
34+
35+
# see https://github.com/devcontainers/images/tree/main/src/base-debian/history
36+
FROM mcr.microsoft.com/devcontainers/base:2.0.2-trixie
37+
38+
RUN <<'EOF'
39+
#!/usr/bin/bash
40+
set -euxo pipefail
41+
export DEBIAN_FRONTEND=noninteractive
42+
apt-get update
43+
apt-get -y install --no-install-recommends \
44+
bash-completion \
45+
curl \
46+
sudo \
47+
unzip \
48+
wget
49+
apt-get clean
50+
rm -rf /var/lib/apt/lists/*
51+
EOF
52+
53+
USER vscode
54+
55+
# install rustup.
56+
# see https://github.com/rust-lang/rustup/tags.
57+
# see https://rust-lang.github.io/rustup/installation/other.html#manual-installation
58+
# see https://github.com/rgl/my-ubuntu-ansible-playbooks/blob/main/roles/rust/files/install-rust.sh
59+
ARG RUSTUP_INIT_VERSION
60+
RUN <<'EOF'
61+
#!/usr/bin/bash
62+
set -euxo pipefail
63+
u="https://static.rust-lang.org/rustup/archive/${RUSTUP_INIT_VERSION}/x86_64-unknown-linux-gnu/rustup-init"
64+
t="$(mktemp -q -d)"
65+
wget -qO "$t/rustup-init" "$u"
66+
chmod +x "$t/rustup-init"
67+
"$t/rustup-init" \
68+
-y \
69+
--no-update-default-toolchain
70+
rm -rf "$t"
71+
EOF
72+
ENV PATH="$PATH:/home/vscode/.cargo/bin"
73+
74+
# install rust.
75+
ARG RUST_VERSION
76+
RUN rustup default "$RUST_VERSION"
77+
78+
# install cargo-binstall.
79+
# see https://github.com/cargo-bins/cargo-binstall.
80+
ARG CARGO_BINSTALL_VERSION
81+
RUN <<'EOF'
82+
#!/usr/bin/bash
83+
set -euxo pipefail
84+
u="https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-x86_64-unknown-linux-gnu.tgz"
85+
t="$(mktemp -q -d)"
86+
wget -qO- "$u" | tar xzf - -C "$t"
87+
install "$t/cargo-binstall" ~/.cargo/bin
88+
rm -rf "$t"
89+
EOF
90+
91+
# install espup.
92+
ARG ESPUP_VERSION
93+
RUN cargo binstall "espup@$ESPUP_VERSION"
94+
95+
# install esp rust.
96+
ARG ESP_RUST_VERSION
97+
RUN <<'EOF'
98+
#!/usr/bin/bash
99+
set -euxo pipefail
100+
espup install \
101+
--toolchain-version "$ESP_RUST_VERSION" \
102+
--targets esp32
103+
echo 'source "$HOME/export-esp.sh"' >>~/.bashrc
104+
EOF
105+
106+
# install espflash.
107+
ARG ESPFLASH_VERSION
108+
RUN cargo binstall "espflash@$ESPFLASH_VERSION"
109+
110+
# install esp-generate.
111+
ARG ESP_GENERATE_VERSION
112+
RUN cargo binstall "esp-generate@$ESP_GENERATE_VERSION"
113+
114+
USER root
115+
116+
RUN <<'EOF'
117+
#!/usr/bin/bash
118+
set -euxo pipefail
119+
# ensure /etc/profile is called at the top of the file, when running in a
120+
# login shell.
121+
sed -i '0,/esac/s/esac/&\n\nsource \/etc\/profile/' /home/vscode/.bashrc
122+
EOF
123+
COPY .devcontainer/inputrc /etc/inputrc
124+
COPY .devcontainer/login.sh /etc/profile.d/login.sh

.devcontainer/devcontainer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "esp32",
3+
"dockerFile": "Dockerfile",
4+
"context": "..",
5+
"runArgs": [
6+
"--group-add=dialout",
7+
"--device=/dev/ttyUSB0",
8+
"-v=${localEnv:HOME}/.ssh/id_rsa:/home/vscode/.ssh/id_rsa:ro",
9+
"-v=${localEnv:HOME}/.ssh/id_rsa.pub:/home/vscode/.ssh/id_rsa.pub:ro"
10+
],
11+
"postCreateCommand": "bash .devcontainer/setup.sh",
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"github.vscode-github-actions",
16+
"rust-lang.rust-analyzer",
17+
"streetsidesoftware.code-spell-checker",
18+
"tamasfe.even-better-toml"
19+
]
20+
}
21+
}
22+
}

.devcontainer/inputrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set input-meta on
2+
set output-meta on
3+
set show-all-if-ambiguous on
4+
set completion-ignore-case on
5+
6+
"\e[A": history-search-backward
7+
"\e[B": history-search-forward
8+
"\eOD": backward-word
9+
"\eOC": forward-word

.devcontainer/login.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# shellcheck shell=bash
2+
3+
export EDITOR=code
4+
export PAGER=less
5+
6+
alias l='ls -lF --color'
7+
alias ll='l -a'
8+
alias h='history 25'
9+
alias j='jobs -l'

.devcontainer/setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
pushd /home/vscode
5+
sudo chown vscode:vscode .ssh && sudo chmod 700 .ssh
6+
popd

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.devcontainer/*

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: build
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
env:
7+
CARGO_TERM_COLOR: always
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-24.04
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
action:
17+
- command: build
18+
args: --release
19+
- command: fmt
20+
args: --all -- --check
21+
- command: clippy
22+
args: --all-features --workspace -- -D warnings
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v5
26+
- name: Setup Rust
27+
uses: esp-rs/xtensa-toolchain@v1.6
28+
with:
29+
default: true
30+
buildtargets: esp32
31+
version: "1.90.0"
32+
ldproxy: false
33+
- name: Enable caching
34+
uses: Swatinem/rust-cache@v2
35+
- name: Run command
36+
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target/
2+
rust-esp32-hello-world/
3+
*.tmp

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"cSpell.words": [
3+
"binstall",
4+
"espflash",
5+
"espup",
6+
"rustup"
7+
],
8+
"rust-analyzer.cargo.allTargets": false,
9+
"rust-analyzer.cargo.target": "xtensa-esp32-none-elf",
10+
"rust-analyzer.server.extraEnv": {
11+
"RUSTUP_TOOLCHAIN": "1.90.0"
12+
},
13+
"rust-analyzer.check.extraEnv": {
14+
"RUSTUP_TOOLCHAIN": "esp"
15+
},
16+
"rust-analyzer.cargo.extraEnv": {
17+
"RUSTUP_TOOLCHAIN": "esp"
18+
},
19+
}

0 commit comments

Comments
 (0)