better clear bin

This commit is contained in:
Evan Feenstra
2023-04-21 14:08:58 +02:00
parent dc468b4f30
commit 2b36dec22d
3 changed files with 38 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ A Lightning Hardware Wallet based on [Validating Lightning Signer](https://gitla
Find your port (`ls /dev/tty.*`) Find your port (`ls /dev/tty.*`)
`PORT=/dev/tty.usbserial-1420` `PORT=/dev/tty.usbserial-1410`
`espflash $PORT target/riscv32imc-esp-espidf/release/sphinx-key-factory` `espflash $PORT target/riscv32imc-esp-espidf/release/sphinx-key-factory`

View File

@@ -1,9 +1,22 @@
mod conn;
mod core;
mod ota;
mod periph;
#[allow(unused_imports)]
use crate::periph::sd::mount_sd_card;
use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
// use embedded_svc::storage::StorageBase; // use embedded_svc::storage::StorageBase;
use esp_idf_svc::nvs::EspNvs; use esp_idf_svc::nvs::EspNvs;
use esp_idf_svc::nvs::*; use esp_idf_svc::nvs::*;
use std::fs;
use std::path::Path;
pub const ROOT_STORE: &str = "/sdcard/store";
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
// NvsDefault::new(); // NvsDefault::new();
let default_nvs = EspDefaultNvsPartition::take()?; let default_nvs = EspDefaultNvsPartition::take()?;
@@ -13,5 +26,28 @@ fn main() -> anyhow::Result<()> {
store.remove("nonce").expect("couldnt remove nonce 1"); store.remove("nonce").expect("couldnt remove nonce 1");
store.remove("policy").expect("couldnt remove policy 1"); store.remove("policy").expect("couldnt remove policy 1");
println!("NVS cleared!"); println!("NVS cleared!");
println!("About to mount the sdcard...");
while let Err(_e) = mount_sd_card() {
println!("Failed to mount sd card. Make sure it is connected, trying again...");
std::thread::sleep(std::time::Duration::from_secs(5));
}
println!("SD card mounted!");
let dir = Path::new(ROOT_STORE);
println!("root store is dir {}", dir.is_dir());
if dir.is_dir() {
for entry in fs::read_dir(dir)? {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
println!("PATH {}", path.display());
if let Err(e) = fs::remove_dir_all(path) {
println!("err removing dir");
}
}
}
}
Ok(()) Ok(())
} }

View File

@@ -13,7 +13,7 @@ use log::*;
use std::sync::mpsc; use std::sync::mpsc;
use std::thread; use std::thread;
pub const QOS: QoS = QoS::ExactlyOnce; pub const QOS: QoS = QoS::AtMostOnce;
pub fn make_client( pub fn make_client(
broker: &str, broker: &str,