]> git.sur5r.net Git - u-boot/blobdiff - tools/rksd.c
rockchip: mkimage: rewrite padding calculation for SD/MMC and SPI images
[u-boot] / tools / rksd.c
index ac8a67d3bc80b1218f60400cb341b9e9ea315ef1..6dafedf282218bd17f608b71242f9a10b71c8800 100644 (file)
@@ -29,12 +29,20 @@ static void rksd_set_header(void *buf,  struct stat *sbuf,  int ifd,
        unsigned int size;
        int ret;
 
+       printf("params->file_size %d\n", params->file_size);
+       printf("params->orig_file_size %d\n", params->orig_file_size);
+
+       /*
+        * We need to calculate this using 'RK_SPL_HDR_START' and not using
+        * 'tparams->header_size', as the additional byte inserted when
+        * 'is_boot0' is true counts towards the payload.
+        */
        size = params->file_size - RK_SPL_HDR_START;
        ret = rkcommon_set_header(buf, size, params);
        if (ret) {
                /* TODO(sjg@chromium.org): This method should return an error */
-               printf("Warning: SPL image is too large (size %#x) and will not boot\n",
-                      size);
+               printf("Warning: SPL image is too large (size %#x) and will "
+                      "not boot\n", size);
        }
 }
 
@@ -51,18 +59,11 @@ static int rksd_check_image_type(uint8_t type)
                return EXIT_FAILURE;
 }
 
-/* We pad the file out to a fixed size - this method returns that size */
 static int rksd_vrec_header(struct image_tool_params *params,
                            struct image_type_params *tparams)
 {
-       int pad_size;
-
-       rkcommon_vrec_header(params, tparams);
-
-       pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params);
-       debug("pad_size %x\n", pad_size);
-
-       return pad_size - params->file_size - tparams->header_size;
+       /* We don't add any additional padding after the end of the image */
+       return rkcommon_vrec_header(params, tparams, 1);
 }
 
 /*