Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0+ |
| 3 | # |
| 4 | # script to generate FIT image source for i.MX8MQ boards with |
| 5 | # ARM Trusted Firmware and multiple device trees (given on the command line) |
| 6 | # |
| 7 | # usage: $0 <dt_name> [<dt_name> [<dt_name] ...] |
| 8 | |
| 9 | [ -z "$BL31" ] && BL31="bl31.bin" |
| 10 | [ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0xfe000000" |
| 11 | [ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000" |
Peng Fan | f5965b2 | 2018-12-21 06:21:29 +0000 | [diff] [blame] | 12 | [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000" |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 13 | |
| 14 | if [ ! -f $BL31 ]; then |
| 15 | echo "ERROR: BL31 file $BL31 NOT found" >&2 |
| 16 | exit 0 |
| 17 | else |
| 18 | echo "$BL31 size: " >&2 |
| 19 | ls -lct $BL31 | awk '{print $5}' >&2 |
| 20 | fi |
| 21 | |
| 22 | BL32="tee.bin" |
| 23 | |
| 24 | if [ ! -f $BL32 ]; then |
| 25 | BL32=/dev/null |
| 26 | else |
| 27 | echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2 |
| 28 | echo "$BL32 size: " >&2 |
| 29 | ls -lct $BL32 | awk '{print $5}' >&2 |
| 30 | fi |
| 31 | |
| 32 | BL33="u-boot-nodtb.bin" |
| 33 | |
| 34 | if [ ! -f $BL33 ]; then |
| 35 | echo "ERROR: $BL33 file NOT found" >&2 |
| 36 | exit 0 |
| 37 | else |
| 38 | echo "u-boot-nodtb.bin size: " >&2 |
| 39 | ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2 |
| 40 | fi |
| 41 | |
| 42 | for dtname in $* |
| 43 | do |
| 44 | echo "$dtname size: " >&2 |
| 45 | ls -lct $dtname | awk '{print $5}' >&2 |
| 46 | done |
| 47 | |
| 48 | |
| 49 | cat << __HEADER_EOF |
| 50 | /dts-v1/; |
| 51 | |
| 52 | / { |
| 53 | description = "Configuration to load ATF before U-Boot"; |
| 54 | |
| 55 | images { |
| 56 | uboot@1 { |
| 57 | description = "U-Boot (64-bit)"; |
Frieder Schrempf | 796abd0 | 2019-08-27 06:24:40 +0000 | [diff] [blame] | 58 | os = "u-boot"; |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 59 | data = /incbin/("$BL33"); |
| 60 | type = "standalone"; |
| 61 | arch = "arm64"; |
| 62 | compression = "none"; |
Peng Fan | f5965b2 | 2018-12-21 06:21:29 +0000 | [diff] [blame] | 63 | load = <$BL33_LOAD_ADDR>; |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 64 | }; |
Patrick Wildt | 4c881c0 | 2020-05-08 11:59:47 +0200 | [diff] [blame] | 65 | __HEADER_EOF |
| 66 | |
| 67 | cnt=1 |
| 68 | for dtname in $* |
| 69 | do |
| 70 | cat << __FDT_IMAGE_EOF |
| 71 | fdt@$cnt { |
| 72 | description = "$(basename $dtname .dtb)"; |
| 73 | data = /incbin/("$dtname"); |
| 74 | type = "flat_dt"; |
| 75 | compression = "none"; |
| 76 | }; |
| 77 | __FDT_IMAGE_EOF |
| 78 | cnt=$((cnt+1)) |
| 79 | done |
| 80 | |
| 81 | cat << __HEADER_EOF |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 82 | atf@1 { |
| 83 | description = "ARM Trusted Firmware"; |
Frieder Schrempf | 796abd0 | 2019-08-27 06:24:40 +0000 | [diff] [blame] | 84 | os = "arm-trusted-firmware"; |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 85 | data = /incbin/("$BL31"); |
| 86 | type = "firmware"; |
| 87 | arch = "arm64"; |
| 88 | compression = "none"; |
| 89 | load = <$ATF_LOAD_ADDR>; |
| 90 | entry = <$ATF_LOAD_ADDR>; |
| 91 | }; |
| 92 | __HEADER_EOF |
| 93 | |
| 94 | if [ -f $BL32 ]; then |
| 95 | cat << __HEADER_EOF |
| 96 | tee@1 { |
| 97 | description = "TEE firmware"; |
| 98 | data = /incbin/("$BL32"); |
| 99 | type = "firmware"; |
| 100 | arch = "arm64"; |
| 101 | compression = "none"; |
| 102 | load = <$TEE_LOAD_ADDR>; |
| 103 | entry = <$TEE_LOAD_ADDR>; |
| 104 | }; |
| 105 | __HEADER_EOF |
| 106 | fi |
| 107 | |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 108 | cat << __CONF_HEADER_EOF |
| 109 | }; |
| 110 | configurations { |
| 111 | default = "config@1"; |
| 112 | |
| 113 | __CONF_HEADER_EOF |
| 114 | |
| 115 | cnt=1 |
| 116 | for dtname in $* |
| 117 | do |
| 118 | if [ -f $BL32 ]; then |
| 119 | cat << __CONF_SECTION_EOF |
| 120 | config@$cnt { |
| 121 | description = "$(basename $dtname .dtb)"; |
Ye Li | b3f8e3e | 2020-04-09 01:44:43 -0700 | [diff] [blame] | 122 | firmware = "uboot@1"; |
| 123 | loadables = "atf@1", "tee@1"; |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 124 | fdt = "fdt@$cnt"; |
| 125 | }; |
| 126 | __CONF_SECTION_EOF |
| 127 | else |
| 128 | cat << __CONF_SECTION1_EOF |
| 129 | config@$cnt { |
| 130 | description = "$(basename $dtname .dtb)"; |
Ye Li | b3f8e3e | 2020-04-09 01:44:43 -0700 | [diff] [blame] | 131 | firmware = "uboot@1"; |
| 132 | loadables = "atf@1"; |
Peng Fan | 128e342 | 2018-11-20 10:19:39 +0000 | [diff] [blame] | 133 | fdt = "fdt@$cnt"; |
| 134 | }; |
| 135 | __CONF_SECTION1_EOF |
| 136 | fi |
| 137 | cnt=$((cnt+1)) |
| 138 | done |
| 139 | |
| 140 | cat << __ITS_EOF |
| 141 | }; |
| 142 | }; |
| 143 | __ITS_EOF |