[PATCH v3 3/9] cmd: abootimg: Add abootimg command

Eugeniu Rosca roscaeugeniu at gmail.com
Sun Jan 5 21:38:58 CET 2020


Hi,

With below nits, I have provided the Reviewed-by/Tested-by signatures.

On Tue, Dec 24, 2019 at 09:54:49PM +0200, Sam Protsenko wrote:
> This command can be used to extract fields and image payloads from
> Android Boot Image. It can be used for example to implement boot flow
> where dtb is taken from boot.img (as v2 incorporated dtb inside of
> boot.img). Using this command, one can obtain needed dtb blob from
> boot.img in scripting manner, and then apply needed dtbo's (from "dtbo"

FWIW, 'scripted manner' is more common, as suggested by Ngram:
https://tinyurl.com/rck3ysj

> diff --git a/cmd/abootimg.c b/cmd/abootimg.c
> +static int abootimg_get_dtb_by_index(int argc, char * const argv[])
> +{
> +	u32 num;
> +	char *endp;
> +	ulong addr;
> +	u32 size;
> +
> +	if (argc < 1 || argc > 3)
> +		return CMD_RET_USAGE;
> +
> +	num = simple_strtoul(argv[0] + strlen("--index="), &endp, 0);
> +	if (*endp != '\0') {
> +		printf("Error: Wrong num\n");
> +		return CMD_RET_FAILURE;
> +	}

The way '--index=' option is processed right now results in below
inconsistencies:

=> abootimg get dtb --index=0
1980
 `- expected output

=> abootimg get dtb --index=
1980
 `- unexpected output (expected error)

=> abootimg get dtb --index=0 --index=1
=>
 `- unexpected output (expected error)

> +U_BOOT_CMD(
> +	abootimg, CONFIG_SYS_MAXARGS, 0, do_abootimg,
> +	"manipulate Android Boot Image",
> +	"addr <addr>\n"
> +	"    - set the address in RAM where boot image is located\n"
> +	"      ($loadaddr is used by default)\n"
> +	"abootimg dump dtb\n"
> +	"    - print info for all DT blobs in DTB area\n"
> +	"abootimg get ver [varname]\n"
> +	"    - get header version\n"
> +	"abootimg get recovery_dtbo [addr_var [size_var]]\n"
> +	"    - get address and size (hex) of recovery DTBO area in the image\n"
> +	"      [addr_var]: variable name to contain DTBO area address\n"
> +	"      [size_var]: variable name to contain DTBO area size\n"
> +	"abootimg get dtb_load_addr [varname]\n"
> +	"    - get load address (hex) of DTB, from image header\n"
> +	"abootimg get dtb --index=<num> [addr_var [size_var]]\n"
> +	"    - get address and size (hex) of DT blob in the image by index\n"
> +	"      <num>: index number of desired DT blob in DTB area\n"
> +	"      [addr_var]: variable name to contain DT blob address\n"
> +	"      [size_var]: variable name to contain DT blob size\n"

[minor] Superfluous blank line at the end of help.

Apart from the above, testing two Android v2 images containing the
DTB in so called "concat" and DTBO formats didn't reveal any issues.

Reviewed-by: Eugeniu Rosca <erosca at de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca at de.adit-jv.com>

-- 
Best Regards,
Eugeniu


More information about the U-Boot mailing list