Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Minor updates #139

Merged
merged 7 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
36 changes: 1 addition & 35 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ESP_LOGLEVEL="INFO"
[build]
rustflags = [
"-C", "link-arg=-Tlinkall.x",
{% if wifi -%}
{% if wifi %}
"-C", "link-arg=-Trom_functions.x",
{% endif -%}
{%- if arch == "xtensa" %}
Expand All @@ -20,40 +20,6 @@ rustflags = [
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",
{% endif -%}
{%- if atomic_emulation and arch == "riscv" %}
# comment the cfgs below if you do _not_ wish to emulate atomics.
# enable the atomic codegen option for RISCV
"-C", "target-feature=+a",
# tell the core library have atomics even though it's not specified in the target definition
"--cfg", "target_has_atomic_load_store",
"--cfg", 'target_has_atomic_load_store="8"',
"--cfg", 'target_has_atomic_load_store="16"',
"--cfg", 'target_has_atomic_load_store="32"',
"--cfg", 'target_has_atomic_load_store="ptr"',
# enable cas
"--cfg", "target_has_atomic",
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
{% endif -%}
{%- if atomic_emulation and arch == "xtensa" %}
# enable the atomic codegen option for Xtensa
"-C", "target-feature=+s32c1i",

# tell the core library have atomics even though it's not specified in the target definition
"--cfg", "target_has_atomic_load_store",
"--cfg", 'target_has_atomic_load_store="8"',
"--cfg", 'target_has_atomic_load_store="16"',
"--cfg", 'target_has_atomic_load_store="32"',
"--cfg", 'target_has_atomic_load_store="ptr"',
# enable cas
"--cfg", "target_has_atomic",
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
{% endif -%}
]

target = "{{ rust_target }}"
Expand Down
2 changes: 2 additions & 0 deletions .github/verify.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

echo "Verifying $1"

# If you want to execute this script locally, you need to update the path to
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.check.allTargets": false,
}
25 changes: 15 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
hal = { package = "{{ mcu }}-hal", version = "{{ hal_version }}" }
esp-backtrace = { version = "0.9.0", features = ["{{ mcu }}", "panic-handler", "exception-handler", "print-uart"] }
{{ mcu }}-hal = "{{ hal_version }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason we don't want to alias the HAL dependency anymore?

Copy link
Member

@jessebraham jessebraham Jan 5, 2024

Choose a reason for hiding this comment

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

What was the reason we did it in the first place? I always found it weird and needless, every time I generated a template I changed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ... interesting. I found it to be easier to copy code around this way ... however, I don't have a hard preference. Was just curious - and also once we did the split, we will just have esp_hal or something

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel too strongly about this, so feel free to revert if anybody else does.

Copy link
Member Author

Choose a reason for hiding this comment

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

I dont have any hard preference, tbh

Copy link

Choose a reason for hiding this comment

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

The main idea behind alias is to increase portability of the code. Using alias makes it easier to have common app code for multiple targets.

Copy link
Member

Choose a reason for hiding this comment

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

The next release will unify the hal, meaning all hals will be exposed under esp_hal, just like esp_idf_hal supports all target in one.

