- void read_block(long addr) {
- link.printf("R %x\n", addr);
-
+ byte[] read_memory(long addr, int len) throws InterruptedException, IOException {
+ int b;
+ byte[] data = new byte[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 < 0x100 && b + offset < len; b++)
+ data[b+offset] = reply[b];
+ }
+ return data;