-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b3a177
commit cefa760
Showing
7 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod spiflash; | ||
pub mod traits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use anyhow::{bail, Context}; | ||
use esp_idf_svc::partition::{EspPartition, EspWlPartition}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct SPIFlashConfig { | ||
pub partition_label: String, | ||
pub mount_path: String, | ||
} | ||
|
||
pub struct SPIFlashStorage { | ||
config: SPIFlashConfig, | ||
wl_partition: Option<EspWlPartition<EspPartition>>, | ||
} | ||
|
||
impl SPIFlashStorage { | ||
pub fn new(config: &SPIFlashConfig) -> Self { | ||
Self { | ||
config: config.clone(), | ||
wl_partition: None, | ||
} | ||
} | ||
|
||
pub fn install(&mut self) -> anyhow::Result<()> { | ||
if self.wl_partition.is_some() { | ||
bail!("Already installed"); | ||
} | ||
let partition = Some( | ||
unsafe { EspPartition::new(&self.config.partition_label) }?.ok_or_else(|| { | ||
anyhow::anyhow!( | ||
"Failed to find partition with label {:#?}", | ||
self.config.partition_label | ||
) | ||
})?, | ||
); | ||
self.wl_partition = Some(EspWlPartition::new(partition.unwrap()).with_context(|| { | ||
format!( | ||
"Failed to mount partition {} at {}", | ||
self.config.partition_label, self.config.mount_path | ||
) | ||
})?); | ||
log::info!( | ||
"Mount SPI Flash storage with label {} at {}", | ||
self.config.partition_label, | ||
self.config.mount_path | ||
); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub trait Storage {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub mod msc_device; | ||
pub mod msc_device; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters