Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 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 | # |
Aswath Govindraju | 0c51509 | 2021-06-04 22:00:31 +0530 | [diff] [blame] | 8 | # usage: $0 <atf_load_addr> <dt_name> [<dt_name> [<dt_name] ...] |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 9 | |
| 10 | [ -z "$ATF" ] && ATF="bl31.bin" |
| 11 | |
| 12 | if [ ! -f $ATF ]; then |
| 13 | echo "WARNING ATF file $ATF NOT found, resulting binary is non-functional" >&2 |
| 14 | ATF=/dev/null |
| 15 | fi |
| 16 | |
| 17 | [ -z "$TEE" ] && TEE="bl32.bin" |
| 18 | |
| 19 | if [ ! -f $TEE ]; then |
| 20 | echo "WARNING OPTEE file $TEE NOT found, resulting might be non-functional" >&2 |
| 21 | TEE=/dev/null |
| 22 | fi |
| 23 | |
Tero Kristo | df5363a | 2021-06-11 11:45:17 +0300 | [diff] [blame] | 24 | [ -z "$DM" ] && DM="dm.bin" |
| 25 | |
| 26 | if [ ! -e $DM ]; then |
| 27 | echo "WARNING DM file $DM NOT found, resulting might be non-functional" >&2 |
| 28 | DM=/dev/null |
| 29 | fi |
| 30 | |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 31 | if [ ! -z "$IS_HS" ]; then |
| 32 | HS_APPEND=_HS |
| 33 | fi |
| 34 | |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 35 | cat << __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"; |
Aswath Govindraju | 0c51509 | 2021-06-04 22:00:31 +0530 | [diff] [blame] | 50 | load = <$1>; |
| 51 | entry = <$1>; |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 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 | }; |
Tero Kristo | df5363a | 2021-06-11 11:45:17 +0300 | [diff] [blame] | 63 | dm { |
| 64 | description = "DM binary"; |
| 65 | data = /incbin/("$DM"); |
| 66 | type = "firmware"; |
| 67 | arch = "arm32"; |
| 68 | compression = "none"; |
| 69 | os = "DM"; |
| 70 | load = <0xa0000000>; |
| 71 | entry = <0xa0000000>; |
| 72 | }; |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 73 | spl { |
| 74 | description = "SPL (64-bit)"; |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 75 | data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND"); |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 76 | type = "standalone"; |
| 77 | os = "U-Boot"; |
| 78 | arch = "arm64"; |
| 79 | compression = "none"; |
| 80 | load = <0x80080000>; |
| 81 | entry = <0x80080000>; |
| 82 | }; |
| 83 | __HEADER_EOF |
| 84 | |
Aswath Govindraju | 0c51509 | 2021-06-04 22:00:31 +0530 | [diff] [blame] | 85 | # shift through ATF load address in the command line arguments |
| 86 | shift |
| 87 | |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 88 | for dtname in $* |
| 89 | do |
| 90 | cat << __FDT_IMAGE_EOF |
| 91 | $(basename $dtname) { |
| 92 | description = "$(basename $dtname .dtb)"; |
Andrew F. Davis | 5083696 | 2019-04-12 12:54:46 -0400 | [diff] [blame] | 93 | data = /incbin/("$dtname$HS_APPEND"); |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 94 | type = "flat_dt"; |
| 95 | arch = "arm"; |
| 96 | compression = "none"; |
| 97 | }; |
| 98 | __FDT_IMAGE_EOF |
| 99 | done |
| 100 | |
| 101 | cat << __CONF_HEADER_EOF |
| 102 | }; |
| 103 | configurations { |
| 104 | default = "$(basename $1)"; |
| 105 | |
| 106 | __CONF_HEADER_EOF |
| 107 | |
| 108 | for dtname in $* |
| 109 | do |
| 110 | cat << __CONF_SECTION_EOF |
| 111 | $(basename $dtname) { |
| 112 | description = "$(basename $dtname .dtb)"; |
| 113 | firmware = "atf"; |
Tero Kristo | df5363a | 2021-06-11 11:45:17 +0300 | [diff] [blame] | 114 | loadables = "tee", "dm", "spl"; |
Lokesh Vutla | 9d4f8c4 | 2018-08-27 15:57:14 +0530 | [diff] [blame] | 115 | fdt = "$(basename $dtname)"; |
| 116 | }; |
| 117 | __CONF_SECTION_EOF |
| 118 | done |
| 119 | |
| 120 | cat << __ITS_EOF |
| 121 | }; |
| 122 | }; |
| 123 | __ITS_EOF |