firmware-utils/mktplinkfw: add option for combined images
SVN-Revision: 16742
This commit is contained in:
parent
6030323bea
commit
db71f38ed6
1 changed files with 40 additions and 22 deletions
|
@ -90,6 +90,7 @@ static struct board_info *board;
|
||||||
static struct file_info kernel_info;
|
static struct file_info kernel_info;
|
||||||
static struct file_info rootfs_info;
|
static struct file_info rootfs_info;
|
||||||
static struct file_info boot_info;
|
static struct file_info boot_info;
|
||||||
|
static int combined;
|
||||||
|
|
||||||
char md5salt_normal[MD5SUM_LEN] = {
|
char md5salt_normal[MD5SUM_LEN] = {
|
||||||
0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
|
0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
|
||||||
|
@ -177,6 +178,7 @@ static void usage(int status)
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -B <board> create image for the board specified with <board>\n"
|
" -B <board> create image for the board specified with <board>\n"
|
||||||
|
" -c use combined kernel image\n"
|
||||||
" -k <file> read kernel image from the file <file>\n"
|
" -k <file> read kernel image from the file <file>\n"
|
||||||
" -r <file> read rootfs image from the file <file>\n"
|
" -r <file> read rootfs image from the file <file>\n"
|
||||||
" -o <file> write output to the file <file>\n"
|
" -o <file> write output to the file <file>\n"
|
||||||
|
@ -264,11 +266,18 @@ static int check_options(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (kernel_info.file_size > board->rootfs_ofs - sizeof(struct fw_header)) {
|
if (combined) {
|
||||||
|
if (kernel_info.file_size >
|
||||||
|
board->fw_max_len - sizeof(struct fw_header)) {
|
||||||
|
ERR("kernel image is too big");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (kernel_info.file_size >
|
||||||
|
board->rootfs_ofs - sizeof(struct fw_header)) {
|
||||||
ERR("kernel image is too big");
|
ERR("kernel image is too big");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootfs_info.file_name == NULL) {
|
if (rootfs_info.file_name == NULL) {
|
||||||
ERR("no rootfs image specified");
|
ERR("no rootfs image specified");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -278,10 +287,12 @@ static int check_options(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (rootfs_info.file_size > (board->fw_max_len - board->rootfs_ofs)) {
|
if (rootfs_info.file_size >
|
||||||
|
(board->fw_max_len - board->rootfs_ofs)) {
|
||||||
ERR("rootfs image is too big");
|
ERR("rootfs image is too big");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ofname == NULL) {
|
if (ofname == NULL) {
|
||||||
ERR("no output file specified");
|
ERR("no output file specified");
|
||||||
|
@ -313,8 +324,10 @@ static void fill_header(char *buf, int len)
|
||||||
hdr->fw_length = HOST_TO_BE32(board->fw_max_len);
|
hdr->fw_length = HOST_TO_BE32(board->fw_max_len);
|
||||||
hdr->kernel_ofs = HOST_TO_BE32(sizeof(struct fw_header));
|
hdr->kernel_ofs = HOST_TO_BE32(sizeof(struct fw_header));
|
||||||
hdr->kernel_len = HOST_TO_BE32(kernel_info.file_size);
|
hdr->kernel_len = HOST_TO_BE32(kernel_info.file_size);
|
||||||
|
if (!combined) {
|
||||||
hdr->rootfs_ofs = HOST_TO_BE32(board->rootfs_ofs);
|
hdr->rootfs_ofs = HOST_TO_BE32(board->rootfs_ofs);
|
||||||
hdr->rootfs_len = HOST_TO_BE32(rootfs_info.file_size);
|
hdr->rootfs_len = HOST_TO_BE32(rootfs_info.file_size);
|
||||||
|
}
|
||||||
|
|
||||||
get_md5(buf, len, hdr->md5sum1);
|
get_md5(buf, len, hdr->md5sum1);
|
||||||
}
|
}
|
||||||
|
@ -372,10 +385,12 @@ static int build_fw(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free_buf;
|
goto out_free_buf;
|
||||||
|
|
||||||
|
if (!combined) {
|
||||||
p = buf + board->rootfs_ofs;
|
p = buf + board->rootfs_ofs;
|
||||||
ret = read_to_buf(&rootfs_info, p);
|
ret = read_to_buf(&rootfs_info, p);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free_buf;
|
goto out_free_buf;
|
||||||
|
}
|
||||||
|
|
||||||
fill_header(buf, buflen);
|
fill_header(buf, buflen);
|
||||||
|
|
||||||
|
@ -403,7 +418,7 @@ int main(int argc, char *argv[])
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = getopt(argc, argv, "B:V:N:k:r:o:v:h:");
|
c = getopt(argc, argv, "B:V:N:ck:r:o:v:h:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -417,6 +432,9 @@ int main(int argc, char *argv[])
|
||||||
case 'N':
|
case 'N':
|
||||||
vendor = optarg;
|
vendor = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
combined++;
|
||||||
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
kernel_info.file_name = optarg;
|
kernel_info.file_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue