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