Skip to content

Commit 372d44d

Browse files
feat(rust-training-esp32c3): fetch examples (#57)
1 parent 28a25f3 commit 372d44d

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

rust-training-esp32c3/Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ FROM espressif/rust-std-training
44
USER esp
55
ENV USER=esp
66

7-
RUN git clone https://github.com/ferrous-systems/espressif-trainings.git espressif-trainings \
8-
&& rm -rf espressif-trainings/book
7+
RUN git clone https://github.com/esp-rs/std-training.git std-training \
8+
&& rm -rf std-training/book
99

1010
ENV IDF_TOOLS_PATH=/home/esp/.espressif
1111
RUN echo "source /home/esp/.espressif/frameworks/esp-idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
@@ -14,15 +14,21 @@ ENV PATH=${PATH}:/home/esp/.cargo/bin
1414
COPY sdkconfig.defaults /home/esp/
1515
COPY cfg.toml /home/esp/
1616
COPY compile.sh /home/esp/
17+
COPY fetch.sh /home/esp/
1718

1819
RUN mkdir -p /home/esp/build-in /home/esp/build-out
1920

21+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/button-interrupt
22+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-driver
23+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh advanced/i2c-sensor-reading
24+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/hardware-check
25+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-client
26+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/http-server
27+
RUN WOKWI_MCU=esp32-c3 ./fetch.sh intro/mqtt/exercise
28+
29+
2030
ENV HEXI_SRC_DIR="/home/esp/build-in"
2131
ENV HEXI_SRC_FILES="*.rs"
2232
ENV HEXI_BUILD_CMD="bash /home/esp/compile.sh"
2333
ENV HEXI_OUT_HEX="/home/esp/build-out/project.bin"
2434
ENV HEXI_OUT_ELF="/home/esp/build-out/project.elf"
25-
26-
EXPOSE 8080
27-
COPY --from=wokwi/mini-hexi /wokwi-hexi /wokwi-hexi
28-
CMD /wokwi-hexi

rust-training-esp32c3/fetch.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
set -ef
4+
5+
echo "Compiling $1"
6+
7+
cd /home/esp/std-training/$1
8+
9+
if [ -f cfg.toml.example ]; then
10+
# Rename file to cfg.toml
11+
cp cfg.toml.example cfg.toml
12+
# Replace defaults
13+
sed -i 's/wifi_ssid = "FBI Surveillance Van"/wifi_ssid = "Wokwi-GUEST"/g' cfg.toml
14+
sed -i 's/wifi_psk = "hunter2"/wifi_psk = ""/g' cfg.toml
15+
sed -i 's/mqtt_user = "horse"/mqtt_user = "user"/g' cfg.toml
16+
sed -i 's/mqtt_pass = "CorrectHorseBatteryStaple"/mqtt_pass = "pass"/g' cfg.toml
17+
sed -i 's/mqtt_host = "yourpc.local"/mqtt_host = "host"/g' cfg.toml
18+
fi
19+
20+
$HOME/.cargo/bin/cargo clean
21+
$HOME/.cargo/bin/cargo build --release

0 commit comments

Comments
 (0)