diff options
author | Teddy Reed <teddy.reed@gmail.com> | 2016-06-09 19:38:02 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-06-24 17:23:06 -0400 |
commit | f8f9107d97b849afe69ca86e7abd8d1748ea7acd (patch) | |
tree | b210c79fc53f0459b0af6cecb90d7c1cdc1f3016 /tools/fit_image.c | |
parent | 92dfd9221c97265ff303bf9437481b9767bd72ea (diff) | |
download | u-boot-f8f9107d97b849afe69ca86e7abd8d1748ea7acd.tar.gz |
mkimage: fit: spl: Add an optional static offset for external data
When building a FIT with external data (-E), U-Boot proper may require
absolute positioning for executing the external firmware. To acheive this
use the (-p) switch, which will replace the amended 'data-offset' with
'data-position' indicating the absolute position of external data.
It is considered an error if the requested absolute position overlaps with the
initial data required for the compact FIT.
Signed-off-by: Teddy Reed <teddy.reed@gmail.com>
Diffstat (limited to 'tools/fit_image.c')
-rw-r--r-- | tools/fit_image.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c index 0551572b04..76a6de4579 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -416,7 +416,13 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EPERM; goto err_munmap; } - fdt_setprop_u32(fdt, node, "data-offset", buf_ptr); + if (params->external_offset > 0) { + /* An external offset positions the data absolutely. */ + fdt_setprop_u32(fdt, node, "data-position", + params->external_offset + buf_ptr); + } else { + fdt_setprop_u32(fdt, node, "data-offset", buf_ptr); + } fdt_setprop_u32(fdt, node, "data-size", len); buf_ptr += (len + 3) & ~3; @@ -437,6 +443,17 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EIO; goto err; } + + /* Check if an offset for the external data was set. */ + if (params->external_offset > 0) { + if (params->external_offset < new_size) { + debug("External offset %x overlaps FIT length %x", + params->external_offset, new_size); + ret = -EINVAL; + goto err; + } + new_size = params->external_offset; + } if (lseek(fd, new_size, SEEK_SET) < 0) { debug("%s: Failed to seek to end of file: %s\n", __func__, strerror(errno)); |