wip
This commit is contained in:
Generated
+25
-1
@@ -359,6 +359,7 @@ dependencies = [
|
|||||||
"embedded-storage",
|
"embedded-storage",
|
||||||
"embedded-text",
|
"embedded-text",
|
||||||
"esp-alloc",
|
"esp-alloc",
|
||||||
|
"esp-backtrace",
|
||||||
"esp-bootloader-esp-idf",
|
"esp-bootloader-esp-idf",
|
||||||
"esp-hal",
|
"esp-hal",
|
||||||
"esp-hal-wifimanager",
|
"esp-hal-wifimanager",
|
||||||
@@ -1099,6 +1100,23 @@ dependencies = [
|
|||||||
"rlsf",
|
"rlsf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "esp-backtrace"
|
||||||
|
version = "0.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37950e24b2dfd98f1581102d1798281d4d9547af881e6bffc2c2b534c026ec8f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"document-features",
|
||||||
|
"esp-config",
|
||||||
|
"esp-metadata-generated",
|
||||||
|
"esp-println",
|
||||||
|
"heapless 0.9.3",
|
||||||
|
"riscv",
|
||||||
|
"semihosting",
|
||||||
|
"xtensa-lx",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "esp-bootloader-esp-idf"
|
name = "esp-bootloader-esp-idf"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@@ -1231,7 +1249,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "esp-hal-wifimanager"
|
name = "esp-hal-wifimanager"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
source = "git+https://github.com/rhetenor/esp-hal-wifimanager.git#c35c2b35c9c4b724138f2c62a8aed9adf6365a7f"
|
source = "git+https://github.com/rhetenor/esp-hal-wifimanager.git#c1a7c80e870070c74c1f116b4cae5df29c597537"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"embassy-executor",
|
"embassy-executor",
|
||||||
"embassy-futures",
|
"embassy-futures",
|
||||||
@@ -3026,6 +3044,12 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813"
|
checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semihosting"
|
||||||
|
version = "0.1.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f8e4abf97879f4e80db69a9fba7bd64998e9bdad25f58ef045a778e191172fd4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "seq-macro"
|
name = "seq-macro"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ binary_serde = "1.0.25"
|
|||||||
static_assertions = { version = "1.1.0", default-features = false }
|
static_assertions = { version = "1.1.0", default-features = false }
|
||||||
embedded-text = "0.7.3"
|
embedded-text = "0.7.3"
|
||||||
esp-nvs = { version = "0.5.0", features = ["esp32s3"] }
|
esp-nvs = { version = "0.5.0", features = ["esp32s3"] }
|
||||||
|
esp-backtrace = { version = "0.19.0", features = ["esp32s3", "panic-handler", "println"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
|||||||
+2
-7
@@ -1,9 +1,4 @@
|
|||||||
# ESP-IDF Partition Table
|
# ESP-IDF Partition Table
|
||||||
# Name,Type,SubType,Offset,Size,Flags
|
# Name,Type,SubType,Offset,Size,Flags
|
||||||
nvs,data,nvs,0x9000,0x6000,
|
nvs,data,nvs,0x9000,0xa00000,
|
||||||
phy_init,data,phy,0xf000,0x1000,
|
factory,app,factory,0xa10000,0x200000,
|
||||||
# We keep the default layout more or less. But here we add a partition for more data before our application
|
|
||||||
more_nvs,data,nvs,0x10000,0xfa000,
|
|
||||||
# no offset given -> tool infers it for us
|
|
||||||
factory,app,factory, ,0xea6000,
|
|
||||||
|
|
||||||
|
|||||||
|
@@ -1,6 +1,7 @@
|
|||||||
use crate::navigation::navigation::display_error;
|
use crate::navigation::navigation::display_error;
|
||||||
use crate::{
|
use crate::{
|
||||||
navigation::{navigation::Mutex, outputs::Outputs, state::NavigationState},
|
Mutex,
|
||||||
|
navigation::{outputs::Outputs, state::NavigationState},
|
||||||
peripherals::Peripherals,
|
peripherals::Peripherals,
|
||||||
};
|
};
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|||||||
+5
-10
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
use creaturedex::Mutex;
|
||||||
use creaturedex::background_tasks;
|
use creaturedex::background_tasks;
|
||||||
use creaturedex::drivers::i2c_bus::I2cBusPinConfiguration;
|
use creaturedex::drivers::i2c_bus::I2cBusPinConfiguration;
|
||||||
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
use creaturedex::drivers::nfc_pn532::NfcPn532Driver;
|
||||||
@@ -19,7 +20,6 @@ use creaturedex::drivers::tertiary_lcd::{
|
|||||||
BOX, EMPTY, EXAMPLE, HEART, TertiaryDisplay, TertiaryDisplayPinConfiguration,
|
BOX, EMPTY, EXAMPLE, HEART, TertiaryDisplay, TertiaryDisplayPinConfiguration,
|
||||||
};
|
};
|
||||||
use creaturedex::navigation::inputs::Inputs;
|
use creaturedex::navigation::inputs::Inputs;
|
||||||
use creaturedex::navigation::navigation::Mutex;
|
|
||||||
use creaturedex::navigation::navigation::{self};
|
use creaturedex::navigation::navigation::{self};
|
||||||
use creaturedex::navigation::outputs::Outputs;
|
use creaturedex::navigation::outputs::Outputs;
|
||||||
use creaturedex::navigation::state::NavigationState;
|
use creaturedex::navigation::state::NavigationState;
|
||||||
@@ -40,20 +40,15 @@ use esp_hal::gpio::{Input, InputConfig, Pull};
|
|||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
|
use esp_backtrace as _;
|
||||||
use esp_hal::rtc_cntl::Rtc;
|
use esp_hal::rtc_cntl::Rtc;
|
||||||
|
|
||||||
#[panic_handler]
|
|
||||||
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
|
||||||
error!("{}", panic_info);
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
const HEAP_SIZE: usize = 73744;
|
const HEAP_SIZE: usize = 73744;
|
||||||
|
|
||||||
const NVS_PARTITION_OFFSET: usize = 0x10000;
|
const NVS_PARTITION_OFFSET: usize = 0x9000;
|
||||||
const NVS_PARTITION_SIZE: usize = 0xfa000;
|
const NVS_PARTITION_SIZE: usize = 0xa0000;
|
||||||
|
|
||||||
// This creates a default app-descriptor required by the esp-idf bootloader.
|
// This creates a default app-descriptor required by the esp-idf bootloader.
|
||||||
// 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>
|
||||||
@@ -133,7 +128,7 @@ async fn main(spawner: Spawner) {
|
|||||||
.expect("failed to create nvs"),
|
.expect("failed to create nvs"),
|
||||||
));
|
));
|
||||||
|
|
||||||
setup_wifi(esp_peripherals.WIFI, Arc::clone(&nvs), &spawner).await;
|
//setup_wifi(esp_peripherals.WIFI, Arc::clone(&nvs), &spawner).await;
|
||||||
|
|
||||||
let card_store = CardStore::new(nvs)
|
let card_store = CardStore::new(nvs)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(vec_into_chunks)]
|
#![feature(vec_into_chunks)]
|
||||||
|
|
||||||
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
pub mod background_tasks;
|
pub mod background_tasks;
|
||||||
@@ -13,6 +15,9 @@ pub mod network;
|
|||||||
pub mod peripherals;
|
pub mod peripherals;
|
||||||
pub mod views;
|
pub mod views;
|
||||||
|
|
||||||
|
pub type Mutex<T> = embassy_sync::mutex::Mutex<CriticalSectionRawMutex, T>;
|
||||||
|
pub type Signal<T> = embassy_sync::signal::Signal<CriticalSectionRawMutex, T>;
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "Rust" fn _embassy_trace_poll_start(executor_id: u32) {}
|
pub extern "Rust" fn _embassy_trace_poll_start(executor_id: u32) {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::Mutex;
|
||||||
use crate::card::model::Card;
|
use crate::card::model::Card;
|
||||||
use crate::navigation::inputs::ButtonAction;
|
use crate::navigation::inputs::ButtonAction;
|
||||||
use crate::navigation::inputs::Inputs;
|
use crate::navigation::inputs::Inputs;
|
||||||
@@ -12,11 +13,8 @@ use alloc::string::ToString;
|
|||||||
use core::error;
|
use core::error;
|
||||||
|
|
||||||
use embassy_futures::select::{Either, select};
|
use embassy_futures::select::{Either, select};
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
|
|
||||||
pub type Mutex<T> = embassy_sync::mutex::Mutex<CriticalSectionRawMutex, T>;
|
|
||||||
pub type Signal<T> = embassy_sync::signal::Signal<CriticalSectionRawMutex, T>;
|
|
||||||
pub static CARD_DATA: Mutex<Option<Card>> = Mutex::new(None);
|
pub static CARD_DATA: Mutex<Option<Card>> = Mutex::new(None);
|
||||||
const DEBOUNCE_DURATION_MILLIS: u64 = 100;
|
const DEBOUNCE_DURATION_MILLIS: u64 = 100;
|
||||||
|
|
||||||
|
|||||||
+64
-18
@@ -1,33 +1,80 @@
|
|||||||
use crate::navigation::navigation::Mutex;
|
use crate::Signal;
|
||||||
|
use crate::alloc::string::ToString;
|
||||||
use crate::peripherals::storage::Nvs;
|
use crate::peripherals::storage::Nvs;
|
||||||
|
use alloc::string::String;
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
use core::error::Error;
|
||||||
|
use core::fmt::Display;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
|
use esp_nvs::Key;
|
||||||
|
|
||||||
|
struct WifiCredentials {
|
||||||
|
ssid: String,
|
||||||
|
pass: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub static WIFI_CREDENTIALS: Signal<WifiCredentials> = Signal::new();
|
||||||
|
|
||||||
|
const WIFI_NAMESPACE: Key = Key::from_str("WIFI");
|
||||||
|
const WIFI_INIT_KEY: Key = Key::from_str("INIT");
|
||||||
|
const WIFI_SSID_KEY: Key = Key::from_str("SSID");
|
||||||
|
const WIFI_PASSWORD_KEY: Key = Key::from_str("PASSWORD");
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum WifiError {
|
||||||
|
Store(esp_nvs::error::Error),
|
||||||
|
NoEntry(u32),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for WifiError {}
|
||||||
|
|
||||||
|
impl Display for WifiError {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
match self {
|
||||||
|
WifiError::Store(e) => e.fmt(f),
|
||||||
|
WifiError::NoEntry(uuid) => write!(f, "No Card Entry\nuuid: 0x{uuid:x}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<esp_nvs::error::Error> for WifiError {
|
||||||
|
fn from(error: esp_nvs::error::Error) -> WifiError {
|
||||||
|
WifiError::Store(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "wokwi"))]
|
#[cfg(not(feature = "wokwi"))]
|
||||||
pub async fn setup_wifi(
|
pub async fn setup_wifi(
|
||||||
wifi: esp_hal::peripherals::WIFI<'static>,
|
wifi: esp_hal::peripherals::WIFI<'static>,
|
||||||
nvs: Arc<Mutex<Nvs>>,
|
nvs: Arc<Mutex<Nvs>>,
|
||||||
spawner: &Spawner,
|
spawner: &Spawner,
|
||||||
) {
|
) -> Result<(), WifiError> {
|
||||||
let espnvs = esp_hal_wifimanager::Nvs::new_from_nvs(nvs, 0, 0);
|
nvs.lock()
|
||||||
|
.await
|
||||||
|
.set::<bool>(&WIFI_NAMESPACE, &WIFI_INIT_KEY, true)?;
|
||||||
|
|
||||||
let mut wm_settings = esp_hal_wifimanager::WmSettings::default();
|
let wifi_ssid = match option_env!("WIFI_SSID") {
|
||||||
|
Some(ssid) => ssid.to_string(),
|
||||||
|
|
||||||
wm_settings.ssid.clear();
|
None => match nvs
|
||||||
_ = core::fmt::write(
|
.lock()
|
||||||
&mut wm_settings.ssid,
|
.await
|
||||||
format_args!("CreatureDex-{:X}", esp_hal_wifimanager::get_efuse_mac()),
|
.get::<String>(&WIFI_NAMESPACE, &WIFI_SSID_KEY)
|
||||||
);
|
{
|
||||||
|
Ok(ssid) => ssid,
|
||||||
wm_settings.wifi_conn_timeout = 30000;
|
Err(esp_nvs::error::Error::KeyNotFound) => "asdf".to_string(),
|
||||||
wm_settings.esp_reset_timeout = Some(300000); // 5min
|
Err(err) => return Err(err.into()),
|
||||||
|
},
|
||||||
let wifi_res =
|
};
|
||||||
esp_hal_wifimanager::init_wm(wm_settings, spawner, Some(&espnvs), wifi, None).await;
|
Ok(())
|
||||||
|
|
||||||
log::info!("wifi_res: {wifi_res:?}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_wifi_credentials() {
|
||||||
|
log::info!("Waiting for new WiFi credentials");
|
||||||
|
WIFI_CREDENTIALS.wait().await;
|
||||||
|
log::info!("Received new WiFi credentials. Saving...");
|
||||||
|
log::info!("Saved new WiFi credentials. Restarting WiFi");
|
||||||
|
}
|
||||||
#[cfg(feature = "wokwi")]
|
#[cfg(feature = "wokwi")]
|
||||||
pub async fn setup_wifi(
|
pub async fn setup_wifi(
|
||||||
wifi: esp_hal::peripherals::WIFI<'static>,
|
wifi: esp_hal::peripherals::WIFI<'static>,
|
||||||
@@ -36,7 +83,6 @@ pub async fn setup_wifi(
|
|||||||
) {
|
) {
|
||||||
log::info!("Wokwi mode active: pre-seeding WiFi Manager with Wokwi credentials");
|
log::info!("Wokwi mode active: pre-seeding WiFi Manager with Wokwi credentials");
|
||||||
|
|
||||||
use esp_nvs::Key;
|
|
||||||
const WIFIMANAGER_NAMESPACE: Key = Key::from_str("wifimanager");
|
const WIFIMANAGER_NAMESPACE: Key = Key::from_str("wifimanager");
|
||||||
const WIFIMANAGER_NVS_KEY: Key = Key::from_str("WIFI_SETUP");
|
const WIFIMANAGER_NVS_KEY: Key = Key::from_str("WIFI_SETUP");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
pub mod storage;
|
pub mod storage;
|
||||||
|
|
||||||
use crate::navigation::navigation::Mutex;
|
use crate::Mutex;
|
||||||
use crate::peripherals::storage::store::Store;
|
use crate::peripherals::storage::store::Store;
|
||||||
|
|
||||||
use esp_hal::rtc_cntl::Rtc;
|
use esp_hal::rtc_cntl::Rtc;
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
use core::error::Error;
|
|
||||||
use core::fmt::Display;
|
|
||||||
|
|
||||||
use crate::navigation::navigation::Mutex;
|
|
||||||
use embedded_storage::nor_flash::NorFlash;
|
|
||||||
use embedded_storage::nor_flash::ReadNorFlash;
|
|
||||||
use esp_storage::{FlashStorage, FlashStorageError};
|
|
||||||
|
|
||||||
use crate::peripherals::storage::MAGIC_REGION;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct FlashStoreError(FlashStorageError);
|
|
||||||
|
|
||||||
impl From<FlashStorageError> for FlashStoreError {
|
|
||||||
fn from(value: FlashStorageError) -> Self {
|
|
||||||
Self(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error for FlashStoreError {}
|
|
||||||
|
|
||||||
impl Display for FlashStoreError {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
write!(f, "FlashStoreError:\n{:?}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const FLASH_ADDR: u32 = 0x200000;
|
|
||||||
|
|
||||||
const INITIALIZATION_SIZE: usize = 0x1000;
|
|
||||||
const FLASH_INITIALIZE_MAGIC: u32 = 0xde6de6de;
|
|
||||||
|
|
||||||
pub struct FlashStore {
|
|
||||||
pub storage: Mutex<FlashStorage<'static>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FlashStore {
|
|
||||||
pub fn new(flash: esp_hal::peripherals::FLASH<'static>) -> Result<Self, FlashStoreError> {
|
|
||||||
let mut storage = FlashStorage::new(flash);
|
|
||||||
|
|
||||||
let mut magic: [u8; 4] = [0, 0, 0, 0];
|
|
||||||
storage.read(FLASH_ADDR + MAGIC_REGION.offset, &mut magic)?;
|
|
||||||
log::debug!("Magic bytes are {magic:?}");
|
|
||||||
|
|
||||||
if Self::has_magic_bytes(&mut storage)? {
|
|
||||||
log::info!("Skipped flash initialization, magic bytes already present.");
|
|
||||||
} else {
|
|
||||||
log::info!("Initializing flash because no magic bytes found.");
|
|
||||||
Self::initialize_flash(&mut storage)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self {
|
|
||||||
storage: Mutex::new(storage),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn read(&self, offset: u32, bytes: &mut [u8]) -> Result<(), FlashStoreError> {
|
|
||||||
self.storage.lock().await.read(FLASH_ADDR + offset, bytes)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn write(&self, offset: u32, bytes: &mut [u8]) -> Result<(), FlashStoreError> {
|
|
||||||
log::debug!("Writing {} bytes at offset 0x{offset:08x}", bytes.len());
|
|
||||||
self.storage
|
|
||||||
.lock()
|
|
||||||
.await
|
|
||||||
.write(FLASH_ADDR + offset, bytes)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn write_erase(&self, offset: u32, bytes: &mut [u8]) -> Result<(), FlashStoreError> {
|
|
||||||
log::debug!(
|
|
||||||
"Erasing and Writing {} bytes at offset 0x{offset:08x}",
|
|
||||||
bytes.len()
|
|
||||||
);
|
|
||||||
let mut lock = self.storage.lock().await;
|
|
||||||
let addr = FLASH_ADDR + offset;
|
|
||||||
let to = FLASH_ADDR + offset + bytes.len() as u32;
|
|
||||||
log::debug!("Erasing from 0x{addr:x} to 0x{to:x}");
|
|
||||||
//lock.erase(addr, to)?;
|
|
||||||
|
|
||||||
log::debug!("Writing bytes...");
|
|
||||||
lock.write(addr, bytes)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn has_magic_bytes(storage: &mut FlashStorage) -> Result<bool, FlashStoreError> {
|
|
||||||
let mut magic: [u8; 4] = [0, 0, 0, 0];
|
|
||||||
storage.read(FLASH_ADDR + MAGIC_REGION.offset, &mut magic)?;
|
|
||||||
log::debug!("Magic bytes are {magic:?}");
|
|
||||||
|
|
||||||
Ok(u32::from_ne_bytes(magic) == FLASH_INITIALIZE_MAGIC)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn initialize_flash(storage: &mut FlashStorage) -> Result<(), FlashStoreError> {
|
|
||||||
storage.erase(FLASH_ADDR, FLASH_ADDR + INITIALIZATION_SIZE as u32)?;
|
|
||||||
let zeros: [u8; INITIALIZATION_SIZE] = [0; INITIALIZATION_SIZE];
|
|
||||||
storage.write(FLASH_ADDR + MAGIC_REGION.end() as u32, &zeros)?;
|
|
||||||
storage.write(
|
|
||||||
FLASH_ADDR + MAGIC_REGION.offset,
|
|
||||||
&FLASH_INITIALIZE_MAGIC.to_ne_bytes(),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if Self::has_magic_bytes(storage)? {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(FlashStoreError(FlashStorageError::Other(
|
|
||||||
FLASH_INITIALIZE_MAGIC as i32,
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+5
-4
@@ -1,9 +1,10 @@
|
|||||||
[wokwi]
|
[wokwi]
|
||||||
version = 1
|
version = 1
|
||||||
gdbServerPort = 3333
|
gdbServerPort = 3333
|
||||||
elf = "target/xtensa-esp32s3-none-elf/debug/creaturedex"
|
elf = "target/xtensa-esp32s3-none-elf/release/creaturedex"
|
||||||
firmware = "target/xtensa-esp32s3-none-elf/debug/creaturedex"
|
firmware = "target/xtensa-esp32s3-none-elf/release/creaturedex"
|
||||||
|
|
||||||
[[chip]]
|
[[chip]]
|
||||||
name = 'ch1115'
|
name = 'ch1115'
|
||||||
binary = 'wokwi/ch1115.chip.wasm'
|
binary = 'wokwi/ch1115.chip.wasm'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user