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

Host (and ESP-IDF) build; less memory usage; edge_nal::TcpConnect impl #59

Merged
merged 32 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e878dfc
(WIP) Host and ESP-IDF build
ivmarkov Nov 13, 2024
0673361
(WIP) Host and ESP-IDF build
ivmarkov Nov 14, 2024
8256dff
Move the mbedtls submodule inside esp-mbedtls-sys or else cargo publi…
ivmarkov Nov 14, 2024
7e82e56
xtask buildable
ivmarkov Nov 14, 2024
e2612b4
Remove targets dir from xtask; fix a bug where sys was constantly reb…
ivmarkov Nov 14, 2024
76621b2
WIP - debugging and getting it to run
ivmarkov Nov 17, 2024
ceb7982
WIP - no extra buffers
ivmarkov Nov 17, 2024
3a60582
No extra buffer works (tested on host only)
ivmarkov Nov 17, 2024
895c7da
Compatibility with ESP-IDF
ivmarkov Nov 18, 2024
1a547e9
Compatibility with ESP-IDF
ivmarkov Nov 18, 2024
eaeff0d
WIP: Baremetal build
ivmarkov Nov 18, 2024
50514d8
Baremetal build works
ivmarkov Nov 18, 2024
9567bbc
Rename Crypto to Tls; examples build again
ivmarkov Nov 18, 2024
09f7725
Make the examples deps all optional, or else the root workspace does …
ivmarkov Nov 19, 2024
93594d0
New example: crypto_self_test_std (timings for host and ESP-IDF)
ivmarkov Nov 19, 2024
3186616
Documentation; Rename token to tls_ref
ivmarkov Nov 19, 2024
3236df0
Fix the build artefacts for RiscV; implement alignment checker
ivmarkov Nov 19, 2024
6dd99a5
Fix the build for MbedTLS 3.4 which does not recognize MBEDTLS_CONFIG…
ivmarkov Nov 19, 2024
2beb625
cargo fmt; build
ivmarkov Nov 19, 2024
6aa8581
Add crypto-self-test examples
ivmarkov Nov 19, 2024
8269409
Test build for ESP IDF too
ivmarkov Nov 19, 2024
ffa7024
Need to init the mbedtls submodule
ivmarkov Nov 19, 2024
49b04b3
Temporarly comment out the ESP IDF task until I grok justfile
ivmarkov Nov 19, 2024
f95dd0f
Temporarly comment out the ESP IDF task until I grok justfile
ivmarkov Nov 19, 2024
b0dba6c
A fix for MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET in mbedtls vers…
ivmarkov Nov 28, 2024
dca6f83
Depending on a custom version of cmake-rs is no longer necessary
ivmarkov Nov 28, 2024
c3a1f9c
Fix sync coce not working
ivmarkov Nov 28, 2024
605f672
fmt
ivmarkov Nov 28, 2024
0dbc5f6
Enable debug on xtensa; rebuild baremetal libs
ivmarkov Nov 28, 2024
78ebfba
fmt
ivmarkov Nov 28, 2024
013098c
Raise MSRV to 1.82; put license key in all Cargo.toml files
ivmarkov Dec 15, 2024
d137291
Handle stream EOF
ivmarkov Dec 15, 2024
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
18 changes: 18 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[build]
# Build on host
#target = "x86_64-unknown-linux-gnu"
# Build on target firmware with ESP IDF
#target = "xtensa-esp32s3-espidf"
# Build on target firmware with baremetal
#target = "xtensa-esp32s3-none-elf"
#target = "xtensa-esp32-none-elf"
target = "riscv32imc-unknown-none-elf"

[target.xtensa-esp32-none-elf]
runner = "espflash flash --monitor --baud 921600"

Expand Down Expand Up @@ -37,8 +47,16 @@ rustflags = [
"-C", "link-arg=-Trom_functions.x",
]

[target.'cfg(target_os = "espidf")']
linker = "ldproxy"
runner = "espflash flash --monitor"
rustflags = [ "--cfg", "espidf_time64"]

[unstable]
# Enable this when building for baremetal
build-std = ["core", "alloc"]
# Enable this when building on the host machine or for ESP-IDF
#build-std = ["std", "panic_abort"]

