Add extra information on errors
* Print bail out error information
* Print specific location of non-ff writes
diff --git a/sim/src/api.rs b/sim/src/api.rs
index 71d4643..ec502a2 100644
--- a/sim/src/api.rs
+++ b/sim/src/api.rs
@@ -29,6 +29,9 @@
fn map_err(err: Result<()>) -> libc::c_int {
match err {
Ok(()) => 0,
- Err(_) => -1,
+ Err(e) => {
+ warn!("{}", e);
+ -1
+ },
}
}
diff --git a/sim/src/flash.rs b/sim/src/flash.rs
index 797a044..adbb69a 100644
--- a/sim/src/flash.rs
+++ b/sim/src/flash.rs
@@ -94,8 +94,10 @@
}
let mut sub = &mut self.data[offset .. offset + payload.len()];
- if sub.iter().any(|x| *x != 0xFF) {
- bail!(ewrite(format!("Write to non-FF location: offset: {:x}", offset)));
+ for (i, x) in sub.iter().enumerate() {
+ if *x != 0xFF {
+ bail!(ewrite(format!("Write to non-FF location at 0x{:x}", offset + i)));
+ }
}
sub.copy_from_slice(payload);