|
version 1.1.2.1, 2014/01/14 22:25:57
|
version 1.1.2.2, 2014/06/15 15:07:23
|
|
Line 43
|
Line 43
|
| #endif |
#endif |
| |
|
| #define HEADER_VERSION_V1 0x01000000 |
#define HEADER_VERSION_V1 0x01000000 |
| |
#define HWID_TL_MR3020_V1 0x30200001 |
| #define HWID_TL_MR3220_V1 0x32200001 |
#define HWID_TL_MR3220_V1 0x32200001 |
| #define HWID_TL_MR3420_V1 0x34200001 |
#define HWID_TL_MR3420_V1 0x34200001 |
| #define HWID_TL_WA901ND_V1 0x09010001 |
#define HWID_TL_WA901ND_V1 0x09010001 |
|
Line 134 char md5salt_boot[MD5SUM_LEN] = {
|
Line 135 char md5salt_boot[MD5SUM_LEN] = {
|
| |
|
| static struct board_info boards[] = { |
static struct board_info boards[] = { |
| { |
{ |
| |
.id = "TL-MR3020v1", |
| |
.hw_id = HWID_TL_MR3020_V1, |
| |
.hw_rev = 1, |
| |
/* |
| |
* Actual size of firmware is 3.8MB but for now, allow larger |
| |
* sizes until we work out a plan for this unit |
| |
* .fw_max_len = 0x3c0000, |
| |
*/ |
| |
.fw_max_len = 0x640000, |
| |
.kernel_la = 0x80060000, |
| |
.kernel_ep = 0x80060000, |
| |
.rootfs_ofs = 0x100000, |
| |
}, { |
| .id = "TL-MR3220v1", |
.id = "TL-MR3220v1", |
| .hw_id = HWID_TL_MR3220_V1, |
.hw_id = HWID_TL_MR3220_V1, |
| .hw_rev = 1, |
.hw_rev = 1, |
|
Line 278 static struct board_info boards[] = {
|
Line 292 static struct board_info boards[] = {
|
| #define ERRS(fmt, ...) do { \ |
#define ERRS(fmt, ...) do { \ |
| int save = errno; \ |
int save = errno; \ |
| fflush(0); \ |
fflush(0); \ |
| fprintf(stderr, "[%s] *** error: " fmt " %s\n", \ | fprintf(stderr, "[%s] *** error: " fmt " error:%s\n", \ |
| progname, ## __VA_ARGS__, strerror(save)); \ |
progname, ## __VA_ARGS__, strerror(save)); \ |
| } while (0) |
} while (0) |
| |
|
|
Line 343 static void usage(int status)
|
Line 357 static void usage(int status)
|
| exit(status); |
exit(status); |
| } |
} |
| |
|
| static int get_md5(char *data, int size, char *md5) | static void get_md5(char *data, int size, uint8_t *md5) |
| { |
{ |
| MD5_CTX ctx; |
MD5_CTX ctx; |
| |
|
| MD5_Init(&ctx); |
MD5_Init(&ctx); |
| MD5_Update(&ctx, data, size); |
MD5_Update(&ctx, data, size); |
| MD5_Final((u_char*) md5, &ctx); | MD5_Final(md5, &ctx); |
| |
| return 0; | |
| } |
} |
| |
|
| static int get_file_stat(struct file_info *fdata) |
static int get_file_stat(struct file_info *fdata) |
|
Line 442 static int check_options(void)
|
Line 454 static int check_options(void)
|
| if (combined) { |
if (combined) { |
| if (kernel_info.file_size > |
if (kernel_info.file_size > |
| board->fw_max_len - sizeof(struct fw_header)) { |
board->fw_max_len - sizeof(struct fw_header)) { |
| ERR("kernel image is too big"); | ERR("Combined kernel image is too big. Max[%lu] kernel img [%d]", |
| | board->fw_max_len - sizeof(struct fw_header), kernel_info.file_size); |
| return -1; |
return -1; |
| } |
} |
| } else { |
} else { |
| if (kernel_info.file_size > |
if (kernel_info.file_size > |
| rootfs_ofs - sizeof(struct fw_header)) { | (rootfs_ofs - sizeof(struct fw_header))) { |
| ERR("kernel image is too big"); | ERR("kernel image is too big. Max[%lu] kernel img [%d]", |
| | rootfs_ofs - sizeof(struct fw_header), kernel_info.file_size); |
| return -1; |
return -1; |
| } |
} |
| if (rootfs_info.file_name == NULL) { |
if (rootfs_info.file_name == NULL) { |
|
Line 462 static int check_options(void)
|
Line 476 static int check_options(void)
|
| |
|
| if (rootfs_info.file_size > |
if (rootfs_info.file_size > |
| (board->fw_max_len - rootfs_ofs)) { |
(board->fw_max_len - rootfs_ofs)) { |
| ERR("rootfs image is too big"); | ERR("rootfs image is too big. Max[%d] fs img [%d]", |
| | board->fw_max_len - rootfs_ofs, rootfs_info.file_size); |
| return -1; |
return -1; |
| } |
} |
| } |
} |
|
Line 502 static void fill_header(char *buf, int len)
|
Line 517 static void fill_header(char *buf, int len)
|
| hdr->rootfs_len = HOST_TO_BE32(rootfs_info.file_size); |
hdr->rootfs_len = HOST_TO_BE32(rootfs_info.file_size); |
| } |
} |
| |
|
| get_md5(buf, len, (char*) hdr->md5sum1); | get_md5(buf, len, hdr->md5sum1); |
| } |
} |
| |
|
| static int write_fw(char *data, int len) |
static int write_fw(char *data, int len) |
|
Line 519 static int write_fw(char *data, int len)
|
Line 534 static int write_fw(char *data, int len)
|
| errno = 0; |
errno = 0; |
| fwrite(data, len, 1, f); |
fwrite(data, len, 1, f); |
| if (errno) { |
if (errno) { |
| ERRS("unable to write output file"); | ERRS("unable to write output file \"%s\"", ofname); |
| goto out_flush; |
goto out_flush; |
| } |
} |
| |
|
|
Line 688 static int inspect_fw(void)
|
Line 703 static int inspect_fw(void)
|
| memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum)); |
memcpy(hdr->md5sum1, md5salt_normal, sizeof(md5sum)); |
| else |
else |
| memcpy(hdr->md5sum1, md5salt_boot, sizeof(md5sum)); |
memcpy(hdr->md5sum1, md5salt_boot, sizeof(md5sum)); |
| get_md5(buf, inspect_info.file_size, (char*) hdr->md5sum1); | get_md5(buf, inspect_info.file_size, hdr->md5sum1); |
| |
|
| if (memcmp(md5sum, hdr->md5sum1, sizeof(md5sum))) { |
if (memcmp(md5sum, hdr->md5sum1, sizeof(md5sum))) { |
| inspect_fw_pmd5sum("Header MD5Sum1", md5sum, "(*ERROR*)"); |
inspect_fw_pmd5sum("Header MD5Sum1", md5sum, "(*ERROR*)"); |