Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV LANG=C.UTF-8
# Arguments
ARG CONTAINER_USER=esp
ARG CONTAINER_GROUP=esp
ARG TOOLCHAIN_VERSION=1.62.0.0
ARG TOOLCHAIN_VERSION=1.62.1.0
ARG ESP_BOARD=esp32
ARG INSTALL_RUST_TOOLCHAIN=install-rust-toolchain.sh

Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "{{ crate_name }}",
// Select between image and build propieties to pull or build the image.
// "image": "docker.io/espressif/idf-rust:{{ mcu }}_1.62.0.0",
// "image": "docker.io/espressif/idf-rust:{{ mcu }}_1.62.1.0",
"build": {
"dockerfile": "Dockerfile",
"args": {
Expand Down Expand Up @@ -41,4 +41,4 @@
],
"workspaceMount": "source=${localWorkspaceFolder},target=/home/esp/{{ crate_name }},type=bind,consistency=cached",
"workspaceFolder": "/home/esp/{{ crate_name }}"
}
}
20 changes: 15 additions & 5 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@ jobs:
run: rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
- name: Setup | Default to nightly
run: rustup default nightly
- name: Setup | cargo-generate
run: |
- name: Setup | cargo-generate (binaries)
id: binaries
continue-on-error: true
run: |
sudo curl -L "https://github.com/cargo-generate/cargo-generate/releases/latest/download/cargo-generate-$(git ls-remote --refs --sort="version:refname" --tags "https://github.com/cargo-generate/cargo-generate" | cut -d/ -f3- | tail -n1)-x86_64-unknown-linux-gnu.tar.gz" -o "/home/runner/.cargo/bin/cargo-generate.tar.gz"
tar xf "/home/runner/.cargo/bin/cargo-generate.tar.gz" -C /home/runner/.cargo/bin
chmod u+x /home/runner/.cargo/bin/cargo-generate
- name: Setup | cargo-generate (cargo)
if: steps.binaries.outcome != 'success'
run: cargo install cargo-generate
- name: Setup | ldproxy
run: |
sudo curl -L "https://github.com/esp-rs/embuild/releases/latest/download/ldproxy-x86_64-unknown-linux-gnu.zip" -o "/home/runner/.cargo/bin/ldproxy.zip"
unzip "/home/runner/.cargo/bin/ldproxy.zip" -d /home/runner/.cargo/bin
chmod u+x /home/runner/.cargo/bin/ldproxy
- name: Generate (PR)
if: ${{ github.event_name == 'pull_request' }}
run: cargo generate --git https://github.com/${{ github.repository }} --branch ${{ github.head_ref }} --name test-esp32c3 --vcs none --silent -d mcu=esp32c3 -d devcontainer=false
run: cargo generate --git https://github.com/${{ github.event.pull_request.head.repo.full_name }} --branch ${{ github.head_ref }} --name test-esp32c3 --vcs none --silent -d mcu=esp32c3 -d devcontainer=false
- name: Generate (Push)
if: ${{ github.event_name != 'pull_request' }}
run: cargo generate --git https://github.com/esp-rs/esp-template --branch ${{ github.ref_name }} --name test-esp32c3 --vcs none --silent -d mcu=esp32c3 -d devcontainer=false
Expand All @@ -50,14 +55,19 @@ jobs:
matrix:
board: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3']
steps:
- name: Install cargo-generate
- name: Install cargo-generate via binaries
id: binaries
continue-on-error: true
run: |
sudo curl -L "https://github.com/cargo-generate/cargo-generate/releases/latest/download/cargo-generate-$(git ls-remote --refs --sort="version:refname" --tags "https://github.com/cargo-generate/cargo-generate" | cut -d/ -f3- | tail -n1)-x86_64-unknown-linux-gnu.tar.gz" -o "/home/runner/.cargo/bin/cargo-generate.tar.gz"
tar xf "/home/runner/.cargo/bin/cargo-generate.tar.gz" -C /home/runner/.cargo/bin
chmod u+x /home/runner/.cargo/bin/cargo-generate
- name: Install cargo-generate via cargo
if: steps.binaries.outcome != 'success'
run: cargo install cargo-generate
- name: Generate (PR)
if: ${{ github.event_name == 'pull_request' }}
run: cargo generate --git https://github.com/${{ github.repository }} --branch ${{ github.head_ref }} --name test-${{ matrix.board }} --vcs none --silent -d mcu=${{ matrix.board }} -d devcontainer=true
run: cargo generate --git https://github.com/${{ github.event.pull_request.head.repo.full_name }} --branch ${{ github.head_ref }} --name test-${{ matrix.board }} --vcs none --silent -d mcu=${{ matrix.board }} -d devcontainer=true
- name: Generate (Push)
if: ${{ github.event_name != 'pull_request' }}
run: cargo generate --git https://github.com/esp-rs/esp-template --branch ${{ github.ref_name }} --name test-${{ matrix.board }} --vcs none --silent -d mcu=${{ matrix.board }} -d devcontainer=true
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV LANG=C.UTF-8
# ARGS
ARG CONTAINER_USER=gitpod
ARG CONTAINER_GROUP=gitpod
ARG TOOLCHAIN_VERSION=1.62.0.0
ARG TOOLCHAIN_VERSION=1.62.1.0
ARG ESP_BOARD={{ mcu }}
ARG INSTALL_RUST_TOOLCHAIN=install-rust-toolchain.sh

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ esp-backtrace = { git = "https://github.com/esp-rs/esp-backtrace", features = ["
riscv-rt = { version = "0.8", optional = true }
{%- else -%}
{% if mcu == "esp32s2" -%}
xtensa-atomic-emulation-trap = "0.1.0"
xtensa-atomic-emulation-trap = "0.2.0"
{%- endif %}
xtensa-lx-rt = { version = "0.13.0", features = ["{{ mcu }}"], optional = true }
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A minimalist template for use with [cargo-generate] to create `no_std` applicati
To generate a project using this template:

```bash
$ cargo generate https://github.com/esp-rs/esp-template
cargo generate https://github.com/esp-rs/esp-template
```

[cargo-generate]: https://github.com/cargo-generate/cargo-generate
Expand Down
25 changes: 13 additions & 12 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
# Gitpod and VsCode Codespaces tasks do not source the user environment
if [ "${USER}" == "gitpod" ]; then
which idf.py >/dev/null || {
source ~/export-esp.sh > /dev/null 2>&1
source ~/export-esp.sh >/dev/null 2>&1
}
elif [ "${CODESPACE_NAME}" != "" ]; then
which idf.py >/dev/null || {
source ~/export-esp.sh > /dev/null 2>&1
source ~/export-esp.sh >/dev/null 2>&1
}
fi

case "$1" in
""|"release")
cargo build --release
;;
"debug")
cargo build
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1;;
esac
"" | "release")
cargo build --release
;;
"debug")
cargo build
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1
;;
esac
25 changes: 13 additions & 12 deletions scripts/flash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ set -e

