[tools] firmware-utils/mkmylofw: WP543 support
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 8 Sep 2008 12:39:33 +0000 (12:39 +0000)
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Mon, 8 Sep 2008 12:39:33 +0000 (12:39 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12552 3c298f89-4303-0410-b956-a3cf2f4a3e73

tools/firmware-utils/src/mkmylofw.c
tools/firmware-utils/src/myloader.h

index 7a69f6e..aa0a2e1 100644 (file)
@@ -1,7 +1,5 @@
 /*
 /*
- *  $Id$
- *
- *  Copyright (C) 2006,2007 Gabor Juhos <juhosg at openwrt.org>
+ *  Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License
@@ -72,15 +70,24 @@ struct cpx_board {
        uint16_t        svid;   /* sub vendor id */
        uint16_t        sdid;   /* sub device id */
        uint32_t        flash_size;     /* size of flash */
        uint16_t        svid;   /* sub vendor id */
        uint16_t        sdid;   /* sub device id */
        uint32_t        flash_size;     /* size of flash */
+       uint32_t        part_offset;    /* offset of the partition_table */
+       uint32_t        part_size;      /* size of the partition_table */
 };
 
 };
 
-#define BOARD(_vid, _did, _svid, _sdid, _flash, _mod, _name, _desc) {          \
-       .model = _mod, .name = _name, .desc = _desc,                            \
+#define BOARD(_vid, _did, _svid, _sdid, _flash, _mod, _name, _desc, _po, _ps) {                \
+       .model = _mod, .name = _name, .desc = _desc,                    \
        .vid = _vid, .did = _did, .svid = _svid, .sdid = _sdid,         \
        .vid = _vid, .did = _did, .svid = _svid, .sdid = _sdid,         \
-       .flash_size = (_flash << 20)    }
+       .flash_size = (_flash << 20),                                   \
+       .part_offset = _po, .part_size = _ps }
+
+#define CPX_BOARD(_did, _flash, _mod, _name, _desc, _po, _ps) \
+       BOARD(VENID_COMPEX, _did, VENID_COMPEX, _did, _flash, _mod, _name, _desc, _po, _ps)
+
+#define CPX_BOARD_ADM(_did, _flash, _mod, _name, _desc) \
+       CPX_BOARD(_did, _flash, _mod, _name, _desc, 0x10000, 0x10000)
 
 
-#define CPX_BOARD(_did, _flash, _mod, _name, _desc) \
-       BOARD(VENID_COMPEX, _did, VENID_COMPEX, _did, _flash, _mod, _name, _desc)
+#define CPX_BOARD_AR71XX(_did, _flash, _mod, _name, _desc) \
+       CPX_BOARD(_did, _flash, _mod, _name, _desc, 0x20000, 0x8000)
 
 #define ALIGN(x,y)     ((x)+((y)-1)) & ~((y)-1)
 
 
 #define ALIGN(x,y)     ((x)+((y)-1)) & ~((y)-1)
 
@@ -95,44 +102,48 @@ int        verblevel = 0;
 struct mylo_fw_header fw_header;
 struct mylo_partition fw_partitions[MYLO_MAX_PARTITIONS];
 struct fw_block fw_blocks[MAX_FW_BLOCKS];
 struct mylo_fw_header fw_header;
 struct mylo_partition fw_partitions[MYLO_MAX_PARTITIONS];
 struct fw_block fw_blocks[MAX_FW_BLOCKS];
+struct cpx_board *board;
 
 struct cpx_board boards[] = {
 
 struct cpx_board boards[] = {
-       CPX_BOARD(DEVID_COMPEX_NP18A, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP18A, 4,
                "NP18A", "Compex NetPassage 18A",
                "Dualband Wireless A+G Internet Gateway"),
                "NP18A", "Compex NetPassage 18A",
                "Dualband Wireless A+G Internet Gateway"),
-       CPX_BOARD(DEVID_COMPEX_NP26G8M, 2,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP26G8M, 2,
                "NP26G8M", "Compex NetPassage 26G (8M)",
                "Wireless-G Broadband Multimedia Gateway"),
                "NP26G8M", "Compex NetPassage 26G (8M)",
                "Wireless-G Broadband Multimedia Gateway"),
