summaryrefslogtreecommitdiff
path: root/altoslib/AltosSelfFlash.java
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2018-03-18 15:47:31 -0600
committerBdale Garbee <bdale@gag.com>2018-03-18 15:47:31 -0600
commit7b614380f307cb5e27f2a05281bc76c4ace93334 (patch)
treed243b069a134233f4b98e35769193a1244fc57f8 /altoslib/AltosSelfFlash.java
parent16a9d8617b2d2092d166a85ada4349601afb0dce (diff)
parent39023ed6e29103a85bfad505506fa0dbf4dc1112 (diff)
Merge branch 'master' into branch-1.8
Diffstat (limited to 'altoslib/AltosSelfFlash.java')
-rw-r--r--altoslib/AltosSelfFlash.java41
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
+}