BUILD_MODE=""
case "$1" in
""|"release")
bash scripts/build.sh
BUILD_MODE="release"
;;
"debug")
bash scripts/build.sh debug
BUILD_MODE="debug"
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1;;
"" | "release")
bash scripts/build.sh
BUILD_MODE="release"
;;
"debug")
bash scripts/build.sh debug
BUILD_MODE="debug"
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1
;;
esac

export ESP_ARCH=
Expand All @@ -24,4 +25,4 @@ riscv32imac-unknown-none-elf
xtensa-{{ mcu }}-none-elf
{%- endif %}

web-flash --chip {{ mcu }} target/${ESP_ARCH}/${BUILD_MODE}/{{ project-name }}
web-flash --chip {{ mcu }} target/${ESP_ARCH}/${BUILD_MODE}/{{ crate_name }}
33 changes: 17 additions & 16 deletions scripts/run-wokwi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ set -e

BUILD_MODE=""
case "$1" in
""|"release")
bash scripts/build.sh
BUILD_MODE="release"
;;
"debug")
bash scripts/build.sh debug
BUILD_MODE="debug"
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1;;
"" | "release")
bash scripts/build.sh
BUILD_MODE="release"
;;
"debug")
bash scripts/build.sh debug
BUILD_MODE="debug"
;;
*)
echo "Wrong argument. Only \"debug\"/\"release\" arguments are supported"
exit 1
;;
esac

if [ "${USER}" == "gitpod" ];then
if [ "${USER}" == "gitpod" ]; then
gp_url=$(gp url 9012)
echo "gp_url=${gp_url}"
export WOKWI_HOST=${gp_url:8}
elif [ "${CODESPACE_NAME}" != "" ];then
elif [ "${CODESPACE_NAME}" != "" ]; then
export WOKWI_HOST=${CODESPACE_NAME}-9012.githubpreview.dev
fi

Expand All @@ -35,7 +36,7 @@ xtensa-{{ mcu }}-none-elf
# TODO: Update with your Wokwi Project
export WOKWI_PROJECT_ID=""
if [ "${WOKWI_PROJECT_ID}" == "" ]; then
wokwi-server --chip {{ mcu }} target/${ESP_ARCH}/${BUILD_MODE}/{{ project-name }}
wokwi-server --chip {{ mcu }} target/${ESP_ARCH}/${BUILD_MODE}/{{ crate_name }}
else
wokwi-server --chip {{ mcu }} --id ${WOKWI_PROJECT_ID} target/${ESP_ARCH}/${BUILD_MODE}/{{ project-name }}
fi
wokwi-server --chip {{ mcu }} --id ${WOKWI_PROJECT_ID} target/${ESP_ARCH}/${BUILD_MODE}/{{ crate_name }}
fi
10 changes: 4 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_std]
#![no_main]

use {{ mcu }}_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, RtcCntl};
use {{ mcu }}_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc};
use esp_backtrace as _;
{% if mcu == "esp32c3" -%}
use riscv_rt::entry;
Expand All @@ -23,18 +23,16 @@ fn main() -> ! {
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

// Disable the RTC and TIMG watchdog timers
let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut rtc = Rtc::new(peripherals.RTC_CNTL);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;

{% if mcu == "esp32c3" -%}
rtc_cntl.set_super_wdt_enable(false);
rtc_cntl.set_wdt_global_enable(false);
{%- else -%}
rtc_cntl.set_wdt_global_enable(false);
rtc.swd.disable();
{%- endif %}
rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();

Expand Down