mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +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:
committed by
Simon Glass
parent
798c93faf3
commit
366aad4d97
@@ -200,9 +200,13 @@ void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size)
|
||||
}
|
||||
}
|
||||
|
||||
void rkcommon_vrec_header(struct image_tool_params *params,
|
||||
struct image_type_params *tparams)
|
||||
int rkcommon_vrec_header(struct image_tool_params *params,
|
||||
struct image_type_params *tparams,
|
||||
unsigned int alignment)
|
||||
{
|
||||
unsigned int unpadded_size;
|
||||
unsigned int padded_size;
|
||||
|
||||
/*
|
||||
* The SPL image looks as follows:
|
||||
*
|
||||
@@ -228,4 +232,17 @@ void rkcommon_vrec_header(struct image_tool_params *params,
|
||||
/* Allocate, clear and install the header */
|
||||
tparams->hdr = malloc(tparams->header_size);
|
||||
memset(tparams->hdr, 0, tparams->header_size);
|
||||
tparams->header_size = tparams->header_size;
|
||||
|
||||
/*
|
||||
* If someone passed in 0 for the alignment, we'd better handle
|
||||
* it correctly...
|
||||
*/
|
||||
if (!alignment)
|
||||
alignment = 1;
|
||||
|
||||
unpadded_size = tparams->header_size + params->file_size;
|
||||
padded_size = ROUND(unpadded_size, alignment);
|
||||
|
||||
return padded_size - unpadded_size;
|
||||
}
|
||||
|
Reference in New Issue
Block a user