338 Commits

Author SHA1 Message Date
Dániel Buga
f3907af22b
Possibly awful SMP implementation (#4152)
* Test and fix time slicing

* Possibly awful SMP implementation

Co-authored-by: g1ibby <wss.world@gmail.com>

* Remove __esp_radio_builtin_scheduler

---------

Co-authored-by: g1ibby <wss.world@gmail.com>
2025-09-24 08:34:55 +00:00
Björn Quentin
5da68279bc
Rework ota (#4150)
* OTA Fixes

- Support up to 16 OTA app partitions
- Fixed some bugs and shortcomings
- Added an OTA helper

* Changelog

* CHANGELOG.md

* Fix

* Constants

* Code comments

* Make code more readable

* Fix auto-complete's sins
2025-09-22 13:48:59 +00:00
Juraj Sadel
5129e326a0
Remove unused deps across workspace (#4158) 2025-09-22 12:10:43 +00:00
Ulf Lilleengen
62529e2fd3
chore: update bt-hci version (#4146)
* chore: update bt-hci version

* chore: use released version of trouble-host

* Make sure clippy fails, fix warning

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2025-09-19 13:48:49 +00:00
Björn Quentin
37f048f20b
Fix ota-update example (#4145) 2025-09-19 08:11:24 +00:00
Juraj Sadel
3d0d20002e
Make a singleton form FlashStorage constructor, removed Default (#4132)
* Make a singleton form FlashStorage constructor, removed Default

* changelog

* Simplify, don't need the Singleton

* changelog

* reviews and build errors

* fix dead links

* fmt
2025-09-18 14:33:42 +00:00
Dániel Buga
1eed542f64
Use cargo-batch to build tests and examples, avoid linting so much (#4108)
* Use cargo-batch

* Run CI on mac runner

* Rely on MSRV and nightly jobs to lint

* Build docs separately

* Don't copy examples - fix builds on stable

* Run everything by default, set CI env var in ci command

* Run batched commands with RUSTC_BOOTSTRAP enabled

* Force cargo-batch to correctly ignore unstable option

* Test with nightly

* Use a persistent target folder, remove cache

* Don't delete the lp examples

* Restore target dir

* Build with stable again

* Fix rebase fail

* Remove handling tests

* Remove redundant code

* Restore repeated test run option

* Add simpler cargo check

* Introduce check-packages

* Remove stabilized -Zdoctest-xcompile

* Clean up commented code

* Remove more stuff

* Fix uart_uhci test

* No badger for us
2025-09-18 11:25:11 +00:00
Dániel Buga
42297811be
Use TLSF by default (#4130)
* Use TLSF by default

* Update example heap usage to leave more stack

* Fix test configurations
2025-09-17 14:03:32 +00:00
Dániel Buga
646495eb16
Runtime wifi config options (#4121)
* Turn country code and default power mode into runtime configs

* Move G_CONFIG setup to wifi::new

* Turn most configs into runtime options

* Set core ID to current one

* Mark most options unstable
2025-09-17 08:13:18 +00:00
Dániel Buga
54d0da12af
Add defmt+esp-println example (#4122)
* Add defmt+esp-println example

* Fix warning

* Un-nit the pick
2025-09-16 15:09:06 +00:00
Dániel Buga
9d596ca752
esp-radio: remove scheduler lifecycle management, remove idle task (#4093)
* Start scheduler on preempt init, remove deinit

* Static-allocate the main task context

* taskless idle

* Remove the need for an idle task
2025-09-15 12:47:39 +00:00
Juraj Sadel
a5a0833318
Add a CI workflow for checking links in .rs, .md, and .toml files acc… (#4098)
* Add a CI workflow for checking links in .rs, .md, and .toml files accross esp-hal workspace

fix dead links

* exclude unpublished crate documentation's links

* Add .lycheeignore with excluded links

* play with patterns

* don't forget to remove
2025-09-12 10:48:04 +00:00
Juraj Sadel
e888f574fb
Update embassy-futures (#4079) 2025-09-08 14:39:42 +00:00
Björn Quentin
27c89c3adc
Fix wifi event names (#4065)
* Fix wifi event names

* CHANGELOG.md

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
2025-09-08 07:09:04 +00:00
Alexei Pastuchov
6aaf12a08d
examples/README.md: clarify xtask subcommand usage and arguments (#4067)
- Update example commands to use the new `--chip` argument format for `build examples` and `run example` subcommands.
- Improve clarity by showing explicit argument order and usage.
- Reflect recent changes in xtask interface for building and running examples.

Signed-off-by: Alexei Pastuchov <info@maximka.de>
2025-09-06 10:01:15 +00:00
Dániel Buga
24d2122c14
Remove ConcurrentQueue & other minor tweaks (#4058)
* Remove ConcurrentQueue

* Unrequire preempt driver for 802.15.4
2025-09-05 14:59:08 +00:00
Dániel Buga
91e0cea412
Update embassy, embedded-test (#3945) 2025-09-05 13:51:26 +00:00
Dániel Buga
a84d3cc89f
Make timekeeping the driver's job (#4047) 2025-09-05 07:31:40 +00:00
Kirill Mikhailov
38fd991ff7
More cleanup in esp-radio (#4040)
* More cleanup in `esp-radio`

* misc

* address reviews

* docs update

* fmt
2025-09-04 14:03:19 +00:00
Juraj Sadel
34b908dc56
Remove wifi_state and split WifiState into WifiStaState and WifiApState (#4046)
* Remove wifi_state adn split WifiState into WifiStaState and WifiApState

* MG

* changelog

* review
2025-09-04 11:28:00 +00:00
Benedikt
a13def7df6
RMT: Type-erase channels (#3980)
* RMT: add HIL test that exercises all channels

to ensure that there are no issues with channel/register indexing; see
also the code comments.

no user-facing changes

* RMT: store ch_idx instead of channel number

`ConstChannelAccess` and `DynChannelAccess` used to store the channel number
and have a `Direction` generic parameter.
However, there are invalid combinations of `Direction` and the channel
number on some chips (e.g. on esp32c3, there is no channel with (Tx, 2),
because channel 2 and 3 only support Rx).

In constrast, the tuple `(Dir, ch_idx)` also uniquely identifies a
channel and its configuration, and any combination of it is valid as long as the
channel index is in bounds.

This makes it somewhat easier to work with; in particular, it will allow
removing bounds checks on ch_idx in a later commit by replacing
`ch_idx: u8` with an enum type.

This also refactors the `async_interrupt_handler` accordingly.

This is user-visible via the `ConstChannelAccess` type, however a later
commit in this PR will remove that entirely.

* RMT: elide bounds checks via ChannelIndex enum

If the channel index is not known at compile time in a given function,
the compiler will insert bounds checks on

- indexing the STATE global
- register access via the PAC

The compiler seems to be able to deduplicate them since low-level
functions are mostly inlined, but each function will retain at least one
bounds check.

This change helps the compiler to elide these checks by using a custom
type for channel indices that can only take values for which a channel
exists.
Specifically, this uses an enum to serve as a refinement of u8 to help
the compiler restrict value ranges. Due to inlining, this restricted
value range is propagated by the compiler until the potential bounds checks,
even if there's intermediate cast to u8,
cf. https://github.com/rust-lang/rust/issues/109958

There are no user-facing changes. (`ChannelIndex` is `pub` because it
appears in a `[doc(hidden)]` trait member.)

* RMT: always type-erase channels

- remove the `Raw` generic on `Channel`: This simplifies the types,
  should have negligible performance impact (helped by elided bounds
  checks via the recently introduced `ChannelIndex` enum), and greatly
  reduce code size if several channels are used (by avoiding
  monomorphization per channel)

- this also changed the arguments to configure_(tx,rx)_channel such that
  they don't contain generics, again avoiding code bloat due to
  monomorphization

This requires user code to change type annotations for channels and
transactions, and remove any manual type erasure (via `channel.degrade()`).

* RMT: impl blocking tx/rx methods directly on Channel

There's now only a single type that should implement these methods due
to erasing the channel index const generic, so the indirection via a
trait serves no purpose. Implementing methods directly on the channel
probably also helps to make the docs more discoverable.

This requires user code to remove the `TxChannel` and `RxChannel`
imports.

* RMT: impl async tx/rx methods directly on Channel

There's now only a single type that should implement these methods due
to erasing the channel index const generic, so the indirection via a
trait serves no purpose. Implementing methods directly on the channel
probably also helps to make the docs more discoverable.

This requires user code to remove the `TxChannelAsync` and `RxChannelAsync`
imports.

* RMT: impl *ChannelInternal traits only on DynChannelAccess

rather than as a blanket impl for RawChannelAccess, which includes
ConstChannelAccess: We don't intend to perform any accesses via
ConstChannelAccess anymore, so enforce that.
We could also get rid of the traits entirely and directly impl their
methods for DynChannelAccess, but it seems somewhat useful to keep them
around to guarantee that the interfaces in both chip_specific modules
are consistent.

There are no user-facing changes here.

* RMT: remove `pub` on various internal types

that used to be visible somewhere in the API's trait bounds, but are not
part of the API themselves

This is user-visible, but user code should not have used these types in
the first place.

* RMT: rm ConstChannelAccess, RawChannelAccess, private DynChannelAccess

now that Channel has no `Raw: RawChannelAccess` type parameter:

- we don't need low-level channel methods to be implemented for
  ConstChannelAccess, since all accesses go through DynChannelAccess.
  Thus, remove the *ChannelInternal traits and implement their methods directly
  on DynChannelAccess
- none of these types need to be public (although one might consider
  actually making them public with an unsafe constructor to provide an
  unsafe low-level interface to the hardware)

This is user-visible (imports need to be removed; they're not used
anymore since the previous commit that always type-erased the `Raw`
parameter of `Channel`)

* RMT: changelog and migration guide for type-erased channels

* RMT: (review) remove stray comment

* RMT: (review) remove is_tx() from Direction trait

we can simply use the const item directly
2025-09-03 12:15:51 +00:00
Björn Quentin
ec22515d05
Don't talk too much about xtasks (#4034) 2025-09-03 07:06:30 +00:00
Juraj Sadel
fe0a04517f
General esp-radio cleanup (#4017)
* General esp-radio cleanup

* changelog

* MG

* fix build error

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2025-09-02 16:48:17 +00:00
Anthony Grondin
3f29f0571c
feat(example): Add SNTP example to show how to update Rtc to the current time (#3995)
* feat(example): Add SNTP example to show how to update Rtc

* Bump embassy-net to 0.7.0 for compatibility

* Revert back to task-arena to build on stable.
2025-08-29 07:45:04 +00:00
Jesse Braham
1ecb6f5f76
Add BLE examples using trouBLE, move some Wi-Fi examples to qa-test (#3999)
* Move `embassy_wifi_bench`, `wifi_bench`, and `wifi_csi` examples to `qa-test` package

* Remove blocking BLE example, replace Embassy example with trouble-based scanner

* Add BLE `bas_peripheral` example
2025-08-28 09:31:37 +00:00
Juraj Sadel
6f713c357b
API improvements (#3994)
* API improvments

* MG and changelog
2025-08-27 12:51:25 +00:00
Juraj Sadel
e6cdd8eb3c
Add xtask command check-unused-deps and remove unused deps/features (#3967)
* Add xtask command check-unused-deps and remove unused deps/features

* fix changelog

* reviews, move check into nightly-ci

* reviews

* readd document-features to esp-preemt

* Just cargo machete
2025-08-27 08:48:58 +00:00
Jesse Braham
25735229d1
Fix CI example checks (#3988)
* Actually build the examples when not specifying an output directory

* Update `wifi` examples to get them all building again
2025-08-26 10:14:57 +00:00
Björn Quentin
50265b457c
Have a way to get the booted partition (#3979)
* Have a way to get the booted partition

* CHANGELOG.md

* Add inline docs
2025-08-25 08:14:44 +00:00
Björn Quentin
522ff0bb73
Fix ota-example instructions (#3978)
* Fix ota-example instructions

* fmt
2025-08-22 15:38:30 +00:00
Juraj Sadel
0ce9a1c5e7
Split the wifi feature into wifi-ap, wifi-sta and wifi-eap (#3924)
* Split wifi feature into wifi-ap, wifi-sta and wifi-eap

* changelog

* Revert most of the changes, keep wifi and wifi-eap features only

* wifi-eap is unstable, include this feature into CI tests and documentation
2025-08-21 09:47:42 +00:00
Juraj Sadel
68345293ed
More consistent naming of interrupt-related functions (#3933)
* More consistent naming of interrupt-related functions

* MG entry

* changelog

* use correct package for MG

* fix hil

* other drivers

* address review comments
2025-08-21 09:46:04 +00:00
Jesse Braham
a7673b35f7
Remove scan_*_max and scan_n* functions from esp-radio (#3963)
* Remove `scan_*_max` and `scan_n*` functions

* Derive `BuilderLite` for `ScanConfig`

* Update migration guide for `esp-radio`

* Update changelogs
2025-08-20 13:22:26 +00:00
Juraj Sadel
7534606ab6
esp-radio: Hide C-types from public API (#3907)
* Hide C-types from public API

* Add accessories for all events
2025-08-19 13:43:39 +00:00
Scott Mabin
7c944ec939
s/esp-radio-preempt-baremetal/esp-preempt/g (#3938)
* s/esp-radio-preempt-baremetal/esp-preempt/g

esp-preempt will hopefully one day be more useful than just a scheduler
for esp-radio, therefore I've removed the radio prefix for that future
goal. I also felt that baremetal didn't really add much other than
noise, so I've removed that postfix too.

* fix xtask

* remove test code

* fixups
2025-08-15 13:52:42 +00:00
Juraj Sadel
ca4e28da4a
Don't use OTA partition table in radio examples (#3921) 2025-08-12 07:15:16 +00:00
Jesse Braham
8c86bf727a
Restructure example applications into self-contained projects (#3915)
* Move all `embassy` examples to `async` and convert to individual projects

* Move all peripheral examples to `peripheral` and convert to individual projects

* Move all interrupt examples to `interrupt` and convert to individual projects

* Move all `ble` examples to `ble` and convert to individual projects

* Move all `esp-now` examples to `esp-now` and convert to individual projects

* Move all Wi-Fi examples to `wifi` and convert to individual projects

* Move all `ieee802154` examples to `ieee802154` and convert to individual projects

* Move all OTA examples to `ota` and convert to individual projects

* Remove files which are no longer required

* Update `xtask` to handle new examples project layout

* Update `examples/README.md`

* Don't hide TOML parsing error in `is_published`

* Update `fmt-packages` subcommand to handle new examples project layout
2025-08-11 10:22:42 +00:00
Benedikt
ca04263b7b
RMT: Make PulseCode a newtype rather than an extension trait (#3884)
* RMT: make PulseCode a newtype rather than an extension trait on u32

This has several advantages:
- the meaning of `u32` used as pulse code becomes more explicit
- it allows using `PulseCode` methods in `const` context (which is otherwise
  not possible because Rust does not presently support associated const
  fn in traits).
- it allows providing custom `defmt::Format` and `core::fmt::Debug` impls
  for `PulseCode`, greatly helping with debugging

I have taken the liberty to implement `core::fmt::Debug` in a slightly
non-standard way: The most natural implementation would probably use a
struct-style output like

  PulseCode { length1: 42, level1: Level::High, length2: 24, level2: Level::Low }

However, that is very lengthy and not really human-readable anymore when
dealing with an array of `PulseCode`s. Thus, this uses the more compact format

  PulseCode(H 42, L 24)

This provides `u32: From<PulseCode>` and `PulseCode: From<u32>` impls and
converts rx and tx methods to accept `impl Into<PulseCode>` and
`impl From<PulseCode>`, respectively.
This should help to reduce how much user code needs to change (but replacing
`u32` type annotations with `PulseCode` will be required).

By applying `#[repr(transparent)]` to `struct PulseCode`, it is
guaranteed to match the layout of `u32` such that accessing the hardware
buffer via `*mut PulseCode` pointers is valid.

* RMT: Address review on PulseCode refactor, further refine the interface a bit

- introduce Level::const_from and Level::const_into
- pre-compute a few more shifts and masks (this is unlikely to affect
  generated code, since the compiler would have const propagated them
  anyway, but it helps to keep the PulseCode impl more readable)
- improve docstrings
- remove PulseCode::empty in favor of PulseCode::default, keep
  PulseCode::end_marker for now (but it's not completely clear that this
  interface is optimal; see also the FIXME note on adding a variant of
  this methods that supports settings levels and length1)
- make PulseCode::new_unchecked pub and shuffle it around in the code so
  that it doesn't show up first in the docs
- factor out PulseCode::symbolX methods for internal use in debug
  formatting
- sprinkle a few more #[inline] to be totally sure that this really adds
  no overhead over having plain u32
- convert methods receivers from &self to self given that PulseCode is
  Copy (which probably doesn't matter much since all these methods
  should always be inlined)
- remove PulseCode::as_u32() and make the tuple field pub: There's no
  safety implication of marking this pub, and field access still
  provides a const-compatible way to obtain the wrapped value
2025-08-08 07:51:49 +00:00
Björn Quentin
3ab3490d62
Move malloc etc to esp-alloc, common C functions to esp-rom-sys, define "C functions" in esp-radio weak (#3890)
* Provide malloc, free and friends in esp-alloc

* Mute warning

* Remove some (now unused) global symbols

* Have a way to opt-out of esp-alloc's malloc,free etc.

* Fixes

* Move some common C functions from esp-radio to esp-rom-sys

* Fix

* Make esp-readio symbols weakly linked

* CHANGELOG.md

* Align MSRV, cleanup visibility

* Init before `assume_init`

* Linker script fixes

* Fix examples

* Remove heapless - esp-radio is alloc

* Fix examples

* Whitespace

* realloc_internal

* Make `__esp_radio_putchar` a no-op if `sys-logs` is not enabled
2025-08-05 11:58:31 +00:00
Björn Quentin
3c12be8d24
Move exception handler from esp-backtrace to esp-hal (#3887)
* Move exception handler from esp-backtrace to esp-hal

* CHANGELOG.md

* Fix

* Only use defmt compatible display hints

* Workaround xtensa-lx-rt and riscv-rt not implementing defmt::Format

* Add `defmt` feature to xtensa-lx-rt and esp-riscv-rt

* Favor feature gates over random `allow`s - remove unnecessary `allow`s
2025-08-01 07:57:42 +00:00
Juraj Sadel
0fbbe2d22c
esp-wifi: Add unstable feature, mark ble, esp-now, csi, sniffer, and smoltcp features and APIs as unstable (#3865)
* esp-wifi: Add unstable feature, mark ble, esp-now and csi features and APIs as unstable

* changelog

* fix hils

* rebase and reviews

* rebase

* Make at least wifi_embassy_dhcp work without unstable feature

* remove rand_core

* rebase

* Check if a feature is selected which needs unstable

* reviews and fix ci

* reviews
2025-07-31 07:59:05 +00:00
Kirill Mikhailov
66b196a5f8
preempt crates: Rename esp_wifi-prefixed symbols to match new esp-radio crate name (#3881)
* rename `esp_wifi`-prefixed symbols to match new `esp-radio` crate name

* fmt

* rename the rest of functions + example variable renaming

* add migration guide

* reword 😅
2025-07-30 15:17:05 +00:00
Kirill Mikhailov
4eb4c89944
Fold esp-ieee802154 package into esp-radio (#3861)
* folding esp-ieee802154 to `esp-radio`

* remove the package

 Edit monorepo changelog to reflect the ieee-crate changes

* edit readme

* fix cargo.toml

* changelog update

fix changelog entry

* address reviews

* edit changelog

* remove useless "fmt.rs" file

* address reviews

* fix HIL build

sure

oh

fix hashmap inconsistency
2025-07-28 14:31:15 +00:00
Kirill Mikhailov
8ca0f94715
Get rid of EspRadio prefix in esp-radio structs (#3869)
* get rid of `EspRadio` prefix in esp-radio structs

* changelog entry + migration guide entry

* reword entries

* fmt run

* Fix migration guide entry

* edit the changelog entry to still reflect `esp-wifi` changes
2025-07-28 11:40:56 +00:00
Kirill Mikhailov
73ef8d9227
Rename esp-wifi to esp-radio (part 1) (#3858)
* rename `esp-wifi` to `esp-radio`

* Add migration guide entry

* changelog entry

* address reviews

* more fixes

* address reviews

* Thank you for this rebase!

* mmm, rebase

* Remove unnecessary diff

bob

* get rid off all `esp-wifi` references

* drop the links ƒrom the table
2025-07-25 12:26:08 +00:00
Dániel Buga
07214ef80d
Split out preempt driver and default impl (#3855) 2025-07-25 06:35:19 +00:00
HaoboGu
bccd9d770a
Bump embassy-usb version (#3848)
* Bump `embassy-usb` version

Signed-off-by: Haobo Gu <haobogu@outlook.com>

* Add `embassy-usb` update to CHANGELOG.md

Signed-off-by: Haobo Gu <haobogu@outlook.com>

---------

Signed-off-by: Haobo Gu <haobogu@outlook.com>
2025-07-22 13:07:37 +00:00
Dániel Buga
0d9f43db29
Rewrite RNG (#3829) 2025-07-21 15:10:35 +00:00
Simon Neuenhausen
3d6e522cbc
Allow splitting control over modem clocks. (#3687)
* Minimal architecture for split RCC.

* Removed critical section.

* Add all modem clock controllers and adjust esp-ieee802154.

* Fixed incorrect cfg.

* Fixed unstable attribute usage.

* Replaced AtomicU8 with Cell<u8>

* Reverted example channel back to 15

* Added unstable attribute to ModemClockController impls.

* Remember to actually increase the ref count.

* Experimentally removed RadioClockController

* Merged ref counters and made decrease panic if zero is reached.

* Removed RADIO_CLK peripheral.

* Removed RADIO_CLK again.

* Revert "Removed RADIO_CLK again."

This reverts commit 6da2d2834850068aa21bc52b141de2cfd8154acc.

* Removed RADIO_CLK without reformatting the files.

* Applied changes to examples and hil-tests.

* Fixed OS adapter for C2 and H2

* Adjusted docs and used unwrap!

* Fixed comments.

* Added changelog.

* Fixed esp-wifi for esp32h2.

* Changed comment for PHY_CLOCK_REF_COUNTER.

* Fixed lint for esp32c2.

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Removed unnecessary comments and made init_radio_clocks unstable.

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Fixed lint.

* Removed clocks_ll functions for chips that don't have those peripherals.

* fmt

* Changed modem clock controller stealing.

* Added lifetime

* fixed peripheral stealing again

* Made modem_clock_controller not const.

* Used type alias instead of function for peripheral stealing.

* fmt

* Adjusted remaining comments.

* Added note about coex.

* fmt

* misc

* Revert "misc"

This reverts commit d8740421e0dff84af605160939e246f2308a48e1.

* Regenerated esp metadata

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2025-07-08 17:23:55 +00:00
Dániel Buga
517b5ccbe2
Make cargo xfmt respect the format config (#3739)
* Make cargo xfmt respect the format config

* Make sure comments and doc code have the same width
2025-07-03 08:18:02 +00:00