1 // SPDX-License-Identifier: BSD-2-Clause
3 Copyright (c) 2014, Matthias Schiffer <mschiffer@universe-factory.net>
11 Image generation tool for the TP-LINK SafeLoader as seen on
12 TP-LINK Pharos devices (CPE210/220/510/520)
28 #include <arpa/inet.h>
30 #include <sys/types.h>
37 #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
40 #define MAX_PARTITIONS 32
42 /** An image partition table entry */
43 struct image_partition_entry
{
49 /** A flash partition table entry */
50 struct flash_partition_entry
{
56 /** Partition trailing padding definitions
57 * Values 0x00 to 0xff are reserved to indicate the padding value
58 * Values from 0x100 are reserved to indicate other behaviour */
59 enum partition_trail_value
{
62 PART_TRAIL_MAX
= 0xff,
63 PART_TRAIL_NONE
= 0x100
66 /** soft-version value overwrite types
67 * The default (for an uninitialised soft_ver field) is to use the numerical
68 * version number "0.0.0"
71 SOFT_VER_TYPE_NUMERIC
= 0,
72 SOFT_VER_TYPE_TEXT
= 1,
75 /** Firmware layout description */
79 const char *support_list
;
80 enum partition_trail_value part_trail
;
82 enum soft_ver_type type
;
88 uint32_t soft_ver_compat_level
;
89 struct flash_partition_entry partitions
[MAX_PARTITIONS
+1];
90 const char *first_sysupgrade_partition
;
91 const char *last_sysupgrade_partition
;
94 #define SOFT_VER_TEXT(_t) {.type = SOFT_VER_TYPE_TEXT, .text = _t}
95 #define SOFT_VER_NUMERIC(_maj, _min, _patch) { \
96 .type = SOFT_VER_TYPE_NUMERIC, \
97 .num = {_maj, _min, _patch}}
98 #define SOFT_VER_DEFAULT SOFT_VER_NUMERIC(0, 0, 0)
100 struct __attribute__((__packed__
)) meta_header
{
105 /** The content of the soft-version structure */
106 struct __attribute__((__packed__
)) soft_version
{
108 uint8_t version_major
;
109 uint8_t version_minor
;
110 uint8_t version_patch
;
116 uint32_t compat_level
;
120 static const uint8_t jffs2_eof_mark
[4] = {0xde, 0xad, 0xc0, 0xde};
124 Salt for the MD5 hash
126 Fortunately, TP-LINK seems to use the same salt for most devices which use
127 the new image format.
129 static const uint8_t md5_salt
[16] = {
130 0x7a, 0x2b, 0x15, 0xed,
131 0x9b, 0x98, 0x59, 0x6d,
132 0xe5, 0x04, 0xab, 0x44,
133 0xac, 0x2a, 0x9f, 0x4e,
137 /** Firmware layout table */
138 static struct device_info boards
[] = {
139 /** Firmware layout for the CPE210/220 V1 */
142 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
145 "CPE210(TP-LINK|UN|N300-2):1.0\r\n"
146 "CPE210(TP-LINK|UN|N300-2):1.1\r\n"
147 "CPE210(TP-LINK|US|N300-2):1.1\r\n"
148 "CPE210(TP-LINK|EU|N300-2):1.1\r\n"
149 "CPE220(TP-LINK|UN|N300-2):1.1\r\n"
150 "CPE220(TP-LINK|US|N300-2):1.1\r\n"
151 "CPE220(TP-LINK|EU|N300-2):1.1\r\n",
153 .soft_ver
= SOFT_VER_DEFAULT
,
156 {"fs-uboot", 0x00000, 0x20000},
157 {"partition-table", 0x20000, 0x02000},
158 {"default-mac", 0x30000, 0x00020},
159 {"product-info", 0x31100, 0x00100},
160 {"signature", 0x32000, 0x00400},
161 {"firmware", 0x40000, 0x770000},
162 {"soft-version", 0x7b0000, 0x00100},
163 {"support-list", 0x7b1000, 0x00400},
164 {"user-config", 0x7c0000, 0x10000},
165 {"default-config", 0x7d0000, 0x10000},
166 {"log", 0x7e0000, 0x10000},
167 {"radio", 0x7f0000, 0x10000},
171 .first_sysupgrade_partition
= "os-image",
172 .last_sysupgrade_partition
= "support-list",
175 /** Firmware layout for the CPE210 V2 */
178 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n",
181 "CPE210(TP-LINK|EU|N300-2|00000000):2.0\r\n"
182 "CPE210(TP-LINK|EU|N300-2|45550000):2.0\r\n"
183 "CPE210(TP-LINK|EU|N300-2|55530000):2.0\r\n"
184 "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
185 "CPE210(TP-LINK|UN|N300-2|45550000):2.0\r\n"
186 "CPE210(TP-LINK|UN|N300-2|55530000):2.0\r\n"
187 "CPE210(TP-LINK|US|N300-2|55530000):2.0\r\n"
188 "CPE210(TP-LINK|UN|N300-2):2.0\r\n"
189 "CPE210(TP-LINK|EU|N300-2):2.0\r\n"
190 "CPE210(TP-LINK|US|N300-2):2.0\r\n",
192 .soft_ver
= SOFT_VER_DEFAULT
,
195 {"fs-uboot", 0x00000, 0x20000},
196 {"partition-table", 0x20000, 0x02000},
197 {"default-mac", 0x30000, 0x00020},
198 {"product-info", 0x31100, 0x00100},
199 {"device-info", 0x31400, 0x00400},
200 {"signature", 0x32000, 0x00400},
201 {"device-id", 0x33000, 0x00100},
202 {"firmware", 0x40000, 0x770000},
203 {"soft-version", 0x7b0000, 0x00100},
204 {"support-list", 0x7b1000, 0x01000},
205 {"user-config", 0x7c0000, 0x10000},
206 {"default-config", 0x7d0000, 0x10000},
207 {"log", 0x7e0000, 0x10000},
208 {"radio", 0x7f0000, 0x10000},
212 .first_sysupgrade_partition
= "os-image",
213 .last_sysupgrade_partition
= "support-list",
216 /** Firmware layout for the CPE210 V3 */
219 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n",
222 "CPE210(TP-LINK|EU|N300-2|45550000):3.0\r\n"
223 "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n"
224 "CPE210(TP-LINK|US|N300-2|55530000):3.0\r\n"
225 "CPE210(TP-LINK|UN|N300-2):3.0\r\n"
226 "CPE210(TP-LINK|EU|N300-2):3.0\r\n"
227 "CPE210(TP-LINK|EU|N300-2|45550000):3.1\r\n"
228 "CPE210(TP-LINK|UN|N300-2|00000000):3.1\r\n"
229 "CPE210(TP-LINK|US|N300-2|55530000):3.1\r\n"
230 "CPE210(TP-LINK|EU|N300-2|45550000):3.20\r\n"
231 "CPE210(TP-LINK|UN|N300-2|00000000):3.20\r\n"
232 "CPE210(TP-LINK|US|N300-2|55530000):3.20\r\n",
234 .soft_ver
= SOFT_VER_DEFAULT
,
237 {"fs-uboot", 0x00000, 0x20000},
238 {"partition-table", 0x20000, 0x01000},
239 {"default-mac", 0x30000, 0x00020},
240 {"product-info", 0x31100, 0x00100},
241 {"device-info", 0x31400, 0x00400},
242 {"signature", 0x32000, 0x00400},
243 {"device-id", 0x33000, 0x00100},
244 {"firmware", 0x40000, 0x770000},
245 {"soft-version", 0x7b0000, 0x00100},
246 {"support-list", 0x7b1000, 0x01000},
247 {"user-config", 0x7c0000, 0x10000},
248 {"default-config", 0x7d0000, 0x10000},
249 {"log", 0x7e0000, 0x10000},
250 {"radio", 0x7f0000, 0x10000},
254 .first_sysupgrade_partition
= "os-image",
255 .last_sysupgrade_partition
= "support-list",
258 /** Firmware layout for the CPE220 V2 */
261 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
264 "CPE220(TP-LINK|EU|N300-2|00000000):2.0\r\n"
265 "CPE220(TP-LINK|EU|N300-2|45550000):2.0\r\n"
266 "CPE220(TP-LINK|EU|N300-2|55530000):2.0\r\n"
267 "CPE220(TP-LINK|UN|N300-2|00000000):2.0\r\n"
268 "CPE220(TP-LINK|UN|N300-2|45550000):2.0\r\n"
269 "CPE220(TP-LINK|UN|N300-2|55530000):2.0\r\n"
270 "CPE220(TP-LINK|US|N300-2|55530000):2.0\r\n"
271 "CPE220(TP-LINK|UN|N300-2):2.0\r\n"
272 "CPE220(TP-LINK|EU|N300-2):2.0\r\n"
273 "CPE220(TP-LINK|US|N300-2):2.0\r\n",
275 .soft_ver
= SOFT_VER_DEFAULT
,
278 {"fs-uboot", 0x00000, 0x20000},
279 {"partition-table", 0x20000, 0x02000},
280 {"default-mac", 0x30000, 0x00020},
281 {"product-info", 0x31100, 0x00100},
282 {"signature", 0x32000, 0x00400},
283 {"firmware", 0x40000, 0x770000},
284 {"soft-version", 0x7b0000, 0x00100},
285 {"support-list", 0x7b1000, 0x00400},
286 {"user-config", 0x7c0000, 0x10000},
287 {"default-config", 0x7d0000, 0x10000},
288 {"log", 0x7e0000, 0x10000},
289 {"radio", 0x7f0000, 0x10000},
293 .first_sysupgrade_partition
= "os-image",
294 .last_sysupgrade_partition
= "support-list",
297 /** Firmware layout for the CPE220 V3 */
300 .vendor
= "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n",
303 "CPE220(TP-LINK|EU|N300-2|00000000):3.0\r\n"
304 "CPE220(TP-LINK|EU|N300-2|45550000):3.0\r\n"
305 "CPE220(TP-LINK|EU|N300-2|55530000):3.0\r\n"
306 "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n"
307 "CPE220(TP-LINK|UN|N300-2|45550000):3.0\r\n"
308 "CPE220(TP-LINK|UN|N300-2|55530000):3.0\r\n"
309 "CPE220(TP-LINK|US|N300-2|55530000):3.0\r\n"
310 "CPE220(TP-LINK|UN|N300-2):3.0\r\n"
311 "CPE220(TP-LINK|EU|N300-2):3.0\r\n"
312 "CPE220(TP-LINK|US|N300-2):3.0\r\n",
314 .soft_ver
= SOFT_VER_DEFAULT
,
317 {"fs-uboot", 0x00000, 0x20000},
318 {"partition-table", 0x20000, 0x02000},
319 {"default-mac", 0x30000, 0x00020},
320 {"product-info", 0x31100, 0x00100},
321 {"device-info", 0x31400, 0x00400},
322 {"signature", 0x32000, 0x00400},
323 {"device-id", 0x33000, 0x00100},
324 {"firmware", 0x40000, 0x770000},
325 {"soft-version", 0x7b0000, 0x00100},
326 {"support-list", 0x7b1000, 0x01000},
327 {"user-config", 0x7c0000, 0x10000},
328 {"default-config", 0x7d0000, 0x10000},
329 {"log", 0x7e0000, 0x10000},
330 {"radio", 0x7f0000, 0x10000},
334 .first_sysupgrade_partition
= "os-image",
335 .last_sysupgrade_partition
= "support-list",
338 /** Firmware layout for the CPE510/520 V1 */
341 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
344 "CPE510(TP-LINK|UN|N300-5):1.0\r\n"
345 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
346 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
347 "CPE510(TP-LINK|US|N300-5):1.1\r\n"
348 "CPE510(TP-LINK|EU|N300-5):1.1\r\n"
349 "CPE520(TP-LINK|UN|N300-5):1.1\r\n"
350 "CPE520(TP-LINK|US|N300-5):1.1\r\n"
351 "CPE520(TP-LINK|EU|N300-5):1.1\r\n",
353 .soft_ver
= SOFT_VER_DEFAULT
,
356 {"fs-uboot", 0x00000, 0x20000},
357 {"partition-table", 0x20000, 0x02000},
358 {"default-mac", 0x30000, 0x00020},
359 {"product-info", 0x31100, 0x00100},
360 {"signature", 0x32000, 0x00400},
361 {"firmware", 0x40000, 0x770000},
362 {"soft-version", 0x7b0000, 0x00100},
363 {"support-list", 0x7b1000, 0x00400},
364 {"user-config", 0x7c0000, 0x10000},
365 {"default-config", 0x7d0000, 0x10000},
366 {"log", 0x7e0000, 0x10000},
367 {"radio", 0x7f0000, 0x10000},
371 .first_sysupgrade_partition
= "os-image",
372 .last_sysupgrade_partition
= "support-list",
375 /** Firmware layout for the CPE510 V2 */
378 .vendor
= "CPE510(TP-LINK|UN|N300-5):2.0\r\n",
381 "CPE510(TP-LINK|EU|N300-5|00000000):2.0\r\n"
382 "CPE510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
383 "CPE510(TP-LINK|EU|N300-5|55530000):2.0\r\n"
384 "CPE510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
385 "CPE510(TP-LINK|UN|N300-5|45550000):2.0\r\n"
386 "CPE510(TP-LINK|UN|N300-5|55530000):2.0\r\n"
387 "CPE510(TP-LINK|US|N300-5|00000000):2.0\r\n"
388 "CPE510(TP-LINK|US|N300-5|45550000):2.0\r\n"
389 "CPE510(TP-LINK|US|N300-5|55530000):2.0\r\n"
390 "CPE510(TP-LINK|UN|N300-5):2.0\r\n"
391 "CPE510(TP-LINK|EU|N300-5):2.0\r\n"
392 "CPE510(TP-LINK|US|N300-5):2.0\r\n",
394 .soft_ver
= SOFT_VER_DEFAULT
,
397 {"fs-uboot", 0x00000, 0x20000},
398 {"partition-table", 0x20000, 0x02000},
399 {"default-mac", 0x30000, 0x00020},
400 {"product-info", 0x31100, 0x00100},
401 {"signature", 0x32000, 0x00400},
402 {"firmware", 0x40000, 0x770000},
403 {"soft-version", 0x7b0000, 0x00100},
404 {"support-list", 0x7b1000, 0x00400},
405 {"user-config", 0x7c0000, 0x10000},
406 {"default-config", 0x7d0000, 0x10000},
407 {"log", 0x7e0000, 0x10000},
408 {"radio", 0x7f0000, 0x10000},
412 .first_sysupgrade_partition
= "os-image",
413 .last_sysupgrade_partition
= "support-list",
416 /** Firmware layout for the CPE510 V3 */
419 .vendor
= "CPE510(TP-LINK|UN|N300-5):3.0\r\n",
422 "CPE510(TP-LINK|EU|N300-5|00000000):3.0\r\n"
423 "CPE510(TP-LINK|EU|N300-5|45550000):3.0\r\n"
424 "CPE510(TP-LINK|EU|N300-5|55530000):3.0\r\n"
425 "CPE510(TP-LINK|UN|N300-5|00000000):3.0\r\n"
426 "CPE510(TP-LINK|UN|N300-5|45550000):3.0\r\n"
427 "CPE510(TP-LINK|UN|N300-5|55530000):3.0\r\n"
428 "CPE510(TP-LINK|US|N300-5|00000000):3.0\r\n"
429 "CPE510(TP-LINK|US|N300-5|45550000):3.0\r\n"
430 "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n"
431 "CPE510(TP-LINK|UN|N300-5):3.0\r\n"
432 "CPE510(TP-LINK|EU|N300-5):3.0\r\n"
433 "CPE510(TP-LINK|US|N300-5):3.0\r\n"
434 "CPE510(TP-LINK|UN|N300-5|00000000):3.20\r\n"
435 "CPE510(TP-LINK|US|N300-5|55530000):3.20\r\n"
436 "CPE510(TP-LINK|EU|N300-5|45550000):3.20\r\n",
438 .soft_ver
= SOFT_VER_DEFAULT
,
441 {"fs-uboot", 0x00000, 0x20000},
442 {"partition-table", 0x20000, 0x02000},
443 {"default-mac", 0x30000, 0x00020},
444 {"product-info", 0x31100, 0x00100},
445 {"signature", 0x32000, 0x00400},
446 {"firmware", 0x40000, 0x770000},
447 {"soft-version", 0x7b0000, 0x00100},
448 {"support-list", 0x7b1000, 0x00400},
449 {"user-config", 0x7c0000, 0x10000},
450 {"default-config", 0x7d0000, 0x10000},
451 {"log", 0x7e0000, 0x10000},
452 {"radio", 0x7f0000, 0x10000},
456 .first_sysupgrade_partition
= "os-image",
457 .last_sysupgrade_partition
= "support-list",
460 /** Firmware layout for the CPE610V1 */
463 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n",
466 "CPE610(TP-LINK|EU|N300-5|00000000):1.0\r\n"
467 "CPE610(TP-LINK|EU|N300-5|45550000):1.0\r\n"
468 "CPE610(TP-LINK|EU|N300-5|55530000):1.0\r\n"
469 "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n"
470 "CPE610(TP-LINK|UN|N300-5|45550000):1.0\r\n"
471 "CPE610(TP-LINK|UN|N300-5|55530000):1.0\r\n"
472 "CPE610(TP-LINK|US|N300-5|55530000):1.0\r\n"
473 "CPE610(TP-LINK|UN|N300-5):1.0\r\n"
474 "CPE610(TP-LINK|EU|N300-5):1.0\r\n"
475 "CPE610(TP-LINK|US|N300-5):1.0\r\n",
477 .soft_ver
= SOFT_VER_DEFAULT
,
480 {"fs-uboot", 0x00000, 0x20000},
481 {"partition-table", 0x20000, 0x02000},
482 {"default-mac", 0x30000, 0x00020},
483 {"product-info", 0x31100, 0x00100},
484 {"signature", 0x32000, 0x00400},
485 {"firmware", 0x40000, 0x770000},
486 {"soft-version", 0x7b0000, 0x00100},
487 {"support-list", 0x7b1000, 0x00400},
488 {"user-config", 0x7c0000, 0x10000},
489 {"default-config", 0x7d0000, 0x10000},
490 {"log", 0x7e0000, 0x10000},
491 {"radio", 0x7f0000, 0x10000},
495 .first_sysupgrade_partition
= "os-image",
496 .last_sysupgrade_partition
= "support-list",
499 /** Firmware layout for the CPE610V2 */
502 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n",
505 "CPE610(TP-LINK|EU|N300-5|00000000):2.0\r\n"
506 "CPE610(TP-LINK|EU|N300-5|45550000):2.0\r\n"
507 "CPE610(TP-LINK|EU|N300-5|55530000):2.0\r\n"
508 "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n"
509 "CPE610(TP-LINK|UN|N300-5|45550000):2.0\r\n"
510 "CPE610(TP-LINK|UN|N300-5|55530000):2.0\r\n"
511 "CPE610(TP-LINK|US|N300-5|55530000):2.0\r\n"
512 "CPE610(TP-LINK|UN|N300-5):2.0\r\n"
513 "CPE610(TP-LINK|EU|N300-5):2.0\r\n"
514 "CPE610(TP-LINK|US|N300-5):2.0\r\n",
516 .soft_ver
= SOFT_VER_DEFAULT
,
519 {"fs-uboot", 0x00000, 0x20000},
520 {"partition-table", 0x20000, 0x02000},
521 {"default-mac", 0x30000, 0x00020},
522 {"product-info", 0x31100, 0x00100},
523 {"signature", 0x32000, 0x00400},
524 {"firmware", 0x40000, 0x770000},
525 {"soft-version", 0x7b0000, 0x00100},
526 {"support-list", 0x7b1000, 0x00400},
527 {"user-config", 0x7c0000, 0x10000},
528 {"default-config", 0x7d0000, 0x10000},
529 {"log", 0x7e0000, 0x10000},
530 {"radio", 0x7f0000, 0x10000},
534 .first_sysupgrade_partition
= "os-image",
535 .last_sysupgrade_partition
= "support-list",
537 /** Firmware layout for the CPE710 V1 */
540 .vendor
= "CPE710(TP-LINK|UN|AC866-5|00000000):1.0\r\n",
543 "CPE710(TP-LINK|UN|AC866-5|00000000):1.0\r\n"
544 "CPE710(TP-LINK|EU|AC866-5|45550000):1.0\r\n"
545 "CPE710(TP-LINK|US|AC866-5|55530000):1.0\r\n"
546 "CPE710(TP-LINK|UN|AC866-5):1.0\r\n"
547 "CPE710(TP-LINK|EU|AC866-5):1.0\r\n"
548 "CPE710(TP-LINK|US|AC866-5):1.0\r\n",
550 .soft_ver
= SOFT_VER_DEFAULT
,
553 {"fs-uboot", 0x00000, 0x50000},
554 {"partition-table", 0x50000, 0x02000},
555 {"default-mac", 0x60000, 0x00020},
556 {"serial-number", 0x60100, 0x00020},
557 {"product-info", 0x61100, 0x00100},
558 {"device-info", 0x61400, 0x00400},
559 {"signature", 0x62000, 0x00400},
560 {"device-id", 0x63000, 0x00100},
561 {"firmware", 0x70000, 0xf40000},
562 {"soft-version", 0xfb0000, 0x00100},
563 {"support-list", 0xfb1000, 0x01000},
564 {"user-config", 0xfc0000, 0x10000},
565 {"default-config", 0xfd0000, 0x10000},
566 {"log", 0xfe0000, 0x10000},
567 {"radio", 0xff0000, 0x10000},
571 .first_sysupgrade_partition
= "os-image",
572 .last_sysupgrade_partition
= "support-list",
577 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
580 "WBS210(TP-LINK|UN|N300-2):1.20\r\n"
581 "WBS210(TP-LINK|US|N300-2):1.20\r\n"
582 "WBS210(TP-LINK|EU|N300-2):1.20\r\n",
584 .soft_ver
= SOFT_VER_DEFAULT
,
587 {"fs-uboot", 0x00000, 0x20000},
588 {"partition-table", 0x20000, 0x02000},
589 {"default-mac", 0x30000, 0x00020},
590 {"product-info", 0x31100, 0x00100},
591 {"signature", 0x32000, 0x00400},
592 {"firmware", 0x40000, 0x770000},
593 {"soft-version", 0x7b0000, 0x00100},
594 {"support-list", 0x7b1000, 0x00400},
595 {"user-config", 0x7c0000, 0x10000},
596 {"default-config", 0x7d0000, 0x10000},
597 {"log", 0x7e0000, 0x10000},
598 {"radio", 0x7f0000, 0x10000},
602 .first_sysupgrade_partition
= "os-image",
603 .last_sysupgrade_partition
= "support-list",
608 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
611 "WBS210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
612 "WBS210(TP-LINK|US|N300-2|55530000):2.0\r\n"
613 "WBS210(TP-LINK|EU|N300-2|45550000):2.0\r\n",
615 .soft_ver
= SOFT_VER_DEFAULT
,
618 {"fs-uboot", 0x00000, 0x20000},
619 {"partition-table", 0x20000, 0x02000},
620 {"default-mac", 0x30000, 0x00020},
621 {"product-info", 0x31100, 0x00100},
622 {"signature", 0x32000, 0x00400},
623 {"firmware", 0x40000, 0x770000},
624 {"soft-version", 0x7b0000, 0x00100},
625 {"support-list", 0x7b1000, 0x00400},
626 {"user-config", 0x7c0000, 0x10000},
627 {"default-config", 0x7d0000, 0x10000},
628 {"log", 0x7e0000, 0x10000},
629 {"radio", 0x7f0000, 0x10000},
633 .first_sysupgrade_partition
= "os-image",
634 .last_sysupgrade_partition
= "support-list",
639 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
642 "WBS510(TP-LINK|UN|N300-5):1.20\r\n"
643 "WBS510(TP-LINK|US|N300-5):1.20\r\n"
644 "WBS510(TP-LINK|EU|N300-5):1.20\r\n"
645 "WBS510(TP-LINK|CA|N300-5):1.20\r\n",
647 .soft_ver
= SOFT_VER_DEFAULT
,
650 {"fs-uboot", 0x00000, 0x20000},
651 {"partition-table", 0x20000, 0x02000},
652 {"default-mac", 0x30000, 0x00020},
653 {"product-info", 0x31100, 0x00100},
654 {"signature", 0x32000, 0x00400},
655 {"firmware", 0x40000, 0x770000},
656 {"soft-version", 0x7b0000, 0x00100},
657 {"support-list", 0x7b1000, 0x00400},
658 {"user-config", 0x7c0000, 0x10000},
659 {"default-config", 0x7d0000, 0x10000},
660 {"log", 0x7e0000, 0x10000},
661 {"radio", 0x7f0000, 0x10000},
665 .first_sysupgrade_partition
= "os-image",
666 .last_sysupgrade_partition
= "support-list",
671 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
674 "WBS510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
675 "WBS510(TP-LINK|US|N300-5|55530000):2.0\r\n"
676 "WBS510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
677 "WBS510(TP-LINK|CA|N300-5|43410000):2.0\r\n",
679 .soft_ver
= SOFT_VER_DEFAULT
,
682 {"fs-uboot", 0x00000, 0x20000},
683 {"partition-table", 0x20000, 0x02000},
684 {"default-mac", 0x30000, 0x00020},
685 {"product-info", 0x31100, 0x00100},
686 {"signature", 0x32000, 0x00400},
687 {"firmware", 0x40000, 0x770000},
688 {"soft-version", 0x7b0000, 0x00100},
689 {"support-list", 0x7b1000, 0x00400},
690 {"user-config", 0x7c0000, 0x10000},
691 {"default-config", 0x7d0000, 0x10000},
692 {"log", 0x7e0000, 0x10000},
693 {"radio", 0x7f0000, 0x10000},
697 .first_sysupgrade_partition
= "os-image",
698 .last_sysupgrade_partition
= "support-list",
701 /** Firmware layout for the AD7200 */
707 "{product_name:AD7200,product_ver:1.0.0,special_id:00000000}\r\n",
709 .soft_ver
= SOFT_VER_DEFAULT
,
712 {"SBL1", 0x00000, 0x20000},
713 {"MIBIB", 0x20000, 0x20000},
714 {"SBL2", 0x40000, 0x20000},
715 {"SBL3", 0x60000, 0x30000},
716 {"DDRCONFIG", 0x90000, 0x10000},
717 {"SSD", 0xa0000, 0x10000},
718 {"TZ", 0xb0000, 0x30000},
719 {"RPM", 0xe0000, 0x20000},
720 {"fs-uboot", 0x100000, 0x70000},
721 {"uboot-env", 0x170000, 0x40000},
722 {"radio", 0x1b0000, 0x40000},
723 {"os-image", 0x1f0000, 0x400000},
724 {"file-system", 0x5f0000, 0x1900000},
725 {"default-mac", 0x1ef0000, 0x00200},
726 {"pin", 0x1ef0200, 0x00200},
727 {"device-id", 0x1ef0400, 0x00200},
728 {"product-info", 0x1ef0600, 0x0fa00},
729 {"partition-table", 0x1f00000, 0x10000},
730 {"soft-version", 0x1f10000, 0x10000},
731 {"support-list", 0x1f20000, 0x10000},
732 {"profile", 0x1f30000, 0x10000},
733 {"default-config", 0x1f40000, 0x10000},
734 {"user-config", 0x1f50000, 0x40000},
735 {"qos-db", 0x1f90000, 0x40000},
736 {"usb-config", 0x1fd0000, 0x10000},
737 {"log", 0x1fe0000, 0x20000},
741 .first_sysupgrade_partition
= "os-image",
742 .last_sysupgrade_partition
= "file-system"
745 /** Firmware layout for the C2600 */
751 "{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
753 .soft_ver
= SOFT_VER_DEFAULT
,
756 We use a bigger os-image partition than the stock images (and thus
757 smaller file-system), as our kernel doesn't fit in the stock firmware's
758 2 MB os-image since kernel 4.14.
761 {"SBL1", 0x00000, 0x20000},
762 {"MIBIB", 0x20000, 0x20000},
763 {"SBL2", 0x40000, 0x20000},
764 {"SBL3", 0x60000, 0x30000},
765 {"DDRCONFIG", 0x90000, 0x10000},
766 {"SSD", 0xa0000, 0x10000},
767 {"TZ", 0xb0000, 0x30000},
768 {"RPM", 0xe0000, 0x20000},
769 {"fs-uboot", 0x100000, 0x70000},
770 {"uboot-env", 0x170000, 0x40000},
771 {"radio", 0x1b0000, 0x40000},
772 {"os-image", 0x1f0000, 0x400000}, /* Stock: base 0x1f0000 size 0x200000 */
773 {"file-system", 0x5f0000, 0x1900000}, /* Stock: base 0x3f0000 size 0x1b00000 */
774 {"default-mac", 0x1ef0000, 0x00200},
775 {"pin", 0x1ef0200, 0x00200},
776 {"product-info", 0x1ef0400, 0x0fc00},
777 {"partition-table", 0x1f00000, 0x10000},
778 {"soft-version", 0x1f10000, 0x10000},
779 {"support-list", 0x1f20000, 0x10000},
780 {"profile", 0x1f30000, 0x10000},
781 {"default-config", 0x1f40000, 0x10000},
782 {"user-config", 0x1f50000, 0x40000},
783 {"qos-db", 0x1f90000, 0x40000},
784 {"usb-config", 0x1fd0000, 0x10000},
785 {"log", 0x1fe0000, 0x20000},
789 .first_sysupgrade_partition
= "os-image",
790 .last_sysupgrade_partition
= "file-system"
793 /** Firmware layout for the A7-V5 */
795 .id
= "ARCHER-A7-V5",
798 "{product_name:Archer A7,product_ver:5.0.0,special_id:45550000}\n"
799 "{product_name:Archer A7,product_ver:5.0.0,special_id:55530000}\n"
800 "{product_name:Archer A7,product_ver:5.0.0,special_id:43410000}\n"
801 "{product_name:Archer A7,product_ver:5.0.0,special_id:4A500000}\n"
802 "{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n"
803 "{product_name:Archer A7,product_ver:5.0.0,special_id:52550000}\n",
805 .soft_ver
= SOFT_VER_TEXT("soft_ver:7.0.0\n"),
807 /* We're using a dynamic kernel/rootfs split here */
809 {"factory-boot", 0x00000, 0x20000},
810 {"fs-uboot", 0x20000, 0x20000},
811 {"firmware", 0x40000, 0xec0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
812 /* Stock: name file-system base 0x160000 size 0xda0000 */
813 {"default-mac", 0xf40000, 0x00200},
814 {"pin", 0xf40200, 0x00200},
815 {"device-id", 0xf40400, 0x00100},
816 {"product-info", 0xf40500, 0x0fb00},
817 {"soft-version", 0xf50000, 0x00100},
818 {"extra-para", 0xf51000, 0x01000},
819 {"support-list", 0xf52000, 0x0a000},
820 {"profile", 0xf5c000, 0x04000},
821 {"default-config", 0xf60000, 0x10000},
822 {"user-config", 0xf70000, 0x40000},
823 {"certificate", 0xfb0000, 0x10000},
824 {"partition-table", 0xfc0000, 0x10000},
825 {"log", 0xfd0000, 0x20000},
826 {"radio", 0xff0000, 0x10000},
830 .first_sysupgrade_partition
= "os-image",
831 .last_sysupgrade_partition
= "file-system",
834 /** Firmware layout for the Archer A9 v6 */
836 .id
= "ARCHER-A9-V6",
839 "{product_name:Archer A9,product_ver:6.0,special_id:55530000}\n"
840 "{product_name:Archer A9,product_ver:6.0,special_id:45550000}\n"
841 "{product_name:Archer A9,product_ver:6.0,special_id:52550000}\n"
842 "{product_name:Archer A9,product_ver:6.0,special_id:4A500000}\n"
843 "{product_name:Archer C90,product_ver:6.0,special_id:55530000}\n",
845 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.1.0\n"),
847 /* We're using a dynamic kernel/rootfs split here */
849 {"factory-boot", 0x00000, 0x20000},
850 {"fs-uboot", 0x20000, 0x20000},
851 {"partition-table", 0x40000, 0x10000},
852 {"radio", 0x50000, 0x10000},
853 {"default-mac", 0x60000, 0x00200},
854 {"pin", 0x60200, 0x00200},
855 {"device-id", 0x60400, 0x00100},
856 {"product-info", 0x60500, 0x0fb00},
857 {"soft-version", 0x70000, 0x01000},
858 {"extra-para", 0x71000, 0x01000},
859 {"support-list", 0x72000, 0x0a000},
860 {"profile", 0x7c000, 0x04000},
861 {"user-config", 0x80000, 0x10000},
862 {"ap-config", 0x90000, 0x10000},
863 {"apdef-config", 0xa0000, 0x10000},
864 {"router-config", 0xb0000, 0x10000},
865 {"firmware", 0xc0000, 0xf00000}, /* Stock: name os-image base 0xc0000 size 0x120000 */
866 /* Stock: name file-system base 0x1e0000 size 0xde0000 */
867 {"log", 0xfc0000, 0x20000},
868 {"certificate", 0xfe0000, 0x10000},
869 {"default-config", 0xff0000, 0x10000},
873 .first_sysupgrade_partition
= "os-image",
874 .last_sysupgrade_partition
= "file-system",
877 /** Firmware layout for the C2v3 */
879 .id
= "ARCHER-C2-V3",
882 "{product_name:ArcherC2,product_ver:3.0.0,special_id:00000000}\n"
883 "{product_name:ArcherC2,product_ver:3.0.0,special_id:55530000}\n"
884 "{product_name:ArcherC2,product_ver:3.0.0,special_id:45550000}\n",
886 .soft_ver
= SOFT_VER_TEXT("soft_ver:3.0.1\n"),
888 /** We're using a dynamic kernel/rootfs split here */
891 {"factory-boot", 0x00000, 0x20000},
892 {"fs-uboot", 0x20000, 0x10000},
893 {"firmware", 0x30000, 0x7a0000},
894 {"user-config", 0x7d0000, 0x04000},
895 {"default-mac", 0x7e0000, 0x00100},
896 {"device-id", 0x7e0100, 0x00100},
897 {"extra-para", 0x7e0200, 0x00100},
898 {"pin", 0x7e0300, 0x00100},
899 {"support-list", 0x7e0400, 0x00400},
900 {"soft-version", 0x7e0800, 0x00400},
901 {"product-info", 0x7e0c00, 0x01400},
902 {"partition-table", 0x7e2000, 0x01000},
903 {"profile", 0x7e3000, 0x01000},
904 {"default-config", 0x7e4000, 0x04000},
905 {"merge-config", 0x7ec000, 0x02000},
906 {"qos-db", 0x7ee000, 0x02000},
907 {"radio", 0x7f0000, 0x10000},
911 .first_sysupgrade_partition
= "os-image",
912 .last_sysupgrade_partition
= "file-system",
915 /** Firmware layout for the C25v1 */
917 .id
= "ARCHER-C25-V1",
920 "{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
921 "{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
922 "{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
924 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
926 /* We're using a dynamic kernel/rootfs split here */
928 {"factory-boot", 0x00000, 0x20000},
929 {"fs-uboot", 0x20000, 0x10000},
930 {"firmware", 0x30000, 0x7a0000}, /* Stock: name os-image base 0x30000 size 0x100000 */
931 /* Stock: name file-system base 0x130000 size 0x6a0000 */
932 {"user-config", 0x7d0000, 0x04000},
933 {"default-mac", 0x7e0000, 0x00100},
934 {"device-id", 0x7e0100, 0x00100},
935 {"extra-para", 0x7e0200, 0x00100},
936 {"pin", 0x7e0300, 0x00100},
937 {"support-list", 0x7e0400, 0x00400},
938 {"soft-version", 0x7e0800, 0x00400},
939 {"product-info", 0x7e0c00, 0x01400},
940 {"partition-table", 0x7e2000, 0x01000},
941 {"profile", 0x7e3000, 0x01000},
942 {"default-config", 0x7e4000, 0x04000},
943 {"merge-config", 0x7ec000, 0x02000},
944 {"qos-db", 0x7ee000, 0x02000},
945 {"radio", 0x7f0000, 0x10000},
949 .first_sysupgrade_partition
= "os-image",
950 .last_sysupgrade_partition
= "file-system",
953 /** Firmware layout for the C58v1 */
955 .id
= "ARCHER-C58-V1",
959 "{product_name:Archer C58,product_ver:1.0.0,special_id:00000000}\r\n"
960 "{product_name:Archer C58,product_ver:1.0.0,special_id:45550000}\r\n"
961 "{product_name:Archer C58,product_ver:1.0.0,special_id:55530000}\r\n",
963 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
966 {"fs-uboot", 0x00000, 0x10000},
967 {"default-mac", 0x10000, 0x00200},
968 {"pin", 0x10200, 0x00200},
969 {"product-info", 0x10400, 0x00100},
970 {"partition-table", 0x10500, 0x00800},
971 {"soft-version", 0x11300, 0x00200},
972 {"support-list", 0x11500, 0x00100},
973 {"device-id", 0x11600, 0x00100},
974 {"profile", 0x11700, 0x03900},
975 {"default-config", 0x15000, 0x04000},
976 {"user-config", 0x19000, 0x04000},
977 {"firmware", 0x20000, 0x7c8000},
978 {"certyficate", 0x7e8000, 0x08000},
979 {"radio", 0x7f0000, 0x10000},
983 .first_sysupgrade_partition
= "os-image",
984 .last_sysupgrade_partition
= "file-system",
987 /** Firmware layout for the C59v1 */
989 .id
= "ARCHER-C59-V1",
993 "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
994 "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
995 "{product_name:Archer C59,product_ver:1.0.0,special_id:52550000}\r\n"
996 "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
998 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1000 /* We're using a dynamic kernel/rootfs split here */
1002 {"fs-uboot", 0x00000, 0x10000},
1003 {"default-mac", 0x10000, 0x00200},
1004 {"pin", 0x10200, 0x00200},
1005 {"device-id", 0x10400, 0x00100},
1006 {"product-info", 0x10500, 0x0fb00},
1007 {"firmware", 0x20000, 0xe30000},
1008 {"partition-table", 0xe50000, 0x10000},
1009 {"soft-version", 0xe60000, 0x10000},
1010 {"support-list", 0xe70000, 0x10000},
1011 {"profile", 0xe80000, 0x10000},
1012 {"default-config", 0xe90000, 0x10000},
1013 {"user-config", 0xea0000, 0x40000},
1014 {"usb-config", 0xee0000, 0x10000},
1015 {"certificate", 0xef0000, 0x10000},
1016 {"qos-db", 0xf00000, 0x40000},
1017 {"log", 0xfe0000, 0x10000},
1018 {"radio", 0xff0000, 0x10000},
1022 .first_sysupgrade_partition
= "os-image",
1023 .last_sysupgrade_partition
= "file-system",
1026 /** Firmware layout for the C59v2 */
1028 .id
= "ARCHER-C59-V2",
1032 "{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
1033 "{product_name:Archer C59,product_ver:2.0.0,special_id:45550000}\r\n"
1034 "{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
1036 .soft_ver
= SOFT_VER_TEXT("soft_ver:2.0.0 Build 20161206 rel.7303\n"),
1038 /** We're using a dynamic kernel/rootfs split here */
1040 {"factory-boot", 0x00000, 0x20000},
1041 {"fs-uboot", 0x20000, 0x10000},
1042 {"default-mac", 0x30000, 0x00200},
1043 {"pin", 0x30200, 0x00200},
1044 {"device-id", 0x30400, 0x00100},
1045 {"product-info", 0x30500, 0x0fb00},
1046 {"firmware", 0x40000, 0xe10000},
1047 {"partition-table", 0xe50000, 0x10000},
1048 {"soft-version", 0xe60000, 0x10000},
1049 {"support-list", 0xe70000, 0x10000},
1050 {"profile", 0xe80000, 0x10000},
1051 {"default-config", 0xe90000, 0x10000},
1052 {"user-config", 0xea0000, 0x40000},
1053 {"usb-config", 0xee0000, 0x10000},
1054 {"certificate", 0xef0000, 0x10000},
1055 {"extra-para", 0xf00000, 0x10000},
1056 {"qos-db", 0xf10000, 0x30000},
1057 {"log", 0xfe0000, 0x10000},
1058 {"radio", 0xff0000, 0x10000},
1062 .first_sysupgrade_partition
= "os-image",
1063 .last_sysupgrade_partition
= "file-system",
1066 /** Firmware layout for the Archer C6 v2 (EU/RU/JP) */
1068 .id
= "ARCHER-C6-V2",
1072 "{product_name:Archer C6,product_ver:2.0.0,special_id:45550000}\r\n"
1073 "{product_name:Archer C6,product_ver:2.0.0,special_id:52550000}\r\n"
1074 "{product_name:Archer C6,product_ver:2.0.0,special_id:4A500000}\r\n",
1076 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.9.1\n"),
1079 {"fs-uboot", 0x00000, 0x20000},
1080 {"default-mac", 0x20000, 0x00200},
1081 {"pin", 0x20200, 0x00100},
1082 {"product-info", 0x20300, 0x00200},
1083 {"device-id", 0x20500, 0x0fb00},
1084 {"firmware", 0x30000, 0x7a9400},
1085 {"soft-version", 0x7d9400, 0x00100},
1086 {"extra-para", 0x7d9500, 0x00100},
1087 {"support-list", 0x7d9600, 0x00200},
1088 {"profile", 0x7d9800, 0x03000},
1089 {"default-config", 0x7dc800, 0x03000},
1090 {"partition-table", 0x7df800, 0x00800},
1091 {"user-config", 0x7e0000, 0x0c000},
1092 {"certificate", 0x7ec000, 0x04000},
1093 {"radio", 0x7f0000, 0x10000},
1097 .first_sysupgrade_partition
= "os-image",
1098 .last_sysupgrade_partition
= "file-system",
1101 /** Firmware layout for the Archer C6 v2 (US) and A6 v2 (US/TW) */
1103 .id
= "ARCHER-C6-V2-US",
1107 "{product_name:Archer A6,product_ver:2.0.0,special_id:55530000}\n"
1108 "{product_name:Archer A6,product_ver:2.0.0,special_id:54570000}\n"
1109 "{product_name:Archer C6,product_ver:2.0.0,special_id:55530000}\n",
1111 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.9.1\n"),
1114 {"factory-boot", 0x00000, 0x20000},
1115 {"default-mac", 0x20000, 0x00200},
1116 {"pin", 0x20200, 0x00100},
1117 {"product-info", 0x20300, 0x00200},
1118 {"device-id", 0x20500, 0x0fb00},
1119 {"fs-uboot", 0x30000, 0x20000},
1120 {"firmware", 0x50000, 0xf89400},
1121 {"soft-version", 0xfd9400, 0x00100},
1122 {"extra-para", 0xfd9500, 0x00100},
1123 {"support-list", 0xfd9600, 0x00200},
1124 {"profile", 0xfd9800, 0x03000},
1125 {"default-config", 0xfdc800, 0x03000},
1126 {"partition-table", 0xfdf800, 0x00800},
1127 {"user-config", 0xfe0000, 0x0c000},
1128 {"certificate", 0xfec000, 0x04000},
1129 {"radio", 0xff0000, 0x10000},
1132 .first_sysupgrade_partition
= "os-image",
1133 .last_sysupgrade_partition
= "file-system",
1135 /** Firmware layout for the Archer C6 v3 */
1137 .id
= "ARCHER-C6-V3",
1141 "{product_name:Archer C6,product_ver:3.20,special_id:55530000}"
1142 "{product_name:Archer C6,product_ver:3.20,special_id:45550000}"
1143 "{product_name:Archer C6,product_ver:3.20,special_id:52550000}"
1144 "{product_name:Archer C6,product_ver:3.20,special_id:4A500000}"
1145 "{product_name:Archer C6,product_ver:3.20,special_id:4B520000}"
1146 "{product_name:Archer C6,product_ver:3.0.0,special_id:42520000}",
1148 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.9\n"),
1151 {"fs-uboot", 0x00000, 0x40000},
1152 {"firmware", 0x40000, 0xf60000},
1153 {"default-mac", 0xfa0000, 0x00200},
1154 {"pin", 0xfa0200, 0x00100},
1155 {"device-id", 0xfa0300, 0x00100},
1156 {"product-info", 0xfa0400, 0x0fc00},
1157 {"default-config", 0xfb0000, 0x08000},
1158 {"ap-def-config", 0xfb8000, 0x08000},
1159 {"user-config", 0xfc0000, 0x0a000},
1160 {"ag-config", 0xfca000, 0x04000},
1161 {"certificate", 0xfce000, 0x02000},
1162 {"ap-config", 0xfd0000, 0x06000},
1163 {"router-config", 0xfd6000, 0x06000},
1164 {"favicon", 0xfdc000, 0x02000},
1165 {"logo", 0xfde000, 0x02000},
1166 {"partition-table", 0xfe0000, 0x00800},
1167 {"soft-version", 0xfe0800, 0x00100},
1168 {"support-list", 0xfe0900, 0x00200},
1169 {"profile", 0xfe0b00, 0x03000},
1170 {"extra-para", 0xfe3b00, 0x00100},
1171 {"radio", 0xff0000, 0x10000},
1174 .first_sysupgrade_partition
= "os-image",
1175 .last_sysupgrade_partition
= "file-system",
1177 /** Firmware layout for the Archer A6 v3 */
1179 .id
= "ARCHER-A6-V3",
1183 "{product_name:Archer A6,product_ver:3.0.0,special_id:43410000}\n"
1184 "{product_name:Archer A6,product_ver:3.0.0,special_id:55530000}\n"
1185 "{product_name:Archer A6,product_ver:3.0.0,special_id:54570000}\n"
1186 "{product_name:Archer A6,product_ver:3.0.0,special_id:4A500000}\n",
1188 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.5\n"),
1191 {"fs-uboot", 0x00000, 0x40000},
1192 {"firmware", 0x40000, 0xf60000},
1193 {"default-mac", 0xfa0000, 0x00200},
1194 {"pin", 0xfa0200, 0x00100},
1195 {"device-id", 0xfa0300, 0x00100},
1196 {"product-info", 0xfa0400, 0x0fc00},
1197 {"default-config", 0xfb0000, 0x08000},
1198 {"ap-def-config", 0xfb8000, 0x08000},
1199 {"user-config", 0xfc0000, 0x0a000},
1200 {"ag-config", 0xfca000, 0x04000},
1201 {"certificate", 0xfce000, 0x02000},
1202 {"ap-config", 0xfd0000, 0x06000},
1203 {"router-config", 0xfd6000, 0x06000},
1204 {"favicon", 0xfdc000, 0x02000},
1205 {"logo", 0xfde000, 0x02000},
1206 {"partition-table", 0xfe0000, 0x00800},
1207 {"soft-version", 0xfe0800, 0x00100},
1208 {"support-list", 0xfe0900, 0x00200},
1209 {"profile", 0xfe0b00, 0x03000},
1210 {"extra-para", 0xfe3b00, 0x00100},
1211 {"radio", 0xff0000, 0x10000},
1214 .first_sysupgrade_partition
= "os-image",
1215 .last_sysupgrade_partition
= "file-system",
1217 /** Firmware layout for the Archer C6U v1 */
1219 .id
= "ARCHER-C6U-V1",
1223 "{product_name:Archer C6U,product_ver:1.0.0,special_id:45550000}\n",
1225 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.2\n"),
1228 {"fs-uboot", 0x00000, 0x40000},
1229 {"firmware", 0x40000, 0xf60000},
1230 {"default-mac", 0xfa0000, 0x00200},
1231 {"pin", 0xfa0200, 0x00100},
1232 {"device-id", 0xfa0300, 0x00100},
1233 {"product-info", 0xfa0400, 0x0fc00},
1234 {"default-config", 0xfb0000, 0x08000},
1235 {"ap-def-config", 0xfb8000, 0x08000},
1236 {"user-config", 0xfc0000, 0x0c000},
1237 {"certificate", 0xfcc000, 0x04000},
1238 {"ap-config", 0xfd0000, 0x08000},
1239 {"router-config", 0xfd8000, 0x08000},
1240 {"partition-table", 0xfe0000, 0x00800},
1241 {"soft-version", 0xfe0800, 0x00100},
1242 {"support-list", 0xfe0900, 0x00200},
1243 {"profile", 0xfe0b00, 0x03000},
1244 {"extra-para", 0xfe3b00, 0x00100},
1245 {"radio", 0xff0000, 0x10000},
1248 .first_sysupgrade_partition
= "os-image",
1249 .last_sysupgrade_partition
= "file-system",
1251 /** Firmware layout for the C60v1 */
1253 .id
= "ARCHER-C60-V1",
1257 "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
1258 "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
1259 "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
1261 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1264 {"fs-uboot", 0x00000, 0x10000},
1265 {"default-mac", 0x10000, 0x00200},
1266 {"pin", 0x10200, 0x00200},
1267 {"product-info", 0x10400, 0x00100},
1268 {"partition-table", 0x10500, 0x00800},
1269 {"soft-version", 0x11300, 0x00200},
1270 {"support-list", 0x11500, 0x00100},
1271 {"device-id", 0x11600, 0x00100},
1272 {"profile", 0x11700, 0x03900},
1273 {"default-config", 0x15000, 0x04000},
1274 {"user-config", 0x19000, 0x04000},
1275 {"firmware", 0x20000, 0x7c8000},
1276 {"certyficate", 0x7e8000, 0x08000},
1277 {"radio", 0x7f0000, 0x10000},
1281 .first_sysupgrade_partition
= "os-image",
1282 .last_sysupgrade_partition
= "file-system",
1285 /** Firmware layout for the C60v2 */
1287 .id
= "ARCHER-C60-V2",
1291 "{product_name:Archer C60,product_ver:2.0.0,special_id:42520000}\r\n"
1292 "{product_name:Archer C60,product_ver:2.0.0,special_id:45550000}\r\n"
1293 "{product_name:Archer C60,product_ver:2.0.0,special_id:55530000}\r\n",
1295 .soft_ver
= SOFT_VER_TEXT("soft_ver:2.0.0\n"),
1298 {"factory-boot", 0x00000, 0x1fb00},
1299 {"default-mac", 0x1fb00, 0x00200},
1300 {"pin", 0x1fd00, 0x00100},
1301 {"product-info", 0x1fe00, 0x00100},
1302 {"device-id", 0x1ff00, 0x00100},
1303 {"fs-uboot", 0x20000, 0x10000},
1304 {"firmware", 0x30000, 0x7a0000},
1305 {"soft-version", 0x7d9500, 0x00100},
1306 {"support-list", 0x7d9600, 0x00100},
1307 {"extra-para", 0x7d9700, 0x00100},
1308 {"profile", 0x7d9800, 0x03000},
1309 {"default-config", 0x7dc800, 0x03000},
1310 {"partition-table", 0x7df800, 0x00800},
1311 {"user-config", 0x7e0000, 0x0c000},
1312 {"certificate", 0x7ec000, 0x04000},
1313 {"radio", 0x7f0000, 0x10000},
1317 .first_sysupgrade_partition
= "os-image",
1318 .last_sysupgrade_partition
= "file-system",
1321 /** Firmware layout for the C60v3 */
1323 .id
= "ARCHER-C60-V3",
1327 "{product_name:Archer C60,product_ver:3.0.0,special_id:42520000}\r\n"
1328 "{product_name:Archer C60,product_ver:3.0.0,special_id:45550000}\r\n"
1329 "{product_name:Archer C60,product_ver:3.0.0,special_id:55530000}\r\n",
1331 .soft_ver
= SOFT_VER_TEXT("soft_ver:3.0.0\n"),
1334 {"factory-boot", 0x00000, 0x1fb00},
1335 {"default-mac", 0x1fb00, 0x00200},
1336 {"pin", 0x1fd00, 0x00100},
1337 {"product-info", 0x1fe00, 0x00100},
1338 {"device-id", 0x1ff00, 0x00100},
1339 {"fs-uboot", 0x20000, 0x10000},
1340 {"firmware", 0x30000, 0x7a0000},
1341 {"soft-version", 0x7d9500, 0x00100},
1342 {"support-list", 0x7d9600, 0x00100},
1343 {"extra-para", 0x7d9700, 0x00100},
1344 {"profile", 0x7d9800, 0x03000},
1345 {"default-config", 0x7dc800, 0x03000},
1346 {"partition-table", 0x7df800, 0x00800},
1347 {"user-config", 0x7e0000, 0x0c000},
1348 {"certificate", 0x7ec000, 0x04000},
1349 {"radio", 0x7f0000, 0x10000},
1353 .first_sysupgrade_partition
= "os-image",
1354 .last_sysupgrade_partition
= "file-system",
1357 /** Firmware layout for the C5 */
1359 .id
= "ARCHER-C5-V2",
1363 "{product_name:ArcherC5,product_ver:2.0.0,special_id:00000000}\r\n"
1364 "{product_name:ArcherC5,product_ver:2.0.0,special_id:55530000}\r\n"
1365 "{product_name:ArcherC5,product_ver:2.0.0,special_id:4A500000}\r\n", /* JP version */
1367 .soft_ver
= SOFT_VER_DEFAULT
,
1370 {"fs-uboot", 0x00000, 0x40000},
1371 {"os-image", 0x40000, 0x200000},
1372 {"file-system", 0x240000, 0xc00000},
1373 {"default-mac", 0xe40000, 0x00200},
1374 {"pin", 0xe40200, 0x00200},
1375 {"product-info", 0xe40400, 0x00200},
1376 {"partition-table", 0xe50000, 0x10000},
1377 {"soft-version", 0xe60000, 0x00200},
1378 {"support-list", 0xe61000, 0x0f000},
1379 {"profile", 0xe70000, 0x10000},
1380 {"default-config", 0xe80000, 0x10000},
1381 {"user-config", 0xe90000, 0x50000},
1382 {"log", 0xee0000, 0x100000},
1383 {"radio_bk", 0xfe0000, 0x10000},
1384 {"radio", 0xff0000, 0x10000},
1388 .first_sysupgrade_partition
= "os-image",
1389 .last_sysupgrade_partition
= "file-system"
1392 /** Firmware layout for the C7 */
1394 .id
= "ARCHER-C7-V4",
1397 "{product_name:Archer C7,product_ver:4.0.0,special_id:00000000}\n"
1398 "{product_name:Archer C7,product_ver:4.0.0,special_id:41550000}\n"
1399 "{product_name:Archer C7,product_ver:4.0.0,special_id:45550000}\n"
1400 "{product_name:Archer C7,product_ver:4.0.0,special_id:4B520000}\n"
1401 "{product_name:Archer C7,product_ver:4.0.0,special_id:42520000}\n"
1402 "{product_name:Archer C7,product_ver:4.0.0,special_id:4A500000}\n"
1403 "{product_name:Archer C7,product_ver:4.0.0,special_id:52550000}\n"
1404 "{product_name:Archer C7,product_ver:4.0.0,special_id:54570000}\n"
1405 "{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
1406 "{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
1408 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
1410 /* We're using a dynamic kernel/rootfs split here */
1412 {"factory-boot", 0x00000, 0x20000},
1413 {"fs-uboot", 0x20000, 0x20000},
1414 {"firmware", 0x40000, 0xEC0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
1415 /* Stock: name file-system base 0x160000 size 0xda0000 */
1416 {"default-mac", 0xf00000, 0x00200},
1417 {"pin", 0xf00200, 0x00200},
1418 {"device-id", 0xf00400, 0x00100},
1419 {"product-info", 0xf00500, 0x0fb00},
1420 {"soft-version", 0xf10000, 0x00100},
1421 {"extra-para", 0xf11000, 0x01000},
1422 {"support-list", 0xf12000, 0x0a000},
1423 {"profile", 0xf1c000, 0x04000},
1424 {"default-config", 0xf20000, 0x10000},
1425 {"user-config", 0xf30000, 0x40000},
1426 {"qos-db", 0xf70000, 0x40000},
1427 {"certificate", 0xfb0000, 0x10000},
1428 {"partition-table", 0xfc0000, 0x10000},
1429 {"log", 0xfd0000, 0x20000},
1430 {"radio", 0xff0000, 0x10000},
1434 .first_sysupgrade_partition
= "os-image",
1435 .last_sysupgrade_partition
= "file-system",
1438 /** Firmware layout for the C7 v5*/
1440 .id
= "ARCHER-C7-V5",
1443 "{product_name:Archer C7,product_ver:5.0.0,special_id:00000000}\n"
1444 "{product_name:Archer C7,product_ver:5.0.0,special_id:45550000}\n"
1445 "{product_name:Archer C7,product_ver:5.0.0,special_id:55530000}\n"
1446 "{product_name:Archer C7,product_ver:5.0.0,special_id:43410000}\n"
1447 "{product_name:Archer C7,product_ver:5.0.0,special_id:4A500000}\n"
1448 "{product_name:Archer C7,product_ver:5.0.0,special_id:54570000}\n"
1449 "{product_name:Archer C7,product_ver:5.0.0,special_id:52550000}\n"
1450 "{product_name:Archer C7,product_ver:5.0.0,special_id:4B520000}\n",
1453 .soft_ver
= SOFT_VER_TEXT("soft_ver:7.0.0\n"),
1455 /* We're using a dynamic kernel/rootfs split here */
1457 {"factory-boot", 0x00000, 0x20000},
1458 {"fs-uboot", 0x20000, 0x20000},
1459 {"partition-table", 0x40000, 0x10000},
1460 {"radio", 0x50000, 0x10000},
1461 {"default-mac", 0x60000, 0x00200},
1462 {"pin", 0x60200, 0x00200},
1463 {"device-id", 0x60400, 0x00100},
1464 {"product-info", 0x60500, 0x0fb00},
1465 {"soft-version", 0x70000, 0x01000},
1466 {"extra-para", 0x71000, 0x01000},
1467 {"support-list", 0x72000, 0x0a000},
1468 {"profile", 0x7c000, 0x04000},
1469 {"user-config", 0x80000, 0x40000},
1472 {"firmware", 0xc0000, 0xf00000}, /* Stock: name os-image base 0xc0000 size 0x120000 */
1473 /* Stock: name file-system base 0x1e0000 size 0xde0000 */
1475 {"log", 0xfc0000, 0x20000},
1476 {"certificate", 0xfe0000, 0x10000},
1477 {"default-config", 0xff0000, 0x10000},
1482 .first_sysupgrade_partition
= "os-image",
1483 .last_sysupgrade_partition
= "file-system",
1486 /** Firmware layout for the C9 */
1492 "{product_name:ArcherC9,"
1493 "product_ver:1.0.0,"
1494 "special_id:00000000}\n",
1496 .soft_ver
= SOFT_VER_DEFAULT
,
1499 {"fs-uboot", 0x00000, 0x40000},
1500 {"os-image", 0x40000, 0x200000},
1501 {"file-system", 0x240000, 0xc00000},
1502 {"default-mac", 0xe40000, 0x00200},
1503 {"pin", 0xe40200, 0x00200},
1504 {"product-info", 0xe40400, 0x00200},
1505 {"partition-table", 0xe50000, 0x10000},
1506 {"soft-version", 0xe60000, 0x00200},
1507 {"support-list", 0xe61000, 0x0f000},
1508 {"profile", 0xe70000, 0x10000},
1509 {"default-config", 0xe80000, 0x10000},
1510 {"user-config", 0xe90000, 0x50000},
1511 {"log", 0xee0000, 0x100000},
1512 {"radio_bk", 0xfe0000, 0x10000},
1513 {"radio", 0xff0000, 0x10000},
1517 .first_sysupgrade_partition
= "os-image",
1518 .last_sysupgrade_partition
= "file-system"
1521 /** Firmware layout for the Deco M4R v1 and v2 */
1523 .id
= "DECO-M4R-V1",
1527 "{product_name:M4R,product_ver:1.0.0,special_id:55530000}\n"
1528 "{product_name:M4R,product_ver:1.0.0,special_id:45550000}\n"
1529 "{product_name:M4R,product_ver:1.0.0,special_id:43410000}\n"
1530 "{product_name:M4R,product_ver:1.0.0,special_id:4A500000}\n"
1531 "{product_name:M4R,product_ver:1.0.0,special_id:41550000}\n"
1532 "{product_name:M4R,product_ver:1.0.0,special_id:4B520000}\n"
1533 "{product_name:M4R,product_ver:1.0.0,special_id:49440000}\n"
1534 "{product_name:M4R,product_ver:2.0.0,special_id:55530000}\n"
1535 "{product_name:M4R,product_ver:2.0.0,special_id:45550000}\n"
1536 "{product_name:M4R,product_ver:2.0.0,special_id:43410000}\n"
1537 "{product_name:M4R,product_ver:2.0.0,special_id:4A500000}\n"
1538 "{product_name:M4R,product_ver:2.0.0,special_id:41550000}\n"
1539 "{product_name:M4R,product_ver:2.0.0,special_id:4B520000}\n"
1540 "{product_name:M4R,product_ver:2.0.0,special_id:54570000}\n"
1541 "{product_name:M4R,product_ver:2.0.0,special_id:42340000}\n"
1542 "{product_name:M4R,product_ver:2.0.0,special_id:49440000}\n",
1544 .soft_ver
= SOFT_VER_DEFAULT
,
1547 {"fs-uboot", 0x00000, 0x80000},
1548 {"firmware", 0x80000, 0xe00000},
1549 {"product-info", 0xe80000, 0x05000},
1550 {"default-mac", 0xe85000, 0x01000},
1551 {"device-id", 0xe86000, 0x01000},
1552 {"support-list", 0xe87000, 0x10000},
1553 {"user-config", 0xea7000, 0x10000},
1554 {"device-config", 0xeb7000, 0x10000},
1555 {"group-info", 0xec7000, 0x10000},
1556 {"partition-table", 0xed7000, 0x02000},
1557 {"soft-version", 0xed9000, 0x10000},
1558 {"profile", 0xee9000, 0x10000},
1559 {"default-config", 0xef9000, 0x10000},
1560 {"url-sig", 0xfe0000, 0x10000},
1561 {"radio", 0xff0000, 0x10000},
1564 .first_sysupgrade_partition
= "os-image",
1565 .last_sysupgrade_partition
= "file-system",
1568 /** Firmware layout for the EAP120 */
1571 .vendor
= "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1574 "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1576 .soft_ver
= SOFT_VER_DEFAULT
,
1579 {"fs-uboot", 0x00000, 0x20000},
1580 {"partition-table", 0x20000, 0x02000},
1581 {"default-mac", 0x30000, 0x00020},
1582 {"support-list", 0x31000, 0x00100},
1583 {"product-info", 0x31100, 0x00100},
1584 {"soft-version", 0x32000, 0x00100},
1585 {"os-image", 0x40000, 0x180000},
1586 {"file-system", 0x1c0000, 0x600000},
1587 {"user-config", 0x7c0000, 0x10000},
1588 {"backup-config", 0x7d0000, 0x10000},
1589 {"log", 0x7e0000, 0x10000},
1590 {"radio", 0x7f0000, 0x10000},
1594 .first_sysupgrade_partition
= "os-image",
1595 .last_sysupgrade_partition
= "file-system"
1598 /** Firmware layout for the EAP225-Outdoor v1 */
1600 .id
= "EAP225-OUTDOOR-V1",
1603 "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n",
1604 .part_trail
= PART_TRAIL_NONE
,
1605 .soft_ver
= SOFT_VER_DEFAULT
,
1606 .soft_ver_compat_level
= 1,
1609 {"fs-uboot", 0x00000, 0x20000},
1610 {"partition-table", 0x20000, 0x02000},
1611 {"default-mac", 0x30000, 0x01000},
1612 {"support-list", 0x31000, 0x00100},
1613 {"product-info", 0x31100, 0x00400},
1614 {"soft-version", 0x32000, 0x00100},
1615 {"firmware", 0x40000, 0xd80000},
1616 {"user-config", 0xdc0000, 0x30000},
1617 {"mutil-log", 0xf30000, 0x80000},
1618 {"oops", 0xfb0000, 0x40000},
1619 {"radio", 0xff0000, 0x10000},
1623 .first_sysupgrade_partition
= "os-image",
1624 .last_sysupgrade_partition
= "file-system"
1627 /** Firmware layout for the EAP225 v1 */
1632 "EAP225(TP-LINK|UN|AC1200-D):1.0\r\n",
1633 .part_trail
= PART_TRAIL_NONE
,
1634 .soft_ver
= SOFT_VER_DEFAULT
,
1637 {"fs-uboot", 0x00000, 0x20000},
1638 {"partition-table", 0x20000, 0x02000},
1639 {"default-mac", 0x30000, 0x01000},
1640 {"support-list", 0x31000, 0x00100},
1641 {"product-info", 0x31100, 0x00400},
1642 {"soft-version", 0x32000, 0x00100},
1643 {"firmware", 0x40000, 0xd80000},
1644 {"user-config", 0xdc0000, 0x30000},
1645 {"radio", 0xff0000, 0x10000},
1649 .first_sysupgrade_partition
= "os-image",
1650 .last_sysupgrade_partition
= "file-system"
1653 /** Firmware layout for the EAP225 v3 */
1658 "EAP225(TP-Link|UN|AC1350-D):3.0\r\n",
1659 .part_trail
= PART_TRAIL_NONE
,
1660 .soft_ver
= SOFT_VER_DEFAULT
,
1661 .soft_ver_compat_level
= 1,
1664 {"fs-uboot", 0x00000, 0x20000},
1665 {"partition-table", 0x20000, 0x02000},
1666 {"default-mac", 0x30000, 0x01000},
1667 {"support-list", 0x31000, 0x00100},
1668 {"product-info", 0x31100, 0x00400},
1669 {"soft-version", 0x32000, 0x00100},
1670 {"firmware", 0x40000, 0xd80000},
1671 {"user-config", 0xdc0000, 0x30000},
1672 {"mutil-log", 0xf30000, 0x80000},
1673 {"oops", 0xfb0000, 0x40000},
1674 {"radio", 0xff0000, 0x10000},
1678 .first_sysupgrade_partition
= "os-image",
1679 .last_sysupgrade_partition
= "file-system"
1682 /** Firmware layout for the EAP225-Wall v2 */
1684 .id
= "EAP225-WALL-V2",
1687 "EAP225-Wall(TP-Link|UN|AC1200-D):2.0\r\n",
1688 .part_trail
= PART_TRAIL_NONE
,
1689 .soft_ver
= SOFT_VER_DEFAULT
,
1690 .soft_ver_compat_level
= 1,
1693 {"fs-uboot", 0x00000, 0x20000},
1694 {"partition-table", 0x20000, 0x02000},
1695 {"default-mac", 0x30000, 0x01000},
1696 {"support-list", 0x31000, 0x00100},
1697 {"product-info", 0x31100, 0x00400},
1698 {"soft-version", 0x32000, 0x00100},
1699 {"firmware", 0x40000, 0xd80000},
1700 {"user-config", 0xdc0000, 0x30000},
1701 {"mutil-log", 0xf30000, 0x80000},
1702 {"oops", 0xfb0000, 0x40000},
1703 {"radio", 0xff0000, 0x10000},
1707 .first_sysupgrade_partition
= "os-image",
1708 .last_sysupgrade_partition
= "file-system"
1711 /** Firmware layout for the EAP235-Wall v1 */
1713 .id
= "EAP235-WALL-V1",
1716 "EAP235-Wall(TP-Link|UN|AC1200-D):1.0\r\n",
1717 .part_trail
= PART_TRAIL_NONE
,
1718 .soft_ver
= SOFT_VER_NUMERIC(3, 0, 0),
1719 .soft_ver_compat_level
= 1,
1722 {"fs-uboot", 0x00000, 0x80000},
1723 {"partition-table", 0x80000, 0x02000},
1724 {"default-mac", 0x90000, 0x01000},
1725 {"support-list", 0x91000, 0x00100},
1726 {"product-info", 0x91100, 0x00400},
1727 {"soft-version", 0x92000, 0x00100},
1728 {"firmware", 0xa0000, 0xd20000},
1729 {"user-config", 0xdc0000, 0x30000},
1730 {"mutil-log", 0xf30000, 0x80000},
1731 {"oops", 0xfb0000, 0x40000},
1732 {"radio", 0xff0000, 0x10000},
1736 .first_sysupgrade_partition
= "os-image",
1737 .last_sysupgrade_partition
= "file-system"
1740 /** Firmware layout for the EAP245 v1 */
1745 "EAP245(TP-LINK|UN|AC1750-D):1.0\r\n",
1746 .part_trail
= PART_TRAIL_NONE
,
1747 .soft_ver
= SOFT_VER_DEFAULT
,
1750 {"fs-uboot", 0x00000, 0x20000},
1751 {"partition-table", 0x20000, 0x02000},
1752 {"default-mac", 0x30000, 0x01000},
1753 {"support-list", 0x31000, 0x00100},
1754 {"product-info", 0x31100, 0x00400},
1755 {"soft-version", 0x32000, 0x00100},
1756 {"firmware", 0x40000, 0xd80000},
1757 {"user-config", 0xdc0000, 0x30000},
1758 {"radio", 0xff0000, 0x10000},
1762 .first_sysupgrade_partition
= "os-image",
1763 .last_sysupgrade_partition
= "file-system"
1766 /** Firmware layout for the EAP245 v3 */
1771 "EAP245(TP-Link|UN|AC1750-D):3.0\r\n"
1772 "EAP265 HD(TP-Link|UN|AC1750-D):1.0",
1773 .part_trail
= PART_TRAIL_NONE
,
1774 .soft_ver
= SOFT_VER_DEFAULT
,
1775 .soft_ver_compat_level
= 1,
1777 /** Firmware partition with dynamic kernel/rootfs split */
1779 {"factroy-boot", 0x00000, 0x40000},
1780 {"fs-uboot", 0x40000, 0x40000},
1781 {"partition-table", 0x80000, 0x10000},
1782 {"default-mac", 0x90000, 0x01000},
1783 {"support-list", 0x91000, 0x00100},
1784 {"product-info", 0x91100, 0x00400},
1785 {"soft-version", 0x92000, 0x00100},
1786 {"radio", 0xa0000, 0x10000},
1787 {"extra-para", 0xb0000, 0x10000},
1788 {"firmware", 0xc0000, 0xe40000},
1789 {"config", 0xf00000, 0x30000},
1790 {"mutil-log", 0xf30000, 0x80000},
1791 {"oops", 0xfb0000, 0x40000},
1795 .first_sysupgrade_partition
= "os-image",
1796 .last_sysupgrade_partition
= "file-system"
1799 /** Firmware layout for the EAP615-Wall v1 */
1801 .id
= "EAP615-WALL-V1",
1802 .soft_ver
= SOFT_VER_DEFAULT
,
1803 .soft_ver_compat_level
= 1,
1806 "EAP615-Wall(TP-Link|UN|AX1800-D):1.0\r\n"
1807 "EAP615-Wall(TP-Link|CA|AX1800-D):1.0\r\n"
1808 "EAP615-Wall(TP-Link|JP|AX1800-D):1.0\r\n",
1809 .part_trail
= PART_TRAIL_NONE
,
1812 {"fs-uboot", 0x00000, 0x80000},
1813 {"partition-table", 0x80000, 0x02000},
1814 {"default-mac", 0x90000, 0x01000},
1815 {"support-list", 0x91000, 0x00100},
1816 {"product-info", 0x91100, 0x00400},
1817 {"soft-version", 0x92000, 0x00100},
1818 {"firmware", 0xa0000, 0xcf0000},
1819 {"user-config", 0xd90000, 0x60000},
1820 {"mutil-log", 0xf30000, 0x80000},
1821 {"oops", 0xfb0000, 0x40000},
1822 {"radio", 0xff0000, 0x10000},
1826 .first_sysupgrade_partition
= "os-image",
1827 .last_sysupgrade_partition
= "file-system"
1830 /** Firmware layout for the TL-WA1201 v2 */
1832 .id
= "TL-WA1201-V2",
1836 "{product_name:TL-WA1201,product_ver:2.0.0,special_id:45550000}\n"
1837 "{product_name:TL-WA1201,product_ver:2.0.0,special_id:55530000}\n",
1839 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.1 Build 20200709 rel.66244\n"),
1842 {"fs-uboot", 0x00000, 0x20000},
1843 {"default-mac", 0x20000, 0x00200},
1844 {"pin", 0x20200, 0x00100},
1845 {"product-info", 0x20300, 0x00200},
1846 {"device-id", 0x20500, 0x0fb00},
1847 {"firmware", 0x30000, 0xce0000},
1848 {"portal-logo", 0xd10000, 0x20000},
1849 {"portal-back", 0xd30000, 0x200000},
1850 {"soft-version", 0xf30000, 0x00200},
1851 {"extra-para", 0xf30200, 0x00200},
1852 {"support-list", 0xf30400, 0x00200},
1853 {"profile", 0xf30600, 0x0fa00},
1854 {"apdef-config", 0xf40000, 0x10000},
1855 {"ap-config", 0xf50000, 0x10000},
1856 {"redef-config", 0xf60000, 0x10000},
1857 {"re-config", 0xf70000, 0x10000},
1858 {"multidef-config", 0xf80000, 0x10000},
1859 {"multi-config", 0xf90000, 0x10000},
1860 {"clientdef-config", 0xfa0000, 0x10000},
1861 {"client-config", 0xfb0000, 0x10000},
1862 {"partition-table", 0xfc0000, 0x10000},
1863 {"user-config", 0xfd0000, 0x10000},
1864 {"certificate", 0xfe0000, 0x10000},
1865 {"radio", 0xff0000, 0x10000},
1868 .first_sysupgrade_partition
= "os-image",
1869 .last_sysupgrade_partition
= "file-system",
1872 /** Firmware layout for the TL-WA850RE v2 */
1874 .id
= "TLWA850REV2",
1878 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55530000}\n"
1879 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:00000000}\n"
1880 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55534100}\n"
1881 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:45550000}\n"
1882 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4B520000}\n"
1883 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:42520000}\n"
1884 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4A500000}\n"
1885 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
1886 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
1887 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
1889 .soft_ver
= SOFT_VER_DEFAULT
,
1892 576KB were moved from file-system to os-image
1893 in comparison to the stock image
1896 {"fs-uboot", 0x00000, 0x20000},
1897 {"firmware", 0x20000, 0x390000},
1898 {"partition-table", 0x3b0000, 0x02000},
1899 {"default-mac", 0x3c0000, 0x00020},
1900 {"pin", 0x3c0100, 0x00020},
1901 {"product-info", 0x3c1000, 0x01000},
1902 {"soft-version", 0x3c2000, 0x00100},
1903 {"support-list", 0x3c3000, 0x01000},
1904 {"profile", 0x3c4000, 0x08000},
1905 {"user-config", 0x3d0000, 0x10000},
1906 {"default-config", 0x3e0000, 0x10000},
1907 {"radio", 0x3f0000, 0x10000},
1911 .first_sysupgrade_partition
= "os-image",
1912 .last_sysupgrade_partition
= "file-system"
1915 /** Firmware layout for the TL-WA855RE v1 */
1917 .id
= "TLWA855REV1",
1921 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:00000000}\n"
1922 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:55530000}\n"
1923 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:45550000}\n"
1924 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4B520000}\n"
1925 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:42520000}\n"
1926 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4A500000}\n"
1927 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:43410000}\n"
1928 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:41550000}\n"
1929 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:52550000}\n",
1931 .soft_ver
= SOFT_VER_DEFAULT
,
1934 {"fs-uboot", 0x00000, 0x20000},
1935 {"os-image", 0x20000, 0x150000},
1936 {"file-system", 0x170000, 0x240000},
1937 {"partition-table", 0x3b0000, 0x02000},
1938 {"default-mac", 0x3c0000, 0x00020},
1939 {"pin", 0x3c0100, 0x00020},
1940 {"product-info", 0x3c1000, 0x01000},
1941 {"soft-version", 0x3c2000, 0x00100},
1942 {"support-list", 0x3c3000, 0x01000},
1943 {"profile", 0x3c4000, 0x08000},
1944 {"user-config", 0x3d0000, 0x10000},
1945 {"default-config", 0x3e0000, 0x10000},
1946 {"radio", 0x3f0000, 0x10000},
1950 .first_sysupgrade_partition
= "os-image",
1951 .last_sysupgrade_partition
= "file-system"
1954 /** Firmware layout for the TL-WPA8630P v2 (EU)*/
1956 .id
= "TL-WPA8630P-V2.0-EU",
1960 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:45550000}\n",
1962 .soft_ver
= SOFT_VER_DEFAULT
,
1965 {"factory-uboot", 0x00000, 0x20000},
1966 {"fs-uboot", 0x20000, 0x20000},
1967 {"firmware", 0x40000, 0x5e0000},
1968 {"partition-table", 0x620000, 0x02000},
1969 {"default-mac", 0x630000, 0x00020},
1970 {"pin", 0x630100, 0x00020},
1971 {"device-id", 0x630200, 0x00030},
1972 {"product-info", 0x631100, 0x01000},
1973 {"extra-para", 0x632100, 0x01000},
1974 {"soft-version", 0x640000, 0x01000},
1975 {"support-list", 0x641000, 0x01000},
1976 {"profile", 0x642000, 0x08000},
1977 {"user-config", 0x650000, 0x10000},
1978 {"default-config", 0x660000, 0x10000},
1979 {"default-nvm", 0x670000, 0xc0000},
1980 {"default-pib", 0x730000, 0x40000},
1981 {"radio", 0x7f0000, 0x10000},
1985 .first_sysupgrade_partition
= "os-image",
1986 .last_sysupgrade_partition
= "file-system"
1989 /** Firmware layout for the TL-WPA8630P v2 (INT)*/
1991 .id
= "TL-WPA8630P-V2-INT",
1995 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:41550000}\n"
1996 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:44450000}\n"
1997 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:41550000}\n",
1999 .soft_ver
= SOFT_VER_DEFAULT
,
2002 {"factory-uboot", 0x00000, 0x20000},
2003 {"fs-uboot", 0x20000, 0x20000},
2004 {"firmware", 0x40000, 0x5e0000},
2005 {"partition-table", 0x620000, 0x02000},
2006 {"extra-para", 0x632100, 0x01000},
2007 {"soft-version", 0x640000, 0x01000},
2008 {"support-list", 0x641000, 0x01000},
2009 {"profile", 0x642000, 0x08000},
2010 {"user-config", 0x650000, 0x10000},
2011 {"default-config", 0x660000, 0x10000},
2012 {"default-nvm", 0x670000, 0xc0000},
2013 {"default-pib", 0x730000, 0x40000},
2014 {"default-mac", 0x7e0000, 0x00020},
2015 {"pin", 0x7e0100, 0x00020},
2016 {"device-id", 0x7e0200, 0x00030},
2017 {"product-info", 0x7e1100, 0x01000},
2018 {"radio", 0x7f0000, 0x10000},
2022 .first_sysupgrade_partition
= "os-image",
2023 .last_sysupgrade_partition
= "file-system"
2026 /** Firmware layout for the TL-WPA8630P v2.1 (EU)*/
2028 .id
= "TL-WPA8630P-V2.1-EU",
2032 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:45550000}\n",
2034 .soft_ver
= SOFT_VER_DEFAULT
,
2037 {"factory-uboot", 0x00000, 0x20000},
2038 {"fs-uboot", 0x20000, 0x20000},
2039 {"firmware", 0x40000, 0x5e0000},
2040 {"extra-para", 0x680000, 0x01000},
2041 {"product-info", 0x690000, 0x01000},
2042 {"partition-table", 0x6a0000, 0x02000},
2043 {"soft-version", 0x6b0000, 0x01000},
2044 {"support-list", 0x6b1000, 0x01000},
2045 {"profile", 0x6b2000, 0x08000},
2046 {"user-config", 0x6c0000, 0x10000},
2047 {"default-config", 0x6d0000, 0x10000},
2048 {"default-nvm", 0x6e0000, 0xc0000},
2049 {"default-pib", 0x7a0000, 0x40000},
2050 {"default-mac", 0x7e0000, 0x00020},
2051 {"pin", 0x7e0100, 0x00020},
2052 {"device-id", 0x7e0200, 0x00030},
2053 {"radio", 0x7f0000, 0x10000},
2057 .first_sysupgrade_partition
= "os-image",
2058 .last_sysupgrade_partition
= "file-system"
2061 /** Firmware layout for the TL-WPA8631P v3 */
2063 .id
= "TL-WPA8631P-V3",
2067 "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:41550000}\n"
2068 "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:45550000}\n"
2069 "{product_name:TL-WPA8631P,product_ver:3.0.0,special_id:55530000}\n",
2071 .soft_ver
= SOFT_VER_DEFAULT
,
2074 {"fs-uboot", 0x00000, 0x20000},
2075 {"firmware", 0x20000, 0x710000},
2076 {"partition-table", 0x730000, 0x02000},
2077 {"default-mac", 0x732000, 0x00020},
2078 {"pin", 0x732100, 0x00020},
2079 {"device-id", 0x732200, 0x00030},
2080 {"default-region", 0x732300, 0x00010},
2081 {"product-info", 0x732400, 0x00200},
2082 {"extra-para", 0x732600, 0x00200},
2083 {"soft-version", 0x732800, 0x00200},
2084 {"support-list", 0x732a00, 0x00100},
2085 {"profile", 0x732b00, 0x00100},
2086 {"default-config", 0x732c00, 0x00800},
2087 {"plc-type", 0x733400, 0x00020},
2088 {"default-pib", 0x733500, 0x06000},
2089 {"user-config", 0x740000, 0x10000},
2090 {"plc-pib", 0x750000, 0x10000},
2091 {"plc-nvm", 0x760000, 0x90000},
2092 {"radio", 0x7f0000, 0x10000},
2096 .first_sysupgrade_partition
= "os-image",
2097 .last_sysupgrade_partition
= "file-system"
2100 /** Firmware layout for the TL-WR1043 v5 */
2102 .id
= "TLWR1043NV5",
2106 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
2107 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
2109 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.0.0\n"),
2111 {"factory-boot", 0x00000, 0x20000},
2112 {"fs-uboot", 0x20000, 0x20000},
2113 {"firmware", 0x40000, 0xec0000},
2114 {"default-mac", 0xf00000, 0x00200},
2115 {"pin", 0xf00200, 0x00200},
2116 {"device-id", 0xf00400, 0x00100},
2117 {"product-info", 0xf00500, 0x0fb00},
2118 {"soft-version", 0xf10000, 0x01000},
2119 {"extra-para", 0xf11000, 0x01000},
2120 {"support-list", 0xf12000, 0x0a000},
2121 {"profile", 0xf1c000, 0x04000},
2122 {"default-config", 0xf20000, 0x10000},
2123 {"user-config", 0xf30000, 0x40000},
2124 {"qos-db", 0xf70000, 0x40000},
2125 {"certificate", 0xfb0000, 0x10000},
2126 {"partition-table", 0xfc0000, 0x10000},
2127 {"log", 0xfd0000, 0x20000},
2128 {"radio", 0xff0000, 0x10000},
2131 .first_sysupgrade_partition
= "os-image",
2132 .last_sysupgrade_partition
= "file-system"
2135 /** Firmware layout for the TL-WR1043 v4 */
2137 .id
= "TLWR1043NDV4",
2141 "{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
2143 .soft_ver
= SOFT_VER_DEFAULT
,
2145 /* We're using a dynamic kernel/rootfs split here */
2147 {"fs-uboot", 0x00000, 0x20000},
2148 {"firmware", 0x20000, 0xf30000},
2149 {"default-mac", 0xf50000, 0x00200},
2150 {"pin", 0xf50200, 0x00200},
2151 {"product-info", 0xf50400, 0x0fc00},
2152 {"soft-version", 0xf60000, 0x0b000},
2153 {"support-list", 0xf6b000, 0x04000},
2154 {"profile", 0xf70000, 0x04000},
2155 {"default-config", 0xf74000, 0x0b000},
2156 {"user-config", 0xf80000, 0x40000},
2157 {"partition-table", 0xfc0000, 0x10000},
2158 {"log", 0xfd0000, 0x20000},
2159 {"radio", 0xff0000, 0x10000},
2163 .first_sysupgrade_partition
= "os-image",
2164 .last_sysupgrade_partition
= "file-system"
2167 /** Firmware layout for the TL-WR902AC v1 */
2169 .id
= "TL-WR902AC-V1",
2173 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:45550000}\n"
2174 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:55530000}\n",
2176 .soft_ver
= SOFT_VER_DEFAULT
,
2179 384KB were moved from file-system to os-image
2180 in comparison to the stock image
2183 {"fs-uboot", 0x00000, 0x20000},
2184 {"firmware", 0x20000, 0x730000},
2185 {"default-mac", 0x750000, 0x00200},
2186 {"pin", 0x750200, 0x00200},
2187 {"product-info", 0x750400, 0x0fc00},
2188 {"soft-version", 0x760000, 0x0b000},
2189 {"support-list", 0x76b000, 0x04000},
2190 {"profile", 0x770000, 0x04000},
2191 {"default-config", 0x774000, 0x0b000},
2192 {"user-config", 0x780000, 0x40000},
2193 {"partition-table", 0x7c0000, 0x10000},
2194 {"log", 0x7d0000, 0x20000},
2195 {"radio", 0x7f0000, 0x10000},
2199 .first_sysupgrade_partition
= "os-image",
2200 .last_sysupgrade_partition
= "file-system",
2203 /** Firmware layout for the TL-WR941HP v1 */
2205 .id
= "TL-WR941HP-V1",
2209 "{product_name:TL-WR941HP,product_ver:1.0.0,special_id:00000000}\n",
2211 .soft_ver
= SOFT_VER_DEFAULT
,
2214 {"fs-uboot", 0x00000, 0x20000},
2215 {"firmware", 0x20000, 0x730000},
2216 {"default-mac", 0x750000, 0x00200},
2217 {"pin", 0x750200, 0x00200},
2218 {"product-info", 0x750400, 0x0fc00},
2219 {"soft-version", 0x760000, 0x0b000},
2220 {"support-list", 0x76b000, 0x04000},
2221 {"profile", 0x770000, 0x04000},
2222 {"default-config", 0x774000, 0x0b000},
2223 {"user-config", 0x780000, 0x40000},
2224 {"partition-table", 0x7c0000, 0x10000},
2225 {"log", 0x7d0000, 0x20000},
2226 {"radio", 0x7f0000, 0x10000},
2230 .first_sysupgrade_partition
= "os-image",
2231 .last_sysupgrade_partition
= "file-system",
2234 /** Firmware layout for the TL-WR942N V1 */
2240 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:00000000}\r\n"
2241 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:52550000}\r\n",
2243 .soft_ver
= SOFT_VER_DEFAULT
,
2246 {"fs-uboot", 0x00000, 0x20000},
2247 {"firmware", 0x20000, 0xe20000},
2248 {"default-mac", 0xe40000, 0x00200},
2249 {"pin", 0xe40200, 0x00200},
2250 {"product-info", 0xe40400, 0x0fc00},
2251 {"partition-table", 0xe50000, 0x10000},
2252 {"soft-version", 0xe60000, 0x10000},
2253 {"support-list", 0xe70000, 0x10000},
2254 {"profile", 0xe80000, 0x10000},
2255 {"default-config", 0xe90000, 0x10000},
2256 {"user-config", 0xea0000, 0x40000},
2257 {"qos-db", 0xee0000, 0x40000},
2258 {"certificate", 0xf20000, 0x10000},
2259 {"usb-config", 0xfb0000, 0x10000},
2260 {"log", 0xfc0000, 0x20000},
2261 {"radio-bk", 0xfe0000, 0x10000},
2262 {"radio", 0xff0000, 0x10000},
2266 .first_sysupgrade_partition
= "os-image",
2267 .last_sysupgrade_partition
= "file-system",
2270 /** Firmware layout for the RE200 v2 */
2276 "{product_name:RE200,product_ver:2.0.0,special_id:00000000}\n"
2277 "{product_name:RE200,product_ver:2.0.0,special_id:41520000}\n"
2278 "{product_name:RE200,product_ver:2.0.0,special_id:41550000}\n"
2279 "{product_name:RE200,product_ver:2.0.0,special_id:42520000}\n"
2280 "{product_name:RE200,product_ver:2.0.0,special_id:43410000}\n"
2281 "{product_name:RE200,product_ver:2.0.0,special_id:45530000}\n"
2282 "{product_name:RE200,product_ver:2.0.0,special_id:45550000}\n"
2283 "{product_name:RE200,product_ver:2.0.0,special_id:49440000}\n"
2284 "{product_name:RE200,product_ver:2.0.0,special_id:4a500000}\n"
2285 "{product_name:RE200,product_ver:2.0.0,special_id:4b520000}\n"
2286 "{product_name:RE200,product_ver:2.0.0,special_id:52550000}\n"
2287 "{product_name:RE200,product_ver:2.0.0,special_id:54570000}\n"
2288 "{product_name:RE200,product_ver:2.0.0,special_id:55530000}\n",
2290 .soft_ver
= SOFT_VER_DEFAULT
,
2293 {"fs-uboot", 0x00000, 0x20000},
2294 {"firmware", 0x20000, 0x7a0000},
2295 {"partition-table", 0x7c0000, 0x02000},
2296 {"default-mac", 0x7c2000, 0x00020},
2297 {"pin", 0x7c2100, 0x00020},
2298 {"product-info", 0x7c3100, 0x01000},
2299 {"soft-version", 0x7c4200, 0x01000},
2300 {"support-list", 0x7c5200, 0x01000},
2301 {"profile", 0x7c6200, 0x08000},
2302 {"config-info", 0x7ce200, 0x00400},
2303 {"user-config", 0x7d0000, 0x10000},
2304 {"default-config", 0x7e0000, 0x10000},
2305 {"radio", 0x7f0000, 0x10000},
2309 .first_sysupgrade_partition
= "os-image",
2310 .last_sysupgrade_partition
= "file-system"
2313 /** Firmware layout for the RE200 v3 */
2319 "{product_name:RE200,product_ver:3.0.0,special_id:00000000}\n"
2320 "{product_name:RE200,product_ver:3.0.0,special_id:41520000}\n"
2321 "{product_name:RE200,product_ver:3.0.0,special_id:41550000}\n"
2322 "{product_name:RE200,product_ver:3.0.0,special_id:42520000}\n"
2323 "{product_name:RE200,product_ver:3.0.0,special_id:43410000}\n"
2324 "{product_name:RE200,product_ver:3.0.0,special_id:45470000}\n"
2325 "{product_name:RE200,product_ver:3.0.0,special_id:45530000}\n"
2326 "{product_name:RE200,product_ver:3.0.0,special_id:45550000}\n"
2327 "{product_name:RE200,product_ver:3.0.0,special_id:49440000}\n"
2328 "{product_name:RE200,product_ver:3.0.0,special_id:4A500000}\n"
2329 "{product_name:RE200,product_ver:3.0.0,special_id:4B520000}\n"
2330 "{product_name:RE200,product_ver:3.0.0,special_id:52550000}\n"
2331 "{product_name:RE200,product_ver:3.0.0,special_id:54570000}\n"
2332 "{product_name:RE200,product_ver:3.0.0,special_id:55530000}\n",
2334 .soft_ver
= SOFT_VER_DEFAULT
,
2337 {"fs-uboot", 0x00000, 0x20000},
2338 {"firmware", 0x20000, 0x7a0000},
2339 {"partition-table", 0x7c0000, 0x02000},
2340 {"default-mac", 0x7c2000, 0x00020},
2341 {"pin", 0x7c2100, 0x00020},
2342 {"product-info", 0x7c3100, 0x01000},
2343 {"soft-version", 0x7c4200, 0x01000},
2344 {"support-list", 0x7c5200, 0x01000},
2345 {"profile", 0x7c6200, 0x08000},
2346 {"config-info", 0x7ce200, 0x00400},
2347 {"user-config", 0x7d0000, 0x10000},
2348 {"default-config", 0x7e0000, 0x10000},
2349 {"radio", 0x7f0000, 0x10000},
2353 .first_sysupgrade_partition
= "os-image",
2354 .last_sysupgrade_partition
= "file-system"
2357 /** Firmware layout for the RE200 v4 */
2363 "{product_name:RE200,product_ver:4.0.0,special_id:00000000}\n"
2364 "{product_name:RE200,product_ver:4.0.0,special_id:45550000}\n"
2365 "{product_name:RE200,product_ver:4.0.0,special_id:4A500000}\n"
2366 "{product_name:RE200,product_ver:4.0.0,special_id:4B520000}\n"
2367 "{product_name:RE200,product_ver:4.0.0,special_id:43410000}\n"
2368 "{product_name:RE200,product_ver:4.0.0,special_id:41550000}\n"
2369 "{product_name:RE200,product_ver:4.0.0,special_id:42520000}\n"
2370 "{product_name:RE200,product_ver:4.0.0,special_id:55530000}\n"
2371 "{product_name:RE200,product_ver:4.0.0,special_id:41520000}\n"
2372 "{product_name:RE200,product_ver:4.0.0,special_id:52550000}\n"
2373 "{product_name:RE200,product_ver:4.0.0,special_id:54570000}\n"
2374 "{product_name:RE200,product_ver:4.0.0,special_id:45530000}\n"
2375 "{product_name:RE200,product_ver:4.0.0,special_id:49440000}\n"
2376 "{product_name:RE200,product_ver:4.0.0,special_id:45470000}\n",
2378 .soft_ver
= SOFT_VER_TEXT("soft_ver:1.1.0\n"),
2381 {"fs-uboot", 0x00000, 0x20000},
2382 {"firmware", 0x20000, 0x7a0000},
2383 {"partition-table", 0x7c0000, 0x02000},
2384 {"default-mac", 0x7c2000, 0x00020},
2385 {"pin", 0x7c2100, 0x00020},
2386 {"product-info", 0x7c3100, 0x01000},
2387 {"soft-version", 0x7c4200, 0x01000},
2388 {"support-list", 0x7c5200, 0x01000},
2389 {"profile", 0x7c6200, 0x08000},
2390 {"config-info", 0x7ce200, 0x00400},
2391 {"user-config", 0x7d0000, 0x10000},
2392 {"default-config", 0x7e0000, 0x10000},
2393 {"radio", 0x7f0000, 0x10000},
2397 .first_sysupgrade_partition
= "os-image",
2398 .last_sysupgrade_partition
= "file-system"
2401 /** Firmware layout for the RE220 v2 */
2407 "{product_name:RE220,product_ver:2.0.0,special_id:00000000}\n"
2408 "{product_name:RE220,product_ver:2.0.0,special_id:41520000}\n"
2409 "{product_name:RE220,product_ver:2.0.0,special_id:41550000}\n"
2410 "{product_name:RE220,product_ver:2.0.0,special_id:42520000}\n"
2411 "{product_name:RE220,product_ver:2.0.0,special_id:43410000}\n"
2412 "{product_name:RE220,product_ver:2.0.0,special_id:45530000}\n"
2413 "{product_name:RE220,product_ver:2.0.0,special_id:45550000}\n"
2414 "{product_name:RE220,product_ver:2.0.0,special_id:49440000}\n"
2415 "{product_name:RE220,product_ver:2.0.0,special_id:4a500000}\n"
2416 "{product_name:RE220,product_ver:2.0.0,special_id:4b520000}\n"
2417 "{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n"
2418 "{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n"
2419 "{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n",
2421 .soft_ver
= SOFT_VER_DEFAULT
,
2424 {"fs-uboot", 0x00000, 0x20000},
2425 {"firmware", 0x20000, 0x7a0000},
2426 {"partition-table", 0x7c0000, 0x02000},
2427 {"default-mac", 0x7c2000, 0x00020},
2428 {"pin", 0x7c2100, 0x00020},
2429 {"product-info", 0x7c3100, 0x01000},
2430 {"soft-version", 0x7c4200, 0x01000},
2431 {"support-list", 0x7c5200, 0x01000},
2432 {"profile", 0x7c6200, 0x08000},
2433 {"config-info", 0x7ce200, 0x00400},
2434 {"user-config", 0x7d0000, 0x10000},
2435 {"default-config", 0x7e0000, 0x10000},
2436 {"radio", 0x7f0000, 0x10000},
2440 .first_sysupgrade_partition
= "os-image",
2441 .last_sysupgrade_partition
= "file-system"
2444 /** Firmware layout for the RE305 v1 */
2450 "{product_name:RE305,product_ver:1.0.0,special_id:45550000}\n"
2451 "{product_name:RE305,product_ver:1.0.0,special_id:55530000}\n"
2452 "{product_name:RE305,product_ver:1.0.0,special_id:4a500000}\n"
2453 "{product_name:RE305,product_ver:1.0.0,special_id:42520000}\n"
2454 "{product_name:RE305,product_ver:1.0.0,special_id:4b520000}\n"
2455 "{product_name:RE305,product_ver:1.0.0,special_id:41550000}\n"
2456 "{product_name:RE305,product_ver:1.0.0,special_id:43410000}\n",
2458 .soft_ver
= SOFT_VER_DEFAULT
,
2461 {"fs-uboot", 0x00000, 0x20000},
2462 {"firmware", 0x20000, 0x5e0000},
2463 {"partition-table", 0x600000, 0x02000},
2464 {"default-mac", 0x610000, 0x00020},
2465 {"pin", 0x610100, 0x00020},
2466 {"product-info", 0x611100, 0x01000},
2467 {"soft-version", 0x620000, 0x01000},
2468 {"support-list", 0x621000, 0x01000},
2469 {"profile", 0x622000, 0x08000},
2470 {"user-config", 0x630000, 0x10000},
2471 {"default-config", 0x640000, 0x10000},
2472 {"radio", 0x7f0000, 0x10000},
2476 .first_sysupgrade_partition
= "os-image",
2477 .last_sysupgrade_partition
= "file-system"
2480 /** Firmware layout for the RE305 v3 */
2486 "{product_name:RE305,product_ver:3.0.0,special_id:00000000}\n"
2487 "{product_name:RE305,product_ver:3.0.0,special_id:45550000}\n"
2488 "{product_name:RE305,product_ver:3.0.0,special_id:4A500000}\n"
2489 "{product_name:RE305,product_ver:3.0.0,special_id:4B520000}\n"
2490 "{product_name:RE305,product_ver:3.0.0,special_id:41550000}\n"
2491 "{product_name:RE305,product_ver:3.0.0,special_id:42520000}\n"
2492 "{product_name:RE305,product_ver:3.0.0,special_id:55530000}\n"
2493 "{product_name:RE305,product_ver:3.0.0,special_id:45530000}\n"
2494 "{product_name:RE305,product_ver:3.0.0,special_id:41530000}\n"
2495 "{product_name:RE305,product_ver:3.0.0,special_id:43410000}\n"
2496 "{product_name:RE305,product_ver:3.0.0,special_id:52550000}\n",
2498 .soft_ver
= SOFT_VER_TEXT("soft_ver:2.0.0\n"),
2501 {"fs-uboot", 0x00000, 0x20000},
2502 {"firmware", 0x20000, 0x7a0000},
2503 {"partition-table", 0x7c0000, 0x02000},
2504 {"default-mac", 0x7c2000, 0x00020},
2505 {"pin", 0x7c2100, 0x00020},
2506 {"product-info", 0x7c3100, 0x01000},
2507 {"soft-version", 0x7c4200, 0x01000},
2508 {"support-list", 0x7c5200, 0x01000},
2509 {"profile", 0x7c6200, 0x08000},
2510 {"config-info", 0x7ce200, 0x00400},
2511 {"user-config", 0x7d0000, 0x10000},
2512 {"default-config", 0x7e0000, 0x10000},
2513 {"radio", 0x7f0000, 0x10000},
2517 .first_sysupgrade_partition
= "os-image",
2518 .last_sysupgrade_partition
= "file-system"
2521 /** Firmware layout for the RE350 v1 */
2527 "{product_name:RE350,product_ver:1.0.0,special_id:45550000}\n"
2528 "{product_name:RE350,product_ver:1.0.0,special_id:00000000}\n"
2529 "{product_name:RE350,product_ver:1.0.0,special_id:41550000}\n"
2530 "{product_name:RE350,product_ver:1.0.0,special_id:55530000}\n"
2531 "{product_name:RE350,product_ver:1.0.0,special_id:43410000}\n"
2532 "{product_name:RE350,product_ver:1.0.0,special_id:4b520000}\n"
2533 "{product_name:RE350,product_ver:1.0.0,special_id:4a500000}\n",
2535 .soft_ver
= SOFT_VER_DEFAULT
,
2537 /** We're using a dynamic kernel/rootfs split here */
2539 {"fs-uboot", 0x00000, 0x20000},
2540 {"firmware", 0x20000, 0x5e0000},
2541 {"partition-table", 0x600000, 0x02000},
2542 {"default-mac", 0x610000, 0x00020},
2543 {"pin", 0x610100, 0x00020},
2544 {"product-info", 0x611100, 0x01000},
2545 {"soft-version", 0x620000, 0x01000},
2546 {"support-list", 0x621000, 0x01000},
2547 {"profile", 0x622000, 0x08000},
2548 {"user-config", 0x630000, 0x10000},
2549 {"default-config", 0x640000, 0x10000},
2550 {"radio", 0x7f0000, 0x10000},
2554 .first_sysupgrade_partition
= "os-image",
2555 .last_sysupgrade_partition
= "file-system"
2558 /** Firmware layout for the RE350K v1 */
2564 "{product_name:RE350K,product_ver:1.0.0,special_id:00000000,product_region:US}\n",
2566 .soft_ver
= SOFT_VER_DEFAULT
,
2568 /** We're using a dynamic kernel/rootfs split here */
2570 {"fs-uboot", 0x00000, 0x20000},
2571 {"firmware", 0x20000, 0xd70000},
2572 {"partition-table", 0xd90000, 0x02000},
2573 {"default-mac", 0xda0000, 0x00020},
2574 {"pin", 0xda0100, 0x00020},
2575 {"product-info", 0xda1100, 0x01000},
2576 {"soft-version", 0xdb0000, 0x01000},
2577 {"support-list", 0xdb1000, 0x01000},
2578 {"profile", 0xdb2000, 0x08000},
2579 {"user-config", 0xdc0000, 0x10000},
2580 {"default-config", 0xdd0000, 0x10000},
2581 {"device-id", 0xde0000, 0x00108},
2582 {"radio", 0xff0000, 0x10000},
2586 .first_sysupgrade_partition
= "os-image",
2587 .last_sysupgrade_partition
= "file-system"
2590 /** Firmware layout for the RE355 */
2596 "{product_name:RE355,product_ver:1.0.0,special_id:00000000}\r\n"
2597 "{product_name:RE355,product_ver:1.0.0,special_id:55530000}\r\n"
2598 "{product_name:RE355,product_ver:1.0.0,special_id:45550000}\r\n"
2599 "{product_name:RE355,product_ver:1.0.0,special_id:4A500000}\r\n"
2600 "{product_name:RE355,product_ver:1.0.0,special_id:43410000}\r\n"
2601 "{product_name:RE355,product_ver:1.0.0,special_id:41550000}\r\n"
2602 "{product_name:RE355,product_ver:1.0.0,special_id:4B520000}\r\n"
2603 "{product_name:RE355,product_ver:1.0.0,special_id:55534100}\r\n",
2605 .soft_ver
= SOFT_VER_DEFAULT
,
2607 /* We're using a dynamic kernel/rootfs split here */
2609 {"fs-uboot", 0x00000, 0x20000},
2610 {"firmware", 0x20000, 0x5e0000},
2611 {"partition-table", 0x600000, 0x02000},
2612 {"default-mac", 0x610000, 0x00020},
2613 {"pin", 0x610100, 0x00020},
2614 {"product-info", 0x611100, 0x01000},
2615 {"soft-version", 0x620000, 0x01000},
2616 {"support-list", 0x621000, 0x01000},
2617 {"profile", 0x622000, 0x08000},
2618 {"user-config", 0x630000, 0x10000},
2619 {"default-config", 0x640000, 0x10000},
2620 {"radio", 0x7f0000, 0x10000},
2624 .first_sysupgrade_partition
= "os-image",
2625 .last_sysupgrade_partition
= "file-system"
2628 /** Firmware layout for the RE450 */
2634 "{product_name:RE450,product_ver:1.0.0,special_id:00000000}\r\n"
2635 "{product_name:RE450,product_ver:1.0.0,special_id:55530000}\r\n"
2636 "{product_name:RE450,product_ver:1.0.0,special_id:45550000}\r\n"
2637 "{product_name:RE450,product_ver:1.0.0,special_id:4A500000}\r\n"
2638 "{product_name:RE450,product_ver:1.0.0,special_id:43410000}\r\n"
2639 "{product_name:RE450,product_ver:1.0.0,special_id:41550000}\r\n"
2640 "{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
2641 "{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
2643 .soft_ver
= SOFT_VER_DEFAULT
,
2645 /** We're using a dynamic kernel/rootfs split here */
2647 {"fs-uboot", 0x00000, 0x20000},
2648 {"firmware", 0x20000, 0x5e0000},
2649 {"partition-table", 0x600000, 0x02000},
2650 {"default-mac", 0x610000, 0x00020},
2651 {"pin", 0x610100, 0x00020},
2652 {"product-info", 0x611100, 0x01000},
2653 {"soft-version", 0x620000, 0x01000},
2654 {"support-list", 0x621000, 0x01000},
2655 {"profile", 0x622000, 0x08000},
2656 {"user-config", 0x630000, 0x10000},
2657 {"default-config", 0x640000, 0x10000},
2658 {"radio", 0x7f0000, 0x10000},
2662 .first_sysupgrade_partition
= "os-image",
2663 .last_sysupgrade_partition
= "file-system"
2666 /** Firmware layout for the RE450 v2 */
2672 "{product_name:RE450,product_ver:2.0.0,special_id:00000000}\r\n"
2673 "{product_name:RE450,product_ver:2.0.0,special_id:55530000}\r\n"
2674 "{product_name:RE450,product_ver:2.0.0,special_id:45550000}\r\n"
2675 "{product_name:RE450,product_ver:2.0.0,special_id:4A500000}\r\n"
2676 "{product_name:RE450,product_ver:2.0.0,special_id:43410000}\r\n"
2677 "{product_name:RE450,product_ver:2.0.0,special_id:41550000}\r\n"
2678 "{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n"
2679 "{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n"
2680 "{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n",
2682 .soft_ver
= SOFT_VER_DEFAULT
,
2684 /* We're using a dynamic kernel/rootfs split here */
2686 {"fs-uboot", 0x00000, 0x20000},
2687 {"firmware", 0x20000, 0x5e0000},
2688 {"partition-table", 0x600000, 0x02000},
2689 {"default-mac", 0x610000, 0x00020},
2690 {"pin", 0x610100, 0x00020},
2691 {"product-info", 0x611100, 0x01000},
2692 {"soft-version", 0x620000, 0x01000},
2693 {"support-list", 0x621000, 0x01000},
2694 {"profile", 0x622000, 0x08000},
2695 {"user-config", 0x630000, 0x10000},
2696 {"default-config", 0x640000, 0x10000},
2697 {"radio", 0x7f0000, 0x10000},
2701 .first_sysupgrade_partition
= "os-image",
2702 .last_sysupgrade_partition
= "file-system"
2705 /** Firmware layout for the RE450 v3 */
2711 "{product_name:RE450,product_ver:3.0.0,special_id:00000000}\r\n"
2712 "{product_name:RE450,product_ver:3.0.0,special_id:55530000}\r\n"
2713 "{product_name:RE450,product_ver:3.0.0,special_id:45550000}\r\n"
2714 "{product_name:RE450,product_ver:3.0.0,special_id:4A500000}\r\n"
2715 "{product_name:RE450,product_ver:3.0.0,special_id:43410000}\r\n"
2716 "{product_name:RE450,product_ver:3.0.0,special_id:41550000}\r\n"
2717 "{product_name:RE450,product_ver:3.0.0,special_id:41530000}\r\n"
2718 "{product_name:RE450,product_ver:3.0.0,special_id:4B520000}\r\n"
2719 "{product_name:RE450,product_ver:3.0.0,special_id:42520000}\r\n",
2721 .soft_ver
= SOFT_VER_DEFAULT
,
2723 /* We're using a dynamic kernel/rootfs split here */
2725 {"fs-uboot", 0x00000, 0x20000},
2726 {"default-mac", 0x20000, 0x00020},
2727 {"pin", 0x20020, 0x00020},
2728 {"product-info", 0x21000, 0x01000},
2729 {"partition-table", 0x22000, 0x02000},
2730 {"soft-version", 0x24000, 0x01000},
2731 {"support-list", 0x25000, 0x01000},
2732 {"profile", 0x26000, 0x08000},
2733 {"user-config", 0x2e000, 0x10000},
2734 {"default-config", 0x3e000, 0x10000},
2735 {"config-info", 0x4e000, 0x00400},
2736 {"firmware", 0x50000, 0x7a0000},
2737 {"radio", 0x7f0000, 0x10000},
2741 .first_sysupgrade_partition
= "os-image",
2742 .last_sysupgrade_partition
= "file-system"
2745 /** Firmware layout for the RE455 v1 */
2751 "{product_name:RE455,product_ver:1.0.0,special_id:00000000}\r\n"
2752 "{product_name:RE455,product_ver:1.0.0,special_id:55530000}\r\n"
2753 "{product_name:RE455,product_ver:1.0.0,special_id:45550000}\r\n"
2754 "{product_name:RE455,product_ver:1.0.0,special_id:4A500000}\r\n"
2755 "{product_name:RE455,product_ver:1.0.0,special_id:43410000}\r\n"
2756 "{product_name:RE455,product_ver:1.0.0,special_id:41550000}\r\n"
2757 "{product_name:RE455,product_ver:1.0.0,special_id:41530000}\r\n"
2758 "{product_name:RE455,product_ver:1.0.0,special_id:4B520000}\r\n"
2759 "{product_name:RE455,product_ver:1.0.0,special_id:42520000}\r\n",
2761 .soft_ver
= SOFT_VER_DEFAULT
,
2763 /* We're using a dynamic kernel/rootfs split here */
2765 {"fs-uboot", 0x00000, 0x20000},
2766 {"default-mac", 0x20000, 0x00020},
2767 {"pin", 0x20020, 0x00020},
2768 {"product-info", 0x21000, 0x01000},
2769 {"partition-table", 0x22000, 0x02000},
2770 {"soft-version", 0x24000, 0x01000},
2771 {"support-list", 0x25000, 0x01000},
2772 {"profile", 0x26000, 0x08000},
2773 {"user-config", 0x2e000, 0x10000},
2774 {"default-config", 0x3e000, 0x10000},
2775 {"config-info", 0x4e000, 0x00400},
2776 {"firmware", 0x50000, 0x7a0000},
2777 {"radio", 0x7f0000, 0x10000},
2781 .first_sysupgrade_partition
= "os-image",
2782 .last_sysupgrade_partition
= "file-system"
2785 /** Firmware layout for the RE500 */
2791 "{product_name:RE500,product_ver:1.0.0,special_id:00000000}\r\n"
2792 "{product_name:RE500,product_ver:1.0.0,special_id:55530000}\r\n"
2793 "{product_name:RE500,product_ver:1.0.0,special_id:45550000}\r\n"
2794 "{product_name:RE500,product_ver:1.0.0,special_id:4A500000}\r\n"
2795 "{product_name:RE500,product_ver:1.0.0,special_id:43410000}\r\n"
2796 "{product_name:RE500,product_ver:1.0.0,special_id:41550000}\r\n"
2797 "{product_name:RE500,product_ver:1.0.0,special_id:41530000}\r\n",
2799 .soft_ver
= SOFT_VER_DEFAULT
,
2801 /* We're using a dynamic kernel/rootfs split here */
2803 {"fs-uboot", 0x00000, 0x20000},
2804 {"firmware", 0x20000, 0xde0000},
2805 {"partition-table", 0xe00000, 0x02000},
2806 {"default-mac", 0xe10000, 0x00020},
2807 {"pin", 0xe10100, 0x00020},
2808 {"product-info", 0xe11100, 0x01000},
2809 {"soft-version", 0xe20000, 0x01000},
2810 {"support-list", 0xe21000, 0x01000},
2811 {"profile", 0xe22000, 0x08000},
2812 {"user-config", 0xe30000, 0x10000},
2813 {"default-config", 0xe40000, 0x10000},
2814 {"radio", 0xff0000, 0x10000},
2818 .first_sysupgrade_partition
= "os-image",
2819 .last_sysupgrade_partition
= "file-system"
2822 /** Firmware layout for the RE650 */
2828 "{product_name:RE650,product_ver:1.0.0,special_id:00000000}\r\n"
2829 "{product_name:RE650,product_ver:1.0.0,special_id:55530000}\r\n"
2830 "{product_name:RE650,product_ver:1.0.0,special_id:45550000}\r\n"
2831 "{product_name:RE650,product_ver:1.0.0,special_id:4A500000}\r\n"
2832 "{product_name:RE650,product_ver:1.0.0,special_id:43410000}\r\n"
2833 "{product_name:RE650,product_ver:1.0.0,special_id:41550000}\r\n"
2834 "{product_name:RE650,product_ver:1.0.0,special_id:41530000}\r\n",
2836 .soft_ver
= SOFT_VER_DEFAULT
,
2838 /* We're using a dynamic kernel/rootfs split here */
2840 {"fs-uboot", 0x00000, 0x20000},
2841 {"firmware", 0x20000, 0xde0000},
2842 {"partition-table", 0xe00000, 0x02000},
2843 {"default-mac", 0xe10000, 0x00020},
2844 {"pin", 0xe10100, 0x00020},
2845 {"product-info", 0xe11100, 0x01000},
2846 {"soft-version", 0xe20000, 0x01000},
2847 {"support-list", 0xe21000, 0x01000},
2848 {"profile", 0xe22000, 0x08000},
2849 {"user-config", 0xe30000, 0x10000},
2850 {"default-config", 0xe40000, 0x10000},
2851 {"radio", 0xff0000, 0x10000},
2855 .first_sysupgrade_partition
= "os-image",
2856 .last_sysupgrade_partition
= "file-system"
2858 /** Firmware layout for the RE650 V2 (8MB Flash)*/
2864 "{product_name:RE650,product_ver:2.0.0,special_id:00000000}\n"
2865 "{product_name:RE650,product_ver:2.0.0,special_id:45550000}\n"
2866 "{product_name:RE650,product_ver:2.0.0,special_id:4A500000}\n"
2867 "{product_name:RE650,product_ver:2.0.0,special_id:41550000}\n"
2868 "{product_name:RE650,product_ver:2.0.0,special_id:43410000}\n"
2869 "{product_name:RE650,product_ver:2.0.0,special_id:41530000}\n"
2870 "{product_name:RE650,product_ver:2.0.0,special_id:55530000}\n",
2872 /* For RE650 v2, soft ver is required, otherwise OEM install doesn't work */
2873 .soft_ver
= SOFT_VER_TEXT("soft_ver:2.0.0\n"),
2875 /* We're using a dynamic kernel/rootfs split here */
2877 {"fs-uboot", 0x00000, 0x20000},
2878 {"firmware", 0x20000, 0x7a0000},
2879 {"partition-table", 0x7c0000, 0x02000},
2880 {"default-mac", 0x7c2000, 0x00020},
2881 {"pin", 0x7c2100, 0x00020},
2882 {"product-info", 0x7c3100, 0x01000},
2883 {"soft-version", 0x7c4200, 0x01000},
2884 {"support-list", 0x7c5200, 0x01000},
2885 {"profile", 0x7c6200, 0x08000},
2886 {"config-info", 0x7ce200, 0x00400},
2887 {"user-config", 0x7d0000, 0x10000},
2888 {"default-config", 0x7e0000, 0x10000},
2889 {"radio", 0x7f0000, 0x10000},
2893 .first_sysupgrade_partition
= "os-image",
2894 .last_sysupgrade_partition
= "file-system"
2901 #define error(_ret, _errno, _str, ...) \
2903 fprintf(stderr, _str ": %s\n", ## __VA_ARGS__, \
2904 strerror(_errno)); \
2910 /** Stores a uint32 as big endian */
2911 static inline void put32(uint8_t *buf
, uint32_t val
) {
2918 static inline bool meta_partition_should_pad(enum partition_trail_value pv
)
2920 return (pv
>= 0) && (pv
<= PART_TRAIL_MAX
);
2923 /** Allocate a padded meta partition with a correctly initialised header
2924 * If the `data` pointer is NULL, then the required space is only allocated,
2925 * otherwise `data_len` bytes will be copied from `data` into the partition
2927 static struct image_partition_entry
init_meta_partition_entry(
2928 const char *name
, const void *data
, uint32_t data_len
,
2929 enum partition_trail_value pad_value
)
2931 uint32_t total_len
= sizeof(struct meta_header
) + data_len
;
2932 if (meta_partition_should_pad(pad_value
))
2935 struct image_partition_entry entry
= {
2938 .data
= malloc(total_len
)
2941 error(1, errno
, "failed to allocate meta partition entry");
2943 struct meta_header
*header
= (struct meta_header
*)entry
.data
;
2944 header
->length
= htonl(data_len
);
2948 memcpy(entry
.data
+sizeof(*header
), data
, data_len
);
2950 if (meta_partition_should_pad(pad_value
))
2951 entry
.data
[total_len
- 1] = (uint8_t) pad_value
;
2956 /** Allocates a new image partition */
2957 static struct image_partition_entry
alloc_image_partition(const char *name
, size_t len
) {
2958 struct image_partition_entry entry
= {name
, len
, malloc(len
)};
2960 error(1, errno
, "malloc");
2965 /** Frees an image partition */
2966 static void free_image_partition(struct image_partition_entry entry
) {
2970 static time_t source_date_epoch
= -1;
2971 static void set_source_date_epoch() {
2972 char *env
= getenv("SOURCE_DATE_EPOCH");
2976 source_date_epoch
= strtoull(env
, &endptr
, 10);
2977 if (errno
|| (endptr
&& *endptr
!= '\0')) {
2978 fprintf(stderr
, "Invalid SOURCE_DATE_EPOCH");
2984 /** Generates the partition-table partition */
2985 static struct image_partition_entry
make_partition_table(const struct flash_partition_entry
*p
) {
2986 struct image_partition_entry entry
= alloc_image_partition("partition-table", 0x800);
2988 char *s
= (char *)entry
.data
, *end
= (char *)(s
+entry
.size
);
2996 for (i
= 0; p
[i
].name
; i
++) {
2998 size_t w
= snprintf(s
, len
, "partition %s base 0x%05x size 0x%05x\n", p
[i
].name
, p
[i
].base
, p
[i
].size
);
3001 error(1, 0, "flash partition table overflow?");
3008 memset(s
, 0xff, end
-s
);
3014 /** Generates a binary-coded decimal representation of an integer in the range [0, 99] */
3015 static inline uint8_t bcd(uint8_t v
) {
3016 return 0x10 * (v
/10) + v
%10;
3020 /** Generates the soft-version partition */
3021 static struct image_partition_entry
make_soft_version(
3022 const struct device_info
*info
, uint32_t rev
)
3024 /** If an info string is provided, use this instead of
3025 * the structured data, and include the null-termination */
3026 if (info
->soft_ver
.type
== SOFT_VER_TYPE_TEXT
) {
3027 uint32_t len
= strlen(info
->soft_ver
.text
) + 1;
3028 return init_meta_partition_entry("soft-version",
3029 info
->soft_ver
.text
, len
, info
->part_trail
);
3034 if (source_date_epoch
!= -1)
3035 t
= source_date_epoch
;
3036 else if (time(&t
) == (time_t)(-1))
3037 error(1, errno
, "time");
3039 struct tm
*tm
= gmtime(&t
);
3041 struct soft_version s
= {
3044 .version_major
= info
->soft_ver
.num
[0],
3045 .version_minor
= info
->soft_ver
.num
[1],
3046 .version_patch
= info
->soft_ver
.num
[2],
3048 .year_hi
= bcd((1900+tm
->tm_year
)/100),
3049 .year_lo
= bcd(tm
->tm_year
%100),
3050 .month
= bcd(tm
->tm_mon
+1),
3051 .day
= bcd(tm
->tm_mday
),
3054 .compat_level
= htonl(info
->soft_ver_compat_level
)
3057 if (info
->soft_ver_compat_level
== 0)
3058 return init_meta_partition_entry("soft-version", &s
,
3059 (uint8_t *)(&s
.compat_level
) - (uint8_t *)(&s
),
3062 return init_meta_partition_entry("soft-version", &s
,
3063 sizeof(s
), info
->part_trail
);
3066 /** Generates the support-list partition */
3067 static struct image_partition_entry
make_support_list(
3068 const struct device_info
*info
)
3070 uint32_t len
= strlen(info
->support_list
);
3071 return init_meta_partition_entry("support-list", info
->support_list
,
3072 len
, info
->part_trail
);
3075 /** Partition with extra-para data */
3076 static struct image_partition_entry
make_extra_para(
3077 const struct device_info
*info
, const uint8_t *extra_para
, size_t len
)
3079 return init_meta_partition_entry("extra-para", extra_para
, len
,
3083 /** Creates a new image partition with an arbitrary name from a file */
3084 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
) {
3085 struct stat statbuf
;
3087 if (stat(filename
, &statbuf
) < 0)
3088 error(1, errno
, "unable to stat file `%s'", filename
);
3090 size_t len
= statbuf
.st_size
;
3092 if (add_jffs2_eof
) {
3093 if (file_system_partition
)
3094 len
= ALIGN(len
+ file_system_partition
->base
, 0x10000) + sizeof(jffs2_eof_mark
) - file_system_partition
->base
;
3096 len
= ALIGN(len
, 0x10000) + sizeof(jffs2_eof_mark
);
3099 struct image_partition_entry entry
= alloc_image_partition(part_name
, len
);
3101 FILE *file
= fopen(filename
, "rb");
3103 error(1, errno
, "unable to open file `%s'", filename
);
3105 if (fread(entry
.data
, statbuf
.st_size
, 1, file
) != 1)
3106 error(1, errno
, "unable to read file `%s'", filename
);
3108 if (add_jffs2_eof
) {
3109 uint8_t *eof
= entry
.data
+ statbuf
.st_size
, *end
= entry
.data
+entry
.size
;
3111 memset(eof
, 0xff, end
- eof
- sizeof(jffs2_eof_mark
));
3112 memcpy(end
- sizeof(jffs2_eof_mark
), jffs2_eof_mark
, sizeof(jffs2_eof_mark
));
3121 Copies a list of image partitions into an image buffer and generates the image partition table while doing so
3123 Example image partition table:
3125 fwup-ptn partition-table base 0x00800 size 0x00800
3126 fwup-ptn os-image base 0x01000 size 0x113b45
3127 fwup-ptn file-system base 0x114b45 size 0x1d0004
3128 fwup-ptn support-list base 0x2e4b49 size 0x000d1
3130 Each line of the partition table is terminated with the bytes 09 0d 0a ("\t\r\n"),
3131 the end of the partition table is marked with a zero byte.
3133 The firmware image must contain at least the partition-table and support-list partitions
3134 to be accepted. There aren't any alignment constraints for the image partitions.
3136 The partition-table partition contains the actual flash layout; partitions
3137 from the image partition table are mapped to the corresponding flash partitions during
3138 the firmware upgrade. The support-list partition contains a list of devices supported by
3141 The base offsets in the firmware partition table are relative to the end
3142 of the vendor information block, so the partition-table partition will
3143 actually start at offset 0x1814 of the image.
3145 I think partition-table must be the first partition in the firmware image.
3147 static void put_partitions(uint8_t *buffer
, const struct flash_partition_entry
*flash_parts
, const struct image_partition_entry
*parts
) {
3149 char *image_pt
= (char *)buffer
, *end
= image_pt
+ 0x800;
3151 size_t base
= 0x800;
3152 for (i
= 0; parts
[i
].name
; i
++) {
3153 for (j
= 0; flash_parts
[j
].name
; j
++) {
3154 if (!strcmp(flash_parts
[j
].name
, parts
[i
].name
)) {
3155 if (parts
[i
].size
> flash_parts
[j
].size
)
3156 error(1, 0, "%s partition too big (more than %u bytes)", flash_parts
[j
].name
, (unsigned)flash_parts
[j
].size
);
3161 assert(flash_parts
[j
].name
);
3163 memcpy(buffer
+ base
, parts
[i
].data
, parts
[i
].size
);
3165 size_t len
= end
-image_pt
;
3166 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
);
3169 error(1, 0, "image partition table overflow?");
3173 base
+= parts
[i
].size
;
3177 /** Generates and writes the image MD5 checksum */
3178 static void put_md5(uint8_t *md5
, uint8_t *buffer
, unsigned int len
) {
3182 MD5_Update(&ctx
, md5_salt
, (unsigned int)sizeof(md5_salt
));
3183 MD5_Update(&ctx
, buffer
, len
);
3184 MD5_Final(md5
, &ctx
);
3189 Generates the firmware image in factory format
3195 0000-0003 Image size (4 bytes, big endian)
3196 0004-0013 MD5 hash (hash of a 16 byte salt and the image data starting with byte 0x14)
3197 0014-0017 Vendor information length (without padding) (4 bytes, big endian)
3198 0018-1013 Vendor information (4092 bytes, padded with 0xff; there seem to be older
3199 (VxWorks-based) TP-LINK devices which use a smaller vendor information block)
3200 1014-1813 Image partition table (2048 bytes, padded with 0xff)
3201 1814-xxxx Firmware partitions
3203 static void * generate_factory_image(struct device_info
*info
, const struct image_partition_entry
*parts
, size_t *len
) {
3207 for (i
= 0; parts
[i
].name
; i
++)
3208 *len
+= parts
[i
].size
;
3210 uint8_t *image
= malloc(*len
);
3212 error(1, errno
, "malloc");
3214 memset(image
, 0xff, *len
);
3218 size_t vendor_len
= strlen(info
->vendor
);
3219 put32(image
+0x14, vendor_len
);
3220 memcpy(image
+0x18, info
->vendor
, vendor_len
);
3223 put_partitions(image
+ 0x1014, info
->partitions
, parts
);
3224 put_md5(image
+0x04, image
+0x14, *len
-0x14);
3230 Generates the firmware image in sysupgrade format
3232 This makes some assumptions about the provided flash and image partition tables and
3233 should be generalized when TP-LINK starts building its safeloader into hardware with
3234 different flash layouts.
3236 static void * generate_sysupgrade_image(struct device_info
*info
, const struct image_partition_entry
*image_parts
, size_t *len
) {
3238 size_t flash_first_partition_index
= 0;
3239 size_t flash_last_partition_index
= 0;
3240 const struct flash_partition_entry
*flash_first_partition
= NULL
;
3241 const struct flash_partition_entry
*flash_last_partition
= NULL
;
3242 const struct image_partition_entry
*image_last_partition
= NULL
;
3244 /** Find first and last partitions */
3245 for (i
= 0; info
->partitions
[i
].name
; i
++) {
3246 if (!strcmp(info
->partitions
[i
].name
, info
->first_sysupgrade_partition
)) {
3247 flash_first_partition
= &info
->partitions
[i
];
3248 flash_first_partition_index
= i
;
3249 } else if (!strcmp(info
->partitions
[i
].name
, info
->last_sysupgrade_partition
)) {
3250 flash_last_partition
= &info
->partitions
[i
];
3251 flash_last_partition_index
= i
;
3255 assert(flash_first_partition
&& flash_last_partition
);
3256 assert(flash_first_partition_index
< flash_last_partition_index
);
3258 /** Find last partition from image to calculate needed size */
3259 for (i
= 0; image_parts
[i
].name
; i
++) {
3260 if (!strcmp(image_parts
[i
].name
, info
->last_sysupgrade_partition
)) {
3261 image_last_partition
= &image_parts
[i
];
3266 assert(image_last_partition
);
3268 *len
= flash_last_partition
->base
- flash_first_partition
->base
+ image_last_partition
->size
;
3270 uint8_t *image
= malloc(*len
);
3272 error(1, errno
, "malloc");
3274 memset(image
, 0xff, *len
);
3276 for (i
= flash_first_partition_index
; i
<= flash_last_partition_index
; i
++) {
3277 for (j
= 0; image_parts
[j
].name
; j
++) {
3278 if (!strcmp(info
->partitions
[i
].name
, image_parts
[j
].name
)) {
3279 if (image_parts
[j
].size
> info
->partitions
[i
].size
)
3280 error(1, 0, "%s partition too big (more than %u bytes)", info
->partitions
[i
].name
, (unsigned)info
->partitions
[i
].size
);
3281 memcpy(image
+ info
->partitions
[i
].base
- flash_first_partition
->base
, image_parts
[j
].data
, image_parts
[j
].size
);
3285 assert(image_parts
[j
].name
);
3292 /** Generates an image according to a given layout and writes it to a file */
3293 static void build_image(const char *output
,
3294 const char *kernel_image
,
3295 const char *rootfs_image
,
3299 struct device_info
*info
) {
3303 struct image_partition_entry parts
[7] = {};
3305 struct flash_partition_entry
*firmware_partition
= NULL
;
3306 struct flash_partition_entry
*os_image_partition
= NULL
;
3307 struct flash_partition_entry
*file_system_partition
= NULL
;
3308 size_t firmware_partition_index
= 0;
3310 for (i
= 0; info
->partitions
[i
].name
; i
++) {
3311 if (!strcmp(info
->partitions
[i
].name
, "firmware"))
3313 firmware_partition
= &info
->partitions
[i
];
3314 firmware_partition_index
= i
;
3318 if (firmware_partition
)
3320 os_image_partition
= &info
->partitions
[firmware_partition_index
];
3321 file_system_partition
= &info
->partitions
[firmware_partition_index
+ 1];
3324 if (stat(kernel_image
, &kernel
) < 0)
3325 error(1, errno
, "unable to stat file `%s'", kernel_image
);
3327 if (kernel
.st_size
> firmware_partition
->size
)
3328 error(1, 0, "kernel overflowed firmware partition\n");
3330 for (i
= MAX_PARTITIONS
-1; i
>= firmware_partition_index
+ 1; i
--)
3331 info
->partitions
[i
+1] = info
->partitions
[i
];
3333 file_system_partition
->name
= "file-system";
3334 file_system_partition
->base
= firmware_partition
->base
+ kernel
.st_size
;
3336 /* Align partition start to erase blocks for factory images only */
3338 file_system_partition
->base
= ALIGN(firmware_partition
->base
+ kernel
.st_size
, 0x10000);
3340 file_system_partition
->size
= firmware_partition
->size
- file_system_partition
->base
;
3342 os_image_partition
->name
= "os-image";
3343 os_image_partition
->size
= kernel
.st_size
;
3346 parts
[0] = make_partition_table(info
->partitions
);
3347 parts
[1] = make_soft_version(info
, rev
);
3348 parts
[2] = make_support_list(info
);
3349 parts
[3] = read_file("os-image", kernel_image
, false, NULL
);
3350 parts
[4] = read_file("file-system", rootfs_image
, add_jffs2_eof
, file_system_partition
);
3352 /* Some devices need the extra-para partition to accept the firmware */
3353 if (strcasecmp(info
->id
, "ARCHER-A6-V3") == 0 ||
3354 strcasecmp(info
->id
, "ARCHER-A7-V5") == 0 ||
3355 strcasecmp(info
->id
, "ARCHER-A9-V6") == 0 ||
3356 strcasecmp(info
->id
, "ARCHER-C2-V3") == 0 ||
3357 strcasecmp(info
->id
, "ARCHER-C7-V4") == 0 ||
3358 strcasecmp(info
->id
, "ARCHER-C7-V5") == 0 ||
3359 strcasecmp(info
->id
, "ARCHER-C25-V1") == 0 ||
3360 strcasecmp(info
->id
, "ARCHER-C59-V2") == 0 ||
3361 strcasecmp(info
->id
, "ARCHER-C60-V2") == 0 ||
3362 strcasecmp(info
->id
, "ARCHER-C60-V3") == 0 ||
3363 strcasecmp(info
->id
, "ARCHER-C6U-V1") == 0 ||
3364 strcasecmp(info
->id
, "ARCHER-C6-V3") == 0 ||
3365 strcasecmp(info
->id
, "TLWR1043NV5") == 0) {
3366 const uint8_t extra_para
[2] = {0x01, 0x00};
3367 parts
[5] = make_extra_para(info
, extra_para
,
3368 sizeof(extra_para
));
3369 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2") == 0 ||
3370 strcasecmp(info
->id
, "TL-WA1201-V2") == 0) {
3371 const uint8_t extra_para
[2] = {0x00, 0x01};
3372 parts
[5] = make_extra_para(info
, extra_para
,
3373 sizeof(extra_para
));
3374 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2-US") == 0 ||
3375 strcasecmp(info
->id
, "EAP245-V3") == 0) {
3376 const uint8_t extra_para
[2] = {0x01, 0x01};
3377 parts
[5] = make_extra_para(info
, extra_para
,
3378 sizeof(extra_para
));
3384 image
= generate_sysupgrade_image(info
, parts
, &len
);
3386 image
= generate_factory_image(info
, parts
, &len
);
3388 FILE *file
= fopen(output
, "wb");
3390 error(1, errno
, "unable to open output file");
3392 if (fwrite(image
, len
, 1, file
) != 1)
3393 error(1, 0, "unable to write output file");
3399 for (i
= 0; parts
[i
].name
; i
++)
3400 free_image_partition(parts
[i
]);
3404 static void usage(const char *argv0
) {
3406 "Usage: %s [OPTIONS...]\n"
3409 " -h show this help\n"
3411 "Info about an image:\n"
3412 " -i <file> input file to read from\n"
3413 "Create a new image:\n"
3414 " -B <board> create image for the board specified with <board>\n"
3415 " -k <file> read kernel image from the file <file>\n"
3416 " -r <file> read rootfs image from the file <file>\n"
3417 " -o <file> write output to the file <file>\n"
3418 " -V <rev> sets the revision number to <rev>\n"
3419 " -j add jffs2 end-of-filesystem markers\n"
3420 " -S create sysupgrade instead of factory image\n"
3421 "Extract an old image:\n"
3422 " -x <file> extract all oem firmware partition\n"
3423 " -d <dir> destination to extract the firmware partition\n"
3424 " -z <file> convert an oem firmware into a sysupgade file. Use -o for output file\n",
3430 static struct device_info
*find_board(const char *id
)
3432 struct device_info
*board
= NULL
;
3434 for (board
= boards
; board
->id
!= NULL
; board
++)
3435 if (strcasecmp(id
, board
->id
) == 0)
3441 static int add_flash_partition(
3442 struct flash_partition_entry
*part_list
,
3449 /* check if the list has a free entry */
3450 for (ptr
= 0; ptr
< max_entries
; ptr
++, part_list
++) {
3451 if (part_list
->name
== NULL
&&
3452 part_list
->base
== 0 &&
3453 part_list
->size
== 0)
3457 if (ptr
== max_entries
) {
3458 error(1, 0, "No free flash part entry available.");
3461 part_list
->name
= calloc(1, strlen(name
) + 1);
3462 if (!part_list
->name
) {
3463 error(1, 0, "Unable to allocate memory");
3466 memcpy((char *)part_list
->name
, name
, strlen(name
));
3467 part_list
->base
= base
;
3468 part_list
->size
= size
;
3473 /** read the partition table into struct flash_partition_entry */
3474 static int read_partition_table(
3475 FILE *file
, long offset
,
3476 struct flash_partition_entry
*entries
, size_t max_entries
,
3481 const char *parthdr
= NULL
;
3482 const char *fwuphdr
= "fwup-ptn";
3483 const char *flashhdr
= "partition";
3485 /* TODO: search for the partition table */
3495 error(1, 0, "Invalid partition table");
3498 if (fseek(file
, offset
, SEEK_SET
) < 0)
3499 error(1, errno
, "Can not seek in the firmware");
3501 if (fread(buf
, 2048, 1, file
) != 1)
3502 error(1, errno
, "Can not read fwup-ptn from the firmware");
3506 /* look for the partition header */
3507 if (memcmp(buf
, parthdr
, strlen(parthdr
)) != 0) {
3508 fprintf(stderr
, "DEBUG: can not find fwuphdr\n");
3513 end
= buf
+ sizeof(buf
);
3514 while ((ptr
+ strlen(parthdr
)) < end
&&
3515 memcmp(ptr
, parthdr
, strlen(parthdr
)) == 0) {
3519 char name
[32] = { 0 };
3521 unsigned long base
= 0;
3522 unsigned long size
= 0;
3524 end_part
= memchr(ptr
, '\n', (end
- ptr
));
3525 if (end_part
== NULL
) {
3526 /* in theory this should never happen, because a partition always ends with 0x09, 0x0D, 0x0A */
3530 for (int i
= 0; i
<= 4; i
++) {
3531 if (end_part
<= ptr
)
3534 end_element
= memchr(ptr
, 0x20, (end_part
- ptr
));
3535 if (end_element
== NULL
) {
3536 error(1, errno
, "Ignoring the rest of the partition entries.");
3541 /* partition header */
3543 ptr
= end_element
+ 1;
3547 name_len
= (end_element
- ptr
) > 31 ? 31 : (end_element
- ptr
);
3548 strncpy(name
, ptr
, name_len
);
3549 name
[name_len
] = '\0';
3550 ptr
= end_element
+ 1;
3555 ptr
= end_element
+ 1;
3560 base
= strtoul(ptr
, NULL
, 16);
3561 ptr
= end_element
+ 1;
3566 ptr
= end_element
+ 1;
3567 /* actual size. The last element doesn't have a sepeartor */
3568 size
= strtoul(ptr
, NULL
, 16);
3569 /* the part ends with 0x09, 0x0d, 0x0a */
3571 add_flash_partition(entries
, max_entries
, name
, base
, size
);
3580 static void write_partition(
3582 size_t firmware_offset
,
3583 struct flash_partition_entry
*entry
,
3589 fseek(input_file
, entry
->base
+ firmware_offset
, SEEK_SET
);
3591 for (offset
= 0; sizeof(buf
) + offset
<= entry
->size
; offset
+= sizeof(buf
)) {
3592 if (fread(buf
, sizeof(buf
), 1, input_file
) != 1)
3593 error(1, errno
, "Can not read partition from input_file");
3595 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3596 error(1, errno
, "Can not write partition to output_file");
3598 /* write last chunk smaller than buffer */
3599 if (offset
< entry
->size
) {
3600 offset
= entry
->size
- offset
;
3601 if (fread(buf
, offset
, 1, input_file
) != 1)
3602 error(1, errno
, "Can not read partition from input_file");
3603 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3604 error(1, errno
, "Can not write partition to output_file");
3608 static int extract_firmware_partition(FILE *input_file
, size_t firmware_offset
, struct flash_partition_entry
*entry
, const char *output_directory
)
3611 char output
[PATH_MAX
];
3613 snprintf(output
, PATH_MAX
, "%s/%s", output_directory
, entry
->name
);
3614 output_file
= fopen(output
, "wb+");
3615 if (output_file
== NULL
) {
3616 error(1, errno
, "Can not open output file %s", output
);
3619 write_partition(input_file
, firmware_offset
, entry
, output_file
);
3621 fclose(output_file
);
3626 /** extract all partitions from the firmware file */
3627 static int extract_firmware(const char *input
, const char *output_directory
)
3629 struct flash_partition_entry entries
[16] = { 0 };
3630 size_t max_entries
= 16;
3631 size_t firmware_offset
= 0x1014;
3634 struct stat statbuf
;
3636 /* check input file */
3637 if (stat(input
, &statbuf
)) {
3638 error(1, errno
, "Can not read input firmware %s", input
);
3641 /* check if output directory exists */
3642 if (stat(output_directory
, &statbuf
)) {
3643 error(1, errno
, "Failed to stat output directory %s", output_directory
);
3646 if ((statbuf
.st_mode
& S_IFMT
) != S_IFDIR
) {
3647 error(1, errno
, "Given output directory is not a directory %s", output_directory
);
3650 input_file
= fopen(input
, "rb");
3652 if (read_partition_table(input_file
, firmware_offset
, entries
, 16, 0) != 0) {
3653 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3656 for (size_t i
= 0; i
< max_entries
; i
++) {
3657 if (entries
[i
].name
== NULL
&&
3658 entries
[i
].base
== 0 &&
3659 entries
[i
].size
== 0)
3662 extract_firmware_partition(input_file
, firmware_offset
, &entries
[i
], output_directory
);
3668 static struct flash_partition_entry
*find_partition(
3669 struct flash_partition_entry
*entries
, size_t max_entries
,
3670 const char *name
, const char *error_msg
)
3672 for (size_t i
= 0; i
< max_entries
; i
++, entries
++) {
3673 if (strcmp(entries
->name
, name
) == 0)
3678 error(1, 0, "%s", error_msg
);
3684 static int firmware_info(const char *input
)
3686 struct flash_partition_entry pointers
[MAX_PARTITIONS
] = { };
3687 struct flash_partition_entry
*e
;
3691 fp
= fopen(input
, "r");
3693 if (read_partition_table(fp
, 0x1014, pointers
, MAX_PARTITIONS
, 0)) {
3694 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3697 printf("Firmware image partitions:\n");
3698 printf("%-8s %-8s %s\n", "base", "size", "name");
3699 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3702 if (!e
->name
&& !e
->base
&& !e
->size
)
3705 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3708 e
= find_partition(pointers
, MAX_PARTITIONS
, "soft-version", NULL
);
3710 size_t data_len
= e
->size
- sizeof(struct meta_header
);
3711 char *buf
= malloc(data_len
);
3712 struct soft_version
*s
;
3717 error(1, errno
, "Failed to alloc buffer");
3719 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3720 error(1, errno
, "Can not seek in the firmware");
3722 if (fread(buf
, data_len
, 1, fp
) != 1)
3723 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3725 /* Check for string ignoring padding character */
3727 for (i
= 0; i
< data_len
- 1; i
++) {
3728 if (!isascii(buf
[i
])) {
3734 printf("\n[Software version]\n");
3736 fwrite(buf
, data_len
, 1, stdout
);
3738 } else if (data_len
>= offsetof(struct soft_version
, rev
)) {
3739 s
= (struct soft_version
*)buf
;
3741 printf("Version: %d.%d.%d\n", s
->version_major
, s
->version_minor
, s
->version_patch
);
3742 printf("Date: %02x%02x-%02x-%02x\n", s
->year_hi
, s
->year_lo
, s
->month
, s
->day
);
3743 printf("Revision: %d\n", ntohl(s
->rev
));
3745 printf("Failed to parse data\n");
3751 e
= find_partition(pointers
, MAX_PARTITIONS
, "support-list", NULL
);
3757 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3758 error(1, errno
, "Can not seek in the firmware");
3760 printf("\n[Support list]\n");
3761 for (length
= e
->size
- sizeof(struct meta_header
); length
; length
-= bytes
) {
3762 bytes
= fread(buf
, 1, length
> sizeof(buf
) ? sizeof(buf
) : length
, fp
);
3764 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3770 e
= find_partition(pointers
, MAX_PARTITIONS
, "partition-table", NULL
);
3772 struct flash_partition_entry parts
[MAX_PARTITIONS
] = { };
3774 if (read_partition_table(fp
, 0x1014 + e
->base
+ 4, parts
, MAX_PARTITIONS
, 1)) {
3775 error(1, 0, "Error can not read the partition table (partition)");
3778 printf("\n[Partition table]\n");
3779 printf("%-8s %-8s %s\n", "base", "size", "name");
3780 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3783 if (!e
->name
&& !e
->base
&& !e
->size
)
3786 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3795 static void write_ff(FILE *output_file
, size_t size
)
3800 memset(buf
, 0xff, sizeof(buf
));
3802 for (offset
= 0; offset
+ sizeof(buf
) < size
; offset
+= sizeof(buf
)) {
3803 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3804 error(1, errno
, "Can not write 0xff to output_file");
3807 /* write last chunk smaller than buffer */
3808 if (offset
< size
) {
3809 offset
= size
- offset
;
3810 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3811 error(1, errno
, "Can not write partition to output_file");
3815 static void convert_firmware(const char *input
, const char *output
)
3817 struct flash_partition_entry fwup
[MAX_PARTITIONS
] = { 0 };
3818 struct flash_partition_entry flash
[MAX_PARTITIONS
] = { 0 };
3819 struct flash_partition_entry
*fwup_os_image
= NULL
, *fwup_file_system
= NULL
;
3820 struct flash_partition_entry
*flash_os_image
= NULL
, *flash_file_system
= NULL
;
3821 struct flash_partition_entry
*fwup_partition_table
= NULL
;
3822 size_t firmware_offset
= 0x1014;
3823 FILE *input_file
, *output_file
;
3825 struct stat statbuf
;
3827 /* check input file */
3828 if (stat(input
, &statbuf
)) {
3829 error(1, errno
, "Can not read input firmware %s", input
);
3832 input_file
= fopen(input
, "rb");
3834 error(1, 0, "Can not open input firmware %s", input
);
3836 output_file
= fopen(output
, "wb");
3838 error(1, 0, "Can not open output firmware %s", output
);
3840 if (read_partition_table(input_file
, firmware_offset
, fwup
, MAX_PARTITIONS
, 0) != 0) {
3841 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3844 fwup_os_image
= find_partition(fwup
, MAX_PARTITIONS
,
3845 "os-image", "Error can not find os-image partition (fwup)");
3846 fwup_file_system
= find_partition(fwup
, MAX_PARTITIONS
,
3847 "file-system", "Error can not find file-system partition (fwup)");
3848 fwup_partition_table
= find_partition(fwup
, MAX_PARTITIONS
,
3849 "partition-table", "Error can not find partition-table partition");
3851 /* the flash partition table has a 0x00000004 magic haeder */
3852 if (read_partition_table(input_file
, firmware_offset
+ fwup_partition_table
->base
+ 4, flash
, MAX_PARTITIONS
, 1) != 0)
3853 error(1, 0, "Error can not read the partition table (flash)");
3855 flash_os_image
= find_partition(flash
, MAX_PARTITIONS
,
3856 "os-image", "Error can not find os-image partition (flash)");
3857 flash_file_system
= find_partition(flash
, MAX_PARTITIONS
,
3858 "file-system", "Error can not find file-system partition (flash)");
3860 /* write os_image to 0x0 */
3861 write_partition(input_file
, firmware_offset
, fwup_os_image
, output_file
);
3862 write_ff(output_file
, flash_os_image
->size
- fwup_os_image
->size
);
3864 /* write file-system behind os_image */
3865 fseek(output_file
, flash_file_system
->base
- flash_os_image
->base
, SEEK_SET
);
3866 write_partition(input_file
, firmware_offset
, fwup_file_system
, output_file
);
3867 write_ff(output_file
, flash_file_system
->size
- fwup_file_system
->size
);
3869 fclose(output_file
);
3873 int main(int argc
, char *argv
[]) {
3874 const char *info_image
= NULL
, *board
= NULL
, *kernel_image
= NULL
, *rootfs_image
= NULL
, *output
= NULL
;
3875 const char *extract_image
= NULL
, *output_directory
= NULL
, *convert_image
= NULL
;
3876 bool add_jffs2_eof
= false, sysupgrade
= false;
3878 struct device_info
*info
;
3879 set_source_date_epoch();
3884 c
= getopt(argc
, argv
, "i:B:k:r:o:V:jSh:x:d:z:");
3890 info_image
= optarg
;
3898 kernel_image
= optarg
;
3902 rootfs_image
= optarg
;
3910 sscanf(optarg
, "r%u", &rev
);
3914 add_jffs2_eof
= true;
3926 output_directory
= optarg
;
3930 extract_image
= optarg
;
3934 convert_image
= optarg
;
3944 firmware_info(info_image
);
3945 } else if (extract_image
|| output_directory
) {
3947 error(1, 0, "No factory/oem image given via -x <file>. Output directory is only valid with -x");
3948 if (!output_directory
)
3949 error(1, 0, "Can not extract an image without output directory. Use -d <dir>");
3950 extract_firmware(extract_image
, output_directory
);
3951 } else if (convert_image
) {
3953 error(1, 0, "Can not convert a factory/oem image into sysupgrade image without output file. Use -o <file>");
3954 convert_firmware(convert_image
, output
);
3957 error(1, 0, "no board has been specified");
3959 error(1, 0, "no kernel image has been specified");
3961 error(1, 0, "no rootfs image has been specified");
3963 error(1, 0, "no output filename has been specified");
3965 info
= find_board(board
);
3968 error(1, 0, "unsupported board %s", board
);
3970 build_image(output
, kernel_image
, rootfs_image
, rev
, add_jffs2_eof
, sysupgrade
, info
);