esp-backtrace = { version = "0.10.0", features = ["{{ mcu }}", "panic-handler", "exception-handler", "print-uart"] }
{% if logging -%}
esp-println = { version = "0.7.0", features = ["{{ mcu }}","log"] }
log = { version = "0.4.18" }
esp-println = { version = "0.8.0", features = ["{{ mcu }}", "log"] }
log = { version = "0.4.20" }
{% else -%}
esp-println = { version = "0.7.0", features = ["{{ mcu }}"] }
esp-println = { version = "0.8.0", features = ["{{ mcu }}"] }
{% endif -%}
{% if alloc -%}
esp-alloc = { version = "0.3.0" }
{% endif -%}
{% if wifi -%}
esp-wifi = { version = "0.1.1", features = ["{{ mcu }}", "wifi"] }
smoltcp = { version = "0.10.0", default-features=false, features = ["proto-igmp", "proto-ipv4", "socket-tcp", "socket-icmp", "socket-udp", "medium-ethernet", "proto-dhcpv4", "socket-raw", "socket-dhcpv4"] }
embedded-svc = { version = "0.26.1", default-features = false, features = [] }
embedded-io = "0.4.0"
heapless = { version = "0.7.14", default-features = false }
esp-wifi = { version = "0.2.0", features = ["{{ mcu }}", "wifi"] }
smoltcp = { version = "0.11.0", default-features=false, features = ["proto-igmp", "proto-ipv4", "socket-tcp", "socket-icmp", "socket-udp", "medium-ethernet", "proto-dhcpv4", "socket-raw", "socket-dhcpv4"] }
embedded-svc = { version = "0.26.4", default-features = false, features = [] }
embedded-io = "0.6.1"
heapless = { version = "0.8.0", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should bump this since it's mostly used for embedded-svc which is still on 0.7+

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sorry - we shouldn't downgrade embedded-io but heapless: https://crates.io/crates/embedded-svc/0.26.4/dependencies

Reason is, it's used in esp-wifi's (through embedded-svc) public API

Copy link
Contributor

Choose a reason for hiding this comment

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

downgrading smoltcp is probably good since for some reason we forgot to bump it in esp-wifi 0.2.0 🤦‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

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

I think now, if I understood it correctly, dependencies should be fine.

{% endif -%}

{% if mcu == "esp32" or mcu == "esp32c2" %}
[features]
default = ["{{ mcu }}-hal/xtal-40mhz"]
{% endif %}
24 changes: 7 additions & 17 deletions pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,57 +1,47 @@
let metadata = #{
// Xtensa devices:
esp32: #{
hal_version: "0.16.0",
hal_version: "0.17.0",
wokwi_board: "board-esp32-devkit-c-v4",
},
esp32s2: #{
atomic_emulation: true,
hal_version: "0.13.0",
hal_version: "0.14.0",
wokwi_board: "board-esp32-s2-devkitm-1",
},
esp32s3: #{
hal_version: "0.13.0",
hal_version: "0.14.0",
wokwi_board: "board-esp32-s3-devkitc-1",
},

// RISC-V devices:
esp32c2: #{
atomic_emulation: true,
extensions: "imc",
hal_version: "0.11.0",
hal_version: "0.12.0",
wokwi_board: "",
},
esp32c3: #{
atomic_emulation: true,
extensions: "imc",
hal_version: "0.13.0",
hal_version: "0.14.0",
wokwi_board: "board-esp32-c3-devkitm-1",
},
esp32c6: #{
extensions: "imac",
hal_version: "0.6.0",
hal_version: "0.7.0",
wokwi_board: "board-esp32-c6-devkitc-1",
},
esp32h2: #{
extensions: "imac",
hal_version: "0.4.0",
hal_version: "0.5.0",
wokwi_board: "board-esp32-h2-devkitm-1",
},
};

let mcu = variable::get("mcu");
let meta = metadata.get(mcu);

if meta.contains("atomic_emulation") {
variable::set("atomic_emulation", meta.get("atomic_emulation"));
} else {
variable::set("atomic_emulation", false);
}

variable::set("hal_version", meta.get("hal_version"));
variable::set("wokwi_board", meta.get("wokwi_board"));


if mcu in ["esp32", "esp32s2", "esp32s3"] {
// Xtensa devices:
variable::set("arch", "xtensa");
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
extern crate alloc;
use core::mem::MaybeUninit;
{% endif -%}
use {{ mcu }}_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};
use esp_backtrace as _;
use esp_println::println;
use hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};

{% if wifi -%}
use esp_wifi::{initialize, EspWifiInitFor};

{% if arch == "riscv" -%}
use hal::{systimer::SystemTimer, Rng};
use {{ mcu }}_hal::{systimer::SystemTimer, Rng};
{% else -%}
use hal::{timer::TimerGroup, Rng};
use {{ mcu }}_hal::{timer::TimerGroup, Rng};
{% endif -%}
{% endif -%}

Expand Down
Loading