]>
cvs.zerfleddert.de Git - rsbs2/blob - firmware.c
12 #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str)))
14 void handle_defaults(unsigned char *fw
, int len
, int patch
)
18 for (i
= 0; i
< (len
-100 /* XXX */); i
++) {
19 if (FINDSTR(fw
+i
, "/default/fw_prop/") ||
20 FINDSTR(fw
+i
, "/default/fw_setup/") ||
21 FINDSTR(fw
+i
, "/default/oem_prop/")) {
22 unsigned char *pos
= fw
+ i
;
23 unsigned char type1
, type2
;
24 unsigned char right_rw
, rw_mask
;
27 printf("0x%08x: found setting: %s: ", i
, pos
);
29 pos
+= strlen((char*)pos
) + 1;
31 if ((pos
[0] != 0x11) ||
35 printf("ignoring...\n");
49 if (type1
== 0x00 && type2
== 0x04) {
50 printf("STRING: %s ", val
);
51 } else if (type1
== 0x01 && type2
== 0x01) {
52 printf("BOOL: %s ",(*val
? "TRUE" : "FALSE"));
53 } else if (type1
== 0x04 && type2
== 0x02) {
54 printf("VAL: 0x%x ", *((unsigned int*)val
));
56 printf("0x%02x 0x%2x...ignoring\n", type1
, type2
);
60 if (right_rw
== 0x00 && rw_mask
== 0x00) {
62 } else if (right_rw
== 0x01) {
63 printf("(RW mask: 0x%02x) ", rw_mask
);
65 printf("(UNK 0x%02x 0x%02x) ", right_rw
, rw_mask
);
72 void handle_boarddescription(unsigned char *fw
, int len
, int patch
)
74 /* 0x01 0x01 0x50 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x88 0x02 0xac 0x01 0xd0 0x05 0x00 0x00 0x6a 0x3a 0x00 0x00 0x06 0x00 0x01 0x00 0x00 0x00 0x00 0x00 */
77 int main(int argc
, char **argv
)
84 unsigned int crc
, oldcrc
;
87 fprintf(stderr
,"Syntax: %s firmware.bin\n", argv
[0]);
91 if (stat(argv
[1], &statbuf
) == -1) {
96 if ((fd
= open(argv
[1], O_RDONLY
)) == -1) {
101 if ((fw
= malloc(statbuf
.st_size
)) == NULL
) {
106 bzero(fw
, statbuf
.st_size
);
108 remaining
= statbuf
.st_size
;
111 if ((ret
= read(fd
, fw
+ (statbuf
.st_size
- remaining
), remaining
)) == -1) {
118 ret
= rsb_crc2(fw
, statbuf
.st_size
, 0x55335053, &crc
);
119 oldcrc
= (unsigned int)*((unsigned int*)(fw
+ statbuf
.st_size
- 4));
121 printf("Checksum: 0x%08x (%s), should be: 0x%08x\n",
123 (ret
? "NOT OK" : "OK"),
127 handle_defaults(fw
, statbuf
.st_size
- 4, 0);
128 handle_boarddescription(fw
, statbuf
.st_size
- 4, 0);
130 ret
= rsb_crc2(fw
, statbuf
.st_size
, 0x55335053, &crc
);
131 printf("Checksum: 0x%08x\n", crc
);