device-tree.bbappend 2.97 KB
Newer Older
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
1
# add dtsi's
2 3 4

FILESEXTRAPATHS_append := "${TOPDIR}/../../linux-elphel/src/arch/arm/boot/dts:"

5 6
MACHINE_DEVICETREE ?= "elphel393.dts"

7 8
COMPATIBLE_MACHINE_elphel393 = ".*"

9
SRC_URI += "file://${MACHINE_DEVICETREE} \
10 11 12 13 14 15
            file://elphel393-zynq-base.dtsi \
            file://elphel393-bootargs-mmc.dtsi \
            file://elphel393-bootargs-nand.dtsi \
            file://elphel393-bootargs-ram.dtsi \
            "

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
16
do_deploy(){
17

18 19 20 21 22 23 24
	DTS_NAME=`basename ${MACHINE_DEVICETREE} | awk -F "." '{print $1}'`
	echo "Copying ${DTS_NAME} device tree to production locations"
	for RLOC in ${PRODUCTION_ROOT_LOCATION}; do
		if [ ! -f ${B}/${DTS_NAME}_${RLOC}.dtb ]; then
			echo "Warning: ${B}/${DTS_NAME}_${RLOC}.dtb is not available!"
			continue
		fi
25

26 27
		install -d ${DEPLOY_DIR_IMAGE}
		install -m 0644 ${B}/${DTS_NAME}_${RLOC}.dtb ${DEPLOY_DIR_IMAGE}/${DTS_NAME}_${RLOC}.dtb
28

29 30 31 32 33
		if [ ! -d ${DEPLOY_DIR_IMAGE}/${RLOC} ]; then
			mkdir ${DEPLOY_DIR_IMAGE}/${RLOC}
		fi
		if [ -f ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_DEVICETREE} ]; then
			rm ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_DEVICETREE}
34
		fi
35 36 37

		cp ${DEPLOY_DIR_IMAGE}/${DTS_NAME}_${RLOC}.dtb ${DEPLOY_DIR_IMAGE}/${RLOC}/${PRODUCTION_DEVICETREE}
		echo "Installed to ${DEPLOY_DIR_IMAGE}/${RLOC}/"
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
	done
}

# full sub
do_compile() {
	if test -n "${MACHINE_DEVICETREE}"; then
		mkdir -p ${WORKDIR}/devicetree
		for i in ${MACHINE_DEVICETREE}; do
			if test -e ${WORKDIR}/$i; then
				echo cp ${WORKDIR}/$i ${WORKDIR}/devicetree
				cp ${WORKDIR}/$i ${WORKDIR}/devicetree
				cp ${WORKDIR}/*.dtsi ${WORKDIR}/devicetree
			fi
		done
	fi

54
	for DTS_FILE in ${S}/devicetree/*.dts; do
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
55 56
		DTS_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
		for RLOC in ${PRODUCTION_ROOT_LOCATION}; do
57
			ln -sf ${WORKDIR}/devicetree/elphel393-bootargs-${RLOC}.dtsi ${WORKDIR}/devicetree/elphel393-bootargs.dtsi
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
58 59 60 61 62 63 64
			dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}_${RLOC}.dtb ${DTS_FILE}
		done
	done
}

# full sub
do_install() {
65
	for DTS_FILE in ${S}/devicetree/*.dts; do
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
66 67
		DTS_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
		for RLOC in ${PRODUCTION_ROOT_LOCATION}; do
68
			if [ ! -f ${B}/${DTS_NAME}_${RLOC}.dtb ]; then
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
69 70 71 72 73 74
				echo "Warning: ${DTS_NAME}_${RLOC}.dtb is not available!"
				continue
			fi
			install -d ${D}/boot/devicetree
			install -m 0644 ${B}/${DTS_NAME}_${RLOC}.dtb ${D}/boot/devicetree/${DTS_NAME}_${RLOC}.dtb
		done
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
75
	done
76 77 78 79 80 81 82 83
}

REMOTE_USER ??= "root"
IDENTITY_FILE ??= "~/.ssh/id_rsa"
REMOTE_IP ??= "192.168.0.9"

do_target_scp () {
    # mmc device tree only
84 85
    echo "scp -i ${IDENTITY_FILE} -p ${DEPLOY_DIR_IMAGE}/mmc/devicetree.dtb ${REMOTE_USER}@${REMOTE_IP}:/mnt/mmc"
    scp -i ${IDENTITY_FILE} -p ${DEPLOY_DIR_IMAGE}/mmc/devicetree.dtb ${REMOTE_USER}@${REMOTE_IP}:/mnt/mmc
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
86
    ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} sync
87 88 89 90 91
}

addtask do_target_scp after do_deploy

do_target_scp[doc] = "scp copied device tree to REMOTE_PATH on the target. REMOTE_USER and REMOTE_IP should be defined (ssh-copy-id -i KEY.pub TARGET_USER@TARGET_IP should be issued once)"