cargo: update to esp-hal 1.0, and use esp-radio for less crashes
This commit is contained in:
584
Cargo.lock
generated
584
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
34
Cargo.toml
34
Cargo.toml
@@ -15,7 +15,7 @@ real-output = []
|
|||||||
simulation = ["dep:rmp"]
|
simulation = ["dep:rmp"]
|
||||||
radio = [
|
radio = [
|
||||||
"dep:bleps",
|
"dep:bleps",
|
||||||
"dep:esp-wifi",
|
"dep:esp-radio",
|
||||||
"dep:reqwless"
|
"dep:reqwless"
|
||||||
]
|
]
|
||||||
motion = ["mpu", "gps"]
|
motion = ["mpu", "gps"]
|
||||||
@@ -31,36 +31,37 @@ demo = []
|
|||||||
# The basic requirements for all features
|
# The basic requirements for all features
|
||||||
figments = { path = "../figments/figments/", features = ["alloc", "embedded-graphics"] }
|
figments = { path = "../figments/figments/", features = ["alloc", "embedded-graphics"] }
|
||||||
figments-render = { path = "../figments/figments-render/", features = ["smart-leds", "micromath"], default-features = false }
|
figments-render = { path = "../figments/figments-render/", features = ["smart-leds", "micromath"], default-features = false }
|
||||||
esp-bootloader-esp-idf = { version = "0.2.0", features = ["esp32s3"] }
|
esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32s3"] }
|
||||||
esp-hal = { version = "=1.0.0-rc.0", features = [
|
esp-hal = { version = "1.0.0", features = [
|
||||||
"esp32s3",
|
"esp32s3",
|
||||||
"log-04",
|
"log-04",
|
||||||
"unstable",
|
"unstable",
|
||||||
] }
|
] }
|
||||||
esp-alloc = "0.8.0"
|
esp-alloc = "0.9.0"
|
||||||
esp-backtrace = { version = "0.17.0", features = [
|
esp-backtrace = { version = "0.18", features = [
|
||||||
"esp32s3",
|
"esp32s3",
|
||||||
"exception-handler",
|
|
||||||
"panic-handler",
|
"panic-handler",
|
||||||
"println",
|
"println",
|
||||||
] }
|
] }
|
||||||
esp-println = { version = "0.15.0", features = ["esp32s3", "log-04"] }
|
esp-println = { version = "0.16", features = ["esp32s3", "log-04"] }
|
||||||
# for more networking protocol support see https://crates.io/crates/edge-net
|
# for more networking protocol support see https://crates.io/crates/edge-net
|
||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
embassy-executor = { version = "0.7.0", features = [
|
embassy-executor = { version = "0.9.0", features = [
|
||||||
"log",
|
"log",
|
||||||
"task-arena-size-98304",
|
# "task-arena-size-98304",
|
||||||
] }
|
] }
|
||||||
embassy-time = { version = "0.5.0", features = ["log"] }
|
embassy-time = { version = "0.5.0", features = ["log"] }
|
||||||
esp-hal-embassy = { version = "0.9.0", features = [
|
esp-rtos = { version = "0.2.0", features = [
|
||||||
|
"esp-radio",
|
||||||
|
"embassy",
|
||||||
|
"esp-alloc",
|
||||||
"esp32s3",
|
"esp32s3",
|
||||||
"log-04"
|
"log-04"
|
||||||
] }
|
] }
|
||||||
log = "0.4.27"
|
log = "0.4"
|
||||||
static_cell = "2.1.1"
|
static_cell = "2.1.1"
|
||||||
rgb = "0.8.52"
|
rgb = "0.8.52"
|
||||||
# esp-hal-smartled = { version = "0.15.0", features = ["esp32c3"] }
|
esp-hal-smartled = { version = "0.17.0", features = ["esp32s3"] }
|
||||||
esp-hal-smartled = { git = "https://github.com/esp-rs/esp-hal-community.git", features = ["esp32s3"] }
|
|
||||||
smart-leds = "0.4.0"
|
smart-leds = "0.4.0"
|
||||||
embassy-sync = "0.7.2"
|
embassy-sync = "0.7.2"
|
||||||
embassy-embedded-hal = "0.5.0"
|
embassy-embedded-hal = "0.5.0"
|
||||||
@@ -73,13 +74,14 @@ enumset = "1.1.10"
|
|||||||
enum-map = "2.7.3"
|
enum-map = "2.7.3"
|
||||||
|
|
||||||
# Telemetry outputs
|
# Telemetry outputs
|
||||||
esp-wifi = { version = "0.15.0", optional = true, features = [
|
esp-radio = { version = "*", optional = true, features = [
|
||||||
"builtin-scheduler",
|
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
"esp32s3",
|
"esp32s3",
|
||||||
"log-04",
|
"log-04",
|
||||||
"wifi",
|
"wifi",
|
||||||
"ble"
|
"ble",
|
||||||
|
"coex",
|
||||||
|
"unstable"
|
||||||
] }
|
] }
|
||||||
bleps = { git = "https://github.com/bjoernQ/bleps", optional = true, package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
|
bleps = { git = "https://github.com/bjoernQ/bleps", optional = true, package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
|
||||||
embedded-graphics = { version = "0.8.1", features = ["nalgebra_support"] }
|
embedded-graphics = { version = "0.8.1", features = ["nalgebra_support"] }
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ use esp_hal::{
|
|||||||
clock::CpuClock, system::{AppCoreGuard, CpuControl, Stack}, timer::{systimer::SystemTimer, timg::{TimerGroup, Wdt}}
|
clock::CpuClock, system::{AppCoreGuard, CpuControl, Stack}, timer::{systimer::SystemTimer, timg::{TimerGroup, Wdt}}
|
||||||
};
|
};
|
||||||
|
|
||||||
use esp_hal_embassy::{Executor, InterruptExecutor};
|
|
||||||
use log::*;
|
use log::*;
|
||||||
use renderbug_embassy::{logging::RenderbugLogger, tasks::{oled::{OledUI, OledUiSurfacePool, oled_ui}, safetyui::{SafetyUi, safety_ui_main}, ui::UiSurfacePool}};
|
use renderbug_embassy::{logging::RenderbugLogger, tasks::{oled::{OledUI, OledUiSurfacePool, oled_ui}, safetyui::{SafetyUi, safety_ui_main}, ui::UiSurfacePool}};
|
||||||
use renderbug_embassy::events::BusGarage;
|
use renderbug_embassy::events::BusGarage;
|
||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
|
use esp_rtos::embassy::{Executor, InterruptExecutor};
|
||||||
|
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
||||||
|
|
||||||
use renderbug_embassy::tasks::{
|
use renderbug_embassy::tasks::{
|
||||||
motion::motion_task,
|
motion::motion_task,
|
||||||
@@ -37,14 +38,15 @@ extern crate alloc;
|
|||||||
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
||||||
esp_bootloader_esp_idf::esp_app_desc!();
|
esp_bootloader_esp_idf::esp_app_desc!();
|
||||||
|
|
||||||
static STATIC_HI_EXEC: StaticCell<InterruptExecutor<0>> = StaticCell::new();
|
static STATIC_HI_EXEC: StaticCell<InterruptExecutor<2>> = StaticCell::new();
|
||||||
static CORE2_EXEC: StaticCell<Executor> = StaticCell::new();
|
static CORE2_EXEC: StaticCell<Executor> = StaticCell::new();
|
||||||
|
|
||||||
static BUS_GARAGE: StaticCell<BusGarage> = StaticCell::new();
|
static BUS_GARAGE: StaticCell<BusGarage> = StaticCell::new();
|
||||||
static mut CORE2_STACK: Stack<16384> = Stack::new();
|
static mut CORE2_STACK: Stack<16384> = Stack::new();
|
||||||
static CORE_HANDLE: StaticCell<AppCoreGuard> = StaticCell::new();
|
#[cfg(feature="radio")]
|
||||||
|
static WIFI_INIT: StaticCell<esp_radio::Controller<'static>> = StaticCell::new();
|
||||||
|
|
||||||
#[esp_hal_embassy::main]
|
#[esp_rtos::main]
|
||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
critical_section::with(|_| {
|
critical_section::with(|_| {
|
||||||
RenderbugLogger::init_logger();
|
RenderbugLogger::init_logger();
|
||||||
@@ -56,7 +58,7 @@ async fn main(spawner: Spawner) {
|
|||||||
esp_alloc::heap_allocator!(size: 128 * 1024);
|
esp_alloc::heap_allocator!(size: 128 * 1024);
|
||||||
|
|
||||||
let sys_timer = SystemTimer::new(peripherals.SYSTIMER);
|
let sys_timer = SystemTimer::new(peripherals.SYSTIMER);
|
||||||
esp_hal_embassy::init([sys_timer.alarm0, sys_timer.alarm1, sys_timer.alarm2]);
|
esp_rtos::start(sys_timer.alarm0);
|
||||||
info!("Embassy initialized!");
|
info!("Embassy initialized!");
|
||||||
|
|
||||||
let timer0 = TimerGroup::new(peripherals.TIMG0);
|
let timer0 = TimerGroup::new(peripherals.TIMG0);
|
||||||
@@ -82,10 +84,10 @@ async fn main(spawner: Spawner) {
|
|||||||
let mut wdt = timer0.wdt;
|
let mut wdt = timer0.wdt;
|
||||||
wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(5));
|
wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(5));
|
||||||
let swi = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
|
let swi = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
|
||||||
let hi_exec = STATIC_HI_EXEC.init(InterruptExecutor::new(swi.software_interrupt0));
|
let hi_exec = STATIC_HI_EXEC.init(InterruptExecutor::new(swi.software_interrupt2));
|
||||||
let hi_spawn = hi_exec.start(esp_hal::interrupt::Priority::max());
|
let hi_spawn = hi_exec.start(esp_hal::interrupt::Priority::max());
|
||||||
|
|
||||||
wdt.enable();
|
//wdt.enable();
|
||||||
hi_spawn.must_spawn(renderbug_embassy::tasks::render::render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, safety_surfaces, garage.display.clone(), wdt));
|
hi_spawn.must_spawn(renderbug_embassy::tasks::render::render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, safety_surfaces, garage.display.clone(), wdt));
|
||||||
|
|
||||||
#[cfg(feature="motion")]
|
#[cfg(feature="motion")]
|
||||||
@@ -97,8 +99,8 @@ async fn main(spawner: Spawner) {
|
|||||||
static I2C_BUS: StaticCell<Mutex<CriticalSectionRawMutex, I2c<'static, Async>>> = StaticCell::new();
|
static I2C_BUS: StaticCell<Mutex<CriticalSectionRawMutex, I2c<'static, Async>>> = StaticCell::new();
|
||||||
|
|
||||||
info!("Launching i2c sensor tasks");
|
info!("Launching i2c sensor tasks");
|
||||||
let sda = peripherals.GPIO3;
|
let sda = peripherals.GPIO4;
|
||||||
let scl = peripherals.GPIO4;
|
let scl = peripherals.GPIO3;
|
||||||
let i2c = I2c::new(peripherals.I2C1, Config::default()).unwrap().with_scl(scl).with_sda(sda).into_async();
|
let i2c = I2c::new(peripherals.I2C1, Config::default()).unwrap().with_scl(scl).with_sda(sda).into_async();
|
||||||
let i2c_bus = I2C_BUS.init(Mutex::new(i2c));
|
let i2c_bus = I2C_BUS.init(Mutex::new(i2c));
|
||||||
#[cfg(feature="mpu")]
|
#[cfg(feature="mpu")]
|
||||||
@@ -148,16 +150,13 @@ async fn main(spawner: Spawner) {
|
|||||||
#[cfg(feature="radio")]
|
#[cfg(feature="radio")]
|
||||||
let wifi_init = {
|
let wifi_init = {
|
||||||
info!("Configuring wifi");
|
info!("Configuring wifi");
|
||||||
|
//let rng = esp_hal::rng::Rng::new(peripherals.RNG);
|
||||||
static WIFI_INIT: StaticCell<esp_wifi::EspWifiController<'static>> = StaticCell::new();
|
WIFI_INIT.init_with(|| {esp_radio::init().expect("Failed to initialize radio controller")})
|
||||||
let rng = esp_hal::rng::Rng::new(peripherals.RNG);
|
|
||||||
WIFI_INIT.init_with(|| {esp_wifi::init(timer0.timer0, rng).expect("Failed to initialize radio controller")})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Starting core 2");
|
info!("Starting core 2");
|
||||||
let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL);
|
//let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL);
|
||||||
CORE_HANDLE.init_with(|| {
|
esp_rtos::start_second_core(peripherals.CPU_CTRL, swi.software_interrupt0, swi.software_interrupt1, unsafe { &mut *addr_of_mut!(CORE2_STACK) }, || {
|
||||||
cpu_control.start_app_core(unsafe { &mut *addr_of_mut!(CORE2_STACK) }, || {
|
|
||||||
let exec = CORE2_EXEC.init_with(|| { Executor::new() });
|
let exec = CORE2_EXEC.init_with(|| { Executor::new() });
|
||||||
exec.run(|spawner| {
|
exec.run(|spawner| {
|
||||||
info!("Launching Safety UI");
|
info!("Launching Safety UI");
|
||||||
@@ -189,7 +188,6 @@ async fn main(spawner: Spawner) {
|
|||||||
|
|
||||||
info!("System is ready in {}ms", Instant::now().as_millis());
|
info!("System is ready in {}ms", Instant::now().as_millis());
|
||||||
});
|
});
|
||||||
}).unwrap()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fn gyro_raw_to_rads(raw: i16) -> f32 {
|
|||||||
(raw as f32 / 16.4) * (DEG2RAD)
|
(raw as f32 / 16.4) * (DEG2RAD)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[esp_hal::ram(rtc_fast, persistent)]
|
#[esp_hal::ram(unstable(rtc_fast, persistent))]
|
||||||
static mut MPU_WAS_CALIBRATED: u8 = 0;
|
static mut MPU_WAS_CALIBRATED: u8 = 0;
|
||||||
|
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
|
|||||||
@@ -16,10 +16,9 @@ pub async fn render(rmt: esp_hal::peripherals::RMT<'static>, gpio: AnyPin<'stati
|
|||||||
.expect("Failed to initialize RMT").into_async();
|
.expect("Failed to initialize RMT").into_async();
|
||||||
let rmt_channel = rmt.channel0;
|
let rmt_channel = rmt.channel0;
|
||||||
|
|
||||||
let rmt_buffer = [0u32; buffer_size_async(NUM_PIXELS)];
|
let mut rmt_buffer = esp_hal_smartled::smart_led_buffer!(NUM_PIXELS);
|
||||||
|
|
||||||
//let target = SmartLedsAdapterAsync::new(rmt_channel, gpio, rmt_buffer);
|
let target = SmartLedsAdapterAsync::new_with_color(rmt_channel, gpio, &mut rmt_buffer);
|
||||||
let target = SmartLedsAdapterAsync::new(rmt_channel, gpio, rmt_buffer);
|
|
||||||
|
|
||||||
// Change this to adjust the power available; the USB spec says 500ma is the standard limit, but sometimes you can draw more from a power brick
|
// Change this to adjust the power available; the USB spec says 500ma is the standard limit, but sometimes you can draw more from a power brick
|
||||||
const POWER_MA : u32 = 500;
|
const POWER_MA : u32 = 500;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::pubsub::DynSubscriber;
|
use embassy_sync::pubsub::DynSubscriber;
|
||||||
use esp_wifi::{EspWifiController, wifi::{ClientConfiguration, WifiDevice}};
|
use esp_radio::Controller;
|
||||||
|
use esp_radio::wifi::{ClientConfig, WifiDevice};
|
||||||
use log::*;
|
use log::*;
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
|
||||||
@@ -24,19 +25,17 @@ static RESOURCES: StaticCell<StackResources<5>> = StaticCell::new();
|
|||||||
|
|
||||||
// TODO: Wifi task needs to know when there is data to upload, so it only connects when needed.
|
// TODO: Wifi task needs to know when there is data to upload, so it only connects when needed.
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wifi_init: &'static mut EspWifiController<'static>, wifi_device: esp_hal::peripherals::WIFI<'static>) {
|
pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wifi_init: &'static mut Controller<'static>, wifi_device: esp_hal::peripherals::WIFI<'static>) {
|
||||||
let (mut wifi, interfaces) = esp_wifi::wifi::new(wifi_init, wifi_device)
|
let (mut wifi, interfaces) = esp_radio::wifi::new(wifi_init, wifi_device, esp_radio::wifi::Config::default())
|
||||||
.expect("Failed to initialize WIFI!");
|
.expect("Failed to initialize WIFI!");
|
||||||
wifi.set_configuration(&esp_wifi::wifi::Configuration::Client(
|
wifi.set_config(&esp_radio::wifi::ModeConfig::Client(
|
||||||
ClientConfiguration {
|
ClientConfig::default()
|
||||||
ssid: "The Frequency".to_string(),
|
.with_ssid("The Frequencey".to_string())
|
||||||
auth_method: esp_wifi::wifi::AuthMethod::WPA2Personal,
|
.with_auth_method(esp_radio::wifi::AuthMethod::Wpa2Personal)
|
||||||
password: "thepasswordkenneth".to_string(),
|
.with_password("thepasswordkenneth".to_string())
|
||||||
..Default::default()
|
|
||||||
}
|
|
||||||
)).unwrap();
|
)).unwrap();
|
||||||
wifi.set_mode(esp_wifi::wifi::WifiMode::Sta).unwrap();
|
wifi.set_mode(esp_radio::wifi::WifiMode::Sta).unwrap();
|
||||||
wifi.set_power_saving(esp_wifi::config::PowerSaveMode::Maximum).unwrap();
|
wifi.set_power_saving(esp_radio::wifi::PowerSaveMode::Maximum).unwrap();
|
||||||
wifi.start_async().await.unwrap();
|
wifi.start_async().await.unwrap();
|
||||||
|
|
||||||
let device = interfaces.sta;
|
let device = interfaces.sta;
|
||||||
@@ -46,7 +45,7 @@ pub async fn wireless_task(mut telemetry: DynSubscriber<'static, Telemetry>, wif
|
|||||||
let config = Config::dhcpv4(Default::default());
|
let config = Config::dhcpv4(Default::default());
|
||||||
let (stack, runner) = embassy_net::new(device, config, RESOURCES.init_with(|| { StackResources::new() }), seed as u64);
|
let (stack, runner) = embassy_net::new(device, config, RESOURCES.init_with(|| { StackResources::new() }), seed as u64);
|
||||||
info!("Launching network task");
|
info!("Launching network task");
|
||||||
Spawner::for_current_executor().await.must_spawn(net_task(runner));
|
unsafe { Spawner::for_current_executor().await }.must_spawn(net_task(runner));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
Backoff::from_secs(3).forever().attempt(async || {
|
Backoff::from_secs(3).forever().attempt(async || {
|
||||||
|
|||||||
Reference in New Issue
Block a user