From 4606d939001c2d126f0d9e904237f1e3f96ae773 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 4 Mar 2021 18:32:02 +0000 Subject: [PATCH 01/70] Update stm32h7xx-hal I haven't done any runtime tests using Pounder, but it seems like the API change is just a consequence of making the QSPI address width runtime-configurable. --- Cargo.lock | 12 +++++++----- src/hardware/pounder/mod.rs | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86401c7..095de10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ad9959" version = "0.1.0" @@ -750,12 +752,12 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stm32h7" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7571f17d1ed7d67957d0004de6c52bd1ef5e736ed5ddc2bcecf001512269f77c" +checksum = "8b672c837e0ee8158ecc7fce0f9a948dd0693a9c588338e728d14b73307a0b7d" dependencies = [ "bare-metal 0.2.5", - "cortex-m 0.6.7", + "cortex-m 0.7.1", "cortex-m-rt", "vcell", ] @@ -763,11 +765,11 @@ dependencies = [ [[package]] name = "stm32h7xx-hal" version = "0.8.0" -source = "git+https://github.com/stm32-rs/stm32h7xx-hal?branch=master#08231e334a11236fe556668ac19cb1c214da2406" +source = "git+https://github.com/stm32-rs/stm32h7xx-hal?branch=master#ad2a1ae9831dd34e171cc178cdad84e770b4c0ae" dependencies = [ "bare-metal 1.0.0", "cast", - "cortex-m 0.6.7", + "cortex-m 0.7.1", "cortex-m-rt", "embedded-dma", "embedded-hal", diff --git a/src/hardware/pounder/mod.rs b/src/hardware/pounder/mod.rs index 0497a37..32a8e80 100644 --- a/src/hardware/pounder/mod.rs +++ b/src/hardware/pounder/mod.rs @@ -231,14 +231,16 @@ impl ad9959::Interface for QspiInterface { }; self.qspi - .write(encoded_address, &encoded_payload) + .write(encoded_address.into(), &encoded_payload) .map_err(|_| Error::Qspi) } ad9959::Mode::FourBitSerial => { if self.streaming { Err(Error::Qspi) } else { - self.qspi.write(addr, data).map_err(|_| Error::Qspi)?; + self.qspi + .write(addr.into(), data) + .map_err(|_| Error::Qspi)?; Ok(()) } } @@ -257,7 +259,7 @@ impl ad9959::Interface for QspiInterface { } self.qspi - .read(0x80_u8 | addr, dest) + .read((0x80_u8 | addr).into(), dest) .map_err(|_| Error::Qspi) } } From a717630c535ba5417058a494c14795d50fe77c03 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 17 Mar 2021 20:16:13 +0100 Subject: [PATCH 02/70] Adding prototype PHY reset detection --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/bin/dual-iir.rs | 78 +++++++++--------------------- src/bin/lockin-external.rs | 78 +++++++++--------------------- src/hardware/configuration.rs | 6 +-- src/hardware/mod.rs | 2 + src/lib.rs | 1 + src/net/mod.rs | 89 +++++++++++++++++++++++++++++++++++ 8 files changed, 141 insertions(+), 117 deletions(-) create mode 100644 src/net/mod.rs diff --git a/Cargo.lock b/Cargo.lock index b435a6b..8b66fe7 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=main#56519012d7c6a382eaa0d7ecb26f2701771d9ce8" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/reset-support#a6db6579100987502563578fb386109ad08758a7" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index 6b14532..f1d88b3 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 = "main" +branch = "feature/reset-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 4a27d48..6c391c7 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -4,17 +4,18 @@ use stm32h7xx_hal as hal; -use stabilizer::hardware; +use stabilizer::{hardware, net}; -use miniconf::{minimq, Miniconf, MqttInterface}; +use miniconf::Miniconf; use serde::Deserialize; use dsp::iir; use hardware::{ - Adc0Input, Adc1Input, AfeGain, CycleCounter, Dac0Output, Dac1Output, - NetworkStack, AFE0, AFE1, + Adc0Input, Adc1Input, AfeGain, Dac0Output, Dac1Output, AFE0, AFE1, }; +use net::{Action, MqttSettings}; + const SCALE: f32 = i16::MAX as _; // The number of cascaded IIR biquads per channel. Select 1 or 2! @@ -41,9 +42,7 @@ const APP: () = { afes: (AFE0, AFE1), adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), - mqtt_interface: - MqttInterface, - clock: CycleCounter, + mqtt_settings: MqttSettings, // Format: iir_state[ch][cascade-no][coeff] #[init([[[0.; 5]; IIR_CASCADE_LENGTH]; 2])] @@ -57,23 +56,13 @@ const APP: () = { // Configure the microcontroller let (mut stabilizer, _pounder) = hardware::setup(c.core, c.device); - let mqtt_interface = { - let mqtt_client = { - minimq::MqttClient::new( - hardware::design_parameters::MQTT_BROKER.into(), - "", - stabilizer.net.stack, - ) - .unwrap() - }; - - MqttInterface::new( - mqtt_client, - "dt/sinara/stabilizer", - Settings::default(), - ) - .unwrap() - }; + let mqtt_settings = MqttSettings::new( + stabilizer.net.stack, + "", + "dt/sinara/stabilizer", + stabilizer.net.phy, + stabilizer.cycle_counter, + ); // Enable ADC/DAC events stabilizer.adcs.0.start(); @@ -85,11 +74,10 @@ const APP: () = { stabilizer.adc_dac_timer.start(); init::LateResources { - mqtt_interface, afes: stabilizer.afes, adcs: stabilizer.adcs, dacs: stabilizer.dacs, - clock: stabilizer.cycle_counter, + mqtt_settings, } } @@ -138,44 +126,22 @@ const APP: () = { } } - #[idle(resources=[mqtt_interface, clock], spawn=[settings_update])] + #[idle(resources=[mqtt_settings], spawn=[settings_update])] fn idle(mut c: idle::Context) -> ! { - let clock = c.resources.clock; - loop { - let sleep = c.resources.mqtt_interface.lock(|interface| { - match interface.network_stack().poll(clock.current_ms()) { - Ok(updated) => !updated, - Err(err) => { - log::info!("Network error: {:?}", err); - false - } + match c.resources.mqtt_settings.lock(|settings| settings.update()) { + Some(Action::Sleep) => cortex_m::asm::wfi(), + Some(Action::UpdateSettings) => { + c.spawn.settings_update().unwrap() } - }); - - match c - .resources - .mqtt_interface - .lock(|interface| interface.update()) - { - 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), + _ => {} } } } - #[task(priority = 1, resources=[mqtt_interface, afes, iir_ch])] + #[task(priority = 1, resources=[mqtt_settings, afes, iir_ch])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_interface.settings; + let settings = &c.resources.mqtt_settings.mqtt_interface.settings; // Update the IIR channels. c.resources.iir_ch.lock(|iir| *iir = settings.iir_ch); diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index 7d2db0e..bb84e91 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -4,16 +4,18 @@ use generic_array::typenum::U4; -use miniconf::{minimq, Miniconf, MqttInterface}; use serde::Deserialize; use dsp::{Accu, Complex, ComplexExt, Lockin, RPLL}; use stabilizer::hardware::{ - design_parameters, setup, Adc0Input, Adc1Input, AfeGain, CycleCounter, - Dac0Output, Dac1Output, InputStamper, NetworkStack, AFE0, AFE1, + design_parameters, setup, Adc0Input, Adc1Input, AfeGain, Dac0Output, + Dac1Output, InputStamper, AFE0, AFE1, }; +use miniconf::Miniconf; +use stabilizer::net::{Action, MqttSettings}; + #[derive(Copy, Clone, Debug, Deserialize, Miniconf)] enum Conf { PowerPhase, @@ -56,11 +58,7 @@ const APP: () = { afes: (AFE0, AFE1), adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), - clock: CycleCounter, - - mqtt_interface: - MqttInterface, - + mqtt_settings: MqttSettings, settings: Settings, timestamper: InputStamper, @@ -73,21 +71,13 @@ const APP: () = { // Configure the microcontroller let (mut stabilizer, _pounder) = setup(c.core, c.device); - let mqtt_interface = { - let mqtt_client = minimq::MqttClient::new( - design_parameters::MQTT_BROKER.into(), - "", - stabilizer.net.stack, - ) - .unwrap(); - - MqttInterface::new( - mqtt_client, - "dt/sinara/lockin", - Settings::default(), - ) - .unwrap() - }; + let mqtt_settings = MqttSettings::new( + stabilizer.net.stack, + "", + "dt/sinara/lockin", + stabilizer.net.phy, + stabilizer.cycle_counter, + ); let settings = Settings::default(); @@ -118,10 +108,8 @@ const APP: () = { afes: stabilizer.afes, adcs: stabilizer.adcs, dacs: stabilizer.dacs, + mqtt_settings, timestamper: stabilizer.timestamper, - clock: stabilizer.cycle_counter, - - mqtt_interface, settings, @@ -202,44 +190,22 @@ const APP: () = { } } - #[idle(resources=[mqtt_interface, clock], spawn=[settings_update])] + #[idle(resources=[mqtt_settings], spawn=[settings_update])] fn idle(mut c: idle::Context) -> ! { - let clock = c.resources.clock; - loop { - let sleep = c.resources.mqtt_interface.lock(|interface| { - match interface.network_stack().poll(clock.current_ms()) { - Ok(updated) => !updated, - Err(err) => { - log::info!("Network error: {:?}", err); - false - } + match c.resources.mqtt_settings.lock(|settings| settings.update()) { + Some(Action::Sleep) => cortex_m::asm::wfi(), + Some(Action::UpdateSettings) => { + c.spawn.settings_update().unwrap() } - }); - - match c - .resources - .mqtt_interface - .lock(|interface| interface.update()) - { - 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), + _ => {} } } } - #[task(priority = 1, resources=[mqtt_interface, settings, afes])] + #[task(priority = 1, resources=[mqtt_settings, settings, afes])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_interface.settings; + let settings = &c.resources.mqtt_settings.mqtt_interface.settings; c.resources.afes.0.set_gain(settings.afe[0]); c.resources.afes.1.set_gain(settings.afe[1]); diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index dfab1e0..74307dd 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -13,8 +13,8 @@ use embedded_hal::digital::v2::{InputPin, OutputPin}; use super::{ adc, afe, cycle_counter::CycleCounter, dac, design_parameters, - digital_input_stamper, eeprom, pounder, timers, DdsOutput, NetworkStack, - AFE0, AFE1, + digital_input_stamper, eeprom, pounder, timers, DdsOutput, EthernetPhy, + NetworkStack, AFE0, AFE1, }; pub struct NetStorage { @@ -56,7 +56,7 @@ impl NetStorage { /// The available networking devices on Stabilizer. pub struct NetworkDevices { pub stack: NetworkStack, - pub phy: ethernet::phy::LAN8742A, + pub phy: EthernetPhy, } /// The available hardware interfaces on Stabilizer. diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index cc7a34a..60e7768 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -40,6 +40,8 @@ pub type NetworkStack = smoltcp_nal::NetworkStack< hal::ethernet::EthernetDMA<'static>, >; +pub type EthernetPhy = hal::ethernet::phy::LAN8742A; + pub use configuration::{setup, PounderDevices, StabilizerDevices}; #[inline(never)] diff --git a/src/lib.rs b/src/lib.rs index 0c9bf2a..975b08f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,3 +5,4 @@ extern crate log; pub mod hardware; +pub mod net; diff --git a/src/net/mod.rs b/src/net/mod.rs new file mode 100644 index 0000000..a996555 --- /dev/null +++ b/src/net/mod.rs @@ -0,0 +1,89 @@ +use crate::hardware::{ + design_parameters::MQTT_BROKER, CycleCounter, EthernetPhy, NetworkStack, +}; + +use miniconf::{minimq, MqttInterface}; + +pub enum Action { + Sleep, + UpdateSettings, +} + +pub struct MqttSettings +where + S: miniconf::Miniconf + Default, +{ + pub mqtt_interface: MqttInterface, + clock: CycleCounter, + phy: EthernetPhy, + network_was_reset: bool, +} + +impl MqttSettings +where + S: miniconf::Miniconf + Default, +{ + pub fn new( + stack: NetworkStack, + client_id: &str, + prefix: &str, + phy: EthernetPhy, + clock: CycleCounter, + ) -> Self { + let mqtt_interface = { + let mqtt_client = { + minimq::MqttClient::new(MQTT_BROKER.into(), client_id, stack) + .unwrap() + }; + + MqttInterface::new(mqtt_client, prefix, S::default()).unwrap() + }; + + Self { + mqtt_interface, + clock, + phy, + network_was_reset: false, + } + } + + pub fn update(&mut self) -> Option { + let now = self.clock.current_ms(); + + let sleep = match self.mqtt_interface.network_stack().poll(now) { + Ok(updated) => !updated, + Err(err) => { + log::info!("Network error: {:?}", err); + false + } + }; + + // If the PHY indicates there's no more ethernet link, reset the network stack and close all + // sockets. + if self.phy.poll_link() == false { + // Only reset the network stack once per link reconnection. This prevents us from + // sending an excessive number of DHCP requests. + if !self.network_was_reset { + self.network_was_reset = true; + self.mqtt_interface.network_stack().reset(); + } + } else { + self.network_was_reset = false; + } + + match self.mqtt_interface.update() { + Ok(true) => Some(Action::UpdateSettings), + Ok(false) if sleep => Some(Action::Sleep), + Ok(_) => None, + + Err(miniconf::MqttError::Network( + smoltcp_nal::NetworkError::NoIpAddress, + )) => None, + + Err(error) => { + log::info!("Unexpected error: {:?}", error); + None + } + } + } +} From 9459152f6f71122a3a97565d85252c32af81a469 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 24 Mar 2021 13:40:17 +0100 Subject: [PATCH 03/70] Updating dependencies --- Cargo.lock | 8 ++++---- Cargo.toml | 3 +-- src/net/mod.rs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b66fe7..d203a3c 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#1bff999a6f3f7adf623d837ea96cc807e1b3a470" dependencies = [ "bitflags", "byteorder", @@ -707,7 +707,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/reset-support#a6db6579100987502563578fb386109ad08758a7" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/reset-support#c43e751afe3c14aac153fa4425231270dbfd918b" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index f1d88b3..fe610d5 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" diff --git a/src/net/mod.rs b/src/net/mod.rs index a996555..1939703 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -65,7 +65,7 @@ where // sending an excessive number of DHCP requests. if !self.network_was_reset { self.network_was_reset = true; - self.mqtt_interface.network_stack().reset(); + self.mqtt_interface.network_stack().handle_link_reset(); } } else { self.network_was_reset = false; From 5e448f284bde0b7c43a85b278266bb6d7298123e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 24 Mar 2021 13:48:34 +0100 Subject: [PATCH 04/70] Updating net module --- src/bin/dual-iir.rs | 2 +- src/bin/lockin-external.rs | 2 +- src/net/mod.rs | 35 +++++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 6c391c7..0e2215b 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -141,7 +141,7 @@ const APP: () = { #[task(priority = 1, resources=[mqtt_settings, afes, iir_ch])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_settings.mqtt_interface.settings; + let settings = &c.resources.mqtt_settings.mqtt.settings; // Update the IIR channels. c.resources.iir_ch.lock(|iir| *iir = settings.iir_ch); diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index bb84e91..b62ea42 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -205,7 +205,7 @@ const APP: () = { #[task(priority = 1, resources=[mqtt_settings, settings, afes])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_settings.mqtt_interface.settings; + let settings = &c.resources.mqtt_settings.mqtt.settings; c.resources.afes.0.set_gain(settings.afe[0]); c.resources.afes.1.set_gain(settings.afe[1]); diff --git a/src/net/mod.rs b/src/net/mod.rs index 1939703..f38f3d9 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -4,16 +4,21 @@ use crate::hardware::{ use miniconf::{minimq, MqttInterface}; +/// Potential actions for firmware to take. pub enum Action { + /// Indicates that firmware can sleep for the next event. Sleep, + + /// Indicates that settings have updated and firmware needs to propogate changes. UpdateSettings, } +/// MQTT settings interface. pub struct MqttSettings where S: miniconf::Miniconf + Default, { - pub mqtt_interface: MqttInterface, + pub mqtt: MqttInterface, clock: CycleCounter, phy: EthernetPhy, network_was_reset: bool, @@ -23,6 +28,14 @@ impl MqttSettings where S: miniconf::Miniconf + Default, { + /// Construct a new MQTT settings interface. + /// + /// # Args + /// * `stack` - The network stack to use for communication. + /// * `client_id` - The ID of the MQTT client. May be an empty string for auto-assigning. + /// * `prefix` - The MQTT device prefix to use for this device. + /// * `phy` - The PHY driver for querying the link state. + /// * `clock` - The clock to utilize for querying the current system time. pub fn new( stack: NetworkStack, client_id: &str, @@ -30,7 +43,7 @@ where phy: EthernetPhy, clock: CycleCounter, ) -> Self { - let mqtt_interface = { + let mqtt = { let mqtt_client = { minimq::MqttClient::new(MQTT_BROKER.into(), client_id, stack) .unwrap() @@ -40,17 +53,22 @@ where }; Self { - mqtt_interface, + mqtt, clock, phy, network_was_reset: false, } } + /// Update the MQTT interface and service the network + /// + /// # Returns + /// An option containing an action that should be completed as a result of network servicing. pub fn update(&mut self) -> Option { let now = self.clock.current_ms(); - let sleep = match self.mqtt_interface.network_stack().poll(now) { + // First, service the network stack to process and inbound and outbound traffic. + let sleep = match self.mqtt.network_stack().poll(now) { Ok(updated) => !updated, Err(err) => { log::info!("Network error: {:?}", err); @@ -58,20 +76,21 @@ where } }; - // If the PHY indicates there's no more ethernet link, reset the network stack and close all - // sockets. + // If the PHY indicates there's no more ethernet link, reset the DHCP server in the network + // stack. if self.phy.poll_link() == false { // Only reset the network stack once per link reconnection. This prevents us from // sending an excessive number of DHCP requests. if !self.network_was_reset { self.network_was_reset = true; - self.mqtt_interface.network_stack().handle_link_reset(); + self.mqtt.network_stack().handle_link_reset(); } } else { self.network_was_reset = false; } - match self.mqtt_interface.update() { + // Finally, service the MQTT interface and handle any necessary messages. + match self.mqtt.update() { Ok(true) => Some(Action::UpdateSettings), Ok(false) if sleep => Some(Action::Sleep), Ok(_) => None, 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 05/70] 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 06/70] 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 d718914f0d49b9567121e32a54ac0892228c660d Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 6 Apr 2021 13:28:07 +0200 Subject: [PATCH 07/70] Adding initial HITL layout --- hitl/README.md | 25 +++++++++++++++++++++++++ hitl/run.sh | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 hitl/README.md create mode 100644 hitl/run.sh diff --git a/hitl/README.md b/hitl/README.md new file mode 100644 index 0000000..a150e6b --- /dev/null +++ b/hitl/README.md @@ -0,0 +1,25 @@ +# Stabilizer HITL Testing + +This directory contains tooling required for Stabilizer hardware-in-the-loop (HITL) testing. + +There is a `Stabilizer` board connected at the Quartiq office that is accessible via a private HITL +repository in order to provide secure hardware testing of the stabilizer application in a public +repository. + +**Note**: In order to ensure application security, all HITL runs must first be approved by a Quartiq +representative before execution. + +# Hardware Configuration +Stabilizer is configured with an ethernet connection to a router. The router runs a DHCP server for +the local network, and Stabilizers MAC address has been assigned to the unique host name of +`gonnigan.ber.quartiq.de`. + +# HITL Workflow +The private HITL repository does the following: + +1. Check out this repository +2. Build firmware images using Cargo +3. Program stabilizer +4. Execute `hitl/run.sh` + +In order to add new HITL tests, update `run.sh` to include the necessary tests. diff --git a/hitl/run.sh b/hitl/run.sh new file mode 100644 index 0000000..a945b0d --- /dev/null +++ b/hitl/run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/bash + +# Title: +# Stabilizer hardware-in-the-loop (HITL) test script. +# +# Description: +# This shell file is executed by the hardware runner in Quartiq's office to exercise the various +# hardware aspects of Stabilizer. + +# Test pinging Stabilizer. This exercises that: +# * DHCP is functional and an IP has been acquired +# * Stabilizer's network is functioning as intended +# * The stabilizer application is opeerational +ping -c 5 -W 20 gonnigan.ber.quartiq.de + +# Test the MQTT interface. +python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' From 2e4fdbb6e2c0925e026bb1084e56a52280a1f612 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 6 Apr 2021 14:28:08 +0200 Subject: [PATCH 08/70] Fixing python venv setup --- hitl/run.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index a945b0d..40e7397 100644 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -7,11 +7,16 @@ # This shell file is executed by the hardware runner in Quartiq's office to exercise the various # hardware aspects of Stabilizer. +# Set up python for testing +python3 -m venv --system-site-packages py +source py/bin/activate +python3 -m pip install -r requirements.txt + # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended # * The stabilizer application is opeerational -ping -c 5 -W 20 gonnigan.ber.quartiq.de +ping -c 5 -w 20 gonnigan.ber.quartiq.de # Test the MQTT interface. python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' 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 09/70] 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 From 2fa94b03a5f5db4940aa0f050bfbd0496e9b5916 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 13:53:29 +0200 Subject: [PATCH 10/70] Updating executability --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 hitl/run.sh diff --git a/hitl/run.sh b/hitl/run.sh old mode 100644 new mode 100755 index 40e7397..ff9796c --- a/hitl/run.sh +++ b/hitl/run.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/bash -e # Title: # Stabilizer hardware-in-the-loop (HITL) test script. From cd25b44b80517ec2d3fee0a1b9b02b26cce0639e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 13:55:08 +0200 Subject: [PATCH 11/70] Updating hitl runner to use correct broker --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index ff9796c..d3d5523 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -19,4 +19,4 @@ python3 -m pip install -r requirements.txt ping -c 5 -w 20 gonnigan.ber.quartiq.de # Test the MQTT interface. -python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' +python3 miniconf.py --broker mqtt.ber.quartiq.de dt/sinara/stabilizer afe/0 '"G2"' From ef9e5557e55f88402a9849afd25d1d60133ce5aa Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:04:11 +0200 Subject: [PATCH 12/70] Adding requirements file --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a3d7fef --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +gmqtt From 38b7884b4916ebc26662017acf12666375e197c1 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:18:21 +0200 Subject: [PATCH 13/70] Updating HITL to run against PRs to master --- .github/workflows/hitl.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index f59e8d2..b8611d4 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -1,9 +1,9 @@ name: HITL on: - push: - branches: [ hitl ] workflow_dispatch: + pull_request: + branches: [ master ] jobs: hitl: From 56acd9de2b906f157047c513b86e4cd3698b6f99 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:21:44 +0200 Subject: [PATCH 14/70] Removing broker specification --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index d3d5523..ff9796c 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -19,4 +19,4 @@ python3 -m pip install -r requirements.txt ping -c 5 -w 20 gonnigan.ber.quartiq.de # Test the MQTT interface. -python3 miniconf.py --broker mqtt.ber.quartiq.de dt/sinara/stabilizer afe/0 '"G2"' +python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' From 5d9c7b0884f244a7d586d966e00fdeb961c05421 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:30:39 +0200 Subject: [PATCH 15/70] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Jördens --- hitl/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hitl/run.sh b/hitl/run.sh index ff9796c..c4a6c15 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash -e +#!/bin/sh # Title: # Stabilizer hardware-in-the-loop (HITL) test script. @@ -15,8 +15,8 @@ python3 -m pip install -r requirements.txt # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended -# * The stabilizer application is opeerational -ping -c 5 -w 20 gonnigan.ber.quartiq.de +# * The stabilizer application is operational +ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' From 3187825b6192d0bf5d051565c6cc44c6f94c0e02 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:31:49 +0200 Subject: [PATCH 16/70] Updating runner operational flags --- hitl/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hitl/run.sh b/hitl/run.sh index c4a6c15..6602bf2 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -7,6 +7,9 @@ # This shell file is executed by the hardware runner in Quartiq's office to exercise the various # hardware aspects of Stabilizer. +# Enable shell operating mode flags. +set -eux + # Set up python for testing python3 -m venv --system-site-packages py source py/bin/activate From 416864b66aaf32d926d6d4375f3d50e8cb753760 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 14:38:22 +0200 Subject: [PATCH 17/70] Replacing sh with bash --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 6602bf2..47c6dd1 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Title: # Stabilizer hardware-in-the-loop (HITL) test script. From 7d3698dd8d8faa81cc2462f30886430baf6a6b78 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 15:02:49 +0200 Subject: [PATCH 18/70] Removing source in favor of dot --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 47c6dd1..a01a472 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -12,7 +12,7 @@ set -eux # Set up python for testing python3 -m venv --system-site-packages py -source py/bin/activate +. py/bin/activate python3 -m pip install -r requirements.txt # Test pinging Stabilizer. This exercises that: From b17831b99506c21c9d88b6c818120ba0cd91bed1 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 15:07:17 +0200 Subject: [PATCH 19/70] Updating HITL script to directly call python binaries --- hitl/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hitl/run.sh b/hitl/run.sh index a01a472..b707192 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -12,8 +12,8 @@ set -eux # Set up python for testing python3 -m venv --system-site-packages py -. py/bin/activate -python3 -m pip install -r requirements.txt + +py/bin/pip install -r requirements.txt # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired @@ -22,4 +22,4 @@ python3 -m pip install -r requirements.txt ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. -python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' +py/bin/python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' From 648731873085c17c24b3400dc1aed71b3a4d1cff Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 15:09:34 +0200 Subject: [PATCH 20/70] Reverting HITL runner changes --- hitl/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hitl/run.sh b/hitl/run.sh index b707192..a01a472 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -12,8 +12,8 @@ set -eux # Set up python for testing python3 -m venv --system-site-packages py - -py/bin/pip install -r requirements.txt +. py/bin/activate +python3 -m pip install -r requirements.txt # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired @@ -22,4 +22,4 @@ py/bin/pip install -r requirements.txt ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. -py/bin/python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' +python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' From fb32939fc55f62d8b105161c678a3d37147abb28 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 7 Apr 2021 15:21:12 +0200 Subject: [PATCH 21/70] Update hitl/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Jördens --- hitl/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hitl/README.md b/hitl/README.md index a150e6b..629b587 100644 --- a/hitl/README.md +++ b/hitl/README.md @@ -9,10 +9,10 @@ repository. **Note**: In order to ensure application security, all HITL runs must first be approved by a Quartiq representative before execution. -# Hardware Configuration -Stabilizer is configured with an ethernet connection to a router. The router runs a DHCP server for -the local network, and Stabilizers MAC address has been assigned to the unique host name of -`gonnigan.ber.quartiq.de`. +# Configuration +* Stabilizer is configured with an ethernet connection to a router. The router runs a DHCP server for +the local network, and ensures that the Stabilizer used for these tests is available under the hostname `stabilizer-hitl`. +* An MQTT broker is running at the hostname `mqtt`. # HITL Workflow The private HITL repository does the following: From 1ca8aa98b0e90386b57eb69b8223b20f693a5b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 7 Apr 2021 16:35:57 +0200 Subject: [PATCH 22/70] hal 0.9.0 --- Cargo.lock | 5 +++-- Cargo.toml | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c6641d..0d7c6b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -771,8 +771,9 @@ dependencies = [ [[package]] name = "stm32h7xx-hal" -version = "0.8.0" -source = "git+https://github.com/stm32-rs/stm32h7xx-hal?branch=master#ad2a1ae9831dd34e171cc178cdad84e770b4c0ae" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67034b80041bc33a48df1c1c435b6ae3bb18c35e42aa7e702ce8363b96793398" dependencies = [ "bare-metal 1.0.0", "cast", diff --git a/Cargo.toml b/Cargo.toml index 8d32d80..b59fffa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,8 +72,7 @@ git = "https://github.com/mrd0ll4r/mcp23017.git" [dependencies.stm32h7xx-hal] features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"] -git = "https://github.com/stm32-rs/stm32h7xx-hal" -branch = "master" +version = "0.9.0" [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] From 46902b39b4cf0fb27b6a4e6751d0005c785e279f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 7 Apr 2021 16:44:39 +0200 Subject: [PATCH 23/70] dependencies: update, move hashes to Cargo.toml cargo update -p doesn't work well if the hashes are only on .lock --- Cargo.lock | 21 +++++++++++---------- Cargo.toml | 40 ++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d7c6b2..da06294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "derive_miniconf" version = "0.1.0" -source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28" +source = "git+https://github.com/quartiq/miniconf.git?rev=314fa5587d#314fa5587d1aa28e1ad70106f19e30db646e9f28" dependencies = [ "proc-macro2", "quote", @@ -392,9 +392,9 @@ dependencies = [ [[package]] name = "managed" -version = "0.8.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca88d725a0a943b096803bd34e73a4437208b6077654cc4ecb2947a5f91618d" +checksum = "c75de51135344a4f8ed3cfe2720dc27736f7711989703a0b43aadf3753c55577" [[package]] name = "matrixmultiply" @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "mcp23017" version = "0.1.1" -source = "git+https://github.com/mrd0ll4r/mcp23017.git#61933f857abe5a837800493a5f58e91a3c9435ec" +source = "git+https://github.com/mrd0ll4r/mcp23017.git?rev=61933f857a#61933f857abe5a837800493a5f58e91a3c9435ec" dependencies = [ "embedded-hal", ] @@ -416,7 +416,7 @@ dependencies = [ [[package]] name = "miniconf" version = "0.1.0" -source = "git+https://github.com/quartiq/miniconf.git?branch=develop#314fa5587d1aa28e1ad70106f19e30db646e9f28" +source = "git+https://github.com/quartiq/miniconf.git?rev=314fa5587d#314fa5587d1aa28e1ad70106f19e30db646e9f28" dependencies = [ "derive_miniconf", "heapless 0.6.1", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "minimq" version = "0.2.0" -source = "git+https://github.com/quartiq/minimq.git#933687c2e4bc8a4d972de9a4d1508b0b554a8b38" +source = "git+https://github.com/quartiq/minimq.git?rev=933687c2e4b#933687c2e4bc8a4d972de9a4d1508b0b554a8b38" dependencies = [ "bit_field", "embedded-nal", @@ -688,7 +688,7 @@ dependencies = [ [[package]] name = "serde-json-core" version = "0.2.0" -source = "git+https://github.com/rust-embedded-community/serde-json-core.git?branch=master#ee06ac91bc43b72450a92198a00d9e5c5b9946d2" +source = "git+https://github.com/rust-embedded-community/serde-json-core.git?rev=ee06ac91bc#ee06ac91bc43b72450a92198a00d9e5c5b9946d2" dependencies = [ "heapless 0.5.6", "serde", @@ -707,8 +707,9 @@ dependencies = [ [[package]] name = "smoltcp" -version = "0.7.0" -source = "git+https://github.com/smoltcp-rs/smoltcp.git#43567b9743cb9f422de83fad9ff42a6d13f6e5ee" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97173c1ef35b0a09304cb3882eba594761243005847cbbf6124f966e8da6519a" dependencies = [ "bitflags", "byteorder", @@ -718,7 +719,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=main#56519012d7c6a382eaa0d7ecb26f2701771d9ce8" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=56519012d7#56519012d7c6a382eaa0d7ecb26f2701771d9ce8" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index b59fffa..8d7ae92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,37 +43,33 @@ 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" - -[patch.crates-io.miniconf] -git = "https://github.com/quartiq/miniconf.git" -branch = "develop" - -[patch.crates-io.minimq] -git = "https://github.com/quartiq/minimq.git" - -[patch.crates-io.smoltcp-nal] -git = "https://github.com/quartiq/smoltcp-nal.git" -branch = "main" - -[patch.crates-io.serde-json-core] -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" +miniconf = "0.1.0" [dependencies.mcp23017] git = "https://github.com/mrd0ll4r/mcp23017.git" +rev = "61933f857a" [dependencies.stm32h7xx-hal] features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"] version = "0.9.0" +[patch.crates-io.miniconf] +git = "https://github.com/quartiq/miniconf.git" +rev = "314fa5587d" + +[dependencies.smoltcp-nal] +git = "https://github.com/quartiq/smoltcp-nal.git" +rev = "56519012d7" + +[patch.crates-io.minimq] +git = "https://github.com/quartiq/minimq.git" +rev = "933687c2e4b" + +[patch.crates-io.serde-json-core] +git = "https://github.com/rust-embedded-community/serde-json-core.git" +rev = "ee06ac91bc" + [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] bkpt = [ ] From f9347e6e29d5059a1a81c38168dbb0c20818ac2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 7 Apr 2021 16:54:02 +0200 Subject: [PATCH 24/70] deps: bulk update --- Cargo.lock | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da06294..976e930 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9a69a963b70ddacfcd382524f72a4576f359af9334b3bf48a79566590bb8bfa" dependencies = [ "bitrate", - "cortex-m 0.7.1", + "cortex-m 0.7.2", "embedded-hal", ] @@ -89,9 +89,9 @@ checksum = "c147d86912d04bef727828fda769a76ca81629a46d8ba311a8d58a26aa91473d" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cast" @@ -117,15 +117,15 @@ dependencies = [ "aligned", "bare-metal 0.2.5", "bitfield", - "cortex-m 0.7.1", + "cortex-m 0.7.2", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b756a8bffc56025de45218a48ff9b801180440c0ee49a722b32d49dcebc771" +checksum = "643a210c1bdc23d0db511e2a576082f4ff4dcae9d0c37f50b431b8f8439d6d6b" dependencies = [ "bare-metal 0.2.5", "bitfield", @@ -139,7 +139,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e202d2eac4e34adf7524a563e36623bae6f69cc0a73ef9bd22a4c93a5a806fa" dependencies = [ - "cortex-m 0.7.1", + "cortex-m 0.7.2", "cortex-m-semihosting", "log", ] @@ -197,7 +197,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc" dependencies = [ - "cortex-m 0.7.1", + "cortex-m 0.7.2", ] [[package]] @@ -361,9 +361,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.1" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.86" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" [[package]] name = "libm" @@ -549,7 +549,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec" dependencies = [ - "cortex-m 0.7.1", + "cortex-m 0.7.2", "cortex-m-semihosting", ] @@ -567,9 +567,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -678,9 +678,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] @@ -696,9 +696,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -765,7 +765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b672c837e0ee8158ecc7fce0f9a948dd0693a9c588338e728d14b73307a0b7d" dependencies = [ "bare-metal 0.2.5", - "cortex-m 0.7.1", + "cortex-m 0.7.2", "cortex-m-rt", "vcell", ] @@ -778,7 +778,7 @@ checksum = "67034b80041bc33a48df1c1c435b6ae3bb18c35e42aa7e702ce8363b96793398" dependencies = [ "bare-metal 1.0.0", "cast", - "cortex-m 0.7.1", + "cortex-m 0.7.2", "cortex-m-rt", "embedded-dma", "embedded-hal", @@ -791,9 +791,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.60" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ "proc-macro2", "quote", @@ -802,9 +802,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicode-xid" @@ -820,9 +820,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" From b39a827affe4653394341348bb59606f70b54237 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Apr 2021 15:00:06 +0000 Subject: [PATCH 25/70] build(deps): bump ndarray from 0.14.0 to 0.15.1 Bumps [ndarray](https://github.com/rust-ndarray/ndarray) from 0.14.0 to 0.15.1. - [Release notes](https://github.com/rust-ndarray/ndarray/releases) - [Changelog](https://github.com/rust-ndarray/ndarray/blob/master/RELEASES.md) - [Commits](https://github.com/rust-ndarray/ndarray/compare/ndarray-rand-0.14.0...0.15.1) Signed-off-by: dependabot[bot] --- Cargo.lock | 21 ++++++--------------- dsp/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 976e930..9c42b6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -398,9 +398,9 @@ checksum = "c75de51135344a4f8ed3cfe2720dc27736f7711989703a0b43aadf3753c55577" [[package]] name = "matrixmultiply" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" +checksum = "1300bdbea33ec2836b01ff1f5a6eed8bad66d0c31f94d9b7993407a8b054c3a1" dependencies = [ "rawpointer", ] @@ -454,12 +454,12 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" [[package]] name = "ndarray" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c0d5c9540a691d153064dc47a4db2504587a75eae07bf1d73f7a596ebc73c04" +checksum = "cc1372704f14bb132a49a6701c2238970a359ee0829fed481b522a63bf25456a" dependencies = [ "matrixmultiply", - "num-complex 0.3.1", + "num-complex", "num-integer", "num-traits", "rawpointer", @@ -477,22 +477,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ - "num-complex 0.4.0", + "num-complex", "num-integer", "num-iter", "num-rational", "num-traits", ] -[[package]] -name = "num-complex" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" -dependencies = [ - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.0" diff --git a/dsp/Cargo.toml b/dsp/Cargo.toml index 9b92078..7b680d3 100644 --- a/dsp/Cargo.toml +++ b/dsp/Cargo.toml @@ -14,7 +14,7 @@ miniconf = "0.1" [dev-dependencies] easybench = "1.0" rand = "0.8" -ndarray = "0.14" +ndarray = "0.15" [[bench]] name = "micro" From d0c1bef55f41e201bb2d6c5f41086603ae75dd40 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 13:37:24 +0200 Subject: [PATCH 26/70] Updating dependencies --- Cargo.lock | 7 +------ Cargo.toml | 5 +---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3aa8999..83f9171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,7 +710,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/reset-support#c43e751afe3c14aac153fa4425231270dbfd918b" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=db2d6c6#db2d6c6ac538a128e63da2f166a0907f4c99989a" dependencies = [ "embedded-nal", "heapless 0.6.1", @@ -835,8 +835,3 @@ name = "wasi" version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[patch.unused]] -name = "smoltcp" -version = "0.7.0" -source = "git+https://github.com/smoltcp-rs/smoltcp.git#09f941851ded868b759e7db067abd67f2fe136a6" diff --git a/Cargo.toml b/Cargo.toml index 144444f..63ea340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,15 +60,12 @@ rev = "314fa5587d" [dependencies.smoltcp-nal] git = "https://github.com/quartiq/smoltcp-nal.git" -branch = "feature/reset-support" +rev = "db2d6c6" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" rev = "933687c2e4b" -[patch.crates-io.smoltcp] -git = "https://github.com/smoltcp-rs/smoltcp.git" - [patch.crates-io.serde-json-core] git = "https://github.com/rust-embedded-community/serde-json-core.git" rev = "ee06ac91bc" From 164fd5969d1b1cc86497853872fb1d8e56700669 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 13:56:57 +0200 Subject: [PATCH 27/70] Updating smoltcp-nal --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83f9171..6224d53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,7 +710,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=db2d6c6#db2d6c6ac538a128e63da2f166a0907f4c99989a" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=d200d4e#d200d4eb20cdad42ed30a77f9c1690f43361d9e8" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index 63ea340..dcdffea 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 = "db2d6c6" +rev = "d200d4e" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" From c24eb17d1eb469a03a3538638d1fa660b3180fde Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 14:02:56 +0200 Subject: [PATCH 28/70] Using main branch commit --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6224d53..f77e0bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,7 +710,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=d200d4e#d200d4eb20cdad42ed30a77f9c1690f43361d9e8" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=7572183#757218316620e074405bc38ff5502ef17a8a3499" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index dcdffea..0c4ab0d 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 = "d200d4e" +rev = "7572183" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" From dd3f293cca606ff2d21555fc513cf89794238043 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 14:17:38 +0200 Subject: [PATCH 29/70] Fixing ACR write padding --- ad9959/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index 206d90a..f5d80a9 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -582,7 +582,9 @@ impl ProfileSerializer { } if let Some(acr) = acr { - self.add_write(Register::ACR, &acr.to_be_bytes()); + let mut data = [0; 3]; + data[1..=2].copy_from_slice(&acr.to_be_bytes()); + self.add_write(Register::ACR, &data); } } From bf3dae814da274052c05f4dde3d3a835fe907af5 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 14:58:28 +0200 Subject: [PATCH 30/70] Updating ACR to 32-bit --- ad9959/src/lib.rs | 11 +++++------ src/hardware/pounder/dds_output.rs | 5 +++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index f5d80a9..a8fc48e 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -558,13 +558,14 @@ impl ProfileSerializer { /// * `channels` - A list of channels to apply the configuration to. /// * `ftw` - If provided, indicates a frequency tuning word for the channels. /// * `pow` - If provided, indicates a phase offset word for the channels. - /// * `acr` - If provided, indicates the amplitude control register for the channels. + /// * `acr` - If provided, indicates the amplitude control register for the channels. The ACR + /// should be stored in the 3 LSB of the word. pub fn update_channels( &mut self, channels: &[Channel], ftw: Option, pow: Option, - acr: Option, + acr: Option, ) { let mut csr: u8 = *0u8.set_bits(1..3, self.mode as u8); for channel in channels.iter() { @@ -582,9 +583,7 @@ impl ProfileSerializer { } if let Some(acr) = acr { - let mut data = [0; 3]; - data[1..=2].copy_from_slice(&acr.to_be_bytes()); - self.add_write(Register::ACR, &data); + self.add_write(Register::ACR, &acr.to_be_bytes()[1..=4]); } } @@ -608,7 +607,6 @@ impl ProfileSerializer { // Pad the buffer to 32-bit alignment by adding dummy writes to CSR and LSRR. let padding = 4 - (self.index % 4); match padding { - 0 => {} 1 => { // For a pad size of 1, we have to pad with 5 bytes to align things. self.add_write(Register::CSR, &[(self.mode as u8) << 1]); @@ -616,6 +614,7 @@ impl ProfileSerializer { } 2 => self.add_write(Register::CSR, &[(self.mode as u8) << 1]), 3 => self.add_write(Register::LSRR, &[0, 0, 0]), + 4 => {} _ => unreachable!(), } diff --git a/src/hardware/pounder/dds_output.rs b/src/hardware/pounder/dds_output.rs index c7c5e6d..e755482 100644 --- a/src/hardware/pounder/dds_output.rs +++ b/src/hardware/pounder/dds_output.rs @@ -144,14 +144,15 @@ impl<'a> ProfileBuilder<'a> { /// * `channels` - A list of channels to apply the configuration to. /// * `ftw` - If provided, indicates a frequency tuning word for the channels. /// * `pow` - If provided, indicates a phase offset word for the channels. - /// * `acr` - If provided, indicates the amplitude control register for the channels. + /// * `acr` - If provided, indicates the amplitude control register for the channels. The + /// 24-bits of the ACR should be stored in the last 3 LSB. #[allow(dead_code)] pub fn update_channels( mut self, channels: &[Channel], ftw: Option, pow: Option, - acr: Option, + acr: Option, ) -> Self { self.serializer.update_channels(channels, ftw, pow, acr); self From 4a2d4af5088ec91f78097bed80f3b7efc303c1ec Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 15:00:30 +0200 Subject: [PATCH 31/70] Fixing end index --- ad9959/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index a8fc48e..9b7d77b 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -583,7 +583,7 @@ impl ProfileSerializer { } if let Some(acr) = acr { - self.add_write(Register::ACR, &acr.to_be_bytes()[1..=4]); + self.add_write(Register::ACR, &acr.to_be_bytes()[1..=3]); } } From 35aa3eb606fde3c090418512c67b1d724c064269 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 15:04:34 +0200 Subject: [PATCH 32/70] Fixing other AD9959 profile issues --- ad9959/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index 9b7d77b..89192b6 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -610,10 +610,10 @@ impl ProfileSerializer { 1 => { // For a pad size of 1, we have to pad with 5 bytes to align things. self.add_write(Register::CSR, &[(self.mode as u8) << 1]); - self.add_write(Register::LSRR, &[0, 0, 0]); + self.add_write(Register::LSRR, &[0, 0]); } 2 => self.add_write(Register::CSR, &[(self.mode as u8) << 1]), - 3 => self.add_write(Register::LSRR, &[0, 0, 0]), + 3 => self.add_write(Register::LSRR, &[0, 0]), 4 => {} _ => unreachable!(), From 1b4d31dbd9ce1432149685eb993f9971df59bd70 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 15:28:11 +0200 Subject: [PATCH 33/70] Updating NAL to support TCP port randomization --- Cargo.lock | 9 ++++++++- Cargo.toml | 2 +- src/hardware/configuration.rs | 24 ++++++++++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f77e0bd..0c99862 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?branch=feature/random-port#462adc56a8cc95bc1324f6d96fdbe82e85ca6d36" dependencies = [ "embedded-nal", "heapless 0.6.1", + "nanorand", "smoltcp", ] diff --git a/Cargo.toml b/Cargo.toml index 0c4ab0d..87a0e2e 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" +branch = "feature/random-port" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index 74307dd..8a6ec0d 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -594,13 +594,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, } }; From 090ec4650d5817f9770cfebbff1e2528dd090815 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 8 Apr 2021 16:05:51 +0200 Subject: [PATCH 34/70] Update ad9959/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Jördens --- ad9959/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index 89192b6..21dfa21 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -559,7 +559,8 @@ impl ProfileSerializer { /// * `ftw` - If provided, indicates a frequency tuning word for the channels. /// * `pow` - If provided, indicates a phase offset word for the channels. /// * `acr` - If provided, indicates the amplitude control register for the channels. The ACR - /// should be stored in the 3 LSB of the word. + /// should be stored in the 3 LSB of the word. Note that if amplitude scaling is to be used, + /// the "Amplitude multiplier enable" bit must be set. pub fn update_channels( &mut self, channels: &[Channel], From 7372bcc2e237504be33006b31edccd075e65d28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 8 Apr 2021 16:20:28 +0200 Subject: [PATCH 35/70] miniconf.py: add iir example --- miniconf.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/miniconf.py b/miniconf.py index 019ebcb..0901127 100644 --- a/miniconf.py +++ b/miniconf.py @@ -83,9 +83,12 @@ class Miniconf: def main(): parser = argparse.ArgumentParser( description='Miniconf command line interface.', - epilog='''Example: - %(prog)s -v -b mqtt dt/sinara/stabilizer afe/0 '"G10"' - ''') + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog='''Examples: +%(prog)s dt/sinara/stabilizer afe/0 '"G10"' +%(prog)s dt/sinara/stabilizer iir_ch/0/0 \ +'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}' +''') parser.add_argument('-v', '--verbose', action='count', default=0, help='Increase logging verbosity') parser.add_argument('--broker', '-b', default='mqtt', type=str, From a3511f522315ffbe287742bb826fb109cd55f72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 8 Apr 2021 16:26:22 +0200 Subject: [PATCH 36/70] cli: print response directly --- miniconf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miniconf.py b/miniconf.py index 0901127..d7fd615 100644 --- a/miniconf.py +++ b/miniconf.py @@ -111,7 +111,7 @@ def main(): async def configure_settings(): interface = await Miniconf.create(args.prefix, args.broker) response = await interface.command(args.path, json.loads(args.value)) - print(f"Response: {response}") + print(response) loop.run_until_complete(configure_settings()) From 7329d0f24151cb49d46fb5e81145c6c4bfeb5a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 8 Apr 2021 17:11:44 +0200 Subject: [PATCH 37/70] cli,hitl: allow more settings per invokation, expand example --- hitl/run.sh | 4 +++- miniconf.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hitl/run.sh b/hitl/run.sh index a01a472..8fe9a3a 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -22,4 +22,6 @@ python3 -m pip install -r requirements.txt ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. -python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"' +python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"' +python3 miniconf.py dt/sinara/stabilizer afe/0='"G1"' iir_ch/0/0=\ +'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}' diff --git a/miniconf.py b/miniconf.py index d7fd615..b059f78 100644 --- a/miniconf.py +++ b/miniconf.py @@ -85,8 +85,7 @@ def main(): description='Miniconf command line interface.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog='''Examples: -%(prog)s dt/sinara/stabilizer afe/0 '"G10"' -%(prog)s dt/sinara/stabilizer iir_ch/0/0 \ +%(prog)s dt/sinara/stabilizer afe/0='"G2"' iir_ch/0/0=\ '{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}' ''') parser.add_argument('-v', '--verbose', action='count', default=0, @@ -95,10 +94,8 @@ def main(): help='The MQTT broker address') parser.add_argument('prefix', type=str, help='The MQTT topic prefix of the target') - parser.add_argument('path', type=str, - help='The setting path to configure') - parser.add_argument('value', type=str, - help='The value of setting in JSON format') + parser.add_argument('settings', metavar="KEY=VALUE", nargs='+', + help='JSON encoded values for settings path keys.') args = parser.parse_args() @@ -110,8 +107,10 @@ def main(): async def configure_settings(): interface = await Miniconf.create(args.prefix, args.broker) - response = await interface.command(args.path, json.loads(args.value)) - print(response) + for kv in args.settings: + path, value = kv.split("=", 1) + response = await interface.command(path, json.loads(value)) + print(response) loop.run_until_complete(configure_settings()) From f26e0b100e0485132e5285368debed9b49b0dc93 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 11:25:58 +0200 Subject: [PATCH 38/70] Adding check wait for HITL --- .github/workflows/hitl.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index b8611d4..a888e06 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -16,3 +16,9 @@ jobs: event-type: stabilizer repository: quartiq/hitl client-payload: '{"github": ${{ toJson(github) }}}' + + - uses: fountainhead/action-wait-for-check@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + checkName: HITL + ref: ${{ github.event.pull_request.head.sha }} From 9d22febe64fbd1f8f69d08b3d7c80bbefad73a81 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 11:27:27 +0200 Subject: [PATCH 39/70] Fixing indent --- .github/workflows/hitl.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index a888e06..5f920fc 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -17,8 +17,8 @@ jobs: repository: quartiq/hitl client-payload: '{"github": ${{ toJson(github) }}}' - - uses: fountainhead/action-wait-for-check@v1.0.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - checkName: HITL - ref: ${{ github.event.pull_request.head.sha }} + - uses: fountainhead/action-wait-for-check@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + checkName: HITL + ref: ${{ github.event.pull_request.head.sha }} From f83973f1a261ea9f916c5eb8b3e7e39f1b15514a Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 11:43:30 +0200 Subject: [PATCH 40/70] Renaming HITL workflow --- .github/workflows/hitl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index 5f920fc..0a39a6e 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -1,4 +1,4 @@ -name: HITL +name: HITL Run Request on: workflow_dispatch: From 26d83da684d6eeb3486c4e99cc200d81dce6378d Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 12:33:54 +0200 Subject: [PATCH 41/70] Adding sleep on startup --- .github/workflows/hitl.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index 0a39a6e..85a00d4 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -17,6 +17,9 @@ jobs: repository: quartiq/hitl client-payload: '{"github": ${{ toJson(github) }}}' + - name: Wait for startup + runs: sleep 30 + - uses: fountainhead/action-wait-for-check@v1.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} From 48b69fa9e622aa33e062387c8fd574bc3442eb1c Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 12:34:41 +0200 Subject: [PATCH 42/70] Fixing run --- .github/workflows/hitl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl.yml index 85a00d4..b594353 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl.yml @@ -18,7 +18,7 @@ jobs: client-payload: '{"github": ${{ toJson(github) }}}' - name: Wait for startup - runs: sleep 30 + run: sleep 30 - uses: fountainhead/action-wait-for-check@v1.0.0 with: From de554d08d9e6d83e3d73e5eb7276f872d2b4fdb3 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 13:24:46 +0200 Subject: [PATCH 43/70] Renaming to HITL Trigger --- .github/workflows/{hitl.yml => hitl_trigger.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{hitl.yml => hitl_trigger.yml} (96%) diff --git a/.github/workflows/hitl.yml b/.github/workflows/hitl_trigger.yml similarity index 96% rename from .github/workflows/hitl.yml rename to .github/workflows/hitl_trigger.yml index b594353..7b82503 100644 --- a/.github/workflows/hitl.yml +++ b/.github/workflows/hitl_trigger.yml @@ -1,4 +1,4 @@ -name: HITL Run Request +name: HITL Trigger on: workflow_dispatch: From 02aa5d2ed76f7010be5c655ba935dedbec96efa5 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 13:35:23 +0200 Subject: [PATCH 44/70] Adding program step to HITL runner --- .github/workflows/hitl_trigger.yml | 2 +- hitl/run.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index 7b82503..6897847 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -23,5 +23,5 @@ jobs: - uses: fountainhead/action-wait-for-check@v1.0.0 with: token: ${{ secrets.GITHUB_TOKEN }} - checkName: HITL + checkName: HITL Run Status ref: ${{ github.event.pull_request.head.sha }} diff --git a/hitl/run.sh b/hitl/run.sh index 8fe9a3a..156c128 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -15,6 +15,8 @@ python3 -m venv --system-site-packages py . py/bin/activate python3 -m pip install -r requirements.txt +cargo flash --bin dual-iir --release --chip STM32H743ZITx + # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended From 02b6b3873130d0edd6111e65b6874da731ae2248 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 13:36:35 +0200 Subject: [PATCH 45/70] Renaming job to hitl-trigger --- .github/workflows/hitl_trigger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index 6897847..62abb96 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -6,7 +6,7 @@ on: branches: [ master ] jobs: - hitl: + hitl-trigger: runs-on: ubuntu-latest environment: hitl steps: From 5bd46593b5b2a5a999a5e8a349a4a3d22b6baa06 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 9 Apr 2021 13:43:15 +0200 Subject: [PATCH 46/70] Using manual elf path --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 156c128..483a8a3 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -15,7 +15,7 @@ python3 -m venv --system-site-packages py . py/bin/activate python3 -m pip install -r requirements.txt -cargo flash --bin dual-iir --release --chip STM32H743ZITx +cargo flash --elf target/thumbv7em-none-eabihf/release/dual-iir --chip STM32H743ZITx # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired From c4336f7bf9a15ff6677e5dc82081329b8cffa48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Fri, 9 Apr 2021 21:40:58 +0200 Subject: [PATCH 47/70] ci: add PR labeler --- .github/labeler.yml | 4 ++++ .github/workflows/labeler.yml | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..9b3dd5c --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,4 @@ +# add changes-hitl label if any hitl scripts are changed +# REVIEW those changes before approving HITL deployment! +changes-hitl: + - any: [hitl/*] diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..82b4e70 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + pull_request_target: + branches: [master] + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v3 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" From 61e1a2a1c6427be6594d31939c4f37fb42c42d15 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 13 Apr 2021 12:28:05 +0200 Subject: [PATCH 48/70] Correcting I2C MAC address read --- src/hardware/configuration.rs | 11 ++++------ src/hardware/eeprom.rs | 40 ++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index dfab1e0..0351db9 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -495,13 +495,10 @@ pub fn setup( .set_speed(hal::gpio::Speed::VeryHigh); } - let mac_addr = match eeprom::read_eui48(&mut eeprom_i2c) { - Err(_) => { - info!("Could not read EEPROM, using default MAC address"); - smoltcp::wire::EthernetAddress([0x10, 0xE2, 0xD5, 0x00, 0x03, 0x00]) - } - Ok(raw_mac) => smoltcp::wire::EthernetAddress(raw_mac), - }; + let mac_addr = smoltcp::wire::EthernetAddress(eeprom::read_eui48( + &mut eeprom_i2c, + &mut delay, + )); let network_devices = { // Configure the ethernet controller diff --git a/src/hardware/eeprom.rs b/src/hardware/eeprom.rs index d84dd70..b9b237c 100644 --- a/src/hardware/eeprom.rs +++ b/src/hardware/eeprom.rs @@ -1,12 +1,42 @@ -use embedded_hal::blocking::i2c::WriteRead; +use embedded_hal::blocking::{delay::DelayMs, i2c::WriteRead}; +// The EEPROM is a variant without address bits, so the 3 LSB of this word are "dont-cares". const I2C_ADDR: u8 = 0x50; -pub fn read_eui48(i2c: &mut T) -> Result<[u8; 6], T::Error> +// The MAC address is stored in the last 6 bytes of the 256 byte address space. +const MAC_POINTER: u8 = 0xFA; + +pub fn read_eui48(i2c: &mut T, delay: &mut impl DelayMs) -> [u8; 6] where T: WriteRead, { - let mut buffer = [0u8; 6]; - i2c.write_read(I2C_ADDR, &[0xFA_u8], &mut buffer)?; - Ok(buffer) + let mut previous_read: Option<[u8; 6]> = None; + // On Stabilizer v1.1 and earlier hardware, there is a fault where the I2C bus is not connected + // to the CPU until the P12V0A rail enables, which can take many seconds, or may never come up + // at all. During these transient turn-on conditions, we may fail the I2C read operation. To + // accomodate this, we repeat the I2C read for a set number of attempts with a fixed delay + // between them. Then, we wait for the bus to stabilize by waiting until the MAC address + // read-out is identical for two consecutive reads. + for _ in 0..40 { + let mut buffer = [0u8; 6]; + if i2c + .write_read(I2C_ADDR, &[MAC_POINTER], &mut buffer) + .is_ok() + { + if let Some(old_read) = previous_read { + if old_read == buffer { + return buffer; + } + } + + previous_read.replace(buffer); + } else { + // Remove any pending previous read if we failed the last attempt. + previous_read.take(); + } + + delay.delay_ms(100); + } + + panic!("Failed to read MAC address"); } From d1ab5093e6411a5293101be1de0ea2332ebbb156 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 13 Apr 2021 13:58:56 +0200 Subject: [PATCH 49/70] Updating badge to utilize nightly workflow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4250d6a..f91976a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![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 HITL [Nightly]](https://github.com/quartiq/hitl/actions/workflows/stabilizer-nightly.yml/badge.svg)](https://github.com/quartiq/hitl/actions/workflows/stabilizer-nightly.yml) # Stabilizer Firmware From 033420b9346e376cc7ec1ccdbc8ee061f3309cbe Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 13 Apr 2021 15:38:30 +0200 Subject: [PATCH 50/70] Adding custom identifier prefix calculations --- src/bin/dual-iir.rs | 5 +++- src/bin/lockin-external.rs | 7 +++++- src/hardware/configuration.rs | 4 +++- src/hardware/design_parameters.rs | 2 +- src/net/mod.rs | 40 +++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 0e2215b..b0072af 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -59,7 +59,10 @@ const APP: () = { let mqtt_settings = MqttSettings::new( stabilizer.net.stack, "", - "dt/sinara/stabilizer", + &net::get_device_prefix( + env!("CARGO_BIN_NAME"), + stabilizer.net.mac_address, + ), stabilizer.net.phy, stabilizer.cycle_counter, ); diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index b62ea42..34a3d5b 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -8,6 +8,8 @@ use serde::Deserialize; use dsp::{Accu, Complex, ComplexExt, Lockin, RPLL}; +use stabilizer::net; + use stabilizer::hardware::{ design_parameters, setup, Adc0Input, Adc1Input, AfeGain, Dac0Output, Dac1Output, InputStamper, AFE0, AFE1, @@ -74,7 +76,10 @@ const APP: () = { let mqtt_settings = MqttSettings::new( stabilizer.net.stack, "", - "dt/sinara/lockin", + &net::get_device_prefix( + env!("CARGO_BIN_NAME"), + stabilizer.net.mac_address, + ), stabilizer.net.phy, stabilizer.cycle_counter, ); diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index 82158f3..fdde1f4 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -57,6 +57,7 @@ impl NetStorage { pub struct NetworkDevices { pub stack: NetworkStack, pub phy: EthernetPhy, + pub mac_address: smoltcp::wire::EthernetAddress, } /// The available hardware interfaces on Stabilizer. @@ -544,7 +545,7 @@ pub fn setup( smoltcp::iface::NeighborCache::new(&mut store.neighbor_cache[..]); let interface = smoltcp::iface::EthernetInterfaceBuilder::new(eth_dma) - .ethernet_addr(mac_addr) + .ethernet_addr(mac_addr.clone()) .neighbor_cache(neighbor_cache) .ip_addrs(&mut store.ip_addrs[..]) .routes(routes) @@ -599,6 +600,7 @@ pub fn setup( Some(dhcp_client), ), phy: lan8742a, + mac_address: mac_addr, } }; diff --git a/src/hardware/design_parameters.rs b/src/hardware/design_parameters.rs index 9a4279b..0ae4c35 100644 --- a/src/hardware/design_parameters.rs +++ b/src/hardware/design_parameters.rs @@ -51,4 +51,4 @@ pub const SAMPLE_BUFFER_SIZE_LOG2: u8 = 3; pub const SAMPLE_BUFFER_SIZE: usize = 1 << SAMPLE_BUFFER_SIZE_LOG2; // The MQTT broker IPv4 address -pub const MQTT_BROKER: [u8; 4] = [10, 34, 16, 10]; +pub const MQTT_BROKER: [u8; 4] = [10, 35, 16, 10]; diff --git a/src/net/mod.rs b/src/net/mod.rs index f38f3d9..3ad21b6 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -2,6 +2,10 @@ use crate::hardware::{ design_parameters::MQTT_BROKER, CycleCounter, EthernetPhy, NetworkStack, }; +use core::fmt::Write; + +use heapless::{consts, String}; + use miniconf::{minimq, MqttInterface}; /// Potential actions for firmware to take. @@ -106,3 +110,39 @@ where } } } + +/// Get the MQTT prefix of a device. +/// +/// # Args +/// * `app` - The name of the application that is executing. +/// * `mac` - The ethernet MAC address of the device. +/// +/// # Returns +/// The MQTT prefix used for this device. +pub fn get_device_prefix( + app: &str, + mac: smoltcp_nal::smoltcp::wire::EthernetAddress, +) -> String { + let mac_string = { + let mut mac_string: String = String::new(); + let mac = mac.as_bytes(); + + // Note(unwrap): 32-bytes is guaranteed to be valid for any mac address, as the address has + // a fixed length. + write!( + &mut mac_string, + "{:02x}-{:02x}-{:02x}-{:02x}-{:02x}-{:02x}", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] + ) + .unwrap(); + + mac_string + }; + + // Note(unwrap): The mac address + binary name must be short enough to fit into this string. If + // they are defined too long, this will panic and the device will fail to boot. + let mut prefix: String = String::new(); + write!(&mut prefix, "dt/sinara/{}/{}", app, mac_string).unwrap(); + + prefix +} From 8954c94a20a6a306cb51b9442b321de085d3fae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 14 Apr 2021 15:53:52 +0200 Subject: [PATCH 51/70] hardware: add digital input support * The inputs of the buffer are not pulled up/down. That might make them unusable if left floating. --- dsp/src/iir.rs | 8 ++++++-- src/bin/dual-iir.rs | 20 ++++++++++++++------ src/hardware/configuration.rs | 14 +++++++++++--- src/hardware/mod.rs | 8 ++++++++ 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/dsp/src/iir.rs b/dsp/src/iir.rs index ee9639e..a6af191 100644 --- a/dsp/src/iir.rs +++ b/dsp/src/iir.rs @@ -117,7 +117,7 @@ impl IIR { /// # Arguments /// * `xy` - Current filter state. /// * `x0` - New input. - pub fn update(&self, xy: &mut Vec5, x0: f32) -> f32 { + pub fn update(&self, xy: &mut Vec5, x0: f32, hold: bool) -> f32 { let n = self.ba.len(); debug_assert!(xy.len() == n); // `xy` contains x0 x1 y0 y1 y2 @@ -128,7 +128,11 @@ impl IIR { // Store x0 x0 x1 x2 y1 y2 xy[0] = x0; // Compute y0 by multiply-accumulate - let y0 = macc(self.y_offset, xy, &self.ba); + let y0 = if hold { + xy[n / 2 + 1] + } else { + macc(self.y_offset, xy, &self.ba) + }; // Limit y0 let y0 = max(self.y_min, min(self.y_max, y0)); // Store y0 x0 x1 y0 y1 y2 diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 4a27d48..520d5ec 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -4,6 +4,8 @@ use stm32h7xx_hal as hal; +pub use embedded_hal::digital::v2::InputPin; + use stabilizer::hardware; use miniconf::{minimq, Miniconf, MqttInterface}; @@ -12,7 +14,7 @@ use serde::Deserialize; use dsp::iir; use hardware::{ Adc0Input, Adc1Input, AfeGain, CycleCounter, Dac0Output, Dac1Output, - NetworkStack, AFE0, AFE1, + DigitalInput1, NetworkStack, AFE0, AFE1, }; const SCALE: f32 = i16::MAX as _; @@ -39,6 +41,7 @@ impl Default for Settings { const APP: () = { struct Resources { afes: (AFE0, AFE1), + di1: DigitalInput1, adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), mqtt_interface: @@ -90,6 +93,7 @@ const APP: () = { adcs: stabilizer.adcs, dacs: stabilizer.dacs, clock: stabilizer.cycle_counter, + di1: stabilizer.digital_inputs.1, } } @@ -109,7 +113,7 @@ const APP: () = { /// /// Because the ADC and DAC operate at the same rate, these two constraints actually implement /// the same time bounds, meeting one also means the other is also met. - #[task(binds=DMA1_STR4, resources=[adcs, dacs, iir_state, iir_ch], priority=2)] + #[task(binds=DMA1_STR4, resources=[adcs, di1, dacs, iir_state, iir_ch], priority=2)] fn process(c: process::Context) { let adc_samples = [ c.resources.adcs.0.acquire_buffer(), @@ -121,13 +125,17 @@ const APP: () = { c.resources.dacs.1.acquire_buffer(), ]; + let hold = c.resources.di1.is_high().unwrap(); + for channel in 0..adc_samples.len() { for sample in 0..adc_samples[0].len() { - let x = f32::from(adc_samples[channel][sample] as i16); - let mut y = x; + let mut y = f32::from(adc_samples[channel][sample] as i16); for i in 0..c.resources.iir_state[channel].len() { - y = c.resources.iir_ch[channel][i] - .update(&mut c.resources.iir_state[channel][i], y); + y = c.resources.iir_ch[channel][i].update( + &mut c.resources.iir_state[channel][i], + y, + hold, + ); } // Note(unsafe): The filter limits ensure that the value is in range. // The truncation introduces 1/2 LSB distortion. diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index 0351db9..31fb16d 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -9,12 +9,12 @@ use stm32h7xx_hal::{ use smoltcp_nal::smoltcp; -use embedded_hal::digital::v2::{InputPin, OutputPin}; +pub use embedded_hal::digital::v2::{InputPin, OutputPin}; use super::{ adc, afe, cycle_counter::CycleCounter, dac, design_parameters, - digital_input_stamper, eeprom, pounder, timers, DdsOutput, NetworkStack, - AFE0, AFE1, + digital_input_stamper, eeprom, pounder, timers, DdsOutput, DigitalInput0, + DigitalInput1, NetworkStack, AFE0, AFE1, }; pub struct NetStorage { @@ -69,6 +69,7 @@ pub struct StabilizerDevices { pub timestamp_timer: timers::TimestampTimer, pub net: NetworkDevices, pub cycle_counter: CycleCounter, + pub digital_inputs: (DigitalInput0, DigitalInput1), } /// The available Pounder-specific hardware interfaces. @@ -439,6 +440,12 @@ pub fn setup( ) }; + let digital_inputs = { + let di0 = gpiog.pg9.into_floating_input(); + let di1 = gpioc.pc15.into_floating_input(); + (di0, di1) + }; + let mut eeprom_i2c = { let sda = gpiof.pf0.into_alternate_af4().set_open_drain(); let scl = gpiof.pf1.into_alternate_af4().set_open_drain(); @@ -872,6 +879,7 @@ pub fn setup( adc_dac_timer: sampling_timer, timestamp_timer, cycle_counter, + digital_inputs, }; // info!("Version {} {}", build_info::PKG_VERSION, build_info::GIT_VERSION.unwrap()); diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index cc7a34a..34f092f 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -34,6 +34,14 @@ pub type AFE1 = afe::ProgrammableGainAmplifier< hal::gpio::gpiod::PD15>, >; +// Type alias for digital input 0 (DI0). +pub type DigitalInput0 = + hal::gpio::gpiog::PG9>; + +// Type alias for digital input 1 (DI1). +pub type DigitalInput1 = + hal::gpio::gpioc::PC15>; + pub type NetworkStack = smoltcp_nal::NetworkStack< 'static, 'static, From bf5f6afbc10f6c4f96fd4658e464da6529177ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 14 Apr 2021 16:02:54 +0200 Subject: [PATCH 52/70] fix bench --- dsp/benches/micro.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsp/benches/micro.rs b/dsp/benches/micro.rs index 0902a4c..22a2540 100644 --- a/dsp/benches/micro.rs +++ b/dsp/benches/micro.rs @@ -67,7 +67,7 @@ fn iir_bench() { let mut xy = iir::Vec5::default(); println!( "int::IIR::update(s, x): {}", - bench_env(0.32241, |x| dut.update(&mut xy, *x)) + bench_env(0.32241, |x| dut.update(&mut xy, *x, true)) ); } From 2bfed7b66971211bdb90220345a0b7fdb895f05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 14 Apr 2021 16:09:54 +0200 Subject: [PATCH 53/70] dual-iir: add enable_hold, force_hold * Also use Settings as resource directly and copy it bulk (like lockin-external) --- src/bin/dual-iir.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 520d5ec..0dc9818 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -22,10 +22,12 @@ const SCALE: f32 = i16::MAX as _; // The number of cascaded IIR biquads per channel. Select 1 or 2! const IIR_CASCADE_LENGTH: usize = 1; -#[derive(Debug, Deserialize, Miniconf)] +#[derive(Clone, Copy, Debug, Deserialize, Miniconf)] pub struct Settings { afe: [AfeGain; 2], iir_ch: [[iir::IIR; IIR_CASCADE_LENGTH]; 2], + allow_hold: bool, + force_hold: bool, } impl Default for Settings { @@ -33,6 +35,8 @@ impl Default for Settings { Self { afe: [AfeGain::G1, AfeGain::G1], iir_ch: [[iir::IIR::new(1., -SCALE, SCALE); IIR_CASCADE_LENGTH]; 2], + allow_hold: false, + force_hold: false, } } } @@ -51,11 +55,10 @@ const APP: () = { // Format: iir_state[ch][cascade-no][coeff] #[init([[[0.; 5]; IIR_CASCADE_LENGTH]; 2])] iir_state: [[iir::Vec5; IIR_CASCADE_LENGTH]; 2], - #[init([[iir::IIR::new(1., -SCALE, SCALE); IIR_CASCADE_LENGTH]; 2])] - iir_ch: [[iir::IIR; IIR_CASCADE_LENGTH]; 2], + settings: Settings, } - #[init] + #[init(spawn=[settings_update])] fn init(c: init::Context) -> init::LateResources { // Configure the microcontroller let (mut stabilizer, _pounder) = hardware::setup(c.core, c.device); @@ -78,6 +81,9 @@ const APP: () = { .unwrap() }; + // Spawn a settings update for default settings. + c.spawn.settings_update().unwrap(); + // Enable ADC/DAC events stabilizer.adcs.0.start(); stabilizer.adcs.1.start(); @@ -94,6 +100,7 @@ const APP: () = { dacs: stabilizer.dacs, clock: stabilizer.cycle_counter, di1: stabilizer.digital_inputs.1, + settings: Settings::default(), } } @@ -113,7 +120,7 @@ const APP: () = { /// /// Because the ADC and DAC operate at the same rate, these two constraints actually implement /// the same time bounds, meeting one also means the other is also met. - #[task(binds=DMA1_STR4, resources=[adcs, di1, dacs, iir_state, iir_ch], priority=2)] + #[task(binds=DMA1_STR4, resources=[adcs, di1, dacs, iir_state, settings], priority=2)] fn process(c: process::Context) { let adc_samples = [ c.resources.adcs.0.acquire_buffer(), @@ -125,13 +132,15 @@ const APP: () = { c.resources.dacs.1.acquire_buffer(), ]; - let hold = c.resources.di1.is_high().unwrap(); + let hold = c.resources.settings.force_hold + || (c.resources.di1.is_high().unwrap() + && c.resources.settings.allow_hold); for channel in 0..adc_samples.len() { for sample in 0..adc_samples[0].len() { let mut y = f32::from(adc_samples[channel][sample] as i16); for i in 0..c.resources.iir_state[channel].len() { - y = c.resources.iir_ch[channel][i].update( + y = c.resources.settings.iir_ch[channel][i].update( &mut c.resources.iir_state[channel][i], y, hold, @@ -181,12 +190,12 @@ const APP: () = { } } - #[task(priority = 1, resources=[mqtt_interface, afes, iir_ch])] + #[task(priority = 1, resources=[mqtt_interface, afes, settings])] fn settings_update(mut c: settings_update::Context) { let settings = &c.resources.mqtt_interface.settings; // Update the IIR channels. - c.resources.iir_ch.lock(|iir| *iir = settings.iir_ch); + c.resources.settings.lock(|current| *current = *settings); // Update AFEs c.resources.afes.0.set_gain(settings.afe[0]); From d333a25301a53e2b8d0347db1bbd7779f734feb4 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 15 Apr 2021 12:24:49 +0200 Subject: [PATCH 54/70] Updating dependency --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0c99862..ee321ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/random-port#462adc56a8cc95bc1324f6d96fdbe82e85ca6d36" +source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/random-port#b5b050b135f3fe89e1a33d7d9f1d3d8570132f3c" dependencies = [ "embedded-nal", "heapless 0.6.1", From 8cc06d39c4e65fd3ceb867598b98f08c31a1b9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 15 Apr 2021 13:47:10 +0200 Subject: [PATCH 55/70] dual-iir: use InputPin re-export, rename digital_input --- src/bin/dual-iir.rs | 16 ++++++---------- src/hardware/configuration.rs | 2 +- src/hardware/mod.rs | 3 +++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index 0dc9818..d51ca56 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -2,10 +2,6 @@ #![no_std] #![no_main] -use stm32h7xx_hal as hal; - -pub use embedded_hal::digital::v2::InputPin; - use stabilizer::hardware; use miniconf::{minimq, Miniconf, MqttInterface}; @@ -14,7 +10,7 @@ use serde::Deserialize; use dsp::iir; use hardware::{ Adc0Input, Adc1Input, AfeGain, CycleCounter, Dac0Output, Dac1Output, - DigitalInput1, NetworkStack, AFE0, AFE1, + DigitalInput1, InputPin, NetworkStack, AFE0, AFE1, }; const SCALE: f32 = i16::MAX as _; @@ -45,7 +41,7 @@ impl Default for Settings { const APP: () = { struct Resources { afes: (AFE0, AFE1), - di1: DigitalInput1, + digital_input1: DigitalInput1, adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), mqtt_interface: @@ -99,7 +95,7 @@ const APP: () = { adcs: stabilizer.adcs, dacs: stabilizer.dacs, clock: stabilizer.cycle_counter, - di1: stabilizer.digital_inputs.1, + digital_input1: stabilizer.digital_inputs.1, settings: Settings::default(), } } @@ -120,7 +116,7 @@ const APP: () = { /// /// Because the ADC and DAC operate at the same rate, these two constraints actually implement /// the same time bounds, meeting one also means the other is also met. - #[task(binds=DMA1_STR4, resources=[adcs, di1, dacs, iir_state, settings], priority=2)] + #[task(binds=DMA1_STR4, resources=[adcs, digital_input1, dacs, iir_state, settings], priority=2)] fn process(c: process::Context) { let adc_samples = [ c.resources.adcs.0.acquire_buffer(), @@ -133,7 +129,7 @@ const APP: () = { ]; let hold = c.resources.settings.force_hold - || (c.resources.di1.is_high().unwrap() + || (c.resources.digital_input1.is_high().unwrap() && c.resources.settings.allow_hold); for channel in 0..adc_samples.len() { @@ -204,7 +200,7 @@ const APP: () = { #[task(binds = ETH, priority = 1)] fn eth(_: eth::Context) { - unsafe { hal::ethernet::interrupt_handler() } + unsafe { stm32h7xx_hal::ethernet::interrupt_handler() } } #[task(binds = SPI2, priority = 3)] diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index 31fb16d..bff3fe6 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -9,7 +9,7 @@ use stm32h7xx_hal::{ use smoltcp_nal::smoltcp; -pub use embedded_hal::digital::v2::{InputPin, OutputPin}; +use embedded_hal::digital::v2::{InputPin, OutputPin}; use super::{ adc, afe, cycle_counter::CycleCounter, dac, design_parameters, diff --git a/src/hardware/mod.rs b/src/hardware/mod.rs index 34f092f..26800fc 100644 --- a/src/hardware/mod.rs +++ b/src/hardware/mod.rs @@ -1,6 +1,9 @@ ///! Module for all hardware-specific setup of Stabilizer use stm32h7xx_hal as hal; +// Re-export for the DigitalInputs below: +pub use embedded_hal::digital::v2::InputPin; + #[cfg(feature = "semihosting")] use panic_semihosting as _; From 1a08634dcb90634141c5f2bb966174b7905423fe Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 19 Apr 2021 12:17:41 +0200 Subject: [PATCH 56/70] Renaming interface to avoid confusion --- src/bin/dual-iir.rs | 20 ++++++++++++-------- src/bin/lockin-external.rs | 20 ++++++++++++-------- src/net/mod.rs | 11 ++++++----- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index cac6f45..8f07cf1 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -13,7 +13,7 @@ use hardware::{ InputPin, AFE0, AFE1, }; -use net::{Action, MqttSettings}; +use net::{Action, MiniconfInterface}; const SCALE: f32 = i16::MAX as _; @@ -46,7 +46,7 @@ const APP: () = { digital_input1: DigitalInput1, adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), - mqtt_settings: MqttSettings, + mqtt_config: MiniconfInterface, // Format: iir_state[ch][cascade-no][coeff] #[init([[[0.; 5]; IIR_CASCADE_LENGTH]; 2])] @@ -59,7 +59,7 @@ const APP: () = { // Configure the microcontroller let (mut stabilizer, _pounder) = hardware::setup(c.core, c.device); - let mqtt_settings = MqttSettings::new( + let mqtt_config = MiniconfInterface::new( stabilizer.net.stack, "", "dt/sinara/stabilizer", @@ -83,7 +83,7 @@ const APP: () = { afes: stabilizer.afes, adcs: stabilizer.adcs, dacs: stabilizer.dacs, - mqtt_settings, + mqtt_config, digital_input1: stabilizer.digital_inputs.1, settings: Settings::default(), } @@ -140,10 +140,14 @@ const APP: () = { } } - #[idle(resources=[mqtt_settings], spawn=[settings_update])] + #[idle(resources=[mqtt_config], spawn=[settings_update])] fn idle(mut c: idle::Context) -> ! { loop { - match c.resources.mqtt_settings.lock(|settings| settings.update()) { + match c + .resources + .mqtt_config + .lock(|config_interface| config_interface.update()) + { Some(Action::Sleep) => cortex_m::asm::wfi(), Some(Action::UpdateSettings) => { c.spawn.settings_update().unwrap() @@ -153,9 +157,9 @@ const APP: () = { } } - #[task(priority = 1, resources=[mqtt_settings, afes, settings])] + #[task(priority = 1, resources=[mqtt_config, afes, settings])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_settings.mqtt.settings; + let settings = &c.resources.mqtt_config.mqtt.settings; // Update the IIR channels. c.resources.settings.lock(|current| *current = *settings); diff --git a/src/bin/lockin-external.rs b/src/bin/lockin-external.rs index b62ea42..36bd882 100644 --- a/src/bin/lockin-external.rs +++ b/src/bin/lockin-external.rs @@ -14,7 +14,7 @@ use stabilizer::hardware::{ }; use miniconf::Miniconf; -use stabilizer::net::{Action, MqttSettings}; +use stabilizer::net::{Action, MiniconfInterface}; #[derive(Copy, Clone, Debug, Deserialize, Miniconf)] enum Conf { @@ -58,7 +58,7 @@ const APP: () = { afes: (AFE0, AFE1), adcs: (Adc0Input, Adc1Input), dacs: (Dac0Output, Dac1Output), - mqtt_settings: MqttSettings, + mqtt_config: MiniconfInterface, settings: Settings, timestamper: InputStamper, @@ -71,7 +71,7 @@ const APP: () = { // Configure the microcontroller let (mut stabilizer, _pounder) = setup(c.core, c.device); - let mqtt_settings = MqttSettings::new( + let mqtt_config = MiniconfInterface::new( stabilizer.net.stack, "", "dt/sinara/lockin", @@ -108,7 +108,7 @@ const APP: () = { afes: stabilizer.afes, adcs: stabilizer.adcs, dacs: stabilizer.dacs, - mqtt_settings, + mqtt_config, timestamper: stabilizer.timestamper, settings, @@ -190,10 +190,14 @@ const APP: () = { } } - #[idle(resources=[mqtt_settings], spawn=[settings_update])] + #[idle(resources=[mqtt_config], spawn=[settings_update])] fn idle(mut c: idle::Context) -> ! { loop { - match c.resources.mqtt_settings.lock(|settings| settings.update()) { + match c + .resources + .mqtt_config + .lock(|config_interface| config_interface.update()) + { Some(Action::Sleep) => cortex_m::asm::wfi(), Some(Action::UpdateSettings) => { c.spawn.settings_update().unwrap() @@ -203,9 +207,9 @@ const APP: () = { } } - #[task(priority = 1, resources=[mqtt_settings, settings, afes])] + #[task(priority = 1, resources=[mqtt_config, settings, afes])] fn settings_update(mut c: settings_update::Context) { - let settings = &c.resources.mqtt_settings.mqtt.settings; + let settings = &c.resources.mqtt_config.mqtt.settings; c.resources.afes.0.set_gain(settings.afe[0]); c.resources.afes.1.set_gain(settings.afe[1]); diff --git a/src/net/mod.rs b/src/net/mod.rs index f38f3d9..23d712d 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -2,7 +2,7 @@ use crate::hardware::{ design_parameters::MQTT_BROKER, CycleCounter, EthernetPhy, NetworkStack, }; -use miniconf::{minimq, MqttInterface}; +use miniconf::minimq; /// Potential actions for firmware to take. pub enum Action { @@ -14,17 +14,17 @@ pub enum Action { } /// MQTT settings interface. -pub struct MqttSettings +pub struct MiniconfInterface where S: miniconf::Miniconf + Default, { - pub mqtt: MqttInterface, + pub mqtt: miniconf::MqttInterface, clock: CycleCounter, phy: EthernetPhy, network_was_reset: bool, } -impl MqttSettings +impl MiniconfInterface where S: miniconf::Miniconf + Default, { @@ -49,7 +49,8 @@ where .unwrap() }; - MqttInterface::new(mqtt_client, prefix, S::default()).unwrap() + miniconf::MqttInterface::new(mqtt_client, prefix, S::default()) + .unwrap() }; Self { From b2285d1ba2f0c9eba38e83aec33cefd88d7a4b93 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 19 Apr 2021 15:55:02 +0200 Subject: [PATCH 57/70] Updating dependency revision --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee321ff..970506d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -716,7 +716,7 @@ dependencies = [ [[package]] name = "smoltcp-nal" version = "0.1.0" -source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/random-port#b5b050b135f3fe89e1a33d7d9f1d3d8570132f3c" +source = "git+https://github.com/quartiq/smoltcp-nal.git?rev=8468f11#8468f11abacd7aba82454e6904df19c1d1ab91bb" dependencies = [ "embedded-nal", "heapless 0.6.1", diff --git a/Cargo.toml b/Cargo.toml index 87a0e2e..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" -branch = "feature/random-port" +rev = "8468f11" [patch.crates-io.minimq] git = "https://github.com/quartiq/minimq.git" From dfda6b6d751e168990cf0ea4e5d2ad765299293e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 19 Apr 2021 15:57:52 +0200 Subject: [PATCH 58/70] Reverting unintended change --- src/hardware/design_parameters.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/design_parameters.rs b/src/hardware/design_parameters.rs index 0ae4c35..9a4279b 100644 --- a/src/hardware/design_parameters.rs +++ b/src/hardware/design_parameters.rs @@ -51,4 +51,4 @@ pub const SAMPLE_BUFFER_SIZE_LOG2: u8 = 3; pub const SAMPLE_BUFFER_SIZE: usize = 1 << SAMPLE_BUFFER_SIZE_LOG2; // The MQTT broker IPv4 address -pub const MQTT_BROKER: [u8; 4] = [10, 35, 16, 10]; +pub const MQTT_BROKER: [u8; 4] = [10, 34, 16, 10]; From 42999e8b2ad54d27d228a6026e10b68d1a600f4e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 20 Apr 2021 10:44:44 +0200 Subject: [PATCH 59/70] Updating ping deadline --- hitl/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 483a8a3..0203071 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -21,7 +21,7 @@ cargo flash --elf target/thumbv7em-none-eabihf/release/dual-iir --chip STM32H743 # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended # * The stabilizer application is operational -ping -c 5 -w 20 stabilizer-hitl +ping -c 5 -w 45 stabilizer-hitl # Test the MQTT interface. python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"' From bc5e532655e358300b27c24987479ecd5b2edea8 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 20 Apr 2021 12:13:40 +0200 Subject: [PATCH 60/70] Adding sleep to HITL run --- hitl/run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 483a8a3..947a0d3 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -17,11 +17,13 @@ python3 -m pip install -r requirements.txt cargo flash --elf target/thumbv7em-none-eabihf/release/dual-iir --chip STM32H743ZITx +sleep 30 + # Test pinging Stabilizer. This exercises that: # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended # * The stabilizer application is operational -ping -c 5 -w 20 stabilizer-hitl +ping -c 5 -w 45 stabilizer-hitl # Test the MQTT interface. python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"' From 7106b7d585e220754aef5a964681b304eec71334 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 20 Apr 2021 13:21:02 +0200 Subject: [PATCH 61/70] Adding comment, reverting change --- hitl/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hitl/run.sh b/hitl/run.sh index 947a0d3..41d59a0 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -17,13 +17,14 @@ 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 # * The stabilizer application is operational -ping -c 5 -w 45 stabilizer-hitl +ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"' From 65073d11b9e6e6196481c62e812dfe7cd0bd924f Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 20 Apr 2021 13:37:49 +0200 Subject: [PATCH 62/70] Updating code after review --- hitl/run.sh | 6 +++--- src/hardware/configuration.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hitl/run.sh b/hitl/run.sh index 40f9039..2af4732 100755 --- a/hitl/run.sh +++ b/hitl/run.sh @@ -24,9 +24,9 @@ sleep 30 # * DHCP is functional and an IP has been acquired # * Stabilizer's network is functioning as intended # * The stabilizer application is operational -ping -c 5 -w 45 stabilizer-hitl +ping -c 5 -w 20 stabilizer-hitl # Test the MQTT interface. -python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"' -python3 miniconf.py dt/sinara/stabilizer afe/0='"G1"' iir_ch/0/0=\ +python3 miniconf.py dt/sinara/dual-iir/04-91-62-d9-7e-5f afe/0='"G2"' +python3 miniconf.py dt/sinara/dual-iir/04-91-62-d9-7e-5f afe/0='"G1"' iir_ch/0/0=\ '{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}' diff --git a/src/hardware/configuration.rs b/src/hardware/configuration.rs index 630fe12..f453c11 100644 --- a/src/hardware/configuration.rs +++ b/src/hardware/configuration.rs @@ -552,7 +552,7 @@ pub fn setup( smoltcp::iface::NeighborCache::new(&mut store.neighbor_cache[..]); let interface = smoltcp::iface::EthernetInterfaceBuilder::new(eth_dma) - .ethernet_addr(mac_addr.clone()) + .ethernet_addr(mac_addr) .neighbor_cache(neighbor_cache) .ip_addrs(&mut store.ip_addrs[..]) .routes(routes) From 770a4681774e262994528612d82b00366eac0a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 21 Apr 2021 14:45:12 +0200 Subject: [PATCH 63/70] prepare v0.5.0 release * update changelog * bump version --- CHANGELOG.md | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 +- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a42efa..d6f355e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,73 @@ -# Changelog +# Change Log -## [v0.2.0] 2019-05-28 +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] + +### Added + +### Changed + +### Fixed + +## [v0.5.0] - 2021-04-21 + +### Added + +* Batch sample processing +* DMA for ADC and DAC batches +* Pounder profile streaming +* DSP library with lots of optimized algorithms +* Digital input support +* Hardware in the loop continuous integration testing +* Dependency updates +* MQTT settings interface through miniconf/minimq +* Multi-binary support +* DHCP support + +### Changed + +* Removed JSON-over-TCP interface + +### Fixed + +* Rebust EEPROM MAC address reading slow supply start + +## [v0.4.1] - 2020-06-23 + +### Fixed + +* Fix DAC clr/ldac, SPI speed + +## [v0.4.0] - 2020-06-22 + +### Added + +* Hardware v1.1 only +* AD9959/Pounder support + +### Changed + +* HAL port + +## [v0.3.0] - 2020-01-20 + +### Added + +* Red LED handling +* EEPROM MAC address reading + +### Changed + +* Panic handler cleanup +* Dependency updates (smoltcp, rtfm) + +## [v0.2.0] - 2019-05-28 + +### Added * Initial basic release * Ethernet support @@ -9,6 +76,15 @@ * ADC/DAC timing and interrupts * Board configuration, bootstrap -## [v0.1.0] 2019-03-10 +## [v0.1.0] - 2019-03-10 + +### Added * First bits of code published + +[Unreleased]: https://github.com/quartiq/stabilizer/compare/v0.5.0...HEAD +[v0.5.0]: https://github.com/quartiq/stabilizer/compare/v0.4.1...v0.5.0 +[v0.4.1]: https://github.com/quartiq/stabilizer/compare/v0.4.0...v0.4.1 +[v0.4.0]: https://github.com/quartiq/stabilizer/compare/v0.3.0...v0.4.0 +[v0.3.0]: https://github.com/quartiq/stabilizer/compare/v0.2.0...v0.3.0 +[v0.2.0]: https://github.com/quartiq/stabilizer/compare/v0.1.0...v0.2.0 diff --git a/Cargo.toml b/Cargo.toml index f4db4d8..fe2f6ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stabilizer" -version = "0.4.1" +version = "0.5.0" authors = ["Robert Jördens "] description = "Firmware for the Sinara Stabilizer board (stm32h743, eth, poe, 2 adc, 2 dac)" categories = ["embedded", "no-std", "hardware-support", "science"] From e5557582a2558a417e58e9e04bc2b1423bd3afe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 21 Apr 2021 15:03:28 +0200 Subject: [PATCH 64/70] let bors handle hitl --- .github/bors.toml | 1 + .github/workflows/hitl_trigger.yml | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/bors.toml b/.github/bors.toml index 722246d..5d1bf89 100644 --- a/.github/bors.toml +++ b/.github/bors.toml @@ -4,4 +4,5 @@ status = [ "style", "test (stable)", "compile (stable)", + "HITL Run Status" ] diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index 62abb96..b275421 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -2,8 +2,10 @@ name: HITL Trigger on: workflow_dispatch: - pull_request: - branches: [ master ] + push: + branches: + - staging + - trying jobs: hitl-trigger: From d9129ed02858437198d352b20dd4beb483f2e185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 21 Apr 2021 16:38:04 +0200 Subject: [PATCH 65/70] update lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 970506d..5e48b40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -726,7 +726,7 @@ dependencies = [ [[package]] name = "stabilizer" -version = "0.4.1" +version = "0.5.0" dependencies = [ "ad9959", "asm-delay", From 3a19d3dc6db8f40884de0b610baa927a1a497b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 21 Apr 2021 16:40:30 +0200 Subject: [PATCH 66/70] changelog: spelling --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6f355e..04aa2fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -* Rebust EEPROM MAC address reading slow supply start +* Robust EEPROM MAC address reading slow supply start ## [v0.4.1] - 2020-06-23 From 61dc6e340eced121ff499ad456f5450a1df1e47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Wed, 28 Apr 2021 16:27:59 +0200 Subject: [PATCH 67/70] dual-iir: add some mqtt parameter docs --- src/bin/dual-iir.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index eaa82ae..6d12be9 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -31,9 +31,17 @@ pub struct Settings { impl Default for Settings { fn default() -> Self { Self { + // Analog frontend programmable gain amplifier gains (G1, G2, G5, G10) afe: [AfeGain::G1, AfeGain::G1], + // IIR filter tap gains are an array `[b0, b1, b2, a1, a2]` such that the + // new output is computed as `y0 = a1*y1 + a2*y2 + b0*x0 + b1*x1 + b2*x2`. + // The array is `iir_state[channel-index][cascade-index][coeff-index]`. + // The IIR coefficients can be mapped to other transfer function + // representations, for example as described in https://arxiv.org/abs/1508.06319 iir_ch: [[iir::IIR::new(1., -SCALE, SCALE); IIR_CASCADE_LENGTH]; 2], + // Permit the DI1 digital input to suppress filter output updates. allow_hold: false, + // Force suppress filter output updates. force_hold: false, } } @@ -48,7 +56,6 @@ const APP: () = { dacs: (Dac0Output, Dac1Output), mqtt_config: MiniconfInterface, - // Format: iir_state[ch][cascade-no][coeff] #[init([[[0.; 5]; IIR_CASCADE_LENGTH]; 2])] iir_state: [[iir::Vec5; IIR_CASCADE_LENGTH]; 2], settings: Settings, From d6cc8f7ed5415905e33a8f6b86928cbb3e889b70 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 29 Apr 2021 14:07:42 +0200 Subject: [PATCH 68/70] Adding bors timeout --- .github/bors.toml | 1 + .github/workflows/hitl_trigger.yml | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/bors.toml b/.github/bors.toml index 5d1bf89..1733a86 100644 --- a/.github/bors.toml +++ b/.github/bors.toml @@ -1,5 +1,6 @@ block_labels = [ "S-blocked" ] delete_merged_branches = true +timeout_sec = 1200 status = [ "style", "test (stable)", diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index b275421..a8494b3 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -12,15 +12,24 @@ jobs: runs-on: ubuntu-latest environment: hitl steps: + - uses: LouisBrunner/checks-action@v1.1.1 + id: hitl-check + with: + repo: ${{ github.repository }} + sha: ${{ github.event.head_commit.id }} + token: ${{ github.token }} + name: HITL Run Status + status: in_progress + details_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" + output: { "summary": "Starting..." } + - uses: peter-evans/repository-dispatch@v1 with: token: ${{ secrets.DISPATCH_PAT }} event-type: stabilizer repository: quartiq/hitl - client-payload: '{"github": ${{ toJson(github) }}}' - - - name: Wait for startup - run: sleep 30 + client-payload: | + '{"github": ${{ toJson(github) }}, "check_id": ${{steps.hitl-check.outputs.check_id}}}' - uses: fountainhead/action-wait-for-check@v1.0.0 with: From 7906ef2f9d6bb94355ac1abd680f3f23f8ad4f4e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 29 Apr 2021 14:12:22 +0200 Subject: [PATCH 69/70] Updating trigger --- .github/workflows/hitl_trigger.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index a8494b3..b108ba6 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -21,7 +21,8 @@ jobs: name: HITL Run Status status: in_progress details_url: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" - output: { "summary": "Starting..." } + output: | + {"summary": "Starting..."} - uses: peter-evans/repository-dispatch@v1 with: From c9f61143f5f4d3dcf260b331426f445420a0fa89 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 29 Apr 2021 14:15:16 +0200 Subject: [PATCH 70/70] Updating JSON syntax --- .github/workflows/hitl_trigger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hitl_trigger.yml b/.github/workflows/hitl_trigger.yml index b108ba6..b0fafac 100644 --- a/.github/workflows/hitl_trigger.yml +++ b/.github/workflows/hitl_trigger.yml @@ -30,7 +30,7 @@ jobs: event-type: stabilizer repository: quartiq/hitl client-payload: | - '{"github": ${{ toJson(github) }}, "check_id": ${{steps.hitl-check.outputs.check_id}}}' + {"github": ${{ toJson(github) }}, "check_id": ${{steps.hitl-check.outputs.check_id}}} - uses: fountainhead/action-wait-for-check@v1.0.0 with: