rust-exercises
rust-exercises copied to clipboard
HAL migration to embassy-nrf for radio, hal-app and USB exercise
This might simplify adding async trainings in the future. The radio module is still custom written to remain synchronous and builds on the nrf-pac. I tested the radio binaries as well.
Deploying ferrous-systems-rust-exercises with
Cloudflare Pages
| Latest commit: |
2ff7bf6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://32b24f7c.ferrous-systems-rust-exercises.pages.dev |
| Branch Preview URL: | https://try-hal-migration.ferrous-systems-rust-exercises.pages.dev |
The only missing feature which requires a fork: https://github.com/embassy-rs/embassy/pull/4700
I'll take a look at this on Friday, hopefully
The only missing feature which requires a fork: embassy-rs/embassy#4700
Is this now in embassy-nrf-v0.8.0?
Can you re-do this PR so that instead of a new crate called dk-migration, we replace the existing dk crate with an embassy based one? That would make it easier to see the diff (and if we did merge the PR and make the change, we probably wouldn't want two copies of the DK crate).
It would also be useful to see how easily the dongle firmware can be ported over?
It might be that the radio driver needs to go into a separate radio crate that dk and dongle can both import/re-export - to save writing it twice.
I think I also did this because there are other components like the USB training which rely on dk as well. Adding a second dk crate allows a partial migration. So I either would have to look into porting everything at once (might actually not be that difficult), or accept breakage of those modules when doing a full replace.
Is this now in embassy-nrf-v0.8.0?
Yes, and that release contains a few other goodies as well (e.g. generic removal on the timer structure)
I had a look at the USB modules. It is not too much. should be possible to migrate that with reasonable effort as well.
I ported the USB code as well, and I updated the HAL exercise with the buttons.
Should we keep the dongle FW port as a separate PR?
Should we keep the dongle FW port as a separate PR?
yes, the dongle uses a different BSP and so it can move to embassy-nrf on its own schedule.
I resolved some smaller stuff. Ready for review now :)
I added a notice and the relevant license sections from the nrf52840 HAL.
- When I run radio-puzzle-solution I no longer see the radio packets on the defmt log. Can we add those back in?
For which log level? I just tried running both main and this branch with debug log level, and I see exchanged packets for both versions.
00:00:00.946258 [DEBUG] TX: [e9, 2e, 1b, 27, 20, d0, 7f] (dk dk/src/lib.rs:255)
00:00:00.948516 [DEBUG] RX: [e9, 2e, 1b, 27, 20, d0, 00] (dk dk/src/lib.rs:259)
00:00:00.948608 [DEBUG] OK: [00] (dk dk/src/lib.rs:263)
00:00:00.953674 [DEBUG] TX: [e9, 2e, 1b, 27, 20, d0] (dk dk/src/lib.rs:255)
00:00:00.956634 [DEBUG] RX: [e9, 2e, 1b, 27, 20, d0, 77, 4f, 25, 22, 3f, 25, 22, 3f, 49, 7b, 3f, 39, 28, 49, 41, 7d, 74, 39, 3f, 41, 39, 22, 22, 49, 32, 39] (dk dk/src/lib.rs:259)
00:00:00.956817 [DEBUG] OK: [77, 4f, 25, 22, 3f, 25, 22, 3f, 49, 7b, 3f, 39, 28, 49, 41, 7d, 74, 39, 3f, 41, 39, 22, 22, 49, 32, 39] (dk dk/src/lib.rs:263)
ciphertext: wO%"?%"?I{?9(IA}t9?A9""I29
plaintext: This is an example message
00:00:00.962677 [DEBUG] TX: [e9, 2e, 1b, 27, 20, d0, 54, 68, 69, 73, 20, 69, 73, 20, 61, 6e, 20, 65, 78, 61, 6d, 70, 6c, 65, 20, 6d, 65, 73, 73, 61, 67, 65] (dk dk/src/lib.rs:255)
00:00:00.966125 [DEBUG] RX: [e9, 2e, 1b, 27, 20, d0, 63, 6f, 72, 72, 65, 63, 74] (dk dk/src/lib.rs:259)
00:00:00.966217 [DEBUG] OK: [63, 6f, 72, 72, 65, 63, 74] (dk dk/src/lib.rs:263)
Dongle response: correct
`dk::exit()` called; exiting ...
Firmware exited successfully
rust-exercises/nrf52-code/radio-app on try-hal-migration [$] is 📦 v0.0.0 via 🦀 v1.91.0 took 5s
- Is there any text in the exercise workbook that is now wrong because of these changes? I'd like to update that text at the same time as the examples change, so we don't get them out of sync.
This migration basically doesn't change anything for the radio exercise materials because only the underlying PAC was changed. I went through the book again but did not find anything so far.
I tested all the solutions on hardware and they look good.
I have some patches to clean up the USB exercise, which I will do separately.