2430 Commits

Author SHA1 Message Date
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
Björn Quentin
9e4da54b2a
Build xtask via xcheck with --quiet (#3965) 2025-08-20 18:16:05 +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
Juraj Sadel
c3c313aff1
Clean TWAI interrupt handling a bit and make it more consistent with all chips (#3936)
* Clean TWAI interrupt handling a bit and make it more consistent with all chips

* temporarily use patched PACs from fork

* use latest pacs
2025-08-19 13:43:15 +00:00
Björn Quentin
b03879507d
Fix link_section on inherent methods (#3953)
* Fix link_section on inherent methods

* Remove the `target_os = "macos"` special treatment where not needed
2025-08-19 11:19:05 +00:00
Dániel Buga
04d3faed5e
Rewrite SHA finish to be nonblocking (#3948) 2025-08-18 18:16:25 +00:00
Björn Quentin
c1c2d04124
Fix problem of not de-allocating memory in some situations (#3949)
* Fix problem of not de-allocating memory in some situations

* CHANGELOG.md
2025-08-18 09:53:58 +00:00
Dániel Buga
ef496a44da
Move SHA driver operatoins into driver struct (#3941)
* Move algos into driver

* Set finished flag
2025-08-15 15:30:58 +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
Dániel Buga
415f5c2a70
Change alignment helper functions to take bytes, not words (#3940) 2025-08-15 10:55:37 +00:00
Kirill Mikhailov
614fc59814
xtask: Rework example command structure (#3927)
* reduce duplicity in function call

* Readme update

* part of reviews

* more reviews addressing
2025-08-15 09:55:36 +00:00
Dániel Buga
fe3e9ecc1c
More SHA tweaks (#3934) 2025-08-14 13:54:01 +00:00
Dániel Buga
244ac687b2
I2C: Attempt resolving C6 issue (#3935) 2025-08-14 13:37:04 +00:00
Dániel Buga
8c8062db56
Tweak I2C timeout defaults and stability, fix sw bus clearing (#3926)
* Tweak I2C timeout defaults and stability

* Add some logs

* Set signal levels before releasing GPIOs

* Use a single option for the pins

* Don't use the hardware to detect idle state, stop when device releases SDA
2025-08-13 15:44:46 +00:00
Dániel Buga
2f1a5cc101
Minor, exploratory SHA cleanup (#3931)
* Add sha_dma metadata

* Move SHA interrupt to metadata

* Minor SHA cleanups
2025-08-13 14:23:09 +00:00
Dániel Buga
3a85c6efe4
I2C: ensure that the right future is cancelled (#3929) 2025-08-13 08:28:04 +00:00
Benedikt
961ddea3f7
RMT: Some internal refactorings (#3917)
* RMT: Encapsulate STATE accesses

Abstract away the unsafe AtomicU8 <-> RmtState conversion behind a safe
API. (See the code comments next to the `mod state` fore more details.)

This adds a few methods that are presently unused, but will be in future
PRs.

* RMT: remove unnecessary pub(crate) from *_SIGNAL arrays

* add #[inline] to (un)listen_(rx|tx)_interrupt

Ensure that these methods are always inlined (they probably would be
anyway, but better be sure):
- The `event` argument is usually known, which might allow for more
  optimizations.
- Ideally, the compiler should be able to optimize away any complexity
  that the `EnumSet` might add.

* RMT: inline Rmt::new_internal

given that there's only a single caller since a previous refactoring

* RMT: add test for channel RAM release on Drop

* RMT: macro simplification

- centralize all macros, getting close to a single source of truth for
  the channel specification
- use paste! to avoid some repetitive macro arguments
- replace the tt-muncher by simple repeat patterns: This makes the macro
  much easier to read. It would be possible to combine the
  declare_channels!, declare_rx_channels!, declare_tx_channels! by using
  one big complicated tt-muncher, but the cost in readability of the
  macro seems excessive
- no need for absolute paths in these macros, we're the only user, and
  they're only used at the top level of the module

* RMT:  import crate::gpio to shorten paths

we keep the gpio prefix, since a later commit will also use
gpio::interconnect::{InputSignal, OutputSignal}
2025-08-12 19:15:52 +00:00
Dániel Buga
fab1221894
DMA-enabled work-queue based AES driver (#3897)
* AES-DMA work queue backend

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Clean up manual subslicing

* Don't copy in write_iv

* Add more to why we can use copy_from_nonoverlapping

* Replace buffers with NoBuffer

* Move buffers to backend

* Volatile-ly zero the key

* Make saving state the user's responsibility

* Ensure data is aligned on esp32

* Also make sure the DMA finishes in AesTransfer

* Deduplicate

* Fix paperwork

* Use the handler attribute

* Remove unused method

* Update esp-hal/MIGRATING-1.0.0-rc.0.md

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Fix build after rebase

* Add empty Final to NoBuffer

* Use the move api internally

* Make () the view type

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2025-08-12 12:19:24 +00:00
Juraj Sadel
ca4e28da4a
Don't use OTA partition table in radio examples (#3921) 2025-08-12 07:15:16 +00:00
Dániel Buga
3fb8c54ddd
RSA work queue driver (#3910)
* RSA work queue

* Document, add stop function
2025-08-11 18:53:04 +00:00
Dániel Buga
30b46809c6
Add Final assoctype to DMA buffers (#3923) 2025-08-11 16:28:23 +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
Ulf Lilleengen
a7bd8980ea
chore: update esp-radio dependency on bt-hci (#3920)
* chore: update esp-radio dependency on bt-hci

* Apply suggestion from @playfulFence

Co-authored-by: Kirill Mikhailov <62840029+playfulFence@users.noreply.github.com>

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
Co-authored-by: Kirill Mikhailov <62840029+playfulFence@users.noreply.github.com>
2025-08-11 08:29:16 +00:00
Dániel Buga
e1b8558057
RSA tweaks (#3900)
* RSA tweaks

* Fix copy-pasted typos from esp-idf docs

* Clean up

* Fix doc issues
2025-08-10 12:34:04 +00:00
Dániel Buga
5b24baf904
Implement suspending the work queue (#3919)
* Implement suspending the work queue

* Add test case

* Rename variable

* Fix race condition

* Move imports out
2025-08-10 12:19:26 +00:00
Dániel Buga
66be1e1001
Work queue tweaks (#3916)
* Allow instructing work queue to poll immediately

* Don't expose Poll to the users

* Use NonNull as the VTable data pointer

* Fix cancellation

* Don't scan list for cancelled item, add async cancel

* Remove unnecessary poll fn

* Use a different waker registration in WorkItem

* Require that work items and drivers are Send

* Properly complete completed work item
2025-08-10 08:14:16 +00:00
Dániel Buga
5982222a40
Make mutexes reentrant by default (#3913)
* Make mutexes reentrant by default

* Remove redundant function
2025-08-08 10:09:41 +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
Dániel Buga
e579b1b1be
Implement ADC trait based on metadata (#3911) 2025-08-07 15:16:12 +00:00
exellentcoin26
edcc63a6d0
fix(esp-hal/esp32): Fix switched ADC channel numbers on esp32 (#3908)
* fix(esp-hal): Fix switched ADC channel numbers on esp32

* chore: Update CHANGELOG.md

* chore(esp-hal): Fix switch comments
2025-08-07 14:25:52 +00:00
Dániel Buga
90fb97531c
Make metadata macros available even for build scripts (#3906) 2025-08-07 11:03:47 +00:00
Björn Quentin
d0a2d49565
Make sure tagged isr callback pointers don't get accidentally called (#3885)
* Make sure tagged isr callback pointers don't get accidentally called

* Changelog and MG

* Honor ESP32-S2's special needs

* Address review comments
2025-08-07 10:41:48 +00:00
Björn Quentin
52790613d2
Don't fail on long strings (#3905)
* Don't fail on long strings

* CHANGELOG.md
2025-08-07 10:32:03 +00:00
Björn Quentin
46fd87347a
Don't panic in build.rs when using RA with rustc-wrapper (#3904) 2025-08-06 19:21:04 +00:00
Björn Quentin
4dac7bafe2
RISCV: Don't pass TrapFrame into interrupt handlers (#3903)
* RISCV: Don't pass TrapFrame into interrupt handlers

* CHANGELOG.md

* Fix

* Remove the fake-trapframe
2025-08-06 13:44:13 +00:00
Dániel Buga
70e2b3d435
Fix FlashRegion capacity (#3902) 2025-08-06 08:43:05 +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
Dániel Buga
97cc5e4d7a
Fix AES issues, clean up API (#3895) 2025-08-05 07:25:39 +00:00
Dániel Buga
351dcfd367
Fix indexing (#3896) 2025-08-04 09:11:49 +00:00
Dániel Buga
3ec26ead9d
Crypto work queue [AES] (#3880)
* Implement a generic work queue

* Implement AES work queue backend with software block modes

* Move tail after enqueueing

* Use NonNull more liberally

* Tweak the queue a bit

* Merge the AES-DMA test into the AES test suite

* Drop AesFlavour

* Document things

* Stop the driver when its handle is dropped

* Fix docs

* Address some correctness concerns
2025-08-01 08:45:36 +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
Björn Quentin
dfd66be8ab
Simplify riscv trap handler (#3875)
* use `riscv::interrupt::nested` for nesting

* Only save/restore caller saved registers in trap-frame (risc-v)

* Replace RISC-V scheduler

* Cleanup

* Clippy

* CHANGELOG.md

* Make sure to reset the runlevel to current, not prio-1

* Clippy

* Fix it for real

* Address review comments

* Address review comments

* More docs, optimize away one instruction

* Address review comments

* Address review comments

* Use a bool for the nested flag again

* Fix

* Clippy
2025-07-30 18:31:05 +00:00
Benedikt
3c21662606
RMT: Refactor state checks, support non-blocking poll on blocking transactions (#3716)
* RMT: add get_tx_status, get_rx_status methods

Unused right now; these methods allow to look at all flags without several
volatile reads (in contrast to calling is_tx_done/is_rx_done,
is_tx_threshold_set, is_error individually). `match`ing on their result
leads to very idiomatic code, and also result in blocking and async code
that is very similar.

The #[inline] attribute might not be required, but better be sure: We
really don't want the Option<Event> to actually be constructed, but
rather that the compiler completely optimized it away in favor of direct
bit tests in the calling function.

* RMT: optimize RmtTxFuture to avoid repeated register reads

* RMT: optimize RmtRxFuture to avoid repeated register reads

* RMT: Optimize ContinuousTxTransaction by avoiding repeated register reads

* RMT: Optimize/simplify SingleShotTxTransaction (1/2)

by merging two loops into one

* RMT: Optimize/simplify SingleShotTxTransaction (2/2)

by avoiding repeated register reads

* RMT: add poll() method to blocking transactions

This allows properly interleaving several such transactions (as the HIL
loopback tests do, in fact) or other work.

Regarding the implementation of the place_rmt_driver_in_ram feature for these
methods, note that `#[ram]` implies `[inline(never)]`.

Thus, this uses `#[inline(always)]` for `poll` and `wait` in that case,
which are rather simple methods.
If putting them in ram actually matters, the calling user code should
probably be placed in ram as well, and then, forced inlining of both
methods should have the desired effect.

`poll_internal` in turn
- contains more code and is called from `poll` and `wait`
	-> it seems sensible that it is not inlined to reduce code size.
- includes the hot loop that copies to the hardware buffer
	-> should be forced to ram
so `#[ram]` makes sense.

Note that none of this was benchmarked.

* RMT: Remove unused low-level methods

Their use has entirely be replaced by get_tx_status and get_rx_status
2025-07-30 18:28:08 +00:00
Dániel Buga
e0b3eb429d
Don't use defmt in ble tests (#3883) 2025-07-30 16:29:16 +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
Juraj Sadel
52831f7c0e
Move Bytes behing ieee802154 feature and make it pub(crate) (#3874) 2025-07-30 15:02:59 +00:00
Dániel Buga
406056ab9c
Midterm AES rework (#3882)
* Midterm AES rework

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

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Update esp-hal/MIGRATING-1.0.0-rc.0.md

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Panic on wrong size

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2025-07-30 15:02:12 +00:00
Kirill Mikhailov
e1917abf9f
esp32: Block ADC2 usage simultaneously with radio (#3876)
* block `ADC2` usage simultaneously with radio (esp32)

* implement `Drop` for `ADC2` (esp32)

fmt

format

* multiple fixes

* make functions internal, lint package

* Cleanup

* use `fetch_or` instead

* take it easy
2025-07-30 12:44:16 +00:00