diff --git a/Cargo.lock b/Cargo.lock index f77e0bd..970506d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,6 +437,12 @@ dependencies = [ "heapless 0.6.1", ] +[[package]] +name = "nanorand" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1378b66f7c93a1c0f8464a19bf47df8795083842e5090f4b7305973d5a22d0" + [[package]] name = "nb" version = "0.1.3" @@ -710,10 +716,11 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=7572183#757218316620e074405bc38ff5502ef17a8a3499" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=8468f11#8468f11abacd7aba82454e6904df19c1d1ab91bb" dependencies = [ "embedded-nal", "heapless 0.6.1", + "nanorand", "smoltcp", ] diff --git a/Cargo.toml b/Cargo.toml index 0c4ab0d..f4db4d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ rev = "314fa5587d" [dependencies.smoltcp-nal] git = "https://github.com/quartiq/smoltcp-nal.git" -rev = "7572183" +rev = "8468f11" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" diff --git a/hitl/run.sh b/hitl/run.sh index 0203071..40f9039 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -17,6 +17,9 @@ python3 -m pip install -r requirements.txt cargo flash --elf target/thumbv7em-none-eabihf/release/dual-iir --chip STM32H743ZITx +# Before attempting to ping the device, sleep to allow Stabilizer to boot. +sleep 30 + # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index f6f1a3b..630fe12 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -599,13 +599,25 @@ pub fn setup( ) }; + let random_seed = { + let mut rng = + device.RNG.constrain(ccdr.peripheral.RNG, &ccdr.clocks); + let mut data = [0u8; 4]; + rng.fill(&mut data).unwrap(); + data + }; + + let mut stack = smoltcp_nal::NetworkStack::new( + interface, + sockets, + &handles, + Some(dhcp_client), + ); + + stack.seed_random_port(&random_seed); + NetworkDevices { - stack: smoltcp_nal::NetworkStack::new( - interface, - sockets, - &handles, - Some(dhcp_client), - ), + stack, phy: lan8742a, mac_address: mac_addr, }