• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/firmware-utils/src/tplink-safeloader.c

  1 // SPDX-License-Identifier: BSD-2-Clause
  2 /*
  3   Copyright (c) 2014, Matthias Schiffer <mschiffer@universe-factory.net>
  4   All rights reserved.
  5 */
  6 
  7 
  8 /*
  9    tplink-safeloader
 10 
 11    Image generation tool for the TP-LINK SafeLoader as seen on
 12    TP-LINK Pharos devices (CPE210/220/510/520)
 13 */
 14 
 15 
 16 #include <assert.h>
 17 #include <ctype.h>
 18 #include <errno.h>
 19 #include <stdbool.h>
 20 #include <stddef.h>
 21 #include <stdio.h>
 22 #include <stdint.h>
 23 #include <stdlib.h>
 24 #include <string.h>
 25 #include <time.h>
 26 #include <unistd.h>
 27 
 28 #include <arpa/inet.h>
 29 
 30 #include <sys/types.h>
 31 #include <sys/stat.h>
 32 #include <limits.h>
 33 
 34 #include "md5.h"
 35 
 36 
 37 #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
 38 
 39 
 40 #define MAX_PARTITIONS  32
 41 
 42 /** An image partition table entry */
 43 struct image_partition_entry {
 44         const char *name;
 45         size_t size;
 46         uint8_t *data;
 47 };
 48 
 49 /** A flash partition table entry */
 50 struct flash_partition_entry {
 51         const char *name;
 52         uint32_t base;
 53         uint32_t size;
 54 };
 55 
 56 /** Flash partition names table entry */
 57 struct factory_partition_names {
 58         const char *partition_table;
 59         const char *soft_ver;
 60         const char *os_image;
 61         const char *support_list;
 62         const char *file_system;
 63         const char *extra_para;
 64 };
 65 
 66 /** Partition trailing padding definitions
 67  * Values 0x00 to 0xff are reserved to indicate the padding value
 68  * Values from 0x100 are reserved to indicate other behaviour */
 69 enum partition_trail_value {
 70         PART_TRAIL_00   = 0x00,
 71         PART_TRAIL_FF   = 0xff,
 72         PART_TRAIL_MAX  = 0xff,
 73         PART_TRAIL_NONE = 0x100
 74 };
 75 
 76 /** soft-version value overwrite types
 77  * The default (for an uninitialised soft_ver field) is to use the numerical
 78  * version number "0.0.0"
 79  */
 80 enum soft_ver_type {
 81         SOFT_VER_TYPE_NUMERIC = 0,
 82         SOFT_VER_TYPE_TEXT = 1,
 83 };
 84 
 85 /** Firmware layout description */
 86 struct device_info {
 87         const char *id;
 88         const char *vendor;
 89         const char *support_list;
 90         enum partition_trail_value part_trail;
 91         struct {
 92                 enum soft_ver_type type;
 93                 union {
 94                         const char *text;
 95                         uint8_t num[3];
 96                 };
 97         } soft_ver;
 98         uint32_t soft_ver_compat_level;
 99         struct flash_partition_entry partitions[MAX_PARTITIONS+1];
100         const char *first_sysupgrade_partition;
101         const char *last_sysupgrade_partition;
102         struct factory_partition_names partition_names;
103 };
104 
105 #define SOFT_VER_TEXT(_t) {.type = SOFT_VER_TYPE_TEXT, .text = _t}
106 #define SOFT_VER_NUMERIC(_maj, _min, _patch) {  \
107                 .type = SOFT_VER_TYPE_NUMERIC,          \
108                 .num = {_maj, _min, _patch}}
109 #define SOFT_VER_DEFAULT SOFT_VER_NUMERIC(0, 0, 0)
110 
111 struct __attribute__((__packed__)) meta_header {
112         uint32_t length;
113         uint32_t zero;
114 };
115 
116 /** The content of the soft-version structure */
117 struct __attribute__((__packed__)) soft_version {
118         uint8_t pad1;
119         uint8_t version_major;
120         uint8_t version_minor;
121         uint8_t version_patch;
122         uint8_t year_hi;
123         uint8_t year_lo;
124         uint8_t month;
125         uint8_t day;
126         uint32_t rev;
127         uint32_t compat_level;
128 };
129 
130 /*
131  * Safeloader image type
132  *   Safeloader images contain a 0x14 byte preamble with image size (big endian
133  *   UINT32) and md5 checksum (16 bytes).
134  *
135  * SAFEFLOADER_TYPE_DEFAULT
136  *   Standard preamble with size including preamble length, and checksum.
137  *   Header of 0x1000 bytes, contents of which are not specified.
138  *   Payload starts at offset 0x1014.
139  *
140  * SAFELOADER_TYPE_VENDOR
141  *   Standard preamble with size including preamble length, and checksum.
142  *   Header contains up to 0x1000 bytes of vendor data, starting with a big endian
143  *   UINT32 size, followed by that number of bytes containing (text) data.
144  *   Padded with 0xFF. Payload starts at offset 0x1014.
145  *
146  * SAFELOADER_TYPE_CLOUD
147  *   Standard preamble with size including preamble length, and checksum.
148  *   Followed by the 'fw-type:Cloud' string and some (unknown) data.
149  *   Payload starts at offset 0x1014.
150  *
151  * SAFELOADER_TYPE_QNEW
152  *   Reversed order preamble, with (apparent) md5 checksum before the image
153  *   size. The size does not include the preamble length.
154  *   Header starts with 0x3C bytes, starting with the string '?NEW' (format not
155  *   understood). Then another 0x1000 bytes follow, with the data payload
156  *   starting at 0x1050.
157  */
158 enum safeloader_image_type {
159         SAFELOADER_TYPE_DEFAULT,
160         SAFELOADER_TYPE_VENDOR,
161         SAFELOADER_TYPE_CLOUD,
162         SAFELOADER_TYPE_QNEW,
163 };
164 
165 /* Internal representation of safeloader image data */
166 struct safeloader_image_info {
167         enum safeloader_image_type type;
168         size_t payload_offset;
169         struct flash_partition_entry entries[MAX_PARTITIONS];
170 };
171 
172 #define SAFELOADER_PREAMBLE_SIZE        0x14
173 #define SAFELOADER_HEADER_SIZE          0x1000
174 #define SAFELOADER_PAYLOAD_OFFSET       (SAFELOADER_PREAMBLE_SIZE + SAFELOADER_HEADER_SIZE)
175 
176 #define SAFELOADER_QNEW_HEADER_SIZE     0x3C
177 #define SAFELOADER_QNEW_PAYLOAD_OFFSET  \
178         (SAFELOADER_PREAMBLE_SIZE + SAFELOADER_QNEW_HEADER_SIZE + SAFELOADER_HEADER_SIZE)
179 
180 #define SAFELOADER_PAYLOAD_TABLE_SIZE   0x800
181 
182 static const uint8_t jffs2_eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
183 
184 
185 /**
186    Salt for the MD5 hash
187 
188    Fortunately, TP-LINK seems to use the same salt for most devices which use
189    the new image format.
190 */
191 static const uint8_t md5_salt[16] = {
192         0x7a, 0x2b, 0x15, 0xed,
193         0x9b, 0x98, 0x59, 0x6d,
194         0xe5, 0x04, 0xab, 0x44,
195         0xac, 0x2a, 0x9f, 0x4e,
196 };
197 
198 
199 /** Firmware layout table */
200 static struct device_info boards[] = {
201         /** Firmware layout for the CPE210/220 V1 */
202         {
203                 .id     = "CPE210",
204                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
205                 .support_list =
206                         "SupportList:\r\n"
207                         "CPE210(TP-LINK|UN|N300-2):1.0\r\n"
208                         "CPE210(TP-LINK|UN|N300-2):1.1\r\n"
209                         "CPE210(TP-LINK|US|N300-2):1.1\r\n"
210                         "CPE210(TP-LINK|EU|N300-2):1.1\r\n"
211                         "CPE220(TP-LINK|UN|N300-2):1.1\r\n"
212                         "CPE220(TP-LINK|US|N300-2):1.1\r\n"
213                         "CPE220(TP-LINK|EU|N300-2):1.1\r\n",
214                 .part_trail = 0xff,
215                 .soft_ver = SOFT_VER_DEFAULT,
216 
217                 .partitions = {
218                         {"fs-uboot", 0x00000, 0x20000},
219                         {"partition-table", 0x20000, 0x02000},
220                         {"default-mac", 0x30000, 0x00020},
221                         {"product-info", 0x31100, 0x00100},
222                         {"signature", 0x32000, 0x00400},
223                         {"firmware", 0x40000, 0x770000},
224                         {"soft-version", 0x7b0000, 0x00100},
225                         {"support-list", 0x7b1000, 0x00400},
226                         {"user-config", 0x7c0000, 0x10000},
227                         {"default-config", 0x7d0000, 0x10000},
228                         {"log", 0x7e0000, 0x10000},
229                         {"radio", 0x7f0000, 0x10000},
230                         {NULL, 0, 0}
231                 },
232 
233                 .first_sysupgrade_partition = "os-image",
234                 .last_sysupgrade_partition = "support-list",
235         },
236 
237         /** Firmware layout for the CPE210 V2 */
238         {
239                 .id     = "CPE210V2",
240                 .vendor = "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n",
241                 .support_list =
242                         "SupportList:\r\n"
243                         "CPE210(TP-LINK|EU|N300-2|00000000):2.0\r\n"
244                         "CPE210(TP-LINK|EU|N300-2|45550000):2.0\r\n"
245                         "CPE210(TP-LINK|EU|N300-2|55530000):2.0\r\n"
246                         "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
247                         "CPE210(TP-LINK|UN|N300-2|45550000):2.0\r\n"
248                         "CPE210(TP-LINK|UN|N300-2|55530000):2.0\r\n"
249                         "CPE210(TP-LINK|US|N300-2|55530000):2.0\r\n"
250                         "CPE210(TP-LINK|UN|N300-2):2.0\r\n"
251                         "CPE210(TP-LINK|EU|N300-2):2.0\r\n"
252                         "CPE210(TP-LINK|US|N300-2):2.0\r\n",
253                 .part_trail = 0xff,
254                 .soft_ver = SOFT_VER_DEFAULT,
255 
256                 .partitions = {
257                         {"fs-uboot", 0x00000, 0x20000},
258                         {"partition-table", 0x20000, 0x02000},
259                         {"default-mac", 0x30000, 0x00020},
260                         {"product-info", 0x31100, 0x00100},
261                         {"device-info", 0x31400, 0x00400},
262                         {"signature", 0x32000, 0x00400},
263                         {"device-id", 0x33000, 0x00100},
264                         {"firmware", 0x40000, 0x770000},
265                         {"soft-version", 0x7b0000, 0x00100},
266                         {"support-list", 0x7b1000, 0x01000},
267                         {"user-config", 0x7c0000, 0x10000},
268                         {"default-config", 0x7d0000, 0x10000},
269                         {"log", 0x7e0000, 0x10000},
270                         {"radio", 0x7f0000, 0x10000},
271                         {NULL, 0, 0}
272                 },
273 
274                 .first_sysupgrade_partition = "os-image",
275                 .last_sysupgrade_partition = "support-list",
276         },
277 
278         /** Firmware layout for the CPE210 V3 */
279         {
280                 .id     = "CPE210V3",
281                 .vendor = "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n",
282                 .support_list =
283                         "SupportList:\r\n"
284                         "CPE210(TP-LINK|EU|N300-2|45550000):3.0\r\n"
285                         "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n"
286                         "CPE210(TP-LINK|US|N300-2|55530000):3.0\r\n"
287                         "CPE210(TP-LINK|UN|N300-2):3.0\r\n"
288                         "CPE210(TP-LINK|EU|N300-2):3.0\r\n"
289                         "CPE210(TP-LINK|EU|N300-2|45550000):3.1\r\n"
290                         "CPE210(TP-LINK|UN|N300-2|00000000):3.1\r\n"
291                         "CPE210(TP-LINK|US|N300-2|55530000):3.1\r\n"
292                         "CPE210(TP-LINK|EU|N300-2|45550000):3.20\r\n"
293                         "CPE210(TP-LINK|UN|N300-2|00000000):3.20\r\n"
294                         "CPE210(TP-LINK|US|N300-2|55530000):3.20\r\n",
295                 .part_trail = 0xff,
296                 .soft_ver = SOFT_VER_DEFAULT,
297 
298                 .partitions = {
299                         {"fs-uboot", 0x00000, 0x20000},
300                         {"partition-table", 0x20000, 0x01000},
301                         {"default-mac", 0x30000, 0x00020},
302                         {"product-info", 0x31100, 0x00100},
303                         {"device-info", 0x31400, 0x00400},
304                         {"signature", 0x32000, 0x00400},
305                         {"device-id", 0x33000, 0x00100},
306                         {"firmware", 0x40000, 0x770000},
307                         {"soft-version", 0x7b0000, 0x00100},
308                         {"support-list", 0x7b1000, 0x01000},
309                         {"user-config", 0x7c0000, 0x10000},
310                         {"default-config", 0x7d0000, 0x10000},
311                         {"log", 0x7e0000, 0x10000},
312                         {"radio", 0x7f0000, 0x10000},
313                         {NULL, 0, 0}
314                 },
315 
316                 .first_sysupgrade_partition = "os-image",
317                 .last_sysupgrade_partition = "support-list",
318         },
319 
320         /** Firmware layout for the CPE220 V2 */
321         {
322                 .id     = "CPE220V2",
323                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
324                 .support_list =
325                         "SupportList:\r\n"
326                         "CPE220(TP-LINK|EU|N300-2|00000000):2.0\r\n"
327                         "CPE220(TP-LINK|EU|N300-2|45550000):2.0\r\n"
328                         "CPE220(TP-LINK|EU|N300-2|55530000):2.0\r\n"
329                         "CPE220(TP-LINK|UN|N300-2|00000000):2.0\r\n"
330                         "CPE220(TP-LINK|UN|N300-2|45550000):2.0\r\n"
331                         "CPE220(TP-LINK|UN|N300-2|55530000):2.0\r\n"
332                         "CPE220(TP-LINK|US|N300-2|55530000):2.0\r\n"
333                         "CPE220(TP-LINK|UN|N300-2):2.0\r\n"
334                         "CPE220(TP-LINK|EU|N300-2):2.0\r\n"
335                         "CPE220(TP-LINK|US|N300-2):2.0\r\n",
336                 .part_trail = 0xff,
337                 .soft_ver = SOFT_VER_DEFAULT,
338 
339                 .partitions = {
340                         {"fs-uboot", 0x00000, 0x20000},
341                         {"partition-table", 0x20000, 0x02000},
342                         {"default-mac", 0x30000, 0x00020},
343                         {"product-info", 0x31100, 0x00100},
344                         {"signature", 0x32000, 0x00400},
345                         {"firmware", 0x40000, 0x770000},
346                         {"soft-version", 0x7b0000, 0x00100},
347                         {"support-list", 0x7b1000, 0x00400},
348                         {"user-config", 0x7c0000, 0x10000},
349                         {"default-config", 0x7d0000, 0x10000},
350                         {"log", 0x7e0000, 0x10000},
351                         {"radio", 0x7f0000, 0x10000},
352                         {NULL, 0, 0}
353                 },
354 
355                 .first_sysupgrade_partition = "os-image",
356                 .last_sysupgrade_partition = "support-list",
357         },
358 
359         /** Firmware layout for the CPE220 V3 */
360         {
361                 .id     = "CPE220V3",
362                 .vendor = "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n",
363                 .support_list =
364                         "SupportList:\r\n"
365                         "CPE220(TP-LINK|EU|N300-2|00000000):3.0\r\n"
366                         "CPE220(TP-LINK|EU|N300-2|45550000):3.0\r\n"
367                         "CPE220(TP-LINK|EU|N300-2|55530000):3.0\r\n"
368                         "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n"
369                         "CPE220(TP-LINK|UN|N300-2|45550000):3.0\r\n"
370                         "CPE220(TP-LINK|UN|N300-2|55530000):3.0\r\n"
371                         "CPE220(TP-LINK|US|N300-2|55530000):3.0\r\n"
372                         "CPE220(TP-LINK|UN|N300-2):3.0\r\n"
373                         "CPE220(TP-LINK|EU|N300-2):3.0\r\n"
374                         "CPE220(TP-LINK|US|N300-2):3.0\r\n",
375                 .part_trail = 0xff,
376                 .soft_ver = SOFT_VER_DEFAULT,
377 
378                 .partitions = {
379                         {"fs-uboot", 0x00000, 0x20000},
380                         {"partition-table", 0x20000, 0x02000},
381                         {"default-mac", 0x30000, 0x00020},
382                         {"product-info", 0x31100, 0x00100},
383                         {"device-info", 0x31400, 0x00400},
384                         {"signature", 0x32000, 0x00400},
385                         {"device-id", 0x33000, 0x00100},
386                         {"firmware", 0x40000, 0x770000},
387                         {"soft-version", 0x7b0000, 0x00100},
388                         {"support-list", 0x7b1000, 0x01000},
389                         {"user-config", 0x7c0000, 0x10000},
390                         {"default-config", 0x7d0000, 0x10000},
391                         {"log", 0x7e0000, 0x10000},
392                         {"radio", 0x7f0000, 0x10000},
393                         {NULL, 0, 0}
394                 },
395 
396                 .first_sysupgrade_partition = "os-image",
397                 .last_sysupgrade_partition = "support-list",
398         },
399 
400         /** Firmware layout for the CPE510/520 V1 */
401         {
402                 .id     = "CPE510",
403                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
404                 .support_list =
405                         "SupportList:\r\n"
406                         "CPE510(TP-LINK|UN|N300-5):1.0\r\n"
407                         "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
408                         "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
409                         "CPE510(TP-LINK|US|N300-5):1.1\r\n"
410                         "CPE510(TP-LINK|CA|N300-5):1.1\r\n"
411                         "CPE510(TP-LINK|EU|N300-5):1.1\r\n"
412                         "CPE520(TP-LINK|UN|N300-5):1.1\r\n"
413                         "CPE520(TP-LINK|US|N300-5):1.1\r\n"
414                         "CPE520(TP-LINK|EU|N300-5):1.1\r\n",
415                 .part_trail = 0xff,
416                 .soft_ver = SOFT_VER_DEFAULT,
417 
418                 .partitions = {
419                         {"fs-uboot", 0x00000, 0x20000},
420                         {"partition-table", 0x20000, 0x02000},
421                         {"default-mac", 0x30000, 0x00020},
422                         {"product-info", 0x31100, 0x00100},
423                         {"signature", 0x32000, 0x00400},
424                         {"firmware", 0x40000, 0x770000},
425                         {"soft-version", 0x7b0000, 0x00100},
426                         {"support-list", 0x7b1000, 0x00400},
427                         {"user-config", 0x7c0000, 0x10000},
428                         {"default-config", 0x7d0000, 0x10000},
429                         {"log", 0x7e0000, 0x10000},
430                         {"radio", 0x7f0000, 0x10000},
431                         {NULL, 0, 0}
432                 },
433 
434                 .first_sysupgrade_partition = "os-image",
435                 .last_sysupgrade_partition = "support-list",
436         },
437 
438         /** Firmware layout for the CPE510 V2 */
439         {
440                 .id     = "CPE510V2",
441                 .vendor = "CPE510(TP-LINK|UN|N300-5):2.0\r\n",
442                 .support_list =
443                         "SupportList:\r\n"
444                         "CPE510(TP-LINK|EU|N300-5|00000000):2.0\r\n"
445                         "CPE510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
446                         "CPE510(TP-LINK|EU|N300-5|55530000):2.0\r\n"
447                         "CPE510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
448                         "CPE510(TP-LINK|UN|N300-5|45550000):2.0\r\n"
449                         "CPE510(TP-LINK|UN|N300-5|55530000):2.0\r\n"
450                         "CPE510(TP-LINK|US|N300-5|00000000):2.0\r\n"
451                         "CPE510(TP-LINK|US|N300-5|45550000):2.0\r\n"
452                         "CPE510(TP-LINK|US|N300-5|55530000):2.0\r\n"
453                         "CPE510(TP-LINK|UN|N300-5):2.0\r\n"
454                         "CPE510(TP-LINK|EU|N300-5):2.0\r\n"
455                         "CPE510(TP-LINK|US|N300-5):2.0\r\n",
456                 .part_trail = 0xff,
457                 .soft_ver = SOFT_VER_DEFAULT,
458 
459                 .partitions = {
460                         {"fs-uboot", 0x00000, 0x20000},
461                         {"partition-table", 0x20000, 0x02000},
462                         {"default-mac", 0x30000, 0x00020},
463                         {"product-info", 0x31100, 0x00100},
464                         {"signature", 0x32000, 0x00400},
465                         {"firmware", 0x40000, 0x770000},
466                         {"soft-version", 0x7b0000, 0x00100},
467                         {"support-list", 0x7b1000, 0x00400},
468                         {"user-config", 0x7c0000, 0x10000},
469                         {"default-config", 0x7d0000, 0x10000},
470                         {"log", 0x7e0000, 0x10000},
471                         {"radio", 0x7f0000, 0x10000},
472                         {NULL, 0, 0}
473                 },
474 
475                 .first_sysupgrade_partition = "os-image",
476                 .last_sysupgrade_partition = "support-list",
477         },
478 
479         /** Firmware layout for the CPE510 V3 */
480         {
481                 .id     = "CPE510V3",
482                 .vendor = "CPE510(TP-LINK|UN|N300-5):3.0\r\n",
483                 .support_list =
484                         "SupportList:\r\n"
485                         "CPE510(TP-LINK|EU|N300-5|00000000):3.0\r\n"
486                         "CPE510(TP-LINK|EU|N300-5|45550000):3.0\r\n"
487                         "CPE510(TP-LINK|EU|N300-5|55530000):3.0\r\n"
488                         "CPE510(TP-LINK|UN|N300-5|00000000):3.0\r\n"
489                         "CPE510(TP-LINK|UN|N300-5|45550000):3.0\r\n"
490                         "CPE510(TP-LINK|UN|N300-5|55530000):3.0\r\n"
491                         "CPE510(TP-LINK|US|N300-5|00000000):3.0\r\n"
492                         "CPE510(TP-LINK|US|N300-5|45550000):3.0\r\n"
493                         "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n"
494                         "CPE510(TP-LINK|UN|N300-5):3.0\r\n"
495                         "CPE510(TP-LINK|EU|N300-5):3.0\r\n"
496                         "CPE510(TP-LINK|US|N300-5):3.0\r\n"
497                         "CPE510(TP-LINK|UN|N300-5|00000000):3.20\r\n"
498                         "CPE510(TP-LINK|US|N300-5|55530000):3.20\r\n"
499                         "CPE510(TP-LINK|EU|N300-5|45550000):3.20\r\n",
500                 .part_trail = 0xff,
501                 .soft_ver = SOFT_VER_DEFAULT,
502 
503                 .partitions = {
504                         {"fs-uboot", 0x00000, 0x20000},
505                         {"partition-table", 0x20000, 0x02000},
506                         {"default-mac", 0x30000, 0x00020},
507                         {"product-info", 0x31100, 0x00100},
508                         {"signature", 0x32000, 0x00400},
509                         {"firmware", 0x40000, 0x770000},
510                         {"soft-version", 0x7b0000, 0x00100},
511                         {"support-list", 0x7b1000, 0x00400},
512                         {"user-config", 0x7c0000, 0x10000},
513                         {"default-config", 0x7d0000, 0x10000},
514                         {"log", 0x7e0000, 0x10000},
515                         {"radio", 0x7f0000, 0x10000},
516                         {NULL, 0, 0}
517                 },
518 
519                 .first_sysupgrade_partition = "os-image",
520                 .last_sysupgrade_partition = "support-list",
521         },
522 
523         /** Firmware layout for the CPE605V1 */
524         {
525                 .id     = "CPE605V1",
526                 .vendor = "CPE605(TP-LINK|UN|N150-5):1.0\r\n",
527                 .support_list =
528                         "SupportList:\r\n"
529                         "CPE605(TP-LINK|UN|N150-5|00000000):1.0\r\n"
530                         "CPE605(TP-LINK|EU|N150-5|45550000):1.0\r\n"
531                         "CPE605(TP-LINK|US|N150-5|55530000):1.0\r\n",
532                 .part_trail = 0x00,
533                 .soft_ver = SOFT_VER_DEFAULT,
534 
535                 .partitions = {
536                         {"fs-uboot", 0x00000, 0x20000},
537                         {"partition-table", 0x20000, 0x02000},
538                         {"default-mac", 0x30000, 0x00020},
539                         {"serial-number", 0x30100, 0x00020},
540                         {"product-info", 0x31100, 0x00100},
541                         {"device-info", 0x31400, 0x00400},
542                         {"signature", 0x32000, 0x00400},
543                         {"device-id", 0x33000, 0x00100},
544                         {"firmware", 0x40000, 0x770000},
545                         {"soft-version", 0x7b0000, 0x00100},
546                         {"support-list", 0x7b1000, 0x01000},
547                         {"user-config", 0x7c0000, 0x10000},
548                         {"default-config", 0x7d0000, 0x10000},
549                         {"log", 0x7e0000, 0x10000},
550                         {"radio", 0x7f0000, 0x10000},
551                         {NULL, 0, 0}
552                 },
553 
554                 .first_sysupgrade_partition = "os-image",
555                 .last_sysupgrade_partition = "support-list",
556         },
557 
558         /** Firmware layout for the CPE610V1 */
559         {
560                 .id     = "CPE610V1",
561                 .vendor = "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n",
562                 .support_list =
563                         "SupportList:\r\n"
564                         "CPE610(TP-LINK|EU|N300-5|00000000):1.0\r\n"
565                         "CPE610(TP-LINK|EU|N300-5|45550000):1.0\r\n"
566                         "CPE610(TP-LINK|EU|N300-5|55530000):1.0\r\n"
567                         "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n"
568                         "CPE610(TP-LINK|UN|N300-5|45550000):1.0\r\n"
569                         "CPE610(TP-LINK|UN|N300-5|55530000):1.0\r\n"
570                         "CPE610(TP-LINK|US|N300-5|55530000):1.0\r\n"
571                         "CPE610(TP-LINK|UN|N300-5):1.0\r\n"
572                         "CPE610(TP-LINK|EU|N300-5):1.0\r\n"
573                         "CPE610(TP-LINK|US|N300-5):1.0\r\n",
574                 .part_trail = 0xff,
575                 .soft_ver = SOFT_VER_DEFAULT,
576 
577                 .partitions = {
578                         {"fs-uboot", 0x00000, 0x20000},
579                         {"partition-table", 0x20000, 0x02000},
580                         {"default-mac", 0x30000, 0x00020},
581                         {"product-info", 0x31100, 0x00100},
582                         {"signature", 0x32000, 0x00400},
583                         {"firmware", 0x40000, 0x770000},
584                         {"soft-version", 0x7b0000, 0x00100},
585                         {"support-list", 0x7b1000, 0x00400},
586                         {"user-config", 0x7c0000, 0x10000},
587                         {"default-config", 0x7d0000, 0x10000},
588                         {"log", 0x7e0000, 0x10000},
589                         {"radio", 0x7f0000, 0x10000},
590                         {NULL, 0, 0}
591                 },
592 
593                 .first_sysupgrade_partition = "os-image",
594                 .last_sysupgrade_partition = "support-list",
595         },
596 
597         /** Firmware layout for the CPE610V2 */
598         {
599                 .id     = "CPE610V2",
600                 .vendor = "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n",
601                 .support_list =
602                         "SupportList:\r\n"
603                         "CPE610(TP-LINK|EU|N300-5|00000000):2.0\r\n"
604                         "CPE610(TP-LINK|EU|N300-5|45550000):2.0\r\n"
605                         "CPE610(TP-LINK|EU|N300-5|55530000):2.0\r\n"
606                         "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n"
607                         "CPE610(TP-LINK|UN|N300-5|45550000):2.0\r\n"
608                         "CPE610(TP-LINK|UN|N300-5|55530000):2.0\r\n"
609                         "CPE610(TP-LINK|US|N300-5|55530000):2.0\r\n"
610                         "CPE610(TP-LINK|UN|N300-5):2.0\r\n"
611                         "CPE610(TP-LINK|EU|N300-5):2.0\r\n"
612                         "CPE610(TP-LINK|US|N300-5):2.0\r\n",
613                 .part_trail = 0xff,
614                 .soft_ver = SOFT_VER_DEFAULT,
615 
616                 .partitions = {
617                         {"fs-uboot", 0x00000, 0x20000},
618                         {"partition-table", 0x20000, 0x02000},
619                         {"default-mac", 0x30000, 0x00020},
620                         {"product-info", 0x31100, 0x00100},
621                         {"signature", 0x32000, 0x00400},
622                         {"firmware", 0x40000, 0x770000},
623                         {"soft-version", 0x7b0000, 0x00100},
624                         {"support-list", 0x7b1000, 0x00400},
625                         {"user-config", 0x7c0000, 0x10000},
626                         {"default-config", 0x7d0000, 0x10000},
627                         {"log", 0x7e0000, 0x10000},
628                         {"radio", 0x7f0000, 0x10000},
629                         {NULL, 0, 0}
630                 },
631 
632                 .first_sysupgrade_partition = "os-image",
633                 .last_sysupgrade_partition = "support-list",
634         },
635         /** Firmware layout for the CPE710 V1 */
636         {
637                 .id     = "CPE710V1",
638                 .vendor = "CPE710(TP-LINK|UN|AC866-5|00000000):1.0\r\n",
639                 .support_list =
640                         "SupportList:\r\n"
641                         "CPE710(TP-LINK|UN|AC866-5|00000000):1.0\r\n"
642                         "CPE710(TP-LINK|EU|AC866-5|45550000):1.0\r\n"
643                         "CPE710(TP-LINK|US|AC866-5|55530000):1.0\r\n"
644                         "CPE710(TP-LINK|UN|AC866-5):1.0\r\n"
645                         "CPE710(TP-LINK|EU|AC866-5):1.0\r\n"
646                         "CPE710(TP-LINK|US|AC866-5):1.0\r\n",
647                 .part_trail = 0xff,
648                 .soft_ver = SOFT_VER_DEFAULT,
649 
650                 .partitions = {
651                         {"fs-uboot", 0x00000, 0x50000},
652                         {"partition-table", 0x50000, 0x02000},
653                         {"default-mac", 0x60000, 0x00020},
654                         {"serial-number", 0x60100, 0x00020},
655                         {"product-info", 0x61100, 0x00100},
656                         {"device-info", 0x61400, 0x00400},
657                         {"signature", 0x62000, 0x00400},
658                         {"device-id", 0x63000, 0x00100},
659                         {"firmware", 0x70000, 0xf40000},
660                         {"soft-version", 0xfb0000, 0x00100},
661                         {"support-list", 0xfb1000, 0x01000},
662                         {"user-config", 0xfc0000, 0x10000},
663                         {"default-config", 0xfd0000, 0x10000},
664                         {"log", 0xfe0000, 0x10000},
665                         {"radio", 0xff0000, 0x10000},
666                         {NULL, 0, 0}
667                 },
668 
669                 .first_sysupgrade_partition = "os-image",
670                 .last_sysupgrade_partition = "support-list",
671         },
672         /** Firmware layout for the CPE710 V2 */
673         {
674                 .id     = "CPE710V2",
675                 .vendor = "CPE710(TP-LINK|UN|AC866-5|00000000):2.0\r\n",
676                 .support_list =
677                         "SupportList:\r\n"
678                         "CPE710(TP-LINK|UN|AC866-5|00000000):2.0\r\n"
679                         "CPE710(TP-LINK|EU|AC866-5|45550000):2.0\r\n"
680                         "CPE710(TP-LINK|US|AC866-5|55530000):2.0\r\n"
681                         "CPE710(TP-LINK|UN|AC866-5):2.0\r\n"
682                         "CPE710(TP-LINK|EU|AC866-5):2.0\r\n"
683                         "CPE710(TP-LINK|US|AC866-5):2.0\r\n",
684                 .part_trail = 0xff,
685                 .soft_ver = SOFT_VER_NUMERIC(1, 0, 0),
686                 .soft_ver_compat_level = 1,
687 
688                 .partitions = {
689                         {"fs-uboot", 0x00000, 0x50000},
690                         {"partition-table", 0x50000, 0x02000},
691                         {"default-mac", 0x60000, 0x00020},
692                         {"serial-number", 0x60100, 0x00020},
693                         {"product-info", 0x61100, 0x00100},
694                         {"device-info", 0x61400, 0x00400},
695                         {"signature", 0x62000, 0x00400},
696                         {"device-id", 0x63000, 0x00100},
697                         {"firmware", 0x70000, 0xf40000},
698                         {"soft-version", 0xfb0000, 0x00100},
699                         {"support-list", 0xfb1000, 0x01000},
700                         {"user-config", 0xfc0000, 0x10000},
701                         {"default-config", 0xfd0000, 0x10000},
702                         {"log", 0xfe0000, 0x10000},
703                         {"radio", 0xff0000, 0x10000},
704                         {NULL, 0, 0}
705                 },
706 
707                 .first_sysupgrade_partition = "os-image",
708                 .last_sysupgrade_partition = "support-list",
709         },
710 
711         {
712                 .id     = "WBS210",
713                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
714                 .support_list =
715                         "SupportList:\r\n"
716                         "WBS210(TP-LINK|UN|N300-2):1.20\r\n"
717                         "WBS210(TP-LINK|US|N300-2):1.20\r\n"
718                         "WBS210(TP-LINK|EU|N300-2):1.20\r\n",
719                 .part_trail = 0xff,
720                 .soft_ver = SOFT_VER_DEFAULT,
721 
722                 .partitions = {
723                         {"fs-uboot", 0x00000, 0x20000},
724                         {"partition-table", 0x20000, 0x02000},
725                         {"default-mac", 0x30000, 0x00020},
726                         {"product-info", 0x31100, 0x00100},
727                         {"signature", 0x32000, 0x00400},
728                         {"firmware", 0x40000, 0x770000},
729                         {"soft-version", 0x7b0000, 0x00100},
730                         {"support-list", 0x7b1000, 0x00400},
731                         {"user-config", 0x7c0000, 0x10000},
732                         {"default-config", 0x7d0000, 0x10000},
733                         {"log", 0x7e0000, 0x10000},
734                         {"radio", 0x7f0000, 0x10000},
735                         {NULL, 0, 0}
736                 },
737 
738                 .first_sysupgrade_partition = "os-image",
739                 .last_sysupgrade_partition = "support-list",
740         },
741 
742         {
743                 .id     = "WBS210V2",
744                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
745                 .support_list =
746                         "SupportList:\r\n"
747                         "WBS210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
748                         "WBS210(TP-LINK|US|N300-2|55530000):2.0\r\n"
749                         "WBS210(TP-LINK|EU|N300-2|45550000):2.0\r\n",
750                 .part_trail = 0xff,
751                 .soft_ver = SOFT_VER_DEFAULT,
752 
753                 .partitions = {
754                         {"fs-uboot", 0x00000, 0x20000},
755                         {"partition-table", 0x20000, 0x02000},
756                         {"default-mac", 0x30000, 0x00020},
757                         {"product-info", 0x31100, 0x00100},
758                         {"signature", 0x32000, 0x00400},
759                         {"firmware", 0x40000, 0x770000},
760                         {"soft-version", 0x7b0000, 0x00100},
761                         {"support-list", 0x7b1000, 0x00400},
762                         {"user-config", 0x7c0000, 0x10000},
763                         {"default-config", 0x7d0000, 0x10000},
764                         {"log", 0x7e0000, 0x10000},
765                         {"radio", 0x7f0000, 0x10000},
766                         {NULL, 0, 0}
767                 },
768 
769                 .first_sysupgrade_partition = "os-image",
770                 .last_sysupgrade_partition = "support-list",
771         },
772 
773         {
774                 .id     = "WBS510",
775                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
776                 .support_list =
777                         "SupportList:\r\n"
778                         "WBS510(TP-LINK|UN|N300-5):1.20\r\n"
779                         "WBS510(TP-LINK|US|N300-5):1.20\r\n"
780                         "WBS510(TP-LINK|EU|N300-5):1.20\r\n"
781                         "WBS510(TP-LINK|CA|N300-5):1.20\r\n",
782                 .part_trail = 0xff,
783                 .soft_ver = SOFT_VER_DEFAULT,
784 
785                 .partitions = {
786                         {"fs-uboot", 0x00000, 0x20000},
787                         {"partition-table", 0x20000, 0x02000},
788                         {"default-mac", 0x30000, 0x00020},
789                         {"product-info", 0x31100, 0x00100},
790                         {"signature", 0x32000, 0x00400},
791                         {"firmware", 0x40000, 0x770000},
792                         {"soft-version", 0x7b0000, 0x00100},
793                         {"support-list", 0x7b1000, 0x00400},
794                         {"user-config", 0x7c0000, 0x10000},
795                         {"default-config", 0x7d0000, 0x10000},
796                         {"log", 0x7e0000, 0x10000},
797                         {"radio", 0x7f0000, 0x10000},
798                         {NULL, 0, 0}
799                 },
800 
801                 .first_sysupgrade_partition = "os-image",
802                 .last_sysupgrade_partition = "support-list",
803         },
804 
805         {
806                 .id     = "WBS510V2",
807                 .vendor = "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
808                 .support_list =
809                         "SupportList:\r\n"
810                         "WBS510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
811                         "WBS510(TP-LINK|US|N300-5|55530000):2.0\r\n"
812                         "WBS510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
813                         "WBS510(TP-LINK|CA|N300-5|43410000):2.0\r\n",
814                 .part_trail = 0xff,
815                 .soft_ver = SOFT_VER_DEFAULT,
816 
817                 .partitions = {
818                         {"fs-uboot", 0x00000, 0x20000},
819                         {"partition-table", 0x20000, 0x02000},
820                         {"default-mac", 0x30000, 0x00020},
821                         {"product-info", 0x31100, 0x00100},
822                         {"signature", 0x32000, 0x00400},
823                         {"firmware", 0x40000, 0x770000},
824                         {"soft-version", 0x7b0000, 0x00100},
825                         {"support-list", 0x7b1000, 0x00400},
826                         {"user-config", 0x7c0000, 0x10000},
827                         {"default-config", 0x7d0000, 0x10000},
828                         {"log", 0x7e0000, 0x10000},
829                         {"radio", 0x7f0000, 0x10000},
830                         {NULL, 0, 0}
831                 },
832 
833                 .first_sysupgrade_partition = "os-image",
834                 .last_sysupgrade_partition = "support-list",
835         },
836 
837         /** Firmware layout for the AD7200 */
838         {
839                 .id = "AD7200",
840                 .vendor = "",
841                 .support_list =
842                         "SupportList:\r\n"
843                         "{product_name:AD7200,product_ver:1.0.0,special_id:00000000}\r\n",
844                 .part_trail = 0x00,
845                 .soft_ver = SOFT_VER_DEFAULT,
846 
847                 .partitions = {
848                         {"SBL1", 0x00000, 0x20000},
849                         {"MIBIB", 0x20000, 0x20000},
850                         {"SBL2", 0x40000, 0x20000},
851                         {"SBL3", 0x60000, 0x30000},
852                         {"DDRCONFIG", 0x90000, 0x10000},
853                         {"SSD", 0xa0000, 0x10000},
854                         {"TZ", 0xb0000, 0x30000},
855                         {"RPM", 0xe0000, 0x20000},
856                         {"fs-uboot", 0x100000, 0x70000},
857                         {"uboot-env", 0x170000, 0x40000},
858                         {"radio", 0x1b0000, 0x40000},
859                         {"os-image", 0x1f0000, 0x400000},
860                         {"file-system", 0x5f0000, 0x1900000},
861                         {"default-mac", 0x1ef0000, 0x00200},
862                         {"pin", 0x1ef0200, 0x00200},
863                         {"device-id", 0x1ef0400, 0x00200},
864                         {"product-info", 0x1ef0600, 0x0fa00},
865                         {"partition-table", 0x1f00000, 0x10000},
866                         {"soft-version", 0x1f10000, 0x10000},
867                         {"support-list", 0x1f20000, 0x10000},
868                         {"profile", 0x1f30000, 0x10000},
869                         {"default-config", 0x1f40000, 0x10000},
870                         {"user-config", 0x1f50000, 0x40000},
871                         {"qos-db", 0x1f90000, 0x40000},
872                         {"usb-config", 0x1fd0000, 0x10000},
873                         {"log", 0x1fe0000, 0x20000},
874                         {NULL, 0, 0}
875                 },
876 
877                 .first_sysupgrade_partition = "os-image",
878                 .last_sysupgrade_partition = "file-system"
879         },
880 
881         /** Firmware layout for the C2600 */
882         {
883                 .id     = "C2600",
884                 .vendor = "",
885                 .support_list =
886                         "SupportList:\r\n"
887                         "{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
888                 .part_trail = 0x00,
889                 .soft_ver = SOFT_VER_DEFAULT,
890 
891                 /**
892                     We use a bigger os-image partition than the stock images (and thus
893                     smaller file-system), as our kernel doesn't fit in the stock firmware's
894                     2 MB os-image since kernel 4.14.
895                 */
896                 .partitions = {
897                         {"SBL1", 0x00000, 0x20000},
898                         {"MIBIB", 0x20000, 0x20000},
899                         {"SBL2", 0x40000, 0x20000},
900                         {"SBL3", 0x60000, 0x30000},
901                         {"DDRCONFIG", 0x90000, 0x10000},
902                         {"SSD", 0xa0000, 0x10000},
903                         {"TZ", 0xb0000, 0x30000},
904                         {"RPM", 0xe0000, 0x20000},
905                         {"fs-uboot", 0x100000, 0x70000},
906                         {"uboot-env", 0x170000, 0x40000},
907                         {"radio", 0x1b0000, 0x40000},
908                         {"os-image", 0x1f0000, 0x400000}, /* Stock: base 0x1f0000 size 0x200000 */
909                         {"file-system", 0x5f0000, 0x1900000}, /* Stock: base 0x3f0000 size 0x1b00000 */
910                         {"default-mac", 0x1ef0000, 0x00200},
911                         {"pin", 0x1ef0200, 0x00200},
912                         {"product-info", 0x1ef0400, 0x0fc00},
913                         {"partition-table", 0x1f00000, 0x10000},
914                         {"soft-version", 0x1f10000, 0x10000},
915                         {"support-list", 0x1f20000, 0x10000},
916                         {"profile", 0x1f30000, 0x10000},
917                         {"default-config", 0x1f40000, 0x10000},
918                         {"user-config", 0x1f50000, 0x40000},
919                         {"qos-db", 0x1f90000, 0x40000},
920                         {"usb-config", 0x1fd0000, 0x10000},
921                         {"log", 0x1fe0000, 0x20000},
922                         {NULL, 0, 0}
923                 },
924 
925                 .first_sysupgrade_partition = "os-image",
926                 .last_sysupgrade_partition = "file-system"
927         },
928 
929         /** Firmware layout for the A7-V5 */
930         {
931                 .id     = "ARCHER-A7-V5",
932                 .support_list =
933                         "SupportList:\n"
934                         "{product_name:Archer A7,product_ver:5.0.0,special_id:45550000}\n"
935                         "{product_name:Archer A7,product_ver:5.0.0,special_id:55530000}\n"
936                         "{product_name:Archer A7,product_ver:5.0.0,special_id:43410000}\n"
937                         "{product_name:Archer A7,product_ver:5.0.0,special_id:4A500000}\n"
938                         "{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n"
939                         "{product_name:Archer A7,product_ver:5.0.0,special_id:52550000}\n",
940                 .part_trail = 0x00,
941                 .soft_ver = SOFT_VER_TEXT("soft_ver:7.0.0\n"),
942 
943                 /* We're using a dynamic kernel/rootfs split here */
944                 .partitions = {
945                         {"factory-boot", 0x00000, 0x20000},
946                         {"fs-uboot", 0x20000, 0x20000},
947                         {"firmware", 0x40000, 0xec0000},        /* Stock: name os-image base 0x40000 size 0x120000 */
948                                                                 /* Stock: name file-system base 0x160000 size 0xda0000 */
949                         {"default-mac", 0xf40000, 0x00200},
950                         {"pin", 0xf40200, 0x00200},
951                         {"device-id", 0xf40400, 0x00100},
952                         {"product-info", 0xf40500, 0x0fb00},
953                         {"soft-version", 0xf50000, 0x00100},
954                         {"extra-para", 0xf51000, 0x01000},
955                         {"support-list", 0xf52000, 0x0a000},
956                         {"profile", 0xf5c000, 0x04000},
957                         {"default-config", 0xf60000, 0x10000},
958                         {"user-config", 0xf70000, 0x40000},
959                         {"certificate", 0xfb0000, 0x10000},
960                         {"partition-table", 0xfc0000, 0x10000},
961                         {"log", 0xfd0000, 0x20000},
962                         {"radio", 0xff0000, 0x10000},
963                         {NULL, 0, 0}
964                 },
965 
966                 .first_sysupgrade_partition = "os-image",
967                 .last_sysupgrade_partition = "file-system",
968         },
969 
970         /** Firmware layout for the Archer A9 v6 */
971         {
972                 .id     = "ARCHER-A9-V6",
973                 .support_list =
974                         "SupportList:\n"
975                         "{product_name:Archer A9,product_ver:6.0,special_id:55530000}\n"
976                         "{product_name:Archer A9,product_ver:6.0,special_id:45550000}\n"
977                         "{product_name:Archer A9,product_ver:6.0,special_id:52550000}\n"
978                         "{product_name:Archer A9,product_ver:6.0,special_id:4A500000}\n"
979                         "{product_name:Archer C90,product_ver:6.0,special_id:55530000}\n",
980                 .part_trail = 0x00,
981                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.1.0\n"),
982 
983                 /* We're using a dynamic kernel/rootfs split here */
984                 .partitions = {
985                         {"factory-boot", 0x00000, 0x20000},
986                         {"fs-uboot", 0x20000, 0x20000},
987                         {"partition-table", 0x40000, 0x10000},
988                         {"radio", 0x50000, 0x10000},
989                         {"default-mac", 0x60000, 0x00200},
990                         {"pin", 0x60200, 0x00200},
991                         {"device-id", 0x60400, 0x00100},
992                         {"product-info", 0x60500, 0x0fb00},
993                         {"soft-version", 0x70000, 0x01000},
994                         {"extra-para", 0x71000, 0x01000},
995                         {"support-list", 0x72000, 0x0a000},
996                         {"profile", 0x7c000, 0x04000},
997                         {"user-config", 0x80000, 0x10000},
998                         {"ap-config", 0x90000, 0x10000},
999                         {"apdef-config", 0xa0000, 0x10000},
1000                         {"router-config", 0xb0000, 0x10000},
1001                         {"firmware", 0xc0000, 0xf00000},        /* Stock: name os-image base 0xc0000 size 0x120000 */
1002                                                                 /* Stock: name file-system base 0x1e0000 size 0xde0000 */
1003                         {"log", 0xfc0000, 0x20000},
1004                         {"certificate", 0xfe0000, 0x10000},
1005                         {"default-config", 0xff0000, 0x10000},
1006                         {NULL, 0, 0}
1007                 },
1008 
1009                 .first_sysupgrade_partition = "os-image",
1010                 .last_sysupgrade_partition = "file-system",
1011         },
1012 
1013         /** Firmware layout for the Archer AX21 v4 */
1014         {
1015                 .id     = "ARCHER-AX21-V4",
1016                 .vendor = "",
1017                 .support_list =
1018                         "SupportList:\n"
1019                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:55530000}\n"
1020                         "{product_name:Archer AX23,product_ver:1.20,special_id:55530000}\n"
1021                         "{product_name:Archer AX1800,product_ver:4.6,special_id:55530000}\n"
1022                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:43410000}\n"
1023                         "{product_name:Archer AX23,product_ver:1.20,special_id:43410000}\n"
1024                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:54570000}\n"
1025                         "{product_name:Archer AX23,product_ver:1.20,special_id:54570000}\n"
1026                         "{product_name:Archer AX20,product_ver:4.6,special_id:55530000}\n"
1027                         "{product_name:Archer AX21,product_ver:4.6,special_id:55530000}\n",
1028                 .part_trail = 0x00,
1029                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.1.0\n"),
1030 
1031                 .partitions = {
1032                         {"fs-uboot", 0x00000, 0x40000},
1033                         {"os-image", 0x40000, 0x400000},
1034                         {"file-system", 0x440000, 0xb60000},
1035                         {"default-mac", 0xfa0000, 0x00200},
1036                         {"pin", 0xfa0200, 0x00100},
1037                         {"device-id", 0xfa0300, 0x00100},
1038                         {"product-info", 0xfa0400, 0x0fc00},
1039                         {"default-config", 0xfb0000, 0x08000},
1040                         {"ap-def-config", 0xfb8000, 0x08000},
1041                         {"user-config", 0xfc0000, 0x0a000},
1042                         {"ag-config", 0xfca000, 0x04000},
1043                         {"certificate", 0xfce000, 0x02000},
1044                         {"ap-config", 0xfd0000, 0x06000},
1045                         {"router-config", 0xfd6000, 0x06000},
1046                         {"favicon", 0xfdc000, 0x02000},
1047                         {"logo", 0xfde000, 0x02000},
1048                         {"partition-table", 0xfe0000, 0x00800},
1049                         {"soft-version", 0xfe0800, 0x00100},
1050                         {"support-list", 0xfe0900, 0x00400},
1051                         {"profile", 0xfe0d00, 0x03000},
1052                         {"extra-para", 0xfe3d00, 0x00100},
1053                         {"radio",0xff0000, 0x10000},
1054                 },
1055 
1056                 .first_sysupgrade_partition = "os-image",
1057                 .last_sysupgrade_partition = "file-system",
1058         },
1059 
1060         /** Firmware layout for the Archer AX23 v1 */
1061         {
1062                 .id     = "ARCHER-AX23-V1",
1063                 .vendor = "",
1064                 .support_list =
1065                         "SupportList:\n"
1066                         "{product_name:Archer AX23,product_ver:1.0,special_id:45550000}\n"
1067                         "{product_name:Archer AX23,product_ver:1.0,special_id:4A500000}\n"
1068                         "{product_name:Archer AX23,product_ver:1.0,special_id:4B520000}\n"
1069                         "{product_name:Archer AX23,product_ver:1.0,special_id:52550000}\n"
1070                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:43410000}\n"
1071                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:54570000}\n"
1072                         "{product_name:Archer AX23,product_ver:1.0.0,special_id:55530000}\n"
1073                         "{product_name:Archer AX23,product_ver:1.20,special_id:45550000}\n"
1074                         "{product_name:Archer AX23,product_ver:1.20,special_id:4A500000}\n"
1075                         "{product_name:Archer AX23,product_ver:1.20,special_id:52550000}\n"
1076                         "{product_name:Archer AX23,product_ver:1.20,special_id:55530000}\n"
1077                         "{product_name:Archer AX1800,product_ver:1.20,special_id:45550000}\n"
1078                         "{product_name:Archer AX1800,product_ver:1.20,special_id:52550000}\n",
1079                 .part_trail = 0x00,
1080                 .soft_ver = SOFT_VER_TEXT("soft_ver:3.0.3\n"),
1081 
1082                 .partitions = {
1083                         {"fs-uboot", 0x00000, 0x40000},
1084                         {"firmware", 0x40000, 0xf60000},
1085                         {"default-mac", 0xfa0000, 0x00200},
1086                         {"pin", 0xfa0200, 0x00100},
1087                         {"device-id", 0xfa0300, 0x00100},
1088                         {"product-info", 0xfa0400, 0x0fc00},
1089                         {"default-config", 0xfb0000, 0x08000},
1090                         {"ap-def-config", 0xfb8000, 0x08000},
1091                         {"user-config", 0xfc0000, 0x0a000},
1092                         {"ag-config", 0xfca000, 0x04000},
1093                         {"certificate", 0xfce000, 0x02000},
1094                         {"ap-config", 0xfd0000, 0x06000},
1095                         {"router-config", 0xfd6000, 0x06000},
1096                         {"favicon", 0xfdc000, 0x02000},
1097                         {"logo", 0xfde000, 0x02000},
1098                         {"partition-table", 0xfe0000, 0x00800},
1099                         {"soft-version", 0xfe0800, 0x00100},
1100                         {"support-list", 0xfe0900, 0x00400},
1101                         {"profile", 0xfe0d00, 0x03000},
1102                         {"extra-para", 0xfe3d00, 0x00100},
1103                         {"radio", 0xff0000, 0x10000},
1104                         {NULL, 0, 0}
1105                 },
1106                 .first_sysupgrade_partition = "os-image",
1107                 .last_sysupgrade_partition = "file-system",
1108         },
1109         /** Firmware layout for the C2v3 */
1110         {
1111                 .id     = "ARCHER-C2-V3",
1112                 .support_list =
1113                         "SupportList:\n"
1114                         "{product_name:ArcherC2,product_ver:3.0.0,special_id:00000000}\n"
1115                         "{product_name:ArcherC2,product_ver:3.0.0,special_id:55530000}\n"
1116                         "{product_name:ArcherC2,product_ver:3.0.0,special_id:45550000}\n",
1117                 .part_trail = 0x00,
1118                 .soft_ver = SOFT_VER_TEXT("soft_ver:3.0.1\n"),
1119 
1120                 /** We're using a dynamic kernel/rootfs split here */
1121 
1122                 .partitions = {
1123                         {"factory-boot", 0x00000, 0x20000},
1124                         {"fs-uboot", 0x20000, 0x10000},
1125                         {"firmware", 0x30000, 0x7a0000},
1126                         {"user-config", 0x7d0000, 0x04000},
1127                         {"default-mac", 0x7e0000, 0x00100},
1128                         {"device-id", 0x7e0100, 0x00100},
1129                         {"extra-para", 0x7e0200, 0x00100},
1130                         {"pin", 0x7e0300, 0x00100},
1131                         {"support-list", 0x7e0400, 0x00400},
1132                         {"soft-version", 0x7e0800, 0x00400},
1133                         {"product-info", 0x7e0c00, 0x01400},
1134                         {"partition-table", 0x7e2000, 0x01000},
1135                         {"profile", 0x7e3000, 0x01000},
1136                         {"default-config", 0x7e4000, 0x04000},
1137                         {"merge-config", 0x7ec000, 0x02000},
1138                         {"qos-db", 0x7ee000, 0x02000},
1139                         {"radio", 0x7f0000, 0x10000},
1140                         {NULL, 0, 0}
1141                 },
1142 
1143                 .first_sysupgrade_partition = "os-image",
1144                 .last_sysupgrade_partition = "file-system",
1145         },
1146 
1147         /** Firmware layout for the C25v1 */
1148         {
1149                 .id     = "ARCHER-C25-V1",
1150                 .support_list =
1151                         "SupportList:\n"
1152                         "{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
1153                         "{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
1154                         "{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
1155                 .part_trail = 0x00,
1156                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1157 
1158                 /* We're using a dynamic kernel/rootfs split here */
1159                 .partitions = {
1160                         {"factory-boot", 0x00000, 0x20000},
1161                         {"fs-uboot", 0x20000, 0x10000},
1162                         {"firmware", 0x30000, 0x7a0000},        /* Stock: name os-image base 0x30000 size 0x100000 */
1163                                                                 /* Stock: name file-system base 0x130000 size 0x6a0000 */
1164                         {"user-config", 0x7d0000, 0x04000},
1165                         {"default-mac", 0x7e0000, 0x00100},
1166                         {"device-id", 0x7e0100, 0x00100},
1167                         {"extra-para", 0x7e0200, 0x00100},
1168                         {"pin", 0x7e0300, 0x00100},
1169                         {"support-list", 0x7e0400, 0x00400},
1170                         {"soft-version", 0x7e0800, 0x00400},
1171                         {"product-info", 0x7e0c00, 0x01400},
1172                         {"partition-table", 0x7e2000, 0x01000},
1173                         {"profile", 0x7e3000, 0x01000},
1174                         {"default-config", 0x7e4000, 0x04000},
1175                         {"merge-config", 0x7ec000, 0x02000},
1176                         {"qos-db", 0x7ee000, 0x02000},
1177                         {"radio", 0x7f0000, 0x10000},
1178                         {NULL, 0, 0}
1179                 },
1180 
1181                 .first_sysupgrade_partition = "os-image",
1182                 .last_sysupgrade_partition = "file-system",
1183         },
1184 
1185         /** Firmware layout for the C58v1 */
1186         {
1187                 .id     = "ARCHER-C58-V1",
1188                 .vendor = "",
1189                 .support_list =
1190                         "SupportList:\r\n"
1191                         "{product_name:Archer C58,product_ver:1.0.0,special_id:00000000}\r\n"
1192                         "{product_name:Archer C58,product_ver:1.0.0,special_id:45550000}\r\n"
1193                         "{product_name:Archer C58,product_ver:1.0.0,special_id:55530000}\r\n",
1194                 .part_trail = 0x00,
1195                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1196 
1197                 .partitions = {
1198                         {"fs-uboot", 0x00000, 0x10000},
1199                         {"default-mac", 0x10000, 0x00200},
1200                         {"pin", 0x10200, 0x00200},
1201                         {"product-info", 0x10400, 0x00100},
1202                         {"partition-table", 0x10500, 0x00800},
1203                         {"soft-version", 0x11300, 0x00200},
1204                         {"support-list", 0x11500, 0x00100},
1205                         {"device-id", 0x11600, 0x00100},
1206                         {"profile", 0x11700, 0x03900},
1207                         {"default-config", 0x15000, 0x04000},
1208                         {"user-config", 0x19000, 0x04000},
1209                         {"firmware", 0x20000, 0x7c8000},
1210                         {"certyficate", 0x7e8000, 0x08000},
1211                         {"radio", 0x7f0000, 0x10000},
1212                         {NULL, 0, 0}
1213                 },
1214 
1215                 .first_sysupgrade_partition = "os-image",
1216                 .last_sysupgrade_partition = "file-system",
1217         },
1218 
1219         /** Firmware layout for the C59v1 */
1220         {
1221                 .id     = "ARCHER-C59-V1",
1222                 .vendor = "",
1223                 .support_list =
1224                         "SupportList:\r\n"
1225                         "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
1226                         "{product_name:Archer C59,product_ver:1.0.0,special_id:43410000}\r\n"
1227                         "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
1228                         "{product_name:Archer C59,product_ver:1.0.0,special_id:52550000}\r\n"
1229                         "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
1230                 .part_trail = 0x00,
1231                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1232 
1233                 /* We're using a dynamic kernel/rootfs split here */
1234                 .partitions = {
1235                         {"fs-uboot", 0x00000, 0x10000},
1236                         {"default-mac", 0x10000, 0x00200},
1237                         {"pin", 0x10200, 0x00200},
1238                         {"device-id", 0x10400, 0x00100},
1239                         {"product-info", 0x10500, 0x0fb00},
1240                         {"firmware", 0x20000, 0xe30000},
1241                         {"partition-table", 0xe50000, 0x10000},
1242                         {"soft-version", 0xe60000, 0x10000},
1243                         {"support-list", 0xe70000, 0x10000},
1244                         {"profile", 0xe80000, 0x10000},
1245                         {"default-config", 0xe90000, 0x10000},
1246                         {"user-config", 0xea0000, 0x40000},
1247                         {"usb-config", 0xee0000, 0x10000},
1248                         {"certificate", 0xef0000, 0x10000},
1249                         {"qos-db", 0xf00000, 0x40000},
1250                         {"log", 0xfe0000, 0x10000},
1251                         {"radio", 0xff0000, 0x10000},
1252                         {NULL, 0, 0}
1253                 },
1254 
1255                 .first_sysupgrade_partition = "os-image",
1256                 .last_sysupgrade_partition = "file-system",
1257         },
1258 
1259         /** Firmware layout for the C59v2 */
1260         {
1261                 .id     = "ARCHER-C59-V2",
1262                 .vendor = "",
1263                 .support_list =
1264                         "SupportList:\r\n"
1265                         "{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
1266                         "{product_name:Archer C59,product_ver:2.0.0,special_id:43410000}\r\n"
1267                         "{product_name:Archer C59,product_ver:2.0.0,special_id:45550000}\r\n"
1268                         "{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
1269                 .part_trail = 0x00,
1270                 .soft_ver = SOFT_VER_TEXT("soft_ver:2.0.0 Build 20161206 rel.7303\n"),
1271 
1272                 /** We're using a dynamic kernel/rootfs split here */
1273                 .partitions = {
1274                         {"factory-boot", 0x00000, 0x20000},
1275                         {"fs-uboot", 0x20000, 0x10000},
1276                         {"default-mac", 0x30000, 0x00200},
1277                         {"pin", 0x30200, 0x00200},
1278                         {"device-id", 0x30400, 0x00100},
1279                         {"product-info", 0x30500, 0x0fb00},
1280                         {"firmware", 0x40000, 0xe10000},
1281                         {"partition-table", 0xe50000, 0x10000},
1282                         {"soft-version", 0xe60000, 0x10000},
1283                         {"support-list", 0xe70000, 0x10000},
1284                         {"profile", 0xe80000, 0x10000},
1285                         {"default-config", 0xe90000, 0x10000},
1286                         {"user-config", 0xea0000, 0x40000},
1287                         {"usb-config", 0xee0000, 0x10000},
1288                         {"certificate", 0xef0000, 0x10000},
1289                         {"extra-para", 0xf00000, 0x10000},
1290                         {"qos-db", 0xf10000, 0x30000},
1291                         {"log", 0xfe0000, 0x10000},
1292                         {"radio", 0xff0000, 0x10000},
1293                         {NULL, 0, 0}
1294                 },
1295 
1296                 .first_sysupgrade_partition = "os-image",
1297                 .last_sysupgrade_partition = "file-system",
1298         },
1299 
1300         /** Firmware layout for the Archer C6 v2 (EU/RU/JP) */
1301         {
1302                 .id     = "ARCHER-C6-V2",
1303                 .vendor = "",
1304                 .support_list =
1305                         "SupportList:\r\n"
1306                         "{product_name:Archer A6,product_ver:2.0.0,special_id:45550000}\r\n"
1307                         "{product_name:Archer A6,product_ver:2.0.0,special_id:52550000}\r\n"
1308                         "{product_name:Archer C6,product_ver:2.0.0,special_id:45550000}\r\n"
1309                         "{product_name:Archer C6,product_ver:2.0.0,special_id:52550000}\r\n"
1310                         "{product_name:Archer C6,product_ver:2.0.0,special_id:4A500000}\r\n",
1311                 .part_trail = 0x00,
1312                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.9.1\n"),
1313 
1314                 .partitions = {
1315                         {"fs-uboot", 0x00000, 0x20000},
1316                         {"default-mac", 0x20000, 0x00200},
1317                         {"pin", 0x20200, 0x00100},
1318                         {"product-info", 0x20300, 0x00200},
1319                         {"device-id", 0x20500, 0x0fb00},
1320                         {"firmware", 0x30000, 0x7a9400},
1321                         {"soft-version", 0x7d9400, 0x00100},
1322                         {"extra-para", 0x7d9500, 0x00100},
1323                         {"support-list", 0x7d9600, 0x00200},
1324                         {"profile", 0x7d9800, 0x03000},
1325                         {"default-config", 0x7dc800, 0x03000},
1326                         {"partition-table", 0x7df800, 0x00800},
1327                         {"user-config", 0x7e0000, 0x0c000},
1328                         {"certificate", 0x7ec000, 0x04000},
1329                         {"radio", 0x7f0000, 0x10000},
1330                         {NULL, 0, 0}
1331                 },
1332 
1333                 .first_sysupgrade_partition = "os-image",
1334                 .last_sysupgrade_partition = "file-system",
1335         },
1336 
1337         /** Firmware layout for the Archer C6 v2 (US) and A6 v2 (US/TW) */
1338         {
1339                 .id     = "ARCHER-C6-V2-US",
1340                 .vendor = "",
1341                 .support_list =
1342                         "SupportList:\n"
1343                         "{product_name:Archer A6,product_ver:2.0.0,special_id:55530000}\n"
1344                         "{product_name:Archer A6,product_ver:2.0.0,special_id:54570000}\n"
1345                         "{product_name:Archer C6,product_ver:2.0.0,special_id:55530000}\n",
1346                 .part_trail = 0x00,
1347                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.9.1\n"),
1348 
1349                 .partitions = {
1350                         {"factory-boot", 0x00000, 0x20000},
1351                         {"default-mac", 0x20000, 0x00200},
1352                         {"pin", 0x20200, 0x00100},
1353                         {"product-info", 0x20300, 0x00200},
1354                         {"device-id", 0x20500, 0x0fb00},
1355                         {"fs-uboot", 0x30000, 0x20000},
1356                         {"firmware", 0x50000, 0xf89400},
1357                         {"soft-version", 0xfd9400, 0x00100},
1358                         {"extra-para", 0xfd9500, 0x00100},
1359                         {"support-list", 0xfd9600, 0x00200},
1360                         {"profile", 0xfd9800, 0x03000},
1361                         {"default-config", 0xfdc800, 0x03000},
1362                         {"partition-table", 0xfdf800, 0x00800},
1363                         {"user-config", 0xfe0000, 0x0c000},
1364                         {"certificate", 0xfec000, 0x04000},
1365                         {"radio", 0xff0000, 0x10000},
1366                         {NULL, 0, 0}
1367                 },
1368                 .first_sysupgrade_partition = "os-image",
1369                 .last_sysupgrade_partition = "file-system",
1370         },
1371         /** Firmware layout for the Archer C6 v3 */
1372         {
1373                 .id     = "ARCHER-C6-V3",
1374                 .vendor = "",
1375                 .support_list =
1376                         "SupportList:\n"
1377                         "{product_name:Archer C6,product_ver:3.20,special_id:55530000}"
1378                         "{product_name:Archer C6,product_ver:3.20,special_id:45550000}"
1379                         "{product_name:Archer C6,product_ver:3.20,special_id:52550000}"
1380                         "{product_name:Archer C6,product_ver:3.20,special_id:4A500000}"
1381                         "{product_name:Archer C6,product_ver:3.20,special_id:4B520000}"
1382                         "{product_name:Archer C6,product_ver:3.0.0,special_id:42520000}",
1383                 .part_trail = 0x00,
1384                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.9\n"),
1385 
1386                 .partitions = {
1387                         {"fs-uboot", 0x00000, 0x40000},
1388                         {"firmware", 0x40000, 0xf60000},
1389                         {"default-mac", 0xfa0000, 0x00200},
1390                         {"pin", 0xfa0200, 0x00100},
1391                         {"device-id", 0xfa0300, 0x00100},
1392                         {"product-info", 0xfa0400, 0x0fc00},
1393                         {"default-config", 0xfb0000, 0x08000},
1394                         {"ap-def-config", 0xfb8000, 0x08000},
1395                         {"user-config", 0xfc0000, 0x0a000},
1396                         {"ag-config", 0xfca000, 0x04000},
1397                         {"certificate", 0xfce000, 0x02000},
1398                         {"ap-config", 0xfd0000, 0x06000},
1399                         {"router-config", 0xfd6000, 0x06000},
1400                         {"favicon", 0xfdc000, 0x02000},
1401                         {"logo", 0xfde000, 0x02000},
1402                         {"partition-table", 0xfe0000, 0x00800},
1403                         {"soft-version", 0xfe0800, 0x00100},
1404                         {"support-list", 0xfe0900, 0x00200},
1405                         {"profile", 0xfe0b00, 0x03000},
1406                         {"extra-para", 0xfe3b00, 0x00100},
1407                         {"radio", 0xff0000, 0x10000},
1408                         {NULL, 0, 0}
1409                 },
1410                 .first_sysupgrade_partition = "os-image",
1411                 .last_sysupgrade_partition = "file-system",
1412         },
1413         /** Firmware layout for the Archer A6 v3  */
1414         {
1415                 .id     = "ARCHER-A6-V3",
1416                 .vendor = "",
1417                 .support_list =
1418                         "SupportList:\n"
1419                         "{product_name:Archer A6,product_ver:3.0.0,special_id:43410000}\n"
1420                         "{product_name:Archer A6,product_ver:3.0.0,special_id:55530000}\n"
1421                         "{product_name:Archer A6,product_ver:3.0.0,special_id:54570000}\n"
1422                         "{product_name:Archer A6,product_ver:3.0.0,special_id:4A500000}\n"
1423                         "{product_name:Archer A6,product_ver:3.20,special_id:45550000}\n"
1424                         "{product_name:Archer A6,product_ver:3.20,special_id:52550000}\n",
1425                 .part_trail = 0x00,
1426                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.5\n"),
1427 
1428                 .partitions = {
1429                         {"fs-uboot", 0x00000, 0x40000},
1430                         {"firmware", 0x40000, 0xf60000},
1431                         {"default-mac", 0xfa0000, 0x00200},
1432                         {"pin", 0xfa0200, 0x00100},
1433                         {"device-id", 0xfa0300, 0x00100},
1434                         {"product-info", 0xfa0400, 0x0fc00},
1435                         {"default-config", 0xfb0000, 0x08000},
1436                         {"ap-def-config", 0xfb8000, 0x08000},
1437                         {"user-config", 0xfc0000, 0x0a000},
1438                         {"ag-config", 0xfca000, 0x04000},
1439                         {"certificate", 0xfce000, 0x02000},
1440                         {"ap-config", 0xfd0000, 0x06000},
1441                         {"router-config", 0xfd6000, 0x06000},
1442                         {"favicon", 0xfdc000, 0x02000},
1443                         {"logo", 0xfde000, 0x02000},
1444                         {"partition-table", 0xfe0000, 0x00800},
1445                         {"soft-version", 0xfe0800, 0x00100},
1446                         {"support-list", 0xfe0900, 0x00200},
1447                         {"profile", 0xfe0b00, 0x03000},
1448                         {"extra-para", 0xfe3b00, 0x00100},
1449                         {"radio", 0xff0000, 0x10000},
1450                         {NULL, 0, 0}
1451                 },
1452                 .first_sysupgrade_partition = "os-image",
1453                 .last_sysupgrade_partition = "file-system",
1454         },
1455         /** Firmware layout for the Archer C6U v1 */
1456         {
1457                 .id     = "ARCHER-C6U-V1",
1458                 .vendor = "",
1459                 .support_list =
1460                         "SupportList:\n"
1461                         "{product_name:Archer C6U,product_ver:1.0.0,special_id:45550000}\n"
1462                         "{product_name:Archer C6U,product_ver:1.0.0,special_id:52550000}\n",
1463                 .part_trail = 0x00,
1464                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.2\n"),
1465 
1466                 .partitions = {
1467                         {"fs-uboot", 0x00000, 0x40000},
1468                         {"firmware", 0x40000, 0xf60000},
1469                         {"default-mac", 0xfa0000, 0x00200},
1470                         {"pin", 0xfa0200, 0x00100},
1471                         {"device-id", 0xfa0300, 0x00100},
1472                         {"product-info", 0xfa0400, 0x0fc00},
1473                         {"default-config", 0xfb0000, 0x08000},
1474                         {"ap-def-config", 0xfb8000, 0x08000},
1475                         {"user-config", 0xfc0000, 0x0c000},
1476                         {"certificate", 0xfcc000, 0x04000},
1477                         {"ap-config", 0xfd0000, 0x08000},
1478                         {"router-config", 0xfd8000, 0x08000},
1479                         {"partition-table", 0xfe0000, 0x00800},
1480                         {"soft-version", 0xfe0800, 0x00100},
1481                         {"support-list", 0xfe0900, 0x00200},
1482                         {"profile", 0xfe0b00, 0x03000},
1483                         {"extra-para", 0xfe3b00, 0x00100},
1484                         {"radio", 0xff0000, 0x10000},
1485                         {NULL, 0, 0}
1486                 },
1487                 .first_sysupgrade_partition = "os-image",
1488                 .last_sysupgrade_partition = "file-system",
1489         },
1490         /** Firmware layout for the C60v1 */
1491         {
1492                 .id     = "ARCHER-C60-V1",
1493                 .vendor = "",
1494                 .support_list =
1495                         "SupportList:\r\n"
1496                         "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
1497                         "{product_name:Archer C60,product_ver:1.0.0,special_id:43410000}\r\n"
1498                         "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
1499                         "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
1500                 .part_trail = 0x00,
1501                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1502 
1503                 .partitions = {
1504                         {"fs-uboot", 0x00000, 0x10000},
1505                         {"default-mac", 0x10000, 0x00200},
1506                         {"pin", 0x10200, 0x00200},
1507                         {"product-info", 0x10400, 0x00100},
1508                         {"partition-table", 0x10500, 0x00800},
1509                         {"soft-version", 0x11300, 0x00200},
1510                         {"support-list", 0x11500, 0x00100},
1511                         {"device-id", 0x11600, 0x00100},
1512                         {"profile", 0x11700, 0x03900},
1513                         {"default-config", 0x15000, 0x04000},
1514                         {"user-config", 0x19000, 0x04000},
1515                         {"firmware", 0x20000, 0x7c8000},
1516                         {"certyficate", 0x7e8000, 0x08000},
1517                         {"radio", 0x7f0000, 0x10000},
1518                         {NULL, 0, 0}
1519                 },
1520 
1521                 .first_sysupgrade_partition = "os-image",
1522                 .last_sysupgrade_partition = "file-system",
1523         },
1524 
1525         /** Firmware layout for the C60v2 */
1526         {
1527                 .id     = "ARCHER-C60-V2",
1528                 .vendor = "",
1529                 .support_list =
1530                         "SupportList:\r\n"
1531                         "{product_name:Archer C60,product_ver:2.0.0,special_id:42520000}\r\n"
1532                         "{product_name:Archer C60,product_ver:2.0.0,special_id:43410000}\r\n"
1533                         "{product_name:Archer C60,product_ver:2.0.0,special_id:45550000}\r\n"
1534                         "{product_name:Archer C60,product_ver:2.0.0,special_id:55530000}\r\n",
1535                 .part_trail = 0x00,
1536                 .soft_ver = SOFT_VER_TEXT("soft_ver:2.0.0\n"),
1537 
1538                 .partitions = {
1539                         {"factory-boot", 0x00000, 0x1fb00},
1540                         {"default-mac", 0x1fb00, 0x00200},
1541                         {"pin", 0x1fd00, 0x00100},
1542                         {"product-info", 0x1fe00, 0x00100},
1543                         {"device-id", 0x1ff00, 0x00100},
1544                         {"fs-uboot", 0x20000, 0x10000},
1545                         {"firmware", 0x30000, 0x7a0000},
1546                         {"soft-version", 0x7d9500, 0x00100},
1547                         {"support-list", 0x7d9600, 0x00100},
1548                         {"extra-para", 0x7d9700, 0x00100},
1549                         {"profile", 0x7d9800, 0x03000},
1550                         {"default-config", 0x7dc800, 0x03000},
1551                         {"partition-table", 0x7df800, 0x00800},
1552                         {"user-config", 0x7e0000, 0x0c000},
1553                         {"certificate", 0x7ec000, 0x04000},
1554                         {"radio", 0x7f0000, 0x10000},
1555                         {NULL, 0, 0}
1556                 },
1557 
1558                 .first_sysupgrade_partition = "os-image",
1559                 .last_sysupgrade_partition = "file-system",
1560         },
1561 
1562         /** Firmware layout for the C60v3 */
1563         {
1564                 .id     = "ARCHER-C60-V3",
1565                 .vendor = "",
1566                 .support_list =
1567                         "SupportList:\r\n"
1568                         "{product_name:Archer C60,product_ver:3.0.0,special_id:42520000}\r\n"
1569                         "{product_name:Archer C60,product_ver:3.0.0,special_id:43410000}\r\n"
1570                         "{product_name:Archer C60,product_ver:3.0.0,special_id:45550000}\r\n"
1571                         "{product_name:Archer C60,product_ver:3.0.0,special_id:55530000}\r\n",
1572                 .part_trail = 0x00,
1573                 .soft_ver = SOFT_VER_TEXT("soft_ver:3.0.0\n"),
1574 
1575                 .partitions = {
1576                         {"factory-boot", 0x00000, 0x1fb00},
1577                         {"default-mac", 0x1fb00, 0x00200},
1578                         {"pin", 0x1fd00, 0x00100},
1579                         {"product-info", 0x1fe00, 0x00100},
1580                         {"device-id", 0x1ff00, 0x00100},
1581                         {"fs-uboot", 0x20000, 0x10000},
1582                         {"firmware", 0x30000, 0x7a0000},
1583                         {"soft-version", 0x7d9500, 0x00100},
1584                         {"support-list", 0x7d9600, 0x00100},
1585                         {"extra-para", 0x7d9700, 0x00100},
1586                         {"profile", 0x7d9800, 0x03000},
1587                         {"default-config", 0x7dc800, 0x03000},
1588                         {"partition-table", 0x7df800, 0x00800},
1589                         {"user-config", 0x7e0000, 0x0c000},
1590                         {"certificate", 0x7ec000, 0x04000},
1591                         {"radio", 0x7f0000, 0x10000},
1592                         {NULL, 0, 0}
1593                 },
1594 
1595                 .first_sysupgrade_partition = "os-image",
1596                 .last_sysupgrade_partition = "file-system",
1597         },
1598 
1599         /** Firmware layout for the C5 */
1600         {
1601                 .id     = "ARCHER-C5-V2",
1602                 .vendor = "",
1603                 .support_list =
1604                         "SupportList:\r\n"
1605                         "{product_name:ArcherC5,product_ver:2.0.0,special_id:00000000}\r\n"
1606                         "{product_name:ArcherC5,product_ver:2.0.0,special_id:55530000}\r\n"
1607                         "{product_name:ArcherC5,product_ver:2.0.0,special_id:4A500000}\r\n", /* JP version */
1608                 .part_trail = 0x00,
1609                 .soft_ver = SOFT_VER_DEFAULT,
1610 
1611                 .partitions = {
1612                         {"fs-uboot", 0x00000, 0x40000},
1613                         {"os-image", 0x40000, 0x200000},
1614                         {"file-system", 0x240000, 0xc00000},
1615                         {"default-mac", 0xe40000, 0x00200},
1616                         {"pin", 0xe40200, 0x00200},
1617                         {"product-info", 0xe40400, 0x00200},
1618                         {"partition-table", 0xe50000, 0x10000},
1619                         {"soft-version", 0xe60000, 0x00200},
1620                         {"support-list", 0xe61000, 0x0f000},
1621                         {"profile", 0xe70000, 0x10000},
1622                         {"default-config", 0xe80000, 0x10000},
1623                         {"user-config", 0xe90000, 0x50000},
1624                         {"log", 0xee0000, 0x100000},
1625                         {"radio_bk", 0xfe0000, 0x10000},
1626                         {"radio", 0xff0000, 0x10000},
1627                         {NULL, 0, 0}
1628                 },
1629 
1630                 .first_sysupgrade_partition = "os-image",
1631                 .last_sysupgrade_partition = "file-system"
1632         },
1633 
1634         /** Firmware layout for the C7 */
1635         {
1636                 .id     = "ARCHER-C7-V4",
1637                 .support_list =
1638                         "SupportList:\n"
1639                         "{product_name:Archer C7,product_ver:4.0.0,special_id:00000000}\n"
1640                         "{product_name:Archer C7,product_ver:4.0.0,special_id:41550000}\n"
1641                         "{product_name:Archer C7,product_ver:4.0.0,special_id:45550000}\n"
1642                         "{product_name:Archer C7,product_ver:4.0.0,special_id:4B520000}\n"
1643                         "{product_name:Archer C7,product_ver:4.0.0,special_id:42520000}\n"
1644                         "{product_name:Archer C7,product_ver:4.0.0,special_id:4A500000}\n"
1645                         "{product_name:Archer C7,product_ver:4.0.0,special_id:52550000}\n"
1646                         "{product_name:Archer C7,product_ver:4.0.0,special_id:54570000}\n"
1647                         "{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
1648                         "{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
1649                 .part_trail = 0x00,
1650                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1651 
1652                 /* We're using a dynamic kernel/rootfs split here */
1653                 .partitions = {
1654                         {"factory-boot", 0x00000, 0x20000},
1655                         {"fs-uboot", 0x20000, 0x20000},
1656                         {"firmware", 0x40000, 0xEC0000},        /* Stock: name os-image base 0x40000 size 0x120000 */
1657                                                                 /* Stock: name file-system base 0x160000 size 0xda0000 */
1658                         {"default-mac", 0xf00000, 0x00200},
1659                         {"pin", 0xf00200, 0x00200},
1660                         {"device-id", 0xf00400, 0x00100},
1661                         {"product-info", 0xf00500, 0x0fb00},
1662                         {"soft-version", 0xf10000, 0x00100},
1663                         {"extra-para", 0xf11000, 0x01000},
1664                         {"support-list", 0xf12000, 0x0a000},
1665                         {"profile", 0xf1c000, 0x04000},
1666                         {"default-config", 0xf20000, 0x10000},
1667                         {"user-config", 0xf30000, 0x40000},
1668                         {"qos-db", 0xf70000, 0x40000},
1669                         {"certificate", 0xfb0000, 0x10000},
1670                         {"partition-table", 0xfc0000, 0x10000},
1671                         {"log", 0xfd0000, 0x20000},
1672                         {"radio", 0xff0000, 0x10000},
1673                         {NULL, 0, 0}
1674                 },
1675 
1676                 .first_sysupgrade_partition = "os-image",
1677                 .last_sysupgrade_partition = "file-system",
1678         },
1679 
1680         /** Firmware layout for the C7 v5*/
1681         {
1682                 .id     = "ARCHER-C7-V5",
1683                 .support_list =
1684                         "SupportList:\n"
1685                         "{product_name:Archer C7,product_ver:5.0.0,special_id:00000000}\n"
1686                         "{product_name:Archer C7,product_ver:5.0.0,special_id:45550000}\n"
1687                         "{product_name:Archer C7,product_ver:5.0.0,special_id:55530000}\n"
1688                         "{product_name:Archer C7,product_ver:5.0.0,special_id:43410000}\n"
1689                         "{product_name:Archer C7,product_ver:5.0.0,special_id:4A500000}\n"
1690                         "{product_name:Archer C7,product_ver:5.0.0,special_id:54570000}\n"
1691                         "{product_name:Archer C7,product_ver:5.0.0,special_id:52550000}\n"
1692                         "{product_name:Archer C7,product_ver:5.0.0,special_id:4B520000}\n",
1693 
1694                 .part_trail = 0x00,
1695                 .soft_ver = SOFT_VER_TEXT("soft_ver:7.0.0\n"),
1696 
1697                 /* We're using a dynamic kernel/rootfs split here */
1698                 .partitions = {
1699                         {"factory-boot",    0x00000,  0x20000},
1700                         {"fs-uboot",        0x20000,  0x20000},
1701                         {"partition-table", 0x40000,  0x10000},
1702                         {"radio",           0x50000,  0x10000},
1703                         {"default-mac",     0x60000,  0x00200},
1704                         {"pin",             0x60200,  0x00200},
1705                         {"device-id",       0x60400,  0x00100},
1706                         {"product-info",    0x60500,  0x0fb00},
1707                         {"soft-version",    0x70000,  0x01000},
1708                         {"extra-para",      0x71000,  0x01000},
1709                         {"support-list",    0x72000,  0x0a000},
1710                         {"profile",         0x7c000,  0x04000},
1711                         {"user-config",     0x80000,  0x40000},
1712 
1713 
1714                         {"firmware",        0xc0000,  0xf00000},        /* Stock: name os-image base 0xc0000  size 0x120000 */
1715                                                                         /* Stock: name file-system base 0x1e0000 size 0xde0000 */
1716 
1717                         {"log",             0xfc0000, 0x20000},
1718                         {"certificate",     0xfe0000, 0x10000},
1719                         {"default-config",  0xff0000, 0x10000},
1720                         {NULL, 0, 0}
1721 
1722                 },
1723 
1724                 .first_sysupgrade_partition = "os-image",
1725                 .last_sysupgrade_partition = "file-system",
1726         },
1727 
1728         /** Firmware layout for the C9 */
1729         {
1730                 .id     = "ARCHERC9",
1731                 .vendor = "",
1732                 .support_list =
1733                         "SupportList:\n"
1734                         "{product_name:ArcherC9,"
1735                         "product_ver:1.0.0,"
1736                         "special_id:00000000}\n",
1737                 .part_trail = 0x00,
1738                 .soft_ver = SOFT_VER_DEFAULT,
1739 
1740                 .partitions = {
1741                         {"fs-uboot", 0x00000, 0x40000},
1742                         {"os-image", 0x40000, 0x200000},
1743                         {"file-system", 0x240000, 0xc00000},
1744                         {"default-mac", 0xe40000, 0x00200},
1745                         {"pin", 0xe40200, 0x00200},
1746                         {"product-info", 0xe40400, 0x00200},
1747                         {"partition-table", 0xe50000, 0x10000},
1748                         {"soft-version", 0xe60000, 0x00200},
1749                         {"support-list", 0xe61000, 0x0f000},
1750                         {"profile", 0xe70000, 0x10000},
1751                         {"default-config", 0xe80000, 0x10000},
1752                         {"user-config", 0xe90000, 0x50000},
1753                         {"log", 0xee0000, 0x100000},
1754                         {"radio_bk", 0xfe0000, 0x10000},
1755                         {"radio", 0xff0000, 0x10000},
1756                         {NULL, 0, 0}
1757                 },
1758 
1759                 .first_sysupgrade_partition = "os-image",
1760                 .last_sysupgrade_partition = "file-system"
1761         },
1762 
1763         /** Firmware layout for the Deco M4R v1 and v2 */
1764         {
1765                 .id     = "DECO-M4R-V1",
1766                 .vendor = "",
1767                 .support_list =
1768                         "SupportList:\n"
1769                         "{product_name:M4R,product_ver:1.0.0,special_id:55530000}\n"
1770                         "{product_name:M4R,product_ver:1.0.0,special_id:45550000}\n"
1771                         "{product_name:M4R,product_ver:1.0.0,special_id:43410000}\n"
1772                         "{product_name:M4R,product_ver:1.0.0,special_id:4A500000}\n"
1773                         "{product_name:M4R,product_ver:1.0.0,special_id:41550000}\n"
1774                         "{product_name:M4R,product_ver:1.0.0,special_id:4B520000}\n"
1775                         "{product_name:M4R,product_ver:1.0.0,special_id:49440000}\n"
1776                         "{product_name:M4R,product_ver:2.0.0,special_id:55530000}\n"
1777                         "{product_name:M4R,product_ver:2.0.0,special_id:45550000}\n"
1778                         "{product_name:M4R,product_ver:2.0.0,special_id:43410000}\n"
1779                         "{product_name:M4R,product_ver:2.0.0,special_id:4A500000}\n"
1780                         "{product_name:M4R,product_ver:2.0.0,special_id:41550000}\n"
1781                         "{product_name:M4R,product_ver:2.0.0,special_id:4B520000}\n"
1782                         "{product_name:M4R,product_ver:2.0.0,special_id:54570000}\n"
1783                         "{product_name:M4R,product_ver:2.0.0,special_id:42340000}\n"
1784                         "{product_name:M4R,product_ver:2.0.0,special_id:49440000}\n",
1785                 .part_trail = 0x00,
1786                 .soft_ver = SOFT_VER_DEFAULT,
1787 
1788                 .partitions = {
1789                         {"fs-uboot", 0x00000, 0x80000},
1790                         {"firmware", 0x80000, 0xe00000},
1791                         {"product-info", 0xe80000, 0x05000},
1792                         {"default-mac", 0xe85000, 0x01000},
1793                         {"device-id", 0xe86000, 0x01000},
1794                         {"support-list", 0xe87000, 0x10000},
1795                         {"user-config", 0xea7000, 0x10000},
1796                         {"device-config", 0xeb7000, 0x10000},
1797                         {"group-info", 0xec7000, 0x10000},
1798                         {"partition-table", 0xed7000, 0x02000},
1799                         {"soft-version", 0xed9000, 0x10000},
1800                         {"profile", 0xee9000, 0x10000},
1801                         {"default-config", 0xef9000, 0x10000},
1802                         {"url-sig", 0xfe0000, 0x10000},
1803                         {"radio", 0xff0000, 0x10000},
1804                         {NULL, 0, 0}
1805                 },
1806                 .first_sysupgrade_partition = "os-image",
1807                 .last_sysupgrade_partition = "file-system",
1808         },
1809 
1810         /** Firmware layout for the Deco M4R v4 */
1811         {
1812                 .id     = "DECO-M4R-V4",
1813                 .vendor = "",
1814                 .support_list =
1815                         "SupportList:\n"
1816                         "{product_name:M4R,product_ver:4.0.0,special_id:55530000}\n"
1817                         "{product_name:M4R,product_ver:4.0.0,special_id:45550000}\n"
1818                         "{product_name:M4R,product_ver:4.0.0,special_id:4A500000}\n"
1819                         "{product_name:M4R,product_ver:4.0.0,special_id:42340000}\n"
1820                         "{product_name:M4R,product_ver:4.0.0,special_id:5A470000}\n",
1821                 .part_trail = 0x00,
1822                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1823 
1824                 .partitions = {
1825                         {"fs-uboot", 0x00000, 0x40000},
1826                         {"firmware", 0x40000, 0xf60000},
1827                         {"default-mac", 0xfa0000, 0x00300},
1828                         {"device-id", 0xfa0300, 0x00100},
1829                         {"product-info", 0xfa0400, 0x0fc00},
1830                         {"group-info", 0xfb0000, 0x04000},
1831                         {"user-config", 0xfb4000, 0x0c000},
1832                         {"device-config", 0xfc0000, 0x10000},
1833                         {"default-config", 0xfd0000, 0x10000},
1834                         {"partition-table", 0xfe0000, 0x00800},
1835                         {"soft-version", 0xfe0800, 0x00100},
1836                         {"support-list", 0xfe0900, 0x00200},
1837                         {"profile", 0xfe0b00, 0x03000},
1838                         {"extra-para", 0xfe3b00, 0x00100},
1839                         {"radio", 0xff0000, 0x10000},
1840                         {NULL, 0, 0}
1841                 },
1842                 .first_sysupgrade_partition = "os-image",
1843                 .last_sysupgrade_partition = "file-system",
1844         },
1845 
1846         /** Firmware layout for the Deco M5 */
1847         {
1848                 .id = "DECO-M5",
1849                 .vendor = "",
1850                 .support_list =
1851                         "SupportList:\n"
1852                         "{product_name:M5,product_ver:1.0.0,special_id:55530000}\n"
1853                         "{product_name:M5,product_ver:1.0.0,special_id:45550000}\n"
1854                         "{product_name:M5,product_ver:1.0.0,special_id:43410000}\n"
1855                         "{product_name:M5,product_ver:1.0.0,special_id:4A500000}\n"
1856                         "{product_name:M5,product_ver:1.0.0,special_id:41550000}\n"
1857                         "{product_name:M5,product_ver:1.0.0,special_id:4B520000}\n"
1858                         "{product_name:M5,product_ver:1.0.0,special_id:49440000}\n"
1859                         "{product_name:M5,product_ver:3.0.0,special_id:55530000}\n"
1860                         "{product_name:M5,product_ver:3.0.0,special_id:45550000}\n"
1861                         "{product_name:M5,product_ver:3.0.0,special_id:43410000}\n"
1862                         "{product_name:M5,product_ver:3.0.0,special_id:4A500000}\n"
1863                         "{product_name:M5,product_ver:3.0.0,special_id:41550000}\n"
1864                         "{product_name:M5,product_ver:3.0.0,special_id:4B520000}\n"
1865                         "{product_name:M5,product_ver:3.0.0,special_id:49440000}\n"
1866                         "{product_name:M5,product_ver:3.0.0,special_id:53570000}\n"
1867                         "{product_name:M5,product_ver:3.0.0,special_id:42340000}\n"
1868                         "{product_name:M5,product_ver:3.0.0,special_id:54570000}\n"
1869                         "{product_name:M5,product_ver:3.2.0,special_id:55530000}\n"
1870                         "{product_name:M5,product_ver:3.2.0,special_id:45550000}\n"
1871                         "{product_name:M5,product_ver:3.2.0,special_id:43410000}\n"
1872                         "{product_name:M5,product_ver:3.2.0,special_id:4A500000}\n"
1873                         "{product_name:M5,product_ver:3.2.0,special_id:41550000}\n"
1874                         "{product_name:M5,product_ver:3.2.0,special_id:4B520000}\n"
1875                         "{product_name:M5,product_ver:3.2.0,special_id:49440000}\n"
1876                         "{product_name:M5,product_ver:3.2.0,special_id:53570000}\n"
1877                         "{product_name:M5,product_ver:3.2.0,special_id:42340000}\n"
1878                         "{product_name:M5,product_ver:3.2.0,special_id:54570000}\n",
1879                 .part_trail = 0x00,
1880                 .soft_ver = SOFT_VER_DEFAULT,
1881 
1882                 .partitions = {
1883                         {"SBL1", 0x00000, 0x30000},
1884                         {"boot-config_0", 0x30000, 0x10000},
1885                         {"MIBIB", 0x40000, 0x10000},
1886                         {"boot-config_1", 0x50000, 0x10000},
1887                         {"QSEE", 0x60000, 0x60000},
1888                         {"CDT", 0xc0000, 0x10000},
1889                         {"DDRPARAMS", 0xd0000, 0x10000},
1890                         {"uboot-env", 0xe0000, 0x10000},
1891                         {"fs-uboot@0", 0xf0000, 0x80000},
1892                         {"radio", 0x170000, 0x0fff0},
1893                         {"bluetooth-XTAL", 0x17fff0, 0x00010},
1894                         {"default-mac", 0x180000, 0x01000},
1895                         {"device-id", 0x182000, 0x01000},
1896                         {"product-info", 0x183000, 0x05000},
1897                         {"support-list", 0x190000, 0x10000},
1898                         {"user-config", 0x200000, 0x10000},
1899                         {"device-config", 0x210000, 0x10000},
1900                         {"group-info", 0x220000, 0x10000},
1901                         {"partition-table@0", 0x230000, 0x02000},
1902                         {"os-image@0", 0x240000, 0x300000},
1903                         {"file-system@0", 0x540000, 0x790000},
1904                         {"soft-version@0", 0xcd0000, 0x10000},
1905                         {"profile@0", 0xce0000, 0x10000},
1906                         {"default-config@0", 0xcf0000, 0x10000},
1907                         {"partition-table@1", 0xd00000, 0x02000},
1908                         {"fs-uboot@1", 0xd10000, 0x80000},
1909                         {"os-image@1", 0xd90000, 0x400000},
1910                         {"file-system@1", 0x1190000, 0xc40000},
1911                         {"soft-version@1", 0x1dd0000, 0x10000},
1912                         {"profile@1", 0x1de0000, 0x10000},
1913                         {"default-config@1", 0x1df0000, 0x10000},
1914                         {"tm-sig", 0x1e00000, 0x200000},
1915                         {NULL, 0, 0}
1916                 },
1917 
1918                 .partition_names.partition_table = "partition-table@1",
1919                 .partition_names.soft_ver = "soft-version@1",
1920                 .partition_names.os_image = "os-image@1",
1921                 .partition_names.file_system = "file-system@1",
1922 
1923                 .first_sysupgrade_partition = "os-image@1",
1924                 .last_sysupgrade_partition = "file-system@1"
1925         },
1926 
1927         /** Firmware layout for the Deco S4 v2 */
1928         {
1929                 .id     = "DECO-S4-V2",
1930                 .vendor = "",
1931                 .support_list =
1932                         "SupportList:\n"
1933                         "{product_name:S4,product_ver:1.0.0,special_id:55530000}\n"
1934                         "{product_name:S4,product_ver:1.0.0,special_id:45550000}\n"
1935                         "{product_name:S4,product_ver:1.0.0,special_id:43410000}\n"
1936                         "{product_name:S4,product_ver:1.0.0,special_id:4A500000}\n"
1937                         "{product_name:S4,product_ver:1.0.0,special_id:41550000}\n"
1938                         "{product_name:S4,product_ver:1.0.0,special_id:4B520000}\n"
1939                         "{product_name:S4,product_ver:2.0.0,special_id:55530000}\n"
1940                         "{product_name:S4,product_ver:2.0.0,special_id:45550000}\n"
1941                         "{product_name:S4,product_ver:2.0.0,special_id:43410000}\n"
1942                         "{product_name:S4,product_ver:2.0.0,special_id:4A500000}\n"
1943                         "{product_name:S4,product_ver:2.0.0,special_id:41550000}\n"
1944                         "{product_name:S4,product_ver:2.0.0,special_id:4B520000}\n",
1945                 .part_trail = 0x00,
1946                 .soft_ver = SOFT_VER_DEFAULT,
1947 
1948                 .partitions = {
1949                         {"fs-uboot", 0x00000, 0x80000},
1950                         {"product-info", 0x80000, 0x05000},
1951                         {"default-mac", 0x85000, 0x01000},
1952                         {"device-id", 0x86000, 0x01000},
1953                         {"support-list", 0x87000, 0x10000},
1954                         {"user-config", 0xa7000, 0x10000},
1955                         {"device-config", 0xb7000, 0x10000},
1956                         {"group-info", 0xc7000, 0x10000},
1957                         {"partition-table", 0xd7000, 0x02000},
1958                         {"soft-version", 0xd9000, 0x10000},
1959                         {"profile", 0xe9000, 0x10000},
1960                         {"default-config", 0xf9000, 0x10000},
1961                         {"url-sig", 0x1e0000, 0x10000},
1962                         {"radio", 0x1f0000, 0x10000},
1963                         {"firmware", 0x200000, 0xe00000},
1964                         {NULL, 0, 0}
1965                 },
1966                 .first_sysupgrade_partition = "os-image",
1967                 .last_sysupgrade_partition = "file-system",
1968         },
1969 
1970         /** Firmware layout for the EAP120 */
1971         {
1972                 .id     = "EAP120",
1973                 .vendor = "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1974                 .support_list =
1975                         "SupportList:\r\n"
1976                         "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1977                 .part_trail = 0xff,
1978                 .soft_ver = SOFT_VER_DEFAULT,
1979 
1980                 .partitions = {
1981                         {"fs-uboot", 0x00000, 0x20000},
1982                         {"partition-table", 0x20000, 0x02000},
1983                         {"default-mac", 0x30000, 0x00020},
1984                         {"support-list", 0x31000, 0x00100},
1985                         {"product-info", 0x31100, 0x00100},
1986                         {"soft-version", 0x32000, 0x00100},
1987                         {"os-image", 0x40000, 0x180000},
1988                         {"file-system", 0x1c0000, 0x600000},
1989                         {"user-config", 0x7c0000, 0x10000},
1990                         {"backup-config", 0x7d0000, 0x10000},
1991                         {"log", 0x7e0000, 0x10000},
1992                         {"radio", 0x7f0000, 0x10000},
1993                         {NULL, 0, 0}
1994                 },
1995 
1996                 .first_sysupgrade_partition = "os-image",
1997                 .last_sysupgrade_partition = "file-system"
1998         },
1999 
2000         /** Firmware layout for the EAP225-Outdoor v1 */
2001         {
2002                 .id     = "EAP225-OUTDOOR-V1",
2003                 .support_list =
2004                         "SupportList:\r\n"
2005                         "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n",
2006                 .part_trail = PART_TRAIL_NONE,
2007                 .soft_ver = SOFT_VER_DEFAULT,
2008                 .soft_ver_compat_level = 2,
2009 
2010                 .partitions = {
2011                         {"fs-uboot", 0x00000, 0x20000},
2012                         {"partition-table", 0x20000, 0x02000},
2013                         {"default-mac", 0x30000, 0x01000},
2014                         {"support-list", 0x31000, 0x00100},
2015                         {"product-info", 0x31100, 0x00400},
2016                         {"soft-version", 0x32000, 0x00100},
2017                         {"firmware", 0x40000, 0xd80000},
2018                         {"user-config", 0xdc0000, 0x30000},
2019                         {"mutil-log", 0xf30000, 0x80000},
2020                         {"oops", 0xfb0000, 0x40000},
2021                         {"radio", 0xff0000, 0x10000},
2022                         {NULL, 0, 0}
2023                 },
2024 
2025                 .first_sysupgrade_partition = "os-image",
2026                 .last_sysupgrade_partition = "file-system"
2027         },
2028 
2029         /** Firmware layout for the EAP225 v1 */
2030         {
2031                 .id     = "EAP225-V1",
2032                 .support_list =
2033                         "SupportList:\r\n"
2034                         "EAP225(TP-LINK|UN|AC1200-D):1.0\r\n",
2035                 .part_trail = PART_TRAIL_NONE,
2036                 .soft_ver = SOFT_VER_DEFAULT,
2037 
2038                 .partitions = {
2039                         {"fs-uboot", 0x00000, 0x20000},
2040                         {"partition-table", 0x20000, 0x02000},
2041                         {"default-mac", 0x30000, 0x01000},
2042                         {"support-list", 0x31000, 0x00100},
2043                         {"product-info", 0x31100, 0x00400},
2044                         {"soft-version", 0x32000, 0x00100},
2045                         {"firmware", 0x40000, 0xd80000},
2046                         {"user-config", 0xdc0000, 0x30000},
2047                         {"radio", 0xff0000, 0x10000},
2048                         {NULL, 0, 0}
2049                 },
2050 
2051                 .first_sysupgrade_partition = "os-image",
2052                 .last_sysupgrade_partition = "file-system"
2053         },
2054 
2055         /** Firmware layout for the EAP225 v3
2056          * Also compatible with:
2057          *   - EAP225 v3.20
2058          *   - EAP225 v4
2059          *   - EAP225-Outdoor v1
2060          *   - EAP225-Outdoor v3
2061          *   */
2062         {
2063                 .id     = "EAP225-V3",
2064                 .support_list =
2065                         "SupportList:\r\n"
2066                         "EAP225(TP-Link|UN|AC1350-D):3.0\r\n"
2067                         "EAP225(TP-Link|UN|AC1350-D):3.20\r\n"
2068                         "EAP225(TP-Link|UN|AC1350-D):4.0 CA\r\n"
2069                         "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n"
2070                         "EAP225-Outdoor(TP-Link|UN|AC1200-D):3.0 CA,JP\r\n",
2071                 .part_trail = PART_TRAIL_NONE,
2072                 .soft_ver = SOFT_VER_DEFAULT,
2073                 .soft_ver_compat_level = 2,
2074 
2075                 .partitions = {
2076                         {"fs-uboot", 0x00000, 0x20000},
2077                         {"partition-table", 0x20000, 0x02000},
2078                         {"default-mac", 0x30000, 0x01000},
2079                         {"support-list", 0x31000, 0x00100},
2080                         {"product-info", 0x31100, 0x00400},
2081                         {"soft-version", 0x32000, 0x00100},
2082                         {"firmware", 0x40000, 0xd80000},
2083                         {"user-config", 0xdc0000, 0x30000},
2084                         {"mutil-log", 0xf30000, 0x80000},
2085                         {"oops", 0xfb0000, 0x40000},
2086                         {"radio", 0xff0000, 0x10000},
2087                         {NULL, 0, 0}
2088                 },
2089 
2090                 .first_sysupgrade_partition = "os-image",
2091                 .last_sysupgrade_partition = "file-system"
2092         },
2093 
2094         /** Firmware layout for the EAP225-Wall v2 */
2095         {
2096                 .id     = "EAP225-WALL-V2",
2097                 .support_list =
2098                         "SupportList:\r\n"
2099                         "EAP225-Wall(TP-Link|UN|AC1200-D):2.0\r\n",
2100                 .part_trail = PART_TRAIL_NONE,
2101                 .soft_ver = SOFT_VER_DEFAULT,
2102                 .soft_ver_compat_level = 1,
2103 
2104                 .partitions = {
2105                         {"fs-uboot", 0x00000, 0x20000},
2106                         {"partition-table", 0x20000, 0x02000},
2107                         {"default-mac", 0x30000, 0x01000},
2108                         {"support-list", 0x31000, 0x00100},
2109                         {"product-info", 0x31100, 0x00400},
2110                         {"soft-version", 0x32000, 0x00100},
2111                         {"firmware", 0x40000, 0xd80000},
2112                         {"user-config", 0xdc0000, 0x30000},
2113                         {"mutil-log", 0xf30000, 0x80000},
2114                         {"oops", 0xfb0000, 0x40000},
2115                         {"radio", 0xff0000, 0x10000},
2116                         {NULL, 0, 0}
2117                 },
2118 
2119                 .first_sysupgrade_partition = "os-image",
2120                 .last_sysupgrade_partition = "file-system"
2121         },
2122 
2123         /** Firmware layout for the EAP235-Wall v1 */
2124         {
2125                 .id     = "EAP235-WALL-V1",
2126                 .support_list =
2127                         "SupportList:\r\n"
2128                         "EAP235-Wall(TP-Link|UN|AC1200-D):1.0\r\n",
2129                 .part_trail = PART_TRAIL_NONE,
2130                 .soft_ver = SOFT_VER_NUMERIC(3, 0, 0),
2131                 .soft_ver_compat_level = 1,
2132 
2133                 .partitions = {
2134                         {"fs-uboot", 0x00000, 0x80000},
2135                         {"partition-table", 0x80000, 0x02000},
2136                         {"default-mac", 0x90000, 0x01000},
2137                         {"support-list", 0x91000, 0x00100},
2138                         {"product-info", 0x91100, 0x00400},
2139                         {"soft-version", 0x92000, 0x00100},
2140                         {"firmware", 0xa0000, 0xd20000},
2141                         {"user-config", 0xdc0000, 0x30000},
2142                         {"mutil-log", 0xf30000, 0x80000},
2143                         {"oops", 0xfb0000, 0x40000},
2144                         {"radio", 0xff0000, 0x10000},
2145                         {NULL, 0, 0}
2146                 },
2147 
2148                 .first_sysupgrade_partition = "os-image",
2149                 .last_sysupgrade_partition = "file-system"
2150         },
2151 
2152         /** Firmware layout for the EAP245 v1 */
2153         {
2154                 .id     = "EAP245-V1",
2155                 .support_list =
2156                         "SupportList:\r\n"
2157                         "EAP245(TP-LINK|UN|AC1750-D):1.0\r\n",
2158                 .part_trail = PART_TRAIL_NONE,
2159                 .soft_ver = SOFT_VER_DEFAULT,
2160 
2161                 .partitions = {
2162                         {"fs-uboot", 0x00000, 0x20000},
2163                         {"partition-table", 0x20000, 0x02000},
2164                         {"default-mac", 0x30000, 0x01000},
2165                         {"support-list", 0x31000, 0x00100},
2166                         {"product-info", 0x31100, 0x00400},
2167                         {"soft-version", 0x32000, 0x00100},
2168                         {"firmware", 0x40000, 0xd80000},
2169                         {"user-config", 0xdc0000, 0x30000},
2170                         {"radio", 0xff0000, 0x10000},
2171                         {NULL, 0, 0}
2172                 },
2173 
2174                 .first_sysupgrade_partition = "os-image",
2175                 .last_sysupgrade_partition = "file-system"
2176         },
2177 
2178         /** Firmware layout for the EAP245 v3 */
2179         {
2180                 .id     = "EAP245-V3",
2181                 .support_list =
2182                         "SupportList:\r\n"
2183                         "EAP245(TP-Link|UN|AC1750-D):3.0\r\n"
2184                         "EAP265 HD(TP-Link|UN|AC1750-D):1.0",
2185                 .part_trail = PART_TRAIL_NONE,
2186                 .soft_ver = SOFT_VER_DEFAULT,
2187                 .soft_ver_compat_level = 1,
2188 
2189                 /** Firmware partition with dynamic kernel/rootfs split */
2190                 .partitions = {
2191                         {"factroy-boot", 0x00000, 0x40000},
2192                         {"fs-uboot", 0x40000, 0x40000},
2193                         {"partition-table", 0x80000, 0x10000},
2194                         {"default-mac", 0x90000, 0x01000},
2195                         {"support-list", 0x91000, 0x00100},
2196                         {"product-info", 0x91100, 0x00400},
2197                         {"soft-version", 0x92000, 0x00100},
2198                         {"radio", 0xa0000, 0x10000},
2199                         {"extra-para", 0xb0000, 0x10000},
2200                         {"firmware", 0xc0000, 0xe40000},
2201                         {"config", 0xf00000, 0x30000},
2202                         {"mutil-log", 0xf30000, 0x80000},
2203                         {"oops", 0xfb0000, 0x40000},
2204                         {NULL, 0, 0}
2205                 },
2206 
2207                 .first_sysupgrade_partition = "os-image",
2208                 .last_sysupgrade_partition = "file-system"
2209         },
2210 
2211         /** Firmware layout for the EAP610 v3/EAP613 v1 */
2212         {
2213                 .id = "EAP610-V3",
2214                 .soft_ver = SOFT_VER_DEFAULT,
2215                 .soft_ver_compat_level = 2,
2216                 .support_list =
2217                         "SupportList:\r\n"
2218                         "EAP610(TP-Link|UN|AX1800-D):3.0\r\n"
2219                         "EAP610(TP-Link|JP|AX1800-D):3.0\r\n"
2220                         "EAP610(TP-Link|EG|AX1800-D):3.0\r\n"
2221                         "EAP610(TP-Link|CA|AX1800-D):3.0\r\n"
2222                         "EAP613(TP-Link|UN|AX1800-D):1.0 JP\r\n"
2223                         "Festa F61(TP-Link|UN|AX1800-D):1.0\r\n",
2224                 .part_trail = PART_TRAIL_NONE,
2225 
2226                 .partitions = {
2227                         {"fs-uboot", 0x00000, 0x80000},
2228                         {"partition-table", 0x80000, 0x02000},
2229                         {"default-mac", 0x90000, 0x01000},
2230                         {"support-list", 0x91000, 0x00100},
2231                         {"product-info", 0x91100, 0x00400},
2232                         {"soft-version", 0x92000, 0x00100},
2233                         {"firmware", 0xa0000, 0xcf0000},
2234                         {"user-config", 0xd90000, 0x60000},
2235                         {"mutil-log", 0xf30000, 0x80000},
2236                         {"oops", 0xfb0000, 0x40000},
2237                         {"radio", 0xff0000, 0x10000},
2238                         {NULL, 0, 0}
2239                 },
2240 
2241                 .first_sysupgrade_partition = "os-image",
2242                 .last_sysupgrade_partition = "file-system"
2243         },
2244 
2245         /** Firmware layout for the EAP615-Wall v1 */
2246         {
2247                 .id = "EAP615-WALL-V1",
2248                 .soft_ver = SOFT_VER_DEFAULT,
2249                 .soft_ver_compat_level = 2,
2250                 .support_list =
2251                         "SupportList:\r\n"
2252                         "EAP615-Wall(TP-Link|UN|AX1800-D):1.0\r\n"
2253                         "EAP615-Wall(TP-Link|CA|AX1800-D):1.0\r\n"
2254                         "EAP615-Wall(TP-Link|JP|AX1800-D):1.0\r\n",
2255                 .part_trail = PART_TRAIL_NONE,
2256 
2257                 .partitions = {
2258                         {"fs-uboot", 0x00000, 0x80000},
2259                         {"partition-table", 0x80000, 0x02000},
2260                         {"default-mac", 0x90000, 0x01000},
2261                         {"support-list", 0x91000, 0x00100},
2262                         {"product-info", 0x91100, 0x00400},
2263                         {"soft-version", 0x92000, 0x00100},
2264                         {"firmware", 0xa0000, 0xcf0000},
2265                         {"user-config", 0xd90000, 0x60000},
2266                         {"mutil-log", 0xf30000, 0x80000},
2267                         {"oops", 0xfb0000, 0x40000},
2268                         {"radio", 0xff0000, 0x10000},
2269                         {NULL, 0, 0}
2270                 },
2271 
2272                 .first_sysupgrade_partition = "os-image",
2273                 .last_sysupgrade_partition = "file-system"
2274         },
2275 
2276         /** Firmware layout for the TL-WA1201 v2 */
2277         {
2278                 .id     = "TL-WA1201-V2",
2279                 .vendor = "",
2280                 .support_list =
2281                         "SupportList:\n"
2282                         "{product_name:TL-WA1201,product_ver:2.0.0,special_id:45550000}\n"
2283                         "{product_name:TL-WA1201,product_ver:2.0.0,special_id:55530000}\n",
2284                 .part_trail = 0x00,
2285                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.1 Build 20200709 rel.66244\n"),
2286 
2287                 .partitions = {
2288                         {"fs-uboot", 0x00000, 0x20000},
2289                         {"default-mac", 0x20000, 0x00200},
2290                         {"pin", 0x20200, 0x00100},
2291                         {"product-info", 0x20300, 0x00200},
2292                         {"device-id", 0x20500, 0x0fb00},
2293                         {"firmware", 0x30000, 0xce0000},
2294                         {"portal-logo", 0xd10000, 0x20000},
2295                         {"portal-back", 0xd30000, 0x200000},
2296                         {"soft-version", 0xf30000, 0x00200},
2297                         {"extra-para", 0xf30200, 0x00200},
2298                         {"support-list", 0xf30400, 0x00200},
2299                         {"profile", 0xf30600, 0x0fa00},
2300                         {"apdef-config", 0xf40000, 0x10000},
2301                         {"ap-config", 0xf50000, 0x10000},
2302                         {"redef-config", 0xf60000, 0x10000},
2303                         {"re-config", 0xf70000, 0x10000},
2304                         {"multidef-config", 0xf80000, 0x10000},
2305                         {"multi-config", 0xf90000, 0x10000},
2306                         {"clientdef-config", 0xfa0000, 0x10000},
2307                         {"client-config", 0xfb0000, 0x10000},
2308                         {"partition-table", 0xfc0000, 0x10000},
2309                         {"user-config", 0xfd0000, 0x10000},
2310                         {"certificate", 0xfe0000, 0x10000},
2311                         {"radio", 0xff0000, 0x10000},
2312                         {NULL, 0, 0}
2313                 },
2314                 .first_sysupgrade_partition = "os-image",
2315                 .last_sysupgrade_partition = "file-system",
2316         },
2317 
2318         /** Firmware layout for the TL-WA850RE v2 */
2319         {
2320                 .id     = "TLWA850REV2",
2321                 .vendor = "",
2322                 .support_list =
2323                         "SupportList:\n"
2324                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55530000}\n"
2325                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:00000000}\n"
2326                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55534100}\n"
2327                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:45550000}\n"
2328                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4B520000}\n"
2329                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:42520000}\n"
2330                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4A500000}\n"
2331                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
2332                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
2333                         "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
2334                 .part_trail = 0x00,
2335                 .soft_ver = SOFT_VER_DEFAULT,
2336 
2337                 /**
2338                    576KB were moved from file-system to os-image
2339                    in comparison to the stock image
2340                 */
2341                 .partitions = {
2342                         {"fs-uboot", 0x00000, 0x20000},
2343                         {"firmware", 0x20000, 0x390000},
2344                         {"partition-table", 0x3b0000, 0x02000},
2345                         {"default-mac", 0x3c0000, 0x00020},
2346                         {"pin", 0x3c0100, 0x00020},
2347                         {"product-info", 0x3c1000, 0x01000},
2348                         {"soft-version", 0x3c2000, 0x00100},
2349                         {"support-list", 0x3c3000, 0x01000},
2350                         {"profile", 0x3c4000, 0x08000},
2351                         {"user-config", 0x3d0000, 0x10000},
2352                         {"default-config", 0x3e0000, 0x10000},
2353                         {"radio", 0x3f0000, 0x10000},
2354                         {NULL, 0, 0}
2355                 },
2356 
2357                 .first_sysupgrade_partition = "os-image",
2358                 .last_sysupgrade_partition = "file-system"
2359         },
2360 
2361         /** Firmware layout for the TL-WA855RE v1 */
2362         {
2363                 .id     = "TLWA855REV1",
2364                 .vendor = "",
2365                 .support_list =
2366                         "SupportList:\n"
2367                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:00000000}\n"
2368                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:55530000}\n"
2369                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:45550000}\n"
2370                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4B520000}\n"
2371                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:42520000}\n"
2372                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4A500000}\n"
2373                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:43410000}\n"
2374                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:41550000}\n"
2375                         "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:52550000}\n",
2376                 .part_trail = 0x00,
2377                 .soft_ver = SOFT_VER_DEFAULT,
2378 
2379                 .partitions = {
2380                         {"fs-uboot", 0x00000, 0x20000},
2381                         {"os-image", 0x20000, 0x150000},
2382                         {"file-system", 0x170000, 0x240000},
2383                         {"partition-table", 0x3b0000, 0x02000},
2384                         {"default-mac", 0x3c0000, 0x00020},
2385                         {"pin", 0x3c0100, 0x00020},
2386                         {"product-info", 0x3c1000, 0x01000},
2387                         {"soft-version", 0x3c2000, 0x00100},
2388                         {"support-list", 0x3c3000, 0x01000},
2389                         {"profile", 0x3c4000, 0x08000},
2390                         {"user-config", 0x3d0000, 0x10000},
2391                         {"default-config", 0x3e0000, 0x10000},
2392                         {"radio", 0x3f0000, 0x10000},
2393                         {NULL, 0, 0}
2394                 },
2395 
2396                 .first_sysupgrade_partition = "os-image",
2397                 .last_sysupgrade_partition = "file-system"
2398         },
2399 
2400         /** Firmware layout for the TL-WPA8630P v2 (EU)*/
2401         {
2402                 .id     = "TL-WPA8630P-V2.0-EU",
2403                 .vendor = "",
2404                 .support_list =
2405                         "SupportList:\n"
2406                         "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:45550000}\n",
2407                 .part_trail = 0x00,
2408                 .soft_ver = SOFT_VER_DEFAULT,
2409 
2410                 .partitions = {
2411                         {"factory-uboot", 0x00000, 0x20000},
2412                         {"fs-uboot", 0x20000, 0x20000},
2413                         {"firmware", 0x40000, 0x5e0000},
2414                         {"partition-table", 0x620000, 0x02000},
2415                         {"default-mac", 0x630000, 0x00020},
2416                         {"pin", 0x630100, 0x00020},
2417                         {"device-id", 0x630200, 0x00030},
2418                         {"product-info", 0x631100, 0x01000},
2419                         {"extra-para", 0x632100, 0x01000},
2420                         {"soft-version", 0x640000, 0x01000},
2421                         {"support-list", 0x641000, 0x01000},
2422                         {"profile", 0x642000, 0x08000},
2423                         {"user-config", 0x650000, 0x10000},
2424                         {"default-config", 0x660000, 0x10000},
2425                         {"default-nvm", 0x670000, 0xc0000},
2426                         {"default-pib", 0x730000, 0x40000},
2427                         {"radio", 0x7f0000, 0x10000},
2428                         {NULL, 0, 0}
2429                 },
2430 
2431                 .first_sysupgrade_partition = "os-image",
2432                 .last_sysupgrade_partition = "file-system"
2433         },
2434 
2435         /** Firmware layout for the TL-WPA8630P v2 (INT)*/
2436         {
2437                 .id     = "TL-WPA8630P-V2-INT",
2438                 .vendor = "",
2439                 .support_list =
2440                         "SupportList:\n"
2441                         "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:41550000}\n"
2442                         "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:44450000}\n"
2443                         "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:41550000}\n",
2444                 .part_trail = 0x00,
2445                 .soft_ver = SOFT_VER_DEFAULT,
2446 
2447                 .partitions = {
2448                         {"factory-uboot", 0x00000, 0x20000},
2449                         {"fs-uboot", 0x20000, 0x20000},
2450                         {"firmware", 0x40000, 0x5e0000},
2451                         {"partition-table", 0x620000, 0x02000},
2452                         {"extra-para", 0x632100, 0x01000},
2453                         {"soft-version", 0x640000, 0x01000},
2454                         {"support-list", 0x641000, 0x01000},
2455                         {"profile", 0x642000, 0x08000},
2456                         {"user-config", 0x650000, 0x10000},
2457                         {"default-config", 0x660000, 0x10000},
2458                         {"default-nvm", 0x670000, 0xc0000},
2459                         {"default-pib", 0x730000, 0x40000},
2460                         {"default-mac", 0x7e0000, 0x00020},
2461                         {"pin", 0x7e0100, 0x00020},
2462                         {"device-id", 0x7e0200, 0x00030},
2463                         {"product-info", 0x7e1100, 0x01000},
2464                         {"radio", 0x7f0000, 0x10000},
2465                         {NULL, 0, 0}
2466                 },
2467 
2468                 .first_sysupgrade_partition = "os-image",
2469                 .last_sysupgrade_partition = "file-system"
2470         },
2471 
2472         /** Firmware layout for the TL-WPA8630P v2.1 (EU)*/
2473         {
2474                 .id     = "TL-WPA8630P-V2.1-EU",
2475                 .vendor = "",
2476                 .support_list =
2477                         "SupportList:\n"
2478                         "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:45550000}\n",
2479                 .part_trail = 0x00,
2480                 .soft_ver = SOFT_VER_DEFAULT,
2481 
2482                 .partitions = {
2483                         {"factory-uboot", 0x00000, 0x20000},
2484                         {"fs-uboot", 0x20000, 0x20000},
2485                         {"firmware", 0x40000, 0x5e0000},
2486                         {"extra-para", 0x680000, 0x01000},
2487                         {"product-info", 0x690000, 0x01000},
2488                         {"partition-table", 0x6a0000, 0x02000},
2489                         {"soft-version", 0x6b0000, 0x01000},
2490                         {"support-list", 0x6b1000, 0x01000},
2491                         {"profile", 0x6b2000, 0x08000},
2492                         {"user-config", 0x6c0000, 0x10000},
2493                         {"default-config", 0x6d0000, 0x10000},
2494                         {"default-nvm", 0x6e0000, 0xc0000},
2495                         {"default-pib", 0x7a0000, 0x40000},
2496                         {"default-mac", 0x7e0000, 0x00020},
2497                         {"pin", 0x7e0100, 0x00020},
2498                         {"device-id", 0x7e0200, 0x00030},
2499                         {"radio", 0x7f0000, 0x10000},
2500                         {NULL, 0, 0}
2501                 },
2502 
2503                 .first_sysupgrade_partition = "os-image",
2504                 .last_sysupgrade_partition = "file-system"
2505         },
2506 
2507         /** Firmware layout for the TL-WPA8631P v3 */
2508         {
2509                 .id     = "TL-WPA8631P-V3",
2510                 .vendor = "",
2511                 .support_list =
2512                         "SupportList:\n"
2513                         "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:41550000}\n"
2514                         "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:45550000}\n"
2515                         "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:55530000}\n"
2516                         "{product_name:TL-WPA8631P,product_ver:4.0.0,special_id:41550000}\n"
2517                         "{product_name:TL-WPA8631P,product_ver:4.0.0,special_id:45550000}\n"
2518                         "{product_name:TL-WPA8631P,product_ver:4.0.0,special_id:55530000}\n"
2519                         "{product_name:TL-WPA8635P,product_ver:3.0.0,special_id:46520000}\n",
2520                 .part_trail = 0x00,
2521                 .soft_ver = SOFT_VER_DEFAULT,
2522 
2523                 .partitions = {
2524                         {"fs-uboot", 0x00000, 0x20000},
2525                         {"firmware", 0x20000, 0x710000},
2526                         {"partition-table", 0x730000, 0x02000},
2527                         {"default-mac", 0x732000, 0x00020},
2528                         {"pin", 0x732100, 0x00020},
2529                         {"device-id", 0x732200, 0x00030},
2530                         {"default-region", 0x732300, 0x00010},
2531                         {"product-info", 0x732400, 0x00200},
2532                         {"extra-para", 0x732600, 0x00200},
2533                         {"soft-version", 0x732800, 0x00100},
2534                         {"support-list", 0x732900, 0x00200},
2535                         {"profile", 0x732b00, 0x00100},
2536                         {"default-config", 0x732c00, 0x00800},
2537                         {"plc-type", 0x733400, 0x00020},
2538                         {"default-pib", 0x733500, 0x06000},
2539                         {"user-config", 0x740000, 0x10000},
2540                         {"plc-pib", 0x750000, 0x10000},
2541                         {"plc-nvm", 0x760000, 0x90000},
2542                         {"radio", 0x7f0000, 0x10000},
2543                         {NULL, 0, 0}
2544                 },
2545 
2546                 .first_sysupgrade_partition = "os-image",
2547                 .last_sysupgrade_partition = "file-system"
2548         },
2549 
2550         /** Firmware layout for the TL-WR1043 v5 */
2551         {
2552                 .id     = "TLWR1043NV5",
2553                 .vendor = "",
2554                 .support_list =
2555                         "SupportList:\n"
2556                         "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
2557                         "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
2558                 .part_trail = 0x00,
2559                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.0.0\n"),
2560                 .partitions = {
2561                         {"factory-boot", 0x00000, 0x20000},
2562                         {"fs-uboot", 0x20000, 0x20000},
2563                         {"firmware", 0x40000, 0xec0000},
2564                         {"default-mac", 0xf00000, 0x00200},
2565                         {"pin", 0xf00200, 0x00200},
2566                         {"device-id", 0xf00400, 0x00100},
2567                         {"product-info", 0xf00500, 0x0fb00},
2568                         {"soft-version", 0xf10000, 0x01000},
2569                         {"extra-para", 0xf11000, 0x01000},
2570                         {"support-list", 0xf12000, 0x0a000},
2571                         {"profile", 0xf1c000, 0x04000},
2572                         {"default-config", 0xf20000, 0x10000},
2573                         {"user-config", 0xf30000, 0x40000},
2574                         {"qos-db", 0xf70000, 0x40000},
2575                         {"certificate", 0xfb0000, 0x10000},
2576                         {"partition-table", 0xfc0000, 0x10000},
2577                         {"log", 0xfd0000, 0x20000},
2578                         {"radio", 0xff0000, 0x10000},
2579                         {NULL, 0, 0}
2580                 },
2581                 .first_sysupgrade_partition = "os-image",
2582                 .last_sysupgrade_partition = "file-system"
2583         },
2584 
2585         /** Firmware layout for the TL-WR1043 v4 */
2586         {
2587                 .id     = "TLWR1043NDV4",
2588                 .vendor = "",
2589                 .support_list =
2590                         "SupportList:\n"
2591                         "{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
2592                 .part_trail = 0x00,
2593                 .soft_ver = SOFT_VER_DEFAULT,
2594 
2595                 /* We're using a dynamic kernel/rootfs split here */
2596                 .partitions = {
2597                         {"fs-uboot", 0x00000, 0x20000},
2598                         {"firmware", 0x20000, 0xf30000},
2599                         {"default-mac", 0xf50000, 0x00200},
2600                         {"pin", 0xf50200, 0x00200},
2601                         {"product-info", 0xf50400, 0x0fc00},
2602                         {"soft-version", 0xf60000, 0x0b000},
2603                         {"support-list", 0xf6b000, 0x04000},
2604                         {"profile", 0xf70000, 0x04000},
2605                         {"default-config", 0xf74000, 0x0b000},
2606                         {"user-config", 0xf80000, 0x40000},
2607                         {"partition-table", 0xfc0000, 0x10000},
2608                         {"log", 0xfd0000, 0x20000},
2609                         {"radio", 0xff0000, 0x10000},
2610                         {NULL, 0, 0}
2611                 },
2612 
2613                 .first_sysupgrade_partition = "os-image",
2614                 .last_sysupgrade_partition = "file-system"
2615         },
2616 
2617         /** Firmware layout for the TL-WR902AC v1 */
2618         {
2619                 .id     = "TL-WR902AC-V1",
2620                 .vendor = "",
2621                 .support_list =
2622                         "SupportList:\n"
2623                         "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:45550000}\n"
2624                         "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:55530000}\n",
2625                 .part_trail = 0x00,
2626                 .soft_ver = SOFT_VER_DEFAULT,
2627 
2628                 /**
2629                    384KB were moved from file-system to os-image
2630                    in comparison to the stock image
2631                 */
2632                 .partitions = {
2633                         {"fs-uboot", 0x00000, 0x20000},
2634                         {"firmware", 0x20000, 0x730000},
2635                         {"default-mac", 0x750000, 0x00200},
2636                         {"pin", 0x750200, 0x00200},
2637                         {"product-info", 0x750400, 0x0fc00},
2638                         {"soft-version", 0x760000, 0x0b000},
2639                         {"support-list", 0x76b000, 0x04000},
2640                         {"profile", 0x770000, 0x04000},
2641                         {"default-config", 0x774000, 0x0b000},
2642                         {"user-config", 0x780000, 0x40000},
2643                         {"partition-table", 0x7c0000, 0x10000},
2644                         {"log", 0x7d0000, 0x20000},
2645                         {"radio", 0x7f0000, 0x10000},
2646                         {NULL, 0, 0}
2647                 },
2648 
2649                 .first_sysupgrade_partition = "os-image",
2650                 .last_sysupgrade_partition = "file-system",
2651         },
2652 
2653         /** Firmware layout for the TL-WR941HP v1 */
2654         {
2655                 .id     = "TL-WR941HP-V1",
2656                 .vendor = "",
2657                 .support_list =
2658                         "SupportList:\n"
2659                         "{product_name:TL-WR941HP,product_ver:1.0.0,special_id:00000000}\n",
2660                 .part_trail = 0x00,
2661                 .soft_ver = SOFT_VER_DEFAULT,
2662 
2663                 .partitions = {
2664                         {"fs-uboot", 0x00000, 0x20000},
2665                         {"firmware", 0x20000, 0x730000},
2666                         {"default-mac", 0x750000, 0x00200},
2667                         {"pin", 0x750200, 0x00200},
2668                         {"product-info", 0x750400, 0x0fc00},
2669                         {"soft-version", 0x760000, 0x0b000},
2670                         {"support-list", 0x76b000, 0x04000},
2671                         {"profile", 0x770000, 0x04000},
2672                         {"default-config", 0x774000, 0x0b000},
2673                         {"user-config", 0x780000, 0x40000},
2674                         {"partition-table", 0x7c0000, 0x10000},
2675                         {"log", 0x7d0000, 0x20000},
2676                         {"radio", 0x7f0000, 0x10000},
2677                         {NULL, 0, 0}
2678                 },
2679 
2680                 .first_sysupgrade_partition = "os-image",
2681                 .last_sysupgrade_partition = "file-system",
2682         },
2683 
2684         /** Firmware layout for the TL-WR942N V1 */
2685         {
2686                 .id     = "TLWR942NV1",
2687                 .vendor = "",
2688                 .support_list =
2689                         "SupportList:\r\n"
2690                         "{product_name:TL-WR942N,product_ver:1.0.0,special_id:00000000}\r\n"
2691                         "{product_name:TL-WR942N,product_ver:1.0.0,special_id:52550000}\r\n",
2692                 .part_trail = 0x00,
2693                 .soft_ver = SOFT_VER_DEFAULT,
2694 
2695                 .partitions = {
2696                         {"fs-uboot", 0x00000, 0x20000},
2697                         {"firmware", 0x20000, 0xe20000},
2698                         {"default-mac", 0xe40000, 0x00200},
2699                         {"pin", 0xe40200, 0x00200},
2700                         {"product-info", 0xe40400, 0x0fc00},
2701                         {"partition-table", 0xe50000, 0x10000},
2702                         {"soft-version", 0xe60000, 0x10000},
2703                         {"support-list", 0xe70000, 0x10000},
2704                         {"profile", 0xe80000, 0x10000},
2705                         {"default-config", 0xe90000, 0x10000},
2706                         {"user-config", 0xea0000, 0x40000},
2707                         {"qos-db", 0xee0000, 0x40000},
2708                         {"certificate", 0xf20000, 0x10000},
2709                         {"usb-config", 0xfb0000, 0x10000},
2710                         {"log", 0xfc0000, 0x20000},
2711                         {"radio-bk", 0xfe0000, 0x10000},
2712                         {"radio", 0xff0000, 0x10000},
2713                         {NULL, 0, 0}
2714                 },
2715 
2716                 .first_sysupgrade_partition = "os-image",
2717                 .last_sysupgrade_partition = "file-system",
2718         },
2719 
2720   /** Firmware layout for the RE200 v2 */
2721         {
2722                 .id     = "RE200-V2",
2723                 .vendor = "",
2724                 .support_list =
2725                         "SupportList:\n"
2726                         "{product_name:RE200,product_ver:2.0.0,special_id:00000000}\n"
2727                         "{product_name:RE200,product_ver:2.0.0,special_id:41520000}\n"
2728                         "{product_name:RE200,product_ver:2.0.0,special_id:41550000}\n"
2729                         "{product_name:RE200,product_ver:2.0.0,special_id:42520000}\n"
2730                         "{product_name:RE200,product_ver:2.0.0,special_id:43410000}\n"
2731                         "{product_name:RE200,product_ver:2.0.0,special_id:45530000}\n"
2732                         "{product_name:RE200,product_ver:2.0.0,special_id:45550000}\n"
2733                         "{product_name:RE200,product_ver:2.0.0,special_id:49440000}\n"
2734                         "{product_name:RE200,product_ver:2.0.0,special_id:4a500000}\n"
2735                         "{product_name:RE200,product_ver:2.0.0,special_id:4b520000}\n"
2736                         "{product_name:RE200,product_ver:2.0.0,special_id:52550000}\n"
2737                         "{product_name:RE200,product_ver:2.0.0,special_id:54570000}\n"
2738                         "{product_name:RE200,product_ver:2.0.0,special_id:55530000}\n",
2739                 .part_trail = 0x00,
2740                 .soft_ver = SOFT_VER_DEFAULT,
2741 
2742                 .partitions = {
2743                         {"fs-uboot", 0x00000, 0x20000},
2744                         {"firmware", 0x20000, 0x7a0000},
2745                         {"partition-table", 0x7c0000, 0x02000},
2746                         {"default-mac", 0x7c2000, 0x00020},
2747                         {"pin", 0x7c2100, 0x00020},
2748                         {"product-info", 0x7c3100, 0x01000},
2749                         {"soft-version", 0x7c4200, 0x01000},
2750                         {"support-list", 0x7c5200, 0x01000},
2751                         {"profile", 0x7c6200, 0x08000},
2752                         {"config-info", 0x7ce200, 0x00400},
2753                         {"user-config", 0x7d0000, 0x10000},
2754                         {"default-config", 0x7e0000, 0x10000},
2755                         {"radio", 0x7f0000, 0x10000},
2756                         {NULL, 0, 0}
2757                 },
2758 
2759                 .first_sysupgrade_partition = "os-image",
2760                 .last_sysupgrade_partition = "file-system"
2761         },
2762 
2763   /** Firmware layout for the RE200 v3 */
2764         {
2765                 .id     = "RE200-V3",
2766                 .vendor = "",
2767                 .support_list =
2768                         "SupportList:\n"
2769                         "{product_name:RE200,product_ver:3.0.0,special_id:00000000}\n"
2770                         "{product_name:RE200,product_ver:3.0.0,special_id:41520000}\n"
2771                         "{product_name:RE200,product_ver:3.0.0,special_id:41550000}\n"
2772                         "{product_name:RE200,product_ver:3.0.0,special_id:42520000}\n"
2773                         "{product_name:RE200,product_ver:3.0.0,special_id:43410000}\n"
2774                         "{product_name:RE200,product_ver:3.0.0,special_id:45470000}\n"
2775                         "{product_name:RE200,product_ver:3.0.0,special_id:45530000}\n"
2776                         "{product_name:RE200,product_ver:3.0.0,special_id:45550000}\n"
2777                         "{product_name:RE200,product_ver:3.0.0,special_id:49440000}\n"
2778                         "{product_name:RE200,product_ver:3.0.0,special_id:4A500000}\n"
2779                         "{product_name:RE200,product_ver:3.0.0,special_id:4B520000}\n"
2780                         "{product_name:RE200,product_ver:3.0.0,special_id:52550000}\n"
2781                         "{product_name:RE200,product_ver:3.0.0,special_id:54570000}\n"
2782                         "{product_name:RE200,product_ver:3.0.0,special_id:55530000}\n",
2783                 .part_trail = 0x00,
2784                 .soft_ver = SOFT_VER_DEFAULT,
2785 
2786                 .partitions = {
2787                         {"fs-uboot", 0x00000, 0x20000},
2788                         {"firmware", 0x20000, 0x7a0000},
2789                         {"partition-table", 0x7c0000, 0x02000},
2790                         {"default-mac", 0x7c2000, 0x00020},
2791                         {"pin", 0x7c2100, 0x00020},
2792                         {"product-info", 0x7c3100, 0x01000},
2793                         {"soft-version", 0x7c4200, 0x01000},
2794                         {"support-list", 0x7c5200, 0x01000},
2795                         {"profile", 0x7c6200, 0x08000},
2796                         {"config-info", 0x7ce200, 0x00400},
2797                         {"user-config", 0x7d0000, 0x10000},
2798                         {"default-config", 0x7e0000, 0x10000},
2799                         {"radio", 0x7f0000, 0x10000},
2800                         {NULL, 0, 0}
2801                 },
2802 
2803                 .first_sysupgrade_partition = "os-image",
2804                 .last_sysupgrade_partition = "file-system"
2805         },
2806 
2807   /** Firmware layout for the RE200 v4 */
2808         {
2809                 .id     = "RE200-V4",
2810                 .vendor = "",
2811                 .support_list =
2812                         "SupportList:\n"
2813                         "{product_name:RE200,product_ver:4.0.0,special_id:00000000}\n"
2814                         "{product_name:RE200,product_ver:4.0.0,special_id:45550000}\n"
2815                         "{product_name:RE200,product_ver:4.0.0,special_id:4A500000}\n"
2816                         "{product_name:RE200,product_ver:4.0.0,special_id:4B520000}\n"
2817                         "{product_name:RE200,product_ver:4.0.0,special_id:43410000}\n"
2818                         "{product_name:RE200,product_ver:4.0.0,special_id:41550000}\n"
2819                         "{product_name:RE200,product_ver:4.0.0,special_id:42520000}\n"
2820                         "{product_name:RE200,product_ver:4.0.0,special_id:55530000}\n"
2821                         "{product_name:RE200,product_ver:4.0.0,special_id:41520000}\n"
2822                         "{product_name:RE200,product_ver:4.0.0,special_id:52550000}\n"
2823                         "{product_name:RE200,product_ver:4.0.0,special_id:54570000}\n"
2824                         "{product_name:RE200,product_ver:4.0.0,special_id:45530000}\n"
2825                         "{product_name:RE200,product_ver:4.0.0,special_id:49440000}\n"
2826                         "{product_name:RE200,product_ver:4.0.0,special_id:45470000}\n",
2827                 .part_trail = 0x00,
2828                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.1.0\n"),
2829 
2830                 .partitions = {
2831                         {"fs-uboot", 0x00000, 0x20000},
2832                         {"firmware", 0x20000, 0x7a0000},
2833                         {"partition-table", 0x7c0000, 0x02000},
2834                         {"default-mac", 0x7c2000, 0x00020},
2835                         {"pin", 0x7c2100, 0x00020},
2836                         {"product-info", 0x7c3100, 0x01000},
2837                         {"soft-version", 0x7c4200, 0x01000},
2838                         {"support-list", 0x7c5200, 0x01000},
2839                         {"profile", 0x7c6200, 0x08000},
2840                         {"config-info", 0x7ce200, 0x00400},
2841                         {"user-config", 0x7d0000, 0x10000},
2842                         {"default-config", 0x7e0000, 0x10000},
2843                         {"radio", 0x7f0000, 0x10000},
2844                         {NULL, 0, 0}
2845                 },
2846 
2847                 .first_sysupgrade_partition = "os-image",
2848                 .last_sysupgrade_partition = "file-system"
2849         },
2850 
2851         /** Firmware layout for the RE205 v3 */
2852         {
2853                 .id     = "RE205-V3",
2854                 .vendor = "",
2855                 .support_list =
2856                         "SupportList:\n"
2857                         "{product_name:RE205,product_ver:3.0.0,special_id:00000000}\n"
2858                         "{product_name:RE205,product_ver:3.0.0,special_id:45550000}\n"
2859                         "{product_name:RE205,product_ver:3.0.0,special_id:4A500000}\n"
2860                         "{product_name:RE205,product_ver:3.0.0,special_id:4B520000}\n"
2861                         "{product_name:RE205,product_ver:3.0.0,special_id:43410000}\n"
2862                         "{product_name:RE205,product_ver:3.0.0,special_id:41550000}\n"
2863                         "{product_name:RE205,product_ver:3.0.0,special_id:42520000}\n"
2864                         "{product_name:RE205,product_ver:3.0.0,special_id:55530000}\n"
2865                         "{product_name:RE205,product_ver:3.0.0,special_id:41520000}\n"
2866                         "{product_name:RE205,product_ver:3.0.0,special_id:52550000}\n"
2867                         "{product_name:RE205,product_ver:3.0.0,special_id:54570000}\n"
2868                         "{product_name:RE205,product_ver:3.0.0,special_id:45530000}\n"
2869                         "{product_name:RE205,product_ver:3.0.0,special_id:45470000}\n",
2870                 .part_trail = 0x00,
2871                 .soft_ver = SOFT_VER_TEXT("soft_ver:1.1.0\n"),
2872 
2873                 .partitions = {
2874                         {"fs-uboot", 0x00000, 0x20000},
2875                         {"firmware", 0x20000, 0x7a0000},
2876                         {"partition-table", 0x7c0000, 0x02000},
2877                         {"default-mac", 0x7c2000, 0x00020},
2878                         {"pin", 0x7c2100, 0x00020},
2879                         {"product-info", 0x7c3100, 0x01000},
2880                         {"soft-version", 0x7c4200, 0x01000},
2881                         {"support-list", 0x7c5200, 0x01000},
2882                         {"profile", 0x7c6200, 0x08000},
2883                         {"config-info", 0x7ce200, 0x00400},
2884                         {"user-config", 0x7d0000, 0x10000},
2885                         {"default-config", 0x7e0000, 0x10000},
2886                         {"radio", 0x7f0000, 0x10000},
2887                         {NULL, 0, 0}
2888                 },
2889 
2890                 .first_sysupgrade_partition = "os-image",
2891                 .last_sysupgrade_partition = "file-system"
2892         },
2893 
2894         /** Firmware layout for the RE220 v2 */
2895         {
2896                 .id     = "RE220-V2",
2897                 .vendor = "",
2898                 .support_list =
2899                         "SupportList:\n"
2900                         "{product_name:RE220,product_ver:2.0.0,special_id:00000000}\n"
2901                         "{product_name:RE220,product_ver:2.0.0,special_id:41520000}\n"
2902                         "{product_name:RE220,product_ver:2.0.0,special_id:41550000}\n"
2903                         "{product_name:RE220,product_ver:2.0.0,special_id:42520000}\n"
2904                         "{product_name:RE220,product_ver:2.0.0,special_id:43410000}\n"
2905                         "{product_name:RE220,product_ver:2.0.0,special_id:45530000}\n"
2906                         "{product_name:RE220,product_ver:2.0.0,special_id:45550000}\n"
2907                         "{product_name:RE220,product_ver:2.0.0,special_id:49440000}\n"
2908                         "{product_name:RE220,product_ver:2.0.0,special_id:4a500000}\n"
2909                         "{product_name:RE220,product_ver:2.0.0,special_id:4b520000}\n"
2910                         "{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n"
2911                         "{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n"
2912                         "{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n",
2913                 .part_trail = 0x00,
2914                 .soft_ver = SOFT_VER_DEFAULT,
2915 
2916                 .partitions = {
2917                         {"fs-uboot", 0x00000, 0x20000},
2918                         {"firmware", 0x20000, 0x7a0000},
2919                         {"partition-table", 0x7c0000, 0x02000},
2920                         {"default-mac", 0x7c2000, 0x00020},
2921                         {"pin", 0x7c2100, 0x00020},
2922                         {"product-info", 0x7c3100, 0x01000},
2923                         {"soft-version", 0x7c4200, 0x01000},
2924                         {"support-list", 0x7c5200, 0x01000},
2925                         {"profile", 0x7c6200, 0x08000},
2926                         {"config-info", 0x7ce200, 0x00400},
2927                         {"user-config", 0x7d0000, 0x10000},
2928                         {"default-config", 0x7e0000, 0x10000},
2929                         {"radio", 0x7f0000, 0x10000},
2930                         {NULL, 0, 0}
2931                 },
2932 
2933                 .first_sysupgrade_partition = "os-image",
2934                 .last_sysupgrade_partition = "file-system"
2935         },
2936 
2937   /** Firmware layout for the RE305 v1 */
2938         {
2939                 .id     = "RE305-V1",
2940                 .vendor = "",
2941                 .support_list =
2942                         "SupportList:\n"
2943                         "{product_name:RE305,product_ver:1.0.0,special_id:45550000}\n"
2944                         "{product_name:RE305,product_ver:1.0.0,special_id:55530000}\n"
2945                         "{product_name:RE305,product_ver:1.0.0,special_id:4a500000}\n"
2946                         "{product_name:RE305,product_ver:1.0.0,special_id:42520000}\n"
2947                         "{product_name:RE305,product_ver:1.0.0,special_id:4b520000}\n"
2948                         "{product_name:RE305,product_ver:1.0.0,special_id:41550000}\n"
2949                         "{product_name:RE305,product_ver:1.0.0,special_id:43410000}\n",
2950                 .part_trail = 0x00,
2951                 .soft_ver = SOFT_VER_DEFAULT,
2952 
2953                 .partitions = {
2954                         {"fs-uboot", 0x00000, 0x20000},
2955                         {"firmware", 0x20000, 0x5e0000},
2956                         {"partition-table", 0x600000, 0x02000},
2957                         {"default-mac", 0x610000, 0x00020},
2958                         {"pin", 0x610100, 0x00020},
2959                         {"product-info", 0x611100, 0x01000},
2960                         {"soft-version", 0x620000, 0x01000},
2961                         {"support-list", 0x621000, 0x01000},
2962                         {"profile", 0x622000, 0x08000},
2963                         {"user-config", 0x630000, 0x10000},
2964                         {"default-config", 0x640000, 0x10000},
2965                         {"radio", 0x7f0000, 0x10000},
2966                         {NULL, 0, 0}
2967                 },
2968 
2969                 .first_sysupgrade_partition = "os-image",
2970                 .last_sysupgrade_partition = "file-system"
2971         },
2972 
2973         /** Firmware layout for the RE305 v3 */
2974         {
2975                 .id     = "RE305-V3",
2976                 .vendor = "",
2977                 .support_list =
2978                         "SupportList:\n"
2979                         "{product_name:RE305,product_ver:3.0.0,special_id:00000000}\n"
2980                         "{product_name:RE305,product_ver:3.0.0,special_id:45550000}\n"
2981                         "{product_name:RE305,product_ver:3.0.0,special_id:4A500000}\n"
2982                         "{product_name:RE305,product_ver:3.0.0,special_id:4B520000}\n"
2983                         "{product_name:RE305,product_ver:3.0.0,special_id:41550000}\n"
2984                         "{product_name:RE305,product_ver:3.0.0,special_id:42520000}\n"
2985                         "{product_name:RE305,product_ver:3.0.0,special_id:55530000}\n"
2986                         "{product_name:RE305,product_ver:3.0.0,special_id:45530000}\n"
2987                         "{product_name:RE305,product_ver:3.0.0,special_id:41530000}\n"
2988                         "{product_name:RE305,product_ver:3.0.0,special_id:43410000}\n"
2989                         "{product_name:RE305,product_ver:3.0.0,special_id:52550000}\n",
2990                 .part_trail = 0x00,
2991                 .soft_ver = SOFT_VER_TEXT("soft_ver:2.0.0\n"),
2992 
2993                 .partitions = {
2994                         {"fs-uboot", 0x00000, 0x20000},
2995                         {"firmware", 0x20000, 0x7a0000},
2996                         {"partition-table", 0x7c0000, 0x02000},
2997                         {"default-mac", 0x7c2000, 0x00020},
2998                         {"pin", 0x7c2100, 0x00020},
2999                         {"product-info", 0x7c3100, 0x01000},
3000                         {"soft-version", 0x7c4200, 0x01000},
3001                         {"support-list", 0x7c5200, 0x01000},
3002                         {"profile", 0x7c6200, 0x08000},
3003                         {"config-info", 0x7ce200, 0x00400},
3004                         {"user-config", 0x7d0000, 0x10000},
3005                         {"default-config", 0x7e0000, 0x10000},
3006                         {"radio", 0x7f0000, 0x10000},
3007                         {NULL, 0, 0}
3008                 },
3009 
3010                 .first_sysupgrade_partition = "os-image",
3011                 .last_sysupgrade_partition = "file-system"
3012         },
3013 
3014         /** Firmware layout for the RE350 v1 */
3015         {
3016                 .id     = "RE350-V1",
3017                 .vendor = "",
3018                 .support_list =
3019                         "SupportList:\n"
3020                         "{product_name:RE350,product_ver:1.0.0,special_id:45550000}\n"
3021                         "{product_name:RE350,product_ver:1.0.0,special_id:00000000}\n"
3022                         "{product_name:RE350,product_ver:1.0.0,special_id:41550000}\n"
3023                         "{product_name:RE350,product_ver:1.0.0,special_id:55530000}\n"
3024                         "{product_name:RE350,product_ver:1.0.0,special_id:43410000}\n"
3025                         "{product_name:RE350,product_ver:1.0.0,special_id:4b520000}\n"
3026                         "{product_name:RE350,product_ver:1.0.0,special_id:4a500000}\n",
3027                 .part_trail = 0x00,
3028                 .soft_ver = SOFT_VER_DEFAULT,
3029 
3030                 /** We're using a dynamic kernel/rootfs split here */
3031                 .partitions = {
3032                         {"fs-uboot", 0x00000, 0x20000},
3033                         {"firmware", 0x20000, 0x5e0000},
3034                         {"partition-table", 0x600000, 0x02000},
3035                         {"default-mac", 0x610000, 0x00020},
3036                         {"pin", 0x610100, 0x00020},
3037                         {"product-info", 0x611100, 0x01000},
3038                         {"soft-version", 0x620000, 0x01000},
3039                         {"support-list", 0x621000, 0x01000},
3040                         {"profile", 0x622000, 0x08000},
3041                         {"user-config", 0x630000, 0x10000},
3042                         {"default-config", 0x640000, 0x10000},
3043                         {"radio", 0x7f0000, 0x10000},
3044                         {NULL, 0, 0}
3045                 },
3046 
3047                 .first_sysupgrade_partition = "os-image",
3048                 .last_sysupgrade_partition = "file-system"
3049         },
3050 
3051         /** Firmware layout for the RE350K v1 */
3052         {
3053                 .id     = "RE350K-V1",
3054                 .vendor = "",
3055                 .support_list =
3056                         "SupportList:\n"
3057                         "{product_name:RE350K,product_ver:1.0.0,special_id:00000000,product_region:US}\n",
3058                 .part_trail = 0x00,
3059                 .soft_ver = SOFT_VER_DEFAULT,
3060 
3061                 /** We're using a dynamic kernel/rootfs split here */
3062                 .partitions = {
3063                         {"fs-uboot", 0x00000, 0x20000},
3064                         {"firmware", 0x20000, 0xd70000},
3065                         {"partition-table", 0xd90000, 0x02000},
3066                         {"default-mac", 0xda0000, 0x00020},
3067                         {"pin", 0xda0100, 0x00020},
3068                         {"product-info", 0xda1100, 0x01000},
3069                         {"soft-version", 0xdb0000, 0x01000},
3070                         {"support-list", 0xdb1000, 0x01000},
3071                         {"profile", 0xdb2000, 0x08000},
3072                         {"user-config", 0xdc0000, 0x10000},
3073                         {"default-config", 0xdd0000, 0x10000},
3074                         {"device-id", 0xde0000, 0x00108},
3075                         {"radio", 0xff0000, 0x10000},
3076                         {NULL, 0, 0}
3077                 },
3078 
3079                 .first_sysupgrade_partition = "os-image",
3080                 .last_sysupgrade_partition = "file-system"
3081         },
3082 
3083         /** Firmware layout for the RE355 */
3084         {
3085                 .id     = "RE355",
3086                 .vendor = "",
3087                 .support_list =
3088                         "SupportList:\r\n"
3089                         "{product_name:RE355,product_ver:1.0.0,special_id:00000000}\r\n"
3090                         "{product_name:RE355,product_ver:1.0.0,special_id:55530000}\r\n"
3091                         "{product_name:RE355,product_ver:1.0.0,special_id:45550000}\r\n"
3092                         "{product_name:RE355,product_ver:1.0.0,special_id:4A500000}\r\n"
3093                         "{product_name:RE355,product_ver:1.0.0,special_id:43410000}\r\n"
3094                         "{product_name:RE355,product_ver:1.0.0,special_id:41550000}\r\n"
3095                         "{product_name:RE355,product_ver:1.0.0,special_id:4B520000}\r\n"
3096                         "{product_name:RE355,product_ver:1.0.0,special_id:55534100}\r\n",
3097                 .part_trail = 0x00,
3098                 .soft_ver = SOFT_VER_DEFAULT,
3099 
3100                 /* We're using a dynamic kernel/rootfs split here */
3101                 .partitions = {
3102                         {"fs-uboot", 0x00000, 0x20000},
3103                         {"firmware", 0x20000, 0x5e0000},
3104                         {"partition-table", 0x600000, 0x02000},
3105                         {"default-mac", 0x610000, 0x00020},
3106                         {"pin", 0x610100, 0x00020},
3107                         {"product-info", 0x611100, 0x01000},
3108                         {"soft-version", 0x620000, 0x01000},
3109                         {"support-list", 0x621000, 0x01000},
3110                         {"profile", 0x622000, 0x08000},
3111                         {"user-config", 0x630000, 0x10000},
3112                         {"default-config", 0x640000, 0x10000},
3113                         {"radio", 0x7f0000, 0x10000},
3114                         {NULL, 0, 0}
3115                 },
3116 
3117                 .first_sysupgrade_partition = "os-image",
3118                 .last_sysupgrade_partition = "file-system"
3119         },
3120 
3121         /** Firmware layout for the RE365 v1 */
3122         {
3123                 .id     = "RE365",
3124                 .vendor = "",
3125                 .support_list =
3126                         "SupportList:\r\n"
3127                         "{product_name:RE365,product_ver:1.0.0,special_id:45550000}\r\n"
3128                         "{product_name:RE365,product_ver:1.0.0,special_id:55530000}\r\n"
3129                         "{product_name:RE365,product_ver:1.0.0,special_id:4a500000}\r\n"
3130                         "{product_name:RE365,product_ver:1.0.0,special_id:42520000}\r\n"
3131                         "{product_name:RE365,product_ver:1.0.0,special_id:4b520000}\r\n"
3132                         "{product_name:RE365,product_ver:1.0.0,special_id:41550000}\r\n"
3133                         "{product_name:RE365,product_ver:1.0.0,special_id:43410000}\r\n"
3134                         "{product_name:RE365,product_ver:1.0.0,special_id:54570000}\r\n"
3135                         "{product_name:RE365,product_ver:1.0.0,special_id:41530000}\r\n",
3136                 .part_trail = 0x00,
3137                 .soft_ver = SOFT_VER_DEFAULT,
3138 
3139                 .partitions = {
3140                         {"fs-uboot", 0x00000, 0x20000},
3141                         {"firmware", 0x20000, 0x5e0000},
3142                         {"partition-table", 0x600000, 0x02000},
3143                         {"default-mac", 0x610000, 0x00020},
3144                         {"pin", 0x610100, 0x00020},
3145                         {"product-info", 0x611100, 0x01000},
3146                         {"soft-version", 0x620000, 0x01000},
3147                         {"support-list", 0x621000, 0x01000},
3148                         {"profile", 0x622000, 0x08000},
3149                         {"user-config", 0x630000, 0x10000},
3150                         {"default-config", 0x640000, 0x10000},
3151                         {"radio", 0x7f0000, 0x10000},
3152                         {NULL, 0, 0}
3153                 },
3154 
3155                 .first_sysupgrade_partition = "os-image",
3156                 .last_sysupgrade_partition = "file-system"
3157         },
3158 
3159         /** Firmware layout for the RE450 */
3160         {
3161                 .id     = "RE450",
3162                 .vendor = "",
3163                 .support_list =
3164                         "SupportList:\r\n"
3165                         "{product_name:RE450,product_ver:1.0.0,special_id:00000000}\r\n"
3166                         "{product_name:RE450,product_ver:1.0.0,special_id:55530000}\r\n"
3167                         "{product_name:RE450,product_ver:1.0.0,special_id:45550000}\r\n"
3168                         "{product_name:RE450,product_ver:1.0.0,special_id:4A500000}\r\n"
3169                         "{product_name:RE450,product_ver:1.0.0,special_id:43410000}\r\n"
3170                         "{product_name:RE450,product_ver:1.0.0,special_id:41550000}\r\n"
3171                         "{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
3172                         "{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
3173                 .part_trail = 0x00,
3174                 .soft_ver = SOFT_VER_DEFAULT,
3175 
3176                 /** We're using a dynamic kernel/rootfs split here */
3177                 .partitions = {
3178                         {"fs-uboot", 0x00000, 0x20000},
3179                         {"firmware", 0x20000, 0x5e0000},
3180                         {"partition-table", 0x600000, 0x02000},
3181                         {"default-mac", 0x610000, 0x00020},
3182                         {"pin", 0x610100, 0x00020},
3183                         {"product-info", 0x611100, 0x01000},
3184                         {"soft-version", 0x620000, 0x01000},
3185                         {"support-list", 0x621000, 0x01000},
3186                         {"profile", 0x622000, 0x08000},
3187                         {"user-config", 0x630000, 0x10000},
3188                         {"default-config", 0x640000, 0x10000},
3189                         {"radio", 0x7f0000, 0x10000},
3190                         {NULL, 0, 0}
3191                 },
3192 
3193                 .first_sysupgrade_partition = "os-image",
3194                 .last_sysupgrade_partition = "file-system"
3195         },
3196 
3197         /** Firmware layout for the RE450 v2 */
3198         {
3199                 .id     = "RE450-V2",
3200                 .vendor = "",
3201                 .support_list =
3202                         "SupportList:\r\n"
3203                         "{product_name:RE450,product_ver:2.0.0,special_id:00000000}\r\n"
3204                         "{product_name:RE450,product_ver:2.0.0,special_id:55530000}\r\n"
3205                         "{product_name:RE450,product_ver:2.0.0,special_id:45550000}\r\n"
3206                         "{product_name:RE450,product_ver:2.0.0,special_id:4A500000}\r\n"
3207                         "{product_name:RE450,product_ver:2.0.0,special_id:43410000}\r\n"
3208                         "{product_name:RE450,product_ver:2.0.0,special_id:41550000}\r\n"
3209                         "{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n"
3210                         "{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n"
3211                         "{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n",
3212                 .part_trail = 0x00,
3213                 .soft_ver = SOFT_VER_DEFAULT,
3214 
3215                 /* We're using a dynamic kernel/rootfs split here */
3216                 .partitions = {
3217                         {"fs-uboot", 0x00000, 0x20000},
3218                         {"firmware", 0x20000, 0x5e0000},
3219                         {"partition-table", 0x600000, 0x02000},
3220                         {"default-mac", 0x610000, 0x00020},
3221                         {"pin", 0x610100, 0x00020},
3222                         {"product-info", 0x611100, 0x01000},
3223                         {"soft-version", 0x620000, 0x01000},
3224                         {"support-list", 0x621000, 0x01000},
3225                         {"profile", 0x622000, 0x08000},
3226                         {"user-config", 0x630000, 0x10000},
3227                         {"default-config", 0x640000, 0x10000},
3228                         {"radio", 0x7f0000, 0x10000},
3229                         {NULL, 0, 0}
3230                 },
3231 
3232                 .first_sysupgrade_partition = "os-image",
3233                 .last_sysupgrade_partition = "file-system"
3234         },
3235 
3236         /** Firmware layout for the RE450 v3 */
3237         {
3238                 .id     = "RE450-V3",
3239                 .vendor = "",
3240                 .support_list =
3241                         "SupportList:\r\n"
3242                         "{product_name:RE450,product_ver:3.0.0,special_id:00000000}\r\n"
3243                         "{product_name:RE450,product_ver:3.0.0,special_id:55530000}\r\n"
3244                         "{product_name:RE450,product_ver:3.0.0,special_id:45550000}\r\n"
3245                         "{product_name:RE450,product_ver:3.0.0,special_id:4A500000}\r\n"
3246                         "{product_name:RE450,product_ver:3.0.0,special_id:43410000}\r\n"
3247                         "{product_name:RE450,product_ver:3.0.0,special_id:41550000}\r\n"
3248                         "{product_name:RE450,product_ver:3.0.0,special_id:41530000}\r\n"
3249                         "{product_name:RE450,product_ver:3.0.0,special_id:4B520000}\r\n"
3250                         "{product_name:RE450,product_ver:3.0.0,special_id:42520000}\r\n",
3251                 .part_trail = 0x00,
3252                 .soft_ver = SOFT_VER_DEFAULT,
3253 
3254                 /* We're using a dynamic kernel/rootfs split here */
3255                 .partitions = {
3256                         {"fs-uboot", 0x00000, 0x20000},
3257                         {"default-mac", 0x20000, 0x00020},
3258                         {"pin", 0x20020, 0x00020},
3259                         {"product-info", 0x21000, 0x01000},
3260                         {"partition-table", 0x22000, 0x02000},
3261                         {"soft-version", 0x24000, 0x01000},
3262                         {"support-list", 0x25000, 0x01000},
3263                         {"profile", 0x26000, 0x08000},
3264                         {"user-config", 0x2e000, 0x10000},
3265                         {"default-config", 0x3e000, 0x10000},
3266                         {"config-info", 0x4e000, 0x00400},
3267                         {"firmware", 0x50000, 0x7a0000},
3268                         {"radio", 0x7f0000, 0x10000},
3269                         {NULL, 0, 0}
3270                 },
3271 
3272                 .first_sysupgrade_partition = "os-image",
3273                 .last_sysupgrade_partition = "file-system"
3274         },
3275 
3276         /** Firmware layout for the RE455 v1 */
3277         {
3278                 .id     = "RE455-V1",
3279                 .vendor = "",
3280                 .support_list =
3281                         "SupportList:\r\n"
3282                         "{product_name:RE455,product_ver:1.0.0,special_id:00000000}\r\n"
3283                         "{product_name:RE455,product_ver:1.0.0,special_id:55530000}\r\n"
3284                         "{product_name:RE455,product_ver:1.0.0,special_id:45550000}\r\n"
3285                         "{product_name:RE455,product_ver:1.0.0,special_id:4A500000}\r\n"
3286                         "{product_name:RE455,product_ver:1.0.0,special_id:43410000}\r\n"
3287                         "{product_name:RE455,product_ver:1.0.0,special_id:41550000}\r\n"
3288                         "{product_name:RE455,product_ver:1.0.0,special_id:41530000}\r\n"
3289                         "{product_name:RE455,product_ver:1.0.0,special_id:4B520000}\r\n"
3290                         "{product_name:RE455,product_ver:1.0.0,special_id:42520000}\r\n",
3291                 .part_trail = 0x00,
3292                 .soft_ver = SOFT_VER_DEFAULT,
3293 
3294                 /* We're using a dynamic kernel/rootfs split here */
3295                 .partitions = {
3296                         {"fs-uboot", 0x00000, 0x20000},
3297                         {"default-mac", 0x20000, 0x00020},
3298                         {"pin", 0x20020, 0x00020},
3299                         {"product-info", 0x21000, 0x01000},
3300                         {"partition-table", 0x22000, 0x02000},
3301                         {"soft-version", 0x24000, 0x01000},
3302                         {"support-list", 0x25000, 0x01000},
3303                         {"profile", 0x26000, 0x08000},
3304                         {"user-config", 0x2e000, 0x10000},
3305                         {"default-config", 0x3e000, 0x10000},
3306                         {"config-info", 0x4e000, 0x00400},
3307                         {"firmware", 0x50000, 0x7a0000},
3308                         {"radio", 0x7f0000, 0x10000},
3309                         {NULL, 0, 0}
3310                 },
3311 
3312                 .first_sysupgrade_partition = "os-image",
3313                 .last_sysupgrade_partition = "file-system"
3314         },
3315 
3316         /** Firmware layout for the RE500 */
3317         {
3318                 .id     = "RE500-V1",
3319                 .vendor = "",
3320                 .support_list =
3321                         "SupportList:\r\n"
3322                         "{product_name:RE500,product_ver:1.0.0,special_id:00000000}\r\n"
3323                         "{product_name:RE500,product_ver:1.0.0,special_id:55530000}\r\n"
3324                         "{product_name:RE500,product_ver:1.0.0,special_id:45550000}\r\n"
3325                         "{product_name:RE500,product_ver:1.0.0,special_id:4A500000}\r\n"
3326                         "{product_name:RE500,product_ver:1.0.0,special_id:43410000}\r\n"
3327                         "{product_name:RE500,product_ver:1.0.0,special_id:41550000}\r\n"
3328                         "{product_name:RE500,product_ver:1.0.0,special_id:41530000}\r\n",
3329                 .part_trail = 0x00,
3330                 .soft_ver = SOFT_VER_DEFAULT,
3331 
3332                 /* We're using a dynamic kernel/rootfs split here */
3333                 .partitions = {
3334                         {"fs-uboot", 0x00000, 0x20000},
3335                         {"firmware", 0x20000, 0xde0000},
3336                         {"partition-table", 0xe00000, 0x02000},
3337                         {"default-mac", 0xe10000, 0x00020},
3338                         {"pin", 0xe10100, 0x00020},
3339                         {"product-info", 0xe11100, 0x01000},
3340                         {"soft-version", 0xe20000, 0x01000},
3341                         {"support-list", 0xe21000, 0x01000},
3342                         {"profile", 0xe22000, 0x08000},
3343                         {"user-config", 0xe30000, 0x10000},
3344                         {"default-config", 0xe40000, 0x10000},
3345                         {"radio", 0xff0000, 0x10000},
3346                         {NULL, 0, 0}
3347                 },
3348 
3349                 .first_sysupgrade_partition = "os-image",
3350                 .last_sysupgrade_partition = "file-system"
3351         },
3352 
3353         /** Firmware layout for the RE650 */
3354         {
3355                 .id     = "RE650-V1",
3356                 .vendor = "",
3357                 .support_list =
3358                         "SupportList:\r\n"
3359                         "{product_name:RE650,product_ver:1.0.0,special_id:00000000}\r\n"
3360                         "{product_name:RE650,product_ver:1.0.0,special_id:55530000}\r\n"
3361                         "{product_name:RE650,product_ver:1.0.0,special_id:45550000}\r\n"
3362                         "{product_name:RE650,product_ver:1.0.0,special_id:4A500000}\r\n"
3363                         "{product_name:RE650,product_ver:1.0.0,special_id:43410000}\r\n"
3364                         "{product_name:RE650,product_ver:1.0.0,special_id:41550000}\r\n"
3365                         "{product_name:RE650,product_ver:1.0.0,special_id:41530000}\r\n",
3366                 .part_trail = 0x00,
3367                 .soft_ver = SOFT_VER_DEFAULT,
3368 
3369                 /* We're using a dynamic kernel/rootfs split here */
3370                 .partitions = {
3371                         {"fs-uboot", 0x00000, 0x20000},
3372                         {"firmware", 0x20000, 0xde0000},
3373                         {"partition-table", 0xe00000, 0x02000},
3374                         {"default-mac", 0xe10000, 0x00020},
3375                         {"pin", 0xe10100, 0x00020},
3376                         {"product-info", 0xe11100, 0x01000},
3377                         {"soft-version", 0xe20000, 0x01000},
3378                         {"support-list", 0xe21000, 0x01000},
3379                         {"profile", 0xe22000, 0x08000},
3380                         {"user-config", 0xe30000, 0x10000},
3381                         {"default-config", 0xe40000, 0x10000},
3382                         {"radio", 0xff0000, 0x10000},
3383                         {NULL, 0, 0}
3384                 },
3385 
3386                 .first_sysupgrade_partition = "os-image",
3387                 .last_sysupgrade_partition = "file-system"
3388         },
3389         /** Firmware layout for the RE650 V2 (8MB Flash)*/
3390         {
3391                 .id     = "RE650-V2",
3392                 .vendor = "",
3393                 .support_list =
3394                         "SupportList:\n"
3395                         "{product_name:RE650,product_ver:2.0.0,special_id:00000000}\n"
3396                         "{product_name:RE650,product_ver:2.0.0,special_id:45550000}\n"
3397                         "{product_name:RE650,product_ver:2.0.0,special_id:4A500000}\n"
3398                         "{product_name:RE650,product_ver:2.0.0,special_id:41550000}\n"
3399                         "{product_name:RE650,product_ver:2.0.0,special_id:43410000}\n"
3400                         "{product_name:RE650,product_ver:2.0.0,special_id:41530000}\n"
3401                         "{product_name:RE650,product_ver:2.0.0,special_id:55530000}\n",
3402                 .part_trail = 0x00,
3403                 /* For RE650 v2, soft ver is required, otherwise OEM install doesn't work */
3404                 .soft_ver = SOFT_VER_TEXT("soft_ver:2.0.0\n"),
3405 
3406                 /* We're using a dynamic kernel/rootfs split here */
3407                 .partitions = {
3408                         {"fs-uboot", 0x00000, 0x20000},
3409                         {"firmware", 0x20000, 0x7a0000},
3410                         {"partition-table", 0x7c0000, 0x02000},
3411                         {"default-mac", 0x7c2000, 0x00020},
3412                         {"pin", 0x7c2100, 0x00020},
3413                         {"product-info", 0x7c3100, 0x01000},
3414                         {"soft-version", 0x7c4200, 0x01000},
3415                         {"support-list", 0x7c5200, 0x01000},
3416                         {"profile", 0x7c6200, 0x08000},
3417                         {"config-info", 0x7ce200, 0x00400},
3418                         {"user-config", 0x7d0000, 0x10000},
3419                         {"default-config", 0x7e0000, 0x10000},
3420                         {"radio", 0x7f0000, 0x10000},
3421                         {NULL, 0, 0}
3422                 },
3423 
3424                 .first_sysupgrade_partition = "os-image",
3425                 .last_sysupgrade_partition = "file-system"
3426         },
3427 
3428         /** Firmware layout for the Mercusys MR70X */
3429         {
3430                 .id     = "MR70X",
3431                 .vendor = "",
3432                 .support_list =
3433                         "SupportList:\n"
3434                         "{product_name:MR1800X,product_ver:1.0.0,special_id:45550000}\n"
3435                         "{product_name:MR70X,product_ver:1.0.0,special_id:42520000}\n"
3436                         "{product_name:MR70X,product_ver:1.0.0,special_id:45470000}\n"
3437                         "{product_name:MR70X,product_ver:1.0.0,special_id:53470000}\n"
3438                         "{product_name:MR70X,product_ver:1.0.0,special_id:45550000}\n"
3439                         "{product_name:MR70X,product_ver:1.0.0,special_id:4A500000}\n"
3440                         "{product_name:MR70X,product_ver:1.0.0,special_id:55530000}\n",
3441                 .part_trail = 0x00,
3442                 .soft_ver = SOFT_VER_DEFAULT,
3443 
3444                 .partitions = {
3445                         {"fs-uboot", 0x00000, 0x40000},
3446                         {"firmware", 0x40000, 0xf60000},
3447                         {"default-mac", 0xfa0000, 0x00200},
3448                         {"pin", 0xfa0200, 0x00100},
3449                         {"device-id", 0xfa0300, 0x00100},
3450                         {"product-info", 0xfa0400, 0x0fc00},
3451                         {"default-config", 0xfb0000, 0x08000},
3452                         {"ap-def-config", 0xfb8000, 0x08000},
3453                         {"user-config", 0xfc0000, 0x0a000},
3454                         {"ag-config", 0xfca000, 0x04000},
3455                         {"certificate", 0xfce000, 0x02000},
3456                         {"ap-config", 0xfd0000, 0x06000},
3457                         {"router-config", 0xfd6000, 0x06000},
3458                         {"favicon", 0xfdc000, 0x02000},
3459                         {"logo", 0xfde000, 0x02000},
3460                         {"partition-table", 0xfe0000, 0x00800},
3461                         {"soft-version", 0xfe0800, 0x00100},
3462                         {"support-list", 0xfe0900, 0x00200},
3463                         {"profile", 0xfe0b00, 0x03000},
3464                         {"extra-para", 0xfe3b00, 0x00100},
3465                         {"radio", 0xff0000, 0x10000},
3466                         {NULL, 0, 0}
3467                 },
3468 
3469                 .first_sysupgrade_partition = "os-image",
3470                 .last_sysupgrade_partition = "file-system"
3471         },
3472 
3473         {}
3474 };
3475 
3476 #define error(_ret, _errno, _str, ...)                          \
3477         do {                                                    \
3478                 fprintf(stderr, _str ": %s\n", ## __VA_ARGS__,  \
3479                         strerror(_errno));                      \
3480                 if (_ret)                                       \
3481                         exit(_ret);                             \
3482         } while (0)
3483 
3484 
3485 /** Stores a uint32 as big endian */
3486 static inline void put32(uint8_t *buf, uint32_t val) {
3487         buf[0] = val >> 24;
3488         buf[1] = val >> 16;
3489         buf[2] = val >> 8;
3490         buf[3] = val;
3491 }
3492 
3493 static inline bool meta_partition_should_pad(enum partition_trail_value pv)
3494 {
3495         return (pv >= 0) && (pv <= PART_TRAIL_MAX);
3496 }
3497 
3498 /** Allocate a padded meta partition with a correctly initialised header
3499  * If the `data` pointer is NULL, then the required space is only allocated,
3500  * otherwise `data_len` bytes will be copied from `data` into the partition
3501  * entry. */
3502 static struct image_partition_entry init_meta_partition_entry(
3503         const char *name, const void *data, uint32_t data_len,
3504         enum partition_trail_value pad_value)
3505 {
3506         uint32_t total_len = sizeof(struct meta_header) + data_len;
3507         if (meta_partition_should_pad(pad_value))
3508                 total_len += 1;
3509 
3510         struct image_partition_entry entry = {
3511                 .name = name,
3512                 .size = total_len,
3513                 .data = malloc(total_len)
3514         };
3515         if (!entry.data)
3516                 error(1, errno, "failed to allocate meta partition entry");
3517 
3518         struct meta_header *header = (struct meta_header *)entry.data;
3519         header->length = htonl(data_len);
3520         header->zero = 0;
3521 
3522         if (data)
3523                 memcpy(entry.data+sizeof(*header), data, data_len);
3524 
3525         if (meta_partition_should_pad(pad_value))
3526                 entry.data[total_len - 1] = (uint8_t) pad_value;
3527 
3528         return entry;
3529 }
3530 
3531 /** Allocates a new image partition */
3532 static struct image_partition_entry alloc_image_partition(const char *name, size_t len) {
3533         struct image_partition_entry entry = {name, len, malloc(len)};
3534         if (!entry.data)
3535                 error(1, errno, "malloc");
3536 
3537         return entry;
3538 }
3539 
3540 /** Sets up default partition names whenever custom names aren't specified */
3541 static void set_partition_names(struct device_info *info)
3542 {
3543         if (!info->partition_names.partition_table)
3544                 info->partition_names.partition_table = "partition-table";
3545         if (!info->partition_names.soft_ver)
3546                 info->partition_names.soft_ver = "soft-version";
3547         if (!info->partition_names.os_image)
3548                 info->partition_names.os_image = "os-image";
3549         if (!info->partition_names.support_list)
3550                 info->partition_names.support_list = "support-list";
3551         if (!info->partition_names.file_system)
3552                 info->partition_names.file_system = "file-system";
3553         if (!info->partition_names.extra_para)
3554                 info->partition_names.extra_para = "extra-para";
3555 }
3556 
3557 /** Frees an image partition */
3558 static void free_image_partition(struct image_partition_entry *entry)
3559 {
3560         void *data = entry->data;
3561 
3562         entry->name = NULL;
3563         entry->size = 0;
3564         entry->data = NULL;
3565 
3566         free(data);
3567 }
3568 
3569 static time_t source_date_epoch = -1;
3570 static void set_source_date_epoch() {
3571         char *env = getenv("SOURCE_DATE_EPOCH");
3572         char *endptr = env;
3573         errno = 0;
3574         if (env && *env) {
3575                 source_date_epoch = strtoull(env, &endptr, 10);
3576                 if (errno || (endptr && *endptr != '\0')) {
3577                         fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
3578                         exit(1);
3579                 }
3580         }
3581 }
3582 
3583 /** Generates the partition-table partition */
3584 static struct image_partition_entry make_partition_table(const struct device_info *p)
3585 {
3586         struct image_partition_entry entry = alloc_image_partition(p->partition_names.partition_table, SAFELOADER_PAYLOAD_TABLE_SIZE);
3587 
3588         char *s = (char *)entry.data, *end = (char *)(s+entry.size);
3589 
3590         *(s++) = 0x00;
3591         *(s++) = 0x04;
3592         *(s++) = 0x00;
3593         *(s++) = 0x00;
3594 
3595         size_t i;
3596         for (i = 0; p->partitions[i].name; i++) {
3597                 size_t len = end-s;
3598                 size_t w = snprintf(s, len, "partition %s base 0x%05x size 0x%05x\n",
3599                         p->partitions[i].name, p->partitions[i].base, p->partitions[i].size);
3600 
3601                 if (w > len-1)
3602                         error(1, 0, "flash partition table overflow?");
3603 
3604                 s += w;
3605         }
3606 
3607         s++;
3608 
3609         memset(s, 0xff, end-s);
3610 
3611         return entry;
3612 }
3613 
3614 
3615 /** Generates a binary-coded decimal representation of an integer in the range [0, 99] */
3616 static inline uint8_t bcd(uint8_t v) {
3617         return 0x10 * (v/10) + v%10;
3618 }
3619 
3620 
3621 /** Generates the soft-version partition */
3622 static struct image_partition_entry make_soft_version(const struct device_info *info, uint32_t rev)
3623 {
3624         /** If an info string is provided, use this instead of
3625          * the structured data, and include the null-termination */
3626         if (info->soft_ver.type == SOFT_VER_TYPE_TEXT) {
3627                 uint32_t len = strlen(info->soft_ver.text) + 1;
3628                 return init_meta_partition_entry(info->partition_names.soft_ver,
3629                         info->soft_ver.text, len, info->part_trail);
3630         }
3631 
3632         time_t t;
3633 
3634         if (source_date_epoch != -1)
3635                 t = source_date_epoch;
3636         else if (time(&t) == (time_t)(-1))
3637                 error(1, errno, "time");
3638 
3639         struct tm *tm = gmtime(&t);
3640 
3641         struct soft_version s = {
3642                 .pad1 = 0xff,
3643 
3644                 .version_major = info->soft_ver.num[0],
3645                 .version_minor = info->soft_ver.num[1],
3646                 .version_patch = info->soft_ver.num[2],
3647 
3648                 .year_hi = bcd((1900+tm->tm_year)/100),
3649                 .year_lo = bcd(tm->tm_year%100),
3650                 .month = bcd(tm->tm_mon+1),
3651                 .day = bcd(tm->tm_mday),
3652                 .rev = htonl(rev),
3653 
3654                 .compat_level = htonl(info->soft_ver_compat_level)
3655         };
3656 
3657         if (info->soft_ver_compat_level == 0)
3658                 return init_meta_partition_entry(info->partition_names.soft_ver, &s,
3659                         (uint8_t *)(&s.compat_level) - (uint8_t *)(&s),
3660                         info->part_trail);
3661         else
3662                 return init_meta_partition_entry(info->partition_names.soft_ver, &s,
3663                         sizeof(s), info->part_trail);
3664 }
3665 
3666 /** Generates the support-list partition */
3667 static struct image_partition_entry make_support_list(
3668         const struct device_info *info)
3669 {
3670         uint32_t len = strlen(info->support_list);
3671         return init_meta_partition_entry(info->partition_names.support_list, info->support_list,
3672                 len, info->part_trail);
3673 }
3674 
3675 /** Partition with extra-para data */
3676 static struct image_partition_entry make_extra_para(
3677         const struct device_info *info, const uint8_t *extra_para, size_t len)
3678 {
3679         return init_meta_partition_entry(info->partition_names.extra_para, extra_para, len,
3680                 info->part_trail);
3681 }
3682 
3683 /** Creates a new image partition with an arbitrary name from a file */
3684 static struct image_partition_entry read_file(const char *part_name, const char *filename, bool add_jffs2_eof, struct flash_partition_entry *file_system_partition) {
3685         struct stat statbuf;
3686 
3687         if (stat(filename, &statbuf) < 0)
3688                 error(1, errno, "unable to stat file `%s'", filename);
3689 
3690         size_t len = statbuf.st_size;
3691 
3692         if (add_jffs2_eof) {
3693                 if (file_system_partition)
3694                         len = ALIGN(len + file_system_partition->base, 0x10000) + sizeof(jffs2_eof_mark) - file_system_partition->base;
3695                 else
3696                         len = ALIGN(len, 0x10000) + sizeof(jffs2_eof_mark);
3697         }
3698 
3699         struct image_partition_entry entry = alloc_image_partition(part_name, len);
3700 
3701         FILE *file = fopen(filename, "rb");
3702         if (!file)
3703                 error(1, errno, "unable to open file `%s'", filename);
3704 
3705         if (fread(entry.data, statbuf.st_size, 1, file) != 1)
3706                 error(1, errno, "unable to read file `%s'", filename);
3707 
3708         if (add_jffs2_eof) {
3709                 uint8_t *eof = entry.data + statbuf.st_size, *end = entry.data+entry.size;
3710 
3711                 memset(eof, 0xff, end - eof - sizeof(jffs2_eof_mark));
3712                 memcpy(end - sizeof(jffs2_eof_mark), jffs2_eof_mark, sizeof(jffs2_eof_mark));
3713         }
3714 
3715         fclose(file);
3716 
3717         return entry;
3718 }
3719 
3720 /**
3721    Copies a list of image partitions into an image buffer and generates the image partition table while doing so
3722 
3723    Example image partition table:
3724 
3725      fwup-ptn partition-table base 0x00800 size 0x00800
3726      fwup-ptn os-image base 0x01000 size 0x113b45
3727      fwup-ptn file-system base 0x114b45 size 0x1d0004
3728      fwup-ptn support-list base 0x2e4b49 size 0x000d1
3729 
3730    Each line of the partition table is terminated with the bytes 09 0d 0a ("\t\r\n"),
3731    the end of the partition table is marked with a zero byte.
3732 
3733    The firmware image must contain at least the partition-table and support-list partitions
3734    to be accepted. There aren't any alignment constraints for the image partitions.
3735 
3736    The partition-table partition contains the actual flash layout; partitions
3737    from the image partition table are mapped to the corresponding flash partitions during
3738    the firmware upgrade. The support-list partition contains a list of devices supported by
3739    the firmware image.
3740 
3741    The base offsets in the firmware partition table are relative to the end
3742    of the vendor information block, so the partition-table partition will
3743    actually start at offset 0x1814 of the image.
3744 
3745    I think partition-table must be the first partition in the firmware image.
3746 */
3747 static void put_partitions(uint8_t *buffer, const struct flash_partition_entry *flash_parts, const struct image_partition_entry *parts) {
3748         size_t i, j;
3749         char *image_pt = (char *)buffer, *end = image_pt + SAFELOADER_PAYLOAD_TABLE_SIZE;
3750 
3751         size_t base = SAFELOADER_PAYLOAD_TABLE_SIZE;
3752         for (i = 0; parts[i].name; i++) {
3753                 for (j = 0; flash_parts[j].name; j++) {
3754                         if (!strcmp(flash_parts[j].name, parts[i].name)) {
3755                                 if (parts[i].size > flash_parts[j].size)
3756                                         error(1, 0, "%s partition too big (more than %u bytes)", flash_parts[j].name, (unsigned)flash_parts[j].size);
3757                                 break;
3758                         }
3759                 }
3760 
3761                 assert(flash_parts[j].name);
3762 
3763                 memcpy(buffer + base, parts[i].data, parts[i].size);
3764 
3765                 size_t len = end-image_pt;
3766                 size_t w = snprintf(image_pt, len, "fwup-ptn %s base 0x%05x size 0x%05x\t\r\n", parts[i].name, (unsigned)base, (unsigned)parts[i].size);
3767 
3768                 if (w > len-1)
3769                         error(1, 0, "image partition table overflow?");
3770 
3771                 image_pt += w;
3772 
3773                 base += parts[i].size;
3774         }
3775 }
3776 
3777 /** Generates and writes the image MD5 checksum */
3778 static void put_md5(uint8_t *md5, uint8_t *buffer, unsigned int len) {
3779         MD5_CTX ctx;
3780 
3781         MD5_Init(&ctx);
3782         MD5_Update(&ctx, md5_salt, (unsigned int)sizeof(md5_salt));
3783         MD5_Update(&ctx, buffer, len);
3784         MD5_Final(md5, &ctx);
3785 }
3786 
3787 
3788 /**
3789    Generates the firmware image in factory format
3790 
3791    Image format:
3792 
3793      Bytes (hex)  Usage
3794      -----------  -----
3795      0000-0003    Image size (4 bytes, big endian)
3796      0004-0013    MD5 hash (hash of a 16 byte salt and the image data starting with byte 0x14)
3797      0014-0017    Vendor information length (without padding) (4 bytes, big endian)
3798      0018-1013    Vendor information (4092 bytes, padded with 0xff; there seem to be older
3799                   (VxWorks-based) TP-LINK devices which use a smaller vendor information block)
3800      1014-1813    Image partition table (2048 bytes, padded with 0xff)
3801      1814-xxxx    Firmware partitions
3802 */
3803 static void * generate_factory_image(struct device_info *info, const struct image_partition_entry *parts, size_t *len) {
3804         *len = SAFELOADER_PAYLOAD_OFFSET + SAFELOADER_PAYLOAD_TABLE_SIZE;
3805 
3806         size_t i;
3807         for (i = 0; parts[i].name; i++)
3808                 *len += parts[i].size;
3809 
3810         uint8_t *image = malloc(*len);
3811         if (!image)
3812                 error(1, errno, "malloc");
3813 
3814         memset(image, 0xff, *len);
3815         put32(image, *len);
3816 
3817         if (info->vendor) {
3818                 size_t vendor_len = strlen(info->vendor);
3819                 put32(image + SAFELOADER_PREAMBLE_SIZE, vendor_len);
3820                 memcpy(image + SAFELOADER_PREAMBLE_SIZE + 0x4, info->vendor, vendor_len);
3821         }
3822 
3823         put_partitions(image + SAFELOADER_PAYLOAD_OFFSET, info->partitions, parts);
3824         put_md5(image + 0x04, image + SAFELOADER_PREAMBLE_SIZE, *len - SAFELOADER_PREAMBLE_SIZE);
3825 
3826         return image;
3827 }
3828 
3829 /**
3830    Generates the firmware image in sysupgrade format
3831 
3832    This makes some assumptions about the provided flash and image partition tables and
3833    should be generalized when TP-LINK starts building its safeloader into hardware with
3834    different flash layouts.
3835 */
3836 static void * generate_sysupgrade_image(struct device_info *info, const struct image_partition_entry *image_parts, size_t *len) {
3837         size_t i, j;
3838         size_t flash_first_partition_index = 0;
3839         size_t flash_last_partition_index = 0;
3840         const struct flash_partition_entry *flash_first_partition = NULL;
3841         const struct flash_partition_entry *flash_last_partition = NULL;
3842         const struct image_partition_entry *image_last_partition = NULL;
3843 
3844         /** Find first and last partitions */
3845         for (i = 0; info->partitions[i].name; i++) {
3846                 if (!strcmp(info->partitions[i].name, info->first_sysupgrade_partition)) {
3847                         flash_first_partition = &info->partitions[i];
3848                         flash_first_partition_index = i;
3849                 } else if (!strcmp(info->partitions[i].name, info->last_sysupgrade_partition)) {
3850                         flash_last_partition = &info->partitions[i];
3851                         flash_last_partition_index = i;
3852                 }
3853         }
3854 
3855         assert(flash_first_partition && flash_last_partition);
3856         assert(flash_first_partition_index < flash_last_partition_index);
3857 
3858         /** Find last partition from image to calculate needed size */
3859         for (i = 0; image_parts[i].name; i++) {
3860                 if (!strcmp(image_parts[i].name, info->last_sysupgrade_partition)) {
3861                         image_last_partition = &image_parts[i];
3862                         break;
3863                 }
3864         }
3865 
3866         assert(image_last_partition);
3867 
3868         *len = flash_last_partition->base - flash_first_partition->base + image_last_partition->size;
3869 
3870         uint8_t *image = malloc(*len);
3871         if (!image)
3872                 error(1, errno, "malloc");
3873 
3874         memset(image, 0xff, *len);
3875 
3876         for (i = flash_first_partition_index; i <= flash_last_partition_index; i++) {
3877                 for (j = 0; image_parts[j].name; j++) {
3878                         if (!strcmp(info->partitions[i].name, image_parts[j].name)) {
3879                                 if (image_parts[j].size > info->partitions[i].size)
3880                                         error(1, 0, "%s partition too big (more than %u bytes)", info->partitions[i].name, (unsigned)info->partitions[i].size);
3881                                 memcpy(image + info->partitions[i].base - flash_first_partition->base, image_parts[j].data, image_parts[j].size);
3882                                 break;
3883                         }
3884 
3885                         assert(image_parts[j].name);
3886                 }
3887         }
3888 
3889         return image;
3890 }
3891 
3892 /** Generates an image according to a given layout and writes it to a file */
3893 static void build_image(const char *output,
3894                 const char *kernel_image,
3895                 const char *rootfs_image,
3896                 uint32_t rev,
3897                 bool add_jffs2_eof,
3898                 bool sysupgrade,
3899                 struct device_info *info) {
3900 
3901         size_t i;
3902 
3903         struct image_partition_entry parts[7] = {};
3904 
3905         struct flash_partition_entry *firmware_partition = NULL;
3906         struct flash_partition_entry *os_image_partition = NULL;
3907         struct flash_partition_entry *file_system_partition = NULL;
3908         size_t firmware_partition_index = 0;
3909 
3910         set_partition_names(info);
3911 
3912         for (i = 0; info->partitions[i].name; i++) {
3913                 if (!strcmp(info->partitions[i].name, "firmware"))
3914                 {
3915                         firmware_partition = &info->partitions[i];
3916                         firmware_partition_index = i;
3917                 }
3918         }
3919 
3920         if (firmware_partition)
3921         {
3922                 os_image_partition = &info->partitions[firmware_partition_index];
3923                 file_system_partition = &info->partitions[firmware_partition_index + 1];
3924 
3925                 struct stat kernel;
3926                 if (stat(kernel_image, &kernel) < 0)
3927                         error(1, errno, "unable to stat file `%s'", kernel_image);
3928 
3929                 if (kernel.st_size > firmware_partition->size)
3930                         error(1, 0, "kernel overflowed firmware partition\n");
3931 
3932                 for (i = MAX_PARTITIONS-1; i >= firmware_partition_index + 1; i--)
3933                         info->partitions[i+1] = info->partitions[i];
3934 
3935                 file_system_partition->name = info->partition_names.file_system;
3936 
3937                 file_system_partition->base = firmware_partition->base + kernel.st_size;
3938 
3939                 /* Align partition start to erase blocks for factory images only */
3940                 if (!sysupgrade)
3941                         file_system_partition->base = ALIGN(firmware_partition->base + kernel.st_size, 0x10000);
3942 
3943                 file_system_partition->size = firmware_partition->size - file_system_partition->base;
3944 
3945                 os_image_partition->name = info->partition_names.os_image;
3946 
3947                 os_image_partition->size = kernel.st_size;
3948         }
3949 
3950         parts[0] = make_partition_table(info);
3951         parts[1] = make_soft_version(info, rev);
3952         parts[2] = make_support_list(info);
3953         parts[3] = read_file(info->partition_names.os_image, kernel_image, false, NULL);
3954         parts[4] = read_file(info->partition_names.file_system, rootfs_image, add_jffs2_eof, file_system_partition);
3955 
3956 
3957         /* Some devices need the extra-para partition to accept the firmware */
3958         if (strcasecmp(info->id, "ARCHER-A6-V3") == 0 ||
3959             strcasecmp(info->id, "ARCHER-A7-V5") == 0 ||
3960             strcasecmp(info->id, "ARCHER-A9-V6") == 0 ||
3961             strcasecmp(info->id, "ARCHER-AX21-V4") == 0 ||
3962             strcasecmp(info->id, "ARCHER-AX23-V1") == 0 ||
3963             strcasecmp(info->id, "ARCHER-C2-V3") == 0 ||
3964             strcasecmp(info->id, "ARCHER-C7-V4") == 0 ||
3965             strcasecmp(info->id, "ARCHER-C7-V5") == 0 ||
3966             strcasecmp(info->id, "ARCHER-C25-V1") == 0 ||
3967             strcasecmp(info->id, "ARCHER-C59-V2") == 0 ||
3968             strcasecmp(info->id, "ARCHER-C60-V2") == 0 ||
3969             strcasecmp(info->id, "ARCHER-C60-V3") == 0 ||
3970             strcasecmp(info->id, "ARCHER-C6U-V1") == 0 ||
3971             strcasecmp(info->id, "ARCHER-C6-V3") == 0 ||
3972             strcasecmp(info->id, "DECO-M4R-V4") == 0 ||
3973             strcasecmp(info->id, "MR70X") == 0 ||
3974             strcasecmp(info->id, "TLWR1043NV5") == 0) {
3975                 const uint8_t extra_para[2] = {0x01, 0x00};
3976                 parts[5] = make_extra_para(info, extra_para,
3977                         sizeof(extra_para));
3978         } else if (strcasecmp(info->id, "ARCHER-C6-V2") == 0 ||
3979                    strcasecmp(info->id, "TL-WA1201-V2") == 0) {
3980                 const uint8_t extra_para[2] = {0x00, 0x01};
3981                 parts[5] = make_extra_para(info, extra_para,
3982                         sizeof(extra_para));
3983         } else if (strcasecmp(info->id, "ARCHER-C6-V2-US") == 0 ||
3984                    strcasecmp(info->id, "EAP245-V3") == 0) {
3985                 const uint8_t extra_para[2] = {0x01, 0x01};
3986                 parts[5] = make_extra_para(info, extra_para,
3987                         sizeof(extra_para));
3988         }
3989 
3990         size_t len;
3991         void *image;
3992         if (sysupgrade)
3993                 image = generate_sysupgrade_image(info, parts, &len);
3994         else
3995                 image = generate_factory_image(info, parts, &len);
3996 
3997         FILE *file = fopen(output, "wb");
3998         if (!file)
3999                 error(1, errno, "unable to open output file");
4000 
4001         if (fwrite(image, len, 1, file) != 1)
4002                 error(1, 0, "unable to write output file");
4003 
4004         fclose(file);
4005 
4006         free(image);
4007 
4008         for (i = 0; parts[i].name; i++)
4009                 free_image_partition(&parts[i]);
4010 }
4011 
4012 /** Usage output */
4013 static void usage(const char *argv0) {
4014         fprintf(stderr,
4015                 "Usage: %s [OPTIONS...]\n"
4016                 "\n"
4017                 "Options:\n"
4018                 "  -h              show this help\n"
4019                 "\n"
4020                 "Info about an image:\n"
4021                 "  -i <file>       input file to read from\n"
4022                 "Create a new image:\n"
4023                 "  -B <board>      create image for the board specified with <board>\n"
4024                 "  -k <file>       read kernel image from the file <file>\n"
4025                 "  -r <file>       read rootfs image from the file <file>\n"
4026                 "  -o <file>       write output to the file <file>\n"
4027                 "  -V <rev>        sets the revision number to <rev>\n"
4028                 "  -j              add jffs2 end-of-filesystem markers\n"
4029                 "  -S              create sysupgrade instead of factory image\n"
4030                 "Extract an old image:\n"
4031                 "  -x <file>       extract all oem firmware partition\n"
4032                 "  -d <dir>        destination to extract the firmware partition\n"
4033                 "  -z <file>       convert an oem firmware into a sysupgade file. Use -o for output file\n",
4034                 argv0
4035         );
4036 };
4037 
4038 
4039 static struct device_info *find_board(const char *id)
4040 {
4041         struct device_info *board = NULL;
4042 
4043         for (board = boards; board->id != NULL; board++)
4044                 if (strcasecmp(id, board->id) == 0)
4045                         return board;
4046 
4047         return NULL;
4048 }
4049 
4050 static int add_flash_partition(
4051                 struct flash_partition_entry *part_list,
4052                 size_t max_entries,
4053                 const char *name,
4054                 unsigned long base,
4055                 unsigned long size)
4056 {
4057         size_t ptr;
4058         /* check if the list has a free entry */
4059         for (ptr = 0; ptr < max_entries; ptr++, part_list++) {
4060                 if (part_list->name == NULL &&
4061                                 part_list->base == 0 &&
4062                                 part_list->size == 0)
4063                         break;
4064         }
4065 
4066         if (ptr == max_entries) {
4067                 error(1, 0, "No free flash part entry available.");
4068         }
4069 
4070         part_list->name = calloc(1, strlen(name) + 1);
4071         if (!part_list->name) {
4072                 error(1, 0, "Unable to allocate memory");
4073         }
4074 
4075         memcpy((char *)part_list->name, name, strlen(name));
4076         part_list->base = base;
4077         part_list->size = size;
4078 
4079         return 0;
4080 }
4081 
4082 /** read the partition table into struct flash_partition_entry */
4083 enum PARTITION_TABLE_TYPE {
4084         PARTITION_TABLE_FWUP,
4085         PARTITION_TABLE_FLASH,
4086 };
4087 
4088 static int read_partition_table(
4089                 FILE *file, long offset,
4090                 struct flash_partition_entry *entries, size_t max_entries,
4091                 int type)
4092 {
4093         char buf[SAFELOADER_PAYLOAD_TABLE_SIZE];
4094         char *ptr, *end;
4095         const char *parthdr = NULL;
4096         const char *fwuphdr = "fwup-ptn";
4097         const char *flashhdr = "partition";
4098 
4099         /* TODO: search for the partition table */
4100 
4101         switch(type) {
4102         case PARTITION_TABLE_FWUP:
4103                 parthdr = fwuphdr;
4104                 break;
4105         case PARTITION_TABLE_FLASH:
4106                 parthdr = flashhdr;
4107                 break;
4108         default:
4109                 error(1, 0, "Invalid partition table");
4110         }
4111 
4112         if (fseek(file, offset, SEEK_SET) < 0)
4113                 error(1, errno, "Can not seek in the firmware");
4114 
4115         if (fread(buf, sizeof(buf), 1, file) != 1)
4116                 error(1, errno, "Can not read fwup-ptn from the firmware");
4117 
4118         buf[sizeof(buf) - 1] = '\0';
4119 
4120         /* look for the partition header */
4121         if (memcmp(buf, parthdr, strlen(parthdr)) != 0) {
4122                 fprintf(stderr, "DEBUG: can not find fwuphdr\n");
4123                 return 1;
4124         }
4125 
4126         ptr = buf;
4127         end = buf + sizeof(buf);
4128         while ((ptr + strlen(parthdr)) < end &&
4129                         memcmp(ptr, parthdr, strlen(parthdr)) == 0) {
4130                 char *end_part;
4131                 char *end_element;
4132 
4133                 char name[32] = { 0 };
4134                 int name_len = 0;
4135                 unsigned long base = 0;
4136                 unsigned long size = 0;
4137 
4138                 end_part = memchr(ptr, '\n', (end - ptr));
4139                 if (end_part == NULL) {
4140                         /* in theory this should never happen, because a partition always ends with 0x09, 0x0D, 0x0A */
4141                         break;
4142                 }
4143 
4144                 for (int i = 0; i <= 4; i++) {
4145                         if (end_part <= ptr)
4146                                 break;
4147 
4148                         end_element = memchr(ptr, 0x20, (end_part - ptr));
4149                         if (end_element == NULL) {
4150                                 error(1, errno, "Ignoring the rest of the partition entries.");
4151                                 break;
4152                         }
4153 
4154                         switch (i) {
4155                                 /* partition header */
4156                                 case 0:
4157                                         ptr = end_element + 1;
4158                                         continue;
4159                                 /* name */
4160                                 case 1:
4161                                         name_len = (end_element - ptr) > 31 ? 31 : (end_element - ptr);
4162                                         strncpy(name, ptr, name_len);
4163                                         name[name_len] = '\0';
4164                                         ptr = end_element + 1;
4165                                         continue;
4166 
4167                                 /* string "base" */
4168                                 case 2:
4169                                         ptr = end_element + 1;
4170                                         continue;
4171 
4172                                 /* actual base */
4173                                 case 3:
4174                                         base = strtoul(ptr, NULL, 16);
4175                                         ptr = end_element + 1;
4176                                         continue;
4177 
4178                                 /* string "size" */
4179                                 case 4:
4180                                         ptr = end_element + 1;
4181                                         /* actual size. The last element doesn't have a sepeartor */
4182                                         size = strtoul(ptr, NULL, 16);
4183                                         /* the part ends with 0x09, 0x0d, 0x0a */
4184                                         ptr = end_part + 1;
4185                                         add_flash_partition(entries, max_entries, name, base, size);
4186                                         continue;
4187                         }
4188                 }
4189         }
4190 
4191         return 0;
4192 }
4193 
4194 static void safeloader_read_partition(FILE *input_file, size_t payload_offset,
4195                                       struct flash_partition_entry *entry,
4196                                       struct image_partition_entry *part)
4197 {
4198         size_t part_size = entry->size;
4199         void *part_data = malloc(part_size);
4200 
4201         if (fseek(input_file, payload_offset, SEEK_SET))
4202                 error(1, errno, "Failed to seek to partition data");
4203 
4204         if (!part_data)
4205                 error(1, ENOMEM, "Failed to allocate partition data");
4206 
4207         if (fread(part_data, 1, part_size, input_file) < part_size)
4208                 error(1, errno, "Failed to read partition data");
4209 
4210         part->data = part_data;
4211         part->size = part_size;
4212         part->name = entry->name;
4213 }
4214 
4215 static void safeloader_parse_image(FILE *input_file, struct safeloader_image_info *image)
4216 {
4217         static const char *HEADER_ID_CLOUD = "fw-type:Cloud";
4218         static const char *HEADER_ID_QNEW = "?NEW";
4219 
4220         char buf[64];
4221 
4222         if (!input_file)
4223                 return;
4224 
4225         fseek(input_file, SAFELOADER_PREAMBLE_SIZE, SEEK_SET);
4226 
4227         if (fread(buf, sizeof(buf), 1, input_file) != 1)
4228                 error(1, errno, "Can not read image header");
4229 
4230         if (memcmp(HEADER_ID_QNEW, &buf[0], strlen(HEADER_ID_QNEW)) == 0)
4231                 image->type = SAFELOADER_TYPE_QNEW;
4232         else if (memcmp(HEADER_ID_CLOUD, &buf[0], strlen(HEADER_ID_CLOUD)) == 0)
4233                 image->type = SAFELOADER_TYPE_CLOUD;
4234         else if (ntohl(*((uint32_t *) &buf[0])) <= SAFELOADER_HEADER_SIZE)
4235                 image->type = SAFELOADER_TYPE_VENDOR;
4236         else
4237                 image->type = SAFELOADER_TYPE_DEFAULT;
4238 
4239         switch (image->type) {
4240         case SAFELOADER_TYPE_DEFAULT:
4241         case SAFELOADER_TYPE_VENDOR:
4242         case SAFELOADER_TYPE_CLOUD:
4243                 image->payload_offset = SAFELOADER_PAYLOAD_OFFSET;
4244                 break;
4245         case SAFELOADER_TYPE_QNEW:
4246                 image->payload_offset = SAFELOADER_QNEW_PAYLOAD_OFFSET;
4247                 break;
4248         }
4249 
4250         /* Parse image partition table */
4251         read_partition_table(input_file, image->payload_offset, &image->entries[0],
4252                              MAX_PARTITIONS, PARTITION_TABLE_FWUP);
4253 }
4254 
4255 static void write_partition(
4256                 FILE *input_file,
4257                 size_t firmware_offset,
4258                 struct flash_partition_entry *entry,
4259                 FILE *output_file)
4260 {
4261         char buf[4096];
4262         size_t offset;
4263 
4264         fseek(input_file, entry->base + firmware_offset, SEEK_SET);
4265 
4266         for (offset = 0; sizeof(buf) + offset <= entry->size; offset += sizeof(buf)) {
4267                 if (fread(buf, sizeof(buf), 1, input_file) != 1)
4268                         error(1, errno, "Can not read partition from input_file");
4269 
4270                 if (fwrite(buf, sizeof(buf), 1, output_file) != 1)
4271                         error(1, errno, "Can not write partition to output_file");
4272         }
4273         /* write last chunk smaller than buffer */
4274         if (offset < entry->size) {
4275                 offset = entry->size - offset;
4276                 if (fread(buf, offset, 1, input_file) != 1)
4277                         error(1, errno, "Can not read partition from input_file");
4278                 if (fwrite(buf, offset, 1, output_file) != 1)
4279                         error(1, errno, "Can not write partition to output_file");
4280         }
4281 }
4282 
4283 static int extract_firmware_partition(FILE *input_file, size_t firmware_offset, struct flash_partition_entry *entry, const char *output_directory)
4284 {
4285         FILE *output_file;
4286         char output[PATH_MAX];
4287 
4288         snprintf(output, PATH_MAX, "%s/%s", output_directory, entry->name);
4289         output_file = fopen(output, "wb+");
4290         if (output_file == NULL) {
4291                 error(1, errno, "Can not open output file %s", output);
4292         }
4293 
4294         write_partition(input_file, firmware_offset, entry, output_file);
4295 
4296         fclose(output_file);
4297 
4298         return 0;
4299 }
4300 
4301 /** extract all partitions from the firmware file */
4302 static int extract_firmware(const char *input, const char *output_directory)
4303 {
4304         struct safeloader_image_info info = {};
4305         struct stat statbuf;
4306         FILE *input_file;
4307 
4308         /* check input file */
4309         if (stat(input, &statbuf)) {
4310                 error(1, errno, "Can not read input firmware %s", input);
4311         }
4312 
4313         /* check if output directory exists */
4314         if (stat(output_directory, &statbuf)) {
4315                 error(1, errno, "Failed to stat output directory %s", output_directory);
4316         }
4317 
4318         if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
4319                 error(1, errno, "Given output directory is not a directory %s", output_directory);
4320         }
4321 
4322         input_file = fopen(input, "rb");
4323         safeloader_parse_image(input_file, &info);
4324 
4325         for (size_t i = 0; i < MAX_PARTITIONS && info.entries[i].name; i++)
4326                 extract_firmware_partition(input_file, info.payload_offset, &info.entries[i], output_directory);
4327 
4328         return 0;
4329 }
4330 
4331 static struct flash_partition_entry *find_partition(
4332                 struct flash_partition_entry *entries, size_t max_entries,
4333                 const char *name, const char *error_msg)
4334 {
4335         for (size_t i = 0; i < max_entries; i++, entries++) {
4336                 if (entries->name && strcmp(entries->name, name) == 0)
4337                         return entries;
4338         }
4339 
4340         if (error_msg) {
4341                 error(1, 0, "%s", error_msg);
4342         }
4343 
4344         return NULL;
4345 }
4346 
4347 static int firmware_info(const char *input)
4348 {
4349         struct safeloader_image_info info = {};
4350         struct image_partition_entry part = {};
4351         struct flash_partition_entry *e;
4352         FILE *input_file;
4353 
4354         input_file = fopen(input, "rb");
4355 
4356         safeloader_parse_image(input_file, &info);
4357 
4358         if (info.type == SAFELOADER_TYPE_VENDOR) {
4359                 char buf[SAFELOADER_HEADER_SIZE] = {};
4360                 uint32_t vendor_size;
4361 
4362                 fseek(input_file, SAFELOADER_PREAMBLE_SIZE, SEEK_SET);
4363                 fread(&vendor_size, sizeof(uint32_t), 1, input_file);
4364 
4365                 vendor_size = ntohl(vendor_size);
4366                 fread(buf, vendor_size, 1, input_file);
4367 
4368                 printf("Firmware vendor string:\n");
4369                 fwrite(buf, strnlen(buf, vendor_size), 1, stdout);
4370                 printf("\n");
4371         }
4372 
4373         printf("Firmware image partitions:\n");
4374         printf("%-8s %-8s %s\n", "base", "size", "name");
4375 
4376         e = &info.entries[0];
4377         for (unsigned int i = 0; i < MAX_PARTITIONS && e->name; i++, e++)
4378                 printf("%08x %08x %s\n", e->base, e->size, e->name);
4379 
4380         e = find_partition(&info.entries[0], MAX_PARTITIONS, "soft-version", NULL);
4381         if (e) {
4382                 struct soft_version *s;
4383                 unsigned int ascii_len;
4384                 const uint8_t *buf;
4385                 size_t data_len;
4386                 bool isstr;
4387 
4388                 safeloader_read_partition(input_file, info.payload_offset + e->base, e, &part);
4389                 data_len = ntohl(((struct meta_header *) part.data)->length);
4390                 buf = part.data + sizeof(struct meta_header);
4391 
4392                 /* Check for (null-terminated) string */
4393                 ascii_len = 0;
4394                 while (ascii_len < data_len && isascii(buf[ascii_len]))
4395                         ascii_len++;
4396 
4397                 isstr = ascii_len == data_len;
4398 
4399                 printf("\n[Software version]\n");
4400                 if (isstr) {
4401                         fwrite(buf, strnlen((const char *) buf, data_len), 1, stdout);
4402                         putchar('\n');
4403                 } else if (data_len >= offsetof(struct soft_version, rev)) {
4404                         s = (struct soft_version *) buf;
4405 
4406                         printf("Version: %d.%d.%d\n", s->version_major, s->version_minor, s->version_patch);
4407                         printf("Date: %02x%02x-%02x-%02x\n", s->year_hi, s->year_lo, s->month, s->day);
4408                         printf("Revision: %d\n", ntohl(s->rev));
4409 
4410                         if (data_len >= offsetof(struct soft_version, compat_level)) {
4411                                 printf("Compatibility level: %d\n", ntohl(s->compat_level));
4412                         }
4413                 } else {
4414                         printf("Failed to parse data\n");
4415                 }
4416 
4417                 free_image_partition(&part);
4418         }
4419 
4420         e = find_partition(&info.entries[0], MAX_PARTITIONS, "support-list", NULL);
4421         if (e) {
4422                 size_t data_len;
4423 
4424                 safeloader_read_partition(input_file, info.payload_offset + e->base, e, &part);
4425                 data_len = ntohl(((struct meta_header *) part.data)->length);
4426 
4427                 printf("\n[Support list]\n");
4428                 fwrite(part.data + sizeof(struct meta_header), data_len, 1, stdout);
4429                 printf("\n");
4430 
4431                 free_image_partition(&part);
4432         }
4433 
4434         e = find_partition(&info.entries[0], MAX_PARTITIONS, "partition-table", NULL);
4435         if (e) {
4436                 size_t flash_table_offset = info.payload_offset + e->base + 4;
4437                 struct flash_partition_entry parts[MAX_PARTITIONS] = {};
4438 
4439                 if (read_partition_table(input_file, flash_table_offset, parts, MAX_PARTITIONS, PARTITION_TABLE_FLASH))
4440                         error(1, 0, "Error can not read the partition table (partition)");
4441 
4442                 printf("\n[Partition table]\n");
4443                 printf("%-8s %-8s %s\n", "base", "size", "name");
4444 
4445                 e = &parts[0];
4446                 for (unsigned int i = 0; i < MAX_PARTITIONS && e->name; i++, e++)
4447                         printf("%08x %08x %s\n", e->base, e->size, e->name);
4448         }
4449 
4450         fclose(input_file);
4451 
4452         return 0;
4453 }
4454 
4455 static void write_ff(FILE *output_file, size_t size)
4456 {
4457         char buf[4096];
4458         size_t offset;
4459 
4460         memset(buf, 0xff, sizeof(buf));
4461 
4462         for (offset = 0; offset + sizeof(buf) < size ; offset += sizeof(buf)) {
4463                 if (fwrite(buf, sizeof(buf), 1, output_file) != 1)
4464                         error(1, errno, "Can not write 0xff to output_file");
4465         }
4466 
4467         /* write last chunk smaller than buffer */
4468         if (offset < size) {
4469                 offset = size - offset;
4470                 if (fwrite(buf, offset, 1, output_file) != 1)
4471                         error(1, errno, "Can not write partition to output_file");
4472         }
4473 }
4474 
4475 static void convert_firmware(const char *input, const char *output)
4476 {
4477         struct flash_partition_entry flash[MAX_PARTITIONS] = {};
4478         struct flash_partition_entry *fwup_partition_table;
4479         struct flash_partition_entry *flash_file_system;
4480         struct flash_partition_entry *fwup_file_system;
4481         struct flash_partition_entry *flash_os_image;
4482         struct flash_partition_entry *fwup_os_image;
4483         struct safeloader_image_info info = {};
4484         size_t flash_table_offset;
4485         struct stat statbuf;
4486         FILE *output_file;
4487         FILE *input_file;
4488 
4489         /* check input file */
4490         if (stat(input, &statbuf)) {
4491                 error(1, errno, "Can not read input firmware %s", input);
4492         }
4493 
4494         input_file = fopen(input, "rb");
4495         if (!input_file)
4496                 error(1, 0, "Can not open input firmware %s", input);
4497 
4498         output_file = fopen(output, "wb");
4499         if (!output_file)
4500                 error(1, 0, "Can not open output firmware %s", output);
4501 
4502         input_file = fopen(input, "rb");
4503         safeloader_parse_image(input_file, &info);
4504 
4505         fwup_os_image = find_partition(info.entries, MAX_PARTITIONS,
4506                         "os-image", "Error can not find os-image partition (fwup)");
4507         fwup_file_system = find_partition(info.entries, MAX_PARTITIONS,
4508                         "file-system", "Error can not find file-system partition (fwup)");
4509         fwup_partition_table = find_partition(info.entries, MAX_PARTITIONS,
4510                         "partition-table", "Error can not find partition-table partition");
4511 
4512         /* the flash partition table has a 0x00000004 magic haeder */
4513         flash_table_offset = info.payload_offset + fwup_partition_table->base + 4;
4514         if (read_partition_table(input_file, flash_table_offset, flash, MAX_PARTITIONS, PARTITION_TABLE_FLASH) != 0)
4515                 error(1, 0, "Error can not read the partition table (flash)");
4516 
4517         flash_os_image = find_partition(flash, MAX_PARTITIONS,
4518                         "os-image", "Error can not find os-image partition (flash)");
4519         flash_file_system = find_partition(flash, MAX_PARTITIONS,
4520                         "file-system", "Error can not find file-system partition (flash)");
4521 
4522         /* write os_image to 0x0 */
4523         write_partition(input_file, info.payload_offset, fwup_os_image, output_file);
4524         write_ff(output_file, flash_os_image->size - fwup_os_image->size);
4525 
4526         /* write file-system behind os_image */
4527         fseek(output_file, flash_file_system->base - flash_os_image->base, SEEK_SET);
4528         write_partition(input_file, info.payload_offset, fwup_file_system, output_file);
4529 
4530         fclose(output_file);
4531         fclose(input_file);
4532 }
4533 
4534 int main(int argc, char *argv[]) {
4535         const char *info_image = NULL, *board = NULL, *kernel_image = NULL, *rootfs_image = NULL, *output = NULL;
4536         const char *extract_image = NULL, *output_directory = NULL, *convert_image = NULL;
4537         bool add_jffs2_eof = false, sysupgrade = false;
4538         unsigned rev = 0;
4539         struct device_info *info;
4540         set_source_date_epoch();
4541 
4542         while (true) {
4543                 int c;
4544 
4545                 c = getopt(argc, argv, "i:B:k:r:o:V:jSh:x:d:z:");
4546                 if (c == -1)
4547                         break;
4548 
4549                 switch (c) {
4550                 case 'i':
4551                         info_image = optarg;
4552                         break;
4553 
4554                 case 'B':
4555                         board = optarg;
4556                         break;
4557 
4558                 case 'k':
4559                         kernel_image = optarg;
4560                         break;
4561 
4562                 case 'r':
4563                         rootfs_image = optarg;
4564                         break;
4565 
4566                 case 'o':
4567                         output = optarg;
4568                         break;
4569 
4570                 case 'V':
4571                         sscanf(optarg, "r%u", &rev);
4572                         break;
4573 
4574                 case 'j':
4575                         add_jffs2_eof = true;
4576                         break;
4577 
4578                 case 'S':
4579                         sysupgrade = true;
4580                         break;
4581 
4582                 case 'h':
4583                         usage(argv[0]);
4584                         return 0;
4585 
4586                 case 'd':
4587                         output_directory = optarg;
4588                         break;
4589 
4590                 case 'x':
4591                         extract_image = optarg;
4592                         break;
4593 
4594                 case 'z':
4595                         convert_image = optarg;
4596                         break;
4597 
4598                 default:
4599                         usage(argv[0]);
4600                         return 1;
4601                 }
4602         }
4603 
4604         if (info_image) {
4605                 firmware_info(info_image);
4606         } else if (extract_image || output_directory) {
4607                 if (!extract_image)
4608                         error(1, 0, "No factory/oem image given via -x <file>. Output directory is only valid with -x");
4609                 if (!output_directory)
4610                         error(1, 0, "Can not extract an image without output directory. Use -d <dir>");
4611                 extract_firmware(extract_image, output_directory);
4612         } else if (convert_image) {
4613                 if (!output)
4614                         error(1, 0, "Can not convert a factory/oem image into sysupgrade image without output file. Use -o <file>");
4615                 convert_firmware(convert_image, output);
4616         } else {
4617                 if (!board)
4618                         error(1, 0, "no board has been specified");
4619                 if (!kernel_image)
4620                         error(1, 0, "no kernel image has been specified");
4621                 if (!rootfs_image)
4622                         error(1, 0, "no rootfs image has been specified");
4623                 if (!output)
4624                         error(1, 0, "no output filename has been specified");
4625 
4626                 info = find_board(board);
4627 
4628                 if (info == NULL)
4629                         error(1, 0, "unsupported board %s", board);
4630 
4631                 build_image(output, kernel_image, rootfs_image, rev, add_jffs2_eof, sysupgrade, info);
4632         }
4633 
4634         return 0;
4635 }
4636 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt