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 /** Firmware layout description */
70 const char *support_list
;
71 enum partition_trail_value part_trail
;
73 uint32_t soft_ver_compat_level
;
74 struct flash_partition_entry partitions
[MAX_PARTITIONS
+1];
75 const char *first_sysupgrade_partition
;
76 const char *last_sysupgrade_partition
;
79 struct __attribute__((__packed__
)) meta_header
{
84 /** The content of the soft-version structure */
85 struct __attribute__((__packed__
)) soft_version
{
87 uint8_t version_major
;
88 uint8_t version_minor
;
89 uint8_t version_patch
;
95 uint32_t compat_level
;
99 static const uint8_t jffs2_eof_mark
[4] = {0xde, 0xad, 0xc0, 0xde};
103 Salt for the MD5 hash
105 Fortunately, TP-LINK seems to use the same salt for most devices which use
106 the new image format.
108 static const uint8_t md5_salt
[16] = {
109 0x7a, 0x2b, 0x15, 0xed,
110 0x9b, 0x98, 0x59, 0x6d,
111 0xe5, 0x04, 0xab, 0x44,
112 0xac, 0x2a, 0x9f, 0x4e,
116 /** Firmware layout table */
117 static struct device_info boards
[] = {
118 /** Firmware layout for the CPE210/220 V1 */
121 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
124 "CPE210(TP-LINK|UN|N300-2):1.0\r\n"
125 "CPE210(TP-LINK|UN|N300-2):1.1\r\n"
126 "CPE210(TP-LINK|US|N300-2):1.1\r\n"
127 "CPE210(TP-LINK|EU|N300-2):1.1\r\n"
128 "CPE220(TP-LINK|UN|N300-2):1.1\r\n"
129 "CPE220(TP-LINK|US|N300-2):1.1\r\n"
130 "CPE220(TP-LINK|EU|N300-2):1.1\r\n",
135 {"fs-uboot", 0x00000, 0x20000},
136 {"partition-table", 0x20000, 0x02000},
137 {"default-mac", 0x30000, 0x00020},
138 {"product-info", 0x31100, 0x00100},
139 {"signature", 0x32000, 0x00400},
140 {"firmware", 0x40000, 0x770000},
141 {"soft-version", 0x7b0000, 0x00100},
142 {"support-list", 0x7b1000, 0x00400},
143 {"user-config", 0x7c0000, 0x10000},
144 {"default-config", 0x7d0000, 0x10000},
145 {"log", 0x7e0000, 0x10000},
146 {"radio", 0x7f0000, 0x10000},
150 .first_sysupgrade_partition
= "os-image",
151 .last_sysupgrade_partition
= "support-list",
154 /** Firmware layout for the CPE210 V2 */
157 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n",
160 "CPE210(TP-LINK|EU|N300-2|00000000):2.0\r\n"
161 "CPE210(TP-LINK|EU|N300-2|45550000):2.0\r\n"
162 "CPE210(TP-LINK|EU|N300-2|55530000):2.0\r\n"
163 "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
164 "CPE210(TP-LINK|UN|N300-2|45550000):2.0\r\n"
165 "CPE210(TP-LINK|UN|N300-2|55530000):2.0\r\n"
166 "CPE210(TP-LINK|US|N300-2|55530000):2.0\r\n"
167 "CPE210(TP-LINK|UN|N300-2):2.0\r\n"
168 "CPE210(TP-LINK|EU|N300-2):2.0\r\n"
169 "CPE210(TP-LINK|US|N300-2):2.0\r\n",
174 {"fs-uboot", 0x00000, 0x20000},
175 {"partition-table", 0x20000, 0x02000},
176 {"default-mac", 0x30000, 0x00020},
177 {"product-info", 0x31100, 0x00100},
178 {"device-info", 0x31400, 0x00400},
179 {"signature", 0x32000, 0x00400},
180 {"device-id", 0x33000, 0x00100},
181 {"firmware", 0x40000, 0x770000},
182 {"soft-version", 0x7b0000, 0x00100},
183 {"support-list", 0x7b1000, 0x01000},
184 {"user-config", 0x7c0000, 0x10000},
185 {"default-config", 0x7d0000, 0x10000},
186 {"log", 0x7e0000, 0x10000},
187 {"radio", 0x7f0000, 0x10000},
191 .first_sysupgrade_partition
= "os-image",
192 .last_sysupgrade_partition
= "support-list",
195 /** Firmware layout for the CPE210 V3 */
198 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n",
201 "CPE210(TP-LINK|EU|N300-2|45550000):3.0\r\n"
202 "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n"
203 "CPE210(TP-LINK|US|N300-2|55530000):3.0\r\n"
204 "CPE210(TP-LINK|UN|N300-2):3.0\r\n"
205 "CPE210(TP-LINK|EU|N300-2):3.0\r\n"
206 "CPE210(TP-LINK|EU|N300-2|45550000):3.1\r\n"
207 "CPE210(TP-LINK|UN|N300-2|00000000):3.1\r\n"
208 "CPE210(TP-LINK|US|N300-2|55530000):3.1\r\n"
209 "CPE210(TP-LINK|EU|N300-2|45550000):3.20\r\n"
210 "CPE210(TP-LINK|UN|N300-2|00000000):3.20\r\n"
211 "CPE210(TP-LINK|US|N300-2|55530000):3.20\r\n",
216 {"fs-uboot", 0x00000, 0x20000},
217 {"partition-table", 0x20000, 0x01000},
218 {"default-mac", 0x30000, 0x00020},
219 {"product-info", 0x31100, 0x00100},
220 {"device-info", 0x31400, 0x00400},
221 {"signature", 0x32000, 0x00400},
222 {"device-id", 0x33000, 0x00100},
223 {"firmware", 0x40000, 0x770000},
224 {"soft-version", 0x7b0000, 0x00100},
225 {"support-list", 0x7b1000, 0x01000},
226 {"user-config", 0x7c0000, 0x10000},
227 {"default-config", 0x7d0000, 0x10000},
228 {"log", 0x7e0000, 0x10000},
229 {"radio", 0x7f0000, 0x10000},
233 .first_sysupgrade_partition
= "os-image",
234 .last_sysupgrade_partition
= "support-list",
237 /** Firmware layout for the CPE220 V2 */
240 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
243 "CPE220(TP-LINK|EU|N300-2|00000000):2.0\r\n"
244 "CPE220(TP-LINK|EU|N300-2|45550000):2.0\r\n"
245 "CPE220(TP-LINK|EU|N300-2|55530000):2.0\r\n"
246 "CPE220(TP-LINK|UN|N300-2|00000000):2.0\r\n"
247 "CPE220(TP-LINK|UN|N300-2|45550000):2.0\r\n"
248 "CPE220(TP-LINK|UN|N300-2|55530000):2.0\r\n"
249 "CPE220(TP-LINK|US|N300-2|55530000):2.0\r\n"
250 "CPE220(TP-LINK|UN|N300-2):2.0\r\n"
251 "CPE220(TP-LINK|EU|N300-2):2.0\r\n"
252 "CPE220(TP-LINK|US|N300-2):2.0\r\n",
257 {"fs-uboot", 0x00000, 0x20000},
258 {"partition-table", 0x20000, 0x02000},
259 {"default-mac", 0x30000, 0x00020},
260 {"product-info", 0x31100, 0x00100},
261 {"signature", 0x32000, 0x00400},
262 {"firmware", 0x40000, 0x770000},
263 {"soft-version", 0x7b0000, 0x00100},
264 {"support-list", 0x7b1000, 0x00400},
265 {"user-config", 0x7c0000, 0x10000},
266 {"default-config", 0x7d0000, 0x10000},
267 {"log", 0x7e0000, 0x10000},
268 {"radio", 0x7f0000, 0x10000},
272 .first_sysupgrade_partition
= "os-image",
273 .last_sysupgrade_partition
= "support-list",
276 /** Firmware layout for the CPE220 V3 */
279 .vendor
= "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n",
282 "CPE220(TP-LINK|EU|N300-2|00000000):3.0\r\n"
283 "CPE220(TP-LINK|EU|N300-2|45550000):3.0\r\n"
284 "CPE220(TP-LINK|EU|N300-2|55530000):3.0\r\n"
285 "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n"
286 "CPE220(TP-LINK|UN|N300-2|45550000):3.0\r\n"
287 "CPE220(TP-LINK|UN|N300-2|55530000):3.0\r\n"
288 "CPE220(TP-LINK|US|N300-2|55530000):3.0\r\n"
289 "CPE220(TP-LINK|UN|N300-2):3.0\r\n"
290 "CPE220(TP-LINK|EU|N300-2):3.0\r\n"
291 "CPE220(TP-LINK|US|N300-2):3.0\r\n",
296 {"fs-uboot", 0x00000, 0x20000},
297 {"partition-table", 0x20000, 0x02000},
298 {"default-mac", 0x30000, 0x00020},
299 {"product-info", 0x31100, 0x00100},
300 {"device-info", 0x31400, 0x00400},
301 {"signature", 0x32000, 0x00400},
302 {"device-id", 0x33000, 0x00100},
303 {"firmware", 0x40000, 0x770000},
304 {"soft-version", 0x7b0000, 0x00100},
305 {"support-list", 0x7b1000, 0x01000},
306 {"user-config", 0x7c0000, 0x10000},
307 {"default-config", 0x7d0000, 0x10000},
308 {"log", 0x7e0000, 0x10000},
309 {"radio", 0x7f0000, 0x10000},
313 .first_sysupgrade_partition
= "os-image",
314 .last_sysupgrade_partition
= "support-list",
317 /** Firmware layout for the CPE510/520 V1 */
320 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
323 "CPE510(TP-LINK|UN|N300-5):1.0\r\n"
324 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
325 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
326 "CPE510(TP-LINK|US|N300-5):1.1\r\n"
327 "CPE510(TP-LINK|EU|N300-5):1.1\r\n"
328 "CPE520(TP-LINK|UN|N300-5):1.1\r\n"
329 "CPE520(TP-LINK|US|N300-5):1.1\r\n"
330 "CPE520(TP-LINK|EU|N300-5):1.1\r\n",
335 {"fs-uboot", 0x00000, 0x20000},
336 {"partition-table", 0x20000, 0x02000},
337 {"default-mac", 0x30000, 0x00020},
338 {"product-info", 0x31100, 0x00100},
339 {"signature", 0x32000, 0x00400},
340 {"firmware", 0x40000, 0x770000},
341 {"soft-version", 0x7b0000, 0x00100},
342 {"support-list", 0x7b1000, 0x00400},
343 {"user-config", 0x7c0000, 0x10000},
344 {"default-config", 0x7d0000, 0x10000},
345 {"log", 0x7e0000, 0x10000},
346 {"radio", 0x7f0000, 0x10000},
350 .first_sysupgrade_partition
= "os-image",
351 .last_sysupgrade_partition
= "support-list",
354 /** Firmware layout for the CPE510 V2 */
357 .vendor
= "CPE510(TP-LINK|UN|N300-5):2.0\r\n",
360 "CPE510(TP-LINK|EU|N300-5|00000000):2.0\r\n"
361 "CPE510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
362 "CPE510(TP-LINK|EU|N300-5|55530000):2.0\r\n"
363 "CPE510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
364 "CPE510(TP-LINK|UN|N300-5|45550000):2.0\r\n"
365 "CPE510(TP-LINK|UN|N300-5|55530000):2.0\r\n"
366 "CPE510(TP-LINK|US|N300-5|00000000):2.0\r\n"
367 "CPE510(TP-LINK|US|N300-5|45550000):2.0\r\n"
368 "CPE510(TP-LINK|US|N300-5|55530000):2.0\r\n"
369 "CPE510(TP-LINK|UN|N300-5):2.0\r\n"
370 "CPE510(TP-LINK|EU|N300-5):2.0\r\n"
371 "CPE510(TP-LINK|US|N300-5):2.0\r\n",
376 {"fs-uboot", 0x00000, 0x20000},
377 {"partition-table", 0x20000, 0x02000},
378 {"default-mac", 0x30000, 0x00020},
379 {"product-info", 0x31100, 0x00100},
380 {"signature", 0x32000, 0x00400},
381 {"firmware", 0x40000, 0x770000},
382 {"soft-version", 0x7b0000, 0x00100},
383 {"support-list", 0x7b1000, 0x00400},
384 {"user-config", 0x7c0000, 0x10000},
385 {"default-config", 0x7d0000, 0x10000},
386 {"log", 0x7e0000, 0x10000},
387 {"radio", 0x7f0000, 0x10000},
391 .first_sysupgrade_partition
= "os-image",
392 .last_sysupgrade_partition
= "support-list",
395 /** Firmware layout for the CPE510 V3 */
398 .vendor
= "CPE510(TP-LINK|UN|N300-5):3.0\r\n",
401 "CPE510(TP-LINK|EU|N300-5|00000000):3.0\r\n"
402 "CPE510(TP-LINK|EU|N300-5|45550000):3.0\r\n"
403 "CPE510(TP-LINK|EU|N300-5|55530000):3.0\r\n"
404 "CPE510(TP-LINK|UN|N300-5|00000000):3.0\r\n"
405 "CPE510(TP-LINK|UN|N300-5|45550000):3.0\r\n"
406 "CPE510(TP-LINK|UN|N300-5|55530000):3.0\r\n"
407 "CPE510(TP-LINK|US|N300-5|00000000):3.0\r\n"
408 "CPE510(TP-LINK|US|N300-5|45550000):3.0\r\n"
409 "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n"
410 "CPE510(TP-LINK|UN|N300-5):3.0\r\n"
411 "CPE510(TP-LINK|EU|N300-5):3.0\r\n"
412 "CPE510(TP-LINK|US|N300-5):3.0\r\n"
413 "CPE510(TP-LINK|UN|N300-5|00000000):3.20\r\n"
414 "CPE510(TP-LINK|US|N300-5|55530000):3.20\r\n"
415 "CPE510(TP-LINK|EU|N300-5|45550000):3.20\r\n",
420 {"fs-uboot", 0x00000, 0x20000},
421 {"partition-table", 0x20000, 0x02000},
422 {"default-mac", 0x30000, 0x00020},
423 {"product-info", 0x31100, 0x00100},
424 {"signature", 0x32000, 0x00400},
425 {"firmware", 0x40000, 0x770000},
426 {"soft-version", 0x7b0000, 0x00100},
427 {"support-list", 0x7b1000, 0x00400},
428 {"user-config", 0x7c0000, 0x10000},
429 {"default-config", 0x7d0000, 0x10000},
430 {"log", 0x7e0000, 0x10000},
431 {"radio", 0x7f0000, 0x10000},
435 .first_sysupgrade_partition
= "os-image",
436 .last_sysupgrade_partition
= "support-list",
439 /** Firmware layout for the CPE610V1 */
442 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n",
445 "CPE610(TP-LINK|EU|N300-5|00000000):1.0\r\n"
446 "CPE610(TP-LINK|EU|N300-5|45550000):1.0\r\n"
447 "CPE610(TP-LINK|EU|N300-5|55530000):1.0\r\n"
448 "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n"
449 "CPE610(TP-LINK|UN|N300-5|45550000):1.0\r\n"
450 "CPE610(TP-LINK|UN|N300-5|55530000):1.0\r\n"
451 "CPE610(TP-LINK|US|N300-5|55530000):1.0\r\n"
452 "CPE610(TP-LINK|UN|N300-5):1.0\r\n"
453 "CPE610(TP-LINK|EU|N300-5):1.0\r\n"
454 "CPE610(TP-LINK|US|N300-5):1.0\r\n",
459 {"fs-uboot", 0x00000, 0x20000},
460 {"partition-table", 0x20000, 0x02000},
461 {"default-mac", 0x30000, 0x00020},
462 {"product-info", 0x31100, 0x00100},
463 {"signature", 0x32000, 0x00400},
464 {"firmware", 0x40000, 0x770000},
465 {"soft-version", 0x7b0000, 0x00100},
466 {"support-list", 0x7b1000, 0x00400},
467 {"user-config", 0x7c0000, 0x10000},
468 {"default-config", 0x7d0000, 0x10000},
469 {"log", 0x7e0000, 0x10000},
470 {"radio", 0x7f0000, 0x10000},
474 .first_sysupgrade_partition
= "os-image",
475 .last_sysupgrade_partition
= "support-list",
478 /** Firmware layout for the CPE610V2 */
481 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n",
484 "CPE610(TP-LINK|EU|N300-5|00000000):2.0\r\n"
485 "CPE610(TP-LINK|EU|N300-5|45550000):2.0\r\n"
486 "CPE610(TP-LINK|EU|N300-5|55530000):2.0\r\n"
487 "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n"
488 "CPE610(TP-LINK|UN|N300-5|45550000):2.0\r\n"
489 "CPE610(TP-LINK|UN|N300-5|55530000):2.0\r\n"
490 "CPE610(TP-LINK|US|N300-5|55530000):2.0\r\n"
491 "CPE610(TP-LINK|UN|N300-5):2.0\r\n"
492 "CPE610(TP-LINK|EU|N300-5):2.0\r\n"
493 "CPE610(TP-LINK|US|N300-5):2.0\r\n",
498 {"fs-uboot", 0x00000, 0x20000},
499 {"partition-table", 0x20000, 0x02000},
500 {"default-mac", 0x30000, 0x00020},
501 {"product-info", 0x31100, 0x00100},
502 {"signature", 0x32000, 0x00400},
503 {"firmware", 0x40000, 0x770000},
504 {"soft-version", 0x7b0000, 0x00100},
505 {"support-list", 0x7b1000, 0x00400},
506 {"user-config", 0x7c0000, 0x10000},
507 {"default-config", 0x7d0000, 0x10000},
508 {"log", 0x7e0000, 0x10000},
509 {"radio", 0x7f0000, 0x10000},
513 .first_sysupgrade_partition
= "os-image",
514 .last_sysupgrade_partition
= "support-list",
519 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
522 "WBS210(TP-LINK|UN|N300-2):1.20\r\n"
523 "WBS210(TP-LINK|US|N300-2):1.20\r\n"
524 "WBS210(TP-LINK|EU|N300-2):1.20\r\n",
529 {"fs-uboot", 0x00000, 0x20000},
530 {"partition-table", 0x20000, 0x02000},
531 {"default-mac", 0x30000, 0x00020},
532 {"product-info", 0x31100, 0x00100},
533 {"signature", 0x32000, 0x00400},
534 {"firmware", 0x40000, 0x770000},
535 {"soft-version", 0x7b0000, 0x00100},
536 {"support-list", 0x7b1000, 0x00400},
537 {"user-config", 0x7c0000, 0x10000},
538 {"default-config", 0x7d0000, 0x10000},
539 {"log", 0x7e0000, 0x10000},
540 {"radio", 0x7f0000, 0x10000},
544 .first_sysupgrade_partition
= "os-image",
545 .last_sysupgrade_partition
= "support-list",
550 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
553 "WBS210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
554 "WBS210(TP-LINK|US|N300-2|55530000):2.0\r\n"
555 "WBS210(TP-LINK|EU|N300-2|45550000):2.0\r\n",
560 {"fs-uboot", 0x00000, 0x20000},
561 {"partition-table", 0x20000, 0x02000},
562 {"default-mac", 0x30000, 0x00020},
563 {"product-info", 0x31100, 0x00100},
564 {"signature", 0x32000, 0x00400},
565 {"firmware", 0x40000, 0x770000},
566 {"soft-version", 0x7b0000, 0x00100},
567 {"support-list", 0x7b1000, 0x00400},
568 {"user-config", 0x7c0000, 0x10000},
569 {"default-config", 0x7d0000, 0x10000},
570 {"log", 0x7e0000, 0x10000},
571 {"radio", 0x7f0000, 0x10000},
575 .first_sysupgrade_partition
= "os-image",
576 .last_sysupgrade_partition
= "support-list",
581 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
584 "WBS510(TP-LINK|UN|N300-5):1.20\r\n"
585 "WBS510(TP-LINK|US|N300-5):1.20\r\n"
586 "WBS510(TP-LINK|EU|N300-5):1.20\r\n"
587 "WBS510(TP-LINK|CA|N300-5):1.20\r\n",
592 {"fs-uboot", 0x00000, 0x20000},
593 {"partition-table", 0x20000, 0x02000},
594 {"default-mac", 0x30000, 0x00020},
595 {"product-info", 0x31100, 0x00100},
596 {"signature", 0x32000, 0x00400},
597 {"firmware", 0x40000, 0x770000},
598 {"soft-version", 0x7b0000, 0x00100},
599 {"support-list", 0x7b1000, 0x00400},
600 {"user-config", 0x7c0000, 0x10000},
601 {"default-config", 0x7d0000, 0x10000},
602 {"log", 0x7e0000, 0x10000},
603 {"radio", 0x7f0000, 0x10000},
607 .first_sysupgrade_partition
= "os-image",
608 .last_sysupgrade_partition
= "support-list",
613 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
616 "WBS510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
617 "WBS510(TP-LINK|US|N300-5|55530000):2.0\r\n"
618 "WBS510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
619 "WBS510(TP-LINK|CA|N300-5|43410000):2.0\r\n",
624 {"fs-uboot", 0x00000, 0x20000},
625 {"partition-table", 0x20000, 0x02000},
626 {"default-mac", 0x30000, 0x00020},
627 {"product-info", 0x31100, 0x00100},
628 {"signature", 0x32000, 0x00400},
629 {"firmware", 0x40000, 0x770000},
630 {"soft-version", 0x7b0000, 0x00100},
631 {"support-list", 0x7b1000, 0x00400},
632 {"user-config", 0x7c0000, 0x10000},
633 {"default-config", 0x7d0000, 0x10000},
634 {"log", 0x7e0000, 0x10000},
635 {"radio", 0x7f0000, 0x10000},
639 .first_sysupgrade_partition
= "os-image",
640 .last_sysupgrade_partition
= "support-list",
643 /** Firmware layout for the AD7200 */
649 "{product_name:AD7200,product_ver:1.0.0,special_id:00000000}\r\n",
654 {"SBL1", 0x00000, 0x20000},
655 {"MIBIB", 0x20000, 0x20000},
656 {"SBL2", 0x40000, 0x20000},
657 {"SBL3", 0x60000, 0x30000},
658 {"DDRCONFIG", 0x90000, 0x10000},
659 {"SSD", 0xa0000, 0x10000},
660 {"TZ", 0xb0000, 0x30000},
661 {"RPM", 0xe0000, 0x20000},
662 {"fs-uboot", 0x100000, 0x70000},
663 {"uboot-env", 0x170000, 0x40000},
664 {"radio", 0x1b0000, 0x40000},
665 {"os-image", 0x1f0000, 0x400000},
666 {"file-system", 0x5f0000, 0x1900000},
667 {"default-mac", 0x1ef0000, 0x00200},
668 {"pin", 0x1ef0200, 0x00200},
669 {"device-id", 0x1ef0400, 0x00200},
670 {"product-info", 0x1ef0600, 0x0fa00},
671 {"partition-table", 0x1f00000, 0x10000},
672 {"soft-version", 0x1f10000, 0x10000},
673 {"support-list", 0x1f20000, 0x10000},
674 {"profile", 0x1f30000, 0x10000},
675 {"default-config", 0x1f40000, 0x10000},
676 {"user-config", 0x1f50000, 0x40000},
677 {"qos-db", 0x1f90000, 0x40000},
678 {"usb-config", 0x1fd0000, 0x10000},
679 {"log", 0x1fe0000, 0x20000},
683 .first_sysupgrade_partition
= "os-image",
684 .last_sysupgrade_partition
= "file-system"
687 /** Firmware layout for the C2600 */
693 "{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
698 We use a bigger os-image partition than the stock images (and thus
699 smaller file-system), as our kernel doesn't fit in the stock firmware's
700 2 MB os-image since kernel 4.14.
703 {"SBL1", 0x00000, 0x20000},
704 {"MIBIB", 0x20000, 0x20000},
705 {"SBL2", 0x40000, 0x20000},
706 {"SBL3", 0x60000, 0x30000},
707 {"DDRCONFIG", 0x90000, 0x10000},
708 {"SSD", 0xa0000, 0x10000},
709 {"TZ", 0xb0000, 0x30000},
710 {"RPM", 0xe0000, 0x20000},
711 {"fs-uboot", 0x100000, 0x70000},
712 {"uboot-env", 0x170000, 0x40000},
713 {"radio", 0x1b0000, 0x40000},
714 {"os-image", 0x1f0000, 0x400000}, /* Stock: base 0x1f0000 size 0x200000 */
715 {"file-system", 0x5f0000, 0x1900000}, /* Stock: base 0x3f0000 size 0x1b00000 */
716 {"default-mac", 0x1ef0000, 0x00200},
717 {"pin", 0x1ef0200, 0x00200},
718 {"product-info", 0x1ef0400, 0x0fc00},
719 {"partition-table", 0x1f00000, 0x10000},
720 {"soft-version", 0x1f10000, 0x10000},
721 {"support-list", 0x1f20000, 0x10000},
722 {"profile", 0x1f30000, 0x10000},
723 {"default-config", 0x1f40000, 0x10000},
724 {"user-config", 0x1f50000, 0x40000},
725 {"qos-db", 0x1f90000, 0x40000},
726 {"usb-config", 0x1fd0000, 0x10000},
727 {"log", 0x1fe0000, 0x20000},
731 .first_sysupgrade_partition
= "os-image",
732 .last_sysupgrade_partition
= "file-system"
735 /** Firmware layout for the A7-V5 */
737 .id
= "ARCHER-A7-V5",
740 "{product_name:Archer A7,product_ver:5.0.0,special_id:45550000}\n"
741 "{product_name:Archer A7,product_ver:5.0.0,special_id:55530000}\n"
742 "{product_name:Archer A7,product_ver:5.0.0,special_id:43410000}\n"
743 "{product_name:Archer A7,product_ver:5.0.0,special_id:4A500000}\n"
744 "{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n"
745 "{product_name:Archer A7,product_ver:5.0.0,special_id:52550000}\n",
747 .soft_ver
= "soft_ver:1.0.0\n",
749 /* We're using a dynamic kernel/rootfs split here */
751 {"factory-boot", 0x00000, 0x20000},
752 {"fs-uboot", 0x20000, 0x20000},
753 {"firmware", 0x40000, 0xec0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
754 /* Stock: name file-system base 0x160000 size 0xda0000 */
755 {"default-mac", 0xf40000, 0x00200},
756 {"pin", 0xf40200, 0x00200},
757 {"device-id", 0xf40400, 0x00100},
758 {"product-info", 0xf40500, 0x0fb00},
759 {"soft-version", 0xf50000, 0x00100},
760 {"extra-para", 0xf51000, 0x01000},
761 {"support-list", 0xf52000, 0x0a000},
762 {"profile", 0xf5c000, 0x04000},
763 {"default-config", 0xf60000, 0x10000},
764 {"user-config", 0xf70000, 0x40000},
765 {"certificate", 0xfb0000, 0x10000},
766 {"partition-table", 0xfc0000, 0x10000},
767 {"log", 0xfd0000, 0x20000},
768 {"radio", 0xff0000, 0x10000},
772 .first_sysupgrade_partition
= "os-image",
773 .last_sysupgrade_partition
= "file-system",
776 /** Firmware layout for the C2v3 */
778 .id
= "ARCHER-C2-V3",
781 "{product_name:ArcherC2,product_ver:3.0.0,special_id:00000000}\n"
782 "{product_name:ArcherC2,product_ver:3.0.0,special_id:55530000}\n"
783 "{product_name:ArcherC2,product_ver:3.0.0,special_id:45550000}\n",
785 .soft_ver
= "soft_ver:3.0.1\n",
787 /** We're using a dynamic kernel/rootfs split here */
790 {"factory-boot", 0x00000, 0x20000},
791 {"fs-uboot", 0x20000, 0x10000},
792 {"firmware", 0x30000, 0x7a0000},
793 {"user-config", 0x7d0000, 0x04000},
794 {"default-mac", 0x7e0000, 0x00100},
795 {"device-id", 0x7e0100, 0x00100},
796 {"extra-para", 0x7e0200, 0x00100},
797 {"pin", 0x7e0300, 0x00100},
798 {"support-list", 0x7e0400, 0x00400},
799 {"soft-version", 0x7e0800, 0x00400},
800 {"product-info", 0x7e0c00, 0x01400},
801 {"partition-table", 0x7e2000, 0x01000},
802 {"profile", 0x7e3000, 0x01000},
803 {"default-config", 0x7e4000, 0x04000},
804 {"merge-config", 0x7ec000, 0x02000},
805 {"qos-db", 0x7ee000, 0x02000},
806 {"radio", 0x7f0000, 0x10000},
810 .first_sysupgrade_partition
= "os-image",
811 .last_sysupgrade_partition
= "file-system",
814 /** Firmware layout for the C25v1 */
816 .id
= "ARCHER-C25-V1",
819 "{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
820 "{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
821 "{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
823 .soft_ver
= "soft_ver:1.0.0\n",
825 /* We're using a dynamic kernel/rootfs split here */
827 {"factory-boot", 0x00000, 0x20000},
828 {"fs-uboot", 0x20000, 0x10000},
829 {"firmware", 0x30000, 0x7a0000}, /* Stock: name os-image base 0x30000 size 0x100000 */
830 /* Stock: name file-system base 0x130000 size 0x6a0000 */
831 {"user-config", 0x7d0000, 0x04000},
832 {"default-mac", 0x7e0000, 0x00100},
833 {"device-id", 0x7e0100, 0x00100},
834 {"extra-para", 0x7e0200, 0x00100},
835 {"pin", 0x7e0300, 0x00100},
836 {"support-list", 0x7e0400, 0x00400},
837 {"soft-version", 0x7e0800, 0x00400},
838 {"product-info", 0x7e0c00, 0x01400},
839 {"partition-table", 0x7e2000, 0x01000},
840 {"profile", 0x7e3000, 0x01000},
841 {"default-config", 0x7e4000, 0x04000},
842 {"merge-config", 0x7ec000, 0x02000},
843 {"qos-db", 0x7ee000, 0x02000},
844 {"radio", 0x7f0000, 0x10000},
848 .first_sysupgrade_partition
= "os-image",
849 .last_sysupgrade_partition
= "file-system",
852 /** Firmware layout for the C58v1 */
854 .id
= "ARCHER-C58-V1",
858 "{product_name:Archer C58,product_ver:1.0.0,special_id:00000000}\r\n"
859 "{product_name:Archer C58,product_ver:1.0.0,special_id:45550000}\r\n"
860 "{product_name:Archer C58,product_ver:1.0.0,special_id:55530000}\r\n",
862 .soft_ver
= "soft_ver:1.0.0\n",
865 {"fs-uboot", 0x00000, 0x10000},
866 {"default-mac", 0x10000, 0x00200},
867 {"pin", 0x10200, 0x00200},
868 {"product-info", 0x10400, 0x00100},
869 {"partition-table", 0x10500, 0x00800},
870 {"soft-version", 0x11300, 0x00200},
871 {"support-list", 0x11500, 0x00100},
872 {"device-id", 0x11600, 0x00100},
873 {"profile", 0x11700, 0x03900},
874 {"default-config", 0x15000, 0x04000},
875 {"user-config", 0x19000, 0x04000},
876 {"firmware", 0x20000, 0x7c8000},
877 {"certyficate", 0x7e8000, 0x08000},
878 {"radio", 0x7f0000, 0x10000},
882 .first_sysupgrade_partition
= "os-image",
883 .last_sysupgrade_partition
= "file-system",
886 /** Firmware layout for the C59v1 */
888 .id
= "ARCHER-C59-V1",
892 "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
893 "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
894 "{product_name:Archer C59,product_ver:1.0.0,special_id:52550000}\r\n"
895 "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
897 .soft_ver
= "soft_ver:1.0.0\n",
899 /* We're using a dynamic kernel/rootfs split here */
901 {"fs-uboot", 0x00000, 0x10000},
902 {"default-mac", 0x10000, 0x00200},
903 {"pin", 0x10200, 0x00200},
904 {"device-id", 0x10400, 0x00100},
905 {"product-info", 0x10500, 0x0fb00},
906 {"firmware", 0x20000, 0xe30000},
907 {"partition-table", 0xe50000, 0x10000},
908 {"soft-version", 0xe60000, 0x10000},
909 {"support-list", 0xe70000, 0x10000},
910 {"profile", 0xe80000, 0x10000},
911 {"default-config", 0xe90000, 0x10000},
912 {"user-config", 0xea0000, 0x40000},
913 {"usb-config", 0xee0000, 0x10000},
914 {"certificate", 0xef0000, 0x10000},
915 {"qos-db", 0xf00000, 0x40000},
916 {"log", 0xfe0000, 0x10000},
917 {"radio", 0xff0000, 0x10000},
921 .first_sysupgrade_partition
= "os-image",
922 .last_sysupgrade_partition
= "file-system",
925 /** Firmware layout for the C59v2 */
927 .id
= "ARCHER-C59-V2",
931 "{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
932 "{product_name:Archer C59,product_ver:2.0.0,special_id:45550000}\r\n"
933 "{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
935 .soft_ver
= "soft_ver:2.0.0 Build 20161206 rel.7303\n",
937 /** We're using a dynamic kernel/rootfs split here */
939 {"factory-boot", 0x00000, 0x20000},
940 {"fs-uboot", 0x20000, 0x10000},
941 {"default-mac", 0x30000, 0x00200},
942 {"pin", 0x30200, 0x00200},
943 {"device-id", 0x30400, 0x00100},
944 {"product-info", 0x30500, 0x0fb00},
945 {"firmware", 0x40000, 0xe10000},
946 {"partition-table", 0xe50000, 0x10000},
947 {"soft-version", 0xe60000, 0x10000},
948 {"support-list", 0xe70000, 0x10000},
949 {"profile", 0xe80000, 0x10000},
950 {"default-config", 0xe90000, 0x10000},
951 {"user-config", 0xea0000, 0x40000},
952 {"usb-config", 0xee0000, 0x10000},
953 {"certificate", 0xef0000, 0x10000},
954 {"extra-para", 0xf00000, 0x10000},
955 {"qos-db", 0xf10000, 0x30000},
956 {"log", 0xfe0000, 0x10000},
957 {"radio", 0xff0000, 0x10000},
961 .first_sysupgrade_partition
= "os-image",
962 .last_sysupgrade_partition
= "file-system",
965 /** Firmware layout for the Archer C6 v2 (EU/RU/JP) */
967 .id
= "ARCHER-C6-V2",
971 "{product_name:Archer C6,product_ver:2.0.0,special_id:45550000}\r\n"
972 "{product_name:Archer C6,product_ver:2.0.0,special_id:52550000}\r\n"
973 "{product_name:Archer C6,product_ver:2.0.0,special_id:4A500000}\r\n",
975 .soft_ver
= "soft_ver:1.9.1\n",
978 {"fs-uboot", 0x00000, 0x20000},
979 {"default-mac", 0x20000, 0x00200},
980 {"pin", 0x20200, 0x00100},
981 {"product-info", 0x20300, 0x00200},
982 {"device-id", 0x20500, 0x0fb00},
983 {"firmware", 0x30000, 0x7a9400},
984 {"soft-version", 0x7d9400, 0x00100},
985 {"extra-para", 0x7d9500, 0x00100},
986 {"support-list", 0x7d9600, 0x00200},
987 {"profile", 0x7d9800, 0x03000},
988 {"default-config", 0x7dc800, 0x03000},
989 {"partition-table", 0x7df800, 0x00800},
990 {"user-config", 0x7e0000, 0x0c000},
991 {"certificate", 0x7ec000, 0x04000},
992 {"radio", 0x7f0000, 0x10000},
996 .first_sysupgrade_partition
= "os-image",
997 .last_sysupgrade_partition
= "file-system",
1000 /** Firmware layout for the Archer C6 v2 (US) and A6 v2 (US/TW) */
1002 .id
= "ARCHER-C6-V2-US",
1006 "{product_name:Archer A6,product_ver:2.0.0,special_id:55530000}\n"
1007 "{product_name:Archer A6,product_ver:2.0.0,special_id:54570000}\n"
1008 "{product_name:Archer C6,product_ver:2.0.0,special_id:55530000}\n",
1010 .soft_ver
= "soft_ver:1.9.1\n",
1013 {"factory-boot", 0x00000, 0x20000},
1014 {"default-mac", 0x20000, 0x00200},
1015 {"pin", 0x20200, 0x00100},
1016 {"product-info", 0x20300, 0x00200},
1017 {"device-id", 0x20500, 0x0fb00},
1018 {"fs-uboot", 0x30000, 0x20000},
1019 {"firmware", 0x50000, 0xf89400},
1020 {"soft-version", 0xfd9400, 0x00100},
1021 {"extra-para", 0xfd9500, 0x00100},
1022 {"support-list", 0xfd9600, 0x00200},
1023 {"profile", 0xfd9800, 0x03000},
1024 {"default-config", 0xfdc800, 0x03000},
1025 {"partition-table", 0xfdf800, 0x00800},
1026 {"user-config", 0xfe0000, 0x0c000},
1027 {"certificate", 0xfec000, 0x04000},
1028 {"radio", 0xff0000, 0x10000},
1031 .first_sysupgrade_partition
= "os-image",
1032 .last_sysupgrade_partition
= "file-system",
1034 /** Firmware layout for the Archer C6 v3 */
1036 .id
= "ARCHER-C6-V3",
1040 "{product_name:Archer C6,product_ver:3.20,special_id:55530000}"
1041 "{product_name:Archer C6,product_ver:3.20,special_id:45550000}"
1042 "{product_name:Archer C6,product_ver:3.20,special_id:52550000}"
1043 "{product_name:Archer C6,product_ver:3.20,special_id:4A500000}"
1044 "{product_name:Archer C6,product_ver:3.20,special_id:4B520000}",
1046 .soft_ver
= "soft_ver:1.0.9\n",
1049 {"fs-uboot", 0x00000, 0x40000},
1050 {"firmware", 0x40000, 0xf60000},
1051 {"default-mac", 0xfa0000, 0x00200},
1052 {"pin", 0xfa0200, 0x00100},
1053 {"device-id", 0xfa0300, 0x00100},
1054 {"product-info", 0xfa0400, 0x0fc00},
1055 {"default-config", 0xfb0000, 0x08000},
1056 {"ap-def-config", 0xfb8000, 0x08000},
1057 {"user-config", 0xfc0000, 0x0a000},
1058 {"ag-config", 0xfca000, 0x04000},
1059 {"certificate", 0xfce000, 0x02000},
1060 {"ap-config", 0xfd0000, 0x06000},
1061 {"router-config", 0xfd6000, 0x06000},
1062 {"favicon", 0xfdc000, 0x02000},
1063 {"logo", 0xfde000, 0x02000},
1064 {"partition-table", 0xfe0000, 0x00800},
1065 {"soft-version", 0xfe0800, 0x00100},
1066 {"support-list", 0xfe0900, 0x00200},
1067 {"profile", 0xfe0b00, 0x03000},
1068 {"extra-para", 0xfe3b00, 0x00100},
1069 {"radio", 0xff0000, 0x10000},
1072 .first_sysupgrade_partition
= "os-image",
1073 .last_sysupgrade_partition
= "file-system",
1075 /** Firmware layout for the Archer A6 v3 */
1077 .id
= "ARCHER-A6-V3",
1081 "{product_name:Archer A6,product_ver:3.0.0,special_id:43410000}\n"
1082 "{product_name:Archer A6,product_ver:3.0.0,special_id:55530000}\n"
1083 "{product_name:Archer A6,product_ver:3.0.0,special_id:54570000}\n",
1085 .soft_ver
= "soft_ver:1.0.5\n",
1088 {"fs-uboot", 0x00000, 0x40000},
1089 {"firmware", 0x40000, 0xf60000},
1090 {"default-mac", 0xfa0000, 0x00200},
1091 {"pin", 0xfa0200, 0x00100},
1092 {"device-id", 0xfa0300, 0x00100},
1093 {"product-info", 0xfa0400, 0x0fc00},
1094 {"default-config", 0xfb0000, 0x08000},
1095 {"ap-def-config", 0xfb8000, 0x08000},
1096 {"user-config", 0xfc0000, 0x0a000},
1097 {"ag-config", 0xfca000, 0x04000},
1098 {"certificate", 0xfce000, 0x02000},
1099 {"ap-config", 0xfd0000, 0x06000},
1100 {"router-config", 0xfd6000, 0x06000},
1101 {"favicon", 0xfdc000, 0x02000},
1102 {"logo", 0xfde000, 0x02000},
1103 {"partition-table", 0xfe0000, 0x00800},
1104 {"soft-version", 0xfe0800, 0x00100},
1105 {"support-list", 0xfe0900, 0x00200},
1106 {"profile", 0xfe0b00, 0x03000},
1107 {"extra-para", 0xfe3b00, 0x00100},
1108 {"radio", 0xff0000, 0x10000},
1111 .first_sysupgrade_partition
= "os-image",
1112 .last_sysupgrade_partition
= "file-system",
1114 /** Firmware layout for the Archer C6U v1 */
1116 .id
= "ARCHER-C6U-V1",
1120 "{product_name:Archer C6U,product_ver:1.0.0,special_id:45550000}\n",
1122 .soft_ver
= "soft_ver:1.0.2\n",
1125 {"fs-uboot", 0x00000, 0x40000},
1126 {"firmware", 0x40000, 0xf60000},
1127 {"default-mac", 0xfa0000, 0x00200},
1128 {"pin", 0xfa0200, 0x00100},
1129 {"device-id", 0xfa0300, 0x00100},
1130 {"product-info", 0xfa0400, 0x0fc00},
1131 {"default-config", 0xfb0000, 0x08000},
1132 {"ap-def-config", 0xfb8000, 0x08000},
1133 {"user-config", 0xfc0000, 0x0c000},
1134 {"certificate", 0xfcc000, 0x04000},
1135 {"ap-config", 0xfd0000, 0x08000},
1136 {"router-config", 0xfd8000, 0x08000},
1137 {"partition-table", 0xfe0000, 0x00800},
1138 {"soft-version", 0xfe0800, 0x00100},
1139 {"support-list", 0xfe0900, 0x00200},
1140 {"profile", 0xfe0b00, 0x03000},
1141 {"extra-para", 0xfe3b00, 0x00100},
1142 {"radio", 0xff0000, 0x10000},
1145 .first_sysupgrade_partition
= "os-image",
1146 .last_sysupgrade_partition
= "file-system",
1148 /** Firmware layout for the C60v1 */
1150 .id
= "ARCHER-C60-V1",
1154 "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
1155 "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
1156 "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
1158 .soft_ver
= "soft_ver:1.0.0\n",
1161 {"fs-uboot", 0x00000, 0x10000},
1162 {"default-mac", 0x10000, 0x00200},
1163 {"pin", 0x10200, 0x00200},
1164 {"product-info", 0x10400, 0x00100},
1165 {"partition-table", 0x10500, 0x00800},
1166 {"soft-version", 0x11300, 0x00200},
1167 {"support-list", 0x11500, 0x00100},
1168 {"device-id", 0x11600, 0x00100},
1169 {"profile", 0x11700, 0x03900},
1170 {"default-config", 0x15000, 0x04000},
1171 {"user-config", 0x19000, 0x04000},
1172 {"firmware", 0x20000, 0x7c8000},
1173 {"certyficate", 0x7e8000, 0x08000},
1174 {"radio", 0x7f0000, 0x10000},
1178 .first_sysupgrade_partition
= "os-image",
1179 .last_sysupgrade_partition
= "file-system",
1182 /** Firmware layout for the C60v2 */
1184 .id
= "ARCHER-C60-V2",
1188 "{product_name:Archer C60,product_ver:2.0.0,special_id:42520000}\r\n"
1189 "{product_name:Archer C60,product_ver:2.0.0,special_id:45550000}\r\n"
1190 "{product_name:Archer C60,product_ver:2.0.0,special_id:55530000}\r\n",
1192 .soft_ver
= "soft_ver:2.0.0\n",
1195 {"factory-boot", 0x00000, 0x1fb00},
1196 {"default-mac", 0x1fb00, 0x00200},
1197 {"pin", 0x1fd00, 0x00100},
1198 {"product-info", 0x1fe00, 0x00100},
1199 {"device-id", 0x1ff00, 0x00100},
1200 {"fs-uboot", 0x20000, 0x10000},
1201 {"firmware", 0x30000, 0x7a0000},
1202 {"soft-version", 0x7d9500, 0x00100},
1203 {"support-list", 0x7d9600, 0x00100},
1204 {"extra-para", 0x7d9700, 0x00100},
1205 {"profile", 0x7d9800, 0x03000},
1206 {"default-config", 0x7dc800, 0x03000},
1207 {"partition-table", 0x7df800, 0x00800},
1208 {"user-config", 0x7e0000, 0x0c000},
1209 {"certificate", 0x7ec000, 0x04000},
1210 {"radio", 0x7f0000, 0x10000},
1214 .first_sysupgrade_partition
= "os-image",
1215 .last_sysupgrade_partition
= "file-system",
1218 /** Firmware layout for the C60v3 */
1220 .id
= "ARCHER-C60-V3",
1224 "{product_name:Archer C60,product_ver:3.0.0,special_id:42520000}\r\n"
1225 "{product_name:Archer C60,product_ver:3.0.0,special_id:45550000}\r\n"
1226 "{product_name:Archer C60,product_ver:3.0.0,special_id:55530000}\r\n",
1228 .soft_ver
= "soft_ver:3.0.0\n",
1231 {"factory-boot", 0x00000, 0x1fb00},
1232 {"default-mac", 0x1fb00, 0x00200},
1233 {"pin", 0x1fd00, 0x00100},
1234 {"product-info", 0x1fe00, 0x00100},
1235 {"device-id", 0x1ff00, 0x00100},
1236 {"fs-uboot", 0x20000, 0x10000},
1237 {"firmware", 0x30000, 0x7a0000},
1238 {"soft-version", 0x7d9500, 0x00100},
1239 {"support-list", 0x7d9600, 0x00100},
1240 {"extra-para", 0x7d9700, 0x00100},
1241 {"profile", 0x7d9800, 0x03000},
1242 {"default-config", 0x7dc800, 0x03000},
1243 {"partition-table", 0x7df800, 0x00800},
1244 {"user-config", 0x7e0000, 0x0c000},
1245 {"certificate", 0x7ec000, 0x04000},
1246 {"radio", 0x7f0000, 0x10000},
1250 .first_sysupgrade_partition
= "os-image",
1251 .last_sysupgrade_partition
= "file-system",
1254 /** Firmware layout for the C5 */
1256 .id
= "ARCHER-C5-V2",
1260 "{product_name:ArcherC5,product_ver:2.0.0,special_id:00000000}\r\n"
1261 "{product_name:ArcherC5,product_ver:2.0.0,special_id:55530000}\r\n"
1262 "{product_name:ArcherC5,product_ver:2.0.0,special_id:4A500000}\r\n", /* JP version */
1267 {"fs-uboot", 0x00000, 0x40000},
1268 {"os-image", 0x40000, 0x200000},
1269 {"file-system", 0x240000, 0xc00000},
1270 {"default-mac", 0xe40000, 0x00200},
1271 {"pin", 0xe40200, 0x00200},
1272 {"product-info", 0xe40400, 0x00200},
1273 {"partition-table", 0xe50000, 0x10000},
1274 {"soft-version", 0xe60000, 0x00200},
1275 {"support-list", 0xe61000, 0x0f000},
1276 {"profile", 0xe70000, 0x10000},
1277 {"default-config", 0xe80000, 0x10000},
1278 {"user-config", 0xe90000, 0x50000},
1279 {"log", 0xee0000, 0x100000},
1280 {"radio_bk", 0xfe0000, 0x10000},
1281 {"radio", 0xff0000, 0x10000},
1285 .first_sysupgrade_partition
= "os-image",
1286 .last_sysupgrade_partition
= "file-system"
1289 /** Firmware layout for the C7 */
1291 .id
= "ARCHER-C7-V4",
1294 "{product_name:Archer C7,product_ver:4.0.0,special_id:00000000}\n"
1295 "{product_name:Archer C7,product_ver:4.0.0,special_id:41550000}\n"
1296 "{product_name:Archer C7,product_ver:4.0.0,special_id:45550000}\n"
1297 "{product_name:Archer C7,product_ver:4.0.0,special_id:4B520000}\n"
1298 "{product_name:Archer C7,product_ver:4.0.0,special_id:42520000}\n"
1299 "{product_name:Archer C7,product_ver:4.0.0,special_id:4A500000}\n"
1300 "{product_name:Archer C7,product_ver:4.0.0,special_id:52550000}\n"
1301 "{product_name:Archer C7,product_ver:4.0.0,special_id:54570000}\n"
1302 "{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
1303 "{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
1305 .soft_ver
= "soft_ver:1.0.0\n",
1307 /* We're using a dynamic kernel/rootfs split here */
1309 {"factory-boot", 0x00000, 0x20000},
1310 {"fs-uboot", 0x20000, 0x20000},
1311 {"firmware", 0x40000, 0xEC0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
1312 /* Stock: name file-system base 0x160000 size 0xda0000 */
1313 {"default-mac", 0xf00000, 0x00200},
1314 {"pin", 0xf00200, 0x00200},
1315 {"device-id", 0xf00400, 0x00100},
1316 {"product-info", 0xf00500, 0x0fb00},
1317 {"soft-version", 0xf10000, 0x00100},
1318 {"extra-para", 0xf11000, 0x01000},
1319 {"support-list", 0xf12000, 0x0a000},
1320 {"profile", 0xf1c000, 0x04000},
1321 {"default-config", 0xf20000, 0x10000},
1322 {"user-config", 0xf30000, 0x40000},
1323 {"qos-db", 0xf70000, 0x40000},
1324 {"certificate", 0xfb0000, 0x10000},
1325 {"partition-table", 0xfc0000, 0x10000},
1326 {"log", 0xfd0000, 0x20000},
1327 {"radio", 0xff0000, 0x10000},
1331 .first_sysupgrade_partition
= "os-image",
1332 .last_sysupgrade_partition
= "file-system",
1335 /** Firmware layout for the C7 v5*/
1337 .id
= "ARCHER-C7-V5",
1340 "{product_name:Archer C7,product_ver:5.0.0,special_id:00000000}\n"
1341 "{product_name:Archer C7,product_ver:5.0.0,special_id:45550000}\n"
1342 "{product_name:Archer C7,product_ver:5.0.0,special_id:55530000}\n"
1343 "{product_name:Archer C7,product_ver:5.0.0,special_id:43410000}\n"
1344 "{product_name:Archer C7,product_ver:5.0.0,special_id:4A500000}\n"
1345 "{product_name:Archer C7,product_ver:5.0.0,special_id:54570000}\n"
1346 "{product_name:Archer C7,product_ver:5.0.0,special_id:52550000}\n"
1347 "{product_name:Archer C7,product_ver:5.0.0,special_id:4B520000}\n",
1350 .soft_ver
= "soft_ver:7.0.0\n",
1352 /* We're using a dynamic kernel/rootfs split here */
1354 {"factory-boot", 0x00000, 0x20000},
1355 {"fs-uboot", 0x20000, 0x20000},
1356 {"partition-table", 0x40000, 0x10000},
1357 {"radio", 0x50000, 0x10000},
1358 {"default-mac", 0x60000, 0x00200},
1359 {"pin", 0x60200, 0x00200},
1360 {"device-id", 0x60400, 0x00100},
1361 {"product-info", 0x60500, 0x0fb00},
1362 {"soft-version", 0x70000, 0x01000},
1363 {"extra-para", 0x71000, 0x01000},
1364 {"support-list", 0x72000, 0x0a000},
1365 {"profile", 0x7c000, 0x04000},
1366 {"user-config", 0x80000, 0x40000},
1369 {"firmware", 0xc0000, 0xf00000}, /* Stock: name os-image base 0xc0000 size 0x120000 */
1370 /* Stock: name file-system base 0x1e0000 size 0xde0000 */
1372 {"log", 0xfc0000, 0x20000},
1373 {"certificate", 0xfe0000, 0x10000},
1374 {"default-config", 0xff0000, 0x10000},
1379 .first_sysupgrade_partition
= "os-image",
1380 .last_sysupgrade_partition
= "file-system",
1383 /** Firmware layout for the C9 */
1389 "{product_name:ArcherC9,"
1390 "product_ver:1.0.0,"
1391 "special_id:00000000}\n",
1396 {"fs-uboot", 0x00000, 0x40000},
1397 {"os-image", 0x40000, 0x200000},
1398 {"file-system", 0x240000, 0xc00000},
1399 {"default-mac", 0xe40000, 0x00200},
1400 {"pin", 0xe40200, 0x00200},
1401 {"product-info", 0xe40400, 0x00200},
1402 {"partition-table", 0xe50000, 0x10000},
1403 {"soft-version", 0xe60000, 0x00200},
1404 {"support-list", 0xe61000, 0x0f000},
1405 {"profile", 0xe70000, 0x10000},
1406 {"default-config", 0xe80000, 0x10000},
1407 {"user-config", 0xe90000, 0x50000},
1408 {"log", 0xee0000, 0x100000},
1409 {"radio_bk", 0xfe0000, 0x10000},
1410 {"radio", 0xff0000, 0x10000},
1414 .first_sysupgrade_partition
= "os-image",
1415 .last_sysupgrade_partition
= "file-system"
1418 /** Firmware layout for the EAP120 */
1421 .vendor
= "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1424 "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1429 {"fs-uboot", 0x00000, 0x20000},
1430 {"partition-table", 0x20000, 0x02000},
1431 {"default-mac", 0x30000, 0x00020},
1432 {"support-list", 0x31000, 0x00100},
1433 {"product-info", 0x31100, 0x00100},
1434 {"soft-version", 0x32000, 0x00100},
1435 {"os-image", 0x40000, 0x180000},
1436 {"file-system", 0x1c0000, 0x600000},
1437 {"user-config", 0x7c0000, 0x10000},
1438 {"backup-config", 0x7d0000, 0x10000},
1439 {"log", 0x7e0000, 0x10000},
1440 {"radio", 0x7f0000, 0x10000},
1444 .first_sysupgrade_partition
= "os-image",
1445 .last_sysupgrade_partition
= "file-system"
1448 /** Firmware layout for the EAP225-Outdoor v1 */
1450 .id
= "EAP225-OUTDOOR-V1",
1453 "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n",
1454 .part_trail
= PART_TRAIL_NONE
,
1456 .soft_ver_compat_level
= 1,
1459 {"fs-uboot", 0x00000, 0x20000},
1460 {"partition-table", 0x20000, 0x02000},
1461 {"default-mac", 0x30000, 0x01000},
1462 {"support-list", 0x31000, 0x00100},
1463 {"product-info", 0x31100, 0x00400},
1464 {"soft-version", 0x32000, 0x00100},
1465 {"firmware", 0x40000, 0xd80000},
1466 {"user-config", 0xdc0000, 0x30000},
1467 {"mutil-log", 0xf30000, 0x80000},
1468 {"oops", 0xfb0000, 0x40000},
1469 {"radio", 0xff0000, 0x10000},
1473 .first_sysupgrade_partition
= "os-image",
1474 .last_sysupgrade_partition
= "file-system"
1477 /** Firmware layout for the EAP225 v3 */
1482 "EAP225(TP-Link|UN|AC1350-D):3.0\r\n",
1483 .part_trail
= PART_TRAIL_NONE
,
1485 .soft_ver_compat_level
= 1,
1488 {"fs-uboot", 0x00000, 0x20000},
1489 {"partition-table", 0x20000, 0x02000},
1490 {"default-mac", 0x30000, 0x01000},
1491 {"support-list", 0x31000, 0x00100},
1492 {"product-info", 0x31100, 0x00400},
1493 {"soft-version", 0x32000, 0x00100},
1494 {"firmware", 0x40000, 0xd80000},
1495 {"user-config", 0xdc0000, 0x30000},
1496 {"mutil-log", 0xf30000, 0x80000},
1497 {"oops", 0xfb0000, 0x40000},
1498 {"radio", 0xff0000, 0x10000},
1502 .first_sysupgrade_partition
= "os-image",
1503 .last_sysupgrade_partition
= "file-system"
1506 /** Firmware layout for the EAP225-Wall v2 */
1508 .id
= "EAP225-WALL-V2",
1511 "EAP225-Wall(TP-Link|UN|AC1200-D):2.0\r\n",
1512 .part_trail
= PART_TRAIL_NONE
,
1514 .soft_ver_compat_level
= 1,
1517 {"fs-uboot", 0x00000, 0x20000},
1518 {"partition-table", 0x20000, 0x02000},
1519 {"default-mac", 0x30000, 0x01000},
1520 {"support-list", 0x31000, 0x00100},
1521 {"product-info", 0x31100, 0x00400},
1522 {"soft-version", 0x32000, 0x00100},
1523 {"firmware", 0x40000, 0xd80000},
1524 {"user-config", 0xdc0000, 0x30000},
1525 {"mutil-log", 0xf30000, 0x80000},
1526 {"oops", 0xfb0000, 0x40000},
1527 {"radio", 0xff0000, 0x10000},
1531 .first_sysupgrade_partition
= "os-image",
1532 .last_sysupgrade_partition
= "file-system"
1535 /** Firmware layout for the EAP235-Wall v1 */
1537 .id
= "EAP235-WALL-V1",
1540 "EAP235-Wall(TP-Link|UN|AC1200-D):1.0\r\n",
1541 .part_trail
= PART_TRAIL_NONE
,
1543 .soft_ver_compat_level
= 1,
1546 {"fs-uboot", 0x00000, 0x80000},
1547 {"partition-table", 0x80000, 0x02000},
1548 {"default-mac", 0x90000, 0x01000},
1549 {"support-list", 0x91000, 0x00100},
1550 {"product-info", 0x91100, 0x00400},
1551 {"soft-version", 0x92000, 0x00100},
1552 {"firmware", 0xa0000, 0xd20000},
1553 {"user-config", 0xdc0000, 0x30000},
1554 {"mutil-log", 0xf30000, 0x80000},
1555 {"oops", 0xfb0000, 0x40000},
1556 {"radio", 0xff0000, 0x10000},
1560 .first_sysupgrade_partition
= "os-image",
1561 .last_sysupgrade_partition
= "file-system"
1564 /** Firmware layout for the EAP245 v1 */
1569 "EAP245(TP-LINK|UN|AC1750-D):1.0\r\n",
1570 .part_trail
= PART_TRAIL_NONE
,
1574 {"fs-uboot", 0x00000, 0x20000},
1575 {"partition-table", 0x20000, 0x02000},
1576 {"default-mac", 0x30000, 0x01000},
1577 {"support-list", 0x31000, 0x00100},
1578 {"product-info", 0x31100, 0x00400},
1579 {"soft-version", 0x32000, 0x00100},
1580 {"firmware", 0x40000, 0xd80000},
1581 {"user-config", 0xdc0000, 0x30000},
1582 {"radio", 0xff0000, 0x10000},
1586 .first_sysupgrade_partition
= "os-image",
1587 .last_sysupgrade_partition
= "file-system"
1590 /** Firmware layout for the EAP245 v3 */
1595 "EAP245(TP-Link|UN|AC1750-D):3.0\r\n",
1596 .part_trail
= PART_TRAIL_NONE
,
1598 .soft_ver_compat_level
= 1,
1600 /** Firmware partition with dynamic kernel/rootfs split */
1602 {"factroy-boot", 0x00000, 0x40000},
1603 {"fs-uboot", 0x40000, 0x40000},
1604 {"partition-table", 0x80000, 0x10000},
1605 {"default-mac", 0x90000, 0x01000},
1606 {"support-list", 0x91000, 0x00100},
1607 {"product-info", 0x91100, 0x00400},
1608 {"soft-version", 0x92000, 0x00100},
1609 {"radio", 0xa0000, 0x10000},
1610 {"extra-para", 0xb0000, 0x10000},
1611 {"firmware", 0xc0000, 0xe40000},
1612 {"config", 0xf00000, 0x30000},
1613 {"mutil-log", 0xf30000, 0x80000},
1614 {"oops", 0xfb0000, 0x40000},
1618 .first_sysupgrade_partition
= "os-image",
1619 .last_sysupgrade_partition
= "file-system"
1622 /** Firmware layout for the TL-WA1201 v2 */
1624 .id
= "TL-WA1201-V2",
1628 "{product_name:TL-WA1201,product_ver:2.0.0,special_id:45550000}\n"
1629 "{product_name:TL-WA1201,product_ver:2.0.0,special_id:55530000}\n",
1631 .soft_ver
= "soft_ver:1.0.1 Build 20200709 rel.66244\n",
1634 {"fs-uboot", 0x00000, 0x20000},
1635 {"default-mac", 0x20000, 0x00200},
1636 {"pin", 0x20200, 0x00100},
1637 {"product-info", 0x20300, 0x00200},
1638 {"device-id", 0x20500, 0x0fb00},
1639 {"firmware", 0x30000, 0xce0000},
1640 {"portal-logo", 0xd10000, 0x20000},
1641 {"portal-back", 0xd30000, 0x200000},
1642 {"soft-version", 0xf30000, 0x00200},
1643 {"extra-para", 0xf30200, 0x00200},
1644 {"support-list", 0xf30400, 0x00200},
1645 {"profile", 0xf30600, 0x0fa00},
1646 {"apdef-config", 0xf40000, 0x10000},
1647 {"ap-config", 0xf50000, 0x10000},
1648 {"redef-config", 0xf60000, 0x10000},
1649 {"re-config", 0xf70000, 0x10000},
1650 {"multidef-config", 0xf80000, 0x10000},
1651 {"multi-config", 0xf90000, 0x10000},
1652 {"clientdef-config", 0xfa0000, 0x10000},
1653 {"client-config", 0xfb0000, 0x10000},
1654 {"partition-table", 0xfc0000, 0x10000},
1655 {"user-config", 0xfd0000, 0x10000},
1656 {"certificate", 0xfe0000, 0x10000},
1657 {"radio", 0xff0000, 0x10000},
1660 .first_sysupgrade_partition
= "os-image",
1661 .last_sysupgrade_partition
= "file-system",
1664 /** Firmware layout for the TL-WA850RE v2 */
1666 .id
= "TLWA850REV2",
1670 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55530000}\n"
1671 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:00000000}\n"
1672 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55534100}\n"
1673 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:45550000}\n"
1674 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4B520000}\n"
1675 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:42520000}\n"
1676 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4A500000}\n"
1677 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
1678 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
1679 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
1684 576KB were moved from file-system to os-image
1685 in comparison to the stock image
1688 {"fs-uboot", 0x00000, 0x20000},
1689 {"firmware", 0x20000, 0x390000},
1690 {"partition-table", 0x3b0000, 0x02000},
1691 {"default-mac", 0x3c0000, 0x00020},
1692 {"pin", 0x3c0100, 0x00020},
1693 {"product-info", 0x3c1000, 0x01000},
1694 {"soft-version", 0x3c2000, 0x00100},
1695 {"support-list", 0x3c3000, 0x01000},
1696 {"profile", 0x3c4000, 0x08000},
1697 {"user-config", 0x3d0000, 0x10000},
1698 {"default-config", 0x3e0000, 0x10000},
1699 {"radio", 0x3f0000, 0x10000},
1703 .first_sysupgrade_partition
= "os-image",
1704 .last_sysupgrade_partition
= "file-system"
1707 /** Firmware layout for the TL-WA855RE v1 */
1709 .id
= "TLWA855REV1",
1713 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:00000000}\n"
1714 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:55530000}\n"
1715 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:45550000}\n"
1716 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4B520000}\n"
1717 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:42520000}\n"
1718 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4A500000}\n"
1719 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:43410000}\n"
1720 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:41550000}\n"
1721 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:52550000}\n",
1726 {"fs-uboot", 0x00000, 0x20000},
1727 {"os-image", 0x20000, 0x150000},
1728 {"file-system", 0x170000, 0x240000},
1729 {"partition-table", 0x3b0000, 0x02000},
1730 {"default-mac", 0x3c0000, 0x00020},
1731 {"pin", 0x3c0100, 0x00020},
1732 {"product-info", 0x3c1000, 0x01000},
1733 {"soft-version", 0x3c2000, 0x00100},
1734 {"support-list", 0x3c3000, 0x01000},
1735 {"profile", 0x3c4000, 0x08000},
1736 {"user-config", 0x3d0000, 0x10000},
1737 {"default-config", 0x3e0000, 0x10000},
1738 {"radio", 0x3f0000, 0x10000},
1742 .first_sysupgrade_partition
= "os-image",
1743 .last_sysupgrade_partition
= "file-system"
1746 /** Firmware layout for the TL-WPA8630P v2 (EU)*/
1748 .id
= "TL-WPA8630P-V2.0-EU",
1752 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:45550000}\n",
1757 {"factory-uboot", 0x00000, 0x20000},
1758 {"fs-uboot", 0x20000, 0x20000},
1759 {"firmware", 0x40000, 0x5e0000},
1760 {"partition-table", 0x620000, 0x02000},
1761 {"default-mac", 0x630000, 0x00020},
1762 {"pin", 0x630100, 0x00020},
1763 {"device-id", 0x630200, 0x00030},
1764 {"product-info", 0x631100, 0x01000},
1765 {"extra-para", 0x632100, 0x01000},
1766 {"soft-version", 0x640000, 0x01000},
1767 {"support-list", 0x641000, 0x01000},
1768 {"profile", 0x642000, 0x08000},
1769 {"user-config", 0x650000, 0x10000},
1770 {"default-config", 0x660000, 0x10000},
1771 {"default-nvm", 0x670000, 0xc0000},
1772 {"default-pib", 0x730000, 0x40000},
1773 {"radio", 0x7f0000, 0x10000},
1777 .first_sysupgrade_partition
= "os-image",
1778 .last_sysupgrade_partition
= "file-system"
1781 /** Firmware layout for the TL-WPA8630P v2 (INT)*/
1783 .id
= "TL-WPA8630P-V2-INT",
1787 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:41550000}\n"
1788 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:44450000}\n"
1789 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:41550000}\n",
1794 {"factory-uboot", 0x00000, 0x20000},
1795 {"fs-uboot", 0x20000, 0x20000},
1796 {"firmware", 0x40000, 0x5e0000},
1797 {"partition-table", 0x620000, 0x02000},
1798 {"extra-para", 0x632100, 0x01000},
1799 {"soft-version", 0x640000, 0x01000},
1800 {"support-list", 0x641000, 0x01000},
1801 {"profile", 0x642000, 0x08000},
1802 {"user-config", 0x650000, 0x10000},
1803 {"default-config", 0x660000, 0x10000},
1804 {"default-nvm", 0x670000, 0xc0000},
1805 {"default-pib", 0x730000, 0x40000},
1806 {"default-mac", 0x7e0000, 0x00020},
1807 {"pin", 0x7e0100, 0x00020},
1808 {"device-id", 0x7e0200, 0x00030},
1809 {"product-info", 0x7e1100, 0x01000},
1810 {"radio", 0x7f0000, 0x10000},
1814 .first_sysupgrade_partition
= "os-image",
1815 .last_sysupgrade_partition
= "file-system"
1818 /** Firmware layout for the TL-WPA8630P v2.1 (EU)*/
1820 .id
= "TL-WPA8630P-V2.1-EU",
1824 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:45550000}\n",
1829 {"factory-uboot", 0x00000, 0x20000},
1830 {"fs-uboot", 0x20000, 0x20000},
1831 {"firmware", 0x40000, 0x5e0000},
1832 {"extra-para", 0x680000, 0x01000},
1833 {"product-info", 0x690000, 0x01000},
1834 {"partition-table", 0x6a0000, 0x02000},
1835 {"soft-version", 0x6b0000, 0x01000},
1836 {"support-list", 0x6b1000, 0x01000},
1837 {"profile", 0x6b2000, 0x08000},
1838 {"user-config", 0x6c0000, 0x10000},
1839 {"default-config", 0x6d0000, 0x10000},
1840 {"default-nvm", 0x6e0000, 0xc0000},
1841 {"default-pib", 0x7a0000, 0x40000},
1842 {"default-mac", 0x7e0000, 0x00020},
1843 {"pin", 0x7e0100, 0x00020},
1844 {"device-id", 0x7e0200, 0x00030},
1845 {"radio", 0x7f0000, 0x10000},
1849 .first_sysupgrade_partition
= "os-image",
1850 .last_sysupgrade_partition
= "file-system"
1853 /** Firmware layout for the TL-WR1043 v5 */
1855 .id
= "TLWR1043NV5",
1859 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
1860 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
1862 .soft_ver
= "soft_ver:1.0.0\n",
1864 {"factory-boot", 0x00000, 0x20000},
1865 {"fs-uboot", 0x20000, 0x20000},
1866 {"firmware", 0x40000, 0xec0000},
1867 {"default-mac", 0xf00000, 0x00200},
1868 {"pin", 0xf00200, 0x00200},
1869 {"device-id", 0xf00400, 0x00100},
1870 {"product-info", 0xf00500, 0x0fb00},
1871 {"soft-version", 0xf10000, 0x01000},
1872 {"extra-para", 0xf11000, 0x01000},
1873 {"support-list", 0xf12000, 0x0a000},
1874 {"profile", 0xf1c000, 0x04000},
1875 {"default-config", 0xf20000, 0x10000},
1876 {"user-config", 0xf30000, 0x40000},
1877 {"qos-db", 0xf70000, 0x40000},
1878 {"certificate", 0xfb0000, 0x10000},
1879 {"partition-table", 0xfc0000, 0x10000},
1880 {"log", 0xfd0000, 0x20000},
1881 {"radio", 0xff0000, 0x10000},
1884 .first_sysupgrade_partition
= "os-image",
1885 .last_sysupgrade_partition
= "file-system"
1888 /** Firmware layout for the TL-WR1043 v4 */
1890 .id
= "TLWR1043NDV4",
1894 "{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
1898 /* We're using a dynamic kernel/rootfs split here */
1900 {"fs-uboot", 0x00000, 0x20000},
1901 {"firmware", 0x20000, 0xf30000},
1902 {"default-mac", 0xf50000, 0x00200},
1903 {"pin", 0xf50200, 0x00200},
1904 {"product-info", 0xf50400, 0x0fc00},
1905 {"soft-version", 0xf60000, 0x0b000},
1906 {"support-list", 0xf6b000, 0x04000},
1907 {"profile", 0xf70000, 0x04000},
1908 {"default-config", 0xf74000, 0x0b000},
1909 {"user-config", 0xf80000, 0x40000},
1910 {"partition-table", 0xfc0000, 0x10000},
1911 {"log", 0xfd0000, 0x20000},
1912 {"radio", 0xff0000, 0x10000},
1916 .first_sysupgrade_partition
= "os-image",
1917 .last_sysupgrade_partition
= "file-system"
1920 /** Firmware layout for the TL-WR902AC v1 */
1922 .id
= "TL-WR902AC-V1",
1926 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:45550000}\n"
1927 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:55530000}\n",
1932 384KB were moved from file-system to os-image
1933 in comparison to the stock image
1936 {"fs-uboot", 0x00000, 0x20000},
1937 {"firmware", 0x20000, 0x730000},
1938 {"default-mac", 0x750000, 0x00200},
1939 {"pin", 0x750200, 0x00200},
1940 {"product-info", 0x750400, 0x0fc00},
1941 {"soft-version", 0x760000, 0x0b000},
1942 {"support-list", 0x76b000, 0x04000},
1943 {"profile", 0x770000, 0x04000},
1944 {"default-config", 0x774000, 0x0b000},
1945 {"user-config", 0x780000, 0x40000},
1946 {"partition-table", 0x7c0000, 0x10000},
1947 {"log", 0x7d0000, 0x20000},
1948 {"radio", 0x7f0000, 0x10000},
1952 .first_sysupgrade_partition
= "os-image",
1953 .last_sysupgrade_partition
= "file-system",
1956 /** Firmware layout for the TL-WR941HP v1 */
1958 .id
= "TL-WR941HP-V1",
1962 "{product_name:TL-WR941HP,product_ver:1.0.0,special_id:00000000}\n",
1967 {"fs-uboot", 0x00000, 0x20000},
1968 {"firmware", 0x20000, 0x730000},
1969 {"default-mac", 0x750000, 0x00200},
1970 {"pin", 0x750200, 0x00200},
1971 {"product-info", 0x750400, 0x0fc00},
1972 {"soft-version", 0x760000, 0x0b000},
1973 {"support-list", 0x76b000, 0x04000},
1974 {"profile", 0x770000, 0x04000},
1975 {"default-config", 0x774000, 0x0b000},
1976 {"user-config", 0x780000, 0x40000},
1977 {"partition-table", 0x7c0000, 0x10000},
1978 {"log", 0x7d0000, 0x20000},
1979 {"radio", 0x7f0000, 0x10000},
1983 .first_sysupgrade_partition
= "os-image",
1984 .last_sysupgrade_partition
= "file-system",
1987 /** Firmware layout for the TL-WR942N V1 */
1993 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:00000000}\r\n"
1994 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:52550000}\r\n",
1999 {"fs-uboot", 0x00000, 0x20000},
2000 {"firmware", 0x20000, 0xe20000},
2001 {"default-mac", 0xe40000, 0x00200},
2002 {"pin", 0xe40200, 0x00200},
2003 {"product-info", 0xe40400, 0x0fc00},
2004 {"partition-table", 0xe50000, 0x10000},
2005 {"soft-version", 0xe60000, 0x10000},
2006 {"support-list", 0xe70000, 0x10000},
2007 {"profile", 0xe80000, 0x10000},
2008 {"default-config", 0xe90000, 0x10000},
2009 {"user-config", 0xea0000, 0x40000},
2010 {"qos-db", 0xee0000, 0x40000},
2011 {"certificate", 0xf20000, 0x10000},
2012 {"usb-config", 0xfb0000, 0x10000},
2013 {"log", 0xfc0000, 0x20000},
2014 {"radio-bk", 0xfe0000, 0x10000},
2015 {"radio", 0xff0000, 0x10000},
2019 .first_sysupgrade_partition
= "os-image",
2020 .last_sysupgrade_partition
= "file-system",
2023 /** Firmware layout for the RE200 v2 */
2029 "{product_name:RE200,product_ver:2.0.0,special_id:00000000}\n"
2030 "{product_name:RE200,product_ver:2.0.0,special_id:41520000}\n"
2031 "{product_name:RE200,product_ver:2.0.0,special_id:41550000}\n"
2032 "{product_name:RE200,product_ver:2.0.0,special_id:42520000}\n"
2033 "{product_name:RE200,product_ver:2.0.0,special_id:43410000}\n"
2034 "{product_name:RE200,product_ver:2.0.0,special_id:45530000}\n"
2035 "{product_name:RE200,product_ver:2.0.0,special_id:45550000}\n"
2036 "{product_name:RE200,product_ver:2.0.0,special_id:49440000}\n"
2037 "{product_name:RE200,product_ver:2.0.0,special_id:4a500000}\n"
2038 "{product_name:RE200,product_ver:2.0.0,special_id:4b520000}\n"
2039 "{product_name:RE200,product_ver:2.0.0,special_id:52550000}\n"
2040 "{product_name:RE200,product_ver:2.0.0,special_id:54570000}\n"
2041 "{product_name:RE200,product_ver:2.0.0,special_id:55530000}\n",
2046 {"fs-uboot", 0x00000, 0x20000},
2047 {"firmware", 0x20000, 0x7a0000},
2048 {"partition-table", 0x7c0000, 0x02000},
2049 {"default-mac", 0x7c2000, 0x00020},
2050 {"pin", 0x7c2100, 0x00020},
2051 {"product-info", 0x7c3100, 0x01000},
2052 {"soft-version", 0x7c4200, 0x01000},
2053 {"support-list", 0x7c5200, 0x01000},
2054 {"profile", 0x7c6200, 0x08000},
2055 {"config-info", 0x7ce200, 0x00400},
2056 {"user-config", 0x7d0000, 0x10000},
2057 {"default-config", 0x7e0000, 0x10000},
2058 {"radio", 0x7f0000, 0x10000},
2062 .first_sysupgrade_partition
= "os-image",
2063 .last_sysupgrade_partition
= "file-system"
2066 /** Firmware layout for the RE200 v3 */
2072 "{product_name:RE200,product_ver:3.0.0,special_id:00000000}\n"
2073 "{product_name:RE200,product_ver:3.0.0,special_id:41520000}\n"
2074 "{product_name:RE200,product_ver:3.0.0,special_id:41550000}\n"
2075 "{product_name:RE200,product_ver:3.0.0,special_id:42520000}\n"
2076 "{product_name:RE200,product_ver:3.0.0,special_id:43410000}\n"
2077 "{product_name:RE200,product_ver:3.0.0,special_id:45470000}\n"
2078 "{product_name:RE200,product_ver:3.0.0,special_id:45530000}\n"
2079 "{product_name:RE200,product_ver:3.0.0,special_id:45550000}\n"
2080 "{product_name:RE200,product_ver:3.0.0,special_id:49440000}\n"
2081 "{product_name:RE200,product_ver:3.0.0,special_id:4A500000}\n"
2082 "{product_name:RE200,product_ver:3.0.0,special_id:4B520000}\n"
2083 "{product_name:RE200,product_ver:3.0.0,special_id:52550000}\n"
2084 "{product_name:RE200,product_ver:3.0.0,special_id:54570000}\n"
2085 "{product_name:RE200,product_ver:3.0.0,special_id:55530000}\n",
2090 {"fs-uboot", 0x00000, 0x20000},
2091 {"firmware", 0x20000, 0x7a0000},
2092 {"partition-table", 0x7c0000, 0x02000},
2093 {"default-mac", 0x7c2000, 0x00020},
2094 {"pin", 0x7c2100, 0x00020},
2095 {"product-info", 0x7c3100, 0x01000},
2096 {"soft-version", 0x7c4200, 0x01000},
2097 {"support-list", 0x7c5200, 0x01000},
2098 {"profile", 0x7c6200, 0x08000},
2099 {"config-info", 0x7ce200, 0x00400},
2100 {"user-config", 0x7d0000, 0x10000},
2101 {"default-config", 0x7e0000, 0x10000},
2102 {"radio", 0x7f0000, 0x10000},
2106 .first_sysupgrade_partition
= "os-image",
2107 .last_sysupgrade_partition
= "file-system"
2110 /** Firmware layout for the RE200 v4 */
2116 "{product_name:RE200,product_ver:4.0.0,special_id:00000000}\n"
2117 "{product_name:RE200,product_ver:4.0.0,special_id:45550000}\n"
2118 "{product_name:RE200,product_ver:4.0.0,special_id:4A500000}\n"
2119 "{product_name:RE200,product_ver:4.0.0,special_id:4B520000}\n"
2120 "{product_name:RE200,product_ver:4.0.0,special_id:43410000}\n"
2121 "{product_name:RE200,product_ver:4.0.0,special_id:41550000}\n"
2122 "{product_name:RE200,product_ver:4.0.0,special_id:42520000}\n"
2123 "{product_name:RE200,product_ver:4.0.0,special_id:55530000}\n"
2124 "{product_name:RE200,product_ver:4.0.0,special_id:41520000}\n"
2125 "{product_name:RE200,product_ver:4.0.0,special_id:52550000}\n"
2126 "{product_name:RE200,product_ver:4.0.0,special_id:54570000}\n"
2127 "{product_name:RE200,product_ver:4.0.0,special_id:45530000}\n"
2128 "{product_name:RE200,product_ver:4.0.0,special_id:49440000}\n"
2129 "{product_name:RE200,product_ver:4.0.0,special_id:45470000}\n",
2131 .soft_ver
= "soft_ver:1.1.0\n",
2134 {"fs-uboot", 0x00000, 0x20000},
2135 {"firmware", 0x20000, 0x7a0000},
2136 {"partition-table", 0x7c0000, 0x02000},
2137 {"default-mac", 0x7c2000, 0x00020},
2138 {"pin", 0x7c2100, 0x00020},
2139 {"product-info", 0x7c3100, 0x01000},
2140 {"soft-version", 0x7c4200, 0x01000},
2141 {"support-list", 0x7c5200, 0x01000},
2142 {"profile", 0x7c6200, 0x08000},
2143 {"config-info", 0x7ce200, 0x00400},
2144 {"user-config", 0x7d0000, 0x10000},
2145 {"default-config", 0x7e0000, 0x10000},
2146 {"radio", 0x7f0000, 0x10000},
2150 .first_sysupgrade_partition
= "os-image",
2151 .last_sysupgrade_partition
= "file-system"
2154 /** Firmware layout for the RE220 v2 */
2160 "{product_name:RE220,product_ver:2.0.0,special_id:00000000}\n"
2161 "{product_name:RE220,product_ver:2.0.0,special_id:41520000}\n"
2162 "{product_name:RE220,product_ver:2.0.0,special_id:41550000}\n"
2163 "{product_name:RE220,product_ver:2.0.0,special_id:42520000}\n"
2164 "{product_name:RE220,product_ver:2.0.0,special_id:43410000}\n"
2165 "{product_name:RE220,product_ver:2.0.0,special_id:45530000}\n"
2166 "{product_name:RE220,product_ver:2.0.0,special_id:45550000}\n"
2167 "{product_name:RE220,product_ver:2.0.0,special_id:49440000}\n"
2168 "{product_name:RE220,product_ver:2.0.0,special_id:4a500000}\n"
2169 "{product_name:RE220,product_ver:2.0.0,special_id:4b520000}\n"
2170 "{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n"
2171 "{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n"
2172 "{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n",
2177 {"fs-uboot", 0x00000, 0x20000},
2178 {"firmware", 0x20000, 0x7a0000},
2179 {"partition-table", 0x7c0000, 0x02000},
2180 {"default-mac", 0x7c2000, 0x00020},
2181 {"pin", 0x7c2100, 0x00020},
2182 {"product-info", 0x7c3100, 0x01000},
2183 {"soft-version", 0x7c4200, 0x01000},
2184 {"support-list", 0x7c5200, 0x01000},
2185 {"profile", 0x7c6200, 0x08000},
2186 {"config-info", 0x7ce200, 0x00400},
2187 {"user-config", 0x7d0000, 0x10000},
2188 {"default-config", 0x7e0000, 0x10000},
2189 {"radio", 0x7f0000, 0x10000},
2193 .first_sysupgrade_partition
= "os-image",
2194 .last_sysupgrade_partition
= "file-system"
2197 /** Firmware layout for the RE305 v1 */
2203 "{product_name:RE305,product_ver:1.0.0,special_id:45550000}\n"
2204 "{product_name:RE305,product_ver:1.0.0,special_id:55530000}\n"
2205 "{product_name:RE305,product_ver:1.0.0,special_id:4a500000}\n"
2206 "{product_name:RE305,product_ver:1.0.0,special_id:42520000}\n"
2207 "{product_name:RE305,product_ver:1.0.0,special_id:4b520000}\n"
2208 "{product_name:RE305,product_ver:1.0.0,special_id:41550000}\n"
2209 "{product_name:RE305,product_ver:1.0.0,special_id:43410000}\n",
2214 {"fs-uboot", 0x00000, 0x20000},
2215 {"firmware", 0x20000, 0x5e0000},
2216 {"partition-table", 0x600000, 0x02000},
2217 {"default-mac", 0x610000, 0x00020},
2218 {"pin", 0x610100, 0x00020},
2219 {"product-info", 0x611100, 0x01000},
2220 {"soft-version", 0x620000, 0x01000},
2221 {"support-list", 0x621000, 0x01000},
2222 {"profile", 0x622000, 0x08000},
2223 {"user-config", 0x630000, 0x10000},
2224 {"default-config", 0x640000, 0x10000},
2225 {"radio", 0x7f0000, 0x10000},
2229 .first_sysupgrade_partition
= "os-image",
2230 .last_sysupgrade_partition
= "file-system"
2233 /** Firmware layout for the RE350 v1 */
2239 "{product_name:RE350,product_ver:1.0.0,special_id:45550000}\n"
2240 "{product_name:RE350,product_ver:1.0.0,special_id:00000000}\n"
2241 "{product_name:RE350,product_ver:1.0.0,special_id:41550000}\n"
2242 "{product_name:RE350,product_ver:1.0.0,special_id:55530000}\n"
2243 "{product_name:RE350,product_ver:1.0.0,special_id:43410000}\n"
2244 "{product_name:RE350,product_ver:1.0.0,special_id:4b520000}\n"
2245 "{product_name:RE350,product_ver:1.0.0,special_id:4a500000}\n",
2249 /** We're using a dynamic kernel/rootfs split here */
2251 {"fs-uboot", 0x00000, 0x20000},
2252 {"firmware", 0x20000, 0x5e0000},
2253 {"partition-table", 0x600000, 0x02000},
2254 {"default-mac", 0x610000, 0x00020},
2255 {"pin", 0x610100, 0x00020},
2256 {"product-info", 0x611100, 0x01000},
2257 {"soft-version", 0x620000, 0x01000},
2258 {"support-list", 0x621000, 0x01000},
2259 {"profile", 0x622000, 0x08000},
2260 {"user-config", 0x630000, 0x10000},
2261 {"default-config", 0x640000, 0x10000},
2262 {"radio", 0x7f0000, 0x10000},
2266 .first_sysupgrade_partition
= "os-image",
2267 .last_sysupgrade_partition
= "file-system"
2270 /** Firmware layout for the RE350K v1 */
2276 "{product_name:RE350K,product_ver:1.0.0,special_id:00000000,product_region:US}\n",
2280 /** We're using a dynamic kernel/rootfs split here */
2282 {"fs-uboot", 0x00000, 0x20000},
2283 {"firmware", 0x20000, 0xd70000},
2284 {"partition-table", 0xd90000, 0x02000},
2285 {"default-mac", 0xda0000, 0x00020},
2286 {"pin", 0xda0100, 0x00020},
2287 {"product-info", 0xda1100, 0x01000},
2288 {"soft-version", 0xdb0000, 0x01000},
2289 {"support-list", 0xdb1000, 0x01000},
2290 {"profile", 0xdb2000, 0x08000},
2291 {"user-config", 0xdc0000, 0x10000},
2292 {"default-config", 0xdd0000, 0x10000},
2293 {"device-id", 0xde0000, 0x00108},
2294 {"radio", 0xff0000, 0x10000},
2298 .first_sysupgrade_partition
= "os-image",
2299 .last_sysupgrade_partition
= "file-system"
2302 /** Firmware layout for the RE355 */
2308 "{product_name:RE355,product_ver:1.0.0,special_id:00000000}\r\n"
2309 "{product_name:RE355,product_ver:1.0.0,special_id:55530000}\r\n"
2310 "{product_name:RE355,product_ver:1.0.0,special_id:45550000}\r\n"
2311 "{product_name:RE355,product_ver:1.0.0,special_id:4A500000}\r\n"
2312 "{product_name:RE355,product_ver:1.0.0,special_id:43410000}\r\n"
2313 "{product_name:RE355,product_ver:1.0.0,special_id:41550000}\r\n"
2314 "{product_name:RE355,product_ver:1.0.0,special_id:4B520000}\r\n"
2315 "{product_name:RE355,product_ver:1.0.0,special_id:55534100}\r\n",
2319 /* We're using a dynamic kernel/rootfs split here */
2321 {"fs-uboot", 0x00000, 0x20000},
2322 {"firmware", 0x20000, 0x5e0000},
2323 {"partition-table", 0x600000, 0x02000},
2324 {"default-mac", 0x610000, 0x00020},
2325 {"pin", 0x610100, 0x00020},
2326 {"product-info", 0x611100, 0x01000},
2327 {"soft-version", 0x620000, 0x01000},
2328 {"support-list", 0x621000, 0x01000},
2329 {"profile", 0x622000, 0x08000},
2330 {"user-config", 0x630000, 0x10000},
2331 {"default-config", 0x640000, 0x10000},
2332 {"radio", 0x7f0000, 0x10000},
2336 .first_sysupgrade_partition
= "os-image",
2337 .last_sysupgrade_partition
= "file-system"
2340 /** Firmware layout for the RE450 */
2346 "{product_name:RE450,product_ver:1.0.0,special_id:00000000}\r\n"
2347 "{product_name:RE450,product_ver:1.0.0,special_id:55530000}\r\n"
2348 "{product_name:RE450,product_ver:1.0.0,special_id:45550000}\r\n"
2349 "{product_name:RE450,product_ver:1.0.0,special_id:4A500000}\r\n"
2350 "{product_name:RE450,product_ver:1.0.0,special_id:43410000}\r\n"
2351 "{product_name:RE450,product_ver:1.0.0,special_id:41550000}\r\n"
2352 "{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
2353 "{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
2357 /** We're using a dynamic kernel/rootfs split here */
2359 {"fs-uboot", 0x00000, 0x20000},
2360 {"firmware", 0x20000, 0x5e0000},
2361 {"partition-table", 0x600000, 0x02000},
2362 {"default-mac", 0x610000, 0x00020},
2363 {"pin", 0x610100, 0x00020},
2364 {"product-info", 0x611100, 0x01000},
2365 {"soft-version", 0x620000, 0x01000},
2366 {"support-list", 0x621000, 0x01000},
2367 {"profile", 0x622000, 0x08000},
2368 {"user-config", 0x630000, 0x10000},
2369 {"default-config", 0x640000, 0x10000},
2370 {"radio", 0x7f0000, 0x10000},
2374 .first_sysupgrade_partition
= "os-image",
2375 .last_sysupgrade_partition
= "file-system"
2378 /** Firmware layout for the RE450 v2 */
2384 "{product_name:RE450,product_ver:2.0.0,special_id:00000000}\r\n"
2385 "{product_name:RE450,product_ver:2.0.0,special_id:55530000}\r\n"
2386 "{product_name:RE450,product_ver:2.0.0,special_id:45550000}\r\n"
2387 "{product_name:RE450,product_ver:2.0.0,special_id:4A500000}\r\n"
2388 "{product_name:RE450,product_ver:2.0.0,special_id:43410000}\r\n"
2389 "{product_name:RE450,product_ver:2.0.0,special_id:41550000}\r\n"
2390 "{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n"
2391 "{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n"
2392 "{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n",
2396 /* We're using a dynamic kernel/rootfs split here */
2398 {"fs-uboot", 0x00000, 0x20000},
2399 {"firmware", 0x20000, 0x5e0000},
2400 {"partition-table", 0x600000, 0x02000},
2401 {"default-mac", 0x610000, 0x00020},
2402 {"pin", 0x610100, 0x00020},
2403 {"product-info", 0x611100, 0x01000},
2404 {"soft-version", 0x620000, 0x01000},
2405 {"support-list", 0x621000, 0x01000},
2406 {"profile", 0x622000, 0x08000},
2407 {"user-config", 0x630000, 0x10000},
2408 {"default-config", 0x640000, 0x10000},
2409 {"radio", 0x7f0000, 0x10000},
2413 .first_sysupgrade_partition
= "os-image",
2414 .last_sysupgrade_partition
= "file-system"
2417 /** Firmware layout for the RE450 v3 */
2423 "{product_name:RE450,product_ver:3.0.0,special_id:00000000}\r\n"
2424 "{product_name:RE450,product_ver:3.0.0,special_id:55530000}\r\n"
2425 "{product_name:RE450,product_ver:3.0.0,special_id:45550000}\r\n"
2426 "{product_name:RE450,product_ver:3.0.0,special_id:4A500000}\r\n"
2427 "{product_name:RE450,product_ver:3.0.0,special_id:43410000}\r\n"
2428 "{product_name:RE450,product_ver:3.0.0,special_id:41550000}\r\n"
2429 "{product_name:RE450,product_ver:3.0.0,special_id:41530000}\r\n"
2430 "{product_name:RE450,product_ver:3.0.0,special_id:4B520000}\r\n"
2431 "{product_name:RE450,product_ver:3.0.0,special_id:42520000}\r\n",
2435 /* We're using a dynamic kernel/rootfs split here */
2437 {"fs-uboot", 0x00000, 0x20000},
2438 {"default-mac", 0x20000, 0x00020},
2439 {"pin", 0x20020, 0x00020},
2440 {"product-info", 0x21000, 0x01000},
2441 {"partition-table", 0x22000, 0x02000},
2442 {"soft-version", 0x24000, 0x01000},
2443 {"support-list", 0x25000, 0x01000},
2444 {"profile", 0x26000, 0x08000},
2445 {"user-config", 0x2e000, 0x10000},
2446 {"default-config", 0x3e000, 0x10000},
2447 {"config-info", 0x4e000, 0x00400},
2448 {"firmware", 0x50000, 0x7a0000},
2449 {"radio", 0x7f0000, 0x10000},
2453 .first_sysupgrade_partition
= "os-image",
2454 .last_sysupgrade_partition
= "file-system"
2457 /** Firmware layout for the RE455 v1 */
2463 "{product_name:RE455,product_ver:1.0.0,special_id:00000000}\r\n"
2464 "{product_name:RE455,product_ver:1.0.0,special_id:55530000}\r\n"
2465 "{product_name:RE455,product_ver:1.0.0,special_id:45550000}\r\n"
2466 "{product_name:RE455,product_ver:1.0.0,special_id:4A500000}\r\n"
2467 "{product_name:RE455,product_ver:1.0.0,special_id:43410000}\r\n"
2468 "{product_name:RE455,product_ver:1.0.0,special_id:41550000}\r\n"
2469 "{product_name:RE455,product_ver:1.0.0,special_id:41530000}\r\n"
2470 "{product_name:RE455,product_ver:1.0.0,special_id:4B520000}\r\n"
2471 "{product_name:RE455,product_ver:1.0.0,special_id:42520000}\r\n",
2475 /* We're using a dynamic kernel/rootfs split here */
2477 {"fs-uboot", 0x00000, 0x20000},
2478 {"default-mac", 0x20000, 0x00020},
2479 {"pin", 0x20020, 0x00020},
2480 {"product-info", 0x21000, 0x01000},
2481 {"partition-table", 0x22000, 0x02000},
2482 {"soft-version", 0x24000, 0x01000},
2483 {"support-list", 0x25000, 0x01000},
2484 {"profile", 0x26000, 0x08000},
2485 {"user-config", 0x2e000, 0x10000},
2486 {"default-config", 0x3e000, 0x10000},
2487 {"config-info", 0x4e000, 0x00400},
2488 {"firmware", 0x50000, 0x7a0000},
2489 {"radio", 0x7f0000, 0x10000},
2493 .first_sysupgrade_partition
= "os-image",
2494 .last_sysupgrade_partition
= "file-system"
2497 /** Firmware layout for the RE500 */
2503 "{product_name:RE500,product_ver:1.0.0,special_id:00000000}\r\n"
2504 "{product_name:RE500,product_ver:1.0.0,special_id:55530000}\r\n"
2505 "{product_name:RE500,product_ver:1.0.0,special_id:45550000}\r\n"
2506 "{product_name:RE500,product_ver:1.0.0,special_id:4A500000}\r\n"
2507 "{product_name:RE500,product_ver:1.0.0,special_id:43410000}\r\n"
2508 "{product_name:RE500,product_ver:1.0.0,special_id:41550000}\r\n"
2509 "{product_name:RE500,product_ver:1.0.0,special_id:41530000}\r\n",
2513 /* We're using a dynamic kernel/rootfs split here */
2515 {"fs-uboot", 0x00000, 0x20000},
2516 {"firmware", 0x20000, 0xde0000},
2517 {"partition-table", 0xe00000, 0x02000},
2518 {"default-mac", 0xe10000, 0x00020},
2519 {"pin", 0xe10100, 0x00020},
2520 {"product-info", 0xe11100, 0x01000},
2521 {"soft-version", 0xe20000, 0x01000},
2522 {"support-list", 0xe21000, 0x01000},
2523 {"profile", 0xe22000, 0x08000},
2524 {"user-config", 0xe30000, 0x10000},
2525 {"default-config", 0xe40000, 0x10000},
2526 {"radio", 0xff0000, 0x10000},
2530 .first_sysupgrade_partition
= "os-image",
2531 .last_sysupgrade_partition
= "file-system"
2534 /** Firmware layout for the RE650 */
2540 "{product_name:RE650,product_ver:1.0.0,special_id:00000000}\r\n"
2541 "{product_name:RE650,product_ver:1.0.0,special_id:55530000}\r\n"
2542 "{product_name:RE650,product_ver:1.0.0,special_id:45550000}\r\n"
2543 "{product_name:RE650,product_ver:1.0.0,special_id:4A500000}\r\n"
2544 "{product_name:RE650,product_ver:1.0.0,special_id:43410000}\r\n"
2545 "{product_name:RE650,product_ver:1.0.0,special_id:41550000}\r\n"
2546 "{product_name:RE650,product_ver:1.0.0,special_id:41530000}\r\n",
2550 /* We're using a dynamic kernel/rootfs split here */
2552 {"fs-uboot", 0x00000, 0x20000},
2553 {"firmware", 0x20000, 0xde0000},
2554 {"partition-table", 0xe00000, 0x02000},
2555 {"default-mac", 0xe10000, 0x00020},
2556 {"pin", 0xe10100, 0x00020},
2557 {"product-info", 0xe11100, 0x01000},
2558 {"soft-version", 0xe20000, 0x01000},
2559 {"support-list", 0xe21000, 0x01000},
2560 {"profile", 0xe22000, 0x08000},
2561 {"user-config", 0xe30000, 0x10000},
2562 {"default-config", 0xe40000, 0x10000},
2563 {"radio", 0xff0000, 0x10000},
2567 .first_sysupgrade_partition
= "os-image",
2568 .last_sysupgrade_partition
= "file-system"
2574 #define error(_ret, _errno, _str, ...) \
2576 fprintf(stderr, _str ": %s\n", ## __VA_ARGS__, \
2577 strerror(_errno)); \
2583 /** Stores a uint32 as big endian */
2584 static inline void put32(uint8_t *buf
, uint32_t val
) {
2591 static inline bool meta_partition_should_pad(enum partition_trail_value pv
)
2593 return (pv
>= 0) && (pv
<= PART_TRAIL_MAX
);
2596 /** Allocate a padded meta partition with a correctly initialised header
2597 * If the `data` pointer is NULL, then the required space is only allocated,
2598 * otherwise `data_len` bytes will be copied from `data` into the partition
2600 static struct image_partition_entry
init_meta_partition_entry(
2601 const char *name
, const void *data
, uint32_t data_len
,
2602 enum partition_trail_value pad_value
)
2604 uint32_t total_len
= sizeof(struct meta_header
) + data_len
;
2605 if (meta_partition_should_pad(pad_value
))
2608 struct image_partition_entry entry
= {
2611 .data
= malloc(total_len
)
2614 error(1, errno
, "failed to allocate meta partition entry");
2616 struct meta_header
*header
= (struct meta_header
*)entry
.data
;
2617 header
->length
= htonl(data_len
);
2621 memcpy(entry
.data
+sizeof(*header
), data
, data_len
);
2623 if (meta_partition_should_pad(pad_value
))
2624 entry
.data
[total_len
- 1] = (uint8_t) pad_value
;
2629 /** Allocates a new image partition */
2630 static struct image_partition_entry
alloc_image_partition(const char *name
, size_t len
) {
2631 struct image_partition_entry entry
= {name
, len
, malloc(len
)};
2633 error(1, errno
, "malloc");
2638 /** Frees an image partition */
2639 static void free_image_partition(struct image_partition_entry entry
) {
2643 static time_t source_date_epoch
= -1;
2644 static void set_source_date_epoch() {
2645 char *env
= getenv("SOURCE_DATE_EPOCH");
2649 source_date_epoch
= strtoull(env
, &endptr
, 10);
2650 if (errno
|| (endptr
&& *endptr
!= '\0')) {
2651 fprintf(stderr
, "Invalid SOURCE_DATE_EPOCH");
2657 /** Generates the partition-table partition */
2658 static struct image_partition_entry
make_partition_table(const struct flash_partition_entry
*p
) {
2659 struct image_partition_entry entry
= alloc_image_partition("partition-table", 0x800);
2661 char *s
= (char *)entry
.data
, *end
= (char *)(s
+entry
.size
);
2669 for (i
= 0; p
[i
].name
; i
++) {
2671 size_t w
= snprintf(s
, len
, "partition %s base 0x%05x size 0x%05x\n", p
[i
].name
, p
[i
].base
, p
[i
].size
);
2674 error(1, 0, "flash partition table overflow?");
2681 memset(s
, 0xff, end
-s
);
2687 /** Generates a binary-coded decimal representation of an integer in the range [0, 99] */
2688 static inline uint8_t bcd(uint8_t v
) {
2689 return 0x10 * (v
/10) + v
%10;
2693 /** Generates the soft-version partition */
2694 static struct image_partition_entry
make_soft_version(
2695 const struct device_info
*info
, uint32_t rev
)
2697 /** If an info string is provided, use this instead of
2698 * the structured data, and include the null-termination */
2699 if (info
->soft_ver
) {
2700 uint32_t len
= strlen(info
->soft_ver
) + 1;
2701 return init_meta_partition_entry("soft-version",
2702 info
->soft_ver
, len
, info
->part_trail
);
2707 if (source_date_epoch
!= -1)
2708 t
= source_date_epoch
;
2709 else if (time(&t
) == (time_t)(-1))
2710 error(1, errno
, "time");
2712 struct tm
*tm
= gmtime(&t
);
2714 struct soft_version s
= {
2721 .year_hi
= bcd((1900+tm
->tm_year
)/100),
2722 .year_lo
= bcd(tm
->tm_year
%100),
2723 .month
= bcd(tm
->tm_mon
+1),
2724 .day
= bcd(tm
->tm_mday
),
2727 .compat_level
= htonl(info
->soft_ver_compat_level
)
2730 if (info
->soft_ver_compat_level
== 0)
2731 return init_meta_partition_entry("soft-version", &s
,
2732 (uint8_t *)(&s
.compat_level
) - (uint8_t *)(&s
),
2735 return init_meta_partition_entry("soft-version", &s
,
2736 sizeof(s
), info
->part_trail
);
2739 /** Generates the support-list partition */
2740 static struct image_partition_entry
make_support_list(
2741 const struct device_info
*info
)
2743 uint32_t len
= strlen(info
->support_list
);
2744 return init_meta_partition_entry("support-list", info
->support_list
,
2745 len
, info
->part_trail
);
2748 /** Partition with extra-para data */
2749 static struct image_partition_entry
make_extra_para(
2750 const struct device_info
*info
, const uint8_t *extra_para
, size_t len
)
2752 return init_meta_partition_entry("extra-para", extra_para
, len
,
2756 /** Creates a new image partition with an arbitrary name from a file */
2757 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
) {
2758 struct stat statbuf
;
2760 if (stat(filename
, &statbuf
) < 0)
2761 error(1, errno
, "unable to stat file `%s'", filename
);
2763 size_t len
= statbuf
.st_size
;
2765 if (add_jffs2_eof
) {
2766 if (file_system_partition
)
2767 len
= ALIGN(len
+ file_system_partition
->base
, 0x10000) + sizeof(jffs2_eof_mark
) - file_system_partition
->base
;
2769 len
= ALIGN(len
, 0x10000) + sizeof(jffs2_eof_mark
);
2772 struct image_partition_entry entry
= alloc_image_partition(part_name
, len
);
2774 FILE *file
= fopen(filename
, "rb");
2776 error(1, errno
, "unable to open file `%s'", filename
);
2778 if (fread(entry
.data
, statbuf
.st_size
, 1, file
) != 1)
2779 error(1, errno
, "unable to read file `%s'", filename
);
2781 if (add_jffs2_eof
) {
2782 uint8_t *eof
= entry
.data
+ statbuf
.st_size
, *end
= entry
.data
+entry
.size
;
2784 memset(eof
, 0xff, end
- eof
- sizeof(jffs2_eof_mark
));
2785 memcpy(end
- sizeof(jffs2_eof_mark
), jffs2_eof_mark
, sizeof(jffs2_eof_mark
));
2794 Copies a list of image partitions into an image buffer and generates the image partition table while doing so
2796 Example image partition table:
2798 fwup-ptn partition-table base 0x00800 size 0x00800
2799 fwup-ptn os-image base 0x01000 size 0x113b45
2800 fwup-ptn file-system base 0x114b45 size 0x1d0004
2801 fwup-ptn support-list base 0x2e4b49 size 0x000d1
2803 Each line of the partition table is terminated with the bytes 09 0d 0a ("\t\r\n"),
2804 the end of the partition table is marked with a zero byte.
2806 The firmware image must contain at least the partition-table and support-list partitions
2807 to be accepted. There aren't any alignment constraints for the image partitions.
2809 The partition-table partition contains the actual flash layout; partitions
2810 from the image partition table are mapped to the corresponding flash partitions during
2811 the firmware upgrade. The support-list partition contains a list of devices supported by
2814 The base offsets in the firmware partition table are relative to the end
2815 of the vendor information block, so the partition-table partition will
2816 actually start at offset 0x1814 of the image.
2818 I think partition-table must be the first partition in the firmware image.
2820 static void put_partitions(uint8_t *buffer
, const struct flash_partition_entry
*flash_parts
, const struct image_partition_entry
*parts
) {
2822 char *image_pt
= (char *)buffer
, *end
= image_pt
+ 0x800;
2824 size_t base
= 0x800;
2825 for (i
= 0; parts
[i
].name
; i
++) {
2826 for (j
= 0; flash_parts
[j
].name
; j
++) {
2827 if (!strcmp(flash_parts
[j
].name
, parts
[i
].name
)) {
2828 if (parts
[i
].size
> flash_parts
[j
].size
)
2829 error(1, 0, "%s partition too big (more than %u bytes)", flash_parts
[j
].name
, (unsigned)flash_parts
[j
].size
);
2834 assert(flash_parts
[j
].name
);
2836 memcpy(buffer
+ base
, parts
[i
].data
, parts
[i
].size
);
2838 size_t len
= end
-image_pt
;
2839 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
);
2842 error(1, 0, "image partition table overflow?");
2846 base
+= parts
[i
].size
;
2850 /** Generates and writes the image MD5 checksum */
2851 static void put_md5(uint8_t *md5
, uint8_t *buffer
, unsigned int len
) {
2855 MD5_Update(&ctx
, md5_salt
, (unsigned int)sizeof(md5_salt
));
2856 MD5_Update(&ctx
, buffer
, len
);
2857 MD5_Final(md5
, &ctx
);
2862 Generates the firmware image in factory format
2868 0000-0003 Image size (4 bytes, big endian)
2869 0004-0013 MD5 hash (hash of a 16 byte salt and the image data starting with byte 0x14)
2870 0014-0017 Vendor information length (without padding) (4 bytes, big endian)
2871 0018-1013 Vendor information (4092 bytes, padded with 0xff; there seem to be older
2872 (VxWorks-based) TP-LINK devices which use a smaller vendor information block)
2873 1014-1813 Image partition table (2048 bytes, padded with 0xff)
2874 1814-xxxx Firmware partitions
2876 static void * generate_factory_image(struct device_info
*info
, const struct image_partition_entry
*parts
, size_t *len
) {
2880 for (i
= 0; parts
[i
].name
; i
++)
2881 *len
+= parts
[i
].size
;
2883 uint8_t *image
= malloc(*len
);
2885 error(1, errno
, "malloc");
2887 memset(image
, 0xff, *len
);
2891 size_t vendor_len
= strlen(info
->vendor
);
2892 put32(image
+0x14, vendor_len
);
2893 memcpy(image
+0x18, info
->vendor
, vendor_len
);
2896 put_partitions(image
+ 0x1014, info
->partitions
, parts
);
2897 put_md5(image
+0x04, image
+0x14, *len
-0x14);
2903 Generates the firmware image in sysupgrade format
2905 This makes some assumptions about the provided flash and image partition tables and
2906 should be generalized when TP-LINK starts building its safeloader into hardware with
2907 different flash layouts.
2909 static void * generate_sysupgrade_image(struct device_info
*info
, const struct image_partition_entry
*image_parts
, size_t *len
) {
2911 size_t flash_first_partition_index
= 0;
2912 size_t flash_last_partition_index
= 0;
2913 const struct flash_partition_entry
*flash_first_partition
= NULL
;
2914 const struct flash_partition_entry
*flash_last_partition
= NULL
;
2915 const struct image_partition_entry
*image_last_partition
= NULL
;
2917 /** Find first and last partitions */
2918 for (i
= 0; info
->partitions
[i
].name
; i
++) {
2919 if (!strcmp(info
->partitions
[i
].name
, info
->first_sysupgrade_partition
)) {
2920 flash_first_partition
= &info
->partitions
[i
];
2921 flash_first_partition_index
= i
;
2922 } else if (!strcmp(info
->partitions
[i
].name
, info
->last_sysupgrade_partition
)) {
2923 flash_last_partition
= &info
->partitions
[i
];
2924 flash_last_partition_index
= i
;
2928 assert(flash_first_partition
&& flash_last_partition
);
2929 assert(flash_first_partition_index
< flash_last_partition_index
);
2931 /** Find last partition from image to calculate needed size */
2932 for (i
= 0; image_parts
[i
].name
; i
++) {
2933 if (!strcmp(image_parts
[i
].name
, info
->last_sysupgrade_partition
)) {
2934 image_last_partition
= &image_parts
[i
];
2939 assert(image_last_partition
);
2941 *len
= flash_last_partition
->base
- flash_first_partition
->base
+ image_last_partition
->size
;
2943 uint8_t *image
= malloc(*len
);
2945 error(1, errno
, "malloc");
2947 memset(image
, 0xff, *len
);
2949 for (i
= flash_first_partition_index
; i
<= flash_last_partition_index
; i
++) {
2950 for (j
= 0; image_parts
[j
].name
; j
++) {
2951 if (!strcmp(info
->partitions
[i
].name
, image_parts
[j
].name
)) {
2952 if (image_parts
[j
].size
> info
->partitions
[i
].size
)
2953 error(1, 0, "%s partition too big (more than %u bytes)", info
->partitions
[i
].name
, (unsigned)info
->partitions
[i
].size
);
2954 memcpy(image
+ info
->partitions
[i
].base
- flash_first_partition
->base
, image_parts
[j
].data
, image_parts
[j
].size
);
2958 assert(image_parts
[j
].name
);
2965 /** Generates an image according to a given layout and writes it to a file */
2966 static void build_image(const char *output
,
2967 const char *kernel_image
,
2968 const char *rootfs_image
,
2972 struct device_info
*info
) {
2976 struct image_partition_entry parts
[7] = {};
2978 struct flash_partition_entry
*firmware_partition
= NULL
;
2979 struct flash_partition_entry
*os_image_partition
= NULL
;
2980 struct flash_partition_entry
*file_system_partition
= NULL
;
2981 size_t firmware_partition_index
= 0;
2983 for (i
= 0; info
->partitions
[i
].name
; i
++) {
2984 if (!strcmp(info
->partitions
[i
].name
, "firmware"))
2986 firmware_partition
= &info
->partitions
[i
];
2987 firmware_partition_index
= i
;
2991 if (firmware_partition
)
2993 os_image_partition
= &info
->partitions
[firmware_partition_index
];
2994 file_system_partition
= &info
->partitions
[firmware_partition_index
+ 1];
2997 if (stat(kernel_image
, &kernel
) < 0)
2998 error(1, errno
, "unable to stat file `%s'", kernel_image
);
3000 if (kernel
.st_size
> firmware_partition
->size
)
3001 error(1, 0, "kernel overflowed firmware partition\n");
3003 for (i
= MAX_PARTITIONS
-1; i
>= firmware_partition_index
+ 1; i
--)
3004 info
->partitions
[i
+1] = info
->partitions
[i
];
3006 file_system_partition
->name
= "file-system";
3007 file_system_partition
->base
= firmware_partition
->base
+ kernel
.st_size
;
3009 /* Align partition start to erase blocks for factory images only */
3011 file_system_partition
->base
= ALIGN(firmware_partition
->base
+ kernel
.st_size
, 0x10000);
3013 file_system_partition
->size
= firmware_partition
->size
- file_system_partition
->base
;
3015 os_image_partition
->name
= "os-image";
3016 os_image_partition
->size
= kernel
.st_size
;
3019 parts
[0] = make_partition_table(info
->partitions
);
3020 parts
[1] = make_soft_version(info
, rev
);
3021 parts
[2] = make_support_list(info
);
3022 parts
[3] = read_file("os-image", kernel_image
, false, NULL
);
3023 parts
[4] = read_file("file-system", rootfs_image
, add_jffs2_eof
, file_system_partition
);
3025 /* Some devices need the extra-para partition to accept the firmware */
3026 if (strcasecmp(info
->id
, "ARCHER-A6-V3") == 0 ||
3027 strcasecmp(info
->id
, "ARCHER-A7-V5") == 0 ||
3028 strcasecmp(info
->id
, "ARCHER-C2-V3") == 0 ||
3029 strcasecmp(info
->id
, "ARCHER-C7-V4") == 0 ||
3030 strcasecmp(info
->id
, "ARCHER-C7-V5") == 0 ||
3031 strcasecmp(info
->id
, "ARCHER-C25-V1") == 0 ||
3032 strcasecmp(info
->id
, "ARCHER-C59-V2") == 0 ||
3033 strcasecmp(info
->id
, "ARCHER-C60-V2") == 0 ||
3034 strcasecmp(info
->id
, "ARCHER-C60-V3") == 0 ||
3035 strcasecmp(info
->id
, "ARCHER-C6U-V1") == 0 ||
3036 strcasecmp(info
->id
, "ARCHER-C6-V3") == 0 ||
3037 strcasecmp(info
->id
, "TLWR1043NV5") == 0) {
3038 const uint8_t extra_para
[2] = {0x01, 0x00};
3039 parts
[5] = make_extra_para(info
, extra_para
,
3040 sizeof(extra_para
));
3041 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2") == 0 ||
3042 strcasecmp(info
->id
, "TL-WA1201-V2") == 0) {
3043 const uint8_t extra_para
[2] = {0x00, 0x01};
3044 parts
[5] = make_extra_para(info
, extra_para
,
3045 sizeof(extra_para
));
3046 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2-US") == 0 ||
3047 strcasecmp(info
->id
, "EAP245-V3") == 0) {
3048 const uint8_t extra_para
[2] = {0x01, 0x01};
3049 parts
[5] = make_extra_para(info
, extra_para
,
3050 sizeof(extra_para
));
3056 image
= generate_sysupgrade_image(info
, parts
, &len
);
3058 image
= generate_factory_image(info
, parts
, &len
);
3060 FILE *file
= fopen(output
, "wb");
3062 error(1, errno
, "unable to open output file");
3064 if (fwrite(image
, len
, 1, file
) != 1)
3065 error(1, 0, "unable to write output file");
3071 for (i
= 0; parts
[i
].name
; i
++)
3072 free_image_partition(parts
[i
]);
3076 static void usage(const char *argv0
) {
3078 "Usage: %s [OPTIONS...]\n"
3081 " -h show this help\n"
3083 "Info about an image:\n"
3084 " -i <file> input file to read from\n"
3085 "Create a new image:\n"
3086 " -B <board> create image for the board specified with <board>\n"
3087 " -k <file> read kernel image from the file <file>\n"
3088 " -r <file> read rootfs image from the file <file>\n"
3089 " -o <file> write output to the file <file>\n"
3090 " -V <rev> sets the revision number to <rev>\n"
3091 " -j add jffs2 end-of-filesystem markers\n"
3092 " -S create sysupgrade instead of factory image\n"
3093 "Extract an old image:\n"
3094 " -x <file> extract all oem firmware partition\n"
3095 " -d <dir> destination to extract the firmware partition\n"
3096 " -z <file> convert an oem firmware into a sysupgade file. Use -o for output file\n",
3102 static struct device_info
*find_board(const char *id
)
3104 struct device_info
*board
= NULL
;
3106 for (board
= boards
; board
->id
!= NULL
; board
++)
3107 if (strcasecmp(id
, board
->id
) == 0)
3113 static int add_flash_partition(
3114 struct flash_partition_entry
*part_list
,
3121 /* check if the list has a free entry */
3122 for (ptr
= 0; ptr
< max_entries
; ptr
++, part_list
++) {
3123 if (part_list
->name
== NULL
&&
3124 part_list
->base
== 0 &&
3125 part_list
->size
== 0)
3129 if (ptr
== max_entries
) {
3130 error(1, 0, "No free flash part entry available.");
3133 part_list
->name
= calloc(1, strlen(name
) + 1);
3134 if (!part_list
->name
) {
3135 error(1, 0, "Unable to allocate memory");
3138 memcpy((char *)part_list
->name
, name
, strlen(name
));
3139 part_list
->base
= base
;
3140 part_list
->size
= size
;
3145 /** read the partition table into struct flash_partition_entry */
3146 static int read_partition_table(
3147 FILE *file
, long offset
,
3148 struct flash_partition_entry
*entries
, size_t max_entries
,
3153 const char *parthdr
= NULL
;
3154 const char *fwuphdr
= "fwup-ptn";
3155 const char *flashhdr
= "partition";
3157 /* TODO: search for the partition table */
3167 error(1, 0, "Invalid partition table");
3170 if (fseek(file
, offset
, SEEK_SET
) < 0)
3171 error(1, errno
, "Can not seek in the firmware");
3173 if (fread(buf
, 2048, 1, file
) != 1)
3174 error(1, errno
, "Can not read fwup-ptn from the firmware");
3178 /* look for the partition header */
3179 if (memcmp(buf
, parthdr
, strlen(parthdr
)) != 0) {
3180 fprintf(stderr
, "DEBUG: can not find fwuphdr\n");
3185 end
= buf
+ sizeof(buf
);
3186 while ((ptr
+ strlen(parthdr
)) < end
&&
3187 memcmp(ptr
, parthdr
, strlen(parthdr
)) == 0) {
3191 char name
[32] = { 0 };
3193 unsigned long base
= 0;
3194 unsigned long size
= 0;
3196 end_part
= memchr(ptr
, '\n', (end
- ptr
));
3197 if (end_part
== NULL
) {
3198 /* in theory this should never happen, because a partition always ends with 0x09, 0x0D, 0x0A */
3202 for (int i
= 0; i
<= 4; i
++) {
3203 if (end_part
<= ptr
)
3206 end_element
= memchr(ptr
, 0x20, (end_part
- ptr
));
3207 if (end_element
== NULL
) {
3208 error(1, errno
, "Ignoring the rest of the partition entries.");
3213 /* partition header */
3215 ptr
= end_element
+ 1;
3219 name_len
= (end_element
- ptr
) > 31 ? 31 : (end_element
- ptr
);
3220 strncpy(name
, ptr
, name_len
);
3221 name
[name_len
] = '\0';
3222 ptr
= end_element
+ 1;
3227 ptr
= end_element
+ 1;
3232 base
= strtoul(ptr
, NULL
, 16);
3233 ptr
= end_element
+ 1;
3238 ptr
= end_element
+ 1;
3239 /* actual size. The last element doesn't have a sepeartor */
3240 size
= strtoul(ptr
, NULL
, 16);
3241 /* the part ends with 0x09, 0x0d, 0x0a */
3243 add_flash_partition(entries
, max_entries
, name
, base
, size
);
3252 static void write_partition(
3254 size_t firmware_offset
,
3255 struct flash_partition_entry
*entry
,
3261 fseek(input_file
, entry
->base
+ firmware_offset
, SEEK_SET
);
3263 for (offset
= 0; sizeof(buf
) + offset
<= entry
->size
; offset
+= sizeof(buf
)) {
3264 if (fread(buf
, sizeof(buf
), 1, input_file
) != 1)
3265 error(1, errno
, "Can not read partition from input_file");
3267 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3268 error(1, errno
, "Can not write partition to output_file");
3270 /* write last chunk smaller than buffer */
3271 if (offset
< entry
->size
) {
3272 offset
= entry
->size
- offset
;
3273 if (fread(buf
, offset
, 1, input_file
) != 1)
3274 error(1, errno
, "Can not read partition from input_file");
3275 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3276 error(1, errno
, "Can not write partition to output_file");
3280 static int extract_firmware_partition(FILE *input_file
, size_t firmware_offset
, struct flash_partition_entry
*entry
, const char *output_directory
)
3283 char output
[PATH_MAX
];
3285 snprintf(output
, PATH_MAX
, "%s/%s", output_directory
, entry
->name
);
3286 output_file
= fopen(output
, "wb+");
3287 if (output_file
== NULL
) {
3288 error(1, errno
, "Can not open output file %s", output
);
3291 write_partition(input_file
, firmware_offset
, entry
, output_file
);
3293 fclose(output_file
);
3298 /** extract all partitions from the firmware file */
3299 static int extract_firmware(const char *input
, const char *output_directory
)
3301 struct flash_partition_entry entries
[16] = { 0 };
3302 size_t max_entries
= 16;
3303 size_t firmware_offset
= 0x1014;
3306 struct stat statbuf
;
3308 /* check input file */
3309 if (stat(input
, &statbuf
)) {
3310 error(1, errno
, "Can not read input firmware %s", input
);
3313 /* check if output directory exists */
3314 if (stat(output_directory
, &statbuf
)) {
3315 error(1, errno
, "Failed to stat output directory %s", output_directory
);
3318 if ((statbuf
.st_mode
& S_IFMT
) != S_IFDIR
) {
3319 error(1, errno
, "Given output directory is not a directory %s", output_directory
);
3322 input_file
= fopen(input
, "rb");
3324 if (read_partition_table(input_file
, firmware_offset
, entries
, 16, 0) != 0) {
3325 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3328 for (size_t i
= 0; i
< max_entries
; i
++) {
3329 if (entries
[i
].name
== NULL
&&
3330 entries
[i
].base
== 0 &&
3331 entries
[i
].size
== 0)
3334 extract_firmware_partition(input_file
, firmware_offset
, &entries
[i
], output_directory
);
3340 static struct flash_partition_entry
*find_partition(
3341 struct flash_partition_entry
*entries
, size_t max_entries
,
3342 const char *name
, const char *error_msg
)
3344 for (size_t i
= 0; i
< max_entries
; i
++, entries
++) {
3345 if (strcmp(entries
->name
, name
) == 0)
3350 error(1, 0, "%s", error_msg
);
3356 static int firmware_info(const char *input
)
3358 struct flash_partition_entry pointers
[MAX_PARTITIONS
] = { };
3359 struct flash_partition_entry
*e
;
3363 fp
= fopen(input
, "r");
3365 if (read_partition_table(fp
, 0x1014, pointers
, MAX_PARTITIONS
, 0)) {
3366 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3369 printf("Firmware image partitions:\n");
3370 printf("%-8s %-8s %s\n", "base", "size", "name");
3371 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3374 if (!e
->name
&& !e
->base
&& !e
->size
)
3377 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3380 e
= find_partition(pointers
, MAX_PARTITIONS
, "soft-version", NULL
);
3382 size_t data_len
= e
->size
- sizeof(struct meta_header
);
3383 char *buf
= malloc(data_len
);
3384 struct soft_version
*s
;
3389 error(1, errno
, "Failed to alloc buffer");
3391 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3392 error(1, errno
, "Can not seek in the firmware");
3394 if (fread(buf
, data_len
, 1, fp
) != 1)
3395 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3397 /* Check for string ignoring padding character */
3399 for (i
= 0; i
< data_len
- 1; i
++) {
3400 if (!isascii(buf
[i
])) {
3406 printf("\n[Software version]\n");
3408 fwrite(buf
, data_len
, 1, stdout
);
3410 } else if (data_len
>= offsetof(struct soft_version
, rev
)) {
3411 s
= (struct soft_version
*)buf
;
3413 printf("Version: %d.%d.%d\n", s
->version_major
, s
->version_minor
, s
->version_patch
);
3414 printf("Date: %02x%02x-%02x-%02x\n", s
->year_hi
, s
->year_lo
, s
->month
, s
->day
);
3415 printf("Revision: %d\n", ntohl(s
->rev
));
3417 printf("Failed to parse data\n");
3423 e
= find_partition(pointers
, MAX_PARTITIONS
, "support-list", NULL
);
3429 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3430 error(1, errno
, "Can not seek in the firmware");
3432 printf("\n[Support list]\n");
3433 for (length
= e
->size
- sizeof(struct meta_header
); length
; length
-= bytes
) {
3434 bytes
= fread(buf
, 1, length
> sizeof(buf
) ? sizeof(buf
) : length
, fp
);
3436 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3442 e
= find_partition(pointers
, MAX_PARTITIONS
, "partition-table", NULL
);
3444 struct flash_partition_entry parts
[MAX_PARTITIONS
] = { };
3446 if (read_partition_table(fp
, 0x1014 + e
->base
+ 4, parts
, MAX_PARTITIONS
, 1)) {
3447 error(1, 0, "Error can not read the partition table (partition)");
3450 printf("\n[Partition table]\n");
3451 printf("%-8s %-8s %s\n", "base", "size", "name");
3452 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3455 if (!e
->name
&& !e
->base
&& !e
->size
)
3458 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3467 static void write_ff(FILE *output_file
, size_t size
)
3472 memset(buf
, 0xff, sizeof(buf
));
3474 for (offset
= 0; offset
+ sizeof(buf
) < size
; offset
+= sizeof(buf
)) {
3475 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3476 error(1, errno
, "Can not write 0xff to output_file");
3479 /* write last chunk smaller than buffer */
3480 if (offset
< size
) {
3481 offset
= size
- offset
;
3482 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3483 error(1, errno
, "Can not write partition to output_file");
3487 static void convert_firmware(const char *input
, const char *output
)
3489 struct flash_partition_entry fwup
[MAX_PARTITIONS
] = { 0 };
3490 struct flash_partition_entry flash
[MAX_PARTITIONS
] = { 0 };
3491 struct flash_partition_entry
*fwup_os_image
= NULL
, *fwup_file_system
= NULL
;
3492 struct flash_partition_entry
*flash_os_image
= NULL
, *flash_file_system
= NULL
;
3493 struct flash_partition_entry
*fwup_partition_table
= NULL
;
3494 size_t firmware_offset
= 0x1014;
3495 FILE *input_file
, *output_file
;
3497 struct stat statbuf
;
3499 /* check input file */
3500 if (stat(input
, &statbuf
)) {
3501 error(1, errno
, "Can not read input firmware %s", input
);
3504 input_file
= fopen(input
, "rb");
3506 error(1, 0, "Can not open input firmware %s", input
);
3508 output_file
= fopen(output
, "wb");
3510 error(1, 0, "Can not open output firmware %s", output
);
3512 if (read_partition_table(input_file
, firmware_offset
, fwup
, MAX_PARTITIONS
, 0) != 0) {
3513 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3516 fwup_os_image
= find_partition(fwup
, MAX_PARTITIONS
,
3517 "os-image", "Error can not find os-image partition (fwup)");
3518 fwup_file_system
= find_partition(fwup
, MAX_PARTITIONS
,
3519 "file-system", "Error can not find file-system partition (fwup)");
3520 fwup_partition_table
= find_partition(fwup
, MAX_PARTITIONS
,
3521 "partition-table", "Error can not find partition-table partition");
3523 /* the flash partition table has a 0x00000004 magic haeder */
3524 if (read_partition_table(input_file
, firmware_offset
+ fwup_partition_table
->base
+ 4, flash
, MAX_PARTITIONS
, 1) != 0)
3525 error(1, 0, "Error can not read the partition table (flash)");
3527 flash_os_image
= find_partition(flash
, MAX_PARTITIONS
,
3528 "os-image", "Error can not find os-image partition (flash)");
3529 flash_file_system
= find_partition(flash
, MAX_PARTITIONS
,
3530 "file-system", "Error can not find file-system partition (flash)");
3532 /* write os_image to 0x0 */
3533 write_partition(input_file
, firmware_offset
, fwup_os_image
, output_file
);
3534 write_ff(output_file
, flash_os_image
->size
- fwup_os_image
->size
);
3536 /* write file-system behind os_image */
3537 fseek(output_file
, flash_file_system
->base
- flash_os_image
->base
, SEEK_SET
);
3538 write_partition(input_file
, firmware_offset
, fwup_file_system
, output_file
);
3539 write_ff(output_file
, flash_file_system
->size
- fwup_file_system
->size
);
3541 fclose(output_file
);
3545 int main(int argc
, char *argv
[]) {
3546 const char *info_image
= NULL
, *board
= NULL
, *kernel_image
= NULL
, *rootfs_image
= NULL
, *output
= NULL
;
3547 const char *extract_image
= NULL
, *output_directory
= NULL
, *convert_image
= NULL
;
3548 bool add_jffs2_eof
= false, sysupgrade
= false;
3550 struct device_info
*info
;
3551 set_source_date_epoch();
3556 c
= getopt(argc
, argv
, "i:B:k:r:o:V:jSh:x:d:z:");
3562 info_image
= optarg
;
3570 kernel_image
= optarg
;
3574 rootfs_image
= optarg
;
3582 sscanf(optarg
, "r%u", &rev
);
3586 add_jffs2_eof
= true;
3598 output_directory
= optarg
;
3602 extract_image
= optarg
;
3606 convert_image
= optarg
;
3616 firmware_info(info_image
);
3617 } else if (extract_image
|| output_directory
) {
3619 error(1, 0, "No factory/oem image given via -x <file>. Output directory is only valid with -x");
3620 if (!output_directory
)
3621 error(1, 0, "Can not extract an image without output directory. Use -d <dir>");
3622 extract_firmware(extract_image
, output_directory
);
3623 } else if (convert_image
) {
3625 error(1, 0, "Can not convert a factory/oem image into sysupgrade image without output file. Use -o <file>");
3626 convert_firmware(convert_image
, output
);
3629 error(1, 0, "no board has been specified");
3631 error(1, 0, "no kernel image has been specified");
3633 error(1, 0, "no rootfs image has been specified");
3635 error(1, 0, "no output filename has been specified");
3637 info
= find_board(board
);
3640 error(1, 0, "unsupported board %s", board
);
3642 build_image(output
, kernel_image
, rootfs_image
, rev
, add_jffs2_eof
, sysupgrade
, info
);