tools/mkrasimage: Add support for 128k header size

128k header size support is needed for ZyXEL NBG6716.

Signed-off-by: André Valentin <avalentin@marcant.net>
master
André Valentin 2019-10-23 11:30:28 +02:00 committed by John Crispin
parent 522d5ff428
commit 6ae7ee7724
1 changed files with 8 additions and 3 deletions

View File

@ -70,6 +70,7 @@ static char *progname;
static char *board_name = 0; static char *board_name = 0;
static char *version_name = 0; static char *version_name = 0;
static unsigned int rootfs_size = 0; static unsigned int rootfs_size = 0;
static unsigned int header_length = HEADER_PARTITION_LENGTH;
static struct file_info kernel = { NULL, NULL, 0 }; static struct file_info kernel = { NULL, NULL, 0 };
static struct file_info rootfs = { NULL, NULL, 0 }; static struct file_info rootfs = { NULL, NULL, 0 };
@ -144,6 +145,7 @@ void usage(int status)
" -v <version> version string\n" " -v <version> version string\n"
" -b <boardname> name of board to generate image for\n" " -b <boardname> name of board to generate image for\n"
" -o <out_name> name of output image\n" " -o <out_name> name of output image\n"
" -l <hdr_length> length of header, default 65536\n"
" -h show this screen\n" " -h show this screen\n"
); );
@ -334,7 +336,7 @@ int build_image()
board_header = generate_board_header(kernel_header, rootfs_header, board_name); board_header = generate_board_header(kernel_header, rootfs_header, board_name);
/* Prepare output file */ /* Prepare output file */
out.size = HEADER_PARTITION_LENGTH + rootfs_out.size; out.size = header_length + rootfs_out.size;
if (kernel.name) if (kernel.name)
out.size += kernel.size; out.size += kernel.size;
out.data = malloc(out.size); out.data = malloc(out.size);
@ -345,7 +347,7 @@ int build_image()
memcpy(out.data + ROOTFS_HEADER_LEN, board_header, BOARD_HEADER_LEN); memcpy(out.data + ROOTFS_HEADER_LEN, board_header, BOARD_HEADER_LEN);
if (kernel.name) if (kernel.name)
memcpy(out.data + ROOTFS_HEADER_LEN + BOARD_HEADER_LEN, kernel_header, KERNEL_HEADER_LEN); memcpy(out.data + ROOTFS_HEADER_LEN + BOARD_HEADER_LEN, kernel_header, KERNEL_HEADER_LEN);
ptr = HEADER_PARTITION_LENGTH; ptr = header_length;
memcpy(out.data + ptr, rootfs_out.data, rootfs_out.size); memcpy(out.data + ptr, rootfs_out.data, rootfs_out.size);
ptr += rootfs_out.size; ptr += rootfs_out.size;
if (kernel.name) if (kernel.name)
@ -410,7 +412,7 @@ int main(int argc, char *argv[])
while (1) { while (1) {
int c; int c;
c = getopt(argc, argv, "b:k:o:r:s:v:h"); c = getopt(argc, argv, "b:k:o:r:s:v:l:h");
if (c == -1) if (c == -1)
break; break;
@ -436,6 +438,9 @@ int main(int argc, char *argv[])
case 'v': case 'v':
version_name = optarg; version_name = optarg;
break; break;
case 'l':
sscanf(optarg, "%u", &header_length);
break;
default: default:
usage(EXIT_FAILURE); usage(EXIT_FAILURE);
break; break;