cmd: add command "android_print_hdr" support
This is useful for debug. Change-Id: I6e56255d6e32e692031c6c3226d0dc041433dd48 Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
acffe33271
commit
eae0a6b103
|
|
@ -24,7 +24,7 @@ obj-$(CONFIG_CMD_BDI) += bdinfo.o
|
||||||
obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
|
obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
|
||||||
obj-$(CONFIG_CMD_BLOCK_CACHE) += blkcache.o
|
obj-$(CONFIG_CMD_BLOCK_CACHE) += blkcache.o
|
||||||
obj-$(CONFIG_CMD_BMP) += bmp.o
|
obj-$(CONFIG_CMD_BMP) += bmp.o
|
||||||
obj-$(CONFIG_CMD_BOOT_ANDROID) += boot_android.o
|
obj-$(CONFIG_CMD_BOOT_ANDROID) += boot_android.o android.o
|
||||||
obj-$(CONFIG_CMD_BOOT_ROCKCHIP) += bootrkp.o
|
obj-$(CONFIG_CMD_BOOT_ROCKCHIP) += bootrkp.o
|
||||||
obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
|
obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
|
||||||
obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
|
obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2019 Rockchip Electronics Co., Ltd
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <common.h>
|
||||||
|
#include <android_image.h>
|
||||||
|
#include <blk.h>
|
||||||
|
#include <boot_rkimg.h>
|
||||||
|
#include <command.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
static int do_android_print_hdr(cmd_tbl_t *cmdtp, int flag,
|
||||||
|
int argc, char * const argv[])
|
||||||
|
{
|
||||||
|
struct blk_desc *dev_desc;
|
||||||
|
struct andr_img_hdr *hdr;
|
||||||
|
disk_partition_t part_info;
|
||||||
|
const char *part_name;
|
||||||
|
int blkcnt, ret;
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
part_name = argv[1];
|
||||||
|
|
||||||
|
dev_desc = rockchip_get_bootdev();
|
||||||
|
if (!dev_desc) {
|
||||||
|
printf("dev_desc is NULL!\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = part_get_info_by_name(dev_desc, part_name, &part_info);
|
||||||
|
if (ret < 0) {
|
||||||
|
printf("Failed to get \"%s\" part, ret=%d\n", part_name, ret);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdr = memalign(ARCH_DMA_MINALIGN, sizeof(*hdr));
|
||||||
|
if (!hdr) {
|
||||||
|
printf("%s: out of memory!\n", __func__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
blkcnt = sizeof(*hdr) / dev_desc->blksz;
|
||||||
|
ret = blk_dread(dev_desc, part_info.start, blkcnt, hdr);
|
||||||
|
if (ret != blkcnt) {
|
||||||
|
printf("Failed to read %s sector, ret=%d\n", part_info.name, ret);
|
||||||
|
free(hdr);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!android_image_check_header(hdr)) {
|
||||||
|
printf("Partition \"%s\"\n", part_info.name);
|
||||||
|
android_print_contents(hdr);
|
||||||
|
} else {
|
||||||
|
printf("Not an android image\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
free(hdr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_BOOT_CMD(
|
||||||
|
android_print_hdr, 2, 1, do_android_print_hdr,
|
||||||
|
"print android image header", "<partition name>"
|
||||||
|
);
|
||||||
Loading…
Reference in New Issue