diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-05-18 20:32:48 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-05-18 20:35:36 +0200 |
| commit | e4fc48764491f8981e4a145a72e9b6e72df8c546 (patch) | |
| tree | cac023f3457123f2fbc7686f2f90414987eae264 | |
| parent | e8b1ea14c7fb151aa5e296ca8f9724f175bdeaef (diff) | |
Add rand-core v0.9 support.
Co-Authored-By: Aurélien Jacobs <[email protected]>
63 files changed, 218 insertions, 122 deletions
diff --git a/embassy-imxrt/Cargo.toml b/embassy-imxrt/Cargo.toml index f16002a8d..d8cf3aaba 100644 --- a/embassy-imxrt/Cargo.toml +++ b/embassy-imxrt/Cargo.toml | |||
| @@ -80,9 +80,11 @@ cortex-m = "0.7.6" | |||
| 80 | critical-section = "1.1" | 80 | critical-section = "1.1" |
| 81 | embedded-io = { version = "0.6.1" } | 81 | embedded-io = { version = "0.6.1" } |
| 82 | embedded-io-async = { version = "0.6.1" } | 82 | embedded-io-async = { version = "0.6.1" } |
| 83 | rand_core = "0.6.4" | ||
| 84 | fixed = "1.23.1" | 83 | fixed = "1.23.1" |
| 85 | 84 | ||
| 85 | rand-core-06 = { package = "rand_core", version = "0.6" } | ||
| 86 | rand-core-09 = { package = "rand_core", version = "0.9" } | ||
| 87 | |||
| 86 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ | 88 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ |
| 87 | "unproven", | 89 | "unproven", |
| 88 | ] } | 90 | ] } |
diff --git a/embassy-imxrt/src/rng.rs b/embassy-imxrt/src/rng.rs index 67e7ab65d..75f243df9 100644 --- a/embassy-imxrt/src/rng.rs +++ b/embassy-imxrt/src/rng.rs | |||
| @@ -6,7 +6,6 @@ use core::task::Poll; | |||
| 6 | 6 | ||
| 7 | use embassy_futures::block_on; | 7 | use embassy_futures::block_on; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use rand_core::{CryptoRng, RngCore}; | ||
| 10 | 9 | ||
| 11 | use crate::clocks::{enable_and_reset, SysconPeripheral}; | 10 | use crate::clocks::{enable_and_reset, SysconPeripheral}; |
| 12 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| @@ -201,32 +200,63 @@ impl<'d> Rng<'d> { | |||
| 201 | .mctl() | 200 | .mctl() |
| 202 | .modify(|_, w| w.trng_acc().set_bit().prgm().clear_bit()); | 201 | .modify(|_, w| w.trng_acc().set_bit().prgm().clear_bit()); |
| 203 | } | 202 | } |
| 204 | } | ||
| 205 | 203 | ||
| 206 | impl RngCore for Rng<'_> { | 204 | /// Generate a random u32 |
| 207 | fn next_u32(&mut self) -> u32 { | 205 | pub fn blocking_next_u32(&mut self) -> u32 { |
| 208 | let mut bytes = [0u8; 4]; | 206 | let mut bytes = [0u8; 4]; |
| 209 | block_on(self.async_fill_bytes(&mut bytes)).unwrap(); | 207 | block_on(self.async_fill_bytes(&mut bytes)).unwrap(); |
| 210 | u32::from_ne_bytes(bytes) | 208 | u32::from_ne_bytes(bytes) |
| 211 | } | 209 | } |
| 212 | 210 | ||
| 213 | fn next_u64(&mut self) -> u64 { | 211 | /// Generate a random u64 |
| 212 | pub fn blocking_next_u64(&mut self) -> u64 { | ||
| 214 | let mut bytes = [0u8; 8]; | 213 | let mut bytes = [0u8; 8]; |
| 215 | block_on(self.async_fill_bytes(&mut bytes)).unwrap(); | 214 | block_on(self.async_fill_bytes(&mut bytes)).unwrap(); |
| 216 | u64::from_ne_bytes(bytes) | 215 | u64::from_ne_bytes(bytes) |
| 217 | } | 216 | } |
| 218 | 217 | ||
| 219 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 218 | /// Fill a slice with random bytes. |
| 219 | pub fn blocking_fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 220 | block_on(self.async_fill_bytes(dest)).unwrap(); | 220 | block_on(self.async_fill_bytes(dest)).unwrap(); |
| 221 | } | 221 | } |
| 222 | } | ||
| 222 | 223 | ||
| 223 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | 224 | impl<'d> rand_core_06::RngCore for Rng<'d> { |
| 224 | self.fill_bytes(dest); | 225 | fn next_u32(&mut self) -> u32 { |
| 226 | self.blocking_next_u32() | ||
| 227 | } | ||
| 228 | |||
| 229 | fn next_u64(&mut self) -> u64 { | ||
| 230 | self.blocking_next_u64() | ||
| 231 | } | ||
| 232 | |||
| 233 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 234 | self.blocking_fill_bytes(dest); | ||
| 235 | } | ||
| 236 | |||
| 237 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_06::Error> { | ||
| 238 | self.blocking_fill_bytes(dest); | ||
| 225 | Ok(()) | 239 | Ok(()) |
| 226 | } | 240 | } |
| 227 | } | 241 | } |
| 228 | 242 | ||
| 229 | impl CryptoRng for Rng<'_> {} | 243 | impl<'d> rand_core_06::CryptoRng for Rng<'d> {} |
| 244 | |||
| 245 | impl<'d> rand_core_09::RngCore for Rng<'d> { | ||
| 246 | fn next_u32(&mut self) -> u32 { | ||
| 247 | self.blocking_next_u32() | ||
| 248 | } | ||
| 249 | |||
| 250 | fn next_u64(&mut self) -> u64 { | ||
| 251 | self.blocking_next_u64() | ||
| 252 | } | ||
| 253 | |||
| 254 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 255 | self.blocking_fill_bytes(dest); | ||
| 256 | } | ||
| 257 | } | ||
| 258 | |||
| 259 | impl<'d> rand_core_09::CryptoRng for Rng<'d> {} | ||
| 230 | 260 | ||
| 231 | struct Info { | 261 | struct Info { |
| 232 | regs: crate::pac::Trng, | 262 | regs: crate::pac::Trng, |
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 6ca099599..e4e143c65 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -154,6 +154,9 @@ embedded-hal-async = { version = "1.0" } | |||
| 154 | embedded-io = { version = "0.6.0" } | 154 | embedded-io = { version = "0.6.0" } |
| 155 | embedded-io-async = { version = "0.6.1" } | 155 | embedded-io-async = { version = "0.6.1" } |
| 156 | 156 | ||
| 157 | rand-core-06 = { package = "rand_core", version = "0.6" } | ||
| 158 | rand-core-09 = { package = "rand_core", version = "0.9" } | ||
| 159 | |||
| 157 | nrf-pac = "0.1.0" | 160 | nrf-pac = "0.1.0" |
| 158 | 161 | ||
| 159 | defmt = { version = "0.3", optional = true } | 162 | defmt = { version = "0.3", optional = true } |
| @@ -162,7 +165,6 @@ log = { version = "0.4.14", optional = true } | |||
| 162 | cortex-m-rt = ">=0.6.15,<0.8" | 165 | cortex-m-rt = ">=0.6.15,<0.8" |
| 163 | cortex-m = "0.7.6" | 166 | cortex-m = "0.7.6" |
| 164 | critical-section = "1.1" | 167 | critical-section = "1.1" |
| 165 | rand_core = "0.6.3" | ||
| 166 | fixed = "1.10.0" | 168 | fixed = "1.10.0" |
| 167 | embedded-storage = "0.3.1" | 169 | embedded-storage = "0.3.1" |
| 168 | embedded-storage-async = "0.4.1" | 170 | embedded-storage-async = "0.4.1" |
diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index e75ffda00..7e42dc938 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs | |||
| @@ -167,6 +167,21 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 167 | 167 | ||
| 168 | self.stop(); | 168 | self.stop(); |
| 169 | } | 169 | } |
| 170 | |||
| 171 | /// Generate a random u32 | ||
| 172 | pub fn blocking_next_u32(&mut self) -> u32 { | ||
| 173 | let mut bytes = [0; 4]; | ||
| 174 | self.blocking_fill_bytes(&mut bytes); | ||
| 175 | // We don't care about the endianness, so just use the native one. | ||
| 176 | u32::from_ne_bytes(bytes) | ||
| 177 | } | ||
| 178 | |||
| 179 | /// Generate a random u64 | ||
| 180 | pub fn blocking_next_u64(&mut self) -> u64 { | ||
| 181 | let mut bytes = [0; 8]; | ||
| 182 | self.blocking_fill_bytes(&mut bytes); | ||
| 183 | u64::from_ne_bytes(bytes) | ||
| 184 | } | ||
| 170 | } | 185 | } |
| 171 | 186 | ||
| 172 | impl<'d, T: Instance> Drop for Rng<'d, T> { | 187 | impl<'d, T: Instance> Drop for Rng<'d, T> { |
| @@ -180,31 +195,37 @@ impl<'d, T: Instance> Drop for Rng<'d, T> { | |||
| 180 | } | 195 | } |
| 181 | } | 196 | } |
| 182 | 197 | ||
| 183 | impl<'d, T: Instance> rand_core::RngCore for Rng<'d, T> { | 198 | impl<'d, T: Instance> rand_core_06::RngCore for Rng<'d, T> { |
| 184 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 199 | fn fill_bytes(&mut self, dest: &mut [u8]) { |
| 185 | self.blocking_fill_bytes(dest); | 200 | self.blocking_fill_bytes(dest); |
| 186 | } | 201 | } |
| 187 | |||
| 188 | fn next_u32(&mut self) -> u32 { | 202 | fn next_u32(&mut self) -> u32 { |
| 189 | let mut bytes = [0; 4]; | 203 | self.blocking_next_u32() |
| 190 | self.blocking_fill_bytes(&mut bytes); | ||
| 191 | // We don't care about the endianness, so just use the native one. | ||
| 192 | u32::from_ne_bytes(bytes) | ||
| 193 | } | 204 | } |
| 194 | |||
| 195 | fn next_u64(&mut self) -> u64 { | 205 | fn next_u64(&mut self) -> u64 { |
| 196 | let mut bytes = [0; 8]; | 206 | self.blocking_next_u64() |
| 197 | self.blocking_fill_bytes(&mut bytes); | ||
| 198 | u64::from_ne_bytes(bytes) | ||
| 199 | } | 207 | } |
| 200 | 208 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_06::Error> { | |
| 201 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | ||
| 202 | self.blocking_fill_bytes(dest); | 209 | self.blocking_fill_bytes(dest); |
| 203 | Ok(()) | 210 | Ok(()) |
| 204 | } | 211 | } |
| 205 | } | 212 | } |
| 206 | 213 | ||
| 207 | impl<'d, T: Instance> rand_core::CryptoRng for Rng<'d, T> {} | 214 | impl<'d, T: Instance> rand_core_06::CryptoRng for Rng<'d, T> {} |
| 215 | |||
| 216 | impl<'d, T: Instance> rand_core_09::RngCore for Rng<'d, T> { | ||
| 217 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 218 | self.blocking_fill_bytes(dest); | ||
| 219 | } | ||
| 220 | fn next_u32(&mut self) -> u32 { | ||
| 221 | self.blocking_next_u32() | ||
| 222 | } | ||
| 223 | fn next_u64(&mut self) -> u64 { | ||
| 224 | self.blocking_next_u64() | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | impl<'d, T: Instance> rand_core_09::CryptoRng for Rng<'d, T> {} | ||
| 208 | 229 | ||
| 209 | /// Peripheral static state | 230 | /// Peripheral static state |
| 210 | pub(crate) struct State { | 231 | pub(crate) struct State { |
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 8fb8a50fd..849cb549a 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -157,7 +157,6 @@ embedded-io = { version = "0.6.1" } | |||
| 157 | embedded-io-async = { version = "0.6.1" } | 157 | embedded-io-async = { version = "0.6.1" } |
| 158 | embedded-storage = { version = "0.3" } | 158 | embedded-storage = { version = "0.3" } |
| 159 | embedded-storage-async = { version = "0.4.1" } | 159 | embedded-storage-async = { version = "0.4.1" } |
| 160 | rand_core = "0.6.4" | ||
| 161 | fixed = "1.28.0" | 160 | fixed = "1.28.0" |
| 162 | 161 | ||
| 163 | rp-pac = { version = "7.0.0" } | 162 | rp-pac = { version = "7.0.0" } |
| @@ -167,6 +166,9 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | |||
| 167 | embedded-hal-async = { version = "1.0" } | 166 | embedded-hal-async = { version = "1.0" } |
| 168 | embedded-hal-nb = { version = "1.0" } | 167 | embedded-hal-nb = { version = "1.0" } |
| 169 | 168 | ||
| 169 | rand-core-06 = { package = "rand_core", version = "0.6" } | ||
| 170 | rand-core-09 = { package = "rand_core", version = "0.9" } | ||
| 171 | |||
| 170 | pio = { version = "0.3" } | 172 | pio = { version = "0.3" } |
| 171 | rp2040-boot2 = "0.3" | 173 | rp2040-boot2 = "0.3" |
| 172 | document-features = "0.2.10" | 174 | document-features = "0.2.10" |
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs index 857877680..d79bffab3 100644 --- a/embassy-rp/src/clocks.rs +++ b/embassy-rp/src/clocks.rs | |||
| @@ -1776,7 +1776,8 @@ impl<'d, T: GpoutPin> Drop for Gpout<'d, T> { | |||
| 1776 | pub struct RoscRng; | 1776 | pub struct RoscRng; |
| 1777 | 1777 | ||
| 1778 | impl RoscRng { | 1778 | impl RoscRng { |
| 1779 | fn next_u8() -> u8 { | 1779 | /// Get a random u8 |
| 1780 | pub fn next_u8() -> u8 { | ||
| 1780 | let random_reg = pac::ROSC.randombit(); | 1781 | let random_reg = pac::ROSC.randombit(); |
| 1781 | let mut acc = 0; | 1782 | let mut acc = 0; |
| 1782 | for _ in 0..u8::BITS { | 1783 | for _ in 0..u8::BITS { |
| @@ -1785,26 +1786,60 @@ impl RoscRng { | |||
| 1785 | } | 1786 | } |
| 1786 | acc | 1787 | acc |
| 1787 | } | 1788 | } |
| 1789 | |||
| 1790 | /// Get a random u32 | ||
| 1791 | pub fn next_u32(&mut self) -> u32 { | ||
| 1792 | rand_core_09::impls::next_u32_via_fill(self) | ||
| 1793 | } | ||
| 1794 | |||
| 1795 | /// Get a random u64 | ||
| 1796 | pub fn next_u64(&mut self) -> u64 { | ||
| 1797 | rand_core_09::impls::next_u64_via_fill(self) | ||
| 1798 | } | ||
| 1799 | |||
| 1800 | /// Fill a slice with random bytes | ||
| 1801 | pub fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 1802 | dest.fill_with(Self::next_u8) | ||
| 1803 | } | ||
| 1788 | } | 1804 | } |
| 1789 | 1805 | ||
| 1790 | impl rand_core::RngCore for RoscRng { | 1806 | impl rand_core_06::RngCore for RoscRng { |
| 1791 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | 1807 | fn next_u32(&mut self) -> u32 { |
| 1792 | Ok(self.fill_bytes(dest)) | 1808 | self.next_u32() |
| 1809 | } | ||
| 1810 | |||
| 1811 | fn next_u64(&mut self) -> u64 { | ||
| 1812 | self.next_u64() | ||
| 1813 | } | ||
| 1814 | |||
| 1815 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 1816 | self.fill_bytes(dest); | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_06::Error> { | ||
| 1820 | self.fill_bytes(dest); | ||
| 1821 | Ok(()) | ||
| 1793 | } | 1822 | } |
| 1823 | } | ||
| 1824 | |||
| 1825 | impl rand_core_06::CryptoRng for RoscRng {} | ||
| 1794 | 1826 | ||
| 1827 | impl rand_core_09::RngCore for RoscRng { | ||
| 1795 | fn next_u32(&mut self) -> u32 { | 1828 | fn next_u32(&mut self) -> u32 { |
| 1796 | rand_core::impls::next_u32_via_fill(self) | 1829 | self.next_u32() |
| 1797 | } | 1830 | } |
| 1798 | 1831 | ||
| 1799 | fn next_u64(&mut self) -> u64 { | 1832 | fn next_u64(&mut self) -> u64 { |
| 1800 | rand_core::impls::next_u64_via_fill(self) | 1833 | self.next_u64() |
| 1801 | } | 1834 | } |
| 1802 | 1835 | ||
| 1803 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 1836 | fn fill_bytes(&mut self, dest: &mut [u8]) { |
| 1804 | dest.fill_with(Self::next_u8) | 1837 | self.fill_bytes(dest); |
| 1805 | } | 1838 | } |
| 1806 | } | 1839 | } |
| 1807 | 1840 | ||
| 1841 | impl rand_core_09::CryptoRng for RoscRng {} | ||
| 1842 | |||
| 1808 | /// Enter the `DORMANT` sleep state. This will stop *all* internal clocks | 1843 | /// Enter the `DORMANT` sleep state. This will stop *all* internal clocks |
| 1809 | /// and can only be exited through resets, dormant-wake GPIO interrupts, | 1844 | /// and can only be exited through resets, dormant-wake GPIO interrupts, |
| 1810 | /// and RTC interrupts. If RTC is clocked from an internal clock source | 1845 | /// and RTC interrupts. If RTC is clocked from an internal clock source |
diff --git a/embassy-rp/src/trng.rs b/embassy-rp/src/trng.rs index a8a0172be..a3f23c1f2 100644 --- a/embassy-rp/src/trng.rs +++ b/embassy-rp/src/trng.rs | |||
| @@ -7,7 +7,6 @@ use core::task::Poll; | |||
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use rand_core::Error; | ||
| 11 | 10 | ||
| 12 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 11 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 13 | use crate::peripherals::TRNG; | 12 | use crate::peripherals::TRNG; |
| @@ -369,7 +368,7 @@ impl<'d, T: Instance> Trng<'d, T> { | |||
| 369 | } | 368 | } |
| 370 | } | 369 | } |
| 371 | 370 | ||
| 372 | impl<'d, T: Instance> rand_core::RngCore for Trng<'d, T> { | 371 | impl<'d, T: Instance> rand_core_06::RngCore for Trng<'d, T> { |
| 373 | fn next_u32(&mut self) -> u32 { | 372 | fn next_u32(&mut self) -> u32 { |
| 374 | self.blocking_next_u32() | 373 | self.blocking_next_u32() |
| 375 | } | 374 | } |
| @@ -379,16 +378,32 @@ impl<'d, T: Instance> rand_core::RngCore for Trng<'d, T> { | |||
| 379 | } | 378 | } |
| 380 | 379 | ||
| 381 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 380 | fn fill_bytes(&mut self, dest: &mut [u8]) { |
| 382 | self.blocking_fill_bytes(dest) | 381 | self.blocking_fill_bytes(dest); |
| 383 | } | 382 | } |
| 384 | 383 | ||
| 385 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { | 384 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_06::Error> { |
| 386 | self.blocking_fill_bytes(dest); | 385 | self.blocking_fill_bytes(dest); |
| 387 | Ok(()) | 386 | Ok(()) |
| 388 | } | 387 | } |
| 389 | } | 388 | } |
| 390 | 389 | ||
| 391 | impl<'d, T: Instance> rand_core::CryptoRng for Trng<'d, T> {} | 390 | impl<'d, T: Instance> rand_core_06::CryptoRng for Trng<'d, T> {} |
| 391 | |||
| 392 | impl<'d, T: Instance> rand_core_09::RngCore for Trng<'d, T> { | ||
| 393 | fn next_u32(&mut self) -> u32 { | ||
| 394 | self.blocking_next_u32() | ||
| 395 | } | ||
| 396 | |||
| 397 | fn next_u64(&mut self) -> u64 { | ||
| 398 | self.blocking_next_u64() | ||
| 399 | } | ||
| 400 | |||
| 401 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 402 | self.blocking_fill_bytes(dest); | ||
| 403 | } | ||
| 404 | } | ||
| 405 | |||
| 406 | impl<'d, T: Instance> rand_core_09::CryptoRng for Trng<'d, T> {} | ||
| 392 | 407 | ||
| 393 | /// TRNG interrupt handler. | 408 | /// TRNG interrupt handler. |
| 394 | pub struct InterruptHandler<T: Instance> { | 409 | pub struct InterruptHandler<T: Instance> { |
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 972307bec..35c1291fd 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -63,13 +63,15 @@ embedded-can = "0.4" | |||
| 63 | embedded-storage = "0.3.1" | 63 | embedded-storage = "0.3.1" |
| 64 | embedded-storage-async = { version = "0.4.1" } | 64 | embedded-storage-async = { version = "0.4.1" } |
| 65 | 65 | ||
| 66 | rand-core-06 = { package = "rand_core", version = "0.6" } | ||
| 67 | rand-core-09 = { package = "rand_core", version = "0.9" } | ||
| 68 | |||
| 66 | 69 | ||
| 67 | defmt = { version = "0.3", optional = true } | 70 | defmt = { version = "0.3", optional = true } |
| 68 | log = { version = "0.4.14", optional = true } | 71 | log = { version = "0.4.14", optional = true } |
| 69 | cortex-m-rt = ">=0.6.15,<0.8" | 72 | cortex-m-rt = ">=0.6.15,<0.8" |
| 70 | cortex-m = "0.7.6" | 73 | cortex-m = "0.7.6" |
| 71 | futures-util = { version = "0.3.30", default-features = false } | 74 | futures-util = { version = "0.3.30", default-features = false } |
| 72 | rand_core = "0.6.3" | ||
| 73 | sdio-host = "0.9.0" | 75 | sdio-host = "0.9.0" |
| 74 | critical-section = "1.1" | 76 | critical-section = "1.1" |
| 75 | #stm32-metapac = { version = "16" } | 77 | #stm32-metapac = { version = "16" } |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 8fa1b3a9d..312f343b9 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -7,7 +7,6 @@ use core::task::Poll; | |||
| 7 | 7 | ||
| 8 | use embassy_hal_internal::PeripheralType; | 8 | use embassy_hal_internal::PeripheralType; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use rand_core::{CryptoRng, RngCore}; | ||
| 11 | 10 | ||
| 12 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 13 | use crate::{interrupt, pac, peripherals, rcc, Peri}; | 12 | use crate::{interrupt, pac, peripherals, rcc, Peri}; |
| @@ -184,19 +183,9 @@ impl<'d, T: Instance> Rng<'d, T> { | |||
| 184 | 183 | ||
| 185 | Ok(()) | 184 | Ok(()) |
| 186 | } | 185 | } |
| 187 | } | ||
| 188 | |||
| 189 | impl<'d, T: Instance> Drop for Rng<'d, T> { | ||
| 190 | fn drop(&mut self) { | ||
| 191 | T::regs().cr().modify(|reg| { | ||
| 192 | reg.set_rngen(false); | ||
| 193 | }); | ||
| 194 | rcc::disable::<T>(); | ||
| 195 | } | ||
| 196 | } | ||
| 197 | 186 | ||
| 198 | impl<'d, T: Instance> RngCore for Rng<'d, T> { | 187 | /// Get a random u32 |
| 199 | fn next_u32(&mut self) -> u32 { | 188 | pub fn next_u32(&mut self) -> u32 { |
| 200 | loop { | 189 | loop { |
| 201 | let sr = T::regs().sr().read(); | 190 | let sr = T::regs().sr().read(); |
| 202 | if sr.seis() | sr.ceis() { | 191 | if sr.seis() | sr.ceis() { |
| @@ -207,13 +196,15 @@ impl<'d, T: Instance> RngCore for Rng<'d, T> { | |||
| 207 | } | 196 | } |
| 208 | } | 197 | } |
| 209 | 198 | ||
| 210 | fn next_u64(&mut self) -> u64 { | 199 | /// Get a random u64 |
| 200 | pub fn next_u64(&mut self) -> u64 { | ||
| 211 | let mut rand = self.next_u32() as u64; | 201 | let mut rand = self.next_u32() as u64; |
| 212 | rand |= (self.next_u32() as u64) << 32; | 202 | rand |= (self.next_u32() as u64) << 32; |
| 213 | rand | 203 | rand |
| 214 | } | 204 | } |
| 215 | 205 | ||
| 216 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 206 | /// Fill a slice with random bytes |
| 207 | pub fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 217 | for chunk in dest.chunks_mut(4) { | 208 | for chunk in dest.chunks_mut(4) { |
| 218 | let rand = self.next_u32(); | 209 | let rand = self.next_u32(); |
| 219 | for (slot, num) in chunk.iter_mut().zip(rand.to_ne_bytes().iter()) { | 210 | for (slot, num) in chunk.iter_mut().zip(rand.to_ne_bytes().iter()) { |
| @@ -221,14 +212,53 @@ impl<'d, T: Instance> RngCore for Rng<'d, T> { | |||
| 221 | } | 212 | } |
| 222 | } | 213 | } |
| 223 | } | 214 | } |
| 215 | } | ||
| 216 | |||
| 217 | impl<'d, T: Instance> Drop for Rng<'d, T> { | ||
| 218 | fn drop(&mut self) { | ||
| 219 | T::regs().cr().modify(|reg| { | ||
| 220 | reg.set_rngen(false); | ||
| 221 | }); | ||
| 222 | rcc::disable::<T>(); | ||
| 223 | } | ||
| 224 | } | ||
| 224 | 225 | ||
| 225 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { | 226 | impl<'d, T: Instance> rand_core_06::RngCore for Rng<'d, T> { |
| 227 | fn next_u32(&mut self) -> u32 { | ||
| 228 | self.next_u32() | ||
| 229 | } | ||
| 230 | |||
| 231 | fn next_u64(&mut self) -> u64 { | ||
| 232 | self.next_u64() | ||
| 233 | } | ||
| 234 | |||
| 235 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 236 | self.fill_bytes(dest); | ||
| 237 | } | ||
| 238 | |||
| 239 | fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_06::Error> { | ||
| 226 | self.fill_bytes(dest); | 240 | self.fill_bytes(dest); |
| 227 | Ok(()) | 241 | Ok(()) |
| 228 | } | 242 | } |
| 229 | } | 243 | } |
| 230 | 244 | ||
| 231 | impl<'d, T: Instance> CryptoRng for Rng<'d, T> {} | 245 | impl<'d, T: Instance> rand_core_06::CryptoRng for Rng<'d, T> {} |
| 246 | |||
| 247 | impl<'d, T: Instance> rand_core_09::RngCore for Rng<'d, T> { | ||
| 248 | fn next_u32(&mut self) -> u32 { | ||
| 249 | self.next_u32() | ||
| 250 | } | ||
| 251 | |||
| 252 | fn next_u64(&mut self) -> u64 { | ||
| 253 | self.next_u64() | ||
| 254 | } | ||
| 255 | |||
| 256 | fn fill_bytes(&mut self, dest: &mut [u8]) { | ||
| 257 | self.fill_bytes(dest); | ||
| 258 | } | ||
| 259 | } | ||
| 260 | |||
| 261 | impl<'d, T: Instance> rand_core_09::CryptoRng for Rng<'d, T> {} | ||
| 232 | 262 | ||
| 233 | trait SealedInstance { | 263 | trait SealedInstance { |
| 234 | fn regs() -> pac::rng::Rng; | 264 | fn regs() -> pac::rng::Rng; |
diff --git a/examples/mimxrt6/Cargo.toml b/examples/mimxrt6/Cargo.toml index b0c56f003..27c3a27dc 100644 --- a/examples/mimxrt6/Cargo.toml +++ b/examples/mimxrt6/Cargo.toml | |||
| @@ -20,7 +20,6 @@ embedded-hal-async = "1.0.0" | |||
| 20 | 20 | ||
| 21 | mimxrt600-fcb = "0.2.2" | 21 | mimxrt600-fcb = "0.2.2" |
| 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 22 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 23 | rand = { version = "0.8.5", default-features = false } | ||
| 24 | 23 | ||
| 25 | # cargo build/run | 24 | # cargo build/run |
| 26 | [profile.dev] | 25 | [profile.dev] |
diff --git a/examples/mimxrt6/src/bin/rng.rs b/examples/mimxrt6/src/bin/rng.rs index 5f64cb96a..9468dd109 100644 --- a/examples/mimxrt6/src/bin/rng.rs +++ b/examples/mimxrt6/src/bin/rng.rs | |||
| @@ -7,7 +7,6 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_imxrt::rng::Rng; | 8 | use embassy_imxrt::rng::Rng; |
| 9 | use embassy_imxrt::{bind_interrupts, peripherals, rng}; | 9 | use embassy_imxrt::{bind_interrupts, peripherals, rng}; |
| 10 | use rand::RngCore; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | bind_interrupts!(struct Irqs { | 12 | bind_interrupts!(struct Irqs { |
| @@ -29,10 +28,10 @@ async fn main(_spawner: Spawner) { | |||
| 29 | // RngCore interface | 28 | // RngCore interface |
| 30 | let mut random_bytes = [0; 16]; | 29 | let mut random_bytes = [0; 16]; |
| 31 | 30 | ||
| 32 | let random_u32 = rng.next_u32(); | 31 | let random_u32 = rng.blocking_next_u32(); |
| 33 | let random_u64 = rng.next_u64(); | 32 | let random_u64 = rng.blocking_next_u64(); |
| 34 | 33 | ||
| 35 | rng.fill_bytes(&mut random_bytes); | 34 | rng.blocking_fill_bytes(&mut random_bytes); |
| 36 | 35 | ||
| 37 | info!("random_u32 {}", random_u32); | 36 | info!("random_u32 {}", random_u32); |
| 38 | info!("random_u64 {}", random_u64); | 37 | info!("random_u64 {}", random_u64); |
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index af12212cd..ba609d889 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -23,7 +23,6 @@ embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["nrf5 | |||
| 23 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 23 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 24 | cortex-m-rt = "0.7.0" | 24 | cortex-m-rt = "0.7.0" |
| 25 | panic-probe = { version = "0.3" } | 25 | panic-probe = { version = "0.3" } |
| 26 | rand = { version = "0.8.4", default-features = false } | ||
| 27 | serde = { version = "1.0.136", default-features = false } | 26 | serde = { version = "1.0.136", default-features = false } |
| 28 | rtos-trace = "0.1.3" | 27 | rtos-trace = "0.1.3" |
| 29 | systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } | 28 | systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } |
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 902193f3a..ff40a34af 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -25,7 +25,7 @@ static_cell = { version = "2" } | |||
| 25 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 25 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 26 | cortex-m-rt = "0.7.0" | 26 | cortex-m-rt = "0.7.0" |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 28 | rand = { version = "0.8.4", default-features = false } | 28 | rand = { version = "0.9.0", default-features = false } |
| 29 | embedded-storage = "0.3.1" | 29 | embedded-storage = "0.3.1" |
| 30 | usbd-hid = "0.8.1" | 30 | usbd-hid = "0.8.1" |
| 31 | serde = { version = "1.0.136", default-features = false } | 31 | serde = { version = "1.0.136", default-features = false } |
diff --git a/examples/nrf52840/src/bin/rng.rs b/examples/nrf52840/src/bin/rng.rs index 326054c9a..f32d17cd9 100644..100755 --- a/examples/nrf52840/src/bin/rng.rs +++ b/examples/nrf52840/src/bin/rng.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | defmt::info!("Some random bytes: {:?}", bytes); | 22 | defmt::info!("Some random bytes: {:?}", bytes); |
| 23 | 23 | ||
| 24 | // Sync API with `rand` | 24 | // Sync API with `rand` |
| 25 | defmt::info!("A random number from 1 to 10: {:?}", rng.gen_range(1..=10)); | 25 | defmt::info!("A random number from 1 to 10: {:?}", rng.random_range(1..=10)); |
| 26 | 26 | ||
| 27 | let mut bytes = [0; 1024]; | 27 | let mut bytes = [0; 1024]; |
| 28 | rng.fill_bytes(&mut bytes).await; | 28 | rng.fill_bytes(&mut bytes).await; |
diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index 459c43221..5c226695f 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml | |||
| @@ -21,7 +21,6 @@ static_cell = "2" | |||
| 21 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 21 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 22 | cortex-m-rt = "0.7.0" | 22 | cortex-m-rt = "0.7.0" |
| 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 24 | rand = { version = "0.8.4", default-features = false } | ||
| 25 | embedded-storage = "0.3.1" | 24 | embedded-storage = "0.3.1" |
| 26 | usbd-hid = "0.8.1" | 25 | usbd-hid = "0.8.1" |
| 27 | serde = { version = "1.0.136", default-features = false } | 26 | serde = { version = "1.0.136", default-features = false } |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 45ca30e4c..aacf9846a 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -45,7 +45,6 @@ byte-slice-cast = { version = "1.2.0", default-features = false } | |||
| 45 | smart-leds = "0.4.0" | 45 | smart-leds = "0.4.0" |
| 46 | heapless = "0.8" | 46 | heapless = "0.8" |
| 47 | usbd-hid = "0.8.1" | 47 | usbd-hid = "0.8.1" |
| 48 | rand_core = "0.6.4" | ||
| 49 | 48 | ||
| 50 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | 49 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } |
| 51 | embedded-hal-async = "1.0" | 50 | embedded-hal-async = "1.0" |
| @@ -55,7 +54,7 @@ embedded-storage = { version = "0.3" } | |||
| 55 | static_cell = "2.1" | 54 | static_cell = "2.1" |
| 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 55 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 57 | log = "0.4" | 56 | log = "0.4" |
| 58 | rand = { version = "0.8.5", default-features = false } | 57 | rand = { version = "0.9.0", default-features = false } |
| 59 | embedded-sdmmc = "0.7.0" | 58 | embedded-sdmmc = "0.7.0" |
| 60 | 59 | ||
| 61 | [profile.release] | 60 | [profile.release] |
diff --git a/examples/rp/src/bin/ethernet_w5500_icmp.rs b/examples/rp/src/bin/ethernet_w5500_icmp.rs index 5c42b2dde..e434b3bbc 100644 --- a/examples/rp/src/bin/ethernet_w5500_icmp.rs +++ b/examples/rp/src/bin/ethernet_w5500_icmp.rs | |||
| @@ -21,7 +21,6 @@ use embassy_rp::peripherals::SPI0; | |||
| 21 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 21 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 22 | use embassy_time::{Delay, Instant, Timer}; | 22 | use embassy_time::{Delay, Instant, Timer}; |
| 23 | use embedded_hal_bus::spi::ExclusiveDevice; | 23 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 24 | use rand::RngCore; | ||
| 25 | use static_cell::StaticCell; | 24 | use static_cell::StaticCell; |
| 26 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 27 | 26 | ||
diff --git a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs index 0724311f9..0ec594fd5 100644 --- a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs +++ b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs | |||
| @@ -23,7 +23,6 @@ use embassy_rp::peripherals::SPI0; | |||
| 23 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 23 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 24 | use embassy_time::{Delay, Duration}; | 24 | use embassy_time::{Delay, Duration}; |
| 25 | use embedded_hal_bus::spi::ExclusiveDevice; | 25 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 26 | use rand::RngCore; | ||
| 27 | use static_cell::StaticCell; | 26 | use static_cell::StaticCell; |
| 28 | use {defmt_rtt as _, panic_probe as _}; | 27 | use {defmt_rtt as _, panic_probe as _}; |
| 29 | 28 | ||
diff --git a/examples/rp/src/bin/ethernet_w5500_multisocket.rs b/examples/rp/src/bin/ethernet_w5500_multisocket.rs index 2bea9fc9d..27e2f3c30 100644 --- a/examples/rp/src/bin/ethernet_w5500_multisocket.rs +++ b/examples/rp/src/bin/ethernet_w5500_multisocket.rs | |||
| @@ -18,7 +18,6 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | |||
| 18 | use embassy_time::{Delay, Duration}; | 18 | use embassy_time::{Delay, Duration}; |
| 19 | use embedded_hal_bus::spi::ExclusiveDevice; | 19 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 20 | use embedded_io_async::Write; | 20 | use embedded_io_async::Write; |
| 21 | use rand::RngCore; | ||
| 22 | use static_cell::StaticCell; | 21 | use static_cell::StaticCell; |
| 23 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 23 | ||
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index 78d1b0b83..ba82f2a60 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs | |||
| @@ -20,7 +20,6 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | |||
| 20 | use embassy_time::{Delay, Duration, Timer}; | 20 | use embassy_time::{Delay, Duration, Timer}; |
| 21 | use embedded_hal_bus::spi::ExclusiveDevice; | 21 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 22 | use embedded_io_async::Write; | 22 | use embedded_io_async::Write; |
| 23 | use rand::RngCore; | ||
| 24 | use static_cell::StaticCell; | 23 | use static_cell::StaticCell; |
| 25 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 26 | 25 | ||
diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs index 25a38c714..5c56dcafa 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs | |||
| @@ -19,7 +19,6 @@ use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | |||
| 19 | use embassy_time::{Delay, Duration}; | 19 | use embassy_time::{Delay, Duration}; |
| 20 | use embedded_hal_bus::spi::ExclusiveDevice; | 20 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 21 | use embedded_io_async::Write; | 21 | use embedded_io_async::Write; |
| 22 | use rand::RngCore; | ||
| 23 | use static_cell::StaticCell; | 22 | use static_cell::StaticCell; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 24 | ||
diff --git a/examples/rp/src/bin/ethernet_w5500_udp.rs b/examples/rp/src/bin/ethernet_w5500_udp.rs index 683e29222..c5fc8de1d 100644 --- a/examples/rp/src/bin/ethernet_w5500_udp.rs +++ b/examples/rp/src/bin/ethernet_w5500_udp.rs | |||
| @@ -18,7 +18,6 @@ use embassy_rp::peripherals::SPI0; | |||
| 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 19 | use embassy_time::Delay; | 19 | use embassy_time::Delay; |
| 20 | use embedded_hal_bus::spi::ExclusiveDevice; | 20 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 21 | use rand::RngCore; | ||
| 22 | use static_cell::StaticCell; | 21 | use static_cell::StaticCell; |
| 23 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 23 | ||
diff --git a/examples/rp/src/bin/orchestrate_tasks.rs b/examples/rp/src/bin/orchestrate_tasks.rs index 5e2775793..c35679251 100644 --- a/examples/rp/src/bin/orchestrate_tasks.rs +++ b/examples/rp/src/bin/orchestrate_tasks.rs | |||
| @@ -29,7 +29,6 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | |||
| 29 | use embassy_sync::mutex::Mutex; | 29 | use embassy_sync::mutex::Mutex; |
| 30 | use embassy_sync::{channel, signal}; | 30 | use embassy_sync::{channel, signal}; |
| 31 | use embassy_time::{Duration, Timer}; | 31 | use embassy_time::{Duration, Timer}; |
| 32 | use rand::RngCore; | ||
| 33 | use {defmt_rtt as _, panic_probe as _}; | 32 | use {defmt_rtt as _, panic_probe as _}; |
| 34 | 33 | ||
| 35 | // Hardware resource assignment. See other examples for different ways of doing this. | 34 | // Hardware resource assignment. See other examples for different ways of doing this. |
diff --git a/examples/rp/src/bin/sharing.rs b/examples/rp/src/bin/sharing.rs index 497c4f845..856be6ace 100644 --- a/examples/rp/src/bin/sharing.rs +++ b/examples/rp/src/bin/sharing.rs | |||
| @@ -27,7 +27,6 @@ use embassy_rp::{bind_interrupts, interrupt}; | |||
| 27 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 27 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 28 | use embassy_sync::{blocking_mutex, mutex}; | 28 | use embassy_sync::{blocking_mutex, mutex}; |
| 29 | use embassy_time::{Duration, Ticker}; | 29 | use embassy_time::{Duration, Ticker}; |
| 30 | use rand::RngCore; | ||
| 31 | use static_cell::{ConstStaticCell, StaticCell}; | 30 | use static_cell::{ConstStaticCell, StaticCell}; |
| 32 | use {defmt_rtt as _, panic_probe as _}; | 31 | use {defmt_rtt as _, panic_probe as _}; |
| 33 | 32 | ||
diff --git a/examples/rp/src/bin/spi_gc9a01.rs b/examples/rp/src/bin/spi_gc9a01.rs index 30afc253d..fdef09d4b 100644 --- a/examples/rp/src/bin/spi_gc9a01.rs +++ b/examples/rp/src/bin/spi_gc9a01.rs | |||
| @@ -26,7 +26,6 @@ use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; | |||
| 26 | use mipidsi::models::GC9A01; | 26 | use mipidsi::models::GC9A01; |
| 27 | use mipidsi::options::{ColorInversion, ColorOrder}; | 27 | use mipidsi::options::{ColorInversion, ColorOrder}; |
| 28 | use mipidsi::Builder; | 28 | use mipidsi::Builder; |
| 29 | use rand_core::RngCore; | ||
| 30 | use {defmt_rtt as _, panic_probe as _}; | 29 | use {defmt_rtt as _, panic_probe as _}; |
| 31 | 30 | ||
| 32 | const DISPLAY_FREQ: u32 = 64_000_000; | 31 | const DISPLAY_FREQ: u32 = 64_000_000; |
diff --git a/examples/rp/src/bin/usb_ethernet.rs b/examples/rp/src/bin/usb_ethernet.rs index 2add20bc6..171f21a75 100644 --- a/examples/rp/src/bin/usb_ethernet.rs +++ b/examples/rp/src/bin/usb_ethernet.rs | |||
| @@ -17,7 +17,6 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 17 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 17 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 18 | use embassy_usb::{Builder, Config, UsbDevice}; | 18 | use embassy_usb::{Builder, Config, UsbDevice}; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
| 20 | use rand::RngCore; | ||
| 21 | use static_cell::StaticCell; | 20 | use static_cell::StaticCell; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 22 | ||
diff --git a/examples/rp/src/bin/usb_hid_mouse.rs b/examples/rp/src/bin/usb_hid_mouse.rs index 5ee650910..4454c593c 100644..100755 --- a/examples/rp/src/bin/usb_hid_mouse.rs +++ b/examples/rp/src/bin/usb_hid_mouse.rs | |||
| @@ -85,8 +85,8 @@ async fn main(_spawner: Spawner) { | |||
| 85 | _ = Timer::after_secs(1).await; | 85 | _ = Timer::after_secs(1).await; |
| 86 | let report = MouseReport { | 86 | let report = MouseReport { |
| 87 | buttons: 0, | 87 | buttons: 0, |
| 88 | x: rng.gen_range(-100..100), // random small x movement | 88 | x: rng.random_range(-100..100), // random small x movement |
| 89 | y: rng.gen_range(-100..100), // random small y movement | 89 | y: rng.random_range(-100..100), // random small y movement |
| 90 | wheel: 0, | 90 | wheel: 0, |
| 91 | pan: 0, | 91 | pan: 0, |
| 92 | }; | 92 | }; |
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index e97ddb4c1..856838a8c 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs | |||
| @@ -19,7 +19,6 @@ use embassy_rp::peripherals::{DMA_CH0, PIO0}; | |||
| 19 | use embassy_rp::pio::{InterruptHandler, Pio}; | 19 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 20 | use embassy_time::Duration; | 20 | use embassy_time::Duration; |
| 21 | use embedded_io_async::Write; | 21 | use embedded_io_async::Write; |
| 22 | use rand::RngCore; | ||
| 23 | use static_cell::StaticCell; | 22 | use static_cell::StaticCell; |
| 24 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 24 | ||
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 7e3c663fe..fbc957e0e 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -20,7 +20,6 @@ use embassy_rp::peripherals::{DMA_CH0, PIO0}; | |||
| 20 | use embassy_rp::pio::{InterruptHandler, Pio}; | 20 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 21 | use embassy_time::{Duration, Timer}; | 21 | use embassy_time::{Duration, Timer}; |
| 22 | use embedded_io_async::Write; | 22 | use embedded_io_async::Write; |
| 23 | use rand::RngCore; | ||
| 24 | use static_cell::StaticCell; | 23 | use static_cell::StaticCell; |
| 25 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 26 | 25 | ||
diff --git a/examples/rp/src/bin/wifi_webrequest.rs b/examples/rp/src/bin/wifi_webrequest.rs index f1b398b65..1efd1cd28 100644 --- a/examples/rp/src/bin/wifi_webrequest.rs +++ b/examples/rp/src/bin/wifi_webrequest.rs | |||
| @@ -20,7 +20,6 @@ use embassy_rp::gpio::{Level, Output}; | |||
| 20 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; | 20 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 21 | use embassy_rp::pio::{InterruptHandler, Pio}; | 21 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 22 | use embassy_time::{Duration, Timer}; | 22 | use embassy_time::{Duration, Timer}; |
| 23 | use rand::RngCore; | ||
| 24 | use reqwless::client::{HttpClient, TlsConfig, TlsVerify}; | 23 | use reqwless::client::{HttpClient, TlsConfig, TlsVerify}; |
| 25 | use reqwless::request::Method; | 24 | use reqwless::request::Method; |
| 26 | use serde::Deserialize; | 25 | use serde::Deserialize; |
diff --git a/examples/rp235x/Cargo.toml b/examples/rp235x/Cargo.toml index 345a915af..a247bc619 100644 --- a/examples/rp235x/Cargo.toml +++ b/examples/rp235x/Cargo.toml | |||
| @@ -55,7 +55,6 @@ embedded-storage = { version = "0.3" } | |||
| 55 | static_cell = "2.1" | 55 | static_cell = "2.1" |
| 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 57 | log = "0.4" | 57 | log = "0.4" |
| 58 | rand = { version = "0.8.5", default-features = false } | ||
| 59 | embedded-sdmmc = "0.7.0" | 58 | embedded-sdmmc = "0.7.0" |
| 60 | 59 | ||
| 61 | [profile.release] | 60 | [profile.release] |
diff --git a/examples/rp235x/src/bin/sharing.rs b/examples/rp235x/src/bin/sharing.rs index 497c4f845..856be6ace 100644 --- a/examples/rp235x/src/bin/sharing.rs +++ b/examples/rp235x/src/bin/sharing.rs | |||
| @@ -27,7 +27,6 @@ use embassy_rp::{bind_interrupts, interrupt}; | |||
| 27 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 27 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 28 | use embassy_sync::{blocking_mutex, mutex}; | 28 | use embassy_sync::{blocking_mutex, mutex}; |
| 29 | use embassy_time::{Duration, Ticker}; | 29 | use embassy_time::{Duration, Ticker}; |
| 30 | use rand::RngCore; | ||
| 31 | use static_cell::{ConstStaticCell, StaticCell}; | 30 | use static_cell::{ConstStaticCell, StaticCell}; |
| 32 | use {defmt_rtt as _, panic_probe as _}; | 31 | use {defmt_rtt as _, panic_probe as _}; |
| 33 | 32 | ||
diff --git a/examples/rp235x/src/bin/trng.rs b/examples/rp235x/src/bin/trng.rs index ad19aef3e..100d6b104 100644 --- a/examples/rp235x/src/bin/trng.rs +++ b/examples/rp235x/src/bin/trng.rs | |||
| @@ -10,7 +10,6 @@ use embassy_rp::gpio::{Level, Output}; | |||
| 10 | use embassy_rp::peripherals::TRNG; | 10 | use embassy_rp::peripherals::TRNG; |
| 11 | use embassy_rp::trng::Trng; | 11 | use embassy_rp::trng::Trng; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use rand::RngCore; | ||
| 14 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 14 | ||
| 16 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -33,8 +32,8 @@ async fn main(_spawner: Spawner) { | |||
| 33 | info!("Random bytes async {}", &randomness); | 32 | info!("Random bytes async {}", &randomness); |
| 34 | trng.blocking_fill_bytes(&mut randomness); | 33 | trng.blocking_fill_bytes(&mut randomness); |
| 35 | info!("Random bytes blocking {}", &randomness); | 34 | info!("Random bytes blocking {}", &randomness); |
| 36 | let random_u32 = trng.next_u32(); | 35 | let random_u32 = trng.blocking_next_u32(); |
| 37 | let random_u64 = trng.next_u64(); | 36 | let random_u64 = trng.blocking_next_u64(); |
| 38 | info!("Random u32 {} u64 {}", random_u32, random_u64); | 37 | info!("Random u32 {} u64 {}", random_u32, random_u64); |
| 39 | // Random number of blinks between 0 and 31 | 38 | // Random number of blinks between 0 and 31 |
| 40 | let blinks = random_u32 % 32; | 39 | let blinks = random_u32 % 32; |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index f00953167..ff4b2fbbd 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -21,7 +21,7 @@ futures = { version = "0.3.17" } | |||
| 21 | log = "0.4.14" | 21 | log = "0.4.14" |
| 22 | nix = "0.26.2" | 22 | nix = "0.26.2" |
| 23 | clap = { version = "3.0.0-beta.5", features = ["derive"] } | 23 | clap = { version = "3.0.0-beta.5", features = ["derive"] } |
| 24 | rand_core = { version = "0.6.3", features = ["std"] } | 24 | rand_core = { version = "0.9.1", features = ["std", "os_rng"] } |
| 25 | heapless = { version = "0.8", default-features = false } | 25 | heapless = { version = "0.8", default-features = false } |
| 26 | static_cell = "2" | 26 | static_cell = "2" |
| 27 | 27 | ||
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs index 6e50b1a01..232cf494b 100644 --- a/examples/std/src/bin/net.rs +++ b/examples/std/src/bin/net.rs | |||
| @@ -9,7 +9,7 @@ use embassy_time::Duration; | |||
| 9 | use embedded_io_async::Write; | 9 | use embedded_io_async::Write; |
| 10 | use heapless::Vec; | 10 | use heapless::Vec; |
| 11 | use log::*; | 11 | use log::*; |
| 12 | use rand_core::{OsRng, RngCore}; | 12 | use rand_core::{OsRng, TryRngCore}; |
| 13 | use static_cell::StaticCell; | 13 | use static_cell::StaticCell; |
| 14 | 14 | ||
| 15 | #[derive(Parser)] | 15 | #[derive(Parser)] |
| @@ -48,7 +48,7 @@ async fn main_task(spawner: Spawner) { | |||
| 48 | 48 | ||
| 49 | // Generate random seed | 49 | // Generate random seed |
| 50 | let mut seed = [0; 8]; | 50 | let mut seed = [0; 8]; |
| 51 | OsRng.fill_bytes(&mut seed); | 51 | OsRng.try_fill_bytes(&mut seed).unwrap(); |
| 52 | let seed = u64::from_le_bytes(seed); | 52 | let seed = u64::from_le_bytes(seed); |
| 53 | 53 | ||
| 54 | // Init network stack | 54 | // Init network stack |
diff --git a/examples/std/src/bin/net_dns.rs b/examples/std/src/bin/net_dns.rs index a42c5dbb7..cf90731dd 100644 --- a/examples/std/src/bin/net_dns.rs +++ b/examples/std/src/bin/net_dns.rs | |||
| @@ -5,7 +5,7 @@ use embassy_net::{Config, Ipv4Address, Ipv4Cidr, StackResources}; | |||
| 5 | use embassy_net_tuntap::TunTapDevice; | 5 | use embassy_net_tuntap::TunTapDevice; |
| 6 | use heapless::Vec; | 6 | use heapless::Vec; |
| 7 | use log::*; | 7 | use log::*; |
| 8 | use rand_core::{OsRng, RngCore}; | 8 | use rand_core::{OsRng, TryRngCore}; |
| 9 | use static_cell::StaticCell; | 9 | use static_cell::StaticCell; |
| 10 | 10 | ||
| 11 | #[derive(Parser)] | 11 | #[derive(Parser)] |
| @@ -45,7 +45,7 @@ async fn main_task(spawner: Spawner) { | |||
| 45 | 45 | ||
| 46 | // Generate random seed | 46 | // Generate random seed |
| 47 | let mut seed = [0; 8]; | 47 | let mut seed = [0; 8]; |
| 48 | OsRng.fill_bytes(&mut seed); | 48 | OsRng.try_fill_bytes(&mut seed).unwrap(); |
| 49 | let seed = u64::from_le_bytes(seed); | 49 | let seed = u64::from_le_bytes(seed); |
| 50 | 50 | ||
| 51 | // Init network stack | 51 | // Init network stack |
diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs index f667e8d4c..ac3aea6ff 100644 --- a/examples/std/src/bin/net_ppp.rs +++ b/examples/std/src/bin/net_ppp.rs | |||
| @@ -23,7 +23,7 @@ use futures::io::BufReader; | |||
| 23 | use heapless::Vec; | 23 | use heapless::Vec; |
| 24 | use log::*; | 24 | use log::*; |
| 25 | use nix::sys::termios; | 25 | use nix::sys::termios; |
| 26 | use rand_core::{OsRng, RngCore}; | 26 | use rand_core::{OsRng, TryRngCore}; |
| 27 | use static_cell::StaticCell; | 27 | use static_cell::StaticCell; |
| 28 | 28 | ||
| 29 | use crate::serial_port::SerialPort; | 29 | use crate::serial_port::SerialPort; |
| @@ -89,7 +89,7 @@ async fn main_task(spawner: Spawner) { | |||
| 89 | 89 | ||
| 90 | // Generate random seed | 90 | // Generate random seed |
| 91 | let mut seed = [0; 8]; | 91 | let mut seed = [0; 8]; |
| 92 | OsRng.fill_bytes(&mut seed); | 92 | OsRng.try_fill_bytes(&mut seed).unwrap(); |
| 93 | let seed = u64::from_le_bytes(seed); | 93 | let seed = u64::from_le_bytes(seed); |
| 94 | 94 | ||
| 95 | // Init network stack | 95 | // Init network stack |
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs index 02d4d3efb..53632a5b4 100644 --- a/examples/std/src/bin/net_udp.rs +++ b/examples/std/src/bin/net_udp.rs | |||
| @@ -5,7 +5,7 @@ use embassy_net::{Config, Ipv4Address, Ipv4Cidr, StackResources}; | |||
| 5 | use embassy_net_tuntap::TunTapDevice; | 5 | use embassy_net_tuntap::TunTapDevice; |
| 6 | use heapless::Vec; | 6 | use heapless::Vec; |
| 7 | use log::*; | 7 | use log::*; |
| 8 | use rand_core::{OsRng, RngCore}; | 8 | use rand_core::{OsRng, TryRngCore}; |
| 9 | use static_cell::StaticCell; | 9 | use static_cell::StaticCell; |
| 10 | 10 | ||
| 11 | #[derive(Parser)] | 11 | #[derive(Parser)] |
| @@ -44,7 +44,7 @@ async fn main_task(spawner: Spawner) { | |||
| 44 | 44 | ||
| 45 | // Generate random seed | 45 | // Generate random seed |
| 46 | let mut seed = [0; 8]; | 46 | let mut seed = [0; 8]; |
| 47 | OsRng.fill_bytes(&mut seed); | 47 | OsRng.try_fill_bytes(&mut seed).unwrap(); |
| 48 | let seed = u64::from_le_bytes(seed); | 48 | let seed = u64::from_le_bytes(seed); |
| 49 | 49 | ||
| 50 | // Init network stack | 50 | // Init network stack |
diff --git a/examples/std/src/bin/tcp_accept.rs b/examples/std/src/bin/tcp_accept.rs index 18646a083..961c20e2d 100644 --- a/examples/std/src/bin/tcp_accept.rs +++ b/examples/std/src/bin/tcp_accept.rs | |||
| @@ -7,7 +7,7 @@ use embassy_time::{Duration, Timer}; | |||
| 7 | use embedded_io_async::Write as _; | 7 | use embedded_io_async::Write as _; |
| 8 | use heapless::Vec; | 8 | use heapless::Vec; |
| 9 | use log::*; | 9 | use log::*; |
| 10 | use rand_core::{OsRng, RngCore}; | 10 | use rand_core::{OsRng, TryRngCore}; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | 12 | ||
| 13 | #[derive(Parser)] | 13 | #[derive(Parser)] |
| @@ -46,7 +46,7 @@ async fn main_task(spawner: Spawner) { | |||
| 46 | 46 | ||
| 47 | // Generate random seed | 47 | // Generate random seed |
| 48 | let mut seed = [0; 8]; | 48 | let mut seed = [0; 8]; |
| 49 | OsRng.fill_bytes(&mut seed); | 49 | OsRng.try_fill_bytes(&mut seed).unwrap(); |
| 50 | let seed = u64::from_le_bytes(seed); | 50 | let seed = u64::from_le_bytes(seed); |
| 51 | 51 | ||
| 52 | // Init network stack | 52 | // Init network stack |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 1a46931d9..94e0a80eb 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -24,7 +24,6 @@ embedded-hal = "0.2.6" | |||
| 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 25 | heapless = { version = "0.8", default-features = false } | 25 | heapless = { version = "0.8", default-features = false } |
| 26 | nb = "1.0.0" | 26 | nb = "1.0.0" |
| 27 | rand_core = "0.6.3" | ||
| 28 | critical-section = "1.1" | 27 | critical-section = "1.1" |
| 29 | embedded-storage = "0.3.1" | 28 | embedded-storage = "0.3.1" |
| 30 | static_cell = "2" | 29 | static_cell = "2" |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 17ab7fc00..67a2b34bb 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -12,7 +12,6 @@ use embassy_stm32::time::Hertz; | |||
| 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 15 | use rand_core::RngCore; | ||
| 16 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 17 | ||
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index 5631ff746..6fb14f422 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml | |||
| @@ -26,7 +26,6 @@ embedded-io-async = { version = "0.6.1" } | |||
| 26 | embedded-nal-async = "0.8.0" | 26 | embedded-nal-async = "0.8.0" |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 28 | heapless = { version = "0.8", default-features = false } | 28 | heapless = { version = "0.8", default-features = false } |
| 29 | rand_core = "0.6.3" | ||
| 30 | critical-section = "1.1" | 29 | critical-section = "1.1" |
| 31 | micromath = "2.0.0" | 30 | micromath = "2.0.0" |
| 32 | stm32-fmc = "0.3.0" | 31 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index 4034b552c..1d85cc1e7 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -15,7 +15,6 @@ use embassy_stm32::time::Hertz; | |||
| 15 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 15 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 16 | use embassy_time::Timer; | 16 | use embassy_time::Timer; |
| 17 | use embedded_io_async::Write; | 17 | use embedded_io_async::Write; |
| 18 | use rand_core::RngCore; | ||
| 19 | use static_cell::StaticCell; | 18 | use static_cell::StaticCell; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 20 | ||
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 2f98542bb..5035dacae 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -27,7 +27,6 @@ embedded-nal-async = "0.8.0" | |||
| 27 | embedded-io-async = { version = "0.6.1" } | 27 | embedded-io-async = { version = "0.6.1" } |
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 29 | heapless = { version = "0.8", default-features = false } | 29 | heapless = { version = "0.8", default-features = false } |
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 32 | micromath = "2.0.0" | 31 | micromath = "2.0.0" |
| 33 | stm32-fmc = "0.3.0" | 32 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index da7aa4af5..fc14c1a70 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -11,7 +11,6 @@ use embassy_stm32::rng::Rng; | |||
| 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use embedded_io_async::Write; | 13 | use embedded_io_async::Write; |
| 14 | use rand_core::RngCore; | ||
| 15 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 16 | ||
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 10485109a..46301a478 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -14,7 +14,6 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | |||
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::TcpConnect; | 16 | use embedded_nal_async::TcpConnect; |
| 17 | use rand_core::RngCore; | ||
| 18 | use static_cell::StaticCell; | 17 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 19 | ||
diff --git a/examples/stm32h7/src/bin/eth_client_mii.rs b/examples/stm32h7/src/bin/eth_client_mii.rs index 849173615..99cd1a158 100644 --- a/examples/stm32h7/src/bin/eth_client_mii.rs +++ b/examples/stm32h7/src/bin/eth_client_mii.rs | |||
| @@ -14,7 +14,6 @@ use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | |||
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::TcpConnect; | 16 | use embedded_nal_async::TcpConnect; |
| 17 | use rand_core::RngCore; | ||
| 18 | use static_cell::StaticCell; | 17 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 19 | ||
diff --git a/examples/stm32h723/Cargo.toml b/examples/stm32h723/Cargo.toml index 749fd78ae..f07d360b3 100644 --- a/examples/stm32h723/Cargo.toml +++ b/examples/stm32h723/Cargo.toml | |||
| @@ -24,7 +24,6 @@ embedded-nal-async = "0.8.0" | |||
| 24 | embedded-io-async = { version = "0.6.1" } | 24 | embedded-io-async = { version = "0.6.1" } |
| 25 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 25 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 26 | heapless = { version = "0.8", default-features = false } | 26 | heapless = { version = "0.8", default-features = false } |
| 27 | rand_core = "0.6.3" | ||
| 28 | critical-section = "1.1" | 27 | critical-section = "1.1" |
| 29 | static_cell = "2" | 28 | static_cell = "2" |
| 30 | chrono = { version = "^0.4", default-features = false } | 29 | chrono = { version = "^0.4", default-features = false } |
diff --git a/examples/stm32h742/Cargo.toml b/examples/stm32h742/Cargo.toml index e2e0094b8..3f936193c 100644 --- a/examples/stm32h742/Cargo.toml +++ b/examples/stm32h742/Cargo.toml | |||
| @@ -51,7 +51,6 @@ embedded-hal = "0.2.6" | |||
| 51 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 51 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 52 | heapless = { version = "0.8", default-features = false } | 52 | heapless = { version = "0.8", default-features = false } |
| 53 | nb = "1.0.0" | 53 | nb = "1.0.0" |
| 54 | rand_core = "0.6.3" | ||
| 55 | critical-section = "1.1" | 54 | critical-section = "1.1" |
| 56 | embedded-storage = "0.3.1" | 55 | embedded-storage = "0.3.1" |
| 57 | static_cell = "2" | 56 | static_cell = "2" |
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml index 7c17bc766..c186ef19f 100644 --- a/examples/stm32h755cm4/Cargo.toml +++ b/examples/stm32h755cm4/Cargo.toml | |||
| @@ -27,7 +27,6 @@ embedded-nal-async = "0.8.0" | |||
| 27 | embedded-io-async = { version = "0.6.1" } | 27 | embedded-io-async = { version = "0.6.1" } |
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 29 | heapless = { version = "0.8", default-features = false } | 29 | heapless = { version = "0.8", default-features = false } |
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 32 | micromath = "2.0.0" | 31 | micromath = "2.0.0" |
| 33 | stm32-fmc = "0.3.0" | 32 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml index 3186929a8..d37978e44 100644 --- a/examples/stm32h755cm7/Cargo.toml +++ b/examples/stm32h755cm7/Cargo.toml | |||
| @@ -27,7 +27,6 @@ embedded-nal-async = "0.8.0" | |||
| 27 | embedded-io-async = { version = "0.6.1" } | 27 | embedded-io-async = { version = "0.6.1" } |
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 29 | heapless = { version = "0.8", default-features = false } | 29 | heapless = { version = "0.8", default-features = false } |
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 32 | micromath = "2.0.0" | 31 | micromath = "2.0.0" |
| 33 | stm32-fmc = "0.3.0" | 32 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h7b0/Cargo.toml b/examples/stm32h7b0/Cargo.toml index e5f2dfe86..dc8ecc684 100644 --- a/examples/stm32h7b0/Cargo.toml +++ b/examples/stm32h7b0/Cargo.toml | |||
| @@ -26,7 +26,6 @@ embedded-nal-async = "0.8.0" | |||
| 26 | embedded-io-async = { version = "0.6.1" } | 26 | embedded-io-async = { version = "0.6.1" } |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 28 | heapless = { version = "0.8", default-features = false } | 28 | heapless = { version = "0.8", default-features = false } |
| 29 | rand_core = "0.6.3" | ||
| 30 | critical-section = "1.1" | 29 | critical-section = "1.1" |
| 31 | micromath = "2.0.0" | 30 | micromath = "2.0.0" |
| 32 | stm32-fmc = "0.3.0" | 31 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h7rs/Cargo.toml b/examples/stm32h7rs/Cargo.toml index 22d59be04..aee2703a1 100644 --- a/examples/stm32h7rs/Cargo.toml +++ b/examples/stm32h7rs/Cargo.toml | |||
| @@ -26,7 +26,6 @@ embedded-nal-async = "0.8.0" | |||
| 26 | embedded-io-async = { version = "0.6.1" } | 26 | embedded-io-async = { version = "0.6.1" } |
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 28 | heapless = { version = "0.8", default-features = false } | 28 | heapless = { version = "0.8", default-features = false } |
| 29 | rand_core = "0.6.3" | ||
| 30 | critical-section = "1.1" | 29 | critical-section = "1.1" |
| 31 | micromath = "2.0.0" | 30 | micromath = "2.0.0" |
| 32 | stm32-fmc = "0.3.0" | 31 | stm32-fmc = "0.3.0" |
diff --git a/examples/stm32h7rs/src/bin/eth.rs b/examples/stm32h7rs/src/bin/eth.rs index f2bd9575e..6d246bb09 100644 --- a/examples/stm32h7rs/src/bin/eth.rs +++ b/examples/stm32h7rs/src/bin/eth.rs | |||
| @@ -11,7 +11,6 @@ use embassy_stm32::rng::Rng; | |||
| 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use heapless::Vec; | 13 | use heapless::Vec; |
| 14 | use rand_core::RngCore; | ||
| 15 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 16 | ||
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 239bfcd79..cceec86dd 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -30,7 +30,6 @@ embedded-hal-bus = { version = "0.1", features = ["async"] } | |||
| 30 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 30 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 31 | heapless = { version = "0.8", default-features = false } | 31 | heapless = { version = "0.8", default-features = false } |
| 32 | chrono = { version = "^0.4", default-features = false } | 32 | chrono = { version = "^0.4", default-features = false } |
| 33 | rand = { version = "0.8.5", default-features = false } | ||
| 34 | static_cell = "2" | 33 | static_cell = "2" |
| 35 | 34 | ||
| 36 | micromath = "2.0.0" | 35 | micromath = "2.0.0" |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 4a7c01f9f..354ac90b2 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -38,7 +38,6 @@ use embedded_io::Write as bWrite; | |||
| 38 | use embedded_io_async::Write; | 38 | use embedded_io_async::Write; |
| 39 | use heapless::Vec; | 39 | use heapless::Vec; |
| 40 | use panic_probe as _; | 40 | use panic_probe as _; |
| 41 | use rand::RngCore; | ||
| 42 | use static_cell::StaticCell; | 41 | use static_cell::StaticCell; |
| 43 | 42 | ||
| 44 | bind_interrupts!(struct Irqs { | 43 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 4c372a554..6962db7ea 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -23,7 +23,6 @@ cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-sing | |||
| 23 | cortex-m-rt = "0.7.0" | 23 | cortex-m-rt = "0.7.0" |
| 24 | embedded-hal = "0.2.6" | 24 | embedded-hal = "0.2.6" |
| 25 | heapless = { version = "0.8", default-features = false } | 25 | heapless = { version = "0.8", default-features = false } |
| 26 | rand_core = { version = "0.6.3", default-features = false } | ||
| 27 | embedded-io-async = { version = "0.6.1" } | 26 | embedded-io-async = { version = "0.6.1" } |
| 28 | static_cell = "2" | 27 | static_cell = "2" |
| 29 | 28 | ||
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 809ec6ab1..6c72132c6 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -12,7 +12,6 @@ use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState | |||
| 12 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 12 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 13 | use embassy_usb::{Builder, UsbDevice}; | 13 | use embassy_usb::{Builder, UsbDevice}; |
| 14 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 15 | use rand_core::RngCore; | ||
| 16 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 17 | ||
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 1335aa84b..46dc820ab 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -38,7 +38,6 @@ embedded-io-async = { version = "0.6.1" } | |||
| 38 | embedded-storage = { version = "0.3" } | 38 | embedded-storage = { version = "0.3" } |
| 39 | static_cell = "2" | 39 | static_cell = "2" |
| 40 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 40 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 41 | rand = { version = "0.8.5", default-features = false } | ||
| 42 | 41 | ||
| 43 | # bootsel not currently supported on 2350 | 42 | # bootsel not currently supported on 2350 |
| 44 | [[bin]] | 43 | [[bin]] |
diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs index ae2adfa55..89e0ad32e 100644 --- a/tests/rp/src/bin/ethernet_w5100s_perf.rs +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs | |||
| @@ -14,7 +14,6 @@ use embassy_rp::peripherals::SPI0; | |||
| 14 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 14 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 15 | use embassy_time::Delay; | 15 | use embassy_time::Delay; |
| 16 | use embedded_hal_bus::spi::ExclusiveDevice; | 16 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 17 | use rand::RngCore; | ||
| 18 | use static_cell::StaticCell; | 17 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 19 | ||
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 3a347e279..b230e619e 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -81,8 +81,8 @@ embedded-hal-async = { version = "1.0" } | |||
| 81 | embedded-can = { version = "0.4" } | 81 | embedded-can = { version = "0.4" } |
| 82 | micromath = "2.0.0" | 82 | micromath = "2.0.0" |
| 83 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 83 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 84 | rand_core = { version = "0.6", default-features = false } | 84 | rand_core = { version = "0.9.1", default-features = false } |
| 85 | rand_chacha = { version = "0.3", default-features = false } | 85 | rand_chacha = { version = "0.9.0", default-features = false } |
| 86 | static_cell = "2" | 86 | static_cell = "2" |
| 87 | portable-atomic = { version = "1.5", features = [] } | 87 | portable-atomic = { version = "1.5", features = [] } |
| 88 | 88 | ||
diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index a7e76fd8e..bcb362b42 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs | |||
| @@ -11,7 +11,6 @@ use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | |||
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; |
| 14 | use rand_core::RngCore; | ||
| 15 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 16 | ||
diff --git a/tests/utils/Cargo.toml b/tests/utils/Cargo.toml index 7b54a4f52..bda55ad32 100644 --- a/tests/utils/Cargo.toml +++ b/tests/utils/Cargo.toml | |||
| @@ -4,5 +4,5 @@ version = "0.1.0" | |||
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | rand = "0.8" | 7 | rand = "0.9" |
| 8 | serial = "0.4" | 8 | serial = "0.4" |
