]> git.zerfleddert.de Git - rsbs2/commitdiff
allow modification of BOARD_DESCRIPTION
authorMichael Gernoth <michael@gernoth.net>
Wed, 28 Jan 2009 22:34:29 +0000 (23:34 +0100)
committerMichael Gernoth <michael@gernoth.net>
Wed, 28 Jan 2009 22:34:29 +0000 (23:34 +0100)
firmware.c
set_better_defaults

index 6b47e2bf2c32b670107180ee4303377f9b229c9a..ac83b96e4c2911f5984c0de09a646a6786ac0954 100644 (file)
@@ -152,9 +152,49 @@ void change_properties(unsigned char *fw, int len, struct propaction *paction)
        }
 }
 
        }
 }
 
+void print_boarddescription(unsigned char *bd)
+{
+       int j;
+
+       for (j = 0; j < 32; j++) {
+               printf("%02x ", *(bd+j));
+       }
+       printf("\n");
+}
+
 void handle_boarddescription(unsigned char *fw, int len, int patch)
 {
 void handle_boarddescription(unsigned char *fw, int len, int patch)
 {
-       /* 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 */
+       int i;
+       
+       for (i = len - (strlen("pdata")+1); i > 0; i--) {
+               if (FINDSTR(fw+i, "pdata")) {
+                       unsigned char *pos = fw + i + strlen("pdata") + 1;
+
+                       /* MAGIC? */
+                       if (*((unsigned int*)pos) != 0x00002802) {
+                               continue;
+                       }
+
+                       pos += 26;
+
+                       /* MAGIC2? */
+                       if (*((unsigned int*)pos) != 0x00500101) {
+                               continue;
+                       }
+
+                       printf("0x%08x: BOARD_DESCRIPTION: ", pos-fw);
+                       print_boarddescription(pos);
+
+                       if (patch) {
+                               /* Enable ATX and relay power switching */
+                               pos[22] |= 0x03;
+                               printf("0x%08x: BOARD_DESCRIPTION: ", pos-fw);
+                               print_boarddescription(pos);
+                       }
+
+                       break;
+               }
+       }
 }
 
 void syntax(char *name)
 }
 
 void syntax(char *name)
@@ -163,6 +203,7 @@ void syntax(char *name)
        fprintf(stderr,"parameters as follows:\n");
        fprintf(stderr,"\t-d\t\tdisplay all properties of the image\n");
        fprintf(stderr,"\t-u\t\tupdate checksum of the image\n");
        fprintf(stderr,"parameters as follows:\n");
        fprintf(stderr,"\t-d\t\tdisplay all properties of the image\n");
        fprintf(stderr,"\t-u\t\tupdate checksum of the image\n");
+       fprintf(stderr,"\t-b\t\tmodify BOARD_DESCRIPTION for more power-switch options\n");
        fprintf(stderr,"\t-t property\tset 'property' to true\n");
        fprintf(stderr,"\t-f property\tset 'property' to false\n");
        fprintf(stderr,"\t-w property\tallow read-write access to 'property'\n");
        fprintf(stderr,"\t-t property\tset 'property' to true\n");
        fprintf(stderr,"\t-f property\tset 'property' to false\n");
        fprintf(stderr,"\t-w property\tallow read-write access to 'property'\n");
@@ -258,12 +299,13 @@ int main(int argc, char **argv)
        struct propaction *paction = NULL;
        int showall = 0;
        int update_crc = 0;
        struct propaction *paction = NULL;
        int showall = 0;
        int update_crc = 0;
+       int patch_bd = 0;
        int patch_fw = 0;
 
        if (argc < 2)
                syntax(argv[0]);
 
        int patch_fw = 0;
 
        if (argc < 2)
                syntax(argv[0]);
 
-       while ((opt = getopt(argc, argv, "dut:f:w:r:")) != -1) {
+       while ((opt = getopt(argc, argv, "dubt:f:w:r:")) != -1) {
                switch(opt) {
                        case 'd':
                                showall = 1;
                switch(opt) {
                        case 'd':
                                showall = 1;
@@ -271,6 +313,9 @@ int main(int argc, char **argv)
                        case 'u':
                                update_crc = 1;
                                break;
                        case 'u':
                                update_crc = 1;
                                break;
+                       case 'b':
+                               patch_bd = 1;
+                               break;
                        case 't':
                        case 'f':
                        case 'w':
                        case 't':
                        case 'f':
                        case 'w':
@@ -350,10 +395,16 @@ int main(int argc, char **argv)
                printf("\n");
        }
 
                printf("\n");
        }
 
-       if (showall)
+       if (patch_bd) {
+               handle_boarddescription(fw, statbuf.st_size -4, 1);
+       }
+
+       if (showall) {
                show_properties(fw, statbuf.st_size - 4);
                show_properties(fw, statbuf.st_size - 4);
+               handle_boarddescription(fw, statbuf.st_size -4, 0);
+       }
 
 
-       if (update_crc || patch_fw) {
+       if (update_crc || patch_fw || patch_bd) {
                ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);
                if (ret == 4) {
                        *((unsigned int*)(fw + statbuf.st_size - 4)) = crc;
                ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);
                if (ret == 4) {
                        *((unsigned int*)(fw + statbuf.st_size - 4)) = crc;
index 7f4250c9c9f728a7fb0a04005203b95d30db51eb..51f8011d116fae953337b6c4bc0fcf750b85b519 100755 (executable)
@@ -5,7 +5,7 @@ if [ "$1" = "" ]; then
        exit 1
 fi
 
        exit 1
 fi
 
-./firmware \
+./firmware -b \
        -w /default/fw_prop/FP_COMREDIRECT -t /default/fw_prop/FP_COMREDIRECT \
        -t /default/fw_prop/FP_REMOTE_POWER \
        -w /default/fw_prop/FP_NO_DIAG_PANEL -f /default/fw_prop/FP_NO_DIAG_PANEL \
        -w /default/fw_prop/FP_COMREDIRECT -t /default/fw_prop/FP_COMREDIRECT \
        -t /default/fw_prop/FP_REMOTE_POWER \
        -w /default/fw_prop/FP_NO_DIAG_PANEL -f /default/fw_prop/FP_NO_DIAG_PANEL \
Impressum, Datenschutz