Compare commits
No commits in common. "eb80d0365b85573b69748c5d07bbc0550047ced6" and "e8fd234f57625be396a8167b8acf421ef3c7b5de" have entirely different histories.
eb80d0365b
...
e8fd234f57
11 changed files with 56 additions and 110 deletions
5
firmware/Cargo.lock
generated
5
firmware/Cargo.lock
generated
|
|
@ -130,7 +130,8 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cortex-m",
|
"cortex-m",
|
||||||
"cortex-m-rt",
|
"cortex-m-rt",
|
||||||
"embassy-boot",
|
"defmt 1.0.1",
|
||||||
|
"defmt-rtt",
|
||||||
"embassy-boot-stm32",
|
"embassy-boot-stm32",
|
||||||
"embassy-executor",
|
"embassy-executor",
|
||||||
"embassy-stm32",
|
"embassy-stm32",
|
||||||
|
|
@ -319,6 +320,7 @@ name = "embassy-boot"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/embassy-rs/embassy#56572ef0adffd6258adc10fb424e37a8b4ddc19c"
|
source = "git+https://github.com/embassy-rs/embassy#56572ef0adffd6258adc10fb424e37a8b4ddc19c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"defmt 1.0.1",
|
||||||
"digest",
|
"digest",
|
||||||
"embassy-embedded-hal",
|
"embassy-embedded-hal",
|
||||||
"embassy-sync",
|
"embassy-sync",
|
||||||
|
|
@ -335,6 +337,7 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cortex-m",
|
"cortex-m",
|
||||||
"cortex-m-rt",
|
"cortex-m-rt",
|
||||||
|
"defmt 1.0.1",
|
||||||
"embassy-boot",
|
"embassy-boot",
|
||||||
"embassy-stm32",
|
"embassy-stm32",
|
||||||
"embassy-sync",
|
"embassy-sync",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ resolver = "3"
|
||||||
members = ["app", "boot"]
|
members = ["app", "boot"]
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
embassy-boot = { git = "https://github.com/embassy-rs/embassy" }
|
|
||||||
embassy-boot-stm32 = { git = "https://github.com/embassy-rs/embassy" }
|
embassy-boot-stm32 = { git = "https://github.com/embassy-rs/embassy" }
|
||||||
embassy-executor = { git = "https://github.com/embassy-rs/embassy" }
|
embassy-executor = { git = "https://github.com/embassy-rs/embassy" }
|
||||||
embassy-futures = { git = "https://github.com/embassy-rs/embassy" }
|
embassy-futures = { git = "https://github.com/embassy-rs/embassy" }
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
runner = [
|
||||||
|
"probe-rs",
|
||||||
|
"run",
|
||||||
|
"--chip",
|
||||||
|
"STM32G070KB",
|
||||||
|
"--log-format",
|
||||||
|
"{t} {m} {s}",
|
||||||
|
]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "thumbv6m-none-eabi"
|
target = "thumbv6m-none-eabi"
|
||||||
rustdocflags = ["--document-private-items"]
|
rustdocflags = ["--document-private-items"]
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,13 @@
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::usart;
|
use embassy_stm32::usart;
|
||||||
|
use micropb::heapless::Vec;
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
struct UartBuf {
|
type UartRxBuf = Vec<u8, 32>;
|
||||||
buffer: [u8; 32],
|
type UartTxBuf = Vec<u8, 32>;
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for UartBuf {
|
static UART_RX_BUF: StaticCell<UartRxBuf> = StaticCell::new();
|
||||||
fn default() -> UartBuf {
|
static UART_TX_BUF: StaticCell<UartTxBuf> = StaticCell::new();
|
||||||
unsafe { core::mem::zeroed() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static UART_TX_BUF: StaticCell<UartBuf> = StaticCell::new();
|
|
||||||
static UART_RX_BUF: StaticCell<UartBuf> = StaticCell::new();
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct Tx {
|
struct Tx {
|
||||||
|
|
@ -26,8 +20,8 @@ struct Rx {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(r: crate::HeatPumpInterfaceResources, spawner: Spawner) {
|
pub fn start(r: crate::HeatPumpInterfaceResources, spawner: Spawner) {
|
||||||
let tx_buf = UART_TX_BUF.init(UartBuf::default());
|
let rx_buf = UART_RX_BUF.init(UartRxBuf::new());
|
||||||
let rx_buf = UART_RX_BUF.init(UartBuf::default());
|
let tx_buf = UART_TX_BUF.init(UartTxBuf::new());
|
||||||
|
|
||||||
let mut config = usart::Config::default();
|
let mut config = usart::Config::default();
|
||||||
config.baudrate = 2400;
|
config.baudrate = 2400;
|
||||||
|
|
@ -38,8 +32,8 @@ pub fn start(r: crate::HeatPumpInterfaceResources, spawner: Spawner) {
|
||||||
r.usart,
|
r.usart,
|
||||||
r.rx_pin,
|
r.rx_pin,
|
||||||
r.tx_pin,
|
r.tx_pin,
|
||||||
&mut tx_buf.buffer,
|
tx_buf,
|
||||||
&mut rx_buf.buffer,
|
rx_buf,
|
||||||
crate::Irqs,
|
crate::Irqs,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,13 @@
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::usart;
|
use embassy_stm32::usart;
|
||||||
|
use micropb::heapless::Vec;
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
struct UartBuf {
|
type UartRxBuf = Vec<u8, 32>;
|
||||||
buffer: [u8; 32],
|
type UartTxBuf = Vec<u8, 32>;
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for UartBuf {
|
static UART_RX_BUF: StaticCell<UartRxBuf> = StaticCell::new();
|
||||||
fn default() -> UartBuf {
|
static UART_TX_BUF: StaticCell<UartTxBuf> = StaticCell::new();
|
||||||
unsafe { core::mem::zeroed() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static UART_TX_BUF: StaticCell<UartBuf> = StaticCell::new();
|
|
||||||
static UART_RX_BUF: StaticCell<UartBuf> = StaticCell::new();
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct Tx {
|
struct Tx {
|
||||||
|
|
@ -26,8 +20,8 @@ struct Rx {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(r: crate::ThermostatInterfaceResources, spawner: Spawner) {
|
pub fn start(r: crate::ThermostatInterfaceResources, spawner: Spawner) {
|
||||||
let tx_buf = UART_TX_BUF.init(UartBuf::default());
|
let rx_buf = UART_RX_BUF.init(UartRxBuf::new());
|
||||||
let rx_buf = UART_RX_BUF.init(UartBuf::default());
|
let tx_buf = UART_TX_BUF.init(UartTxBuf::new());
|
||||||
|
|
||||||
let mut config = usart::Config::default();
|
let mut config = usart::Config::default();
|
||||||
config.baudrate = 2400;
|
config.baudrate = 2400;
|
||||||
|
|
@ -38,8 +32,8 @@ pub fn start(r: crate::ThermostatInterfaceResources, spawner: Spawner) {
|
||||||
r.usart,
|
r.usart,
|
||||||
r.rx_pin,
|
r.rx_pin,
|
||||||
r.tx_pin,
|
r.tx_pin,
|
||||||
&mut tx_buf.buffer,
|
tx_buf,
|
||||||
&mut rx_buf.buffer,
|
rx_buf,
|
||||||
crate::Irqs,
|
crate::Irqs,
|
||||||
config,
|
config,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,16 @@
|
||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
runner = [
|
||||||
|
"probe-rs",
|
||||||
|
"run",
|
||||||
|
"--chip",
|
||||||
|
"STM32G070KB",
|
||||||
|
"--log-format",
|
||||||
|
"{t} {m} {s}",
|
||||||
|
]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "thumbv6m-none-eabi"
|
target = "thumbv6m-none-eabi"
|
||||||
rustdocflags = ["--document-private-items"]
|
rustdocflags = ["--document-private-items"]
|
||||||
|
|
||||||
|
[env]
|
||||||
|
DEFMT_LOG = "trace"
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embassy-boot = { version = "0.4.0" }
|
embassy-boot-stm32 = { version = "0.3.0", features = ["defmt"] }
|
||||||
embassy-boot-stm32 = { version = "0.3.0" }
|
embassy-executor = { version = "0.7.0", features = ["arch-cortex-m", "executor-thread", "defmt"] }
|
||||||
embassy-executor = { version = "0.7.0", features = ["arch-cortex-m", "executor-thread"] }
|
embassy-stm32 = { version = "0.2.0", features = ["time-driver-tim1", "stm32g070kb", "defmt"] }
|
||||||
embassy-stm32 = { version = "0.2.0", features = ["time-driver-tim1", "stm32g070kb"] }
|
|
||||||
embassy-sync = "0.7.0"
|
embassy-sync = "0.7.0"
|
||||||
|
|
||||||
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
|
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
|
||||||
|
|
@ -18,6 +17,9 @@ embedded-storage-async = "0.4.1"
|
||||||
|
|
||||||
cfg-if = "1.0.1"
|
cfg-if = "1.0.1"
|
||||||
|
|
||||||
|
defmt = { version = "1.0.0" }
|
||||||
|
defmt-rtt = { version = "1.0.0" }
|
||||||
|
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
pedantic = { level = "warn", priority = -1 }
|
pedantic = { level = "warn", priority = -1 }
|
||||||
cargo = { level = "warn", priority = -1 }
|
cargo = { level = "warn", priority = -1 }
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,5 @@ fn main() {
|
||||||
|
|
||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use cortex_m_rt::{entry, exception};
|
use cortex_m_rt::{entry, exception};
|
||||||
|
use defmt_rtt as _;
|
||||||
use embassy_boot_stm32::*;
|
use embassy_boot_stm32::*;
|
||||||
use embassy_stm32::Config;
|
use embassy_stm32::Config;
|
||||||
use embassy_stm32::flash::{BANK1_REGION, Flash};
|
use embassy_stm32::flash::{BANK1_REGION, Flash};
|
||||||
|
|
@ -15,9 +16,9 @@ fn main() -> ! {
|
||||||
|
|
||||||
// Uncomment this if you are debugging the bootloader with debugger/RTT attached,
|
// Uncomment this if you are debugging the bootloader with debugger/RTT attached,
|
||||||
// as it prevents a hard fault when accessing flash 'too early' after boot.
|
// as it prevents a hard fault when accessing flash 'too early' after boot.
|
||||||
// for _i in 0..50_000_000 {
|
for _i in 0..10_000_000 {
|
||||||
// cortex_m::asm::nop();
|
cortex_m::asm::nop();
|
||||||
// }
|
}
|
||||||
|
|
||||||
let layout = Flash::new_blocking(p.FLASH).into_blocking_regions();
|
let layout = Flash::new_blocking(p.FLASH).into_blocking_regions();
|
||||||
let flash = Mutex::new(RefCell::new(layout.bank1_region));
|
let flash = Mutex::new(RefCell::new(layout.bank1_region));
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
run.sh
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CHIP=STM32G070KB
|
|
||||||
|
|
||||||
function clean {
|
|
||||||
cargo clean $@
|
|
||||||
}
|
|
||||||
|
|
||||||
function build-boot {
|
|
||||||
(cd boot; cargo build --release $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function build-app {
|
|
||||||
(cd app; cargo build --release $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function build {
|
|
||||||
build-boot
|
|
||||||
build-app
|
|
||||||
}
|
|
||||||
|
|
||||||
function size-boot {
|
|
||||||
(cd boot; cargo size --release -- -A $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function size-app {
|
|
||||||
(cd app; cargo size --release -- -A $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function size {
|
|
||||||
size-boot
|
|
||||||
size-app
|
|
||||||
}
|
|
||||||
|
|
||||||
function erase {
|
|
||||||
probe-rs erase --chip ${CHIP}
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash-boot {
|
|
||||||
(cd boot; cargo flash --release --chip ${CHIP} --reset-halt --log INFO $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash-app {
|
|
||||||
(cd app; cargo flash --release --chip ${CHIP} --reset-halt --log INFO $@)
|
|
||||||
}
|
|
||||||
|
|
||||||
function flash {
|
|
||||||
flash-boot
|
|
||||||
flash-app
|
|
||||||
}
|
|
||||||
|
|
||||||
function run {
|
|
||||||
probe-rs attach --chip ${CHIP} --log-format "{t} {m} {s}" target/thumbv6m-none-eabi/release/app
|
|
||||||
}
|
|
||||||
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
set -o errexit
|
|
||||||
#set -o xtrace
|
|
||||||
|
|
||||||
PROJECT_ROOT=${0%/*}
|
|
||||||
if [[ $0 != $PROJECT_ROOT && $PROJECT_ROOT != "" ]]; then
|
|
||||||
cd "$PROJECT_ROOT"
|
|
||||||
fi
|
|
||||||
readonly PROJECT_ROOT=$(pwd)
|
|
||||||
|
|
||||||
readonly SCRIPT="$PROJECT_ROOT/$(basename "$0")"
|
|
||||||
|
|
||||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
|
||||||
time "${@}"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue