Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for esp32p4 & updated to new released esp-idf v5.3 #226

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions .github/workflows/ci_cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ jobs:
strategy:
fail-fast: false
matrix:
target: ["esp32", "esp32c3", "esp32c2", "esp32c6", "esp32h2", "esp32s2", "esp32s3"]
target: ["esp32", "esp32c3", "esp32c2", "esp32c6", "esp32h2", "esp32p4", "esp32s2", "esp32s3"]
std-config:
- std: true
- std: false
esp-idf:
- version: v5.3
- version: v5.2
- version: v5.1 # only for compairson why no_std build fails on v5.2
# - version: v5.1 # only for compairson why no_std build fails on v5.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this worth to keep it still? We removed the 5.1 option from the template

# - version: master
steps:
- name: Setup | Rust (RISC-V)
Expand Down Expand Up @@ -72,17 +73,17 @@ jobs:
- uses: actions/checkout@v4
with:
path: /home/runner/work/esp-idf-template/esp-idf-template/github-esp-idf-template
- name: Generate v5.2
if: matrix.esp-idf.version == 'v5.2' || matrix.esp-idf.version == 'v5.1'
- name: Generate v5.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Generate v5.3
- name: Generate Project

if: matrix.esp-idf.version == 'v5.3' || (matrix.esp-idf.version == 'v5.2' && matrix.target != 'esp32p4')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this condition? Is it to avoid P4 and v5.2? We could add the esp-idf version to the target in the matrix so we can choose the esp-idf version per targets without having too much conditions (this could be helpful in the future where new targets will have the same issue as p4):

        target:
          - device: esp32
            esp-idf: v5.2
          - device: esp32
            esp-idf: v5.3
          - device: esp32c2
            esp-idf: v5.2
          - device: esp32c2
            esp-idf: v5.3                  
          - device: esp32c3
            esp-idf: v5.2
          - device: esp32c3
            esp-idf: v5.3          
          - device: esp32c6
            esp-idf: v5.2
          - device: esp32c6
            esp-idf: v5.3    
            ....
          - device: esp32p4
            esp-idf: v5.3                               

The matrix becomes significantly uglier though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm that somehow would nullify the complete concept of a matrix if i cramp all into a linear list of options right? That its merely a vector.

run: cargo generate --path /home/runner/work/esp-idf-template/esp-idf-template/github-esp-idf-template cargo --name ${{ matrix.target }}-${{ matrix.std-config.std }} --vcs none --silent -d mcu=${{ matrix.target }} -d advanced=true -d espidfver=${{ matrix.esp-idf.version }} -d std=${{ matrix.std-config.std }} -d devcontainer=false -d wokwi=false -d ci=false
- name: Build | Fmt Check
if: matrix.esp-idf.version == 'v5.2' && matrix.target == 'esp32c3'
if: matrix.esp-idf.version == 'v5.3' && matrix.target == 'esp32c3'
run: cd ${{ matrix.target }}-${{ matrix.std-config.std }}; cargo fmt -- --check
- name: Build | Clippy
if: matrix.esp-idf.version == 'v5.2' || matrix.esp-idf.version == 'v5.1'
if: matrix.esp-idf.version == 'v5.3' || (matrix.esp-idf.version == 'v5.2' && matrix.target != 'esp32p4')
run: cd ${{ matrix.target }}-${{ matrix.std-config.std }}; cargo clippy --no-deps -- -Dwarnings
- name: Build | Compile
if: matrix.esp-idf.version == 'v5.2' || matrix.esp-idf.version == 'v5.1'
if: matrix.esp-idf.version == 'v5.3' || (matrix.esp-idf.version == 'v5.2' && matrix.target != 'esp32p4')
run: cd ${{ matrix.target }}-${{ matrix.std-config.std }}; cargo build
container-checks:
name: "Container Check: ${{ matrix.target }}"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
toolchain: "nightly"
- mcu: "esp32h2"
toolchain: "nightly"
- mcu: "esp32p4"
toolchain: "nightly"
std-config:
- hal: true
std: true
Expand All @@ -49,7 +51,7 @@ jobs:
- hal: false
std: false
esp-idf:
- version: v5.2
- version: v5.3
# - version: master
# name: master
steps:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ The command will display a few prompts:
- `Configure advanced template options?`: If `false`, skips the rest of the prompts and uses their default value. If `true`, you will be prompted with:
- `Enable STD support?`: When `true` (default), adds support for the [Rust Standard Library](https://doc.rust-lang.org/std/). Otherwise, a `no_std` [Rust Core Library](https://doc.rust-lang.org/core/index.html) crate would be created.
- `ESP-IDF Version`: ESP-IDF branch/tag to use. Possible choices:
- [`v4.4`](https://github.com/espressif/esp-idf/releases/tag/v4.4.5): Stable
- [`v5.1`](https://github.com/espressif/esp-idf/releases/tag/v5.1): Stable
- [`v5.2`](https://github.com/espressif/esp-idf/releases/tag/v5.2.2): Stable
- [`v5.3`](https://github.com/espressif/esp-idf/releases/tag/v5.3): Stable
- [`master`](https://github.com/espressif/esp-idf/tree/master): **Unstable**
- `Configure project to support Wokwi simulation with Wokwi VS Code extension?`: Adds support for Wokwi simulation using [VS Code Wokwi extension](https://marketplace.visualstudio.com/items?itemName=wokwi.wokwi-vscode).
- `Configure project to use Dev Containers (VS Code and GitHub Codespaces)?`: Adds support for:
Expand Down Expand Up @@ -200,4 +200,3 @@ You need a Python 3.7 or later installed on your machine.

You'll also need the Python PIP and Python VENV modules. On Debian systems, you can install with:
* `sudo apt install python3-pip python3-venv`

8 changes: 4 additions & 4 deletions cargo/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ build-std = ["core", "alloc", "panic_abort"]
[env]
MCU="{{ mcu }}"
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
{%- if espidfver == "v5.1" %}
ESP_IDF_VERSION = "v5.1.4"
{% elsif espidfver == "v5.2" %}
{%- if espidfver == "v5.2" %}
ESP_IDF_VERSION = "v5.2.2"
{% elsif espidfver == "v5.3" %}
ESP_IDF_VERSION = "v5.3"
{% elsif espidfver == "master" %}
ESP_IDF_VERSION = "master"
{% endif %}
# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174
# Workaround for https://github.com/esp-rs/esp-idf-template/issues/174
CRATE_CC_NO_DEFAULTS = "1"
24 changes: 20 additions & 4 deletions cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rust-version = "1.77"

[[bin]]
name = "{{project-name}}"
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors

[profile.release]
opt-level = "s"
Expand All @@ -21,19 +21,35 @@ opt-level = "z"
{%- if std %}
default = ["std", "embassy", "esp-idf-svc/native"]
{%- else %}
default = ["alloc", "embassy", "esp-idf-svc/native", "esp-idf-svc/panic_handler", "esp-idf-svc/alloc_handler", "esp-idf-svc/libstart"]
default = [
"alloc",
"embassy",
"esp-idf-svc/native",
"esp-idf-svc/panic_handler",
"esp-idf-svc/alloc_handler",
"esp-idf-svc/libstart",
]
{%- endif %}

pio = ["esp-idf-svc/pio"]
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
alloc = ["esp-idf-svc/alloc"]
nightly = ["esp-idf-svc/nightly"]
experimental = ["esp-idf-svc/experimental"]
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]
embassy = [
"esp-idf-svc/embassy-sync",
"esp-idf-svc/critical-section",
"esp-idf-svc/embassy-time-driver",
]

[dependencies]
log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.49", default-features = false }

[build-dependencies]
embuild = "0.32.0"
embuild = "0.32.0"

[patch.crates-io]
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys", branch = "p4-support" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal", branch = "p4-support" }
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc", branch = "p4-support" }
14 changes: 10 additions & 4 deletions cargo/cargo-generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pre = ["pre-script.rhai"]
[placeholders.mcu]
type = "string"
prompt = "Which MCU to target?"
choices = ["esp32", "esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32s2", "esp32s3"]
choices = ["esp32", "esp32c2", "esp32c3", "esp32c6", "esp32h2","esp32p4", "esp32s2", "esp32s3"]
default = "esp32"

[placeholders.advanced]
Expand All @@ -21,11 +21,17 @@ type = "bool"
prompt = "Enable STD support?"
default = true

[conditional.'advanced'.placeholders.espidfver]
[conditional.'advanced && (mcu == "esp32p4")'.placeholders.espidfver]
type = "string"
prompt = "ESP-IDF version (master = UNSTABLE)"
choices = ["v5.1", "v5.2", "master"]
default = "v5.2"
choices = ["v5.3", "master"]
default = "v5.3"

[conditional.'advanced && (mcu != "esp32p4")'.placeholders.espidfver]
type = "string"
prompt = "ESP-IDF version (master = UNSTABLE)"
choices = ["v5.2", "v5.3", "master"]
default = "v5.3"

[conditional.'advanced'.placeholders.devcontainer]
type = "bool"
Expand Down
8 changes: 7 additions & 1 deletion cargo/pre-script.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ let targets = #{
gcc_target: "riscv32-esp-elf",
wokwi_board: "board-esp32-h2-devkitm-1",
},
esp32p4: #{
arch: "riscv",
rust_target: "riscv32imafc-esp-espidf",
gcc_target: "riscv32-esp-elf",
wokwi_board: "board-esp32-h2-devkitm-1",
},
esp32s2: #{
arch: "xtensa",
rust_target: "xtensa-esp32s2-espidf",
Expand All @@ -52,7 +58,7 @@ for key in target_properties.keys() {
let advanced = variable::get("advanced");
if !advanced {
variable::set("std", true);
variable::set("espidfver", "v5.2");
variable::set("espidfver", "v5.3");
variable::set("devcontainer", false);
variable::set("wokwi", false);
}
4 changes: 3 additions & 1 deletion cmake/components/rust-{{project-name}}/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ idf_component_register(
)

if(CONFIG_IDF_TARGET_ARCH_RISCV)
if (CONFIG_IDF_TARGET_ESP32C6 OR CONFIG_IDF_TARGET_ESP32C5 OR CONFIG_IDF_TARGET_ESP32H2)
if (CONFIG_IDF_TARGET_ESP32P4)
set(RUST_TARGET "riscv32imafc-esp-espidf")
elseif (CONFIG_IDF_TARGET_ESP32C6 OR CONFIG_IDF_TARGET_ESP32C5 OR CONFIG_IDF_TARGET_ESP32H2)
set(RUST_TARGET "riscv32imac-esp-espidf")
else ()
set(RUST_TARGET "riscv32imc-esp-espidf")
Expand Down
25 changes: 21 additions & 4 deletions cmake/components/rust-{{project-name}}/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,51 @@ rust-version = "1.77"

[lib]
crate-type = ["staticlib"]
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors

[profile.release]
opt-level = "s"

[profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash
debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

{%- if hal %}
[features]
{%- if std %}
default = ["std", "embassy", "esp-idf-svc/native"]
{%- else %}
default = ["alloc", "embassy", "esp-idf-svc/native", "esp-idf-svc/panic_handler", "esp-idf-svc/alloc_handler"]
default = [
"alloc",
"embassy",
"esp-idf-svc/native",
"esp-idf-svc/panic_handler",
"esp-idf-svc/alloc_handler",
]
{%- endif %}



pio = ["esp-idf-svc/pio"]
std = ["alloc", "esp-idf-svc/std"]
alloc = ["esp-idf-svc/alloc"]
nightly = ["esp-idf-svc/nightly"]
experimental = ["esp-idf-svc/experimental"]
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]
embassy = [
"esp-idf-svc/embassy-sync",
"esp-idf-svc/critical-section",
"esp-idf-svc/embassy-time-driver",
]

[dependencies]
log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.49", default-features = false }

[build-dependencies]
embuild = "0.32.0"

[patch.crates-io]
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys", branch = "p4-support" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal", branch = "p4-support" }
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc", branch = "p4-support" }
{%- endif %}
Loading