tasks: simulation: move sim data into a separate partition for flashing

This commit is contained in:
2025-11-05 11:56:10 +01:00
parent 4776227793
commit 41f69833e5
3 changed files with 138 additions and 9 deletions

View File

@@ -123,8 +123,21 @@ async fn main(spawner: Spawner) {
#[cfg(feature="simulation")]
{
spawner.must_spawn(renderbug_embassy::tasks::simulation::motion_simulation_task(garage.motion.dyn_sender()));
spawner.must_spawn(renderbug_embassy::tasks::simulation::location_simulation_task(garage.motion.dyn_sender()));
use core::{cell::RefCell, ops::DerefMut};
use alloc::rc::Rc;
use esp_storage::FlashStorage;
let storage = Rc::new(RefCell::new(FlashStorage::new()));
let mut buf = [8; 1024];
let partitions = esp_bootloader_esp_idf::partitions::read_partition_table(storage.borrow_mut().deref_mut(), &mut buf).unwrap();
let data_partition = partitions.find_partition(
esp_bootloader_esp_idf::partitions::PartitionType::Data(
esp_bootloader_esp_idf::partitions::DataPartitionSubType::Undefined
)).expect("Unable to read partition table").expect("Could not find data partition!");
let data_offset = data_partition.offset() as usize;
info!("Loading simulation data starting at {data_offset:#02x}");
spawner.must_spawn(renderbug_embassy::tasks::simulation::motion_simulation_task(Rc::clone(&storage), data_offset, garage.motion.dyn_sender()));
spawner.must_spawn(renderbug_embassy::tasks::simulation::location_simulation_task(storage, data_offset, garage.motion.dyn_sender()));
}
info!("Launching motion engine");