tplink-safeloader: add support for TP-Link Archer A7 v5 (RU)
[openwrt/openwrt.git] / tools / firmware-utils / src / tplink-safeloader.c
index 41b3b8aff992de0b22db6a0729bf575980fb49a2..b9dfad51a6ddb5d7feac7871ed5af94fe4072f8c 100644 (file)
@@ -70,12 +70,22 @@ struct flash_partition_entry {
        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];
@@ -135,7 +145,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -175,7 +185,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -217,7 +227,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -258,7 +268,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -298,7 +308,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -337,7 +347,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -379,7 +389,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -420,8 +430,11 @@ static struct device_info boards[] = {
                        "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n"
                        "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',
+                       "CPE510(TP-LINK|US|N300-5):3.0\r\n"
+                       "CPE510(TP-LINK|UN|N300-5|00000000):3.20\r\n"
+                       "CPE510(TP-LINK|US|N300-5|55530000):3.20\r\n"
+                       "CPE510(TP-LINK|EU|N300-5|45550000):3.20\r\n",
+               .part_trail = 0xff,
                .soft_ver = NULL,
 
                .partitions = {
@@ -461,7 +474,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -501,7 +514,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -533,7 +546,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -565,7 +578,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -598,7 +611,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -631,7 +644,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -655,6 +668,50 @@ static struct device_info boards[] = {
                .last_sysupgrade_partition = "support-list",
        },
 
+       /** Firmware layout for the AD7200 */
+       {
+               .id = "AD7200",
+               .vendor = "",
+               .support_list =
+                       "SupportList:\r\n"
+                       "{product_name:Talon AD7200,product_ver:1.0.0,special_id:00000000}\r\n",
+               .part_trail = 0x00,
+               .soft_ver = NULL,
+
+               .partitions = {
+                       {"SBL1", 0x00000, 0x20000},
+                       {"MIBIB", 0x20000, 0x20000},
+                       {"SBL2", 0x40000, 0x20000},
+                       {"SBL3", 0x60000, 0x30000},
+                       {"DDRCONFIG", 0x90000, 0x10000},
+                       {"SSD", 0xa0000, 0x10000},
+                       {"TZ", 0xb0000, 0x30000},
+                       {"RPM", 0xe0000, 0x20000},
+                       {"fs-uboot", 0x100000, 0x70000},
+                       {"uboot-env", 0x170000, 0x40000},
+                       {"radio", 0x1b0000, 0x40000},
+                       {"os-image", 0x1f0000, 0x400000},
+                       {"file-system", 0x5f0000, 0x1900000},
+                       {"default-mac", 0x1ef0000, 0x00200},
+                       {"pin", 0x1ef0200, 0x00200},
+                       {"device-id", 0x1ef0400, 0x00200},
+                       {"product-info", 0x1ef0600, 0x0fa00},
+                       {"partition-table", 0x1f00000, 0x10000},
+                       {"soft-version", 0x1f10000, 0x10000},
+                       {"support-list", 0x1f20000, 0x10000},
+                       {"profile", 0x1f30000, 0x10000},
+                       {"default-config", 0x1f40000, 0x10000},
+                       {"user-config", 0x1f50000, 0x40000},
+                       {"qos-db", 0x1f90000, 0x40000},
+                       {"usb-config", 0x1fd0000, 0x10000},
+                       {"log", 0x1fe0000, 0x20000},
+                       {NULL, 0, 0}
+               },
+
+               .first_sysupgrade_partition = "os-image",
+               .last_sysupgrade_partition = "file-system"
+       },
+
        /** Firmware layout for the C2600 */
        {
                .id     = "C2600",
@@ -662,7 +719,7 @@ static struct device_info boards[] = {
                .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,
 
                /**
@@ -712,8 +769,9 @@ static struct device_info boards[] = {
                        "{product_name:Archer A7,product_ver:5.0.0,special_id:55530000}\n"
                        "{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',
+                       "{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n"
+                       "{product_name:Archer A7,product_ver:5.0.0,special_id:52550000}\n",
+               .part_trail = 0x00,
                .soft_ver = "soft_ver:1.0.0\n",
 
                /* We're using a dynamic kernel/rootfs split here */
@@ -751,7 +809,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -789,7 +847,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -828,7 +886,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -863,7 +921,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -901,7 +959,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -941,7 +999,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -976,7 +1034,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1011,7 +1069,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1045,7 +1103,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1081,7 +1139,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1117,7 +1175,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1158,7 +1216,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -1203,7 +1261,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -1246,7 +1304,7 @@ static struct device_info boards[] = {
                        "{product_name:ArcherC9,"
                        "product_ver:1.0.0,"
                        "special_id:00000000}\n",
-               .support_trail = '\x00',
+               .part_trail = 0x00,
                .soft_ver = NULL,
 
                .partitions = {
@@ -1279,7 +1337,7 @@ static struct device_info boards[] = {
                .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 = {
@@ -1308,7 +1366,7 @@ static struct device_info boards[] = {
                .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,
 
@@ -1337,7 +1395,7 @@ static struct device_info boards[] = {
                .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,
 
@@ -1366,7 +1424,7 @@ static struct device_info boards[] = {
                .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,
 
@@ -1395,7 +1453,7 @@ static struct device_info boards[] = {
                .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 = {
@@ -1421,7 +1479,7 @@ static struct device_info boards[] = {
                .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,
 
@@ -1463,7 +1521,7 @@ static struct device_info boards[] = {
                        "{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,
 
                /**
@@ -1505,7 +1563,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1536,7 +1594,7 @@ static struct device_info boards[] = {
                .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 = {
@@ -1573,7 +1631,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1608,7 +1666,7 @@ static struct device_info boards[] = {
                .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 = {
@@ -1644,7 +1702,7 @@ static struct device_info boards[] = {
                        "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},
@@ -1678,7 +1736,7 @@ static struct device_info boards[] = {
                .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 */
@@ -1711,7 +1769,7 @@ static struct device_info boards[] = {
                        "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,
 
                /**
@@ -1747,7 +1805,7 @@ static struct device_info boards[] = {
                        "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 = {
@@ -1794,7 +1852,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1838,7 +1896,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1882,7 +1940,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1925,7 +1983,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1962,7 +2020,7 @@ static struct device_info boards[] = {
                        "{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 = {
@@ -1998,7 +2056,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2029,7 +2087,7 @@ static struct device_info boards[] = {
                .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 */
@@ -2068,7 +2126,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2106,7 +2164,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2145,7 +2203,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2184,7 +2242,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2222,7 +2280,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2259,7 +2317,7 @@ static struct device_info boards[] = {
                        "{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 */
@@ -2303,15 +2361,23 @@ static inline void put32(uint8_t *buf, uint32_t val) {
        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,
@@ -2327,7 +2393,8 @@ static struct image_partition_entry init_meta_partition_entry(
        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;
 }
@@ -2405,7 +2472,7 @@ static struct image_partition_entry make_soft_version(
        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;
@@ -2434,10 +2501,11 @@ static struct image_partition_entry make_soft_version(
 
        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 */
@@ -2446,14 +2514,15 @@ static struct image_partition_entry make_support_list(
 {
        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 */