1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

rockchip: mkimage: rewrite padding calculation for SD/MMC and SPI images

In (first) breaking and (then) fixing the rkspi tool, I realised that
the calculation of the required padding (for the header-size and the
2K-in-every-4K SPI layout) was not as self-explainatory as it could
have been.  This change rewrites the code (using new, common functions
in rkcommon.c) and adds verbose in-line comments to ensure that we
won't fall into the same pit in the future...

Tested on the RK3399 (with has a boot0-style payload) with SD/MMC and SPI.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Philipp Tomsich
2017-04-17 17:48:01 +02:00
committed by Simon Glass
parent 798c93faf3
commit 366aad4d97
4 changed files with 66 additions and 29 deletions

View 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);
}
/*