xref: /freebsd/sys/tools/fdt/make_dtb.sh (revision bc7512cc58af2e8bbe5bbf5ca0059b1daa1da897)
1#!/bin/sh
2#
3# $FreeBSD$
4
5# Script generates dtb file ($3) from dts source ($2) in build tree S ($1)
6S=$1
7dts="$2"
8dtb_path=$3
9
10if [ -z "$dts" ]; then
11    echo "No DTS specified"
12    exit 1
13fi
14
15if [ -z "${MACHINE}" ]; then
16    MACHINE=$(uname -m)
17fi
18
19: "${DTC:=dtc}"
20: "${ECHO:=echo}"
21: "${CPP:=cpp}"
22
23for d in ${dts}; do
24    dtb="${dtb_path}/$(basename "$d" .dts).dtb"
25    ${ECHO} "converting $d -> $dtb"
26    ${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 |
27	${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/"
28done
29