uboot/tools/k3_fit_atf.sh
<<
>>
Prefs
   1#!/bin/sh
   2# SPDX-License-Identifier: GPL-2.0+
   3#
   4# script to generate FIT image source for K3 Family boards with
   5# ATF, OPTEE, SPL and multiple device trees (given on the command line).
   6# Inspired from board/sunxi/mksunxi_fit_atf.sh
   7#
   8# usage: $0 <atf_load_addr> <dt_name> [<dt_name> [<dt_name] ...]
   9
  10[ -z "$ATF" ] && ATF="bl31.bin"
  11
  12if [ ! -f $ATF ]; then
  13        echo "WARNING ATF file $ATF NOT found, resulting binary is non-functional" >&2
  14        ATF=/dev/null
  15fi
  16
  17[ -z "$TEE" ] && TEE="bl32.bin"
  18
  19if [ ! -f $TEE ]; then
  20        echo "WARNING OPTEE file $TEE NOT found, resulting might be non-functional" >&2
  21        TEE=/dev/null
  22fi
  23
  24[ -z "$DM" ] && DM="dm.bin"
  25
  26if [ ! -e $DM ]; then
  27        echo "WARNING DM file $DM NOT found, resulting might be non-functional" >&2
  28        DM=/dev/null
  29fi
  30
  31if [ ! -z "$IS_HS" ]; then
  32        HS_APPEND=_HS
  33fi
  34
  35cat << __HEADER_EOF
  36/dts-v1/;
  37
  38/ {
  39        description = "Configuration to load ATF and SPL";
  40        #address-cells = <1>;
  41
  42        images {
  43                atf {
  44                        description = "ARM Trusted Firmware";
  45                        data = /incbin/("$ATF");
  46                        type = "firmware";
  47                        arch = "arm64";
  48                        compression = "none";
  49                        os = "arm-trusted-firmware";
  50                        load = <$1>;
  51                        entry = <$1>;
  52                };
  53                tee {
  54                        description = "OPTEE";
  55                        data = /incbin/("$TEE");
  56                        type = "tee";
  57                        arch = "arm64";
  58                        compression = "none";
  59                        os = "tee";
  60                        load = <0x9e800000>;
  61                        entry = <0x9e800000>;
  62                };
  63                dm {
  64                        description = "DM binary";
  65                        data = /incbin/("$DM");
  66                        type = "firmware";
  67                        arch = "arm32";
  68                        compression = "none";
  69                        os = "DM";
  70                        load = <0x89000000>;
  71                        entry = <0x89000000>;
  72                };
  73                spl {
  74                        description = "SPL (64-bit)";
  75                        data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
  76                        type = "standalone";
  77                        os = "U-Boot";
  78                        arch = "arm64";
  79                        compression = "none";
  80                        load = <0x80080000>;
  81                        entry = <0x80080000>;
  82                };
  83__HEADER_EOF
  84
  85# shift through ATF load address in the command line arguments
  86shift
  87
  88for dtname in $*
  89do
  90        cat << __FDT_IMAGE_EOF
  91                $(basename $dtname) {
  92                        description = "$(basename $dtname .dtb)";
  93                        data = /incbin/("$dtname$HS_APPEND");
  94                        type = "flat_dt";
  95                        arch = "arm";
  96                        compression = "none";
  97                };
  98__FDT_IMAGE_EOF
  99done
 100
 101cat << __CONF_HEADER_EOF
 102        };
 103        configurations {
 104                default = "$(basename $1)";
 105
 106__CONF_HEADER_EOF
 107
 108for dtname in $*
 109do
 110        cat << __CONF_SECTION_EOF
 111                $(basename $dtname) {
 112                        description = "$(basename $dtname .dtb)";
 113                        firmware = "atf";
 114                        loadables = "tee", "dm", "spl";
 115                        fdt = "$(basename $dtname)";
 116                };
 117__CONF_SECTION_EOF
 118done
 119
 120cat << __ITS_EOF
 121        };
 122};
 123__ITS_EOF
 124