Skip to content

Commit f6711f2

Browse files
authored
Do not erase the flash to reset the storage on Nordic (google#337)
Otherwise the UICR registers are also reset which, among others, resets the PSELRESET registers that permits resetting the dev-board from the reset button.
1 parent 42ded96 commit f6711f2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

crates/runner-nordic/memory.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ __flash_origin = __header_origin + __header_length;
2121
__flash_length = 0x00070000 - __header_length;
2222
__sother = 0x00010000 + (1 - RUNNER_SIDE) * 0x00070000;
2323
__eother = __sother + 0x00070000;
24+
/* Keep those values in sync with --reset-storage in xtask */
2425
__sstore = 0x000f0000;
2526
__estore = 0x00100000;
2627

crates/xtask/src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ struct RunnerOptions {
180180
#[clap(long)]
181181
bundle: bool,
182182

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

187187
/// Prints the command lines to use GDB.
188188
#[clap(long)]
@@ -551,7 +551,7 @@ impl RunnerOptions {
551551
fs::touch("target/wasefire/applet.wasm")?;
552552
if run && self.name == "host" {
553553
let path = "target/wasefire/storage.bin";
554-
if self.erase_flash && fs::exists(path) {
554+
if self.reset_storage && fs::exists(path) {
555555
fs::remove_file(path)?;
556556
}
557557
replace_command(cargo);
@@ -635,9 +635,10 @@ impl RunnerOptions {
635635
Permissions::default(),
636636
)?)
637637
});
638-
if self.erase_flash {
639-
println!("Erasing the flash of {}", session.get()?.target().name);
640-
flashing::erase_all(session.get()?, None)?;
638+
if self.reset_storage {
639+
println!("Erasing the persistent storage.");
640+
// Keep those values in sync with crates/runner-nordic/memory.x.
641+
flashing::erase_sectors(session.get()?, None, 240, 16)?;
641642
}
642643
if self.name == "nordic" {
643644
let mut cargo = Command::new("cargo");

0 commit comments

Comments
 (0)