Add script to preprocess and compile .dts files from Linux source tree with commented decompiling

This commit is contained in:
a1batross 2023-03-20 18:08:05 +01:00
parent 2f42a4a426
commit 2b3bd5d6b2
1 changed files with 33 additions and 0 deletions

33
pdtc.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/bash
DEVICE=$1
if [ ! "$DEVICE" ]; then
echo "usage: $0 <device-name>"
exit 1
fi
SRC=$DEVICE.dts
TMP=$DEVICE.tmp.dts
DST=$DEVICE.dtb
DTC=dtc #../../../../scripts/dtc/dtc
LINUX_INCLUDE=../../../../../include # remove one ../ if you're working with arm tree
echo "-- Preprocess $SRC to $TMP"
cpp -nostdinc -I$LINUX_INCLUDE -undef -x assembler-with-cpp "$SRC" > "$TMP" || exit $?
echo "-- Compile $TMP"
$DTC -O dtb -b 0 -o "$DST" "$TMP" || exit $?
#echo "-- Decompile $DST to $IDE.decompiled.dts.tmp"
#$DTC -O dts -s -o "$IDE".decompiled.dts.tmp "$DST" || exit $?
#echo "-- Deleting phandles for easier diffs"
#grep -vE "\sphandle|\slinux,phandle" "$IDE".decompiled.dts.tmp > "$IDE".decompiled.dts || exit $?
#rm "$IDE".decompiled.dts.tmp
echo "-- Remove $TMP"
rm "$TMP"
exit 0