main: add a dual-core feature flag, to switch between configs while debugging deadlocks
This commit is contained in:
@@ -12,6 +12,7 @@ path = "./src/bin/main.rs"
|
||||
[features]
|
||||
default = ["real-output"]
|
||||
real-output = []
|
||||
dual-core = []
|
||||
simulation = ["dep:rmp"]
|
||||
radio = [
|
||||
"dep:bleps",
|
||||
|
||||
@@ -63,13 +63,6 @@ async fn main(spawner: Spawner) {
|
||||
esp_rtos::start(sys_timer.alarm0);
|
||||
info!("Embassy initialized!");
|
||||
|
||||
let timer0 = TimerGroup::new(peripherals.TIMG0);
|
||||
|
||||
let timer1 = TimerGroup::new(peripherals.TIMG1);
|
||||
let mut ui_wdt = timer1.wdt;
|
||||
ui_wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(10));
|
||||
ui_wdt.enable();
|
||||
|
||||
static MOTION_BUS: StaticCell<Channel<CriticalSectionRawMutex,Measurement,5> > = StaticCell::new();
|
||||
let motion_bus = MOTION_BUS.init_with(|| { Channel::new() });
|
||||
|
||||
@@ -87,13 +80,15 @@ async fn main(spawner: Spawner) {
|
||||
let mut safety_surfaces = UiSurfacePool::default();
|
||||
let safety_ui = SafetyUi::new(&mut safety_surfaces, display_controls.clone());
|
||||
|
||||
let timer0 = TimerGroup::new(peripherals.TIMG0);
|
||||
let mut wdt = timer0.wdt;
|
||||
wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(5));
|
||||
wdt.enable();
|
||||
|
||||
let swi = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
|
||||
let hi_exec = STATIC_HI_EXEC.init(InterruptExecutor::new(swi.software_interrupt2));
|
||||
let hi_spawn = hi_exec.start(esp_hal::interrupt::Priority::max());
|
||||
|
||||
//wdt.enable();
|
||||
hi_spawn.must_spawn(renderbug_embassy::tasks::render::render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, safety_surfaces, display_controls, wdt));
|
||||
|
||||
#[cfg(feature="motion")]
|
||||
@@ -148,15 +143,12 @@ async fn main(spawner: Spawner) {
|
||||
#[cfg(feature="radio")]
|
||||
let wifi_init = {
|
||||
info!("Configuring wifi");
|
||||
//let rng = esp_hal::rng::Rng::new(peripherals.RNG);
|
||||
WIFI_INIT.init_with(|| {esp_radio::init().expect("Failed to initialize radio controller")})
|
||||
};
|
||||
|
||||
info!("Starting core 2");
|
||||
//let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL);
|
||||
esp_rtos::start_second_core(peripherals.CPU_CTRL, swi.software_interrupt0, swi.software_interrupt1, unsafe { &mut *addr_of_mut!(CORE2_STACK) }, || {
|
||||
let exec = CORE2_EXEC.init_with(|| { Executor::new() });
|
||||
exec.run(|spawner| {
|
||||
|
||||
let core2_main = |spawner: Spawner| {
|
||||
let garage = BUS_GARAGE.init_with(|| { Default::default() });
|
||||
|
||||
info!("Launching motion engine");
|
||||
@@ -181,12 +173,28 @@ async fn main(spawner: Spawner) {
|
||||
spawner.must_spawn(renderbug_embassy::tasks::demo::demo_task(garage.notify.dyn_publisher().unwrap()));
|
||||
}
|
||||
|
||||
#[cfg(feature="dual-core")]
|
||||
{
|
||||
info!("Launching core 2 watchdog");
|
||||
let timer1 = TimerGroup::new(peripherals.TIMG1);
|
||||
let mut ui_wdt = timer1.wdt;
|
||||
ui_wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(10));
|
||||
#[cfg(feature="dual-core")]
|
||||
ui_wdt.enable();
|
||||
spawner.must_spawn(wdt_task(ui_wdt));
|
||||
}
|
||||
|
||||
info!("System is ready in {}ms", Instant::now().as_millis());
|
||||
};
|
||||
|
||||
#[cfg(feature="dual-core")]
|
||||
esp_rtos::start_second_core(peripherals.CPU_CTRL, swi.software_interrupt0, swi.software_interrupt1, unsafe { &mut *addr_of_mut!(CORE2_STACK) }, || {
|
||||
let exec = CORE2_EXEC.init_with(|| { Executor::new() });
|
||||
exec.run(core2_main);
|
||||
});
|
||||
});
|
||||
|
||||
#[cfg(not(feature="dual-core"))]
|
||||
core2_main(spawner);
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
|
||||
Reference in New Issue
Block a user