summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2016-11-16 10:52:44 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-01-10 08:27:53 +0100
commitfed8acd6c0e504cb746db9f15eae085c9a646a6b (patch)
tree3c4851225e58de5e48a3ec1b53e575645f170706
parentd0cd9b439bcc2001e1cea7d0856bb64a2e331fcc (diff)
downloadbarebox-fed8acd6c0e504cb746db9f15eae085c9a646a6b.tar.gz
scripts/kwbimage: allow to overwrite binary
This is a preparation to let barebox provide the binary.0. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--scripts/kwbimage.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 2af96f0..5b84db3 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -347,6 +347,7 @@ static void usage(const char *prog)
printf(" -h: this help text\n");
printf(" Options specific to image creation:\n");
printf(" -p: path to payload image. Overrides the PAYLOAD line from kwbimage.cfg\n");
+ printf(" -b: path to binary image. Overrides the BINARY line from kwbimage.cfg\n");
printf(" -m: boot media. Overrides the BOOT_FROM line from kwbimage.cfg\n");
printf(" -d: load address. Overrides the DEST_ADDR line from kwbimage.cfg\n");
printf(" -e: exec address. Overrides the EXEC_ADDR line from kwbimage.cfg\n");
@@ -1186,6 +1187,30 @@ static int image_override_payload(struct image_cfg_element *image_cfg,
return 0;
}
+static int image_override_binary(struct image_cfg_element *image_cfg,
+ int *cfgn, char *binary)
+{
+ struct image_cfg_element *e;
+ int cfgi = *cfgn;
+
+ if (!binary)
+ return 0;
+
+ e = image_find_option(image_cfg, *cfgn, IMAGE_CFG_BINARY);
+ if (e) {
+ e->binary.file = binary;
+ return 0;
+ }
+
+ image_cfg[cfgi].type = IMAGE_CFG_BINARY;
+ image_cfg[cfgi].binary.file = binary;
+ image_cfg[cfgi].binary.nargs = 0;
+ cfgi++;
+
+ *cfgn = cfgi;
+ return 0;
+}
+
static int image_override_bootmedia(struct image_cfg_element *image_cfg,
int *cfgn, const char *bootmedia)
{
@@ -1332,9 +1357,9 @@ static void image_dump_config(struct image_cfg_element *image_cfg,
}
static int image_create(const char *input, const char *output,
- const char *payload, const char *bootmedia,
- uint32_t dstaddr, uint32_t execaddr,
- int verbose)
+ const char *payload, char *binary,
+ const char *bootmedia, uint32_t dstaddr,
+ uint32_t execaddr, int verbose)
{
struct image_cfg_element *image_cfg;
FILE *outputimg;
@@ -1361,6 +1386,7 @@ static int image_create(const char *input, const char *output,
}
image_override_payload(image_cfg, &cfgn, payload);
+ image_override_binary(image_cfg, &cfgn, binary);
image_override_bootmedia(image_cfg, &cfgn, bootmedia);
image_override_dstaddr(image_cfg, &cfgn, dstaddr);
image_override_execaddr(image_cfg, &cfgn, execaddr);
@@ -1433,9 +1459,10 @@ int main(int argc, char *argv[])
int action = -1, opt, verbose = 0;
const char *input = NULL, *output = NULL,
*payload = NULL, *bootmedia = NULL;
+ char *binary = NULL;
uint32_t execaddr = ADDR_INVALID, dstaddr = ADDR_INVALID;
- while ((opt = getopt(argc, argv, "hxci:o:p:m:e:d:v")) != -1) {
+ while ((opt = getopt(argc, argv, "hxci:o:p:b:m:e:d:v")) != -1) {
switch (opt) {
case 'x':
action = ACTION_EXTRACT;
@@ -1452,6 +1479,9 @@ int main(int argc, char *argv[])
case 'p':
payload = optarg;
break;
+ case 'b':
+ binary = optarg;
+ break;
case 'm':
bootmedia = optarg;
break;
@@ -1502,7 +1532,7 @@ int main(int argc, char *argv[])
case ACTION_EXTRACT:
return image_extract(input, output);
case ACTION_CREATE:
- return image_create(input, output, payload,
+ return image_create(input, output, payload, binary,
bootmedia, dstaddr, execaddr,
verbose);
case ACTION_HELP: