diff options
author | Bdale Garbee <bdale@gag.com> | 2018-02-12 16:38:57 -0700 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2018-02-12 16:38:57 -0700 |
commit | ee79a205e118ea8730a02cc327d8fb79cc5f74ff (patch) | |
tree | be0b0c9fbccaa84acadb1d18688aae9b8db3e048 /altoslib/AltosSelfFlash.java | |
parent | 365eee3ebfe73204033089b363687228f97e5d98 (diff) | |
parent | 78a90fc760b88ab66c5c238289afc38356e29d8a (diff) |
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Diffstat (limited to 'altoslib/AltosSelfFlash.java')
-rw-r--r-- | altoslib/AltosSelfFlash.java | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 53782172..c7ea147f 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -45,18 +45,33 @@ public class AltosSelfFlash extends AltosProgrammer { int b; byte[] data = new byte[len]; + System.out.printf("read_memory %x %d\n", addr, len); for (int offset = 0; offset < len; offset += 0x100) { link.printf("R %x\n", addr + offset); byte[] reply = link.get_binary_reply(5000, 0x100); if (reply == null) throw new IOException("Read device memory timeout"); - for (b = 0; b < len; b++) + for (b = 0; b < 0x100 && b + offset < len; b++) data[b+offset] = reply[b]; } return data; } + AltosHexfile read_hexfile(long addr, int len) throws InterruptedException { + try { + byte[] mem = read_memory(addr, len); + + AltosHexfile hexfile = new AltosHexfile(mem, addr); + + if (image != null) + hexfile.add_symbols(image); + return hexfile; + } catch (IOException ie) { + return null; + } + } + void write_memory(long addr, byte[] data, int start, int len) { int b; link.printf("W %x\n", addr); @@ -143,18 +158,14 @@ public class AltosSelfFlash extends AltosProgrammer { private AltosHexfile get_rom() throws InterruptedException { try { - int base = AltosRomconfig.fetch_base(image); - int bounds = AltosRomconfig.fetch_bounds(image); - byte[] data = read_memory(base, bounds - base); - AltosHexfile hexfile = new AltosHexfile(data, base); - hexfile.add_symbols(image); - return hexfile; - } catch (AltosNoSymbol none) { - return null; - } catch (IOException ie) { + long base = AltosRomconfig.fetch_base(image); + long bounds = AltosRomconfig.fetch_bounds(image); + + System.out.printf("rom base %x bounds %x\n", base, bounds); + return read_hexfile(base, (int) (bounds - base)); + } catch (AltosNoSymbol ns) { return null; } - } public boolean check_rom_config() throws InterruptedException { @@ -173,12 +184,16 @@ public class AltosSelfFlash 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 AltosSelfFlash(File file, AltosLink link, AltosFlashListener listener) throws IOException, FileNotFoundException, InterruptedException { this.file = file; @@ -187,4 +202,4 @@ public class AltosSelfFlash extends AltosProgrammer { input = new FileInputStream(file); image = new AltosHexfile(input); } -}
\ No newline at end of file +} |