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