xref: /freebsd/sys/tools/fdt/make_dtb.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1#!/bin/sh
2#
3
4# Script generates dtb file ($3) from dts source ($2) in build tree S ($1)
5S=$1
6dts="$2"
7dtb_path=$3
8
9if [ -z "$dts" ]; then
10    echo "No DTS specified"
11    exit 1
12fi
13
14if [ -z "${MACHINE}" ]; then
15    MACHINE=$(uname -m)
16fi
17
18: "${DTC:=dtc}"
19: "${ECHO:=echo}"
20: "${CPP:=cpp}"
21
22for d in ${dts}; do
23    dtb="${dtb_path}/$(basename "$d" .dts).dtb"
24    ${CPP} -P -x assembler-with-cpp -I "$S/dts/include" -I "$S/contrib/device-tree/include" -I "$S/dts/${MACHINE}" -I "$S/contrib/device-tree/src/${MACHINE}" -I "$S/contrib/device-tree/src/" -include "$d" -include "$S/dts/freebsd-compatible.dts" /dev/null |
25	${DTC} -@ -O dtb -o "$dtb" -b 0 -p 1024 -i "$S/dts/${MACHINE}" -i "$S/contrib/device-tree/src/${MACHINE}" -i "$S/contrib/device-tree/src/"
26done
27