xref: /rk3399_rockchip-uboot/cmd/bootrkp.c (revision 54d254fe97494da68cc03670ca2ea7e030b90775)
1 /*
2  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <android_bootloader.h>
9 #include <attestation_key.h>
10 #include <boot_rkimg.h>
11 
12 static int do_boot_rockchip(cmd_tbl_t *cmdtp, int flag, int argc,
13 		      char * const argv[])
14 {
15 	disk_partition_t part_info;
16 	struct blk_desc *dev_desc;
17 	int mode = 0;
18 	char *boot_partname = PART_BOOT;
19 	int ret = 0;
20 
21 	dev_desc = rockchip_get_bootdev();
22 
23 #ifdef CONFIG_OPTEE_CLIENT
24 	disk_partition_t misc_part_info;
25 
26 	/* load attestation key from misc partition. */
27 	ret = part_get_info_by_name(dev_desc, "misc",
28 				    &misc_part_info);
29 	if (ret < 0)
30 		printf("%s Could not find misc partition\n", __func__);
31 	else
32 		load_attestation_key(dev_desc, &misc_part_info);
33 #endif
34 
35 	mode = rockchip_get_boot_mode();
36 	if (mode == BOOT_MODE_RECOVERY) {
37 		boot_partname = PART_RECOVERY;
38 		printf("%s boot from Recovery partition!\n", __func__);
39 	}
40 	ret = part_get_info_by_name(dev_desc, boot_partname, &part_info);
41 
42 	if(boot_rockchip_image(dev_desc, &part_info))
43 		ret = CMD_RET_FAILURE;
44 
45 	return ret;
46 }
47 
48 U_BOOT_CMD(
49 	bootrkp,  CONFIG_SYS_MAXARGS,     1,      do_boot_rockchip,
50 	"Boot Linux Image from rockchip image type",
51 	"kernel.img: zImage/Image\n"
52 	"boot.img: ramdisk\n"
53 	"resource.img: dtb, u-boot logo, kernel logo"
54 );
55