sim: Add a readable header to test images
Rather than just make the test images entirely pseudorandom data, add a
small textual header to the front that describes some key information
about each image. This can be helpful when debugging, to determine what
exactly is in each image slot.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/sim/src/image.rs b/sim/src/image.rs
index 6b351f8..39e7fbb 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -4,6 +4,7 @@
Rng, SeedableRng, XorShiftRng,
};
use std::{
+ io::{Cursor, Write},
mem,
slice,
};
@@ -1097,6 +1098,15 @@
let mut b_img = vec![0; len];
splat(&mut b_img, offset);
+ // Add some information at the start of the payload to make it easier
+ // to see what it is. This will fail if the image itself is too small.
+ {
+ let mut wr = Cursor::new(&mut b_img);
+ writeln!(&mut wr, "offset: {:#x}, dev_id: {:#x}, slot_info: {:?}",
+ offset, dev_id, slot).unwrap();
+ writeln!(&mut wr, "version: {:?}", deps.my_version(offset, slot.index)).unwrap();
+ }
+
// TLV signatures work over plain image
tlv.add_bytes(&b_img);