2 Copyright (c) 2014, Matthias Schiffer <mschiffer@universe-factory.net>
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 Image generation tool for the TP-LINK SafeLoader as seen on
31 TP-LINK Pharos devices (CPE210/220/510/520)
47 #include <arpa/inet.h>
49 #include <sys/types.h>
56 #define ALIGN(x,a) ({ typeof(a) __a = (a); (((x) + __a - 1) & ~(__a - 1)); })
59 #define MAX_PARTITIONS 32
61 /** An image partition table entry */
62 struct image_partition_entry
{
68 /** A flash partition table entry */
69 struct flash_partition_entry
{
75 /** Partition trailing padding definitions
76 * Values 0x00 to 0xff are reserved to indicate the padding value
77 * Values from 0x100 are reserved to indicate other behaviour */
78 enum partition_trail_value
{
81 PART_TRAIL_MAX
= 0xff,
82 PART_TRAIL_NONE
= 0x100
85 /** Firmware layout description */
89 const char *support_list
;
90 enum partition_trail_value part_trail
;
92 uint32_t soft_ver_compat_level
;
93 struct flash_partition_entry partitions
[MAX_PARTITIONS
+1];
94 const char *first_sysupgrade_partition
;
95 const char *last_sysupgrade_partition
;
98 struct __attribute__((__packed__
)) meta_header
{
103 /** The content of the soft-version structure */
104 struct __attribute__((__packed__
)) soft_version
{
106 uint8_t version_major
;
107 uint8_t version_minor
;
108 uint8_t version_patch
;
114 uint32_t compat_level
;
118 static const uint8_t jffs2_eof_mark
[4] = {0xde, 0xad, 0xc0, 0xde};
122 Salt for the MD5 hash
124 Fortunately, TP-LINK seems to use the same salt for most devices which use
125 the new image format.
127 static const uint8_t md5_salt
[16] = {
128 0x7a, 0x2b, 0x15, 0xed,
129 0x9b, 0x98, 0x59, 0x6d,
130 0xe5, 0x04, 0xab, 0x44,
131 0xac, 0x2a, 0x9f, 0x4e,
135 /** Firmware layout table */
136 static struct device_info boards
[] = {
137 /** Firmware layout for the CPE210/220 V1 */
140 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
143 "CPE210(TP-LINK|UN|N300-2):1.0\r\n"
144 "CPE210(TP-LINK|UN|N300-2):1.1\r\n"
145 "CPE210(TP-LINK|US|N300-2):1.1\r\n"
146 "CPE210(TP-LINK|EU|N300-2):1.1\r\n"
147 "CPE220(TP-LINK|UN|N300-2):1.1\r\n"
148 "CPE220(TP-LINK|US|N300-2):1.1\r\n"
149 "CPE220(TP-LINK|EU|N300-2):1.1\r\n",
154 {"fs-uboot", 0x00000, 0x20000},
155 {"partition-table", 0x20000, 0x02000},
156 {"default-mac", 0x30000, 0x00020},
157 {"product-info", 0x31100, 0x00100},
158 {"signature", 0x32000, 0x00400},
159 {"firmware", 0x40000, 0x770000},
160 {"soft-version", 0x7b0000, 0x00100},
161 {"support-list", 0x7b1000, 0x00400},
162 {"user-config", 0x7c0000, 0x10000},
163 {"default-config", 0x7d0000, 0x10000},
164 {"log", 0x7e0000, 0x10000},
165 {"radio", 0x7f0000, 0x10000},
169 .first_sysupgrade_partition
= "os-image",
170 .last_sysupgrade_partition
= "support-list",
173 /** Firmware layout for the CPE210 V2 */
176 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n",
179 "CPE210(TP-LINK|EU|N300-2|00000000):2.0\r\n"
180 "CPE210(TP-LINK|EU|N300-2|45550000):2.0\r\n"
181 "CPE210(TP-LINK|EU|N300-2|55530000):2.0\r\n"
182 "CPE210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
183 "CPE210(TP-LINK|UN|N300-2|45550000):2.0\r\n"
184 "CPE210(TP-LINK|UN|N300-2|55530000):2.0\r\n"
185 "CPE210(TP-LINK|US|N300-2|55530000):2.0\r\n"
186 "CPE210(TP-LINK|UN|N300-2):2.0\r\n"
187 "CPE210(TP-LINK|EU|N300-2):2.0\r\n"
188 "CPE210(TP-LINK|US|N300-2):2.0\r\n",
193 {"fs-uboot", 0x00000, 0x20000},
194 {"partition-table", 0x20000, 0x02000},
195 {"default-mac", 0x30000, 0x00020},
196 {"product-info", 0x31100, 0x00100},
197 {"device-info", 0x31400, 0x00400},
198 {"signature", 0x32000, 0x00400},
199 {"device-id", 0x33000, 0x00100},
200 {"firmware", 0x40000, 0x770000},
201 {"soft-version", 0x7b0000, 0x00100},
202 {"support-list", 0x7b1000, 0x01000},
203 {"user-config", 0x7c0000, 0x10000},
204 {"default-config", 0x7d0000, 0x10000},
205 {"log", 0x7e0000, 0x10000},
206 {"radio", 0x7f0000, 0x10000},
210 .first_sysupgrade_partition
= "os-image",
211 .last_sysupgrade_partition
= "support-list",
214 /** Firmware layout for the CPE210 V3 */
217 .vendor
= "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n",
220 "CPE210(TP-LINK|EU|N300-2|45550000):3.0\r\n"
221 "CPE210(TP-LINK|UN|N300-2|00000000):3.0\r\n"
222 "CPE210(TP-LINK|US|N300-2|55530000):3.0\r\n"
223 "CPE210(TP-LINK|UN|N300-2):3.0\r\n"
224 "CPE210(TP-LINK|EU|N300-2):3.0\r\n"
225 "CPE210(TP-LINK|EU|N300-2|45550000):3.1\r\n"
226 "CPE210(TP-LINK|UN|N300-2|00000000):3.1\r\n"
227 "CPE210(TP-LINK|US|N300-2|55530000):3.1\r\n"
228 "CPE210(TP-LINK|EU|N300-2|45550000):3.20\r\n"
229 "CPE210(TP-LINK|UN|N300-2|00000000):3.20\r\n"
230 "CPE210(TP-LINK|US|N300-2|55530000):3.20\r\n",
235 {"fs-uboot", 0x00000, 0x20000},
236 {"partition-table", 0x20000, 0x01000},
237 {"default-mac", 0x30000, 0x00020},
238 {"product-info", 0x31100, 0x00100},
239 {"device-info", 0x31400, 0x00400},
240 {"signature", 0x32000, 0x00400},
241 {"device-id", 0x33000, 0x00100},
242 {"firmware", 0x40000, 0x770000},
243 {"soft-version", 0x7b0000, 0x00100},
244 {"support-list", 0x7b1000, 0x01000},
245 {"user-config", 0x7c0000, 0x10000},
246 {"default-config", 0x7d0000, 0x10000},
247 {"log", 0x7e0000, 0x10000},
248 {"radio", 0x7f0000, 0x10000},
252 .first_sysupgrade_partition
= "os-image",
253 .last_sysupgrade_partition
= "support-list",
256 /** Firmware layout for the CPE220 V2 */
259 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
262 "CPE220(TP-LINK|EU|N300-2|00000000):2.0\r\n"
263 "CPE220(TP-LINK|EU|N300-2|45550000):2.0\r\n"
264 "CPE220(TP-LINK|EU|N300-2|55530000):2.0\r\n"
265 "CPE220(TP-LINK|UN|N300-2|00000000):2.0\r\n"
266 "CPE220(TP-LINK|UN|N300-2|45550000):2.0\r\n"
267 "CPE220(TP-LINK|UN|N300-2|55530000):2.0\r\n"
268 "CPE220(TP-LINK|US|N300-2|55530000):2.0\r\n"
269 "CPE220(TP-LINK|UN|N300-2):2.0\r\n"
270 "CPE220(TP-LINK|EU|N300-2):2.0\r\n"
271 "CPE220(TP-LINK|US|N300-2):2.0\r\n",
276 {"fs-uboot", 0x00000, 0x20000},
277 {"partition-table", 0x20000, 0x02000},
278 {"default-mac", 0x30000, 0x00020},
279 {"product-info", 0x31100, 0x00100},
280 {"signature", 0x32000, 0x00400},
281 {"firmware", 0x40000, 0x770000},
282 {"soft-version", 0x7b0000, 0x00100},
283 {"support-list", 0x7b1000, 0x00400},
284 {"user-config", 0x7c0000, 0x10000},
285 {"default-config", 0x7d0000, 0x10000},
286 {"log", 0x7e0000, 0x10000},
287 {"radio", 0x7f0000, 0x10000},
291 .first_sysupgrade_partition
= "os-image",
292 .last_sysupgrade_partition
= "support-list",
295 /** Firmware layout for the CPE220 V3 */
298 .vendor
= "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n",
301 "CPE220(TP-LINK|EU|N300-2|00000000):3.0\r\n"
302 "CPE220(TP-LINK|EU|N300-2|45550000):3.0\r\n"
303 "CPE220(TP-LINK|EU|N300-2|55530000):3.0\r\n"
304 "CPE220(TP-LINK|UN|N300-2|00000000):3.0\r\n"
305 "CPE220(TP-LINK|UN|N300-2|45550000):3.0\r\n"
306 "CPE220(TP-LINK|UN|N300-2|55530000):3.0\r\n"
307 "CPE220(TP-LINK|US|N300-2|55530000):3.0\r\n"
308 "CPE220(TP-LINK|UN|N300-2):3.0\r\n"
309 "CPE220(TP-LINK|EU|N300-2):3.0\r\n"
310 "CPE220(TP-LINK|US|N300-2):3.0\r\n",
315 {"fs-uboot", 0x00000, 0x20000},
316 {"partition-table", 0x20000, 0x02000},
317 {"default-mac", 0x30000, 0x00020},
318 {"product-info", 0x31100, 0x00100},
319 {"device-info", 0x31400, 0x00400},
320 {"signature", 0x32000, 0x00400},
321 {"device-id", 0x33000, 0x00100},
322 {"firmware", 0x40000, 0x770000},
323 {"soft-version", 0x7b0000, 0x00100},
324 {"support-list", 0x7b1000, 0x01000},
325 {"user-config", 0x7c0000, 0x10000},
326 {"default-config", 0x7d0000, 0x10000},
327 {"log", 0x7e0000, 0x10000},
328 {"radio", 0x7f0000, 0x10000},
332 .first_sysupgrade_partition
= "os-image",
333 .last_sysupgrade_partition
= "support-list",
336 /** Firmware layout for the CPE510/520 V1 */
339 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
342 "CPE510(TP-LINK|UN|N300-5):1.0\r\n"
343 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
344 "CPE510(TP-LINK|UN|N300-5):1.1\r\n"
345 "CPE510(TP-LINK|US|N300-5):1.1\r\n"
346 "CPE510(TP-LINK|EU|N300-5):1.1\r\n"
347 "CPE520(TP-LINK|UN|N300-5):1.1\r\n"
348 "CPE520(TP-LINK|US|N300-5):1.1\r\n"
349 "CPE520(TP-LINK|EU|N300-5):1.1\r\n",
354 {"fs-uboot", 0x00000, 0x20000},
355 {"partition-table", 0x20000, 0x02000},
356 {"default-mac", 0x30000, 0x00020},
357 {"product-info", 0x31100, 0x00100},
358 {"signature", 0x32000, 0x00400},
359 {"firmware", 0x40000, 0x770000},
360 {"soft-version", 0x7b0000, 0x00100},
361 {"support-list", 0x7b1000, 0x00400},
362 {"user-config", 0x7c0000, 0x10000},
363 {"default-config", 0x7d0000, 0x10000},
364 {"log", 0x7e0000, 0x10000},
365 {"radio", 0x7f0000, 0x10000},
369 .first_sysupgrade_partition
= "os-image",
370 .last_sysupgrade_partition
= "support-list",
373 /** Firmware layout for the CPE510 V2 */
376 .vendor
= "CPE510(TP-LINK|UN|N300-5):2.0\r\n",
379 "CPE510(TP-LINK|EU|N300-5|00000000):2.0\r\n"
380 "CPE510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
381 "CPE510(TP-LINK|EU|N300-5|55530000):2.0\r\n"
382 "CPE510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
383 "CPE510(TP-LINK|UN|N300-5|45550000):2.0\r\n"
384 "CPE510(TP-LINK|UN|N300-5|55530000):2.0\r\n"
385 "CPE510(TP-LINK|US|N300-5|00000000):2.0\r\n"
386 "CPE510(TP-LINK|US|N300-5|45550000):2.0\r\n"
387 "CPE510(TP-LINK|US|N300-5|55530000):2.0\r\n"
388 "CPE510(TP-LINK|UN|N300-5):2.0\r\n"
389 "CPE510(TP-LINK|EU|N300-5):2.0\r\n"
390 "CPE510(TP-LINK|US|N300-5):2.0\r\n",
395 {"fs-uboot", 0x00000, 0x20000},
396 {"partition-table", 0x20000, 0x02000},
397 {"default-mac", 0x30000, 0x00020},
398 {"product-info", 0x31100, 0x00100},
399 {"signature", 0x32000, 0x00400},
400 {"firmware", 0x40000, 0x770000},
401 {"soft-version", 0x7b0000, 0x00100},
402 {"support-list", 0x7b1000, 0x00400},
403 {"user-config", 0x7c0000, 0x10000},
404 {"default-config", 0x7d0000, 0x10000},
405 {"log", 0x7e0000, 0x10000},
406 {"radio", 0x7f0000, 0x10000},
410 .first_sysupgrade_partition
= "os-image",
411 .last_sysupgrade_partition
= "support-list",
414 /** Firmware layout for the CPE510 V3 */
417 .vendor
= "CPE510(TP-LINK|UN|N300-5):3.0\r\n",
420 "CPE510(TP-LINK|EU|N300-5|00000000):3.0\r\n"
421 "CPE510(TP-LINK|EU|N300-5|45550000):3.0\r\n"
422 "CPE510(TP-LINK|EU|N300-5|55530000):3.0\r\n"
423 "CPE510(TP-LINK|UN|N300-5|00000000):3.0\r\n"
424 "CPE510(TP-LINK|UN|N300-5|45550000):3.0\r\n"
425 "CPE510(TP-LINK|UN|N300-5|55530000):3.0\r\n"
426 "CPE510(TP-LINK|US|N300-5|00000000):3.0\r\n"
427 "CPE510(TP-LINK|US|N300-5|45550000):3.0\r\n"
428 "CPE510(TP-LINK|US|N300-5|55530000):3.0\r\n"
429 "CPE510(TP-LINK|UN|N300-5):3.0\r\n"
430 "CPE510(TP-LINK|EU|N300-5):3.0\r\n"
431 "CPE510(TP-LINK|US|N300-5):3.0\r\n"
432 "CPE510(TP-LINK|UN|N300-5|00000000):3.20\r\n"
433 "CPE510(TP-LINK|US|N300-5|55530000):3.20\r\n"
434 "CPE510(TP-LINK|EU|N300-5|45550000):3.20\r\n",
439 {"fs-uboot", 0x00000, 0x20000},
440 {"partition-table", 0x20000, 0x02000},
441 {"default-mac", 0x30000, 0x00020},
442 {"product-info", 0x31100, 0x00100},
443 {"signature", 0x32000, 0x00400},
444 {"firmware", 0x40000, 0x770000},
445 {"soft-version", 0x7b0000, 0x00100},
446 {"support-list", 0x7b1000, 0x00400},
447 {"user-config", 0x7c0000, 0x10000},
448 {"default-config", 0x7d0000, 0x10000},
449 {"log", 0x7e0000, 0x10000},
450 {"radio", 0x7f0000, 0x10000},
454 .first_sysupgrade_partition
= "os-image",
455 .last_sysupgrade_partition
= "support-list",
458 /** Firmware layout for the CPE610V1 */
461 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n",
464 "CPE610(TP-LINK|EU|N300-5|00000000):1.0\r\n"
465 "CPE610(TP-LINK|EU|N300-5|45550000):1.0\r\n"
466 "CPE610(TP-LINK|EU|N300-5|55530000):1.0\r\n"
467 "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n"
468 "CPE610(TP-LINK|UN|N300-5|45550000):1.0\r\n"
469 "CPE610(TP-LINK|UN|N300-5|55530000):1.0\r\n"
470 "CPE610(TP-LINK|US|N300-5|55530000):1.0\r\n"
471 "CPE610(TP-LINK|UN|N300-5):1.0\r\n"
472 "CPE610(TP-LINK|EU|N300-5):1.0\r\n"
473 "CPE610(TP-LINK|US|N300-5):1.0\r\n",
478 {"fs-uboot", 0x00000, 0x20000},
479 {"partition-table", 0x20000, 0x02000},
480 {"default-mac", 0x30000, 0x00020},
481 {"product-info", 0x31100, 0x00100},
482 {"signature", 0x32000, 0x00400},
483 {"firmware", 0x40000, 0x770000},
484 {"soft-version", 0x7b0000, 0x00100},
485 {"support-list", 0x7b1000, 0x00400},
486 {"user-config", 0x7c0000, 0x10000},
487 {"default-config", 0x7d0000, 0x10000},
488 {"log", 0x7e0000, 0x10000},
489 {"radio", 0x7f0000, 0x10000},
493 .first_sysupgrade_partition
= "os-image",
494 .last_sysupgrade_partition
= "support-list",
497 /** Firmware layout for the CPE610V2 */
500 .vendor
= "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n",
503 "CPE610(TP-LINK|EU|N300-5|00000000):2.0\r\n"
504 "CPE610(TP-LINK|EU|N300-5|45550000):2.0\r\n"
505 "CPE610(TP-LINK|EU|N300-5|55530000):2.0\r\n"
506 "CPE610(TP-LINK|UN|N300-5|00000000):2.0\r\n"
507 "CPE610(TP-LINK|UN|N300-5|45550000):2.0\r\n"
508 "CPE610(TP-LINK|UN|N300-5|55530000):2.0\r\n"
509 "CPE610(TP-LINK|US|N300-5|55530000):2.0\r\n"
510 "CPE610(TP-LINK|UN|N300-5):2.0\r\n"
511 "CPE610(TP-LINK|EU|N300-5):2.0\r\n"
512 "CPE610(TP-LINK|US|N300-5):2.0\r\n",
517 {"fs-uboot", 0x00000, 0x20000},
518 {"partition-table", 0x20000, 0x02000},
519 {"default-mac", 0x30000, 0x00020},
520 {"product-info", 0x31100, 0x00100},
521 {"signature", 0x32000, 0x00400},
522 {"firmware", 0x40000, 0x770000},
523 {"soft-version", 0x7b0000, 0x00100},
524 {"support-list", 0x7b1000, 0x00400},
525 {"user-config", 0x7c0000, 0x10000},
526 {"default-config", 0x7d0000, 0x10000},
527 {"log", 0x7e0000, 0x10000},
528 {"radio", 0x7f0000, 0x10000},
532 .first_sysupgrade_partition
= "os-image",
533 .last_sysupgrade_partition
= "support-list",
538 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
541 "WBS210(TP-LINK|UN|N300-2):1.20\r\n"
542 "WBS210(TP-LINK|US|N300-2):1.20\r\n"
543 "WBS210(TP-LINK|EU|N300-2):1.20\r\n",
548 {"fs-uboot", 0x00000, 0x20000},
549 {"partition-table", 0x20000, 0x02000},
550 {"default-mac", 0x30000, 0x00020},
551 {"product-info", 0x31100, 0x00100},
552 {"signature", 0x32000, 0x00400},
553 {"firmware", 0x40000, 0x770000},
554 {"soft-version", 0x7b0000, 0x00100},
555 {"support-list", 0x7b1000, 0x00400},
556 {"user-config", 0x7c0000, 0x10000},
557 {"default-config", 0x7d0000, 0x10000},
558 {"log", 0x7e0000, 0x10000},
559 {"radio", 0x7f0000, 0x10000},
563 .first_sysupgrade_partition
= "os-image",
564 .last_sysupgrade_partition
= "support-list",
569 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
572 "WBS210(TP-LINK|UN|N300-2|00000000):2.0\r\n"
573 "WBS210(TP-LINK|US|N300-2|55530000):2.0\r\n"
574 "WBS210(TP-LINK|EU|N300-2|45550000):2.0\r\n",
579 {"fs-uboot", 0x00000, 0x20000},
580 {"partition-table", 0x20000, 0x02000},
581 {"default-mac", 0x30000, 0x00020},
582 {"product-info", 0x31100, 0x00100},
583 {"signature", 0x32000, 0x00400},
584 {"firmware", 0x40000, 0x770000},
585 {"soft-version", 0x7b0000, 0x00100},
586 {"support-list", 0x7b1000, 0x00400},
587 {"user-config", 0x7c0000, 0x10000},
588 {"default-config", 0x7d0000, 0x10000},
589 {"log", 0x7e0000, 0x10000},
590 {"radio", 0x7f0000, 0x10000},
594 .first_sysupgrade_partition
= "os-image",
595 .last_sysupgrade_partition
= "support-list",
600 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
603 "WBS510(TP-LINK|UN|N300-5):1.20\r\n"
604 "WBS510(TP-LINK|US|N300-5):1.20\r\n"
605 "WBS510(TP-LINK|EU|N300-5):1.20\r\n"
606 "WBS510(TP-LINK|CA|N300-5):1.20\r\n",
611 {"fs-uboot", 0x00000, 0x20000},
612 {"partition-table", 0x20000, 0x02000},
613 {"default-mac", 0x30000, 0x00020},
614 {"product-info", 0x31100, 0x00100},
615 {"signature", 0x32000, 0x00400},
616 {"firmware", 0x40000, 0x770000},
617 {"soft-version", 0x7b0000, 0x00100},
618 {"support-list", 0x7b1000, 0x00400},
619 {"user-config", 0x7c0000, 0x10000},
620 {"default-config", 0x7d0000, 0x10000},
621 {"log", 0x7e0000, 0x10000},
622 {"radio", 0x7f0000, 0x10000},
626 .first_sysupgrade_partition
= "os-image",
627 .last_sysupgrade_partition
= "support-list",
632 .vendor
= "CPE510(TP-LINK|UN|N300-5):1.0\r\n",
635 "WBS510(TP-LINK|UN|N300-5|00000000):2.0\r\n"
636 "WBS510(TP-LINK|US|N300-5|55530000):2.0\r\n"
637 "WBS510(TP-LINK|EU|N300-5|45550000):2.0\r\n"
638 "WBS510(TP-LINK|CA|N300-5|43410000):2.0\r\n",
643 {"fs-uboot", 0x00000, 0x20000},
644 {"partition-table", 0x20000, 0x02000},
645 {"default-mac", 0x30000, 0x00020},
646 {"product-info", 0x31100, 0x00100},
647 {"signature", 0x32000, 0x00400},
648 {"firmware", 0x40000, 0x770000},
649 {"soft-version", 0x7b0000, 0x00100},
650 {"support-list", 0x7b1000, 0x00400},
651 {"user-config", 0x7c0000, 0x10000},
652 {"default-config", 0x7d0000, 0x10000},
653 {"log", 0x7e0000, 0x10000},
654 {"radio", 0x7f0000, 0x10000},
658 .first_sysupgrade_partition
= "os-image",
659 .last_sysupgrade_partition
= "support-list",
662 /** Firmware layout for the AD7200 */
668 "{product_name:AD7200,product_ver:1.0.0,special_id:00000000}\r\n",
673 {"SBL1", 0x00000, 0x20000},
674 {"MIBIB", 0x20000, 0x20000},
675 {"SBL2", 0x40000, 0x20000},
676 {"SBL3", 0x60000, 0x30000},
677 {"DDRCONFIG", 0x90000, 0x10000},
678 {"SSD", 0xa0000, 0x10000},
679 {"TZ", 0xb0000, 0x30000},
680 {"RPM", 0xe0000, 0x20000},
681 {"fs-uboot", 0x100000, 0x70000},
682 {"uboot-env", 0x170000, 0x40000},
683 {"radio", 0x1b0000, 0x40000},
684 {"os-image", 0x1f0000, 0x400000},
685 {"file-system", 0x5f0000, 0x1900000},
686 {"default-mac", 0x1ef0000, 0x00200},
687 {"pin", 0x1ef0200, 0x00200},
688 {"device-id", 0x1ef0400, 0x00200},
689 {"product-info", 0x1ef0600, 0x0fa00},
690 {"partition-table", 0x1f00000, 0x10000},
691 {"soft-version", 0x1f10000, 0x10000},
692 {"support-list", 0x1f20000, 0x10000},
693 {"profile", 0x1f30000, 0x10000},
694 {"default-config", 0x1f40000, 0x10000},
695 {"user-config", 0x1f50000, 0x40000},
696 {"qos-db", 0x1f90000, 0x40000},
697 {"usb-config", 0x1fd0000, 0x10000},
698 {"log", 0x1fe0000, 0x20000},
702 .first_sysupgrade_partition
= "os-image",
703 .last_sysupgrade_partition
= "file-system"
706 /** Firmware layout for the C2600 */
712 "{product_name:Archer C2600,product_ver:1.0.0,special_id:00000000}\r\n",
717 We use a bigger os-image partition than the stock images (and thus
718 smaller file-system), as our kernel doesn't fit in the stock firmware's
719 2 MB os-image since kernel 4.14.
722 {"SBL1", 0x00000, 0x20000},
723 {"MIBIB", 0x20000, 0x20000},
724 {"SBL2", 0x40000, 0x20000},
725 {"SBL3", 0x60000, 0x30000},
726 {"DDRCONFIG", 0x90000, 0x10000},
727 {"SSD", 0xa0000, 0x10000},
728 {"TZ", 0xb0000, 0x30000},
729 {"RPM", 0xe0000, 0x20000},
730 {"fs-uboot", 0x100000, 0x70000},
731 {"uboot-env", 0x170000, 0x40000},
732 {"radio", 0x1b0000, 0x40000},
733 {"os-image", 0x1f0000, 0x400000}, /* Stock: base 0x1f0000 size 0x200000 */
734 {"file-system", 0x5f0000, 0x1900000}, /* Stock: base 0x3f0000 size 0x1b00000 */
735 {"default-mac", 0x1ef0000, 0x00200},
736 {"pin", 0x1ef0200, 0x00200},
737 {"product-info", 0x1ef0400, 0x0fc00},
738 {"partition-table", 0x1f00000, 0x10000},
739 {"soft-version", 0x1f10000, 0x10000},
740 {"support-list", 0x1f20000, 0x10000},
741 {"profile", 0x1f30000, 0x10000},
742 {"default-config", 0x1f40000, 0x10000},
743 {"user-config", 0x1f50000, 0x40000},
744 {"qos-db", 0x1f90000, 0x40000},
745 {"usb-config", 0x1fd0000, 0x10000},
746 {"log", 0x1fe0000, 0x20000},
750 .first_sysupgrade_partition
= "os-image",
751 .last_sysupgrade_partition
= "file-system"
754 /** Firmware layout for the A7-V5 */
756 .id
= "ARCHER-A7-V5",
759 "{product_name:Archer A7,product_ver:5.0.0,special_id:45550000}\n"
760 "{product_name:Archer A7,product_ver:5.0.0,special_id:55530000}\n"
761 "{product_name:Archer A7,product_ver:5.0.0,special_id:43410000}\n"
762 "{product_name:Archer A7,product_ver:5.0.0,special_id:4A500000}\n"
763 "{product_name:Archer A7,product_ver:5.0.0,special_id:54570000}\n"
764 "{product_name:Archer A7,product_ver:5.0.0,special_id:52550000}\n",
766 .soft_ver
= "soft_ver:1.0.0\n",
768 /* We're using a dynamic kernel/rootfs split here */
770 {"factory-boot", 0x00000, 0x20000},
771 {"fs-uboot", 0x20000, 0x20000},
772 {"firmware", 0x40000, 0xec0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
773 /* Stock: name file-system base 0x160000 size 0xda0000 */
774 {"default-mac", 0xf40000, 0x00200},
775 {"pin", 0xf40200, 0x00200},
776 {"device-id", 0xf40400, 0x00100},
777 {"product-info", 0xf40500, 0x0fb00},
778 {"soft-version", 0xf50000, 0x00100},
779 {"extra-para", 0xf51000, 0x01000},
780 {"support-list", 0xf52000, 0x0a000},
781 {"profile", 0xf5c000, 0x04000},
782 {"default-config", 0xf60000, 0x10000},
783 {"user-config", 0xf70000, 0x40000},
784 {"certificate", 0xfb0000, 0x10000},
785 {"partition-table", 0xfc0000, 0x10000},
786 {"log", 0xfd0000, 0x20000},
787 {"radio", 0xff0000, 0x10000},
791 .first_sysupgrade_partition
= "os-image",
792 .last_sysupgrade_partition
= "file-system",
795 /** Firmware layout for the C2v3 */
797 .id
= "ARCHER-C2-V3",
800 "{product_name:ArcherC2,product_ver:3.0.0,special_id:00000000}\n"
801 "{product_name:ArcherC2,product_ver:3.0.0,special_id:55530000}\n"
802 "{product_name:ArcherC2,product_ver:3.0.0,special_id:45550000}\n",
804 .soft_ver
= "soft_ver:3.0.1\n",
806 /** We're using a dynamic kernel/rootfs split here */
809 {"factory-boot", 0x00000, 0x20000},
810 {"fs-uboot", 0x20000, 0x10000},
811 {"firmware", 0x30000, 0x7a0000},
812 {"user-config", 0x7d0000, 0x04000},
813 {"default-mac", 0x7e0000, 0x00100},
814 {"device-id", 0x7e0100, 0x00100},
815 {"extra-para", 0x7e0200, 0x00100},
816 {"pin", 0x7e0300, 0x00100},
817 {"support-list", 0x7e0400, 0x00400},
818 {"soft-version", 0x7e0800, 0x00400},
819 {"product-info", 0x7e0c00, 0x01400},
820 {"partition-table", 0x7e2000, 0x01000},
821 {"profile", 0x7e3000, 0x01000},
822 {"default-config", 0x7e4000, 0x04000},
823 {"merge-config", 0x7ec000, 0x02000},
824 {"qos-db", 0x7ee000, 0x02000},
825 {"radio", 0x7f0000, 0x10000},
829 .first_sysupgrade_partition
= "os-image",
830 .last_sysupgrade_partition
= "file-system",
833 /** Firmware layout for the C25v1 */
835 .id
= "ARCHER-C25-V1",
838 "{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
839 "{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
840 "{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
842 .soft_ver
= "soft_ver:1.0.0\n",
844 /* We're using a dynamic kernel/rootfs split here */
846 {"factory-boot", 0x00000, 0x20000},
847 {"fs-uboot", 0x20000, 0x10000},
848 {"firmware", 0x30000, 0x7a0000}, /* Stock: name os-image base 0x30000 size 0x100000 */
849 /* Stock: name file-system base 0x130000 size 0x6a0000 */
850 {"user-config", 0x7d0000, 0x04000},
851 {"default-mac", 0x7e0000, 0x00100},
852 {"device-id", 0x7e0100, 0x00100},
853 {"extra-para", 0x7e0200, 0x00100},
854 {"pin", 0x7e0300, 0x00100},
855 {"support-list", 0x7e0400, 0x00400},
856 {"soft-version", 0x7e0800, 0x00400},
857 {"product-info", 0x7e0c00, 0x01400},
858 {"partition-table", 0x7e2000, 0x01000},
859 {"profile", 0x7e3000, 0x01000},
860 {"default-config", 0x7e4000, 0x04000},
861 {"merge-config", 0x7ec000, 0x02000},
862 {"qos-db", 0x7ee000, 0x02000},
863 {"radio", 0x7f0000, 0x10000},
867 .first_sysupgrade_partition
= "os-image",
868 .last_sysupgrade_partition
= "file-system",
871 /** Firmware layout for the C58v1 */
873 .id
= "ARCHER-C58-V1",
877 "{product_name:Archer C58,product_ver:1.0.0,special_id:00000000}\r\n"
878 "{product_name:Archer C58,product_ver:1.0.0,special_id:45550000}\r\n"
879 "{product_name:Archer C58,product_ver:1.0.0,special_id:55530000}\r\n",
881 .soft_ver
= "soft_ver:1.0.0\n",
884 {"fs-uboot", 0x00000, 0x10000},
885 {"default-mac", 0x10000, 0x00200},
886 {"pin", 0x10200, 0x00200},
887 {"product-info", 0x10400, 0x00100},
888 {"partition-table", 0x10500, 0x00800},
889 {"soft-version", 0x11300, 0x00200},
890 {"support-list", 0x11500, 0x00100},
891 {"device-id", 0x11600, 0x00100},
892 {"profile", 0x11700, 0x03900},
893 {"default-config", 0x15000, 0x04000},
894 {"user-config", 0x19000, 0x04000},
895 {"firmware", 0x20000, 0x7c8000},
896 {"certyficate", 0x7e8000, 0x08000},
897 {"radio", 0x7f0000, 0x10000},
901 .first_sysupgrade_partition
= "os-image",
902 .last_sysupgrade_partition
= "file-system",
905 /** Firmware layout for the C59v1 */
907 .id
= "ARCHER-C59-V1",
911 "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
912 "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
913 "{product_name:Archer C59,product_ver:1.0.0,special_id:52550000}\r\n"
914 "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
916 .soft_ver
= "soft_ver:1.0.0\n",
918 /* We're using a dynamic kernel/rootfs split here */
920 {"fs-uboot", 0x00000, 0x10000},
921 {"default-mac", 0x10000, 0x00200},
922 {"pin", 0x10200, 0x00200},
923 {"device-id", 0x10400, 0x00100},
924 {"product-info", 0x10500, 0x0fb00},
925 {"firmware", 0x20000, 0xe30000},
926 {"partition-table", 0xe50000, 0x10000},
927 {"soft-version", 0xe60000, 0x10000},
928 {"support-list", 0xe70000, 0x10000},
929 {"profile", 0xe80000, 0x10000},
930 {"default-config", 0xe90000, 0x10000},
931 {"user-config", 0xea0000, 0x40000},
932 {"usb-config", 0xee0000, 0x10000},
933 {"certificate", 0xef0000, 0x10000},
934 {"qos-db", 0xf00000, 0x40000},
935 {"log", 0xfe0000, 0x10000},
936 {"radio", 0xff0000, 0x10000},
940 .first_sysupgrade_partition
= "os-image",
941 .last_sysupgrade_partition
= "file-system",
944 /** Firmware layout for the C59v2 */
946 .id
= "ARCHER-C59-V2",
950 "{product_name:Archer C59,product_ver:2.0.0,special_id:00000000}\r\n"
951 "{product_name:Archer C59,product_ver:2.0.0,special_id:45550000}\r\n"
952 "{product_name:Archer C59,product_ver:2.0.0,special_id:55530000}\r\n",
954 .soft_ver
= "soft_ver:2.0.0 Build 20161206 rel.7303\n",
956 /** We're using a dynamic kernel/rootfs split here */
958 {"factory-boot", 0x00000, 0x20000},
959 {"fs-uboot", 0x20000, 0x10000},
960 {"default-mac", 0x30000, 0x00200},
961 {"pin", 0x30200, 0x00200},
962 {"device-id", 0x30400, 0x00100},
963 {"product-info", 0x30500, 0x0fb00},
964 {"firmware", 0x40000, 0xe10000},
965 {"partition-table", 0xe50000, 0x10000},
966 {"soft-version", 0xe60000, 0x10000},
967 {"support-list", 0xe70000, 0x10000},
968 {"profile", 0xe80000, 0x10000},
969 {"default-config", 0xe90000, 0x10000},
970 {"user-config", 0xea0000, 0x40000},
971 {"usb-config", 0xee0000, 0x10000},
972 {"certificate", 0xef0000, 0x10000},
973 {"extra-para", 0xf00000, 0x10000},
974 {"qos-db", 0xf10000, 0x30000},
975 {"log", 0xfe0000, 0x10000},
976 {"radio", 0xff0000, 0x10000},
980 .first_sysupgrade_partition
= "os-image",
981 .last_sysupgrade_partition
= "file-system",
984 /** Firmware layout for the Archer C6 v2 (EU/RU/JP) */
986 .id
= "ARCHER-C6-V2",
990 "{product_name:Archer C6,product_ver:2.0.0,special_id:45550000}\r\n"
991 "{product_name:Archer C6,product_ver:2.0.0,special_id:52550000}\r\n"
992 "{product_name:Archer C6,product_ver:2.0.0,special_id:4A500000}\r\n",
994 .soft_ver
= "soft_ver:1.9.1\n",
997 {"fs-uboot", 0x00000, 0x20000},
998 {"default-mac", 0x20000, 0x00200},
999 {"pin", 0x20200, 0x00100},
1000 {"product-info", 0x20300, 0x00200},
1001 {"device-id", 0x20500, 0x0fb00},
1002 {"firmware", 0x30000, 0x7a9400},
1003 {"soft-version", 0x7d9400, 0x00100},
1004 {"extra-para", 0x7d9500, 0x00100},
1005 {"support-list", 0x7d9600, 0x00200},
1006 {"profile", 0x7d9800, 0x03000},
1007 {"default-config", 0x7dc800, 0x03000},
1008 {"partition-table", 0x7df800, 0x00800},
1009 {"user-config", 0x7e0000, 0x0c000},
1010 {"certificate", 0x7ec000, 0x04000},
1011 {"radio", 0x7f0000, 0x10000},
1015 .first_sysupgrade_partition
= "os-image",
1016 .last_sysupgrade_partition
= "file-system",
1019 /** Firmware layout for the Archer C6 v2 (US) and A6 v2 (US/TW) */
1021 .id
= "ARCHER-C6-V2-US",
1025 "{product_name:Archer A6,product_ver:2.0.0,special_id:55530000}\n"
1026 "{product_name:Archer A6,product_ver:2.0.0,special_id:54570000}\n"
1027 "{product_name:Archer C6,product_ver:2.0.0,special_id:55530000}\n",
1029 .soft_ver
= "soft_ver:1.9.1\n",
1032 {"factory-boot", 0x00000, 0x20000},
1033 {"default-mac", 0x20000, 0x00200},
1034 {"pin", 0x20200, 0x00100},
1035 {"product-info", 0x20300, 0x00200},
1036 {"device-id", 0x20500, 0x0fb00},
1037 {"fs-uboot", 0x30000, 0x20000},
1038 {"firmware", 0x50000, 0xf89400},
1039 {"soft-version", 0xfd9400, 0x00100},
1040 {"extra-para", 0xfd9500, 0x00100},
1041 {"support-list", 0xfd9600, 0x00200},
1042 {"profile", 0xfd9800, 0x03000},
1043 {"default-config", 0xfdc800, 0x03000},
1044 {"partition-table", 0xfdf800, 0x00800},
1045 {"user-config", 0xfe0000, 0x0c000},
1046 {"certificate", 0xfec000, 0x04000},
1047 {"radio", 0xff0000, 0x10000},
1050 .first_sysupgrade_partition
= "os-image",
1051 .last_sysupgrade_partition
= "file-system",
1053 /** Firmware layout for the Archer C6 v3 */
1055 .id
= "ARCHER-C6-V3",
1059 "{product_name:Archer C6,product_ver:3.20,special_id:55530000}"
1060 "{product_name:Archer C6,product_ver:3.20,special_id:45550000}"
1061 "{product_name:Archer C6,product_ver:3.20,special_id:52550000}"
1062 "{product_name:Archer C6,product_ver:3.20,special_id:4A500000}"
1063 "{product_name:Archer C6,product_ver:3.20,special_id:4B520000}",
1065 .soft_ver
= "soft_ver:1.0.9\n",
1068 {"fs-uboot", 0x00000, 0x40000},
1069 {"firmware", 0x40000, 0xf60000},
1070 {"default-mac", 0xfa0000, 0x00200},
1071 {"pin", 0xfa0200, 0x00100},
1072 {"device-id", 0xfa0300, 0x00100},
1073 {"product-info", 0xfa0400, 0x0fc00},
1074 {"default-config", 0xfb0000, 0x08000},
1075 {"ap-def-config", 0xfb8000, 0x08000},
1076 {"user-config", 0xfc0000, 0x0a000},
1077 {"ag-config", 0xfca000, 0x04000},
1078 {"certificate", 0xfce000, 0x02000},
1079 {"ap-config", 0xfd0000, 0x06000},
1080 {"router-config", 0xfd6000, 0x06000},
1081 {"favicon", 0xfdc000, 0x02000},
1082 {"logo", 0xfde000, 0x02000},
1083 {"partition-table", 0xfe0000, 0x00800},
1084 {"soft-version", 0xfe0800, 0x00100},
1085 {"support-list", 0xfe0900, 0x00200},
1086 {"profile", 0xfe0b00, 0x03000},
1087 {"extra-para", 0xfe3b00, 0x00100},
1088 {"radio", 0xff0000, 0x10000},
1091 .first_sysupgrade_partition
= "os-image",
1092 .last_sysupgrade_partition
= "file-system",
1094 /** Firmware layout for the Archer A6 v3 */
1096 .id
= "ARCHER-A6-V3",
1100 "{product_name:Archer A6,product_ver:3.0.0,special_id:55530000}\n"
1101 "{product_name:Archer A6,product_ver:3.0.0,special_id:54570000}\n",
1103 .soft_ver
= "soft_ver:1.0.5\n",
1106 {"fs-uboot", 0x00000, 0x40000},
1107 {"firmware", 0x40000, 0xf60000},
1108 {"default-mac", 0xfa0000, 0x00200},
1109 {"pin", 0xfa0200, 0x00100},
1110 {"device-id", 0xfa0300, 0x00100},
1111 {"product-info", 0xfa0400, 0x0fc00},
1112 {"default-config", 0xfb0000, 0x08000},
1113 {"ap-def-config", 0xfb8000, 0x08000},
1114 {"user-config", 0xfc0000, 0x0a000},
1115 {"ag-config", 0xfca000, 0x04000},
1116 {"certificate", 0xfce000, 0x02000},
1117 {"ap-config", 0xfd0000, 0x06000},
1118 {"router-config", 0xfd6000, 0x06000},
1119 {"favicon", 0xfdc000, 0x02000},
1120 {"logo", 0xfde000, 0x02000},
1121 {"partition-table", 0xfe0000, 0x00800},
1122 {"soft-version", 0xfe0800, 0x00100},
1123 {"support-list", 0xfe0900, 0x00200},
1124 {"profile", 0xfe0b00, 0x03000},
1125 {"extra-para", 0xfe3b00, 0x00100},
1126 {"radio", 0xff0000, 0x10000},
1129 .first_sysupgrade_partition
= "os-image",
1130 .last_sysupgrade_partition
= "file-system",
1132 /** Firmware layout for the Archer C6U v1 */
1134 .id
= "ARCHER-C6U-V1",
1138 "{product_name:Archer C6U,product_ver:1.0.0,special_id:45550000}\n",
1140 .soft_ver
= "soft_ver:1.0.2\n",
1143 {"fs-uboot", 0x00000, 0x40000},
1144 {"firmware", 0x40000, 0xf60000},
1145 {"default-mac", 0xfa0000, 0x00200},
1146 {"pin", 0xfa0200, 0x00100},
1147 {"device-id", 0xfa0300, 0x00100},
1148 {"product-info", 0xfa0400, 0x0fc00},
1149 {"default-config", 0xfb0000, 0x08000},
1150 {"ap-def-config", 0xfb8000, 0x08000},
1151 {"user-config", 0xfc0000, 0x0c000},
1152 {"certificate", 0xfcc000, 0x04000},
1153 {"ap-config", 0xfd0000, 0x08000},
1154 {"router-config", 0xfd8000, 0x08000},
1155 {"partition-table", 0xfe0000, 0x00800},
1156 {"soft-version", 0xfe0800, 0x00100},
1157 {"support-list", 0xfe0900, 0x00200},
1158 {"profile", 0xfe0b00, 0x03000},
1159 {"extra-para", 0xfe3b00, 0x00100},
1160 {"radio", 0xff0000, 0x10000},
1163 .first_sysupgrade_partition
= "os-image",
1164 .last_sysupgrade_partition
= "file-system",
1166 /** Firmware layout for the C60v1 */
1168 .id
= "ARCHER-C60-V1",
1172 "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
1173 "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
1174 "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
1176 .soft_ver
= "soft_ver:1.0.0\n",
1179 {"fs-uboot", 0x00000, 0x10000},
1180 {"default-mac", 0x10000, 0x00200},
1181 {"pin", 0x10200, 0x00200},
1182 {"product-info", 0x10400, 0x00100},
1183 {"partition-table", 0x10500, 0x00800},
1184 {"soft-version", 0x11300, 0x00200},
1185 {"support-list", 0x11500, 0x00100},
1186 {"device-id", 0x11600, 0x00100},
1187 {"profile", 0x11700, 0x03900},
1188 {"default-config", 0x15000, 0x04000},
1189 {"user-config", 0x19000, 0x04000},
1190 {"firmware", 0x20000, 0x7c8000},
1191 {"certyficate", 0x7e8000, 0x08000},
1192 {"radio", 0x7f0000, 0x10000},
1196 .first_sysupgrade_partition
= "os-image",
1197 .last_sysupgrade_partition
= "file-system",
1200 /** Firmware layout for the C60v2 */
1202 .id
= "ARCHER-C60-V2",
1206 "{product_name:Archer C60,product_ver:2.0.0,special_id:42520000}\r\n"
1207 "{product_name:Archer C60,product_ver:2.0.0,special_id:45550000}\r\n"
1208 "{product_name:Archer C60,product_ver:2.0.0,special_id:55530000}\r\n",
1210 .soft_ver
= "soft_ver:2.0.0\n",
1213 {"factory-boot", 0x00000, 0x1fb00},
1214 {"default-mac", 0x1fb00, 0x00200},
1215 {"pin", 0x1fd00, 0x00100},
1216 {"product-info", 0x1fe00, 0x00100},
1217 {"device-id", 0x1ff00, 0x00100},
1218 {"fs-uboot", 0x20000, 0x10000},
1219 {"firmware", 0x30000, 0x7a0000},
1220 {"soft-version", 0x7d9500, 0x00100},
1221 {"support-list", 0x7d9600, 0x00100},
1222 {"extra-para", 0x7d9700, 0x00100},
1223 {"profile", 0x7d9800, 0x03000},
1224 {"default-config", 0x7dc800, 0x03000},
1225 {"partition-table", 0x7df800, 0x00800},
1226 {"user-config", 0x7e0000, 0x0c000},
1227 {"certificate", 0x7ec000, 0x04000},
1228 {"radio", 0x7f0000, 0x10000},
1232 .first_sysupgrade_partition
= "os-image",
1233 .last_sysupgrade_partition
= "file-system",
1236 /** Firmware layout for the C60v3 */
1238 .id
= "ARCHER-C60-V3",
1242 "{product_name:Archer C60,product_ver:3.0.0,special_id:42520000}\r\n"
1243 "{product_name:Archer C60,product_ver:3.0.0,special_id:45550000}\r\n"
1244 "{product_name:Archer C60,product_ver:3.0.0,special_id:55530000}\r\n",
1246 .soft_ver
= "soft_ver:3.0.0\n",
1249 {"factory-boot", 0x00000, 0x1fb00},
1250 {"default-mac", 0x1fb00, 0x00200},
1251 {"pin", 0x1fd00, 0x00100},
1252 {"product-info", 0x1fe00, 0x00100},
1253 {"device-id", 0x1ff00, 0x00100},
1254 {"fs-uboot", 0x20000, 0x10000},
1255 {"firmware", 0x30000, 0x7a0000},
1256 {"soft-version", 0x7d9500, 0x00100},
1257 {"support-list", 0x7d9600, 0x00100},
1258 {"extra-para", 0x7d9700, 0x00100},
1259 {"profile", 0x7d9800, 0x03000},
1260 {"default-config", 0x7dc800, 0x03000},
1261 {"partition-table", 0x7df800, 0x00800},
1262 {"user-config", 0x7e0000, 0x0c000},
1263 {"certificate", 0x7ec000, 0x04000},
1264 {"radio", 0x7f0000, 0x10000},
1268 .first_sysupgrade_partition
= "os-image",
1269 .last_sysupgrade_partition
= "file-system",
1272 /** Firmware layout for the C5 */
1274 .id
= "ARCHER-C5-V2",
1278 "{product_name:ArcherC5,product_ver:2.0.0,special_id:00000000}\r\n"
1279 "{product_name:ArcherC5,product_ver:2.0.0,special_id:55530000}\r\n"
1280 "{product_name:ArcherC5,product_ver:2.0.0,special_id:4A500000}\r\n", /* JP version */
1285 {"fs-uboot", 0x00000, 0x40000},
1286 {"os-image", 0x40000, 0x200000},
1287 {"file-system", 0x240000, 0xc00000},
1288 {"default-mac", 0xe40000, 0x00200},
1289 {"pin", 0xe40200, 0x00200},
1290 {"product-info", 0xe40400, 0x00200},
1291 {"partition-table", 0xe50000, 0x10000},
1292 {"soft-version", 0xe60000, 0x00200},
1293 {"support-list", 0xe61000, 0x0f000},
1294 {"profile", 0xe70000, 0x10000},
1295 {"default-config", 0xe80000, 0x10000},
1296 {"user-config", 0xe90000, 0x50000},
1297 {"log", 0xee0000, 0x100000},
1298 {"radio_bk", 0xfe0000, 0x10000},
1299 {"radio", 0xff0000, 0x10000},
1303 .first_sysupgrade_partition
= "os-image",
1304 .last_sysupgrade_partition
= "file-system"
1307 /** Firmware layout for the C7 */
1309 .id
= "ARCHER-C7-V4",
1312 "{product_name:Archer C7,product_ver:4.0.0,special_id:00000000}\n"
1313 "{product_name:Archer C7,product_ver:4.0.0,special_id:41550000}\n"
1314 "{product_name:Archer C7,product_ver:4.0.0,special_id:45550000}\n"
1315 "{product_name:Archer C7,product_ver:4.0.0,special_id:4B520000}\n"
1316 "{product_name:Archer C7,product_ver:4.0.0,special_id:42520000}\n"
1317 "{product_name:Archer C7,product_ver:4.0.0,special_id:4A500000}\n"
1318 "{product_name:Archer C7,product_ver:4.0.0,special_id:52550000}\n"
1319 "{product_name:Archer C7,product_ver:4.0.0,special_id:54570000}\n"
1320 "{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
1321 "{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
1323 .soft_ver
= "soft_ver:1.0.0\n",
1325 /* We're using a dynamic kernel/rootfs split here */
1327 {"factory-boot", 0x00000, 0x20000},
1328 {"fs-uboot", 0x20000, 0x20000},
1329 {"firmware", 0x40000, 0xEC0000}, /* Stock: name os-image base 0x40000 size 0x120000 */
1330 /* Stock: name file-system base 0x160000 size 0xda0000 */
1331 {"default-mac", 0xf00000, 0x00200},
1332 {"pin", 0xf00200, 0x00200},
1333 {"device-id", 0xf00400, 0x00100},
1334 {"product-info", 0xf00500, 0x0fb00},
1335 {"soft-version", 0xf10000, 0x00100},
1336 {"extra-para", 0xf11000, 0x01000},
1337 {"support-list", 0xf12000, 0x0a000},
1338 {"profile", 0xf1c000, 0x04000},
1339 {"default-config", 0xf20000, 0x10000},
1340 {"user-config", 0xf30000, 0x40000},
1341 {"qos-db", 0xf70000, 0x40000},
1342 {"certificate", 0xfb0000, 0x10000},
1343 {"partition-table", 0xfc0000, 0x10000},
1344 {"log", 0xfd0000, 0x20000},
1345 {"radio", 0xff0000, 0x10000},
1349 .first_sysupgrade_partition
= "os-image",
1350 .last_sysupgrade_partition
= "file-system",
1353 /** Firmware layout for the C7 v5*/
1355 .id
= "ARCHER-C7-V5",
1358 "{product_name:Archer C7,product_ver:5.0.0,special_id:00000000}\n"
1359 "{product_name:Archer C7,product_ver:5.0.0,special_id:45550000}\n"
1360 "{product_name:Archer C7,product_ver:5.0.0,special_id:55530000}\n"
1361 "{product_name:Archer C7,product_ver:5.0.0,special_id:43410000}\n"
1362 "{product_name:Archer C7,product_ver:5.0.0,special_id:4A500000}\n"
1363 "{product_name:Archer C7,product_ver:5.0.0,special_id:54570000}\n"
1364 "{product_name:Archer C7,product_ver:5.0.0,special_id:52550000}\n"
1365 "{product_name:Archer C7,product_ver:5.0.0,special_id:4B520000}\n",
1368 .soft_ver
= "soft_ver:7.0.0\n",
1370 /* We're using a dynamic kernel/rootfs split here */
1372 {"factory-boot", 0x00000, 0x20000},
1373 {"fs-uboot", 0x20000, 0x20000},
1374 {"partition-table", 0x40000, 0x10000},
1375 {"radio", 0x50000, 0x10000},
1376 {"default-mac", 0x60000, 0x00200},
1377 {"pin", 0x60200, 0x00200},
1378 {"device-id", 0x60400, 0x00100},
1379 {"product-info", 0x60500, 0x0fb00},
1380 {"soft-version", 0x70000, 0x01000},
1381 {"extra-para", 0x71000, 0x01000},
1382 {"support-list", 0x72000, 0x0a000},
1383 {"profile", 0x7c000, 0x04000},
1384 {"user-config", 0x80000, 0x40000},
1387 {"firmware", 0xc0000, 0xf00000}, /* Stock: name os-image base 0xc0000 size 0x120000 */
1388 /* Stock: name file-system base 0x1e0000 size 0xde0000 */
1390 {"log", 0xfc0000, 0x20000},
1391 {"certificate", 0xfe0000, 0x10000},
1392 {"default-config", 0xff0000, 0x10000},
1397 .first_sysupgrade_partition
= "os-image",
1398 .last_sysupgrade_partition
= "file-system",
1401 /** Firmware layout for the C9 */
1407 "{product_name:ArcherC9,"
1408 "product_ver:1.0.0,"
1409 "special_id:00000000}\n",
1414 {"fs-uboot", 0x00000, 0x40000},
1415 {"os-image", 0x40000, 0x200000},
1416 {"file-system", 0x240000, 0xc00000},
1417 {"default-mac", 0xe40000, 0x00200},
1418 {"pin", 0xe40200, 0x00200},
1419 {"product-info", 0xe40400, 0x00200},
1420 {"partition-table", 0xe50000, 0x10000},
1421 {"soft-version", 0xe60000, 0x00200},
1422 {"support-list", 0xe61000, 0x0f000},
1423 {"profile", 0xe70000, 0x10000},
1424 {"default-config", 0xe80000, 0x10000},
1425 {"user-config", 0xe90000, 0x50000},
1426 {"log", 0xee0000, 0x100000},
1427 {"radio_bk", 0xfe0000, 0x10000},
1428 {"radio", 0xff0000, 0x10000},
1432 .first_sysupgrade_partition
= "os-image",
1433 .last_sysupgrade_partition
= "file-system"
1436 /** Firmware layout for the EAP120 */
1439 .vendor
= "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1442 "EAP120(TP-LINK|UN|N300-2):1.0\r\n",
1447 {"fs-uboot", 0x00000, 0x20000},
1448 {"partition-table", 0x20000, 0x02000},
1449 {"default-mac", 0x30000, 0x00020},
1450 {"support-list", 0x31000, 0x00100},
1451 {"product-info", 0x31100, 0x00100},
1452 {"soft-version", 0x32000, 0x00100},
1453 {"os-image", 0x40000, 0x180000},
1454 {"file-system", 0x1c0000, 0x600000},
1455 {"user-config", 0x7c0000, 0x10000},
1456 {"backup-config", 0x7d0000, 0x10000},
1457 {"log", 0x7e0000, 0x10000},
1458 {"radio", 0x7f0000, 0x10000},
1462 .first_sysupgrade_partition
= "os-image",
1463 .last_sysupgrade_partition
= "file-system"
1466 /** Firmware layout for the EAP225-Outdoor v1 */
1468 .id
= "EAP225-OUTDOOR-V1",
1471 "EAP225-Outdoor(TP-Link|UN|AC1200-D):1.0\r\n",
1472 .part_trail
= PART_TRAIL_NONE
,
1474 .soft_ver_compat_level
= 1,
1477 {"fs-uboot", 0x00000, 0x20000},
1478 {"partition-table", 0x20000, 0x02000},
1479 {"default-mac", 0x30000, 0x01000},
1480 {"support-list", 0x31000, 0x00100},
1481 {"product-info", 0x31100, 0x00400},
1482 {"soft-version", 0x32000, 0x00100},
1483 {"firmware", 0x40000, 0xd80000},
1484 {"user-config", 0xdc0000, 0x30000},
1485 {"mutil-log", 0xf30000, 0x80000},
1486 {"oops", 0xfb0000, 0x40000},
1487 {"radio", 0xff0000, 0x10000},
1491 .first_sysupgrade_partition
= "os-image",
1492 .last_sysupgrade_partition
= "file-system"
1495 /** Firmware layout for the EAP225 v3 */
1500 "EAP225(TP-Link|UN|AC1350-D):3.0\r\n",
1501 .part_trail
= PART_TRAIL_NONE
,
1503 .soft_ver_compat_level
= 1,
1506 {"fs-uboot", 0x00000, 0x20000},
1507 {"partition-table", 0x20000, 0x02000},
1508 {"default-mac", 0x30000, 0x01000},
1509 {"support-list", 0x31000, 0x00100},
1510 {"product-info", 0x31100, 0x00400},
1511 {"soft-version", 0x32000, 0x00100},
1512 {"firmware", 0x40000, 0xd80000},
1513 {"user-config", 0xdc0000, 0x30000},
1514 {"mutil-log", 0xf30000, 0x80000},
1515 {"oops", 0xfb0000, 0x40000},
1516 {"radio", 0xff0000, 0x10000},
1520 .first_sysupgrade_partition
= "os-image",
1521 .last_sysupgrade_partition
= "file-system"
1524 /** Firmware layout for the EAP225-Wall v2 */
1526 .id
= "EAP225-WALL-V2",
1529 "EAP225-Wall(TP-Link|UN|AC1200-D):2.0\r\n",
1530 .part_trail
= PART_TRAIL_NONE
,
1532 .soft_ver_compat_level
= 1,
1535 {"fs-uboot", 0x00000, 0x20000},
1536 {"partition-table", 0x20000, 0x02000},
1537 {"default-mac", 0x30000, 0x01000},
1538 {"support-list", 0x31000, 0x00100},
1539 {"product-info", 0x31100, 0x00400},
1540 {"soft-version", 0x32000, 0x00100},
1541 {"firmware", 0x40000, 0xd80000},
1542 {"user-config", 0xdc0000, 0x30000},
1543 {"mutil-log", 0xf30000, 0x80000},
1544 {"oops", 0xfb0000, 0x40000},
1545 {"radio", 0xff0000, 0x10000},
1549 .first_sysupgrade_partition
= "os-image",
1550 .last_sysupgrade_partition
= "file-system"
1553 /** Firmware layout for the EAP235-Wall v1 */
1555 .id
= "EAP235-WALL-V1",
1558 "EAP235-Wall(TP-Link|UN|AC1200-D):1.0\r\n",
1559 .part_trail
= PART_TRAIL_NONE
,
1561 .soft_ver_compat_level
= 1,
1564 {"fs-uboot", 0x00000, 0x80000},
1565 {"partition-table", 0x80000, 0x02000},
1566 {"default-mac", 0x90000, 0x01000},
1567 {"support-list", 0x91000, 0x00100},
1568 {"product-info", 0x91100, 0x00400},
1569 {"soft-version", 0x92000, 0x00100},
1570 {"firmware", 0xa0000, 0xd20000},
1571 {"user-config", 0xdc0000, 0x30000},
1572 {"mutil-log", 0xf30000, 0x80000},
1573 {"oops", 0xfb0000, 0x40000},
1574 {"radio", 0xff0000, 0x10000},
1578 .first_sysupgrade_partition
= "os-image",
1579 .last_sysupgrade_partition
= "file-system"
1582 /** Firmware layout for the EAP245 v1 */
1587 "EAP245(TP-LINK|UN|AC1750-D):1.0\r\n",
1588 .part_trail
= PART_TRAIL_NONE
,
1592 {"fs-uboot", 0x00000, 0x20000},
1593 {"partition-table", 0x20000, 0x02000},
1594 {"default-mac", 0x30000, 0x01000},
1595 {"support-list", 0x31000, 0x00100},
1596 {"product-info", 0x31100, 0x00400},
1597 {"soft-version", 0x32000, 0x00100},
1598 {"firmware", 0x40000, 0xd80000},
1599 {"user-config", 0xdc0000, 0x30000},
1600 {"radio", 0xff0000, 0x10000},
1604 .first_sysupgrade_partition
= "os-image",
1605 .last_sysupgrade_partition
= "file-system"
1608 /** Firmware layout for the EAP245 v3 */
1613 "EAP245(TP-Link|UN|AC1750-D):3.0\r\n",
1614 .part_trail
= PART_TRAIL_NONE
,
1616 .soft_ver_compat_level
= 1,
1618 /** Firmware partition with dynamic kernel/rootfs split */
1620 {"factroy-boot", 0x00000, 0x40000},
1621 {"fs-uboot", 0x40000, 0x40000},
1622 {"partition-table", 0x80000, 0x10000},
1623 {"default-mac", 0x90000, 0x01000},
1624 {"support-list", 0x91000, 0x00100},
1625 {"product-info", 0x91100, 0x00400},
1626 {"soft-version", 0x92000, 0x00100},
1627 {"radio", 0xa0000, 0x10000},
1628 {"extra-para", 0xb0000, 0x10000},
1629 {"firmware", 0xc0000, 0xe40000},
1630 {"config", 0xf00000, 0x30000},
1631 {"mutil-log", 0xf30000, 0x80000},
1632 {"oops", 0xfb0000, 0x40000},
1636 .first_sysupgrade_partition
= "os-image",
1637 .last_sysupgrade_partition
= "file-system"
1640 /** Firmware layout for the TL-WA850RE v2 */
1642 .id
= "TLWA850REV2",
1646 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55530000}\n"
1647 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:00000000}\n"
1648 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:55534100}\n"
1649 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:45550000}\n"
1650 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4B520000}\n"
1651 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:42520000}\n"
1652 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:4A500000}\n"
1653 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:43410000}\n"
1654 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:41550000}\n"
1655 "{product_name:TL-WA850RE,product_ver:2.0.0,special_id:52550000}\n",
1660 576KB were moved from file-system to os-image
1661 in comparison to the stock image
1664 {"fs-uboot", 0x00000, 0x20000},
1665 {"firmware", 0x20000, 0x390000},
1666 {"partition-table", 0x3b0000, 0x02000},
1667 {"default-mac", 0x3c0000, 0x00020},
1668 {"pin", 0x3c0100, 0x00020},
1669 {"product-info", 0x3c1000, 0x01000},
1670 {"soft-version", 0x3c2000, 0x00100},
1671 {"support-list", 0x3c3000, 0x01000},
1672 {"profile", 0x3c4000, 0x08000},
1673 {"user-config", 0x3d0000, 0x10000},
1674 {"default-config", 0x3e0000, 0x10000},
1675 {"radio", 0x3f0000, 0x10000},
1679 .first_sysupgrade_partition
= "os-image",
1680 .last_sysupgrade_partition
= "file-system"
1683 /** Firmware layout for the TL-WA855RE v1 */
1685 .id
= "TLWA855REV1",
1689 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:00000000}\n"
1690 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:55530000}\n"
1691 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:45550000}\n"
1692 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4B520000}\n"
1693 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:42520000}\n"
1694 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:4A500000}\n"
1695 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:43410000}\n"
1696 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:41550000}\n"
1697 "{product_name:TL-WA855RE,product_ver:1.0.0,special_id:52550000}\n",
1702 {"fs-uboot", 0x00000, 0x20000},
1703 {"os-image", 0x20000, 0x150000},
1704 {"file-system", 0x170000, 0x240000},
1705 {"partition-table", 0x3b0000, 0x02000},
1706 {"default-mac", 0x3c0000, 0x00020},
1707 {"pin", 0x3c0100, 0x00020},
1708 {"product-info", 0x3c1000, 0x01000},
1709 {"soft-version", 0x3c2000, 0x00100},
1710 {"support-list", 0x3c3000, 0x01000},
1711 {"profile", 0x3c4000, 0x08000},
1712 {"user-config", 0x3d0000, 0x10000},
1713 {"default-config", 0x3e0000, 0x10000},
1714 {"radio", 0x3f0000, 0x10000},
1718 .first_sysupgrade_partition
= "os-image",
1719 .last_sysupgrade_partition
= "file-system"
1722 /** Firmware layout for the TL-WPA8630P v2 (EU)*/
1724 .id
= "TL-WPA8630P-V2.0-EU",
1728 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:45550000}\n",
1733 {"factory-uboot", 0x00000, 0x20000},
1734 {"fs-uboot", 0x20000, 0x20000},
1735 {"firmware", 0x40000, 0x5e0000},
1736 {"partition-table", 0x620000, 0x02000},
1737 {"default-mac", 0x630000, 0x00020},
1738 {"pin", 0x630100, 0x00020},
1739 {"device-id", 0x630200, 0x00030},
1740 {"product-info", 0x631100, 0x01000},
1741 {"extra-para", 0x632100, 0x01000},
1742 {"soft-version", 0x640000, 0x01000},
1743 {"support-list", 0x641000, 0x01000},
1744 {"profile", 0x642000, 0x08000},
1745 {"user-config", 0x650000, 0x10000},
1746 {"default-config", 0x660000, 0x10000},
1747 {"default-nvm", 0x670000, 0xc0000},
1748 {"default-pib", 0x730000, 0x40000},
1749 {"radio", 0x7f0000, 0x10000},
1753 .first_sysupgrade_partition
= "os-image",
1754 .last_sysupgrade_partition
= "file-system"
1757 /** Firmware layout for the TL-WPA8630P v2 (INT)*/
1759 .id
= "TL-WPA8630P-V2-INT",
1763 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:41550000}\n"
1764 "{product_name:TL-WPA8630P,product_ver:2.0.0,special_id:44450000}\n"
1765 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:41550000}\n",
1770 {"factory-uboot", 0x00000, 0x20000},
1771 {"fs-uboot", 0x20000, 0x20000},
1772 {"firmware", 0x40000, 0x5e0000},
1773 {"partition-table", 0x620000, 0x02000},
1774 {"extra-para", 0x632100, 0x01000},
1775 {"soft-version", 0x640000, 0x01000},
1776 {"support-list", 0x641000, 0x01000},
1777 {"profile", 0x642000, 0x08000},
1778 {"user-config", 0x650000, 0x10000},
1779 {"default-config", 0x660000, 0x10000},
1780 {"default-nvm", 0x670000, 0xc0000},
1781 {"default-pib", 0x730000, 0x40000},
1782 {"default-mac", 0x7e0000, 0x00020},
1783 {"pin", 0x7e0100, 0x00020},
1784 {"device-id", 0x7e0200, 0x00030},
1785 {"product-info", 0x7e1100, 0x01000},
1786 {"radio", 0x7f0000, 0x10000},
1790 .first_sysupgrade_partition
= "os-image",
1791 .last_sysupgrade_partition
= "file-system"
1794 /** Firmware layout for the TL-WPA8630P v2.1 (EU)*/
1796 .id
= "TL-WPA8630P-V2.1-EU",
1800 "{product_name:TL-WPA8630P,product_ver:2.1.0,special_id:45550000}\n",
1805 {"factory-uboot", 0x00000, 0x20000},
1806 {"fs-uboot", 0x20000, 0x20000},
1807 {"firmware", 0x40000, 0x5e0000},
1808 {"extra-para", 0x680000, 0x01000},
1809 {"product-info", 0x690000, 0x01000},
1810 {"partition-table", 0x6a0000, 0x02000},
1811 {"soft-version", 0x6b0000, 0x01000},
1812 {"support-list", 0x6b1000, 0x01000},
1813 {"profile", 0x6b2000, 0x08000},
1814 {"user-config", 0x6c0000, 0x10000},
1815 {"default-config", 0x6d0000, 0x10000},
1816 {"default-nvm", 0x6e0000, 0xc0000},
1817 {"default-pib", 0x7a0000, 0x40000},
1818 {"default-mac", 0x7e0000, 0x00020},
1819 {"pin", 0x7e0100, 0x00020},
1820 {"device-id", 0x7e0200, 0x00030},
1821 {"radio", 0x7f0000, 0x10000},
1825 .first_sysupgrade_partition
= "os-image",
1826 .last_sysupgrade_partition
= "file-system"
1829 /** Firmware layout for the TL-WR1043 v5 */
1831 .id
= "TLWR1043NV5",
1835 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:45550000}\n"
1836 "{product_name:TL-WR1043N,product_ver:5.0.0,special_id:55530000}\n",
1838 .soft_ver
= "soft_ver:1.0.0\n",
1840 {"factory-boot", 0x00000, 0x20000},
1841 {"fs-uboot", 0x20000, 0x20000},
1842 {"firmware", 0x40000, 0xec0000},
1843 {"default-mac", 0xf00000, 0x00200},
1844 {"pin", 0xf00200, 0x00200},
1845 {"device-id", 0xf00400, 0x00100},
1846 {"product-info", 0xf00500, 0x0fb00},
1847 {"soft-version", 0xf10000, 0x01000},
1848 {"extra-para", 0xf11000, 0x01000},
1849 {"support-list", 0xf12000, 0x0a000},
1850 {"profile", 0xf1c000, 0x04000},
1851 {"default-config", 0xf20000, 0x10000},
1852 {"user-config", 0xf30000, 0x40000},
1853 {"qos-db", 0xf70000, 0x40000},
1854 {"certificate", 0xfb0000, 0x10000},
1855 {"partition-table", 0xfc0000, 0x10000},
1856 {"log", 0xfd0000, 0x20000},
1857 {"radio", 0xff0000, 0x10000},
1860 .first_sysupgrade_partition
= "os-image",
1861 .last_sysupgrade_partition
= "file-system"
1864 /** Firmware layout for the TL-WR1043 v4 */
1866 .id
= "TLWR1043NDV4",
1870 "{product_name:TL-WR1043ND,product_ver:4.0.0,special_id:45550000}\n",
1874 /* We're using a dynamic kernel/rootfs split here */
1876 {"fs-uboot", 0x00000, 0x20000},
1877 {"firmware", 0x20000, 0xf30000},
1878 {"default-mac", 0xf50000, 0x00200},
1879 {"pin", 0xf50200, 0x00200},
1880 {"product-info", 0xf50400, 0x0fc00},
1881 {"soft-version", 0xf60000, 0x0b000},
1882 {"support-list", 0xf6b000, 0x04000},
1883 {"profile", 0xf70000, 0x04000},
1884 {"default-config", 0xf74000, 0x0b000},
1885 {"user-config", 0xf80000, 0x40000},
1886 {"partition-table", 0xfc0000, 0x10000},
1887 {"log", 0xfd0000, 0x20000},
1888 {"radio", 0xff0000, 0x10000},
1892 .first_sysupgrade_partition
= "os-image",
1893 .last_sysupgrade_partition
= "file-system"
1896 /** Firmware layout for the TL-WR902AC v1 */
1898 .id
= "TL-WR902AC-V1",
1902 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:45550000}\n"
1903 "{product_name:TL-WR902AC,product_ver:1.0.0,special_id:55530000}\n",
1908 384KB were moved from file-system to os-image
1909 in comparison to the stock image
1912 {"fs-uboot", 0x00000, 0x20000},
1913 {"firmware", 0x20000, 0x730000},
1914 {"default-mac", 0x750000, 0x00200},
1915 {"pin", 0x750200, 0x00200},
1916 {"product-info", 0x750400, 0x0fc00},
1917 {"soft-version", 0x760000, 0x0b000},
1918 {"support-list", 0x76b000, 0x04000},
1919 {"profile", 0x770000, 0x04000},
1920 {"default-config", 0x774000, 0x0b000},
1921 {"user-config", 0x780000, 0x40000},
1922 {"partition-table", 0x7c0000, 0x10000},
1923 {"log", 0x7d0000, 0x20000},
1924 {"radio", 0x7f0000, 0x10000},
1928 .first_sysupgrade_partition
= "os-image",
1929 .last_sysupgrade_partition
= "file-system",
1932 /** Firmware layout for the TL-WR942N V1 */
1938 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:00000000}\r\n"
1939 "{product_name:TL-WR942N,product_ver:1.0.0,special_id:52550000}\r\n",
1944 {"fs-uboot", 0x00000, 0x20000},
1945 {"firmware", 0x20000, 0xe20000},
1946 {"default-mac", 0xe40000, 0x00200},
1947 {"pin", 0xe40200, 0x00200},
1948 {"product-info", 0xe40400, 0x0fc00},
1949 {"partition-table", 0xe50000, 0x10000},
1950 {"soft-version", 0xe60000, 0x10000},
1951 {"support-list", 0xe70000, 0x10000},
1952 {"profile", 0xe80000, 0x10000},
1953 {"default-config", 0xe90000, 0x10000},
1954 {"user-config", 0xea0000, 0x40000},
1955 {"qos-db", 0xee0000, 0x40000},
1956 {"certificate", 0xf20000, 0x10000},
1957 {"usb-config", 0xfb0000, 0x10000},
1958 {"log", 0xfc0000, 0x20000},
1959 {"radio-bk", 0xfe0000, 0x10000},
1960 {"radio", 0xff0000, 0x10000},
1964 .first_sysupgrade_partition
= "os-image",
1965 .last_sysupgrade_partition
= "file-system",
1968 /** Firmware layout for the RE200 v2 */
1974 "{product_name:RE200,product_ver:2.0.0,special_id:00000000}\n"
1975 "{product_name:RE200,product_ver:2.0.0,special_id:41520000}\n"
1976 "{product_name:RE200,product_ver:2.0.0,special_id:41550000}\n"
1977 "{product_name:RE200,product_ver:2.0.0,special_id:42520000}\n"
1978 "{product_name:RE200,product_ver:2.0.0,special_id:43410000}\n"
1979 "{product_name:RE200,product_ver:2.0.0,special_id:45530000}\n"
1980 "{product_name:RE200,product_ver:2.0.0,special_id:45550000}\n"
1981 "{product_name:RE200,product_ver:2.0.0,special_id:49440000}\n"
1982 "{product_name:RE200,product_ver:2.0.0,special_id:4a500000}\n"
1983 "{product_name:RE200,product_ver:2.0.0,special_id:4b520000}\n"
1984 "{product_name:RE200,product_ver:2.0.0,special_id:52550000}\n"
1985 "{product_name:RE200,product_ver:2.0.0,special_id:54570000}\n"
1986 "{product_name:RE200,product_ver:2.0.0,special_id:55530000}\n",
1991 {"fs-uboot", 0x00000, 0x20000},
1992 {"firmware", 0x20000, 0x7a0000},
1993 {"partition-table", 0x7c0000, 0x02000},
1994 {"default-mac", 0x7c2000, 0x00020},
1995 {"pin", 0x7c2100, 0x00020},
1996 {"product-info", 0x7c3100, 0x01000},
1997 {"soft-version", 0x7c4200, 0x01000},
1998 {"support-list", 0x7c5200, 0x01000},
1999 {"profile", 0x7c6200, 0x08000},
2000 {"config-info", 0x7ce200, 0x00400},
2001 {"user-config", 0x7d0000, 0x10000},
2002 {"default-config", 0x7e0000, 0x10000},
2003 {"radio", 0x7f0000, 0x10000},
2007 .first_sysupgrade_partition
= "os-image",
2008 .last_sysupgrade_partition
= "file-system"
2011 /** Firmware layout for the RE200 v3 */
2017 "{product_name:RE200,product_ver:3.0.0,special_id:00000000}\n"
2018 "{product_name:RE200,product_ver:3.0.0,special_id:41520000}\n"
2019 "{product_name:RE200,product_ver:3.0.0,special_id:41550000}\n"
2020 "{product_name:RE200,product_ver:3.0.0,special_id:42520000}\n"
2021 "{product_name:RE200,product_ver:3.0.0,special_id:43410000}\n"
2022 "{product_name:RE200,product_ver:3.0.0,special_id:45470000}\n"
2023 "{product_name:RE200,product_ver:3.0.0,special_id:45530000}\n"
2024 "{product_name:RE200,product_ver:3.0.0,special_id:45550000}\n"
2025 "{product_name:RE200,product_ver:3.0.0,special_id:49440000}\n"
2026 "{product_name:RE200,product_ver:3.0.0,special_id:4A500000}\n"
2027 "{product_name:RE200,product_ver:3.0.0,special_id:4B520000}\n"
2028 "{product_name:RE200,product_ver:3.0.0,special_id:52550000}\n"
2029 "{product_name:RE200,product_ver:3.0.0,special_id:54570000}\n"
2030 "{product_name:RE200,product_ver:3.0.0,special_id:55530000}\n",
2035 {"fs-uboot", 0x00000, 0x20000},
2036 {"firmware", 0x20000, 0x7a0000},
2037 {"partition-table", 0x7c0000, 0x02000},
2038 {"default-mac", 0x7c2000, 0x00020},
2039 {"pin", 0x7c2100, 0x00020},
2040 {"product-info", 0x7c3100, 0x01000},
2041 {"soft-version", 0x7c4200, 0x01000},
2042 {"support-list", 0x7c5200, 0x01000},
2043 {"profile", 0x7c6200, 0x08000},
2044 {"config-info", 0x7ce200, 0x00400},
2045 {"user-config", 0x7d0000, 0x10000},
2046 {"default-config", 0x7e0000, 0x10000},
2047 {"radio", 0x7f0000, 0x10000},
2051 .first_sysupgrade_partition
= "os-image",
2052 .last_sysupgrade_partition
= "file-system"
2055 /** Firmware layout for the RE200 v4 */
2061 "{product_name:RE200,product_ver:4.0.0,special_id:00000000}\n"
2062 "{product_name:RE200,product_ver:4.0.0,special_id:45550000}\n"
2063 "{product_name:RE200,product_ver:4.0.0,special_id:4A500000}\n"
2064 "{product_name:RE200,product_ver:4.0.0,special_id:4B520000}\n"
2065 "{product_name:RE200,product_ver:4.0.0,special_id:43410000}\n"
2066 "{product_name:RE200,product_ver:4.0.0,special_id:41550000}\n"
2067 "{product_name:RE200,product_ver:4.0.0,special_id:42520000}\n"
2068 "{product_name:RE200,product_ver:4.0.0,special_id:55530000}\n"
2069 "{product_name:RE200,product_ver:4.0.0,special_id:41520000}\n"
2070 "{product_name:RE200,product_ver:4.0.0,special_id:52550000}\n"
2071 "{product_name:RE200,product_ver:4.0.0,special_id:54570000}\n"
2072 "{product_name:RE200,product_ver:4.0.0,special_id:45530000}\n"
2073 "{product_name:RE200,product_ver:4.0.0,special_id:49440000}\n"
2074 "{product_name:RE200,product_ver:4.0.0,special_id:45470000}\n",
2076 .soft_ver
= "soft_ver:1.1.0\n",
2079 {"fs-uboot", 0x00000, 0x20000},
2080 {"firmware", 0x20000, 0x7a0000},
2081 {"partition-table", 0x7c0000, 0x02000},
2082 {"default-mac", 0x7c2000, 0x00020},
2083 {"pin", 0x7c2100, 0x00020},
2084 {"product-info", 0x7c3100, 0x01000},
2085 {"soft-version", 0x7c4200, 0x01000},
2086 {"support-list", 0x7c5200, 0x01000},
2087 {"profile", 0x7c6200, 0x08000},
2088 {"config-info", 0x7ce200, 0x00400},
2089 {"user-config", 0x7d0000, 0x10000},
2090 {"default-config", 0x7e0000, 0x10000},
2091 {"radio", 0x7f0000, 0x10000},
2095 .first_sysupgrade_partition
= "os-image",
2096 .last_sysupgrade_partition
= "file-system"
2099 /** Firmware layout for the RE220 v2 */
2105 "{product_name:RE220,product_ver:2.0.0,special_id:00000000}\n"
2106 "{product_name:RE220,product_ver:2.0.0,special_id:41520000}\n"
2107 "{product_name:RE220,product_ver:2.0.0,special_id:41550000}\n"
2108 "{product_name:RE220,product_ver:2.0.0,special_id:42520000}\n"
2109 "{product_name:RE220,product_ver:2.0.0,special_id:43410000}\n"
2110 "{product_name:RE220,product_ver:2.0.0,special_id:45530000}\n"
2111 "{product_name:RE220,product_ver:2.0.0,special_id:45550000}\n"
2112 "{product_name:RE220,product_ver:2.0.0,special_id:49440000}\n"
2113 "{product_name:RE220,product_ver:2.0.0,special_id:4a500000}\n"
2114 "{product_name:RE220,product_ver:2.0.0,special_id:4b520000}\n"
2115 "{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n"
2116 "{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n"
2117 "{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n",
2122 {"fs-uboot", 0x00000, 0x20000},
2123 {"firmware", 0x20000, 0x7a0000},
2124 {"partition-table", 0x7c0000, 0x02000},
2125 {"default-mac", 0x7c2000, 0x00020},
2126 {"pin", 0x7c2100, 0x00020},
2127 {"product-info", 0x7c3100, 0x01000},
2128 {"soft-version", 0x7c4200, 0x01000},
2129 {"support-list", 0x7c5200, 0x01000},
2130 {"profile", 0x7c6200, 0x08000},
2131 {"config-info", 0x7ce200, 0x00400},
2132 {"user-config", 0x7d0000, 0x10000},
2133 {"default-config", 0x7e0000, 0x10000},
2134 {"radio", 0x7f0000, 0x10000},
2138 .first_sysupgrade_partition
= "os-image",
2139 .last_sysupgrade_partition
= "file-system"
2142 /** Firmware layout for the RE305 v1 */
2148 "{product_name:RE305,product_ver:1.0.0,special_id:45550000}\n"
2149 "{product_name:RE305,product_ver:1.0.0,special_id:55530000}\n"
2150 "{product_name:RE305,product_ver:1.0.0,special_id:4a500000}\n"
2151 "{product_name:RE305,product_ver:1.0.0,special_id:42520000}\n"
2152 "{product_name:RE305,product_ver:1.0.0,special_id:4b520000}\n"
2153 "{product_name:RE305,product_ver:1.0.0,special_id:41550000}\n"
2154 "{product_name:RE305,product_ver:1.0.0,special_id:43410000}\n",
2159 {"fs-uboot", 0x00000, 0x20000},
2160 {"firmware", 0x20000, 0x5e0000},
2161 {"partition-table", 0x600000, 0x02000},
2162 {"default-mac", 0x610000, 0x00020},
2163 {"pin", 0x610100, 0x00020},
2164 {"product-info", 0x611100, 0x01000},
2165 {"soft-version", 0x620000, 0x01000},
2166 {"support-list", 0x621000, 0x01000},
2167 {"profile", 0x622000, 0x08000},
2168 {"user-config", 0x630000, 0x10000},
2169 {"default-config", 0x640000, 0x10000},
2170 {"radio", 0x7f0000, 0x10000},
2174 .first_sysupgrade_partition
= "os-image",
2175 .last_sysupgrade_partition
= "file-system"
2178 /** Firmware layout for the RE350 v1 */
2184 "{product_name:RE350,product_ver:1.0.0,special_id:45550000}\n"
2185 "{product_name:RE350,product_ver:1.0.0,special_id:00000000}\n"
2186 "{product_name:RE350,product_ver:1.0.0,special_id:41550000}\n"
2187 "{product_name:RE350,product_ver:1.0.0,special_id:55530000}\n"
2188 "{product_name:RE350,product_ver:1.0.0,special_id:43410000}\n"
2189 "{product_name:RE350,product_ver:1.0.0,special_id:4b520000}\n"
2190 "{product_name:RE350,product_ver:1.0.0,special_id:4a500000}\n",
2194 /** We're using a dynamic kernel/rootfs split here */
2196 {"fs-uboot", 0x00000, 0x20000},
2197 {"firmware", 0x20000, 0x5e0000},
2198 {"partition-table", 0x600000, 0x02000},
2199 {"default-mac", 0x610000, 0x00020},
2200 {"pin", 0x610100, 0x00020},
2201 {"product-info", 0x611100, 0x01000},
2202 {"soft-version", 0x620000, 0x01000},
2203 {"support-list", 0x621000, 0x01000},
2204 {"profile", 0x622000, 0x08000},
2205 {"user-config", 0x630000, 0x10000},
2206 {"default-config", 0x640000, 0x10000},
2207 {"radio", 0x7f0000, 0x10000},
2211 .first_sysupgrade_partition
= "os-image",
2212 .last_sysupgrade_partition
= "file-system"
2215 /** Firmware layout for the RE350K v1 */
2221 "{product_name:RE350K,product_ver:1.0.0,special_id:00000000,product_region:US}\n",
2225 /** We're using a dynamic kernel/rootfs split here */
2227 {"fs-uboot", 0x00000, 0x20000},
2228 {"firmware", 0x20000, 0xd70000},
2229 {"partition-table", 0xd90000, 0x02000},
2230 {"default-mac", 0xda0000, 0x00020},
2231 {"pin", 0xda0100, 0x00020},
2232 {"product-info", 0xda1100, 0x01000},
2233 {"soft-version", 0xdb0000, 0x01000},
2234 {"support-list", 0xdb1000, 0x01000},
2235 {"profile", 0xdb2000, 0x08000},
2236 {"user-config", 0xdc0000, 0x10000},
2237 {"default-config", 0xdd0000, 0x10000},
2238 {"device-id", 0xde0000, 0x00108},
2239 {"radio", 0xff0000, 0x10000},
2243 .first_sysupgrade_partition
= "os-image",
2244 .last_sysupgrade_partition
= "file-system"
2247 /** Firmware layout for the RE355 */
2253 "{product_name:RE355,product_ver:1.0.0,special_id:00000000}\r\n"
2254 "{product_name:RE355,product_ver:1.0.0,special_id:55530000}\r\n"
2255 "{product_name:RE355,product_ver:1.0.0,special_id:45550000}\r\n"
2256 "{product_name:RE355,product_ver:1.0.0,special_id:4A500000}\r\n"
2257 "{product_name:RE355,product_ver:1.0.0,special_id:43410000}\r\n"
2258 "{product_name:RE355,product_ver:1.0.0,special_id:41550000}\r\n"
2259 "{product_name:RE355,product_ver:1.0.0,special_id:4B520000}\r\n"
2260 "{product_name:RE355,product_ver:1.0.0,special_id:55534100}\r\n",
2264 /* We're using a dynamic kernel/rootfs split here */
2266 {"fs-uboot", 0x00000, 0x20000},
2267 {"firmware", 0x20000, 0x5e0000},
2268 {"partition-table", 0x600000, 0x02000},
2269 {"default-mac", 0x610000, 0x00020},
2270 {"pin", 0x610100, 0x00020},
2271 {"product-info", 0x611100, 0x01000},
2272 {"soft-version", 0x620000, 0x01000},
2273 {"support-list", 0x621000, 0x01000},
2274 {"profile", 0x622000, 0x08000},
2275 {"user-config", 0x630000, 0x10000},
2276 {"default-config", 0x640000, 0x10000},
2277 {"radio", 0x7f0000, 0x10000},
2281 .first_sysupgrade_partition
= "os-image",
2282 .last_sysupgrade_partition
= "file-system"
2285 /** Firmware layout for the RE450 */
2291 "{product_name:RE450,product_ver:1.0.0,special_id:00000000}\r\n"
2292 "{product_name:RE450,product_ver:1.0.0,special_id:55530000}\r\n"
2293 "{product_name:RE450,product_ver:1.0.0,special_id:45550000}\r\n"
2294 "{product_name:RE450,product_ver:1.0.0,special_id:4A500000}\r\n"
2295 "{product_name:RE450,product_ver:1.0.0,special_id:43410000}\r\n"
2296 "{product_name:RE450,product_ver:1.0.0,special_id:41550000}\r\n"
2297 "{product_name:RE450,product_ver:1.0.0,special_id:4B520000}\r\n"
2298 "{product_name:RE450,product_ver:1.0.0,special_id:55534100}\r\n",
2302 /** We're using a dynamic kernel/rootfs split here */
2304 {"fs-uboot", 0x00000, 0x20000},
2305 {"firmware", 0x20000, 0x5e0000},
2306 {"partition-table", 0x600000, 0x02000},
2307 {"default-mac", 0x610000, 0x00020},
2308 {"pin", 0x610100, 0x00020},
2309 {"product-info", 0x611100, 0x01000},
2310 {"soft-version", 0x620000, 0x01000},
2311 {"support-list", 0x621000, 0x01000},
2312 {"profile", 0x622000, 0x08000},
2313 {"user-config", 0x630000, 0x10000},
2314 {"default-config", 0x640000, 0x10000},
2315 {"radio", 0x7f0000, 0x10000},
2319 .first_sysupgrade_partition
= "os-image",
2320 .last_sysupgrade_partition
= "file-system"
2323 /** Firmware layout for the RE450 v2 */
2329 "{product_name:RE450,product_ver:2.0.0,special_id:00000000}\r\n"
2330 "{product_name:RE450,product_ver:2.0.0,special_id:55530000}\r\n"
2331 "{product_name:RE450,product_ver:2.0.0,special_id:45550000}\r\n"
2332 "{product_name:RE450,product_ver:2.0.0,special_id:4A500000}\r\n"
2333 "{product_name:RE450,product_ver:2.0.0,special_id:43410000}\r\n"
2334 "{product_name:RE450,product_ver:2.0.0,special_id:41550000}\r\n"
2335 "{product_name:RE450,product_ver:2.0.0,special_id:41530000}\r\n"
2336 "{product_name:RE450,product_ver:2.0.0,special_id:4B520000}\r\n"
2337 "{product_name:RE450,product_ver:2.0.0,special_id:42520000}\r\n",
2341 /* We're using a dynamic kernel/rootfs split here */
2343 {"fs-uboot", 0x00000, 0x20000},
2344 {"firmware", 0x20000, 0x5e0000},
2345 {"partition-table", 0x600000, 0x02000},
2346 {"default-mac", 0x610000, 0x00020},
2347 {"pin", 0x610100, 0x00020},
2348 {"product-info", 0x611100, 0x01000},
2349 {"soft-version", 0x620000, 0x01000},
2350 {"support-list", 0x621000, 0x01000},
2351 {"profile", 0x622000, 0x08000},
2352 {"user-config", 0x630000, 0x10000},
2353 {"default-config", 0x640000, 0x10000},
2354 {"radio", 0x7f0000, 0x10000},
2358 .first_sysupgrade_partition
= "os-image",
2359 .last_sysupgrade_partition
= "file-system"
2362 /** Firmware layout for the RE450 v3 */
2368 "{product_name:RE450,product_ver:3.0.0,special_id:00000000}\r\n"
2369 "{product_name:RE450,product_ver:3.0.0,special_id:55530000}\r\n"
2370 "{product_name:RE450,product_ver:3.0.0,special_id:45550000}\r\n"
2371 "{product_name:RE450,product_ver:3.0.0,special_id:4A500000}\r\n"
2372 "{product_name:RE450,product_ver:3.0.0,special_id:43410000}\r\n"
2373 "{product_name:RE450,product_ver:3.0.0,special_id:41550000}\r\n"
2374 "{product_name:RE450,product_ver:3.0.0,special_id:41530000}\r\n"
2375 "{product_name:RE450,product_ver:3.0.0,special_id:4B520000}\r\n"
2376 "{product_name:RE450,product_ver:3.0.0,special_id:42520000}\r\n",
2380 /* We're using a dynamic kernel/rootfs split here */
2382 {"fs-uboot", 0x00000, 0x20000},
2383 {"default-mac", 0x20000, 0x00020},
2384 {"pin", 0x20020, 0x00020},
2385 {"product-info", 0x21000, 0x01000},
2386 {"partition-table", 0x22000, 0x02000},
2387 {"soft-version", 0x24000, 0x01000},
2388 {"support-list", 0x25000, 0x01000},
2389 {"profile", 0x26000, 0x08000},
2390 {"user-config", 0x2e000, 0x10000},
2391 {"default-config", 0x3e000, 0x10000},
2392 {"config-info", 0x4e000, 0x00400},
2393 {"firmware", 0x50000, 0x7a0000},
2394 {"radio", 0x7f0000, 0x10000},
2398 .first_sysupgrade_partition
= "os-image",
2399 .last_sysupgrade_partition
= "file-system"
2402 /** Firmware layout for the RE500 */
2408 "{product_name:RE500,product_ver:1.0.0,special_id:00000000}\r\n"
2409 "{product_name:RE500,product_ver:1.0.0,special_id:55530000}\r\n"
2410 "{product_name:RE500,product_ver:1.0.0,special_id:45550000}\r\n"
2411 "{product_name:RE500,product_ver:1.0.0,special_id:4A500000}\r\n"
2412 "{product_name:RE500,product_ver:1.0.0,special_id:43410000}\r\n"
2413 "{product_name:RE500,product_ver:1.0.0,special_id:41550000}\r\n"
2414 "{product_name:RE500,product_ver:1.0.0,special_id:41530000}\r\n",
2418 /* We're using a dynamic kernel/rootfs split here */
2420 {"fs-uboot", 0x00000, 0x20000},
2421 {"firmware", 0x20000, 0xde0000},
2422 {"partition-table", 0xe00000, 0x02000},
2423 {"default-mac", 0xe10000, 0x00020},
2424 {"pin", 0xe10100, 0x00020},
2425 {"product-info", 0xe11100, 0x01000},
2426 {"soft-version", 0xe20000, 0x01000},
2427 {"support-list", 0xe21000, 0x01000},
2428 {"profile", 0xe22000, 0x08000},
2429 {"user-config", 0xe30000, 0x10000},
2430 {"default-config", 0xe40000, 0x10000},
2431 {"radio", 0xff0000, 0x10000},
2435 .first_sysupgrade_partition
= "os-image",
2436 .last_sysupgrade_partition
= "file-system"
2439 /** Firmware layout for the RE650 */
2445 "{product_name:RE650,product_ver:1.0.0,special_id:00000000}\r\n"
2446 "{product_name:RE650,product_ver:1.0.0,special_id:55530000}\r\n"
2447 "{product_name:RE650,product_ver:1.0.0,special_id:45550000}\r\n"
2448 "{product_name:RE650,product_ver:1.0.0,special_id:4A500000}\r\n"
2449 "{product_name:RE650,product_ver:1.0.0,special_id:43410000}\r\n"
2450 "{product_name:RE650,product_ver:1.0.0,special_id:41550000}\r\n"
2451 "{product_name:RE650,product_ver:1.0.0,special_id:41530000}\r\n",
2455 /* We're using a dynamic kernel/rootfs split here */
2457 {"fs-uboot", 0x00000, 0x20000},
2458 {"firmware", 0x20000, 0xde0000},
2459 {"partition-table", 0xe00000, 0x02000},
2460 {"default-mac", 0xe10000, 0x00020},
2461 {"pin", 0xe10100, 0x00020},
2462 {"product-info", 0xe11100, 0x01000},
2463 {"soft-version", 0xe20000, 0x01000},
2464 {"support-list", 0xe21000, 0x01000},
2465 {"profile", 0xe22000, 0x08000},
2466 {"user-config", 0xe30000, 0x10000},
2467 {"default-config", 0xe40000, 0x10000},
2468 {"radio", 0xff0000, 0x10000},
2472 .first_sysupgrade_partition
= "os-image",
2473 .last_sysupgrade_partition
= "file-system"
2479 #define error(_ret, _errno, _str, ...) \
2481 fprintf(stderr, _str ": %s\n", ## __VA_ARGS__, \
2482 strerror(_errno)); \
2488 /** Stores a uint32 as big endian */
2489 static inline void put32(uint8_t *buf
, uint32_t val
) {
2496 static inline bool meta_partition_should_pad(enum partition_trail_value pv
)
2498 return (pv
>= 0) && (pv
<= PART_TRAIL_MAX
);
2501 /** Allocate a padded meta partition with a correctly initialised header
2502 * If the `data` pointer is NULL, then the required space is only allocated,
2503 * otherwise `data_len` bytes will be copied from `data` into the partition
2505 static struct image_partition_entry
init_meta_partition_entry(
2506 const char *name
, const void *data
, uint32_t data_len
,
2507 enum partition_trail_value pad_value
)
2509 uint32_t total_len
= sizeof(struct meta_header
) + data_len
;
2510 if (meta_partition_should_pad(pad_value
))
2513 struct image_partition_entry entry
= {
2516 .data
= malloc(total_len
)
2519 error(1, errno
, "failed to allocate meta partition entry");
2521 struct meta_header
*header
= (struct meta_header
*)entry
.data
;
2522 header
->length
= htonl(data_len
);
2526 memcpy(entry
.data
+sizeof(*header
), data
, data_len
);
2528 if (meta_partition_should_pad(pad_value
))
2529 entry
.data
[total_len
- 1] = (uint8_t) pad_value
;
2534 /** Allocates a new image partition */
2535 static struct image_partition_entry
alloc_image_partition(const char *name
, size_t len
) {
2536 struct image_partition_entry entry
= {name
, len
, malloc(len
)};
2538 error(1, errno
, "malloc");
2543 /** Frees an image partition */
2544 static void free_image_partition(struct image_partition_entry entry
) {
2548 static time_t source_date_epoch
= -1;
2549 static void set_source_date_epoch() {
2550 char *env
= getenv("SOURCE_DATE_EPOCH");
2554 source_date_epoch
= strtoull(env
, &endptr
, 10);
2555 if (errno
|| (endptr
&& *endptr
!= '\0')) {
2556 fprintf(stderr
, "Invalid SOURCE_DATE_EPOCH");
2562 /** Generates the partition-table partition */
2563 static struct image_partition_entry
make_partition_table(const struct flash_partition_entry
*p
) {
2564 struct image_partition_entry entry
= alloc_image_partition("partition-table", 0x800);
2566 char *s
= (char *)entry
.data
, *end
= (char *)(s
+entry
.size
);
2574 for (i
= 0; p
[i
].name
; i
++) {
2576 size_t w
= snprintf(s
, len
, "partition %s base 0x%05x size 0x%05x\n", p
[i
].name
, p
[i
].base
, p
[i
].size
);
2579 error(1, 0, "flash partition table overflow?");
2586 memset(s
, 0xff, end
-s
);
2592 /** Generates a binary-coded decimal representation of an integer in the range [0, 99] */
2593 static inline uint8_t bcd(uint8_t v
) {
2594 return 0x10 * (v
/10) + v
%10;
2598 /** Generates the soft-version partition */
2599 static struct image_partition_entry
make_soft_version(
2600 const struct device_info
*info
, uint32_t rev
)
2602 /** If an info string is provided, use this instead of
2603 * the structured data, and include the null-termination */
2604 if (info
->soft_ver
) {
2605 uint32_t len
= strlen(info
->soft_ver
) + 1;
2606 return init_meta_partition_entry("soft-version",
2607 info
->soft_ver
, len
, info
->part_trail
);
2612 if (source_date_epoch
!= -1)
2613 t
= source_date_epoch
;
2614 else if (time(&t
) == (time_t)(-1))
2615 error(1, errno
, "time");
2617 struct tm
*tm
= gmtime(&t
);
2619 struct soft_version s
= {
2626 .year_hi
= bcd((1900+tm
->tm_year
)/100),
2627 .year_lo
= bcd(tm
->tm_year
%100),
2628 .month
= bcd(tm
->tm_mon
+1),
2629 .day
= bcd(tm
->tm_mday
),
2631 .compat_level
= htonl(info
->soft_ver_compat_level
)
2634 if (info
->soft_ver_compat_level
== 0)
2635 return init_meta_partition_entry("soft-version", &s
,
2636 (uint8_t *)(&s
.compat_level
) - (uint8_t *)(&s
),
2639 return init_meta_partition_entry("soft-version", &s
,
2640 sizeof(s
), info
->part_trail
);
2643 /** Generates the support-list partition */
2644 static struct image_partition_entry
make_support_list(
2645 const struct device_info
*info
)
2647 uint32_t len
= strlen(info
->support_list
);
2648 return init_meta_partition_entry("support-list", info
->support_list
,
2649 len
, info
->part_trail
);
2652 /** Partition with extra-para data */
2653 static struct image_partition_entry
make_extra_para(
2654 const struct device_info
*info
, const uint8_t *extra_para
, size_t len
)
2656 return init_meta_partition_entry("extra-para", extra_para
, len
,
2660 /** Creates a new image partition with an arbitrary name from a file */
2661 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
) {
2662 struct stat statbuf
;
2664 if (stat(filename
, &statbuf
) < 0)
2665 error(1, errno
, "unable to stat file `%s'", filename
);
2667 size_t len
= statbuf
.st_size
;
2669 if (add_jffs2_eof
) {
2670 if (file_system_partition
)
2671 len
= ALIGN(len
+ file_system_partition
->base
, 0x10000) + sizeof(jffs2_eof_mark
) - file_system_partition
->base
;
2673 len
= ALIGN(len
, 0x10000) + sizeof(jffs2_eof_mark
);
2676 struct image_partition_entry entry
= alloc_image_partition(part_name
, len
);
2678 FILE *file
= fopen(filename
, "rb");
2680 error(1, errno
, "unable to open file `%s'", filename
);
2682 if (fread(entry
.data
, statbuf
.st_size
, 1, file
) != 1)
2683 error(1, errno
, "unable to read file `%s'", filename
);
2685 if (add_jffs2_eof
) {
2686 uint8_t *eof
= entry
.data
+ statbuf
.st_size
, *end
= entry
.data
+entry
.size
;
2688 memset(eof
, 0xff, end
- eof
- sizeof(jffs2_eof_mark
));
2689 memcpy(end
- sizeof(jffs2_eof_mark
), jffs2_eof_mark
, sizeof(jffs2_eof_mark
));
2698 Copies a list of image partitions into an image buffer and generates the image partition table while doing so
2700 Example image partition table:
2702 fwup-ptn partition-table base 0x00800 size 0x00800
2703 fwup-ptn os-image base 0x01000 size 0x113b45
2704 fwup-ptn file-system base 0x114b45 size 0x1d0004
2705 fwup-ptn support-list base 0x2e4b49 size 0x000d1
2707 Each line of the partition table is terminated with the bytes 09 0d 0a ("\t\r\n"),
2708 the end of the partition table is marked with a zero byte.
2710 The firmware image must contain at least the partition-table and support-list partitions
2711 to be accepted. There aren't any alignment constraints for the image partitions.
2713 The partition-table partition contains the actual flash layout; partitions
2714 from the image partition table are mapped to the corresponding flash partitions during
2715 the firmware upgrade. The support-list partition contains a list of devices supported by
2718 The base offsets in the firmware partition table are relative to the end
2719 of the vendor information block, so the partition-table partition will
2720 actually start at offset 0x1814 of the image.
2722 I think partition-table must be the first partition in the firmware image.
2724 static void put_partitions(uint8_t *buffer
, const struct flash_partition_entry
*flash_parts
, const struct image_partition_entry
*parts
) {
2726 char *image_pt
= (char *)buffer
, *end
= image_pt
+ 0x800;
2728 size_t base
= 0x800;
2729 for (i
= 0; parts
[i
].name
; i
++) {
2730 for (j
= 0; flash_parts
[j
].name
; j
++) {
2731 if (!strcmp(flash_parts
[j
].name
, parts
[i
].name
)) {
2732 if (parts
[i
].size
> flash_parts
[j
].size
)
2733 error(1, 0, "%s partition too big (more than %u bytes)", flash_parts
[j
].name
, (unsigned)flash_parts
[j
].size
);
2738 assert(flash_parts
[j
].name
);
2740 memcpy(buffer
+ base
, parts
[i
].data
, parts
[i
].size
);
2742 size_t len
= end
-image_pt
;
2743 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
);
2746 error(1, 0, "image partition table overflow?");
2750 base
+= parts
[i
].size
;
2754 /** Generates and writes the image MD5 checksum */
2755 static void put_md5(uint8_t *md5
, uint8_t *buffer
, unsigned int len
) {
2759 MD5_Update(&ctx
, md5_salt
, (unsigned int)sizeof(md5_salt
));
2760 MD5_Update(&ctx
, buffer
, len
);
2761 MD5_Final(md5
, &ctx
);
2766 Generates the firmware image in factory format
2772 0000-0003 Image size (4 bytes, big endian)
2773 0004-0013 MD5 hash (hash of a 16 byte salt and the image data starting with byte 0x14)
2774 0014-0017 Vendor information length (without padding) (4 bytes, big endian)
2775 0018-1013 Vendor information (4092 bytes, padded with 0xff; there seem to be older
2776 (VxWorks-based) TP-LINK devices which use a smaller vendor information block)
2777 1014-1813 Image partition table (2048 bytes, padded with 0xff)
2778 1814-xxxx Firmware partitions
2780 static void * generate_factory_image(struct device_info
*info
, const struct image_partition_entry
*parts
, size_t *len
) {
2784 for (i
= 0; parts
[i
].name
; i
++)
2785 *len
+= parts
[i
].size
;
2787 uint8_t *image
= malloc(*len
);
2789 error(1, errno
, "malloc");
2791 memset(image
, 0xff, *len
);
2795 size_t vendor_len
= strlen(info
->vendor
);
2796 put32(image
+0x14, vendor_len
);
2797 memcpy(image
+0x18, info
->vendor
, vendor_len
);
2800 put_partitions(image
+ 0x1014, info
->partitions
, parts
);
2801 put_md5(image
+0x04, image
+0x14, *len
-0x14);
2807 Generates the firmware image in sysupgrade format
2809 This makes some assumptions about the provided flash and image partition tables and
2810 should be generalized when TP-LINK starts building its safeloader into hardware with
2811 different flash layouts.
2813 static void * generate_sysupgrade_image(struct device_info
*info
, const struct image_partition_entry
*image_parts
, size_t *len
) {
2815 size_t flash_first_partition_index
= 0;
2816 size_t flash_last_partition_index
= 0;
2817 const struct flash_partition_entry
*flash_first_partition
= NULL
;
2818 const struct flash_partition_entry
*flash_last_partition
= NULL
;
2819 const struct image_partition_entry
*image_last_partition
= NULL
;
2821 /** Find first and last partitions */
2822 for (i
= 0; info
->partitions
[i
].name
; i
++) {
2823 if (!strcmp(info
->partitions
[i
].name
, info
->first_sysupgrade_partition
)) {
2824 flash_first_partition
= &info
->partitions
[i
];
2825 flash_first_partition_index
= i
;
2826 } else if (!strcmp(info
->partitions
[i
].name
, info
->last_sysupgrade_partition
)) {
2827 flash_last_partition
= &info
->partitions
[i
];
2828 flash_last_partition_index
= i
;
2832 assert(flash_first_partition
&& flash_last_partition
);
2833 assert(flash_first_partition_index
< flash_last_partition_index
);
2835 /** Find last partition from image to calculate needed size */
2836 for (i
= 0; image_parts
[i
].name
; i
++) {
2837 if (!strcmp(image_parts
[i
].name
, info
->last_sysupgrade_partition
)) {
2838 image_last_partition
= &image_parts
[i
];
2843 assert(image_last_partition
);
2845 *len
= flash_last_partition
->base
- flash_first_partition
->base
+ image_last_partition
->size
;
2847 uint8_t *image
= malloc(*len
);
2849 error(1, errno
, "malloc");
2851 memset(image
, 0xff, *len
);
2853 for (i
= flash_first_partition_index
; i
<= flash_last_partition_index
; i
++) {
2854 for (j
= 0; image_parts
[j
].name
; j
++) {
2855 if (!strcmp(info
->partitions
[i
].name
, image_parts
[j
].name
)) {
2856 if (image_parts
[j
].size
> info
->partitions
[i
].size
)
2857 error(1, 0, "%s partition too big (more than %u bytes)", info
->partitions
[i
].name
, (unsigned)info
->partitions
[i
].size
);
2858 memcpy(image
+ info
->partitions
[i
].base
- flash_first_partition
->base
, image_parts
[j
].data
, image_parts
[j
].size
);
2862 assert(image_parts
[j
].name
);
2869 /** Generates an image according to a given layout and writes it to a file */
2870 static void build_image(const char *output
,
2871 const char *kernel_image
,
2872 const char *rootfs_image
,
2876 struct device_info
*info
) {
2880 struct image_partition_entry parts
[7] = {};
2882 struct flash_partition_entry
*firmware_partition
= NULL
;
2883 struct flash_partition_entry
*os_image_partition
= NULL
;
2884 struct flash_partition_entry
*file_system_partition
= NULL
;
2885 size_t firmware_partition_index
= 0;
2887 for (i
= 0; info
->partitions
[i
].name
; i
++) {
2888 if (!strcmp(info
->partitions
[i
].name
, "firmware"))
2890 firmware_partition
= &info
->partitions
[i
];
2891 firmware_partition_index
= i
;
2895 if (firmware_partition
)
2897 os_image_partition
= &info
->partitions
[firmware_partition_index
];
2898 file_system_partition
= &info
->partitions
[firmware_partition_index
+ 1];
2901 if (stat(kernel_image
, &kernel
) < 0)
2902 error(1, errno
, "unable to stat file `%s'", kernel_image
);
2904 if (kernel
.st_size
> firmware_partition
->size
)
2905 error(1, 0, "kernel overflowed firmware partition\n");
2907 for (i
= MAX_PARTITIONS
-1; i
>= firmware_partition_index
+ 1; i
--)
2908 info
->partitions
[i
+1] = info
->partitions
[i
];
2910 file_system_partition
->name
= "file-system";
2911 file_system_partition
->base
= firmware_partition
->base
+ kernel
.st_size
;
2913 /* Align partition start to erase blocks for factory images only */
2915 file_system_partition
->base
= ALIGN(firmware_partition
->base
+ kernel
.st_size
, 0x10000);
2917 file_system_partition
->size
= firmware_partition
->size
- file_system_partition
->base
;
2919 os_image_partition
->name
= "os-image";
2920 os_image_partition
->size
= kernel
.st_size
;
2923 parts
[0] = make_partition_table(info
->partitions
);
2924 parts
[1] = make_soft_version(info
, rev
);
2925 parts
[2] = make_support_list(info
);
2926 parts
[3] = read_file("os-image", kernel_image
, false, NULL
);
2927 parts
[4] = read_file("file-system", rootfs_image
, add_jffs2_eof
, file_system_partition
);
2929 /* Some devices need the extra-para partition to accept the firmware */
2930 if (strcasecmp(info
->id
, "ARCHER-A6-V3") == 0 ||
2931 strcasecmp(info
->id
, "ARCHER-A7-V5") == 0 ||
2932 strcasecmp(info
->id
, "ARCHER-C2-V3") == 0 ||
2933 strcasecmp(info
->id
, "ARCHER-C7-V4") == 0 ||
2934 strcasecmp(info
->id
, "ARCHER-C7-V5") == 0 ||
2935 strcasecmp(info
->id
, "ARCHER-C25-V1") == 0 ||
2936 strcasecmp(info
->id
, "ARCHER-C59-V2") == 0 ||
2937 strcasecmp(info
->id
, "ARCHER-C60-V2") == 0 ||
2938 strcasecmp(info
->id
, "ARCHER-C60-V3") == 0 ||
2939 strcasecmp(info
->id
, "ARCHER-C6U-V1") == 0 ||
2940 strcasecmp(info
->id
, "ARCHER-C6-V3") == 0 ||
2941 strcasecmp(info
->id
, "TLWR1043NV5") == 0) {
2942 const uint8_t extra_para
[2] = {0x01, 0x00};
2943 parts
[5] = make_extra_para(info
, extra_para
,
2944 sizeof(extra_para
));
2945 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2") == 0) {
2946 const uint8_t extra_para
[2] = {0x00, 0x01};
2947 parts
[5] = make_extra_para(info
, extra_para
,
2948 sizeof(extra_para
));
2949 } else if (strcasecmp(info
->id
, "ARCHER-C6-V2-US") == 0 ||
2950 strcasecmp(info
->id
, "EAP245-V3") == 0) {
2951 const uint8_t extra_para
[2] = {0x01, 0x01};
2952 parts
[5] = make_extra_para(info
, extra_para
,
2953 sizeof(extra_para
));
2959 image
= generate_sysupgrade_image(info
, parts
, &len
);
2961 image
= generate_factory_image(info
, parts
, &len
);
2963 FILE *file
= fopen(output
, "wb");
2965 error(1, errno
, "unable to open output file");
2967 if (fwrite(image
, len
, 1, file
) != 1)
2968 error(1, 0, "unable to write output file");
2974 for (i
= 0; parts
[i
].name
; i
++)
2975 free_image_partition(parts
[i
]);
2979 static void usage(const char *argv0
) {
2981 "Usage: %s [OPTIONS...]\n"
2984 " -h show this help\n"
2986 "Info about an image:\n"
2987 " -i <file> input file to read from\n"
2988 "Create a new image:\n"
2989 " -B <board> create image for the board specified with <board>\n"
2990 " -k <file> read kernel image from the file <file>\n"
2991 " -r <file> read rootfs image from the file <file>\n"
2992 " -o <file> write output to the file <file>\n"
2993 " -V <rev> sets the revision number to <rev>\n"
2994 " -j add jffs2 end-of-filesystem markers\n"
2995 " -S create sysupgrade instead of factory image\n"
2996 "Extract an old image:\n"
2997 " -x <file> extract all oem firmware partition\n"
2998 " -d <dir> destination to extract the firmware partition\n"
2999 " -z <file> convert an oem firmware into a sysupgade file. Use -o for output file\n",
3005 static struct device_info
*find_board(const char *id
)
3007 struct device_info
*board
= NULL
;
3009 for (board
= boards
; board
->id
!= NULL
; board
++)
3010 if (strcasecmp(id
, board
->id
) == 0)
3016 static int add_flash_partition(
3017 struct flash_partition_entry
*part_list
,
3024 /* check if the list has a free entry */
3025 for (ptr
= 0; ptr
< max_entries
; ptr
++, part_list
++) {
3026 if (part_list
->name
== NULL
&&
3027 part_list
->base
== 0 &&
3028 part_list
->size
== 0)
3032 if (ptr
== max_entries
) {
3033 error(1, 0, "No free flash part entry available.");
3036 part_list
->name
= calloc(1, strlen(name
) + 1);
3037 if (!part_list
->name
) {
3038 error(1, 0, "Unable to allocate memory");
3041 memcpy((char *)part_list
->name
, name
, strlen(name
));
3042 part_list
->base
= base
;
3043 part_list
->size
= size
;
3048 /** read the partition table into struct flash_partition_entry */
3049 static int read_partition_table(
3050 FILE *file
, long offset
,
3051 struct flash_partition_entry
*entries
, size_t max_entries
,
3056 const char *parthdr
= NULL
;
3057 const char *fwuphdr
= "fwup-ptn";
3058 const char *flashhdr
= "partition";
3060 /* TODO: search for the partition table */
3070 error(1, 0, "Invalid partition table");
3073 if (fseek(file
, offset
, SEEK_SET
) < 0)
3074 error(1, errno
, "Can not seek in the firmware");
3076 if (fread(buf
, 2048, 1, file
) != 1)
3077 error(1, errno
, "Can not read fwup-ptn from the firmware");
3081 /* look for the partition header */
3082 if (memcmp(buf
, parthdr
, strlen(parthdr
)) != 0) {
3083 fprintf(stderr
, "DEBUG: can not find fwuphdr\n");
3088 end
= buf
+ sizeof(buf
);
3089 while ((ptr
+ strlen(parthdr
)) < end
&&
3090 memcmp(ptr
, parthdr
, strlen(parthdr
)) == 0) {
3094 char name
[32] = { 0 };
3096 unsigned long base
= 0;
3097 unsigned long size
= 0;
3099 end_part
= memchr(ptr
, '\n', (end
- ptr
));
3100 if (end_part
== NULL
) {
3101 /* in theory this should never happen, because a partition always ends with 0x09, 0x0D, 0x0A */
3105 for (int i
= 0; i
<= 4; i
++) {
3106 if (end_part
<= ptr
)
3109 end_element
= memchr(ptr
, 0x20, (end_part
- ptr
));
3110 if (end_element
== NULL
) {
3111 error(1, errno
, "Ignoring the rest of the partition entries.");
3116 /* partition header */
3118 ptr
= end_element
+ 1;
3122 name_len
= (end_element
- ptr
) > 31 ? 31 : (end_element
- ptr
);
3123 strncpy(name
, ptr
, name_len
);
3124 name
[name_len
] = '\0';
3125 ptr
= end_element
+ 1;
3130 ptr
= end_element
+ 1;
3135 base
= strtoul(ptr
, NULL
, 16);
3136 ptr
= end_element
+ 1;
3141 ptr
= end_element
+ 1;
3142 /* actual size. The last element doesn't have a sepeartor */
3143 size
= strtoul(ptr
, NULL
, 16);
3144 /* the part ends with 0x09, 0x0d, 0x0a */
3146 add_flash_partition(entries
, max_entries
, name
, base
, size
);
3155 static void write_partition(
3157 size_t firmware_offset
,
3158 struct flash_partition_entry
*entry
,
3164 fseek(input_file
, entry
->base
+ firmware_offset
, SEEK_SET
);
3166 for (offset
= 0; sizeof(buf
) + offset
<= entry
->size
; offset
+= sizeof(buf
)) {
3167 if (fread(buf
, sizeof(buf
), 1, input_file
) != 1)
3168 error(1, errno
, "Can not read partition from input_file");
3170 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3171 error(1, errno
, "Can not write partition to output_file");
3173 /* write last chunk smaller than buffer */
3174 if (offset
< entry
->size
) {
3175 offset
= entry
->size
- offset
;
3176 if (fread(buf
, offset
, 1, input_file
) != 1)
3177 error(1, errno
, "Can not read partition from input_file");
3178 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3179 error(1, errno
, "Can not write partition to output_file");
3183 static int extract_firmware_partition(FILE *input_file
, size_t firmware_offset
, struct flash_partition_entry
*entry
, const char *output_directory
)
3186 char output
[PATH_MAX
];
3188 snprintf(output
, PATH_MAX
, "%s/%s", output_directory
, entry
->name
);
3189 output_file
= fopen(output
, "wb+");
3190 if (output_file
== NULL
) {
3191 error(1, errno
, "Can not open output file %s", output
);
3194 write_partition(input_file
, firmware_offset
, entry
, output_file
);
3196 fclose(output_file
);
3201 /** extract all partitions from the firmware file */
3202 static int extract_firmware(const char *input
, const char *output_directory
)
3204 struct flash_partition_entry entries
[16] = { 0 };
3205 size_t max_entries
= 16;
3206 size_t firmware_offset
= 0x1014;
3209 struct stat statbuf
;
3211 /* check input file */
3212 if (stat(input
, &statbuf
)) {
3213 error(1, errno
, "Can not read input firmware %s", input
);
3216 /* check if output directory exists */
3217 if (stat(output_directory
, &statbuf
)) {
3218 error(1, errno
, "Failed to stat output directory %s", output_directory
);
3221 if ((statbuf
.st_mode
& S_IFMT
) != S_IFDIR
) {
3222 error(1, errno
, "Given output directory is not a directory %s", output_directory
);
3225 input_file
= fopen(input
, "rb");
3227 if (read_partition_table(input_file
, firmware_offset
, entries
, 16, 0) != 0) {
3228 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3231 for (size_t i
= 0; i
< max_entries
; i
++) {
3232 if (entries
[i
].name
== NULL
&&
3233 entries
[i
].base
== 0 &&
3234 entries
[i
].size
== 0)
3237 extract_firmware_partition(input_file
, firmware_offset
, &entries
[i
], output_directory
);
3243 static struct flash_partition_entry
*find_partition(
3244 struct flash_partition_entry
*entries
, size_t max_entries
,
3245 const char *name
, const char *error_msg
)
3247 for (size_t i
= 0; i
< max_entries
; i
++, entries
++) {
3248 if (strcmp(entries
->name
, name
) == 0)
3253 error(1, 0, "%s", error_msg
);
3259 static int firmware_info(const char *input
)
3261 struct flash_partition_entry pointers
[MAX_PARTITIONS
] = { };
3262 struct flash_partition_entry
*e
;
3266 fp
= fopen(input
, "r");
3268 if (read_partition_table(fp
, 0x1014, pointers
, MAX_PARTITIONS
, 0)) {
3269 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3272 printf("Firmware image partitions:\n");
3273 printf("%-8s %-8s %s\n", "base", "size", "name");
3274 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3277 if (!e
->name
&& !e
->base
&& !e
->size
)
3280 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3283 e
= find_partition(pointers
, MAX_PARTITIONS
, "soft-version", NULL
);
3285 size_t data_len
= e
->size
- sizeof(struct meta_header
);
3286 char *buf
= malloc(data_len
);
3287 struct soft_version
*s
;
3292 error(1, errno
, "Failed to alloc buffer");
3294 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3295 error(1, errno
, "Can not seek in the firmware");
3297 if (fread(buf
, data_len
, 1, fp
) != 1)
3298 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3300 /* Check for string ignoring padding character */
3302 for (i
= 0; i
< data_len
- 1; i
++) {
3303 if (!isascii(buf
[i
])) {
3309 printf("\n[Software version]\n");
3311 fwrite(buf
, data_len
, 1, stdout
);
3313 } else if (data_len
>= offsetof(struct soft_version
, rev
)) {
3314 s
= (struct soft_version
*)buf
;
3316 printf("Version: %d.%d.%d\n", s
->version_major
, s
->version_minor
, s
->version_patch
);
3317 printf("Date: %02x%02x-%02x-%02x\n", s
->year_hi
, s
->year_lo
, s
->month
, s
->day
);
3319 printf("Failed to parse data\n");
3325 e
= find_partition(pointers
, MAX_PARTITIONS
, "support-list", NULL
);
3331 if (fseek(fp
, 0x1014 + e
->base
+ sizeof(struct meta_header
), SEEK_SET
))
3332 error(1, errno
, "Can not seek in the firmware");
3334 printf("\n[Support list]\n");
3335 for (length
= e
->size
- sizeof(struct meta_header
); length
; length
-= bytes
) {
3336 bytes
= fread(buf
, 1, length
> sizeof(buf
) ? sizeof(buf
) : length
, fp
);
3338 error(1, errno
, "Can not read fwup-ptn data from the firmware");
3344 e
= find_partition(pointers
, MAX_PARTITIONS
, "partition-table", NULL
);
3346 struct flash_partition_entry parts
[MAX_PARTITIONS
] = { };
3348 if (read_partition_table(fp
, 0x1014 + e
->base
+ 4, parts
, MAX_PARTITIONS
, 1)) {
3349 error(1, 0, "Error can not read the partition table (partition)");
3352 printf("\n[Partition table]\n");
3353 printf("%-8s %-8s %s\n", "base", "size", "name");
3354 for (i
= 0; i
< MAX_PARTITIONS
; i
++) {
3357 if (!e
->name
&& !e
->base
&& !e
->size
)
3360 printf("%08x %08x %s\n", e
->base
, e
->size
, e
->name
? e
->name
: "");
3369 static void write_ff(FILE *output_file
, size_t size
)
3374 memset(buf
, 0xff, sizeof(buf
));
3376 for (offset
= 0; offset
+ sizeof(buf
) < size
; offset
+= sizeof(buf
)) {
3377 if (fwrite(buf
, sizeof(buf
), 1, output_file
) != 1)
3378 error(1, errno
, "Can not write 0xff to output_file");
3381 /* write last chunk smaller than buffer */
3382 if (offset
< size
) {
3383 offset
= size
- offset
;
3384 if (fwrite(buf
, offset
, 1, output_file
) != 1)
3385 error(1, errno
, "Can not write partition to output_file");
3389 static void convert_firmware(const char *input
, const char *output
)
3391 struct flash_partition_entry fwup
[MAX_PARTITIONS
] = { 0 };
3392 struct flash_partition_entry flash
[MAX_PARTITIONS
] = { 0 };
3393 struct flash_partition_entry
*fwup_os_image
= NULL
, *fwup_file_system
= NULL
;
3394 struct flash_partition_entry
*flash_os_image
= NULL
, *flash_file_system
= NULL
;
3395 struct flash_partition_entry
*fwup_partition_table
= NULL
;
3396 size_t firmware_offset
= 0x1014;
3397 FILE *input_file
, *output_file
;
3399 struct stat statbuf
;
3401 /* check input file */
3402 if (stat(input
, &statbuf
)) {
3403 error(1, errno
, "Can not read input firmware %s", input
);
3406 input_file
= fopen(input
, "rb");
3408 error(1, 0, "Can not open input firmware %s", input
);
3410 output_file
= fopen(output
, "wb");
3412 error(1, 0, "Can not open output firmware %s", output
);
3414 if (read_partition_table(input_file
, firmware_offset
, fwup
, MAX_PARTITIONS
, 0) != 0) {
3415 error(1, 0, "Error can not read the partition table (fwup-ptn)");
3418 fwup_os_image
= find_partition(fwup
, MAX_PARTITIONS
,
3419 "os-image", "Error can not find os-image partition (fwup)");
3420 fwup_file_system
= find_partition(fwup
, MAX_PARTITIONS
,
3421 "file-system", "Error can not find file-system partition (fwup)");
3422 fwup_partition_table
= find_partition(fwup
, MAX_PARTITIONS
,
3423 "partition-table", "Error can not find partition-table partition");
3425 /* the flash partition table has a 0x00000004 magic haeder */
3426 if (read_partition_table(input_file
, firmware_offset
+ fwup_partition_table
->base
+ 4, flash
, MAX_PARTITIONS
, 1) != 0)
3427 error(1, 0, "Error can not read the partition table (flash)");
3429 flash_os_image
= find_partition(flash
, MAX_PARTITIONS
,
3430 "os-image", "Error can not find os-image partition (flash)");
3431 flash_file_system
= find_partition(flash
, MAX_PARTITIONS
,
3432 "file-system", "Error can not find file-system partition (flash)");
3434 /* write os_image to 0x0 */
3435 write_partition(input_file
, firmware_offset
, fwup_os_image
, output_file
);
3436 write_ff(output_file
, flash_os_image
->size
- fwup_os_image
->size
);
3438 /* write file-system behind os_image */
3439 fseek(output_file
, flash_file_system
->base
- flash_os_image
->base
, SEEK_SET
);
3440 write_partition(input_file
, firmware_offset
, fwup_file_system
, output_file
);
3441 write_ff(output_file
, flash_file_system
->size
- fwup_file_system
->size
);
3443 fclose(output_file
);
3447 int main(int argc
, char *argv
[]) {
3448 const char *info_image
= NULL
, *board
= NULL
, *kernel_image
= NULL
, *rootfs_image
= NULL
, *output
= NULL
;
3449 const char *extract_image
= NULL
, *output_directory
= NULL
, *convert_image
= NULL
;
3450 bool add_jffs2_eof
= false, sysupgrade
= false;
3452 struct device_info
*info
;
3453 set_source_date_epoch();
3458 c
= getopt(argc
, argv
, "i:B:k:r:o:V:jSh:x:d:z:");
3464 info_image
= optarg
;
3472 kernel_image
= optarg
;
3476 rootfs_image
= optarg
;
3484 sscanf(optarg
, "r%u", &rev
);
3488 add_jffs2_eof
= true;
3500 output_directory
= optarg
;
3504 extract_image
= optarg
;
3508 convert_image
= optarg
;
3518 firmware_info(info_image
);
3519 } else if (extract_image
|| output_directory
) {
3521 error(1, 0, "No factory/oem image given via -x <file>. Output directory is only valid with -x");
3522 if (!output_directory
)
3523 error(1, 0, "Can not extract an image without output directory. Use -d <dir>");
3524 extract_firmware(extract_image
, output_directory
);
3525 } else if (convert_image
) {
3527 error(1, 0, "Can not convert a factory/oem image into sysupgrade image without output file. Use -o <file>");
3528 convert_firmware(convert_image
, output
);
3531 error(1, 0, "no board has been specified");
3533 error(1, 0, "no kernel image has been specified");
3535 error(1, 0, "no rootfs image has been specified");
3537 error(1, 0, "no output filename has been specified");
3539 info
= find_board(board
);
3542 error(1, 0, "unsupported board %s", board
);
3544 build_image(output
, kernel_image
, rootfs_image
, rev
, add_jffs2_eof
, sysupgrade
, info
);