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