Commit cb47dd74 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

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: default avatarDavid Brown <david.brown@linaro.org>
parent c3898d61
Loading
Loading
Loading
Loading
+10
Changes for sim/src/image.rs: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ use rand::{
    Rng, SeedableRng, XorShiftRng,
};
use std::{
    io::{Cursor, Write},
    mem,
    slice,
};
@@ -1097,6 +1098,15 @@ fn install_image(flash: &mut SimMultiFlash, slot: &SlotInfo, len: usize,
    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);