sim: Add debugging ptable to image dumps
Add a `debug_dump()` method to `Images` to allow the images to be
written to a file. The dependency test will call this if the
environment variable MCUBOOT_DEBUG_DUMP is set.
In order to make these debug dumps more useful, add a simple partition
table to the beginning of the image (where MCUboot would reside on
target). This has a simple header, and then entries for each partition,
using the partition ids used within the simulator. This allows the
image to be more easily used by external tools.
As an example, `scripts/mcubin.bt` is a binary template for the [010
Editor](https://www.sweetscape.com/010editor/), allowing it to decode
and show the details of images from MCUboot.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/tests/core.rs b/sim/tests/core.rs
index c536b0a..10a05da 100644
--- a/sim/tests/core.rs
+++ b/sim/tests/core.rs
@@ -8,6 +8,7 @@
NO_DEPS,
testlog,
};
+use std::env;
/// A single test, after setting up logging and such. Within the $body,
/// $arg will be bound to each device.
@@ -51,8 +52,13 @@
return;
}
- for dep in TEST_DEPS {
+ for (index, dep) in TEST_DEPS.iter().enumerate() {
let image = r.clone().make_image(&dep, true);
+
+ if env::var_os("MCUBOOT_DEBUG_DUMP").is_some() {
+ let name = format!("dep-test-{:0>}", index);
+ image.debug_dump(&name);
+ }
assert!(!image.run_check_deps(&dep));
}
});