aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-05-18 20:51:57 +0200
committerGitHub <[email protected]>2025-05-18 20:51:57 +0200
commit51d0252194cd69f73bade2aaeef3163f3cc7453f (patch)
treecac023f3457123f2fbc7686f2f90414987eae264
parente8b1ea14c7fb151aa5e296ca8f9724f175bdeaef (diff)
parente4fc48764491f8981e4a145a72e9b6e72df8c546 (diff)
Merge pull request #4217 from embassy-rs/rand09
Add rand-core v0.9 support.
-rw-r--r--embassy-imxrt/Cargo.toml4
-rw-r--r--embassy-imxrt/src/rng.rs48
-rw-r--r--embassy-nrf/Cargo.toml4
-rw-r--r--embassy-nrf/src/rng.rs47
-rw-r--r--embassy-rp/Cargo.toml4
-rw-r--r--embassy-rp/src/clocks.rs49
-rw-r--r--embassy-rp/src/trng.rs25
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/src/rng.rs64
-rw-r--r--examples/mimxrt6/Cargo.toml1
-rw-r--r--examples/mimxrt6/src/bin/rng.rs7
-rw-r--r--examples/nrf-rtos-trace/Cargo.toml1
-rw-r--r--examples/nrf52840/Cargo.toml2
-rwxr-xr-x[-rw-r--r--]examples/nrf52840/src/bin/rng.rs2
-rw-r--r--examples/nrf5340/Cargo.toml1
-rw-r--r--examples/rp/Cargo.toml3
-rw-r--r--examples/rp/src/bin/ethernet_w5500_icmp.rs1
-rw-r--r--examples/rp/src/bin/ethernet_w5500_icmp_ping.rs1
-rw-r--r--examples/rp/src/bin/ethernet_w5500_multisocket.rs1
-rw-r--r--examples/rp/src/bin/ethernet_w5500_tcp_client.rs1
-rw-r--r--examples/rp/src/bin/ethernet_w5500_tcp_server.rs1
-rw-r--r--examples/rp/src/bin/ethernet_w5500_udp.rs1
-rw-r--r--examples/rp/src/bin/orchestrate_tasks.rs1
-rw-r--r--examples/rp/src/bin/sharing.rs1
-rw-r--r--examples/rp/src/bin/spi_gc9a01.rs1
-rw-r--r--examples/rp/src/bin/usb_ethernet.rs1
-rwxr-xr-x[-rw-r--r--]examples/rp/src/bin/usb_hid_mouse.rs4
-rw-r--r--examples/rp/src/bin/wifi_ap_tcp_server.rs1
-rw-r--r--examples/rp/src/bin/wifi_tcp_server.rs1
-rw-r--r--examples/rp/src/bin/wifi_webrequest.rs1
-rw-r--r--examples/rp235x/Cargo.toml1
-rw-r--r--examples/rp235x/src/bin/sharing.rs1
-rw-r--r--examples/rp235x/src/bin/trng.rs5
-rw-r--r--examples/std/Cargo.toml2
-rw-r--r--examples/std/src/bin/net.rs4
-rw-r--r--examples/std/src/bin/net_dns.rs4
-rw-r--r--examples/std/src/bin/net_ppp.rs4
-rw-r--r--examples/std/src/bin/net_udp.rs4
-rw-r--r--examples/std/src/bin/tcp_accept.rs4
-rw-r--r--examples/stm32f7/Cargo.toml1
-rw-r--r--examples/stm32f7/src/bin/eth.rs1
-rw-r--r--examples/stm32h5/Cargo.toml1
-rw-r--r--examples/stm32h5/src/bin/eth.rs1
-rw-r--r--examples/stm32h7/Cargo.toml1
-rw-r--r--examples/stm32h7/src/bin/eth.rs1
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs1
-rw-r--r--examples/stm32h7/src/bin/eth_client_mii.rs1
-rw-r--r--examples/stm32h723/Cargo.toml1
-rw-r--r--examples/stm32h742/Cargo.toml1
-rw-r--r--examples/stm32h755cm4/Cargo.toml1
-rw-r--r--examples/stm32h755cm7/Cargo.toml1
-rw-r--r--examples/stm32h7b0/Cargo.toml1
-rw-r--r--examples/stm32h7rs/Cargo.toml1
-rw-r--r--examples/stm32h7rs/src/bin/eth.rs1
-rw-r--r--examples/stm32l4/Cargo.toml1
-rw-r--r--examples/stm32l4/src/bin/spe_adin1110_http_server.rs1
-rw-r--r--examples/stm32l5/Cargo.toml1
-rw-r--r--examples/stm32l5/src/bin/usb_ethernet.rs1
-rw-r--r--tests/rp/Cargo.toml1
-rw-r--r--tests/rp/src/bin/ethernet_w5100s_perf.rs1
-rw-r--r--tests/stm32/Cargo.toml4
-rw-r--r--tests/stm32/src/bin/eth.rs1
-rw-r--r--tests/utils/Cargo.toml2
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"
80critical-section = "1.1" 80critical-section = "1.1"
81embedded-io = { version = "0.6.1" } 81embedded-io = { version = "0.6.1" }
82embedded-io-async = { version = "0.6.1" } 82embedded-io-async = { version = "0.6.1" }
83rand_core = "0.6.4"
84fixed = "1.23.1" 83fixed = "1.23.1"
85 84
85rand-core-06 = { package = "rand_core", version = "0.6" }
86rand-core-09 = { package = "rand_core", version = "0.9" }
87
86embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ 88embedded-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
7use embassy_futures::block_on; 7use embassy_futures::block_on;
8use embassy_sync::waitqueue::AtomicWaker; 8use embassy_sync::waitqueue::AtomicWaker;
9use rand_core::{CryptoRng, RngCore};
10 9
11use crate::clocks::{enable_and_reset, SysconPeripheral}; 10use crate::clocks::{enable_and_reset, SysconPeripheral};
12use crate::interrupt::typelevel::Interrupt; 11use 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
206impl 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> { 224impl<'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
229impl CryptoRng for Rng<'_> {} 243impl<'d> rand_core_06::CryptoRng for Rng<'d> {}
244
245impl<'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
259impl<'d> rand_core_09::CryptoRng for Rng<'d> {}
230 260
231struct Info { 261struct 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" }
154embedded-io = { version = "0.6.0" } 154embedded-io = { version = "0.6.0" }
155embedded-io-async = { version = "0.6.1" } 155embedded-io-async = { version = "0.6.1" }
156 156
157rand-core-06 = { package = "rand_core", version = "0.6" }
158rand-core-09 = { package = "rand_core", version = "0.9" }
159
157nrf-pac = "0.1.0" 160nrf-pac = "0.1.0"
158 161
159defmt = { version = "0.3", optional = true } 162defmt = { version = "0.3", optional = true }
@@ -162,7 +165,6 @@ log = { version = "0.4.14", optional = true }
162cortex-m-rt = ">=0.6.15,<0.8" 165cortex-m-rt = ">=0.6.15,<0.8"
163cortex-m = "0.7.6" 166cortex-m = "0.7.6"
164critical-section = "1.1" 167critical-section = "1.1"
165rand_core = "0.6.3"
166fixed = "1.10.0" 168fixed = "1.10.0"
167embedded-storage = "0.3.1" 169embedded-storage = "0.3.1"
168embedded-storage-async = "0.4.1" 170embedded-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
172impl<'d, T: Instance> Drop for Rng<'d, T> { 187impl<'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
183impl<'d, T: Instance> rand_core::RngCore for Rng<'d, T> { 198impl<'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
207impl<'d, T: Instance> rand_core::CryptoRng for Rng<'d, T> {} 214impl<'d, T: Instance> rand_core_06::CryptoRng for Rng<'d, T> {}
215
216impl<'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
228impl<'d, T: Instance> rand_core_09::CryptoRng for Rng<'d, T> {}
208 229
209/// Peripheral static state 230/// Peripheral static state
210pub(crate) struct State { 231pub(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" }
157embedded-io-async = { version = "0.6.1" } 157embedded-io-async = { version = "0.6.1" }
158embedded-storage = { version = "0.3" } 158embedded-storage = { version = "0.3" }
159embedded-storage-async = { version = "0.4.1" } 159embedded-storage-async = { version = "0.4.1" }
160rand_core = "0.6.4"
161fixed = "1.28.0" 160fixed = "1.28.0"
162 161
163rp-pac = { version = "7.0.0" } 162rp-pac = { version = "7.0.0" }
@@ -167,6 +166,9 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
167embedded-hal-async = { version = "1.0" } 166embedded-hal-async = { version = "1.0" }
168embedded-hal-nb = { version = "1.0" } 167embedded-hal-nb = { version = "1.0" }
169 168
169rand-core-06 = { package = "rand_core", version = "0.6" }
170rand-core-09 = { package = "rand_core", version = "0.9" }
171
170pio = { version = "0.3" } 172pio = { version = "0.3" }
171rp2040-boot2 = "0.3" 173rp2040-boot2 = "0.3"
172document-features = "0.2.10" 174document-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> {
1776pub struct RoscRng; 1776pub struct RoscRng;
1777 1777
1778impl RoscRng { 1778impl 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
1790impl rand_core::RngCore for RoscRng { 1806impl 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
1825impl rand_core_06::CryptoRng for RoscRng {}
1794 1826
1827impl 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
1841impl 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
8use embassy_hal_internal::{Peri, PeripheralType}; 8use embassy_hal_internal::{Peri, PeripheralType};
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10use rand_core::Error;
11 10
12use crate::interrupt::typelevel::{Binding, Interrupt}; 11use crate::interrupt::typelevel::{Binding, Interrupt};
13use crate::peripherals::TRNG; 12use crate::peripherals::TRNG;
@@ -369,7 +368,7 @@ impl<'d, T: Instance> Trng<'d, T> {
369 } 368 }
370} 369}
371 370
372impl<'d, T: Instance> rand_core::RngCore for Trng<'d, T> { 371impl<'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
391impl<'d, T: Instance> rand_core::CryptoRng for Trng<'d, T> {} 390impl<'d, T: Instance> rand_core_06::CryptoRng for Trng<'d, T> {}
391
392impl<'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
406impl<'d, T: Instance> rand_core_09::CryptoRng for Trng<'d, T> {}
392 407
393/// TRNG interrupt handler. 408/// TRNG interrupt handler.
394pub struct InterruptHandler<T: Instance> { 409pub 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"
63embedded-storage = "0.3.1" 63embedded-storage = "0.3.1"
64embedded-storage-async = { version = "0.4.1" } 64embedded-storage-async = { version = "0.4.1" }
65 65
66rand-core-06 = { package = "rand_core", version = "0.6" }
67rand-core-09 = { package = "rand_core", version = "0.9" }
68
66 69
67defmt = { version = "0.3", optional = true } 70defmt = { version = "0.3", optional = true }
68log = { version = "0.4.14", optional = true } 71log = { version = "0.4.14", optional = true }
69cortex-m-rt = ">=0.6.15,<0.8" 72cortex-m-rt = ">=0.6.15,<0.8"
70cortex-m = "0.7.6" 73cortex-m = "0.7.6"
71futures-util = { version = "0.3.30", default-features = false } 74futures-util = { version = "0.3.30", default-features = false }
72rand_core = "0.6.3"
73sdio-host = "0.9.0" 75sdio-host = "0.9.0"
74critical-section = "1.1" 76critical-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
8use embassy_hal_internal::PeripheralType; 8use embassy_hal_internal::PeripheralType;
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10use rand_core::{CryptoRng, RngCore};
11 10
12use crate::interrupt::typelevel::Interrupt; 11use crate::interrupt::typelevel::Interrupt;
13use crate::{interrupt, pac, peripherals, rcc, Peri}; 12use 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
189impl<'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
198impl<'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
217impl<'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> { 226impl<'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
231impl<'d, T: Instance> CryptoRng for Rng<'d, T> {} 245impl<'d, T: Instance> rand_core_06::CryptoRng for Rng<'d, T> {}
246
247impl<'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
261impl<'d, T: Instance> rand_core_09::CryptoRng for Rng<'d, T> {}
232 262
233trait SealedInstance { 263trait 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
21mimxrt600-fcb = "0.2.2" 21mimxrt600-fcb = "0.2.2"
22panic-probe = { version = "0.3", features = ["print-defmt"] } 22panic-probe = { version = "0.3", features = ["print-defmt"] }
23rand = { 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::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_imxrt::rng::Rng; 8use embassy_imxrt::rng::Rng;
9use embassy_imxrt::{bind_interrupts, peripherals, rng}; 9use embassy_imxrt::{bind_interrupts, peripherals, rng};
10use rand::RngCore;
11use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
12 11
13bind_interrupts!(struct Irqs { 12bind_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
23cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 23cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
24cortex-m-rt = "0.7.0" 24cortex-m-rt = "0.7.0"
25panic-probe = { version = "0.3" } 25panic-probe = { version = "0.3" }
26rand = { version = "0.8.4", default-features = false }
27serde = { version = "1.0.136", default-features = false } 26serde = { version = "1.0.136", default-features = false }
28rtos-trace = "0.1.3" 27rtos-trace = "0.1.3"
29systemview-target = { version = "0.1.2", features = ["callbacks-app", "callbacks-os", "log", "cortex-m"] } 28systemview-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" }
25cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 25cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
26cortex-m-rt = "0.7.0" 26cortex-m-rt = "0.7.0"
27panic-probe = { version = "0.3", features = ["print-defmt"] } 27panic-probe = { version = "0.3", features = ["print-defmt"] }
28rand = { version = "0.8.4", default-features = false } 28rand = { version = "0.9.0", default-features = false }
29embedded-storage = "0.3.1" 29embedded-storage = "0.3.1"
30usbd-hid = "0.8.1" 30usbd-hid = "0.8.1"
31serde = { version = "1.0.136", default-features = false } 31serde = { 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"
21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
22cortex-m-rt = "0.7.0" 22cortex-m-rt = "0.7.0"
23panic-probe = { version = "0.3", features = ["print-defmt"] } 23panic-probe = { version = "0.3", features = ["print-defmt"] }
24rand = { version = "0.8.4", default-features = false }
25embedded-storage = "0.3.1" 24embedded-storage = "0.3.1"
26usbd-hid = "0.8.1" 25usbd-hid = "0.8.1"
27serde = { version = "1.0.136", default-features = false } 26serde = { 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 }
45smart-leds = "0.4.0" 45smart-leds = "0.4.0"
46heapless = "0.8" 46heapless = "0.8"
47usbd-hid = "0.8.1" 47usbd-hid = "0.8.1"
48rand_core = "0.6.4"
49 48
50embedded-hal-1 = { package = "embedded-hal", version = "1.0" } 49embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
51embedded-hal-async = "1.0" 50embedded-hal-async = "1.0"
@@ -55,7 +54,7 @@ embedded-storage = { version = "0.3" }
55static_cell = "2.1" 54static_cell = "2.1"
56portable-atomic = { version = "1.5", features = ["critical-section"] } 55portable-atomic = { version = "1.5", features = ["critical-section"] }
57log = "0.4" 56log = "0.4"
58rand = { version = "0.8.5", default-features = false } 57rand = { version = "0.9.0", default-features = false }
59embedded-sdmmc = "0.7.0" 58embedded-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;
21use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; 21use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
22use embassy_time::{Delay, Instant, Timer}; 22use embassy_time::{Delay, Instant, Timer};
23use embedded_hal_bus::spi::ExclusiveDevice; 23use embedded_hal_bus::spi::ExclusiveDevice;
24use rand::RngCore;
25use static_cell::StaticCell; 24use static_cell::StaticCell;
26use {defmt_rtt as _, panic_probe as _}; 25use {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;
23use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; 23use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
24use embassy_time::{Delay, Duration}; 24use embassy_time::{Delay, Duration};
25use embedded_hal_bus::spi::ExclusiveDevice; 25use embedded_hal_bus::spi::ExclusiveDevice;
26use rand::RngCore;
27use static_cell::StaticCell; 26use static_cell::StaticCell;
28use {defmt_rtt as _, panic_probe as _}; 27use {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};
18use embassy_time::{Delay, Duration}; 18use embassy_time::{Delay, Duration};
19use embedded_hal_bus::spi::ExclusiveDevice; 19use embedded_hal_bus::spi::ExclusiveDevice;
20use embedded_io_async::Write; 20use embedded_io_async::Write;
21use rand::RngCore;
22use static_cell::StaticCell; 21use static_cell::StaticCell;
23use {defmt_rtt as _, panic_probe as _}; 22use {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};
20use embassy_time::{Delay, Duration, Timer}; 20use embassy_time::{Delay, Duration, Timer};
21use embedded_hal_bus::spi::ExclusiveDevice; 21use embedded_hal_bus::spi::ExclusiveDevice;
22use embedded_io_async::Write; 22use embedded_io_async::Write;
23use rand::RngCore;
24use static_cell::StaticCell; 23use static_cell::StaticCell;
25use {defmt_rtt as _, panic_probe as _}; 24use {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};
19use embassy_time::{Delay, Duration}; 19use embassy_time::{Delay, Duration};
20use embedded_hal_bus::spi::ExclusiveDevice; 20use embedded_hal_bus::spi::ExclusiveDevice;
21use embedded_io_async::Write; 21use embedded_io_async::Write;
22use rand::RngCore;
23use static_cell::StaticCell; 22use static_cell::StaticCell;
24use {defmt_rtt as _, panic_probe as _}; 23use {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;
18use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; 18use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
19use embassy_time::Delay; 19use embassy_time::Delay;
20use embedded_hal_bus::spi::ExclusiveDevice; 20use embedded_hal_bus::spi::ExclusiveDevice;
21use rand::RngCore;
22use static_cell::StaticCell; 21use static_cell::StaticCell;
23use {defmt_rtt as _, panic_probe as _}; 22use {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;
29use embassy_sync::mutex::Mutex; 29use embassy_sync::mutex::Mutex;
30use embassy_sync::{channel, signal}; 30use embassy_sync::{channel, signal};
31use embassy_time::{Duration, Timer}; 31use embassy_time::{Duration, Timer};
32use rand::RngCore;
33use {defmt_rtt as _, panic_probe as _}; 32use {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};
27use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 27use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
28use embassy_sync::{blocking_mutex, mutex}; 28use embassy_sync::{blocking_mutex, mutex};
29use embassy_time::{Duration, Ticker}; 29use embassy_time::{Duration, Ticker};
30use rand::RngCore;
31use static_cell::{ConstStaticCell, StaticCell}; 30use static_cell::{ConstStaticCell, StaticCell};
32use {defmt_rtt as _, panic_probe as _}; 31use {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};
26use mipidsi::models::GC9A01; 26use mipidsi::models::GC9A01;
27use mipidsi::options::{ColorInversion, ColorOrder}; 27use mipidsi::options::{ColorInversion, ColorOrder};
28use mipidsi::Builder; 28use mipidsi::Builder;
29use rand_core::RngCore;
30use {defmt_rtt as _, panic_probe as _}; 29use {defmt_rtt as _, panic_probe as _};
31 30
32const DISPLAY_FREQ: u32 = 64_000_000; 31const 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
17use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; 17use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
18use embassy_usb::{Builder, Config, UsbDevice}; 18use embassy_usb::{Builder, Config, UsbDevice};
19use embedded_io_async::Write; 19use embedded_io_async::Write;
20use rand::RngCore;
21use static_cell::StaticCell; 20use static_cell::StaticCell;
22use {defmt_rtt as _, panic_probe as _}; 21use {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};
19use embassy_rp::pio::{InterruptHandler, Pio}; 19use embassy_rp::pio::{InterruptHandler, Pio};
20use embassy_time::Duration; 20use embassy_time::Duration;
21use embedded_io_async::Write; 21use embedded_io_async::Write;
22use rand::RngCore;
23use static_cell::StaticCell; 22use static_cell::StaticCell;
24use {defmt_rtt as _, panic_probe as _}; 23use {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};
20use embassy_rp::pio::{InterruptHandler, Pio}; 20use embassy_rp::pio::{InterruptHandler, Pio};
21use embassy_time::{Duration, Timer}; 21use embassy_time::{Duration, Timer};
22use embedded_io_async::Write; 22use embedded_io_async::Write;
23use rand::RngCore;
24use static_cell::StaticCell; 23use static_cell::StaticCell;
25use {defmt_rtt as _, panic_probe as _}; 24use {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};
20use embassy_rp::peripherals::{DMA_CH0, PIO0}; 20use embassy_rp::peripherals::{DMA_CH0, PIO0};
21use embassy_rp::pio::{InterruptHandler, Pio}; 21use embassy_rp::pio::{InterruptHandler, Pio};
22use embassy_time::{Duration, Timer}; 22use embassy_time::{Duration, Timer};
23use rand::RngCore;
24use reqwless::client::{HttpClient, TlsConfig, TlsVerify}; 23use reqwless::client::{HttpClient, TlsConfig, TlsVerify};
25use reqwless::request::Method; 24use reqwless::request::Method;
26use serde::Deserialize; 25use 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" }
55static_cell = "2.1" 55static_cell = "2.1"
56portable-atomic = { version = "1.5", features = ["critical-section"] } 56portable-atomic = { version = "1.5", features = ["critical-section"] }
57log = "0.4" 57log = "0.4"
58rand = { version = "0.8.5", default-features = false }
59embedded-sdmmc = "0.7.0" 58embedded-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};
27use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 27use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
28use embassy_sync::{blocking_mutex, mutex}; 28use embassy_sync::{blocking_mutex, mutex};
29use embassy_time::{Duration, Ticker}; 29use embassy_time::{Duration, Ticker};
30use rand::RngCore;
31use static_cell::{ConstStaticCell, StaticCell}; 30use static_cell::{ConstStaticCell, StaticCell};
32use {defmt_rtt as _, panic_probe as _}; 31use {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};
10use embassy_rp::peripherals::TRNG; 10use embassy_rp::peripherals::TRNG;
11use embassy_rp::trng::Trng; 11use embassy_rp::trng::Trng;
12use embassy_time::Timer; 12use embassy_time::Timer;
13use rand::RngCore;
14use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
15 14
16bind_interrupts!(struct Irqs { 15bind_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" }
21log = "0.4.14" 21log = "0.4.14"
22nix = "0.26.2" 22nix = "0.26.2"
23clap = { version = "3.0.0-beta.5", features = ["derive"] } 23clap = { version = "3.0.0-beta.5", features = ["derive"] }
24rand_core = { version = "0.6.3", features = ["std"] } 24rand_core = { version = "0.9.1", features = ["std", "os_rng"] }
25heapless = { version = "0.8", default-features = false } 25heapless = { version = "0.8", default-features = false }
26static_cell = "2" 26static_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;
9use embedded_io_async::Write; 9use embedded_io_async::Write;
10use heapless::Vec; 10use heapless::Vec;
11use log::*; 11use log::*;
12use rand_core::{OsRng, RngCore}; 12use rand_core::{OsRng, TryRngCore};
13use static_cell::StaticCell; 13use 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};
5use embassy_net_tuntap::TunTapDevice; 5use embassy_net_tuntap::TunTapDevice;
6use heapless::Vec; 6use heapless::Vec;
7use log::*; 7use log::*;
8use rand_core::{OsRng, RngCore}; 8use rand_core::{OsRng, TryRngCore};
9use static_cell::StaticCell; 9use 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;
23use heapless::Vec; 23use heapless::Vec;
24use log::*; 24use log::*;
25use nix::sys::termios; 25use nix::sys::termios;
26use rand_core::{OsRng, RngCore}; 26use rand_core::{OsRng, TryRngCore};
27use static_cell::StaticCell; 27use static_cell::StaticCell;
28 28
29use crate::serial_port::SerialPort; 29use 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};
5use embassy_net_tuntap::TunTapDevice; 5use embassy_net_tuntap::TunTapDevice;
6use heapless::Vec; 6use heapless::Vec;
7use log::*; 7use log::*;
8use rand_core::{OsRng, RngCore}; 8use rand_core::{OsRng, TryRngCore};
9use static_cell::StaticCell; 9use 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};
7use embedded_io_async::Write as _; 7use embedded_io_async::Write as _;
8use heapless::Vec; 8use heapless::Vec;
9use log::*; 9use log::*;
10use rand_core::{OsRng, RngCore}; 10use rand_core::{OsRng, TryRngCore};
11use static_cell::StaticCell; 11use 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"
24panic-probe = { version = "0.3", features = ["print-defmt"] } 24panic-probe = { version = "0.3", features = ["print-defmt"] }
25heapless = { version = "0.8", default-features = false } 25heapless = { version = "0.8", default-features = false }
26nb = "1.0.0" 26nb = "1.0.0"
27rand_core = "0.6.3"
28critical-section = "1.1" 27critical-section = "1.1"
29embedded-storage = "0.3.1" 28embedded-storage = "0.3.1"
30static_cell = "2" 29static_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;
12use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 12use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
13use embassy_time::Timer; 13use embassy_time::Timer;
14use embedded_io_async::Write; 14use embedded_io_async::Write;
15use rand_core::RngCore;
16use static_cell::StaticCell; 15use static_cell::StaticCell;
17use {defmt_rtt as _, panic_probe as _}; 16use {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" }
26embedded-nal-async = "0.8.0" 26embedded-nal-async = "0.8.0"
27panic-probe = { version = "0.3", features = ["print-defmt"] } 27panic-probe = { version = "0.3", features = ["print-defmt"] }
28heapless = { version = "0.8", default-features = false } 28heapless = { version = "0.8", default-features = false }
29rand_core = "0.6.3"
30critical-section = "1.1" 29critical-section = "1.1"
31micromath = "2.0.0" 30micromath = "2.0.0"
32stm32-fmc = "0.3.0" 31stm32-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;
15use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 15use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
16use embassy_time::Timer; 16use embassy_time::Timer;
17use embedded_io_async::Write; 17use embedded_io_async::Write;
18use rand_core::RngCore;
19use static_cell::StaticCell; 18use static_cell::StaticCell;
20use {defmt_rtt as _, panic_probe as _}; 19use {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"
27embedded-io-async = { version = "0.6.1" } 27embedded-io-async = { version = "0.6.1" }
28panic-probe = { version = "0.3", features = ["print-defmt"] } 28panic-probe = { version = "0.3", features = ["print-defmt"] }
29heapless = { version = "0.8", default-features = false } 29heapless = { version = "0.8", default-features = false }
30rand_core = "0.6.3"
31critical-section = "1.1" 30critical-section = "1.1"
32micromath = "2.0.0" 31micromath = "2.0.0"
33stm32-fmc = "0.3.0" 32stm32-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;
11use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 11use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
12use embassy_time::Timer; 12use embassy_time::Timer;
13use embedded_io_async::Write; 13use embedded_io_async::Write;
14use rand_core::RngCore;
15use static_cell::StaticCell; 14use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 15use {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};
14use embassy_time::Timer; 14use embassy_time::Timer;
15use embedded_io_async::Write; 15use embedded_io_async::Write;
16use embedded_nal_async::TcpConnect; 16use embedded_nal_async::TcpConnect;
17use rand_core::RngCore;
18use static_cell::StaticCell; 17use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 18use {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};
14use embassy_time::Timer; 14use embassy_time::Timer;
15use embedded_io_async::Write; 15use embedded_io_async::Write;
16use embedded_nal_async::TcpConnect; 16use embedded_nal_async::TcpConnect;
17use rand_core::RngCore;
18use static_cell::StaticCell; 17use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 18use {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"
24embedded-io-async = { version = "0.6.1" } 24embedded-io-async = { version = "0.6.1" }
25panic-probe = { version = "0.3", features = ["print-defmt"] } 25panic-probe = { version = "0.3", features = ["print-defmt"] }
26heapless = { version = "0.8", default-features = false } 26heapless = { version = "0.8", default-features = false }
27rand_core = "0.6.3"
28critical-section = "1.1" 27critical-section = "1.1"
29static_cell = "2" 28static_cell = "2"
30chrono = { version = "^0.4", default-features = false } 29chrono = { 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"
51panic-probe = { version = "0.3", features = ["print-defmt"] } 51panic-probe = { version = "0.3", features = ["print-defmt"] }
52heapless = { version = "0.8", default-features = false } 52heapless = { version = "0.8", default-features = false }
53nb = "1.0.0" 53nb = "1.0.0"
54rand_core = "0.6.3"
55critical-section = "1.1" 54critical-section = "1.1"
56embedded-storage = "0.3.1" 55embedded-storage = "0.3.1"
57static_cell = "2" 56static_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"
27embedded-io-async = { version = "0.6.1" } 27embedded-io-async = { version = "0.6.1" }
28panic-probe = { version = "0.3", features = ["print-defmt"] } 28panic-probe = { version = "0.3", features = ["print-defmt"] }
29heapless = { version = "0.8", default-features = false } 29heapless = { version = "0.8", default-features = false }
30rand_core = "0.6.3"
31critical-section = "1.1" 30critical-section = "1.1"
32micromath = "2.0.0" 31micromath = "2.0.0"
33stm32-fmc = "0.3.0" 32stm32-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"
27embedded-io-async = { version = "0.6.1" } 27embedded-io-async = { version = "0.6.1" }
28panic-probe = { version = "0.3", features = ["print-defmt"] } 28panic-probe = { version = "0.3", features = ["print-defmt"] }
29heapless = { version = "0.8", default-features = false } 29heapless = { version = "0.8", default-features = false }
30rand_core = "0.6.3"
31critical-section = "1.1" 30critical-section = "1.1"
32micromath = "2.0.0" 31micromath = "2.0.0"
33stm32-fmc = "0.3.0" 32stm32-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"
26embedded-io-async = { version = "0.6.1" } 26embedded-io-async = { version = "0.6.1" }
27panic-probe = { version = "0.3", features = ["print-defmt"] } 27panic-probe = { version = "0.3", features = ["print-defmt"] }
28heapless = { version = "0.8", default-features = false } 28heapless = { version = "0.8", default-features = false }
29rand_core = "0.6.3"
30critical-section = "1.1" 29critical-section = "1.1"
31micromath = "2.0.0" 30micromath = "2.0.0"
32stm32-fmc = "0.3.0" 31stm32-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"
26embedded-io-async = { version = "0.6.1" } 26embedded-io-async = { version = "0.6.1" }
27panic-probe = { version = "0.3", features = ["print-defmt"] } 27panic-probe = { version = "0.3", features = ["print-defmt"] }
28heapless = { version = "0.8", default-features = false } 28heapless = { version = "0.8", default-features = false }
29rand_core = "0.6.3"
30critical-section = "1.1" 29critical-section = "1.1"
31micromath = "2.0.0" 30micromath = "2.0.0"
32stm32-fmc = "0.3.0" 31stm32-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;
11use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 11use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
12use embassy_time::Timer; 12use embassy_time::Timer;
13use heapless::Vec; 13use heapless::Vec;
14use rand_core::RngCore;
15use static_cell::StaticCell; 14use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 15use {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"] }
30panic-probe = { version = "0.3", features = ["print-defmt"] } 30panic-probe = { version = "0.3", features = ["print-defmt"] }
31heapless = { version = "0.8", default-features = false } 31heapless = { version = "0.8", default-features = false }
32chrono = { version = "^0.4", default-features = false } 32chrono = { version = "^0.4", default-features = false }
33rand = { version = "0.8.5", default-features = false }
34static_cell = "2" 33static_cell = "2"
35 34
36micromath = "2.0.0" 35micromath = "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;
38use embedded_io_async::Write; 38use embedded_io_async::Write;
39use heapless::Vec; 39use heapless::Vec;
40use panic_probe as _; 40use panic_probe as _;
41use rand::RngCore;
42use static_cell::StaticCell; 41use static_cell::StaticCell;
43 42
44bind_interrupts!(struct Irqs { 43bind_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
23cortex-m-rt = "0.7.0" 23cortex-m-rt = "0.7.0"
24embedded-hal = "0.2.6" 24embedded-hal = "0.2.6"
25heapless = { version = "0.8", default-features = false } 25heapless = { version = "0.8", default-features = false }
26rand_core = { version = "0.6.3", default-features = false }
27embedded-io-async = { version = "0.6.1" } 26embedded-io-async = { version = "0.6.1" }
28static_cell = "2" 27static_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
12use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; 12use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
13use embassy_usb::{Builder, UsbDevice}; 13use embassy_usb::{Builder, UsbDevice};
14use embedded_io_async::Write; 14use embedded_io_async::Write;
15use rand_core::RngCore;
16use static_cell::StaticCell; 15use static_cell::StaticCell;
17use {defmt_rtt as _, panic_probe as _}; 16use {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" }
38embedded-storage = { version = "0.3" } 38embedded-storage = { version = "0.3" }
39static_cell = "2" 39static_cell = "2"
40portable-atomic = { version = "1.5", features = ["critical-section"] } 40portable-atomic = { version = "1.5", features = ["critical-section"] }
41rand = { 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;
14use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; 14use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
15use embassy_time::Delay; 15use embassy_time::Delay;
16use embedded_hal_bus::spi::ExclusiveDevice; 16use embedded_hal_bus::spi::ExclusiveDevice;
17use rand::RngCore;
18use static_cell::StaticCell; 17use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 18use {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" }
81embedded-can = { version = "0.4" } 81embedded-can = { version = "0.4" }
82micromath = "2.0.0" 82micromath = "2.0.0"
83panic-probe = { version = "0.3.0", features = ["print-defmt"] } 83panic-probe = { version = "0.3.0", features = ["print-defmt"] }
84rand_core = { version = "0.6", default-features = false } 84rand_core = { version = "0.9.1", default-features = false }
85rand_chacha = { version = "0.3", default-features = false } 85rand_chacha = { version = "0.9.0", default-features = false }
86static_cell = "2" 86static_cell = "2"
87portable-atomic = { version = "1.5", features = [] } 87portable-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};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; 13use embassy_stm32::{bind_interrupts, eth, peripherals, rng};
14use rand_core::RngCore;
15use static_cell::StaticCell; 14use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _}; 15use {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"
4edition = "2021" 4edition = "2021"
5 5
6[dependencies] 6[dependencies]
7rand = "0.8" 7rand = "0.9"
8serial = "0.4" 8serial = "0.4"