-       CPX_BOARD(DEVID_COMPEX_NP26G16M, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP26G16M, 4,
                "NP26G16M", "Compex NetPassage 26G (16M)",
                "Wireless-G Broadband Multimedia Gateway"),
                "NP26G16M", "Compex NetPassage 26G (16M)",
                "Wireless-G Broadband Multimedia Gateway"),
-       CPX_BOARD(DEVID_COMPEX_NP27G, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP27G, 4,
                "NP27G", "Compex NetPassage 27G",
                "Wireless-G 54Mbps eXtended Range Router"),
                "NP27G", "Compex NetPassage 27G",
                "Wireless-G 54Mbps eXtended Range Router"),
-       CPX_BOARD(DEVID_COMPEX_NP28G, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP28G, 4,
                "NP28G", "Compex NetPassage 28G",
                "Wireless 108Mbps Super-G XR Multimedia Router with 4 USB Ports"),
                "NP28G", "Compex NetPassage 28G",
                "Wireless 108Mbps Super-G XR Multimedia Router with 4 USB Ports"),
-       CPX_BOARD(DEVID_COMPEX_NP28GHS, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_NP28GHS, 4,
                "NP28GHS", "Compex NetPassage 28G (HotSpot)",
                "HotSpot Solution"),
                "NP28GHS", "Compex NetPassage 28G (HotSpot)",
                "HotSpot Solution"),
-       CPX_BOARD(DEVID_COMPEX_WP18, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_WP18, 4,
                "WP18", "Compex NetPassage WP18",
                "Wireless-G 54Mbps A+G Dualband Access Point"),
                "WP18", "Compex NetPassage WP18",
                "Wireless-G 54Mbps A+G Dualband Access Point"),
-       CPX_BOARD(DEVID_COMPEX_WP54G, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_WP54G, 4,
                "WP54G", "Compex WP54G",
                "Wireless-G 54Mbps XR Access Point"),
                "WP54G", "Compex WP54G",
                "Wireless-G 54Mbps XR Access Point"),
-       CPX_BOARD(DEVID_COMPEX_WP54Gv1C, 2,
+       CPX_BOARD_ADM(DEVID_COMPEX_WP54Gv1C, 2,
                "WP54Gv1C", "Compex WP54G rev.1C",
                "Wireless-G 54Mbps XR Access Point"),
                "WP54Gv1C", "Compex WP54G rev.1C",
                "Wireless-G 54Mbps XR Access Point"),
-       CPX_BOARD(DEVID_COMPEX_WP54AG, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_WP54AG, 4,
                "WP54AG", "Compex WP54AG",
                "Wireless-AG 54Mbps XR Access Point"),
                "WP54AG", "Compex WP54AG",
                "Wireless-AG 54Mbps XR Access Point"),
-       CPX_BOARD(DEVID_COMPEX_WPP54G, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_WPP54G, 4,
                "WPP54G", "Compex WPP54G",
                "Outdoor Access Point"),
                "WPP54G", "Compex WPP54G",
                "Outdoor Access Point"),
-       CPX_BOARD(DEVID_COMPEX_WPP54AG, 4,
+       CPX_BOARD_ADM(DEVID_COMPEX_WPP54AG, 4,
                "WPP54AG", "Compex WPP54AG",
                "Outdoor Access Point"),
                "WPP54AG", "Compex WPP54AG",
                "Outdoor Access Point"),
+       CPX_BOARD_AR71XX(DEVID_COMPEX_WP543, 2,
+               "WP543", "Compex WP543",
+               "BareBoard"),
        {.model = NULL}
 };
 
        {.model = NULL}
 };
 
@@ -213,6 +224,7 @@ usage(int status)
 "                      a:  this is the active partition. The bootloader loads\n"
 "                          the firmware from this partition.\n"
 "                      h:  the partition data have a header.\n"
 "                      a:  this is the active partition. The bootloader loads\n"
 "                          the firmware from this partition.\n"
 "                      h:  the partition data have a header.\n"
