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