remove zlib from image builder lists
[openwrt.git] / openwrt / target / utils / src / addpattern.c
index 52fb8ee..5f49b92 100644 (file)
@@ -50,6 +50,7 @@
 
 #define CODE_ID                "U2ND"          /* from code_pattern.h */
 #define CODE_PATTERN   "W54S"  /* from code_pattern.h */
 
 #define CODE_ID                "U2ND"          /* from code_pattern.h */
 #define CODE_PATTERN   "W54S"  /* from code_pattern.h */
+#define PBOT_PATTERN   "PBOT"
 
 #define CYBERTAN_VERSION       "v3.37.2" /* from cyutils.h */
 
 
 #define CYBERTAN_VERSION       "v3.37.2" /* from cyutils.h */
 
@@ -65,7 +66,8 @@ struct code_header {                  /* from cyutils.h */
        char fwvern[3];
        char id[4];                                     /* U2ND */
        char hw_ver;                            /* 0: for 4702, 1: for 4712 -- new in 2.04.3 */
        char fwvern[3];
        char id[4];                                     /* U2ND */
        char hw_ver;                            /* 0: for 4702, 1: for 4712 -- new in 2.04.3 */
-       unsigned short flags;       /* SUPPORT_ flags new for 3.37.2 (WRT54G v2.2 and WRT54GS v1.1) */
+       char unused;
+       unsigned char flags[2];       /* SUPPORT_ flags new for 3.37.2 (WRT54G v2.2 and WRT54GS v1.1) */
        unsigned char res2[10];
 } ;
 
        unsigned char res2[10];
 } ;
 
@@ -75,7 +77,7 @@ void usage(void) __attribute__ (( __noreturn__ ));
 
 void usage(void)
 {
 
 void usage(void)
 {
-       fprintf(stderr, "Usage: addpattern [-i trxfile] [-o binfile] [-p pattern] [-g] [-v v#.#.#] [-{0|1|2}]\n");
+       fprintf(stderr, "Usage: addpattern [-i trxfile] [-o binfile] [-p pattern] [-g] [-b] [-v v#.#.#] [-{0|1|2|4}]\n");
        exit(EXIT_FAILURE);
 }
 
        exit(EXIT_FAILURE);
 }
 
@@ -88,8 +90,10 @@ int main(int argc, char **argv)
        char *ifn = NULL;
        char *ofn = NULL;
        char *pattern = CODE_PATTERN;
        char *ifn = NULL;
        char *ofn = NULL;
        char *pattern = CODE_PATTERN;
+       char *pbotpat = PBOT_PATTERN;
        char *version = CYBERTAN_VERSION;
        int gflag = 0;
        char *version = CYBERTAN_VERSION;
        int gflag = 0;
+       int pbotflag = 0;
        int c;
        int v0, v1, v2;
        size_t off, n;
        int c;
        int v0, v1, v2;
        size_t off, n;
@@ -101,7 +105,7 @@ int main(int argc, char **argv)
        hdr = (struct code_header *) buf;
        memset(hdr, 0, sizeof(struct code_header));
 
        hdr = (struct code_header *) buf;
        memset(hdr, 0, sizeof(struct code_header));
 
-       while ((c = getopt(argc, argv, "i:o:p:gv:012")) != -1) {
+       while ((c = getopt(argc, argv, "i:o:p:gbv:0124")) != -1) {
                switch (c) {
                        case 'i':
                                ifn = optarg;
                switch (c) {
                        case 'i':
                                ifn = optarg;
@@ -115,6 +119,9 @@ int main(int argc, char **argv)
                        case 'g':
                                gflag = 1;
                                break;
                        case 'g':
                                gflag = 1;
                                break;
+                       case 'b':
+                               pbotflag = 1;
+                               break;
                        case 'v':                       /* extension to allow setting version */
                                version = optarg;
                                break;
                        case 'v':                       /* extension to allow setting version */
                                version = optarg;
                                break;
@@ -126,9 +133,14 @@ int main(int argc, char **argv)
                                break;
                        case '2':                       /* new 54G v2.2 and 54GS v1.1 flags */
                                hdr->hw_ver = 1;
                                break;
                        case '2':                       /* new 54G v2.2 and 54GS v1.1 flags */
                                hdr->hw_ver = 1;
-                               hdr->flags |= SUPPORT_4712_CHIP;
-                               hdr->flags |= SUPPORT_INTEL_FLASH;
-                               hdr->flags |= SUPPORT_5325E_SWITCH;
+                               hdr->flags[0] |= SUPPORT_4712_CHIP;
+                               hdr->flags[0] |= SUPPORT_INTEL_FLASH;
+                               hdr->flags[0] |= SUPPORT_5325E_SWITCH;
+                               break;
+                       case '4':
+                               /* V4 firmware sets the flags to 0x1f */
+                               hdr->hw_ver = 0;
+                               hdr->flags[0] = 0x1f;
                                break;
 
                        default:
                                break;
 
                        default:
@@ -169,6 +181,8 @@ int main(int argc, char **argv)
        }
 
        memcpy(&hdr->magic, pattern, 4);
        }
 
        memcpy(&hdr->magic, pattern, 4);
+       if (pbotflag)
+               memcpy(&hdr->res1, pbotpat, 4);
        hdr->fwdate[0] = ptm->tm_year % 100;
        hdr->fwdate[1] = ptm->tm_mon + 1;
        hdr->fwdate[2] = ptm->tm_mday;
        hdr->fwdate[0] = ptm->tm_year % 100;
        hdr->fwdate[1] = ptm->tm_mon + 1;
        hdr->fwdate[2] = ptm->tm_mday;
This page took 0.032887 seconds and 4 git commands to generate.