]>
git.zerfleddert.de Git - rsbs2/blob - firmware.c
a5bdfdb16eb6c795ec27ed8a1d1cd830ab3831fb
12 #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str)))
16 unsigned char unknown0
;
17 unsigned char unknown1
;
18 unsigned char right_rw
;
19 unsigned char rw_mask
;
21 unsigned char unknown5
;
22 unsigned char unknown6
;
23 unsigned char unknown7
;
28 void show_properties(unsigned char *fw
, int len
)
32 for (i
= 0; i
< (len
-100 /* XXX */); i
++) {
33 if (FINDSTR(fw
+i
, "/default/fw_prop/") ||
34 FINDSTR(fw
+i
, "/default/fw_setup/") ||
35 FINDSTR(fw
+i
, "/default/oem_prop/")) {
36 struct properties
*prop
;
37 unsigned char *pos
= fw
+ i
;
39 printf("0x%08x: found setting: %s: ", i
, pos
);
41 prop
= (struct properties
*)(pos
+ strlen((char*)pos
) + 1);
43 if (prop
->magic
!= 0x83011111) {
44 printf("ignoring...\n");
48 if (prop
->type1
== 0x00 && prop
->type2
== 0x04) {
49 printf("STRING: %s ", prop
->val
);
50 } else if (prop
->type1
== 0x01 && prop
->type2
== 0x01) {
51 printf("BOOL: %s ",(*prop
->val
? "TRUE" : "FALSE"));
52 } else if (prop
->type1
== 0x04 && prop
->type2
== 0x02) {
53 printf("VAL: 0x%x ", *((unsigned int*)prop
->val
));
55 printf("0x%02x 0x%2x...ignoring\n", prop
->type1
, prop
->type2
);
59 if (prop
->right_rw
== 0x00 && prop
->rw_mask
== 0x00) {
61 } else if (prop
->right_rw
== 0x01) {
62 printf("(RW mask: 0x%02x) ", prop
->rw_mask
);
64 printf("(UNK 0x%02x 0x%02x) ", prop
->right_rw
, prop
->rw_mask
);
71 void handle_boarddescription(unsigned char *fw
, int len
, int patch
)
73 /* 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 */
76 int main(int argc
, char **argv
)
83 unsigned int crc
, oldcrc
;
86 fprintf(stderr
,"Syntax: %s firmware.bin\n", argv
[0]);
90 if (stat(argv
[1], &statbuf
) == -1) {
95 if ((fd
= open(argv
[1], O_RDONLY
)) == -1) {
100 if ((fw
= malloc(statbuf
.st_size
)) == NULL
) {
105 bzero(fw
, statbuf
.st_size
);
107 remaining
= statbuf
.st_size
;
110 if ((ret
= read(fd
, fw
+ (statbuf
.st_size
- remaining
), remaining
)) == -1) {
117 ret
= rsb_crc2(fw
, statbuf
.st_size
, 0x55335053, &crc
);
118 oldcrc
= (unsigned int)*((unsigned int*)(fw
+ statbuf
.st_size
- 4));
120 printf("Checksum: 0x%08x (%s), should be: 0x%08x\n",
122 (ret
? "NOT OK" : "OK"),
126 show_properties(fw
, statbuf
.st_size
- 4);
127 handle_boarddescription(fw
, statbuf
.st_size
- 4, 0);
129 ret
= rsb_crc2(fw
, statbuf
.st_size
, 0x55335053, &crc
);
130 printf("Checksum: 0x%08x\n", crc
);