[OpenWrt-Devel,1/5] tools/mkrasimage: Add support for 128k header size
diff mbox series

Message ID 20191021123214.2252-2-avalentin@marcant.net
State Changes Requested
Headers show
Series
  • ZyXEL NBG6716 update ar71xx, add ath79, add mtd mac parser
Related show

Commit Message

André Valentin Oct. 21, 2019, 12:32 p.m. UTC
128k header size support is needed for ZyXEL NBG6716.

Signed-off-by: André Valentin <avalentin@marcant.net>
---
 tools/firmware-utils/src/mkrasimage.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Petr Štetiar Oct. 21, 2019, 1:05 p.m. UTC | #1
André Valentin <avalentin@marcant.net> [2019-10-21 14:32:10]:

Hi,

>  #define HEADER_PARTITION_CALC_LENGTH 2048
> -#define HEADER_PARTITION_LENGTH 0x10000
>  
>  struct file_info {
>      char *name;    /* name of the file */
> @@ -70,6 +69,7 @@ static char *progname;
>  static char *board_name = 0;
>  static char *version_name = 0;
>  static unsigned int rootfs_size = 0;
> +static unsigned int header_length = 0x10000;

you've perhaps forget to use that define HEADER_PARTITION_LENGTH above ?

-- ynezz
André Valentin Oct. 21, 2019, 1:15 p.m. UTC | #2
Hi Petr,

thanks, I will remove the constant. It is not needed anymore.


Am 21.10.19 um 15:05 schrieb Petr Štetiar:
> André Valentin <avalentin@marcant.net> [2019-10-21 14:32:10]:
> 
> Hi,
> 
>>  #define HEADER_PARTITION_CALC_LENGTH 2048
>> -#define HEADER_PARTITION_LENGTH 0x10000
>>  
>>  struct file_info {
>>      char *name;    /* name of the file */
>> @@ -70,6 +69,7 @@ static char *progname;
>>  static char *board_name = 0;
>>  static char *version_name = 0;
>>  static unsigned int rootfs_size = 0;
>> +static unsigned int header_length = 0x10000;
> 
> you've perhaps forget to use that define HEADER_PARTITION_LENGTH above ?
> 
> -- ynezz
> 
André

Patch
diff mbox series

diff --git a/tools/firmware-utils/src/mkrasimage.c b/tools/firmware-utils/src/mkrasimage.c
index 8eee29cc08..526a1f3a43 100644
--- a/tools/firmware-utils/src/mkrasimage.c
+++ b/tools/firmware-utils/src/mkrasimage.c
@@ -57,7 +57,6 @@ 
 #define BOARD_HEADER_LEN 68
 
 #define HEADER_PARTITION_CALC_LENGTH 2048
-#define HEADER_PARTITION_LENGTH 0x10000
 
 struct file_info {
     char *name;    /* name of the file */
@@ -70,6 +69,7 @@  static char *progname;
 static char *board_name = 0;
 static char *version_name = 0;
 static unsigned int rootfs_size = 0;
+static unsigned int header_length = 0x10000;
 
 static struct file_info kernel = { NULL, NULL, 0 };
 static struct file_info rootfs = { NULL, NULL, 0 };
@@ -144,6 +144,7 @@  void usage(int status)
             "  -v <version>    version string\n"
             "  -b <boardname>  name of board to generate image for\n"
             "  -o <out_name>   name of output image\n"
+            "  -l <hdr_length> length of header, default 65536\n"
             "  -h              show this screen\n"
     );
 
@@ -334,7 +335,7 @@  int build_image()
     board_header = generate_board_header(kernel_header, rootfs_header, board_name);
 
     /* Prepare output file */
-    out.size = HEADER_PARTITION_LENGTH + rootfs_out.size;
+    out.size = header_length + rootfs_out.size;
     if (kernel.name)
         out.size += kernel.size;
     out.data = malloc(out.size);
@@ -345,7 +346,7 @@  int build_image()
     memcpy(out.data + ROOTFS_HEADER_LEN, board_header, BOARD_HEADER_LEN);
     if (kernel.name)
         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);
     ptr += rootfs_out.size;
     if (kernel.name)
@@ -410,7 +411,7 @@  int main(int argc, char *argv[])
     while (1) {
         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)
             break;
 
@@ -436,6 +437,9 @@  int main(int argc, char *argv[])
             case 'v':
                 version_name = optarg;
                 break;
+            case 'l':
+                sscanf(optarg, "%u", &header_length);
+                break;
             default:
                 usage(EXIT_FAILURE);
                 break;