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