+"                      l:  the partition data uses LZMA compression.\n"
 "                      p:  the bootloader loads data from this partition to\n"
 "                          the RAM before decompress it.\n"
 "  -h              show this screen\n"
 "                      p:  the bootloader loads data from this partition to\n"
 "                          the RAM before decompress it.\n"
 "  -h              show this screen\n"
@@ -624,11 +636,10 @@ write_out_blocks(FILE *outfile, uint32_t *crc)
         * for the partition table
         */
        if (fw_num_partitions > 0) {
         * for the partition table
         */
        if (fw_num_partitions > 0) {
-
                desc.type = HOST_TO_LE32(FW_DESC_TYPE_USED);
                desc.type = HOST_TO_LE32(FW_DESC_TYPE_USED);
-               desc.addr = HOST_TO_LE32(0x10000);
+               desc.addr = HOST_TO_LE32(board->part_offset);
                desc.dlen = HOST_TO_LE32(sizeof(struct mylo_partition_table));
                desc.dlen = HOST_TO_LE32(sizeof(struct mylo_partition_table));
-               desc.blen = HOST_TO_LE32(0x10000);
+               desc.blen = HOST_TO_LE32(board->part_size);
 
                if (write_out_desc(outfile, &desc, crc) != 0)
                        return -1;
 
                if (write_out_desc(outfile, &desc, crc) != 0)
                        return -1;
@@ -1014,6 +1025,9 @@ parse_opt_partition(char ch, char *arg)
                        case 'p':
                                part->flags |= PARTITION_FLAG_PRELOAD;
                                break;
                        case 'p':
                                part->flags |= PARTITION_FLAG_PRELOAD;
                                break;
+                       case 'l':
+                               part->flags |= PARTITION_FLAG_LZMA;
+                               break;
                        case 'h':
                                part->flags |= PARTITION_FLAG_HAVEHDR;
                                break;
                        case 'h':
                                part->flags |= PARTITION_FLAG_HAVEHDR;
                                break;
@@ -1068,8 +1082,6 @@ err_out:
 int
 parse_opt_board(char ch, char *arg)
 {
 int
 parse_opt_board(char ch, char *arg)
 {
-       struct cpx_board *board;
-
        if (required_arg(ch, arg)) {
                goto err_out;
        }
        if (required_arg(ch, arg)) {
                goto err_out;
        }
@@ -1189,6 +1201,11 @@ main(int argc, char *argv[])
                goto out;
        }
 
                goto out;
        }
 
+       if (!board) {
+               errmsg(0, "no board specified");
+               goto out;
+       }
+
        if (flash_size == 0) {
                errmsg(0, "no flash size specified");
                goto out;
        if (flash_size == 0) {
                errmsg(0, "no flash size specified");
                goto out;
index 3c0c602..d01bce9 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *  Copyright (C) 2006,2007 Gabor Juhos
+ *  Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -56,6 +56,9 @@
 #define DEVID_COMPEX_WPP54AG   0x0550
 #define DEVID_COMPEX_WPP54G    0x0555
 
 #define DEVID_COMPEX_WPP54AG   0x0550
 #define DEVID_COMPEX_WPP54G    0x0555
 
+/* Devices based on the Atheros AR71xx */
+#define DEVID_COMPEX_WP543     0x0640
+
 /* Devices based on the IXP422 */
 #define DEVID_COMPEX_WP18      0x047E
 #define DEVID_COMPEX_NP18A     0x0489
 /* Devices based on the IXP422 */
 #define DEVID_COMPEX_WP18      0x047E
 #define DEVID_COMPEX_NP18A     0x0489
@@ -108,6 +111,7 @@ struct mylo_partition {
 #define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
 #define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
                                        * before decompression */
 #define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
 #define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
                                        * before decompression */
+#define PARTITION_FLAG_LZMA    0x0100 /* the partition data compressed with LZMA */
 #define PARTITION_FLAG_HAVEHDR  0x0002 /* the partition data have a header */
 
 #define PARTITION_TYPE_FREE    0
 #define PARTITION_FLAG_HAVEHDR  0x0002 /* the partition data have a header */
 
 #define PARTITION_TYPE_FREE    0
This page took 0.032711 seconds and 4 git commands to generate.