Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # script to generate FIT image source for 64-bit sunxi boards with |
| 4 | # ARM Trusted Firmware and multiple device trees (given on the command line) |
| 5 | # |
| 6 | # usage: $0 <dt_name> [<dt_name> [<dt_name] ...] |
| 7 | |
| 8 | [ -z "$BL31" ] && BL31="bl31.bin" |
| 9 | |
Tom Rini | 4c78028 | 2017-05-22 15:40:11 -0400 | [diff] [blame] | 10 | if [ ! -f $BL31 ]; then |
| 11 | echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2 |
| 12 | echo "Please read the section on ARM Trusted Firmware (ATF) in board/sunxi/README.sunxi64" >&2 |
| 13 | BL31=/dev/null |
| 14 | fi |
| 15 | |
Icenowy Zheng | 0a21fdd | 2018-07-21 16:20:23 +0800 | [diff] [blame] | 16 | if grep -q "^CONFIG_MACH_SUN50I_H6=y" .config; then |
| 17 | BL31_ADDR=0x104000 |
| 18 | else |
| 19 | BL31_ADDR=0x44000 |
| 20 | fi |
| 21 | |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 22 | cat << __HEADER_EOF |
| 23 | /dts-v1/; |
| 24 | |
| 25 | / { |
| 26 | description = "Configuration to load ATF before U-Boot"; |
| 27 | #address-cells = <1>; |
| 28 | |
| 29 | images { |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 30 | uboot { |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 31 | description = "U-Boot (64-bit)"; |
| 32 | data = /incbin/("u-boot-nodtb.bin"); |
| 33 | type = "standalone"; |
| 34 | arch = "arm64"; |
| 35 | compression = "none"; |
| 36 | load = <0x4a000000>; |
| 37 | }; |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 38 | atf { |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 39 | description = "ARM Trusted Firmware"; |
| 40 | data = /incbin/("$BL31"); |
| 41 | type = "firmware"; |
| 42 | arch = "arm64"; |
| 43 | compression = "none"; |
Icenowy Zheng | 0a21fdd | 2018-07-21 16:20:23 +0800 | [diff] [blame] | 44 | load = <$BL31_ADDR>; |
| 45 | entry = <$BL31_ADDR>; |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 46 | }; |
| 47 | __HEADER_EOF |
| 48 | |
| 49 | cnt=1 |
| 50 | for dtname in $* |
| 51 | do |
| 52 | cat << __FDT_IMAGE_EOF |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 53 | fdt_$cnt { |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 54 | description = "$(basename $dtname .dtb)"; |
| 55 | data = /incbin/("$dtname"); |
| 56 | type = "flat_dt"; |
| 57 | compression = "none"; |
| 58 | }; |
| 59 | __FDT_IMAGE_EOF |
| 60 | cnt=$((cnt+1)) |
| 61 | done |
| 62 | |
| 63 | cat << __CONF_HEADER_EOF |
| 64 | }; |
| 65 | configurations { |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 66 | default = "config_1"; |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 67 | |
| 68 | __CONF_HEADER_EOF |
| 69 | |
| 70 | cnt=1 |
| 71 | for dtname in $* |
| 72 | do |
| 73 | cat << __CONF_SECTION_EOF |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 74 | config_$cnt { |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 75 | description = "$(basename $dtname .dtb)"; |
Andre Przywara | 8837af1 | 2017-12-04 02:05:11 +0000 | [diff] [blame] | 76 | firmware = "uboot"; |
| 77 | loadables = "atf"; |
| 78 | fdt = "fdt_$cnt"; |
Andre Przywara | 2ef99d4 | 2017-04-26 01:32:46 +0100 | [diff] [blame] | 79 | }; |
| 80 | __CONF_SECTION_EOF |
| 81 | cnt=$((cnt+1)) |
| 82 | done |
| 83 | |
| 84 | cat << __ITS_EOF |
| 85 | }; |
| 86 | }; |
| 87 | __ITS_EOF |