diff options
author | Keith Packard <keithp@keithp.com> | 2018-10-20 17:29:36 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-10-20 17:31:57 -0700 |
commit | 48e221cca00c9f925ff57588dd782842705f7a23 (patch) | |
tree | eb64bb356655472f56589b074b74f1112b63772b /altoslib | |
parent | 345e3c37a1cf619392b54589bb91b4caf7844810 (diff) |
altoslib: When flashing hardware, pull USB data from device if needed
If we fail to extract USB vid/pid and product values from the device
ROM, use the data discovered over USB when the device was originally
discovered.
Also, use the USB product to select appropriate .ihx files instead of
only using the USB vid/pid. This will help people avoid using the
wrong file when reflashing devices.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosFlash.java | 6 | ||||
-rw-r--r-- | altoslib/AltosHexsym.java | 6 | ||||
-rw-r--r-- | altoslib/AltosProgrammer.java | 2 | ||||
-rw-r--r-- | altoslib/AltosRomconfig.java | 10 | ||||
-rw-r--r-- | altoslib/AltosSelfFlash.java | 6 |
5 files changed, 25 insertions, 5 deletions
diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index e6b05713..434a0265 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -331,9 +331,13 @@ public class AltosFlash extends AltosProgrammer { rom_config = romconfig; } - public AltosRomconfig target_romconfig() throws InterruptedException { + public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException { if (!check_rom_config()) return null; + if (rom_config.usb_id == null) + rom_config.usb_id = usb_id; + if (rom_config.usb_product == null) + rom_config.usb_product = usb_product; return rom_config; } diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java index b1323484..a2ba6935 100644 --- a/altoslib/AltosHexsym.java +++ b/altoslib/AltosHexsym.java @@ -24,8 +24,12 @@ public class AltosHexsym { final static long invalid_addr = 0xffffffff; + public String toString() { + return String.format("%s:0x%x", name, address); + } + public AltosHexsym(String name, long address) { this.name = name; this.address = address; } -}
\ No newline at end of file +} diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java index 1872392d..f87e334c 100644 --- a/altoslib/AltosProgrammer.java +++ b/altoslib/AltosProgrammer.java @@ -28,7 +28,7 @@ public abstract class AltosProgrammer { abstract public void abort(); - abstract public AltosRomconfig target_romconfig() throws InterruptedException; + abstract public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException; abstract public AltosRomconfig image_romconfig(); diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index ebeb76f3..00811ce7 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -273,6 +273,14 @@ public class AltosRomconfig implements AltosUnitInfoListener { throw new IOException("writing new rom config failed\n"); } + public String toString() { + return String.format("valid %b version %d serial %d radio %d usb %04x:%04x %s", + valid, version, serial_number, radio_calibration, + usb_id == null ? 0 : usb_id.vid, + usb_id == null ? 0 : usb_id.pid, + usb_product == null ? "unknown" : usb_product); + } + public AltosRomconfig(int in_serial_number, int in_radio_calibration) { valid = true; version = 1; @@ -282,7 +290,7 @@ public class AltosRomconfig implements AltosUnitInfoListener { } public boolean valid() { - return valid && serial_number != 0; + return valid; } public AltosRomconfig() { diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 0250cce7..70a5ced5 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -184,9 +184,13 @@ public class AltosSelfFlash extends AltosProgrammer { rom_config = romconfig; } - public AltosRomconfig target_romconfig() throws InterruptedException { + public AltosRomconfig target_romconfig(AltosUsbId usb_id, String usb_product) throws InterruptedException { if (!check_rom_config()) return null; + if (rom_config.usb_id == null) + rom_config.usb_id = usb_id; + if (rom_config.usb_product == null) + rom_config.usb_product = usb_product; return rom_config; } |