.last_sysupgrade_partition = "support-list",
},
+ /** Firmware layout for the CPE605V1 */
+ {
+ .id = "CPE605V1",
+ .vendor = "CPE605(TP-LINK|UN|N150-5):1.0\r\n",
+ .support_list =
+ "SupportList:\r\n"
+ "CPE605(TP-LINK|UN|N150-5|00000000):1.0\r\n"
+ "CPE605(TP-LINK|EU|N150-5|45550000):1.0\r\n"
+ "CPE605(TP-LINK|US|N150-5|55530000):1.0\r\n",
+ .part_trail = 0x00,
+ .soft_ver = SOFT_VER_DEFAULT,
+
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x20000},
+ {"partition-table", 0x20000, 0x02000},
+ {"default-mac", 0x30000, 0x00020},
+ {"serial-number", 0x30100, 0x00020},
+ {"product-info", 0x31100, 0x00100},
+ {"device-info", 0x31400, 0x00400},
+ {"signature", 0x32000, 0x00400},
+ {"device-id", 0x33000, 0x00100},
+ {"firmware", 0x40000, 0x770000},
+ {"soft-version", 0x7b0000, 0x00100},
+ {"support-list", 0x7b1000, 0x01000},
+ {"user-config", 0x7c0000, 0x10000},
+ {"default-config", 0x7d0000, 0x10000},
+ {"log", 0x7e0000, 0x10000},
+ {"radio", 0x7f0000, 0x10000},
+ {NULL, 0, 0}
+ },
+
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "support-list",
+ },
+
/** Firmware layout for the CPE610V1 */
{
.id = "CPE610V1",
.last_sysupgrade_partition = "file-system",
},
+ /** Firmware layout for the Deco M4R v4 */
+ {
+ .id = "DECO-M4R-V4",
+ .vendor = "",
+ .support_list =
+ "SupportList:\n"
+ "{product_name:M4R,product_ver:4.0.0,special_id:55530000}\n"
+ "{product_name:M4R,product_ver:4.0.0,special_id:45550000}\n"
+ "{product_name:M4R,product_ver:4.0.0,special_id:4A500000}\n"
+ "{product_name:M4R,product_ver:4.0.0,special_id:42340000}\n"
+ "{product_name:M4R,product_ver:4.0.0,special_id:5A470000}\n",
+ .part_trail = 0x00,
+ .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
+
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x40000},
+ {"firmware", 0x40000, 0xf60000},
+ {"default-mac", 0xfa0000, 0x00300},
+ {"device-id", 0xfa0300, 0x00100},
+ {"product-info", 0xfa0400, 0x0fc00},
+ {"group-info", 0xfb0000, 0x04000},
+ {"user-config", 0xfb4000, 0x0c000},
+ {"device-config", 0xfc0000, 0x10000},
+ {"default-config", 0xfd0000, 0x10000},
+ {"partition-table", 0xfe0000, 0x00800},
+ {"soft-version", 0xfe0800, 0x00100},
+ {"support-list", 0xfe0900, 0x00200},
+ {"profile", 0xfe0b00, 0x03000},
+ {"extra-para", 0xfe3b00, 0x00100},
+ {"radio", 0xff0000, 0x10000},
+ {NULL, 0, 0}
+ },
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "file-system",
+ },
+
+ /** Firmware layout for the Deco S4 v2 */
+ {
+ .id = "DECO-S4-V2",
+ .vendor = "",
+ .support_list =
+ "SupportList:\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:55530000}\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:45550000}\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:43410000}\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:4A500000}\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:41550000}\n"
+ "{product_name:S4,product_ver:1.0.0,special_id:4B520000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:55530000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:45550000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:43410000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:4A500000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:41550000}\n"
+ "{product_name:S4,product_ver:2.0.0,special_id:4B520000}\n",
+ .part_trail = 0x00,
+ .soft_ver = SOFT_VER_DEFAULT,
+
+ .partitions = {
+ {"fs-uboot", 0x00000, 0x80000},
+ {"product-info", 0x80000, 0x05000},
+ {"default-mac", 0x85000, 0x01000},
+ {"device-id", 0x86000, 0x01000},
+ {"support-list", 0x87000, 0x10000},
+ {"user-config", 0xa7000, 0x10000},
+ {"device-config", 0xb7000, 0x10000},
+ {"group-info", 0xc7000, 0x10000},
+ {"partition-table", 0xd7000, 0x02000},
+ {"soft-version", 0xd9000, 0x10000},
+ {"profile", 0xe9000, 0x10000},
+ {"default-config", 0xf9000, 0x10000},
+ {"url-sig", 0x1e0000, 0x10000},
+ {"radio", 0x1f0000, 0x10000},
+ {"firmware", 0x200000, 0xe00000},
+ {NULL, 0, 0}
+ },
+ .first_sysupgrade_partition = "os-image",
+ .last_sysupgrade_partition = "file-system",
+ },
+
/** Firmware layout for the EAP120 */
{
.id = "EAP120",
"SupportList:\r\n"
"EAP225(TP-Link|UN|AC1350-D):3.0\r\n"
"EAP225(TP-Link|UN|AC1350-D):3.20\r\n"
- "EAP225(TP-Link|UN|AC1350-D):4.0\r\n"
"EAP225(TP-Link|UN|AC1350-D):4.0 CA\r\n"
- "EAP225-Outdoor(TP-Link|UN|AC1350-D):1.0\r\n"
- "EAP225-Outdoor(TP-Link|UN|AC1350-D):3.0\r\n"
- "EAP225-Outdoor(TP-Link|UN|AC1350-D):3.0 CA,JP\r\n",
+ "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n"
+ "EAP225-Outdoor(TP-Link|UN|AC1200-D):3.0 CA,JP\r\n",
.part_trail = PART_TRAIL_NONE,
.soft_ver = SOFT_VER_DEFAULT,
.soft_ver_compat_level = 1,
}
/** Frees an image partition */
-static void free_image_partition(struct image_partition_entry entry) {
- free(entry.data);
+static void free_image_partition(struct image_partition_entry *entry)
+{
+ void *data = entry->data;
+
+ entry->name = NULL;
+ entry->size = 0;
+ entry->data = NULL;
+
+ free(data);
}
static time_t source_date_epoch = -1;
strcasecmp(info->id, "ARCHER-C60-V3") == 0 ||
strcasecmp(info->id, "ARCHER-C6U-V1") == 0 ||
strcasecmp(info->id, "ARCHER-C6-V3") == 0 ||
+ strcasecmp(info->id, "DECO-M4R-V4") == 0 ||
strcasecmp(info->id, "MR70X") == 0 ||
strcasecmp(info->id, "TLWR1043NV5") == 0) {
const uint8_t extra_para[2] = {0x01, 0x00};
free(image);
for (i = 0; parts[i].name; i++)
- free_image_partition(parts[i]);
+ free_image_partition(&parts[i]);
}
/** Usage output */
}
/** read the partition table into struct flash_partition_entry */
+enum PARTITION_TABLE_TYPE {
+ PARTITION_TABLE_FWUP,
+ PARTITION_TABLE_FLASH,
+};
+
static int read_partition_table(
FILE *file, long offset,
struct flash_partition_entry *entries, size_t max_entries,
/* TODO: search for the partition table */
switch(type) {
- case 0:
- parthdr = fwuphdr;
- break;
- case 1:
- parthdr = flashhdr;
- break;
- default:
- error(1, 0, "Invalid partition table");
+ case PARTITION_TABLE_FWUP:
+ parthdr = fwuphdr;
+ break;
+ case PARTITION_TABLE_FLASH:
+ parthdr = flashhdr;
+ break;
+ default:
+ error(1, 0, "Invalid partition table");
}
if (fseek(file, offset, SEEK_SET) < 0)
input_file = fopen(input, "rb");
- if (read_partition_table(input_file, firmware_offset, entries, 16, 0) != 0) {
+ if (read_partition_table(input_file, firmware_offset, entries, 16, PARTITION_TABLE_FWUP) != 0)
error(1, 0, "Error can not read the partition table (fwup-ptn)");
- }
for (size_t i = 0; i < max_entries; i++) {
if (entries[i].name == NULL &&
fp = fopen(input, "r");
- if (read_partition_table(fp, 0x1014, pointers, MAX_PARTITIONS, 0)) {
+ if (read_partition_table(fp, 0x1014, pointers, MAX_PARTITIONS, PARTITION_TABLE_FWUP))
error(1, 0, "Error can not read the partition table (fwup-ptn)");
- }
printf("Firmware image partitions:\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
e = find_partition(pointers, MAX_PARTITIONS, "partition-table", NULL);
if (e) {
+ size_t flash_table_offset = 0x1014 + e->base + 4;
struct flash_partition_entry parts[MAX_PARTITIONS] = { };
- if (read_partition_table(fp, 0x1014 + e->base + 4, parts, MAX_PARTITIONS, 1)) {
+ if (read_partition_table(fp, flash_table_offset, parts, MAX_PARTITIONS, PARTITION_TABLE_FLASH))
error(1, 0, "Error can not read the partition table (partition)");
- }
printf("\n[Partition table]\n");
printf("%-8s %-8s %s\n", "base", "size", "name");
struct flash_partition_entry *fwup_partition_table = NULL;
size_t firmware_offset = 0x1014;
FILE *input_file, *output_file;
+ size_t flash_table_offset;
struct stat statbuf;
"partition-table", "Error can not find partition-table partition");
/* the flash partition table has a 0x00000004 magic haeder */
- if (read_partition_table(input_file, firmware_offset + fwup_partition_table->base + 4, flash, MAX_PARTITIONS, 1) != 0)
+ flash_table_offset = firmware_offset + fwup_partition_table->base + 4;
+ if (read_partition_table(input_file, flash_table_offset, flash, MAX_PARTITIONS, PARTITION_TABLE_FLASH) != 0)
error(1, 0, "Error can not read the partition table (flash)");
flash_os_image = find_partition(flash, MAX_PARTITIONS,