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>
This commit is contained in:
parent
d0cd9b439b
commit
fed8acd6c0
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue