summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy Reed <teddy.reed@gmail.com>2016-06-09 19:38:02 -0700
committerTom Rini <trini@konsulko.com>2016-06-24 17:23:06 -0400
commitf8f9107d97b849afe69ca86e7abd8d1748ea7acd (patch)
treeb210c79fc53f0459b0af6cecb90d7c1cdc1f3016
parent92dfd9221c97265ff303bf9437481b9767bd72ea (diff)
downloadu-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>
-rw-r--r--doc/mkimage.16
-rw-r--r--doc/uImage.FIT/source_file_format.txt3
-rw-r--r--tools/fit_image.c19
-rw-r--r--tools/imagetool.h1
-rw-r--r--tools/mkimage.c13
5 files changed, 39 insertions, 3 deletions
diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 4b3a255255..ffa7d60156 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -152,6 +152,12 @@ verification. Typically the file here is the device tree binary used by
CONFIG_OF_CONTROL in U-Boot.
.TP
+.BI "\-p [" "external position" "]"
+Place external data at a static external position. See \-E. Instead of writing
+a 'data-offset' property defining the offset from the end of the FIT, \-p will
+use 'data-position' as the absolute position from the base of the FIT.
+
+.TP
.BI "\-r
Specifies that keys used to sign the FIT are required. This means that they
must be verified for the image to boot. Without this option, the verification
diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
index 3f5418045e..91aa89a77e 100644
--- a/doc/uImage.FIT/source_file_format.txt
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -282,6 +282,9 @@ In this case the 'data' property is omitted. Instead you can use:
aligned to a 4-byte boundary.
- data-size : size of the data in bytes
+The 'data-offset' property can be substituted with 'data-position', which
+defines an absolute position or address as the offset. This is helpful when
+booting U-Boot proper before performing relocation.
9) Examples
-----------
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));
diff --git a/tools/imagetool.h b/tools/imagetool.h
index a3ed0f43d6..1f2161cf61 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -74,6 +74,7 @@ struct image_tool_params {
struct content_info *content_tail;
bool external_data; /* Store data outside the FIT */
bool quiet; /* Don't output text in normal operation */
+ unsigned int external_offset; /* Add padding to external data */
};
/*
diff --git a/tools/mkimage.c b/tools/mkimage.c
index aefe22f19b..ff3024a8f1 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -93,11 +93,13 @@ static void usage(const char *msg)
" -f => input filename for FIT source\n");
#ifdef CONFIG_FIT_SIGNATURE
fprintf(stderr,
- "Signing / verified boot options: [-k keydir] [-K dtb] [ -c <comment>] [-r]\n"
+ "Signing / verified boot options: [-E] [-k keydir] [-K dtb] [ -c <comment>] [-p addr] [-r]\n"
+ " -E => place data outside of the FIT structure\n"
" -k => set directory containing private keys\n"
" -K => write public keys to this .dtb file\n"
" -c => add comment in signature node\n"
" -F => re-sign existing FIT image\n"
+ " -p => place external data at a static position\n"
" -r => mark keys used as 'required' in dtb\n");
#else
fprintf(stderr,
@@ -136,7 +138,7 @@ static void process_args(int argc, char **argv)
int opt;
while ((opt = getopt(argc, argv,
- "a:A:b:cC:d:D:e:Ef:Fk:K:ln:O:rR:qsT:vVx")) != -1) {
+ "a:A:b:cC:d:D:e:Ef:Fk:K:ln:p:O:rR:qsT:vVx")) != -1) {
switch (opt) {
case 'a':
params.addr = strtoull(optarg, &ptr, 16);
@@ -216,6 +218,13 @@ static void process_args(int argc, char **argv)
if (params.os < 0)
usage("Invalid operating system");
break;
+ case 'p':
+ params.external_offset = strtoull(optarg, &ptr, 16);
+ if (*ptr) {
+ fprintf(stderr, "%s: invalid offset size %s\n",
+ params.cmdname, optarg);
+ exit(EXIT_FAILURE);
+ }
case 'q':
params.quiet = 1;
break;