Skip to content

Commit

Permalink
Do not erase the flash to reset the storage on Nordic (google#337)
Browse files Browse the repository at this point in the history
Otherwise the UICR registers are also reset which, among others, resets
the PSELRESET registers that permits resetting the dev-board from the
reset button.
  • Loading branch information
ia0 authored Dec 20, 2023
1 parent 42ded96 commit f6711f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/runner-nordic/memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ __flash_origin = __header_origin + __header_length;
__flash_length = 0x00070000 - __header_length;
__sother = 0x00010000 + (1 - RUNNER_SIDE) * 0x00070000;
__eother = __sother + 0x00070000;
/* Keep those values in sync with --reset-storage in xtask */
__sstore = 0x000f0000;
__estore = 0x00100000;

Expand Down
13 changes: 7 additions & 6 deletions crates/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ struct RunnerOptions {
#[clap(long)]
bundle: bool,

/// Erases all the flash first.
/// Resets the persistent storage before running.
#[clap(long)]
erase_flash: bool,
reset_storage: bool,

/// Prints the command lines to use GDB.
#[clap(long)]
Expand Down Expand Up @@ -551,7 +551,7 @@ impl RunnerOptions {
fs::touch("target/wasefire/applet.wasm")?;
if run && self.name == "host" {
let path = "target/wasefire/storage.bin";
if self.erase_flash && fs::exists(path) {
if self.reset_storage && fs::exists(path) {
fs::remove_file(path)?;
}
replace_command(cargo);
Expand Down Expand Up @@ -635,9 +635,10 @@ impl RunnerOptions {
Permissions::default(),
)?)
});
if self.erase_flash {
println!("Erasing the flash of {}", session.get()?.target().name);
flashing::erase_all(session.get()?, None)?;
if self.reset_storage {
println!("Erasing the persistent storage.");
// Keep those values in sync with crates/runner-nordic/memory.x.
flashing::erase_sectors(session.get()?, None, 240, 16)?;
}
if self.name == "nordic" {
let mut cargo = Command::new("cargo");
Expand Down

0 comments on commit f6711f2

Please sign in to comment.