sim: Add some debug code to dump images

The code is commented out, but can easily be uncommented to allow the
various images to be dumped out for external analysis.
diff --git a/sim/src/flash.rs b/sim/src/flash.rs
index 5b04bf6..83ef771 100644
--- a/sim/src/flash.rs
+++ b/sim/src/flash.rs
@@ -3,7 +3,10 @@
 //! This module is capable of simulating the type of NOR flash commonly used in microcontrollers.
 //! These generally can be written as individual bytes, but must be erased in larger units.
 
+use std::fs::File;
+use std::io::Write;
 use std::iter::Enumerate;
+use std::path::Path;
 use std::slice;
 use pdump::HexDump;
 
@@ -138,6 +141,13 @@
     pub fn dump(&self) {
         self.data.dump();
     }
+
+    /// Dump this image to the given file.
+    pub fn write_file<P: AsRef<Path>>(&self, path: P) -> Result<()> {
+        let mut fd = File::create(path).chain_err(|| "Unable to write image file")?;
+        fd.write_all(&self.data).chain_err(|| "Unable to write to image file")?;
+        Ok(())
+    }
 }
 
 /// It is possible to iterate over the sectors in the device, each element returning this.
diff --git a/sim/src/main.rs b/sim/src/main.rs
index e33a39d..2c53d22 100644
--- a/sim/src/main.rs
+++ b/sim/src/main.rs
@@ -216,7 +216,9 @@
     let mut fl = flash.clone();
     c::set_flash_counter(0);
 
-    for _ in 0 .. count {
+    // fl.write_file("image0.bin").unwrap();
+    for i in 0 .. count {
+        info!("Running boot pass {}", i + 1);
         assert_eq!(c::boot_go(&mut fl, &areadesc), 0);
     }
     fl