diff --git a/flake.nix b/flake.nix index a45cc17..5c96c60 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,8 @@ arm-none-eabi-gcc --version | head -n1 echo "cargo build --release --target thumbv8m.main-none-eabihf" echo "cargo flash --release --chip STM32U575ZI" + echo "export DEFMT_LOG=info" + echo "cargo run --bin main" echo "probe-rs run --chip STM32U575ZITxQ target/thumbv8m.main-none-eabihf/release/main" ''; }; diff --git a/hal_rng/Cargo.lock b/hal_rng/Cargo.lock index 0da36eb..dfd24ee 100644 --- a/hal_rng/Cargo.lock +++ b/hal_rng/Cargo.lock @@ -178,6 +178,15 @@ dependencies = [ "syn 2.0.107", ] +[[package]] +name = "defmt" +version = "0.3.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0963443817029b2024136fc4dd07a5107eb8f977eaf18fcd1fdeb11306b64ad" +dependencies = [ + "defmt 1.0.1", +] + [[package]] name = "defmt" version = "1.0.1" @@ -217,7 +226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93d5a25c99d89c40f5676bec8cefe0614f17f0f40e916f98e345dae941807f9e" dependencies = [ "critical-section", - "defmt", + "defmt 1.0.1", ] [[package]] @@ -235,6 +244,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "554e3e840696f54b4c9afcf28a0f24da431c927f4151040020416e7393d6d0d8" dependencies = [ + "defmt 1.0.1", "embassy-futures", "embassy-hal-internal", "embassy-sync", @@ -292,6 +302,7 @@ checksum = "95285007a91b619dc9f26ea8f55452aa6c60f7115a4edc05085cd2bd3127cd7a" dependencies = [ "cortex-m", "critical-section", + "defmt 1.0.1", "num-traits", ] @@ -300,6 +311,9 @@ name = "embassy-net-driver" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" +dependencies = [ + "defmt 0.3.100", +] [[package]] name = "embassy-net-driver-channel" @@ -326,6 +340,7 @@ dependencies = [ "cortex-m", "cortex-m-rt", "critical-section", + "defmt 1.0.1", "document-features", "embassy-embedded-hal", "embassy-futures", @@ -368,6 +383,7 @@ checksum = "73974a3edbd0bd286759b3d483540f0ebef705919a5f56f4fc7709066f71689b" dependencies = [ "cfg-if", "critical-section", + "defmt 1.0.1", "embedded-io-async", "futures-core", "futures-sink", @@ -382,6 +398,7 @@ checksum = "f4fa65b9284d974dad7a23bb72835c4ec85c0b540d86af7fc4098c88cff51d65" dependencies = [ "cfg-if", "critical-section", + "defmt 1.0.1", "document-features", "embassy-time-driver", "embedded-hal 0.2.7", @@ -431,6 +448,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17119855ccc2d1f7470a39756b12068454ae27a3eabb037d940b5c03d9c77b7a" dependencies = [ + "defmt 1.0.1", "embedded-io-async", ] @@ -441,6 +459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "288751f8eaa44a5cf2613f13cee0ca8e06e6638cb96e897e6834702c79084b23" dependencies = [ "critical-section", + "defmt 1.0.1", "embassy-sync", "embassy-usb-driver", ] @@ -517,6 +536,9 @@ name = "embedded-io" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" +dependencies = [ + "defmt 0.3.100", +] [[package]] name = "embedded-io-async" @@ -524,6 +546,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" dependencies = [ + "defmt 0.3.100", "embedded-io", ] @@ -599,7 +622,7 @@ version = "0.1.0" dependencies = [ "cortex-m", "cortex-m-rt", - "defmt", + "defmt 1.0.1", "defmt-rtt", "embassy-executor", "embassy-futures", @@ -721,7 +744,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd402d00b0fb94c5aee000029204a46884b1262e0c443f166d86d2c0747e1a1a" dependencies = [ "cortex-m", - "defmt", + "defmt 1.0.1", ] [[package]] @@ -892,6 +915,7 @@ checksum = "6fd8ec3a292a0d9fc4798416a61b21da5ae50341b2e7b8d12e662bf305366097" dependencies = [ "cortex-m", "cortex-m-rt", + "defmt 0.3.100", ] [[package]] diff --git a/hal_rng/Cargo.toml b/hal_rng/Cargo.toml index 9078052..7b606c3 100644 --- a/hal_rng/Cargo.toml +++ b/hal_rng/Cargo.toml @@ -12,7 +12,7 @@ panic-halt = "1.0.0" embassy-executor = { version = "0.9.1", features = ["arch-cortex-m", "executor-thread"] } embassy-futures = "0.1.2" -embassy-stm32 = { version = "0.4.0", features = ["unstable-pac", "stm32u575zi", "time-driver-any", "memory-x"] } +embassy-stm32 = { version = "0.4.0", features = ["unstable-pac", "stm32u575zi", "time-driver-any", "memory-x", "defmt"] } embassy-sync = "0.7.2" embassy-time = { version = "0.5.0", features = ["tick-hz-32_768"] } embassy-usb = "0.5.1" diff --git a/hal_rng/src/bin/main.rs b/hal_rng/src/bin/main.rs index f1baf52..df31b1d 100644 --- a/hal_rng/src/bin/main.rs +++ b/hal_rng/src/bin/main.rs @@ -3,10 +3,11 @@ #![no_std] #![no_main] +use defmt::*; use embassy_executor::Spawner; use embassy_stm32::rng::Rng; use embassy_stm32::{bind_interrupts, peripherals, rng}; -use panic_probe as _; +use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { RNG => rng::InterruptHandler; @@ -16,7 +17,11 @@ bind_interrupts!(struct Irqs { async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); + info!("Hello World!"); + let mut rng = Rng::new(p.RNG, Irqs); let mut buf = [0u8; 16]; + unwrap!(rng.async_fill_bytes(&mut buf).await); + info!("random bytes: {:02x}", buf); } diff --git a/hal_rng/src/lib.rs b/hal_rng/src/lib.rs new file mode 100644 index 0000000..0c9ac1a --- /dev/null +++ b/hal_rng/src/lib.rs @@ -0,0 +1 @@ +#![no_std]