uint32_t size;
};
+/** Partition trailing padding definitions
+ * Values 0x00 to 0xff are reserved to indicate the padding value
+ * Values from 0x100 are reserved to indicate other behaviour */
+enum partition_trail_value {
+ PART_TRAIL_00 = 0x00,
+ PART_TRAIL_FF = 0xff,
+ PART_TRAIL_MAX = 0xff,
+ PART_TRAIL_NONE = 0x100
+};
+
/** Firmware layout description */
struct device_info {
const char *id;
const char *vendor;
const char *support_list;
- char support_trail;
+ enum partition_trail_value part_trail;
const char *soft_ver;
uint32_t soft_ver_compat_level;
struct flash_partition_entry partitions[MAX_PARTITIONS+1];
"CPE220(TP-LINK|UN|N300-2):1.1\r\n"
"CPE220(TP-LINK|US|N300-2):1.1\r\n"
"CPE220(TP-LINK|EU|N300-2):1.1\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE210(TP-LINK|UN|N300-2):2.0\r\n"
"CPE210(TP-LINK|EU|N300-2):2.0\r\n"
"CPE210(TP-LINK|US|N300-2):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE210(TP-LINK|EU|N300-2|45550000):3.20\r\n"
"CPE210(TP-LINK|UN|N300-2|00000000):3.20\r\n"
"CPE210(TP-LINK|US|N300-2|55530000):3.20\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE220(TP-LINK|UN|N300-2):2.0\r\n"
"CPE220(TP-LINK|EU|N300-2):2.0\r\n"
"CPE220(TP-LINK|US|N300-2):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE220(TP-LINK|UN|N300-2):3.0\r\n"
"CPE220(TP-LINK|EU|N300-2):3.0\r\n"
"CPE220(TP-LINK|US|N300-2):3.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE520(TP-LINK|UN|N300-5):1.1\r\n"
"CPE520(TP-LINK|US|N300-5):1.1\r\n"
"CPE520(TP-LINK|EU|N300-5):1.1\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE510(TP-LINK|UN|N300-5):2.0\r\n"
"CPE510(TP-LINK|EU|N300-5):2.0\r\n"
"CPE510(TP-LINK|US|N300-5):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE510(TP-LINK|UN|N300-5):3.0\r\n"
"CPE510(TP-LINK|EU|N300-5):3.0\r\n"
"CPE510(TP-LINK|US|N300-5):3.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE610(TP-LINK|UN|N300-5):1.0\r\n"
"CPE610(TP-LINK|EU|N300-5):1.0\r\n"
"CPE610(TP-LINK|US|N300-5):1.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"CPE610(TP-LINK|UN|N300-5):2.0\r\n"
"CPE610(TP-LINK|EU|N300-5):2.0\r\n"
"CPE610(TP-LINK|US|N300-5):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"WBS210(TP-LINK|UN|N300-2):1.20\r\n"
"WBS210(TP-LINK|US|N300-2):1.20\r\n"
"WBS210(TP-LINK|EU|N300-2):1.20\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"WBS210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
"WBS210(TP-LINK|US|N300-2|55530000):2.0\r\n"
"WBS210(TP-LINK|EU|N300-2|45550000):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"WBS510(TP-LINK|US|N300-5):1.20\r\n"
"WBS510(TP-LINK|EU|N300-5):1.20\r\n"
"WBS510(TP-LINK|CA|N300-5):1.20\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
"WBS510(TP-LINK|US|N300-5|55530000):2.0\r\n"
"WBS510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
"WBS510(TP-LINK|CA|N300-5|43410000):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\r\n"
"{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/**
"{product_name:Archer A7,product_ver:5.0.0,special_id:43410000}\n"
"{product_name:Archer A7,product_ver:5.0.0,special_id:4A500000}\n"
"{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
/* We're using a dynamic kernel/rootfs split here */
"{product_name:ArcherC2,product_ver:3.0.0,special_id:00000000}\n"
"{product_name:ArcherC2,product_ver:3.0.0,special_id:55530000}\n"
"{product_name:ArcherC2,product_ver:3.0.0,special_id:45550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:3.0.1\n",
/** We're using a dynamic kernel/rootfs split here */
"{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
"{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
"{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
/* We're using a dynamic kernel/rootfs split here */
"{product_name:Archer C58,product_ver:1.0.0,special_id:00000000}\r\n"
"{product_name:Archer C58,product_ver:1.0.0,special_id:45550000}\r\n"
"{product_name:Archer C58,product_ver:1.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
.partitions = {
"{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
"{product_name:Archer C59,product_ver:1.0.0,special_id:52550000}\r\n"
"{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
/* We're using a dynamic kernel/rootfs split here */
"{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
"{product_name:Archer C59,product_ver:2.0.0,special_id:45550000}\r\n"
"{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:2.0.0 Build 20161206 rel.7303\n",
/** We're using a dynamic kernel/rootfs split here */
"{product_name:Archer C6,product_ver:2.0.0,special_id:45550000}\r\n"
"{product_name:Archer C6,product_ver:2.0.0,special_id:52550000}\r\n"
"{product_name:Archer C6,product_ver:2.0.0,special_id:4A500000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.9.1\n",
.partitions = {
"{product_name:Archer A6,product_ver:2.0.0,special_id:55530000}\n"
"{product_name:Archer A6,product_ver:2.0.0,special_id:54570000}\n"
"{product_name:Archer C6,product_ver:2.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.9.1\n",
.partitions = {
"{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
"{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
"{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
.partitions = {
"{product_name:Archer C60,product_ver:2.0.0,special_id:42520000}\r\n"
"{product_name:Archer C60,product_ver:2.0.0,special_id:45550000}\r\n"
"{product_name:Archer C60,product_ver:2.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:2.0.0\n",
.partitions = {
"{product_name:Archer C60,product_ver:3.0.0,special_id:42520000}\r\n"
"{product_name:Archer C60,product_ver:3.0.0,special_id:45550000}\r\n"
"{product_name:Archer C60,product_ver:3.0.0,special_id:55530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:3.0.0\n",
.partitions = {
"{product_name:ArcherC5,product_ver:2.0.0,special_id:00000000}\r\n"
"{product_name:ArcherC5,product_ver:2.0.0,special_id:55530000}\r\n"
"{product_name:ArcherC5,product_ver:2.0.0,special_id:4A500000}\r\n", /* JP version */
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:Archer C7,product_ver:4.0.0,special_id:54570000}\n"
"{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
"{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
/* We're using a dynamic kernel/rootfs split here */
"{product_name:Archer C7,product_ver:5.0.0,special_id:52550000}\n"
"{product_name:Archer C7,product_ver:5.0.0,special_id:4B520000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
/* We're using a dynamic kernel/rootfs split here */
"{product_name:ArcherC9,"
"product_ver:1.0.0,"
"special_id:00000000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\r\n"
"EAP120(TP-LINK|UN|N300-2):1.0\r\n",
- .support_trail = '\xff',
+ .part_trail = 0xff,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\r\n"
"EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n",
- .support_trail = '\xff',
+ .part_trail = PART_TRAIL_NONE,
.soft_ver = NULL,
.soft_ver_compat_level = 1,
.support_list =
"SupportList:\r\n"
"EAP225(TP-Link|UN|AC1350-D):3.0\r\n",
- .support_trail = '\xff',
+ .part_trail = PART_TRAIL_NONE,
.soft_ver = NULL,
.soft_ver_compat_level = 1,
.support_list =
"SupportList:\r\n"
"EAP225-Wall(TP-Link|UN|AC1200-D):2.0\r\n",
- .support_trail = '\xff',
+ .part_trail = PART_TRAIL_NONE,
.soft_ver = NULL,
.soft_ver_compat_level = 1,
.support_list =
"SupportList:\r\n"
"EAP245(TP-LINK|UN|AC1750-D):1.0\r\n",
- .support_trail = '\xff',
+ .part_trail = PART_TRAIL_NONE,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\r\n"
"EAP245(TP-Link|UN|AC1750-D):3.0\r\n",
- .support_trail = '\xff',
+ .part_trail = PART_TRAIL_NONE,
.soft_ver = NULL,
.soft_ver_compat_level = 1,
"{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
"{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
"{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/**
"{product_name:TL-WA855RE,product_ver:1.0.0,special_id:43410000}\n"
"{product_name:TL-WA855RE,product_ver:1.0.0,special_id:41550000}\n"
"{product_name:TL-WA855RE,product_ver:1.0.0,special_id:52550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\n"
"{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:45550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:41550000}\n"
"{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:44450000}\n"
"{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:41550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
.support_list =
"SupportList:\n"
"{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:45550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"SupportList:\n"
"{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
"{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.0.0\n",
.partitions = {
{"factory-boot", 0x00000, 0x20000},
.support_list =
"SupportList:\n"
"{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
"SupportList:\n"
"{product_name:TL-WR902AC,product_ver:1.0.0,special_id:45550000}\n"
"{product_name:TL-WR902AC,product_ver:1.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/**
"SupportList:\r\n"
"{product_name:TL-WR942N,product_ver:1.0.0,special_id:00000000}\r\n"
"{product_name:TL-WR942N,product_ver:1.0.0,special_id:52550000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:RE200,product_ver:2.0.0,special_id:52550000}\n"
"{product_name:RE200,product_ver:2.0.0,special_id:54570000}\n"
"{product_name:RE200,product_ver:2.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:RE200,product_ver:3.0.0,special_id:52550000}\n"
"{product_name:RE200,product_ver:3.0.0,special_id:54570000}\n"
"{product_name:RE200,product_ver:3.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:RE200,product_ver:4.0.0,special_id:45530000}\n"
"{product_name:RE200,product_ver:4.0.0,special_id:49440000}\n"
"{product_name:RE200,product_ver:4.0.0,special_id:45470000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = "soft_ver:1.1.0\n",
.partitions = {
"{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n"
"{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n"
"{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:RE305,product_ver:1.0.0,special_id:4b520000}\n"
"{product_name:RE305,product_ver:1.0.0,special_id:41550000}\n"
"{product_name:RE305,product_ver:1.0.0,special_id:43410000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
.partitions = {
"{product_name:RE350,product_ver:1.0.0,special_id:43410000}\n"
"{product_name:RE350,product_ver:1.0.0,special_id:4b520000}\n"
"{product_name:RE350,product_ver:1.0.0,special_id:4a500000}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/** We're using a dynamic kernel/rootfs split here */
.support_list =
"SupportList:\n"
"{product_name:RE350K,product_ver:1.0.0,special_id:00000000,product_region:US}\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/** We're using a dynamic kernel/rootfs split here */
"{product_name:RE355,product_ver:1.0.0,special_id:41550000}\r\n"
"{product_name:RE355,product_ver:1.0.0,special_id:4B520000}\r\n"
"{product_name:RE355,product_ver:1.0.0,special_id:55534100}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
"{product_name:RE450,product_ver:1.0.0,special_id:41550000}\r\n"
"{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
"{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/** We're using a dynamic kernel/rootfs split here */
"{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n"
"{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n"
"{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
"{product_name:RE450,product_ver:3.0.0,special_id:41530000}\r\n"
"{product_name:RE450,product_ver:3.0.0,special_id:4B520000}\r\n"
"{product_name:RE450,product_ver:3.0.0,special_id:42520000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
"{product_name:RE500,product_ver:1.0.0,special_id:43410000}\r\n"
"{product_name:RE500,product_ver:1.0.0,special_id:41550000}\r\n"
"{product_name:RE500,product_ver:1.0.0,special_id:41530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
"{product_name:RE650,product_ver:1.0.0,special_id:43410000}\r\n"
"{product_name:RE650,product_ver:1.0.0,special_id:41550000}\r\n"
"{product_name:RE650,product_ver:1.0.0,special_id:41530000}\r\n",
- .support_trail = '\x00',
+ .part_trail = 0x00,
.soft_ver = NULL,
/* We're using a dynamic kernel/rootfs split here */
buf[3] = val;
}
+static inline bool meta_partition_should_pad(enum partition_trail_value pv)
+{
+ return (pv >= 0) && (pv <= PART_TRAIL_MAX);
+}
+
/** Allocate a padded meta partition with a correctly initialised header
* If the `data` pointer is NULL, then the required space is only allocated,
* otherwise `data_len` bytes will be copied from `data` into the partition
* entry. */
static struct image_partition_entry init_meta_partition_entry(
const char *name, const void *data, uint32_t data_len,
- uint8_t pad_value)
+ enum partition_trail_value pad_value)
{
- uint32_t total_len = sizeof(struct meta_header) + data_len + 1;
+ uint32_t total_len = sizeof(struct meta_header) + data_len;
+ if (meta_partition_should_pad(pad_value))
+ total_len += 1;
+
struct image_partition_entry entry = {
.name = name,
.size = total_len,
if (data)
memcpy(entry.data+sizeof(*header), data, data_len);
- entry.data[total_len - 1] = pad_value;
+ if (meta_partition_should_pad(pad_value))
+ entry.data[total_len - 1] = (uint8_t) pad_value;
return entry;
}
if (info->soft_ver) {
uint32_t len = strlen(info->soft_ver) + 1;
return init_meta_partition_entry("soft-version",
- info->soft_ver, len, 0);
+ info->soft_ver, len, info->part_trail);
}
time_t t;
if (info->soft_ver_compat_level == 0)
return init_meta_partition_entry("soft-version", &s,
- (uint8_t *)(&s.compat_level) - (uint8_t *)(&s), 0xff);
+ (uint8_t *)(&s.compat_level) - (uint8_t *)(&s),
+ info->part_trail);
else
return init_meta_partition_entry("soft-version", &s,
- sizeof(s), 0xff);
+ sizeof(s), info->part_trail);
}
/** Generates the support-list partition */
{
uint32_t len = strlen(info->support_list);
return init_meta_partition_entry("support-list", info->support_list,
- len, info->support_trail);
+ len, info->part_trail);
}
/** Partition with extra-para data */
static struct image_partition_entry make_extra_para(
const struct device_info *info, const uint8_t *extra_para, size_t len)
{
- return init_meta_partition_entry("extra-para", extra_para, len, 0x00);
+ return init_meta_partition_entry("extra-para", extra_para, len,
+ info->part_trail);
}
/** Creates a new image partition with an arbitrary name from a file */