From b95db5819885da89504d5e11decfda98cfac37aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Jan 2018 22:27:41 -0800 Subject: altoslib/altosuilib: Validate rom image is for target device This should avoid mis-programming devices with incorrect firmware. Signed-off-by: Keith Packard --- altoslib/AltosFlash.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'altoslib/AltosFlash.java') diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index c8db1f77..9bf0da25 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -254,7 +254,7 @@ public class AltosFlash extends AltosProgrammer { clock_init(); int remain = image.data.length; - int flash_addr = image.address; + int flash_addr = (int) image.address; int image_start = 0; action("start", 0); @@ -295,7 +295,7 @@ public class AltosFlash extends AltosProgrammer { if (!aborted) { action("done", 100); if (debug != null) { - debug.set_pc(image.address); + debug.set_pc((int) image.address); debug.resume(); } } @@ -331,12 +331,16 @@ public class AltosFlash extends AltosProgrammer { rom_config = romconfig; } - public AltosRomconfig romconfig() throws InterruptedException { + public AltosRomconfig target_romconfig() throws InterruptedException { if (!check_rom_config()) return null; return rom_config; } + public AltosRomconfig image_romconfig() { + return new AltosRomconfig(image); + } + public AltosFlash(File file, AltosLink link, AltosFlashListener listener) throws IOException, FileNotFoundException, InterruptedException { this.file = file; -- cgit v1.2.3