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