Skip to content

Commit 20452d5

Browse files
committed
refactor: remove unnecesary code
Signed-off-by: addrian-77 <lunguadrian30@gmail.com>
1 parent f68de5d commit 20452d5

1 file changed

Lines changed: 2 additions & 31 deletions

File tree

tockloader-lib/src/command_impl/probers/erase_apps.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,11 @@ impl CommandEraseApps for ProbeRSConnection {
1616
}
1717
let session = self.session.as_mut().expect("Board must be open");
1818

19-
let mut appaddr: u64 = settings.start_address;
20-
// All applications are stored sequentially in memory, so we read until
21-
// we fail to parse.
22-
let mut total_size: u32 = 0;
23-
loop {
24-
let mut board_core = session.core(self.target_info.core)?;
25-
let mut appdata = vec![0u8; 8];
26-
27-
board_core.read(appaddr, &mut appdata)?;
28-
29-
// The first 8 bytes of the application data contain the TBF header
30-
// lengths and version.
31-
//
32-
// Note on expect: `read` always fills up the entire buffer, which
33-
// was previously declared as 8 bytes.
34-
let app_size: u32 = match parse_tbf_header_lengths(
35-
&appdata
36-
.try_into()
37-
.expect("Buffer length must be at least 8 bytes long."),
38-
) {
39-
Ok(data) => data.2,
40-
_ => break,
41-
};
42-
43-
appaddr += app_size as u64;
44-
total_size += app_size;
45-
}
46-
4719
let mut loader = session.target().flash_loader();
4820

4921
let address = settings.start_address;
50-
// (adi): fill the memory with total_size values of 0x0
51-
let buffer = [0x0].repeat(total_size as usize);
52-
loader.add_data((address as u32).into(), &buffer)?;
22+
// // (adi): a single 0x0 byte is enough to invalidate the header and erase all programs
23+
loader.add_data((address as u32).into(), &[0x0])?;
5324

5425
let mut options = DownloadOptions::default();
5526
options.keep_unwritten_bytes = true;

0 commit comments

Comments
 (0)