From c2cb9a440cccd2edcd5843ba70c8f246d34d14a2 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 4 Mar 2021 17:26:10 +0100 Subject: [PATCH 01/18] Adding initial DHCP support prototype --- Cargo.lock | 15 ++++---- Cargo.toml | 7 ++-- src/bin/dual-iir.rs | 19 +++++++--- src/hardware/configuration.rs | 60 +++++++++++++++++++++++++------ src/hardware/design_parameters.rs | 2 +- 5 files changed, 77 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d5cd72..3fabcd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "derive_miniconf" version = "0.1.0" -source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa" +source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28" dependencies = [ "proc-macro2", "quote", @@ -414,10 +414,10 @@ dependencies = [ [[package]] name = "miniconf" version = "0.1.0" -source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa" +source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28" dependencies = [ "derive_miniconf", - "heapless 0.5.6", + "heapless 0.6.1", "minimq", "serde", "serde-json-core", @@ -426,13 +426,13 @@ dependencies = [ [[package]] name = "minimq" version = "0.2.0" -source = "git+https://github.com/quartiq/minimq.git?branch=master#a89a6f11d0d1f63114fb15f676022eb4fe904f56" +source = "git+https://github.com/quartiq/minimq.git?branch=feature/init-update#e686ccd89090f32990661fe49416d570e2e80835" dependencies = [ "bit_field", "embedded-nal", "enum-iterator", "generic-array 0.14.4", - "heapless 0.5.6", + "heapless 0.6.1", ] [[package]] @@ -714,11 +714,10 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4e5aeb4818706fd74c35917692008d29a5314483c8180300a582253718ce57a" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#5c62caa539d011c45453314c5872e9ca9cd9f780" dependencies = [ "embedded-nal", - "heapless 0.5.6", + "heapless 0.6.1", "smoltcp", ] diff --git a/Cargo.toml b/Cargo.toml index 9c17620..584f777 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,6 @@ enum-iterator = "0.6.0" paste = "1" dsp = { path = "dsp" } ad9959 = { path = "ad9959" } -smoltcp-nal = "0.1.0" miniconf = "0.1" generic-array = "0.14" @@ -54,7 +53,11 @@ branch = "develop" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" -branch = "master" +branch = "feature/init-update" + +[dependencies.smoltcp-nal] +git = "https://github.com/quartiq/smoltcp-nal.git" +branch = "feature/dhcp-support" [patch.crates-io.serde-json-core] git = "https://github.com/rust-embedded-community/serde-json-core.git" diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 5d51632..d4499ab 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -147,13 +147,22 @@ const APP: () = { !interface.network_stack().poll(clock.current_ms()) }); - if c.resources + match c + .resources .mqtt_interface - .lock(|interface| interface.update().unwrap()) + .lock(|interface| interface.update()) { - c.spawn.settings_update().unwrap() - } else if sleep { - cortex_m::asm::wfi(); + Ok(update) => { + if update { + c.spawn.settings_update().unwrap(); + } else if sleep { + cortex_m::asm::wfi(); + } + } + Err(miniconf::MqttError::Network( + smoltcp_nal::NetworkError::NoIpAddress, + )) => {} + Err(error) => log::info!("Unexpected error: {:?}", error), } } } diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index d3d10fe..07fbd32 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -19,13 +19,18 @@ use super::{ pub struct NetStorage { pub ip_addrs: [smoltcp::wire::IpCidr; 1], - pub sockets: [Option>; 1], + pub sockets: [Option>; 2], pub neighbor_cache: [Option<(smoltcp::wire::IpAddress, smoltcp::iface::Neighbor)>; 8], pub routes_cache: [Option<(smoltcp::wire::IpCidr, smoltcp::iface::Route)>; 8], pub tx_storage: [u8; 4096], pub rx_storage: [u8; 4096], + + pub dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata; 1], + pub dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata; 1], + pub dhcp_tx_storage: [u8; 600], + pub dhcp_rx_storage: [u8; 600], } /// The available networking devices on Stabilizer. @@ -69,10 +74,15 @@ static mut NET_STORE: NetStorage = NetStorage { )], neighbor_cache: [None; 8], routes_cache: [None; 8], - sockets: [None; 1], + sockets: [None, None], tx_storage: [0; 4096], rx_storage: [0; 4096], + + dhcp_tx_storage: [0; 600], + dhcp_rx_storage: [0; 600], + dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], + dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], }; /// Configure the stabilizer hardware for operation. @@ -519,14 +529,17 @@ pub fn setup( let store = unsafe { &mut NET_STORE }; store.ip_addrs[0] = smoltcp::wire::IpCidr::new( - smoltcp::wire::IpAddress::v4(10, 34, 16, 103), - 24, + smoltcp::wire::IpAddress::Ipv4( + smoltcp::wire::Ipv4Address::UNSPECIFIED, + ), + 0, ); - let default_v4_gw = smoltcp::wire::Ipv4Address::new(10, 34, 16, 1); let mut routes = smoltcp::iface::Routes::new(&mut store.routes_cache[..]); - routes.add_default_ipv4_route(default_v4_gw).unwrap(); + routes + .add_default_ipv4_route(smoltcp::wire::Ipv4Address::UNSPECIFIED) + .unwrap(); let neighbor_cache = smoltcp::iface::NeighborCache::new(&mut store.neighbor_cache[..]); @@ -538,7 +551,7 @@ pub fn setup( .routes(routes) .finalize(); - let sockets = { + let (mut sockets, handles) = { // Note(unsafe): Configuration is only called once, so we only access the global // storage a single time. let socket_storage = unsafe { &mut NET_STORE.sockets[..] }; @@ -562,12 +575,39 @@ pub fn setup( smoltcp::socket::TcpSocket::new(rx_buffer, tx_buffer) }; - sockets.add(tcp_socket); - sockets + let handle = sockets.add(tcp_socket); + (sockets, [handle]) + }; + + let dhcp_client = { + let rx = unsafe { &mut NET_STORE.dhcp_rx_storage[..] }; + let tx = unsafe { &mut NET_STORE.dhcp_tx_storage[..] }; + + let dhcp_rx_buffer = smoltcp::socket::RawSocketBuffer::new( + unsafe { &mut NET_STORE.dhcp_rx_metadata[..] }, + rx, + ); + + let dhcp_tx_buffer = smoltcp::socket::RawSocketBuffer::new( + unsafe { &mut NET_STORE.dhcp_tx_metadata[..] }, + tx, + ); + + smoltcp::dhcp::Dhcpv4Client::new( + &mut sockets, + dhcp_rx_buffer, + dhcp_tx_buffer, + smoltcp::time::Instant::from_millis(-1), + ) }; NetworkDevices { - stack: smoltcp_nal::NetworkStack::new(interface, sockets), + stack: smoltcp_nal::NetworkStack::new( + interface, + sockets, + &handles, + Some(dhcp_client), + ), phy: lan8742a, } }; diff --git a/src/hardware/design_parameters.rs b/src/hardware/design_parameters.rs index 9a4279b..d56cb77 100644 --- a/src/hardware/design_parameters.rs +++ b/src/hardware/design_parameters.rs @@ -43,7 +43,7 @@ pub const DDS_SYNC_CLK_DIV: u8 = 4; // The number of ticks in the ADC sampling timer. The timer runs at 100MHz, so the step size is // equal to 10ns per tick. // Currently, the sample rate is equal to: Fsample = 100/128 MHz ~ 800 KHz -pub const ADC_SAMPLE_TICKS_LOG2: u8 = 7; +pub const ADC_SAMPLE_TICKS_LOG2: u8 = 12; pub const ADC_SAMPLE_TICKS: u16 = 1 << ADC_SAMPLE_TICKS_LOG2; // The desired ADC sample processing buffer size. From 148a3c8281f829ae02964af35fe96d260ecfaf92 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Fri, 5 Mar 2021 17:58:41 +0000 Subject: [PATCH 02/18] hardware: Enable DEMCR TRCENA on boot for cycle counter Previously, the cycle counter would only work correctly when running in the debugger (which would also enable tracing). GitHub: Fixes #299. --- src/hardware/configuration.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index d3d10fe..e8f3029 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -825,6 +825,14 @@ pub fn setup( None }; + let cycle_counter = { + // Set TRCENA bit, which is required for DWT counter to tick. (This is also + // set automatically when running in the debugger, and only cleared on power + // reset, not on soft reset.) + core.DCB.enable_trace(); + CycleCounter::new(core.DWT, ccdr.clocks.c_ck()) + }; + let stabilizer = StabilizerDevices { afes, adcs, @@ -833,7 +841,7 @@ pub fn setup( net: network_devices, adc_dac_timer: sampling_timer, timestamp_timer, - cycle_counter: CycleCounter::new(core.DWT, ccdr.clocks.c_ck()), + cycle_counter, }; // info!("Version {} {}", build_info::PKG_VERSION, build_info::GIT_VERSION.unwrap()); From 4a9c2fe23af45baec269c044d3cdd2e7194c747b Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 15 Mar 2021 11:41:13 +0100 Subject: [PATCH 03/18] Updating after DHCP PR review --- Cargo.lock | 4 ++-- Cargo.toml | 1 - src/bin/dual-iir.rs | 8 +++++++- src/bin/lockin-external.rs | 8 +++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ddb9d9..6635d9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "minimq" version = "0.2.0" -source = "git+https://github.com/quartiq/minimq.git?branch=feature/init-update#e686ccd89090f32990661fe49416d570e2e80835" +source = "git+https://github.com/quartiq/minimq.git#933687c2e4bc8a4d972de9a4d1508b0b554a8b38" dependencies = [ "bit_field", "embedded-nal", @@ -708,7 +708,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#5c62caa539d011c45453314c5872e9ca9cd9f780" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#b3de37939140d04a64c79afddb97b81ff49e1f23" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index f49855f..3f0caaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,6 @@ branch = "develop" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" -branch = "feature/init-update" [dependencies.smoltcp-nal] git = "https://github.com/quartiq/smoltcp-nal.git" diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index d4499ab..34b852a 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -144,7 +144,13 @@ const APP: () = { loop { let sleep = c.resources.mqtt_interface.lock(|interface| { - !interface.network_stack().poll(clock.current_ms()) + match interface.network_stack().poll(clock.current_ms()) { + Ok(updated) => !updated, + Err(err) => { + log::info!("Network error: {:?}", err); + true + } + } }); match c diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index 306ae45..8635dc9 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -208,7 +208,13 @@ const APP: () = { loop { let sleep = c.resources.mqtt_interface.lock(|interface| { - !interface.network_stack().poll(clock.current_ms()) + match interface.network_stack().poll(clock.current_ms()) { + Ok(updated) => !updated, + Err(err) => { + log::info!("Network error: {:?}", err); + true + } + } }); if c.resources From 3c574467a296800e7839c0e8a843a4e1389a6771 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 15 Mar 2021 12:29:03 +0100 Subject: [PATCH 04/18] Updating dependencies --- Cargo.toml | 3 ++- src/hardware/design_parameters.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3f0caaf..f958a7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ enum-iterator = "0.6.0" paste = "1" dsp = { path = "dsp" } ad9959 = { path = "ad9959" } +smoltcp-nal = "0.1." miniconf = "0.1" generic-array = "0.14" @@ -53,7 +54,7 @@ branch = "develop" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" -[dependencies.smoltcp-nal] +[patch.crates-io.smoltcp-nal] git = "https://github.com/quartiq/smoltcp-nal.git" branch = "feature/dhcp-support" diff --git a/src/hardware/design_parameters.rs b/src/hardware/design_parameters.rs index d56cb77..9a4279b 100644 --- a/src/hardware/design_parameters.rs +++ b/src/hardware/design_parameters.rs @@ -43,7 +43,7 @@ pub const DDS_SYNC_CLK_DIV: u8 = 4; // The number of ticks in the ADC sampling timer. The timer runs at 100MHz, so the step size is // equal to 10ns per tick. // Currently, the sample rate is equal to: Fsample = 100/128 MHz ~ 800 KHz -pub const ADC_SAMPLE_TICKS_LOG2: u8 = 12; +pub const ADC_SAMPLE_TICKS_LOG2: u8 = 7; pub const ADC_SAMPLE_TICKS: u16 = 1 << ADC_SAMPLE_TICKS_LOG2; // The desired ADC sample processing buffer size. From 8c616cebecb395ba80b40ca81df91ea17abfc940 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 15 Mar 2021 12:30:18 +0100 Subject: [PATCH 05/18] Adding unstaged changes --- Cargo.lock | 3 +-- Cargo.toml | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6635d9c..42d6914 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,8 +697,7 @@ dependencies = [ [[package]] name = "smoltcp" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab527c390c7e107f687bd92a886a083fde61b8cdc700b37f3d7e4346ffd8fae1" +source = "git+https://github.com/ryan-summers/smoltcp.git?branch=feature/dhcp-lease-updates#e3954ebb8149341c52a4992e037d4b5109387910" dependencies = [ "bitflags", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index f958a7a..c823019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ enum-iterator = "0.6.0" paste = "1" dsp = { path = "dsp" } ad9959 = { path = "ad9959" } -smoltcp-nal = "0.1." +smoltcp-nal = "0.1.0" miniconf = "0.1" generic-array = "0.14" @@ -62,6 +62,10 @@ branch = "feature/dhcp-support" git = "https://github.com/rust-embedded-community/serde-json-core.git" branch = "master" +[patch.crates-io.smoltcp] +git = "https://github.com/ryan-summers/smoltcp.git" +branch = "feature/dhcp-lease-updates" + [dependencies.mcp23017] git = "https://github.com/mrd0ll4r/mcp23017.git" From 331e21b00a83e40222c6ab8e053f25106d100183 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 14:47:14 +0100 Subject: [PATCH 06/18] Updating dependencies --- Cargo.lock | 2 +- src/bin/dual-iir.rs | 2 +- src/bin/lockin-external.rs | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 42d6914..b1fc810 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -707,7 +707,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#b3de37939140d04a64c79afddb97b81ff49e1f23" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#79fd03e3d051402c71116839606e5b3294372c98" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 34b852a..4a27d48 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -148,7 +148,7 @@ const APP: () = { Ok(updated) => !updated, Err(err) => { log::info!("Network error: {:?}", err); - true + false } } }); diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index 8635dc9..cd03202 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -217,13 +217,22 @@ const APP: () = { } }); - if c.resources + match c + .resources .mqtt_interface - .lock(|interface| interface.update().unwrap()) + .lock(|interface| interface.update()) { - c.spawn.settings_update().unwrap() - } else if sleep { - cortex_m::asm::wfi(); + Ok(update) => { + if update { + c.spawn.settings_update().unwrap(); + } else if sleep { + cortex_m::asm::wfi(); + } + } + Err(miniconf::MqttError::Network( + smoltcp_nal::NetworkError::NoIpAddress, + )) => {} + Err(error) => log::info!("Unexpected error: {:?}", error), } } } From e54a33797c3aeb12d0233e26730bcdbbb1088616 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 14:54:57 +0100 Subject: [PATCH 07/18] Updating comment about time --- src/hardware/configuration.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index aead723..eb34274 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -597,6 +597,9 @@ pub fn setup( &mut sockets, dhcp_rx_buffer, dhcp_tx_buffer, + // Smoltcp indicates that an instant with a negative time is indicative that time is + // not yet available. We can't get the current instant yet, so indicate an invalid + // time value. smoltcp::time::Instant::from_millis(-1), ) }; From df2f122f84f41b5c80ffad625f6084258b5ab35a Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 14:56:31 +0100 Subject: [PATCH 08/18] Fixing sleep state on error --- src/bin/lockin-external.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index cd03202..7d2db0e 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -212,7 +212,7 @@ const APP: () = { Ok(updated) => !updated, Err(err) => { log::info!("Network error: {:?}", err); - true + false } } }); From 3fb2bafaaa6fb123f867db194d33715d21ebc02e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 15:08:56 +0100 Subject: [PATCH 09/18] Implementing safe net storage semantics --- src/hardware/configuration.rs | 82 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 46 deletions(-) diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index eb34274..dfab1e0 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -33,6 +33,26 @@ pub struct NetStorage { pub dhcp_rx_storage: [u8; 600], } +impl NetStorage { + pub fn new() -> Self { + NetStorage { + // Placeholder for the real IP address, which is initialized at runtime. + ip_addrs: [smoltcp::wire::IpCidr::Ipv6( + smoltcp::wire::Ipv6Cidr::SOLICITED_NODE_PREFIX, + )], + neighbor_cache: [None; 8], + routes_cache: [None; 8], + sockets: [None, None], + tx_storage: [0; 4096], + rx_storage: [0; 4096], + dhcp_tx_storage: [0; 600], + dhcp_rx_storage: [0; 600], + dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], + dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], + } + } +} + /// The available networking devices on Stabilizer. pub struct NetworkDevices { pub stack: NetworkStack, @@ -64,27 +84,6 @@ pub struct PounderDevices { /// Static storage for the ethernet DMA descriptor ring. static mut DES_RING: ethernet::DesRing = ethernet::DesRing::new(); -/// Static, global-scope network storage for the ethernet interface. -/// -/// This is a static singleton so that the network storage can be referenced from all contexts. -static mut NET_STORE: NetStorage = NetStorage { - // Placeholder for the real IP address, which is initialized at runtime. - ip_addrs: [smoltcp::wire::IpCidr::Ipv6( - smoltcp::wire::Ipv6Cidr::SOLICITED_NODE_PREFIX, - )], - neighbor_cache: [None; 8], - routes_cache: [None; 8], - sockets: [None, None], - - tx_storage: [0; 4096], - rx_storage: [0; 4096], - - dhcp_tx_storage: [0; 600], - dhcp_rx_storage: [0; 600], - dhcp_rx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], - dhcp_tx_metadata: [smoltcp::socket::RawPacketMetadata::EMPTY; 1], -}; - /// Configure the stabilizer hardware for operation. /// /// # Args @@ -526,7 +525,10 @@ pub fn setup( unsafe { ethernet::enable_interrupt() }; - let store = unsafe { &mut NET_STORE }; + // Note(unwrap): The hardware configuration function is only allowed to be called once. + // Unwrapping is intended to panic if called again to prevent re-use of global memory. + let store = + cortex_m::singleton!(: NetStorage = NetStorage::new()).unwrap(); store.ip_addrs[0] = smoltcp::wire::IpCidr::new( smoltcp::wire::IpAddress::Ipv4( @@ -552,25 +554,16 @@ pub fn setup( .finalize(); let (mut sockets, handles) = { - // Note(unsafe): Configuration is only called once, so we only access the global - // storage a single time. - let socket_storage = unsafe { &mut NET_STORE.sockets[..] }; - let mut sockets = smoltcp::socket::SocketSet::new(socket_storage); + let mut sockets = + smoltcp::socket::SocketSet::new(&mut store.sockets[..]); let tcp_socket = { - let rx_buffer = { - // Note(unsafe): Configuration is only called once, so we only access the global - // storage a single time. - let storage = unsafe { &mut NET_STORE.rx_storage[..] }; - smoltcp::socket::TcpSocketBuffer::new(storage) - }; - - let tx_buffer = { - // Note(unsafe): Configuration is only called once, so we only access the global - // storage a single time. - let storage = unsafe { &mut NET_STORE.tx_storage[..] }; - smoltcp::socket::TcpSocketBuffer::new(storage) - }; + let rx_buffer = smoltcp::socket::TcpSocketBuffer::new( + &mut store.rx_storage[..], + ); + let tx_buffer = smoltcp::socket::TcpSocketBuffer::new( + &mut store.tx_storage[..], + ); smoltcp::socket::TcpSocket::new(rx_buffer, tx_buffer) }; @@ -580,17 +573,14 @@ pub fn setup( }; let dhcp_client = { - let rx = unsafe { &mut NET_STORE.dhcp_rx_storage[..] }; - let tx = unsafe { &mut NET_STORE.dhcp_tx_storage[..] }; - let dhcp_rx_buffer = smoltcp::socket::RawSocketBuffer::new( - unsafe { &mut NET_STORE.dhcp_rx_metadata[..] }, - rx, + &mut store.dhcp_rx_metadata[..], + &mut store.dhcp_rx_storage[..], ); let dhcp_tx_buffer = smoltcp::socket::RawSocketBuffer::new( - unsafe { &mut NET_STORE.dhcp_tx_metadata[..] }, - tx, + &mut store.dhcp_tx_metadata[..], + &mut store.dhcp_tx_storage[..], ); smoltcp::dhcp::Dhcpv4Client::new( From 0577a99bbe9e46ee7928a2b2047dfee973b9caf6 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 15:55:30 +0100 Subject: [PATCH 10/18] Updating dependencies --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1fc810..f56d52d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -707,7 +707,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/dhcp-support#79fd03e3d051402c71116839606e5b3294372c98" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=main#56519012d7c6a382eaa0d7ecb26f2701771d9ce8" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index c823019..79124dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ git = "https://github.com/quartiq/minimq.git" [patch.crates-io.smoltcp-nal] git = "https://github.com/quartiq/smoltcp-nal.git" -branch = "feature/dhcp-support" +branch = "main" [patch.crates-io.serde-json-core] git = "https://github.com/rust-embedded-community/serde-json-core.git" From 1b328a3d2886eb7621ad94509792d3ffefe4e4d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 15:28:50 +0000 Subject: [PATCH 11/18] build(deps): bump heapless from 0.5.6 to 0.6.1 Bumps [heapless](https://github.com/japaric/heapless) from 0.5.6 to 0.6.1. - [Release notes](https://github.com/japaric/heapless/releases) - [Changelog](https://github.com/japaric/heapless/blob/master/CHANGELOG.md) - [Commits](https://github.com/japaric/heapless/compare/v0.5.6...v0.6.1) Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f56d52d..129e311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -341,7 +341,6 @@ dependencies = [ "as-slice", "generic-array 0.13.3", "hash32", - "serde", "stable_deref_trait", ] @@ -354,6 +353,7 @@ dependencies = [ "as-slice", "generic-array 0.14.4", "hash32", + "serde", "stable_deref_trait", ] @@ -728,7 +728,7 @@ dependencies = [ "embedded-hal", "enum-iterator", "generic-array 0.14.4", - "heapless 0.5.6", + "heapless 0.6.1", "log", "mcp23017", "miniconf", diff --git a/Cargo.toml b/Cargo.toml index 79124dd..6b14532 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ cortex-m-log = { version = "0.7", features = ["log-integration"] } log = "0.4" panic-semihosting = { version = "0.5", optional = true } serde = { version = "1.0", features = ["derive"], default-features = false } -heapless = { version = "0.5", features = ["serde"] } +heapless = { version = "0.6", features = ["serde"] } cortex-m-rtic = "0.5.6" embedded-hal = "0.2.4" nb = "1.0.0" From eed190be12d2f4c074107efca61b5d89ad16a35f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 15:36:37 +0000 Subject: [PATCH 12/18] build(deps): bump paste from 1.0.4 to 1.0.5 Bumps [paste](https://github.com/dtolnay/paste) from 1.0.4 to 1.0.5. - [Release notes](https://github.com/dtolnay/paste/releases) - [Commits](https://github.com/dtolnay/paste/compare/1.0.4...1.0.5) Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 129e311..d784d15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -544,9 +544,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] name = "ppv-lite86" From e4b476e49748f075adc97a6202c76a06c9cfa3ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Mar 2021 15:46:45 +0000 Subject: [PATCH 13/18] Bump serde from 1.0.123 to 1.0.124 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.123 to 1.0.124. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.123...v1.0.124) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d784d15..b435a6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -667,9 +667,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -685,9 +685,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.123" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", From 4b9954761e1cee9410ebdd932a7286dd6e96b824 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 25 Mar 2021 09:24:58 +0100 Subject: [PATCH 14/18] Updating smoltcp dependency --- Cargo.lock | 6 +++--- Cargo.toml | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b435a6b..946a634 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,9 +390,9 @@ dependencies = [ [[package]] name = "managed" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75de51135344a4f8ed3cfe2720dc27736f7711989703a0b43aadf3753c55577" +checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" [[package]] name = "matrixmultiply" @@ -697,7 +697,7 @@ dependencies = [ [[package]] name = "smoltcp" version = "0.7.0" -source = "git+https://github.com/ryan-summers/smoltcp.git?branch=feature/dhcp-lease-updates#e3954ebb8149341c52a4992e037d4b5109387910" +source = "git+https://github.com/smoltcp-rs/smoltcp.git#43567b9743cb9f422de83fad9ff42a6d13f6e5ee" dependencies = [ "bitflags", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 6b14532..3f4142b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,8 +63,7 @@ git = "https://github.com/rust-embedded-community/serde-json-core.git" branch = "master" [patch.crates-io.smoltcp] -git = "https://github.com/ryan-summers/smoltcp.git" -branch = "feature/dhcp-lease-updates" +git = "https://github.com/smoltcp-rs/smoltcp.git" [dependencies.mcp23017] git = "https://github.com/mrd0ll4r/mcp23017.git" From 769945d7a23ca3e96ebd0f9793fb67d3d1195621 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 25 Mar 2021 09:26:36 +0100 Subject: [PATCH 15/18] Adding patch comment --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3f4142b..8d32d80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,8 @@ git = "https://github.com/rust-embedded-community/serde-json-core.git" branch = "master" [patch.crates-io.smoltcp] +# We manually patch smoltcp so that we can get access to unreleased updates to the DHCP server. When +# a new release of smoltcp is made, we can remove this patch. git = "https://github.com/smoltcp-rs/smoltcp.git" [dependencies.mcp23017] From 6c892f4ea3b50a6c9ea5c062f9dad8e5d5ab149e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Mar 2021 08:40:58 +0000 Subject: [PATCH 16/18] Bump num from 0.3.1 to 0.4.0 Bumps [num](https://github.com/rust-num/num) from 0.3.1 to 0.4.0. - [Release notes](https://github.com/rust-num/num/releases) - [Changelog](https://github.com/rust-num/num/blob/master/RELEASES.md) - [Commits](https://github.com/rust-num/num/compare/num-0.3.1...num-0.4.0) Signed-off-by: dependabot[bot] --- Cargo.lock | 21 +++++++++++++++------ dsp/Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 946a634..1c76ff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -457,7 +457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04" dependencies = [ "matrixmultiply", - "num-complex", + "num-complex 0.3.1", "num-integer", "num-traits", "rawpointer", @@ -471,11 +471,11 @@ checksum = "2178127478ae4ee9be7180bc9c3bffb6354dd7238400db567102f98c413a9f35" [[package]] name = "num" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ - "num-complex", + "num-complex 0.4.0", "num-integer", "num-iter", "num-rational", @@ -491,6 +491,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-complex" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +dependencies = [ + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -514,9 +523,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" dependencies = [ "autocfg", "num-integer", diff --git a/dsp/Cargo.toml b/dsp/Cargo.toml index 4c675ff..9b92078 100644 --- a/dsp/Cargo.toml +++ b/dsp/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" libm = "0.2.1" serde = { version = "1.0", features = ["derive"], default-features = false } generic-array = "0.14" -num = { version = "0.3.1", default-features = false } +num = { version = "0.4.0", default-features = false } miniconf = "0.1" [dev-dependencies] From 3c877404b4f6a94dd64d0939a7855fd843e9cb62 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Wed, 31 Mar 2021 15:22:24 +0800 Subject: [PATCH 17/18] update cargosha256 --- cargosha256-dual-iir.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargosha256-dual-iir.nix b/cargosha256-dual-iir.nix index d58968f..2d89c3a 100644 --- a/cargosha256-dual-iir.nix +++ b/cargosha256-dual-iir.nix @@ -1 +1 @@ -"138kpxzxs73zhmd4xi5kw3fddb05gac4mpngizm01831n1ycyhl0" +"06qsl59bljr637xcrplbij7ma8l7waryi4lkbd4fxjac0gqpn55s" From cc61e2eedf7030dbc1b90486e8c6f2a9144a3aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 6 Apr 2021 16:28:56 +0200 Subject: [PATCH 18/18] README: add both plain-CI and HITL badges --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 19b5a0d..4250d6a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![QUARTIQ Matrix Chat](https://img.shields.io/matrix/quartiq:matrix.org)](https://matrix.to/#/#quartiq:matrix.org) +[![Continuous Integration](https://github.com/quartiq/stabilizer/actions/workflows/ci.yml/badge.svg)](https://github.com/quartiq/stabilizer/actions/workflows/ci.yml) [![HITL (private)](https://github.com/quartiq/hitl/workflows/Stabilizer/badge.svg)](https://github.com/quartiq/hitl/actions?query=workflow%3AStabilizer) # Stabilizer Firmware