xref: /rk3399_rockchip-uboot/arch/arm/mach-rockchip/make_fit_optee.sh (revision 505eebf24e153630f5a3e0ec232ffda67bf48e9e)
1#!/bin/bash
2
3cat << EOF
4/*
5 * Copyright (C) 2017 Rockchip Electronic Co.,Ltd
6 *
7 * Simple U-boot fit source file containing U-Boot, dtb and optee
8 */
9
10/dts-v1/;
11
12/ {
13	description = "Simple image with OP-TEE support";
14	#address-cells = <1>;
15
16	images {
17		uboot@1 {
18			description = "U-Boot";
19			data = /incbin/("./u-boot-nodtb.bin");
20			type = "standalone";
21			os = "U-Boot";
22			arch = "arm";
23			compression = "none";
24EOF
25
26OUTDIR=$PWD
27DARM_BASE=`sed -n "/CONFIG_SYS_SDRAM_BASE=/s/CONFIG_SYS_SDRAM_BASE=//p" ${OUTDIR}/include/autoconf.mk|tr -d '\r'`
28UBOOT_OFFSET=`sed -n "/CONFIG_SYS_TEXT_BASE=/s/CONFIG_SYS_TEXT_BASE=//p" ${OUTDIR}/include/autoconf.mk|tr -d '\r'`
29UBOOT_BASE=$((DARM_BASE+UBOOT_OFFSET))
30UBOOT_BASE=$(echo "obase=16;${UBOOT_BASE}"|bc)
31echo "			load = <0x"$UBOOT_BASE">;"
32cat << EOF
33			hash@1 {
34				algo = "sha256";
35			};
36		};
37		optee@1 {
38			description = "OP-TEE";
39			data = /incbin/("./tee.bin");
40			type = "firmware";
41			arch = "arm";
42			os = "op-tee";
43			compression = "none";
44EOF
45
46TEE_OFFSET=0x8400000
47TEE_LOAD_ADDR=$((DARM_BASE+TEE_OFFSET))
48TEE_LOAD_ADDR=$(echo "obase=16;${TEE_LOAD_ADDR}"|bc)
49echo "			load = <0x"$TEE_LOAD_ADDR">;"
50echo "			entry = <0x"$TEE_LOAD_ADDR">;"
51cat << EOF
52			hash@1 {
53				algo = "sha256";
54			};
55		};
56		fdt@1 {
57			description = "U-Boot dtb";
58			data = /incbin/("./u-boot.dtb");
59			type = "flat_dt";
60			compression = "none";
61			hash@1 {
62				algo = "sha256";
63			};
64		};
65	};
66
67	configurations {
68		default = "conf@1";
69		conf@1 {
70			description = "Rockchip armv7 with OP-TEE";
71			firmware = "optee@1";
72			loadables = "uboot@1";
73			fdt = "fdt@1";
74			signature@1 {
75				algo = "sha256,rsa2048";
76				key-name-hint = "dev";
77				sign-images = "fdt", "firmware", "loadables";
78			};
79		};
80	};
81};
82EOF
83