Merge pull request #35 from utzig/increase-sim-debug-info

Add extra information on errors
This commit is contained in:
David Brown 2017-04-25 14:59:42 -06:00 committed by GitHub
commit bef227c3a0
2 changed files with 8 additions and 3 deletions

View File

@ -29,6 +29,9 @@ pub extern fn sim_flash_write(dev: *mut Flash, offset: u32, src: *const u8, size
fn map_err(err: Result<()>) -> libc::c_int {
match err {
Ok(()) => 0,
Err(_) => -1,
Err(e) => {
warn!("{}", e);
-1
},
}
}

View File

@ -94,8 +94,10 @@ impl Flash {
}
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);