Last active
November 14, 2016 11:49
-
-
Save mkresin/014667863068871f50bc032d8e6fd095 to your computer and use it in GitHub Desktop.
compile either all device tree source files of a given target or for all targets: ~/compile_all_dts.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TARGET="*" | |
WITHPREPARE=1 | |
# compile a target and copy the directory build_dir/target-*/linux-*/linux-4.4.30/scripts/dtc/ | |
# to your LEDE base directory | |
DTC=./dtc/dtc | |
for i in "$@"; do | |
case $i in | |
--without-prepare) | |
WITHPREPARE=0 | |
shift | |
;; | |
*) | |
TARGET="${i}" | |
;; | |
esac | |
done | |
for MAKEFILE in target/linux/${TARGET}/Makefile | |
do | |
DTSDIR=$(find "$(dirname "${MAKEFILE}")" -type d -name dts) | |
[ -z "${DTSDIR}" ] && continue | |
TARGET=$(grep -m1 'BOARD:=' "${MAKEFILE}") | |
TARGET=${TARGET#BOARD:=} | |
SUBTARGETS=$(grep -m1 'SUBTARGETS:=' "${MAKEFILE}") | |
SUBTARGETS=(${SUBTARGETS#SUBTARGETS:=}) | |
SUBTARGET=${SUBTARGETS[0]} | |
TARGET_SUBTARGET="${TARGET}" | |
[ -n "${SUBTARGET}" ] && TARGET_SUBTARGET="${TARGET_SUBTARGET}_${SUBTARGET}" | |
echo "${TARGET}" | |
[ "${WITHPREPARE}" -eq 1 ] && { | |
echo "CONFIG_TARGET_${TARGET}=y" > .config | |
[ -n "${SUBTARGET}" ] && echo "CONFIG_TARGET_${TARGET_SUBTARGET}=y" >> .config | |
make defconfig > /dev/null | |
make target/linux/{clean,prepare} > /dev/null | |
} | |
ARCH=$(grep -m1 'ARCH:=' "${MAKEFILE}") | |
ARCH=${ARCH#ARCH:=} | |
[ -z "${ARCH}" ] && ARCH=${TARGET} | |
KERNELVER=$(grep -m1 'KERNEL_PATCHVER:=' "${MAKEFILE}") | |
KERNELVER=${KERNELVER#KERNEL_PATCHVER:=} | |
LINUXDIR=$(ls -d build_dir/target-*/linux-"${TARGET_SUBTARGET}"/linux-"${KERNELVER}"*) | |
for DTSFILE in ${DTSDIR}/*.dts | |
do | |
OUTPUTFILE=$(basename "${DTSFILE}") | |
OUTPUTFILE="${OUTPUTFILE%.*}" | |
cpp -nostdinc -x assembler-with-cpp -I"${LINUXDIR}/include" -I"${LINUXDIR}/arch/${ARCH}/boot/dts" -undef -D__DTS__ -o "${OUTPUTFILE}.dts" "${DTSFILE}" || continue | |
OUTPUT="$(${DTC} -O dtb -I dts "${OUTPUTFILE}.dts" -o "${OUTPUTFILE}.dtb" 2>&1)" | |
[ -n "${OUTPUT}" ] && { | |
echo "${DTSFILE}" | |
echo "${OUTPUT}" | |
} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment