-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdts-build.sh
More file actions
executable file
·42 lines (30 loc) · 1003 Bytes
/
dts-build.sh
File metadata and controls
executable file
·42 lines (30 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
## reference
# https://gist.github.com/luaraneda/c12d5d111d6ccac00319d1948b2fc955
set -e
if [[ $# -lt 2 ]]; then
echo "Usage: $0 [cpp flags] [dts file]"
exit -1
fi
DTS_CPP_FLAGS="-nostdinc -Iinclude -undef -D__DTS__ -x assembler-with-cpp"
while [[ $# > 1 ]]; do
DTS_CPP_FLAGS="$DTS_CPP_FLAGS $1"
shift
done
shift $((OPTIND - 1))
DTS_FILE=$1
DTS_RAW_NAME=${DTS_FILE/%.dts}
echo "DTS_CPP_FLAGS = $DTS_CPP_FLAGS"
echo "DTS_FILE= $DTS_FILE"
echo "DTS_RAW_NAME = $DTS_RAW_NAME"
CLANG_BIN=$(which clang)
if [[ $? != 0 ]]; then
cpp -Wp,-MD,${DTS_RAW_NAME}.dts.dep.tmp ${DTS_CPP_FLAGS} -o ${DTS_RAW_NAME}.dts.tmp ${DTS_FILE}
else
clang -E -Wp,-MMD,{DTS_RAW_NAME}.dts.dep.tmp ${DTS_CPP_FLAGS} -o ${DTS_RAW_NAME}.dts.tmp ${DTS_FILE}
fi
dtc -O dtb -o ${DTS_RAW_NAME}.dtb -b 0 -d ${DTS_RAW_NAME}.dts.dep.tmp ${DTS_RAW_NAME}.dts.tmp
rm ${DTS_RAW_NAME}.dts.dep.tmp
rm ${DTS_RAW_NAME}.dts.tmp
echo "Get dtb at: ${DTS_RAW_NAME}.dtb"
# fdtdump ${DTS_RAW_NAME}.dtb