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" |
| 12 | |
| 13 | if [ ! -f $BL31 ]; then |
| 14 | echo "ERROR: BL31 file $BL31 NOT found" >&2 |
| 15 | exit 0 |
| 16 | else |
| 17 | echo "$BL31 size: " >&2 |
| 18 | ls -lct $BL31 | awk '{print $5}' >&2 |
| 19 | fi |
| 20 | |
| 21 | BL32="tee.bin" |
| 22 | |
| 23 | if [ ! -f $BL32 ]; then |
| 24 | BL32=/dev/null |
| 25 | else |
| 26 | echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2 |
| 27 | echo "$BL32 size: " >&2 |
| 28 | ls -lct $BL32 | awk '{print $5}' >&2 |
| 29 | fi |
| 30 | |
| 31 | BL33="u-boot-nodtb.bin" |
| 32 | |
| 33 | if [ ! -f $BL33 ]; then |
| 34 | echo "ERROR: $BL33 file NOT found" >&2 |
| 35 | exit 0 |
| 36 | else |
| 37 | echo "u-boot-nodtb.bin size: " >&2 |
| 38 | ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2 |
| 39 | fi |
| 40 | |
| 41 | for dtname in $* |
| 42 | do |
| 43 | echo "$dtname size: " >&2 |
| 44 | ls -lct $dtname | awk '{print $5}' >&2 |
| 45 | done |
| 46 | |
| 47 | |
| 48 | cat << __HEADER_EOF |
| 49 | /dts-v1/; |
| 50 | |
| 51 | / { |
| 52 | description = "Configuration to load ATF before U-Boot"; |
| 53 | |
| 54 | images { |
| 55 | uboot@1 { |
| 56 | description = "U-Boot (64-bit)"; |
| 57 | data = /incbin/("$BL33"); |
| 58 | type = "standalone"; |
| 59 | arch = "arm64"; |
| 60 | compression = "none"; |
| 61 | load = <0x40200000>; |
| 62 | }; |
| 63 | atf@1 { |
| 64 | description = "ARM Trusted Firmware"; |
| 65 | data = /incbin/("$BL31"); |
| 66 | type = "firmware"; |
| 67 | arch = "arm64"; |
| 68 | compression = "none"; |
| 69 | load = <$ATF_LOAD_ADDR>; |
| 70 | entry = <$ATF_LOAD_ADDR>; |
| 71 | }; |
| 72 | __HEADER_EOF |
| 73 | |
| 74 | if [ -f $BL32 ]; then |
| 75 | cat << __HEADER_EOF |
| 76 | tee@1 { |
| 77 | description = "TEE firmware"; |
| 78 | data = /incbin/("$BL32"); |
| 79 | type = "firmware"; |
| 80 | arch = "arm64"; |
| 81 | compression = "none"; |
| 82 | load = <$TEE_LOAD_ADDR>; |
| 83 | entry = <$TEE_LOAD_ADDR>; |
| 84 | }; |
| 85 | __HEADER_EOF |
| 86 | fi |
| 87 | |
| 88 | cnt=1 |
| 89 | for dtname in $* |
| 90 | do |
| 91 | cat << __FDT_IMAGE_EOF |
| 92 | fdt@$cnt { |
| 93 | description = "$(basename $dtname .dtb)"; |
| 94 | data = /incbin/("$dtname"); |
| 95 | type = "flat_dt"; |
| 96 | compression = "none"; |
| 97 | }; |
| 98 | __FDT_IMAGE_EOF |
| 99 | cnt=$((cnt+1)) |
| 100 | done |
| 101 | |
| 102 | cat << __CONF_HEADER_EOF |
| 103 | }; |
| 104 | configurations { |
| 105 | default = "config@1"; |
| 106 | |
| 107 | __CONF_HEADER_EOF |
| 108 | |
| 109 | cnt=1 |
| 110 | for dtname in $* |
| 111 | do |
| 112 | if [ -f $BL32 ]; then |
| 113 | cat << __CONF_SECTION_EOF |
| 114 | config@$cnt { |
| 115 | description = "$(basename $dtname .dtb)"; |
| 116 | firmware = "uboot@1"; |
| 117 | loadables = "atf@1", "tee@1"; |
| 118 | fdt = "fdt@$cnt"; |
| 119 | }; |
| 120 | __CONF_SECTION_EOF |
| 121 | else |
| 122 | cat << __CONF_SECTION1_EOF |
| 123 | config@$cnt { |
| 124 | description = "$(basename $dtname .dtb)"; |
| 125 | firmware = "uboot@1"; |
| 126 | loadables = "atf@1"; |
| 127 | fdt = "fdt@$cnt"; |
| 128 | }; |
| 129 | __CONF_SECTION1_EOF |
| 130 | fi |
| 131 | cnt=$((cnt+1)) |
| 132 | done |
| 133 | |
| 134 | cat << __ITS_EOF |
| 135 | }; |
| 136 | }; |
| 137 | __ITS_EOF |