[alias]
xtask = "run --manifest-path ./xtask/Cargo.toml --"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ jobs:
components: rust-src,rustfmt
- uses: esp-rs/[email protected]
with:
ldproxy: false
ldproxy: true
override: false
- uses: Swatinem/rust-cache@v2
- uses: extractions/setup-just@v1
with:
just-version: 1.13.0

- name: mbedtls init
run: git submodule update --init --recursive

- name: check
run: just
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ Cargo.lock
# You should copy the template and not modify `settings.json`
.vscode/settings.json

.embuild

tmpsrc
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "mbedtls"]
path = mbedtls
path = esp-mbedtls-sys/mbedtls
url = https://github.com/espressif/mbedtls
103 changes: 52 additions & 51 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ opt-level = "s"
opt-level = 3

[profile.dev]
debug = true
lto = "fat"
opt-level = "z"

[profile.dev.package.esp-wifi]
opt-level = 3

[dependencies]
esp-hal = { version = "0.21.0" }
esp-backtrace = { version = "0.14.0", features = [
esp-hal = { version = "0.21.0", optional = true }
esp-backtrace = { version = "0.14.0", optional = true, features = [
"panic-handler",
"println",
"exception-handler",
] }
esp-println = { version = "0.12.0", features = ["log"] }
esp-println = { version = "0.12.0", optional = true, features = ["log"] }
esp-hal-embassy = { version = "0.4.0", optional = true }

embassy-time = { version = "0.3.0", optional = true }
Expand All @@ -43,9 +45,8 @@ embassy-net = { version = "0.4.0", features = [
"medium-ethernet",
], optional = true }


esp-wifi = { version = "0.10.1", features = ["phy-enable-usb", "wifi-default"] }
smoltcp = { version = "0.11.0", default-features = false, features = [
esp-wifi = { version = "0.10.1", optional = true, features = ["phy-enable-usb", "wifi-default", "sys-logs"] }
smoltcp = { version = "0.11.0", optional = true, default-features = false, features = [
"proto-igmp",
"proto-ipv4",
"socket-tcp",
Expand All @@ -58,7 +59,7 @@ smoltcp = { version = "0.11.0", default-features = false, features = [
] }
log = "0.4.16"
embedded-io = "0.6.1"
embedded-io-async = { version = "0.6.0", optional = true }
embedded-io-async = "0.6.0"
heapless = "0.8.0"
critical-section = "1.0.1"
static_cell = { version = "2.1", features = ["nightly"] }
Expand All @@ -69,91 +70,91 @@ edge-http = { version = "0.3.0", optional = true }
edge-nal = { version = "0.3.0", optional = true }
edge-nal-embassy = { version = "0.3.0", optional = true }
cfg-if = "1.0.0"
esp-alloc = "0.5.0"
esp-alloc = { version = "0.5.0", optional = true}
enumset = { version = "1", default-features = false }

[target.'cfg(target_os = "espidf")'.dependencies]
esp-idf-svc = { version = "0.49.1", features = ["binstart"] }

[[example]]
name = "crypto_self_test"
required-features = ["esp-wifi/sys-logs"]
required-features = ["examples"]

[[example]]
name = "crypto_self_test_std"

[[example]]
name = "async_client"
required-features = ["async"]
required-features = ["examples-async"]

[[example]]
name = "async_client_mTLS"
required-features = ["async"]
required-features = ["examples-async"]

[[example]]
name = "async_server"
required-features = ["async"]
required-features = ["examples-async"]

[[example]]
name = "async_server_mTLS"
required-features = ["async"]
required-features = ["examples-async"]

[[example]]
name = "edge_server"
required-features = ["async", "edge-server"]
required-features = ["examples-async", "edge-http"]

[features]
examples = ["esp-hal", "esp-backtrace", "esp-println", "esp-wifi", "smoltcp", "esp-alloc"]
examples-async = ["examples", "esp-hal-embassy", "embassy-time", "embassy-executor", "embassy-net", "edge-http", "edge-nal", "edge-nal-embassy", "esp-wifi/async", "esp-wifi/embassy-net", "esp-mbedtls/async", "esp-mbedtls/edge-nal"]
examples-std = ["critical-section/std"]

esp32 = [
"esp-hal/esp32",
"esp-hal?/esp32",
"esp-hal-embassy?/esp32",
"esp-backtrace/esp32",
"esp-println/esp32",
"esp-wifi/esp32",
"esp-backtrace?/esp32",
"esp-println?/esp32",
"esp-wifi?/esp32",
"esp-mbedtls/esp32",
]
esp32c3 = [
"esp-hal/esp32c3",
"esp-hal?/esp32c3",
"esp-hal-embassy?/esp32c3",
"esp-backtrace/esp32c3",
"esp-println/esp32c3",
"esp-wifi/esp32c3",
"esp-backtrace?/esp32c3",
"esp-println?/esp32c3",
"esp-wifi?/esp32c3",
"esp-mbedtls/esp32c3",
]
esp32s2 = [
"esp-hal/esp32s2",
"esp-hal?/esp32s2",
"esp-hal-embassy?/esp32s2",
"esp-backtrace/esp32s2",
"esp-println/esp32s2",
"esp-wifi/esp32s2",
"esp-backtrace?/esp32s2",
"esp-println?/esp32s2",
"esp-wifi?/esp32s2",
"esp-mbedtls/esp32s2",
]
esp32s3 = [
"esp-hal/esp32s3",
"esp-hal?/esp32s3",
"esp-hal-embassy?/esp32s3",
"esp-backtrace/esp32s3",
"esp-println/esp32s3",
"esp-wifi/esp32s3",
"esp-backtrace?/esp32s3",
"esp-println?/esp32s3",
"esp-wifi?/esp32s3",
"esp-mbedtls/esp32s3",
]
async = [
"esp-wifi/async",
"esp-wifi/embassy-net",
"embassy-executor",
"embassy-net",
"embassy-time",
"dep:embedded-io-async",
"esp-mbedtls/async",
"esp-hal-embassy",
]

# Helper feature to enable all dependencies required for edge-net
edge-server = [
"edge-nal",
"edge-nal-embassy",
"edge-http",
"esp-mbedtls/edge-nal",
]
[build-dependencies]
embuild = { version = "0.32", features = ["espidf"] }

# Patch until new release
[patch.crates-io]
edge-http = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net", rev = "722f92ac0fffd0cb1e1ce76086cca58df6eb49ee" }
edge-http = { git = "https://github.com/ivmarkov/edge-net" }
edge-nal = { git = "https://github.com/ivmarkov/edge-net" }
edge-nal-embassy = { git = "https://github.com/ivmarkov/edge-net" }
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal" }
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }
cmake = { git = "https://github.com/ivmarkov/cmake-rs" }

# Patch before 0.6.0 got yanked
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "886580179ff250e15b0fad6448e8ebed6cdabf2b" }
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() == "espidf" {
embuild::espidf::sysenv::output();
}
}
29 changes: 23 additions & 6 deletions esp-mbedtls-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,34 @@
name = "esp-mbedtls-sys"
version = "0.1.0"
edition = "2021"
links = "mbedtls"

[build-dependencies]
anyhow = "1.0.68"
anyhow = "1.0.68"
bindgen = "0.68.1"
env_logger = "0.10.0"
log = "0.4.17"
cmake = "0.1.50"
fs_extra = "1.3.0"
embuild = "0.32"

[dependencies]
# For malloc/free
# TODO: Replace with `esp-alloc` once `esp-alloc` starts to provide `malloc` and `free` in future
# ... or switch to our own `mbedtls_malloc/free`
esp-wifi = { version = "0.10.1", default-features = false, optional = true }

# ESP-IDF: The mbedtls lib distributed with ESP-IDF is used
[target.'cfg(target_os = "espidf")'.dependencies]
esp-idf-sys = { version = "0.35", default-features = false }

# All other platforms: mbedtls libs and bindings are created on the fly

[features]
default = []

# Exactly *one* chip MUST be selected via its feature:
esp32 = []
esp32c3 = []
esp32s2 = []
esp32s3 = []
# ESP-HAL: Exactly *one* chip MUST be selected via its feature:
esp32 = ["esp-wifi/esp32"]
esp32c3 = ["esp-wifi/esp32c3"]
esp32s2 = ["esp-wifi/esp32s2"]
esp32s3 = ["esp-wifi/esp32s3"]
Loading
Loading