1#!/bin/bash 2# 3# Copyright (C) 2020 Rockchip Electronics Co., Ltd 4# 5# SPDX-License-Identifier: GPL-2.0+ 6# 7 8# Process args and auto set variables 9source ./${srctree}/arch/arm/mach-rockchip/make_fit_args.sh 10 11rm -f ${srctree}/*.digest ${srctree}/*.bin.gz 12 13if [ "${COMPRESSION}" == "gzip" ]; then 14 SUFFIX=".gz" 15else 16 COMPRESSION="none" 17 SUFFIX= 18fi 19 20# digest 21if [ "${COMPRESSION}" == "gzip" ]; then 22 openssl dgst -sha256 -binary -out ${srctree}/u-boot-nodtb.digest ${srctree}/u-boot-nodtb.bin 23 openssl dgst -sha256 -binary -out ${srctree}/tee.digest ${srctree}/tee.bin 24 gzip -k -f -9 ${srctree}/tee.bin 25 UBOOT_SZ=`ls -l u-boot-nodtb.bin | awk '{ print $5 }'` 26 if [ ${UBOOT_SZ} -gt 0 ]; then 27 gzip -k -f -9 ${srctree}/u-boot-nodtb.bin 28 else 29 touch ${srctree}/u-boot-nodtb.bin.gz 30 fi 31 if [ ! -z "${MCU_LOAD_ADDR}" ]; then 32 openssl dgst -sha256 -binary -out ${srctree}/mcu.digest ${srctree}/mcu.bin 33 gzip -k -f -9 ${srctree}/mcu.bin 34 fi 35 36 UBOOT_DIGEST=" digest { 37 value = /incbin/(\"./u-boot-nodtb.digest\"); 38 algo = \"sha256\"; 39 };" 40 TEE_DIGEST=" digest { 41 value = /incbin/(\"./tee.digest\"); 42 algo = \"sha256\"; 43 };" 44 MCU_DIGEST=" digest { 45 value = /incbin/(\"./mcu.digest\"); 46 algo = \"sha256\"; 47 };" 48fi 49 50# mcu 51if [ ! -z "${MCU_LOAD_ADDR}" ]; then 52 MCU_NODE=" mcu { 53 description = \"mcu\"; 54 type = \"standalone\"; 55 arch = \"riscv\"; 56 data = /incbin/(\"./mcu.bin${SUFFIX}\"); 57 compression = \"${COMPRESSION}\"; 58 load = <0x"${MCU_LOAD_ADDR}">; 59 hash { 60 algo = \"sha256\"; 61 }; 62${MCU_DIGEST} 63 };" 64 MCU_STANDALONE=" standalone = \"mcu\";" 65 SIGN_IMAGES=" sign-images = \"fdt\", \"firmware\", \"loadables\", \"standalone\";" 66else 67 SIGN_IMAGES=" sign-images = \"fdt\", \"firmware\", \"loadables\";" 68fi 69 70if [ -f ${srctree}/dts/kern.dtb ]; then 71 KFDT_NODE=" kernel-fdt { 72 description = \"Kernel dtb\"; 73 data = /incbin/(\"./dts/kern.dtb\"); 74 type = \"flat_dt\"; 75 arch = \"${ARCH}\"; 76 compression = \"none\"; 77 hash { 78 algo = \"sha256\"; 79 }; 80 };" 81fi 82######################################################################################################## 83 84cat << EOF 85/* 86 * Copyright (C) 2020 Rockchip Electronic Co.,Ltd 87 * 88 * Simple U-boot fit source file containing U-Boot, dtb and optee 89 */ 90 91/dts-v1/; 92 93/ { 94 description = "FIT Image with U-Boot/OP-TEE/MCU"; 95 #address-cells = <1>; 96 97 images { 98 uboot { 99 description = "U-Boot (32-bit)"; 100 data = /incbin/("./u-boot-nodtb.bin${SUFFIX}"); 101 type = "standalone"; 102 arch = "arm"; 103 os = "U-Boot"; 104 compression = "${COMPRESSION}"; 105 load = <${UBOOT_LOAD_ADDR}>; 106 hash { 107 algo = "sha256"; 108 }; 109EOF 110echo "${UBOOT_DIGEST}" 111cat << EOF 112 }; 113 optee { 114 description = "OP-TEE"; 115 data = /incbin/("./tee.bin${SUFFIX}"); 116 type = "firmware"; 117 arch = "arm"; 118 os = "op-tee"; 119 compression = "${COMPRESSION}"; 120 load = <0x${TEE_LOAD_ADDR}>; 121 entry = <0x${TEE_LOAD_ADDR}>; 122 hash { 123 algo = "sha256"; 124 }; 125EOF 126echo "${TEE_DIGEST}" 127cat << EOF 128 }; 129 fdt { 130 description = "U-Boot dtb"; 131 data = /incbin/("./u-boot.dtb"); 132 type = "flat_dt"; 133 arch = "${ARCH}"; 134 compression = "none"; 135 hash { 136 algo = "sha256"; 137 }; 138 }; 139EOF 140echo "${KFDT_NODE}" 141echo "${MCU_NODE}" 142cat << EOF 143 }; 144 145 configurations { 146 default = "conf"; 147 conf { 148 description = "Rockchip armv7 with OP-TEE"; 149 rollback-index = <0x0>; 150 burn-key-hash = <0>; 151 firmware = "optee"; 152 loadables = "uboot"; 153 fdt = "fdt"; 154EOF 155echo "${MCU_STANDALONE}" 156cat << EOF 157 signature { 158 algo = "sha256,rsa2048"; 159 padding = "pss"; 160 key-name-hint = "dev"; 161EOF 162echo "${SIGN_IMAGES}" 163cat << EOF 164 }; 165 }; 166 }; 167}; 168EOF 169