projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/draw: hand-edit 64-pixel 3/5 to avoid jank
[fw/altos]
/
altoslib
/
AltosHexfile.java
diff --git
a/altoslib/AltosHexfile.java
b/altoslib/AltosHexfile.java
index 6aa98383e9fc38d92d93b928a97d4990c6fc8258..718826001755a0dedf1a1b9725b94a30e3fcf7f4 100644
(file)
--- a/
altoslib/AltosHexfile.java
+++ b/
altoslib/AltosHexfile.java
@@
-16,7
+16,7
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_1
2
;
+package org.altusmetrum.altoslib_1
4
;
import java.io.*;
import java.util.LinkedList;
import java.io.*;
import java.util.LinkedList;
@@
-287,6
+287,8
@@
public class AltosHexfile {
return null;
}
return null;
}
+ private static final int look_around[] = { 0, -2, 2, -4, 4 };
+
private long find_usb_descriptors() {
AltosHexsym usb_descriptors = lookup_symbol("ao_usb_descriptors");
long a;
private long find_usb_descriptors() {
AltosHexsym usb_descriptors = lookup_symbol("ao_usb_descriptors");
long a;
@@
-294,15
+296,22
@@
public class AltosHexfile {
if (usb_descriptors == null)
return -1;
if (usb_descriptors == null)
return -1;
- /* Walk the descriptors looking for the device */
+ /* The address of this has moved depending on padding
+ * in the linker script and romconfig symbols. Look
+ * forward and backwards two and four bytes to see if
+ * we can find it
+ */
a = usb_descriptors.address;
a = usb_descriptors.address;
- while (get_u8(a+1) != AO_USB_DESC_DEVICE) {
- int delta = get_u8(a);
- a += delta;
- if (delta == 0 || a >= max_address)
- return -1;
+
+ for (int look : look_around) {
+ try {
+ if (get_u8(a + look) == 0x12 && get_u8(a + look + 1) == AO_USB_DESC_DEVICE)
+ return a;
+ } catch (ArrayIndexOutOfBoundsException ae) {
+ continue;
+ }
}
}
- return
a
;
+ return
-1
;
}
public AltosUsbId find_usb_id() {
}
public AltosUsbId find_usb_id() {
@@
-350,11
+359,6
@@
public class AltosHexfile {
int product_len = get_u8(a);
int product_len = get_u8(a);
- System.out.printf("Product is at %x length %d\n", a, product_len);
-
- for (int i = 0; i < product_len; i++)
- System.out.printf(" %2d: %02x\n", i, get_u8(a+i));
-
if (product_len <= 0)
return null;
if (product_len <= 0)
return null;
@@
-363,12
+367,11
@@
public class AltosHexfile {
for (int i = 0; i < product_len - 2; i += 2) {
int c = get_u16(a + 2 + i);
for (int i = 0; i < product_len - 2; i += 2) {
int c = get_u16(a + 2 + i);
- System.out.printf("character %x\n", c);
-
product += Character.toString((char) c);
}
product += Character.toString((char) c);
}
- System.out.printf("product %s\n", product);
+ if (AltosLink.debug)
+ System.out.printf("product %s\n", product);
return product;
}
return product;
}