hc
2024-08-16 a24a44ff9ca902811b99aa9663d697cf452e08ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * (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;
 
   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;
   }
 
   if (part_get_info_by_name(dev_desc, part_name, &part_info) < 0) {
       printf("Failed to get \"%s\" part\n", part_name);
       return -ENODEV;
   }
 
   hdr = populate_andr_img_hdr(dev_desc, &part_info);
   if (!hdr) {
       printf("Not an android image\n");
       return -EINVAL;
   } else {
       printf("Partition \"%s\"\n", part_info.name);
       android_print_contents(hdr);
   }
 
   free(hdr);
 
   return 0;
}
 
U_BOOT_CMD(
   android_print_hdr, 2, 1, do_android_print_hdr,
   "print android image header", "<partition name>"
);