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######################################################################################################## 70 71cat << EOF 72/* 73 * Copyright (C) 2020 Rockchip Electronic Co.,Ltd 74 * 75 * Simple U-boot fit source file containing U-Boot, dtb and optee 76 */ 77 78/dts-v1/; 79 80/ { 81 description = "FIT Image with U-Boot/OP-TEE/MCU"; 82 #address-cells = <1>; 83 84 images { 85 uboot { 86 description = "U-Boot (32-bit)"; 87 data = /incbin/("./u-boot-nodtb.bin${SUFFIX}"); 88 type = "standalone"; 89 arch = "arm"; 90 os = "U-Boot"; 91 compression = "${COMPRESSION}"; 92 load = <${UBOOT_LOAD_ADDR}>; 93 hash { 94 algo = "sha256"; 95 }; 96EOF 97echo "${UBOOT_DIGEST}" 98cat << EOF 99 }; 100 optee { 101 description = "OP-TEE"; 102 data = /incbin/("./tee.bin${SUFFIX}"); 103 type = "firmware"; 104 arch = "arm"; 105 os = "op-tee"; 106 compression = "${COMPRESSION}"; 107 load = <0x${TEE_LOAD_ADDR}>; 108 entry = <0x${TEE_LOAD_ADDR}>; 109 hash { 110 algo = "sha256"; 111 }; 112EOF 113echo "${TEE_DIGEST}" 114cat << EOF 115 }; 116 fdt { 117 description = "U-Boot dtb"; 118 data = /incbin/("./u-boot.dtb"); 119 type = "flat_dt"; 120 compression = "none"; 121 hash { 122 algo = "sha256"; 123 }; 124 }; 125EOF 126echo "${MCU_NODE}" 127cat << EOF 128 }; 129 130 configurations { 131 default = "conf"; 132 conf { 133 description = "Rockchip armv7 with OP-TEE"; 134 rollback-index = <0x0>; 135 firmware = "optee"; 136 loadables = "uboot"; 137 fdt = "fdt"; 138EOF 139echo "${MCU_STANDALONE}" 140cat << EOF 141 signature { 142 algo = "sha256,rsa2048"; 143 padding = "pss"; 144 key-name-hint = "dev"; 145EOF 146echo "${SIGN_IMAGES}" 147cat << EOF 148 }; 149 }; 150 }; 151}; 152EOF 153