sim: Base slots on number of images used

Construct the ImagesBuilder based on the number of images compiled into
the code.  If the flash device doesn't have enough areas for the test,
the test will be skipped.

Extend the FlashId to include Image2, and Image3.  Remove the unused
ones, so that these can be placed immediately after the scratcharea.
The current simulator code assumes the flash areas are numbered
contiguously, requiring these extraneous partitions to be eliminated.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/mcuboot-sys/src/area.rs b/sim/mcuboot-sys/src/area.rs
index 9b13098..6baf8e0 100644
--- a/sim/mcuboot-sys/src/area.rs
+++ b/sim/mcuboot-sys/src/area.rs
@@ -107,15 +107,15 @@
     }
 
     // Look for the image with the given ID, and return its offset, size and
-    // device id. Panics if the area is not present.
-    pub fn find(&self, id: FlashId) -> (usize, usize, u8) {
+    // device id. Returns None if the area is not present.
+    pub fn find(&self, id: FlashId) -> Option<(usize, usize, u8)> {
         for area in &self.whole {
             // FIXME: should we ensure id is not duplicated over multiple devices?
             if area.flash_id == id {
-                return (area.off as usize, area.size as usize, area.device_id);
+                return Some((area.off as usize, area.size as usize, area.device_id));
             }
         }
-        panic!("Requesting area that is not present in flash");
+        None
     }
 
     pub fn get_c(&self) -> CAreaDesc {
@@ -176,9 +176,8 @@
     Image0 = 1,
     Image1 = 2,
     ImageScratch = 3,
-    Nffs = 4,
-    Core = 5,
-    RebootLog = 6
+    Image2 = 4,
+    Image3 = 5,
 }
 
 impl Default for FlashId {