Commit 53fc4818 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

optimized device trees generation for various sensors and 10393 revisions

parent a9b5e6c7
Loading
Loading
Loading
Loading
+82 −33
Original line number Original line Diff line number Diff line
@@ -6,11 +6,21 @@ MACHINE_DEVICETREE ?= "elphel393.dts"


COMPATIBLE_MACHINE_elphel393 = ".*"
COMPATIBLE_MACHINE_elphel393 = ".*"


# include all
# MACHINE_DEVICETREE - in case something new is added
SRC_URI += "file://${MACHINE_DEVICETREE} \
SRC_URI += "file://${MACHINE_DEVICETREE} \
            file://elphel393_4_mt9p006.dts \
            file://elphel393_4_mt9f002.dts \
            file://elphel393_4_lepton35.dts \
            file://elphel393_eyesis.dts \
            file://elphel393_eyesis_bottom2.dts \
            file://elphel393-zynq-base.dtsi \
            file://elphel393-zynq-base.dtsi \
            file://elphel393-common.dtsi \
            file://elphel393-bootargs-mmc.dtsi \
            file://elphel393-bootargs-mmc.dtsi \
            file://elphel393-bootargs-nand.dtsi \
            file://elphel393-bootargs-nand.dtsi \
            file://elphel393-bootargs-ram.dtsi \
            file://elphel393-bootargs-ram.dtsi \
            file://elphel393-revision-rev0-B.dtsi \
            file://elphel393-revision-revC.dtsi \
            "
            "


do_deploy(){
do_deploy(){
@@ -38,41 +48,80 @@ do_deploy(){
	done
	done
}
}


# full sub
python do_deploy(){
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


	for DTS_FILE in ${S}/devicetree/*.dts; do
    import shutil
		DTS_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`

		for RLOC in ${PRODUCTION_ROOT_LOCATION}; do
    B                        = d.getVar('B', True)
			ln -sf ${WORKDIR}/devicetree/elphel393-bootargs-${RLOC}.dtsi ${WORKDIR}/devicetree/elphel393-bootargs.dtsi
    DEPLOY_DIR_IMAGE         = d.getVar('DEPLOY_DIR_IMAGE', True)
			dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}_${RLOC}.dtb ${DTS_FILE}
    MACHINE_DEVICETREE       = d.getVar('MACHINE_DEVICETREE', True)
		done
    PRODUCTION_DEVICETREE    = d.getVar('PRODUCTION_DEVICETREE', True)
	done
    PRODUCTION_ROOT_LOCATION = d.getVar('PRODUCTION_ROOT_LOCATION', True)

    DTS_NAME = os.path.splitext(MACHINE_DEVICETREE)[0]

    for RLOC in PRODUCTION_ROOT_LOCATION.split():
        dtb_name = DTS_NAME+"_"+RLOC+".dtb"
        dtb_path        = os.path.join(B,dtb_name)
        dtb_build_path  = os.path.join(DEPLOY_DIR_IMAGE,dtb_name)
        rloc_path       = os.path.join(DEPLOY_DIR_IMAGE,RLOC)
        dtb_deploy_path = os.path.join(rloc_path,PRODUCTION_DEVICETREE)

        if not os.path.exists(dtb_path):
            print("Warning: "+dtb_path+" is not available")

        os.system("install -d "+DEPLOY_DIR_IMAGE)
        os.system("install -m 0644 "+dtb_path+" "+dtb_build_path)

        os.makedirs(rloc_path,exist_ok=True);

        shutil.copyfile(dtb_build_path,dtb_deploy_path)

        print("Deployed "+dtb_deploy_path)
}
}


# full sub
python do_compile(){
do_install() {

	for DTS_FILE in ${S}/devicetree/*.dts; do
    WORKDIR                  = d.getVar('WORKDIR', True)
		DTS_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'`
    PRODUCTION_ROOT_LOCATION = d.getVar('PRODUCTION_ROOT_LOCATION', True)
		for RLOC in ${PRODUCTION_ROOT_LOCATION}; do
    DEVICETREE_FLAGS         = d.getVar('DEVICETREE_FLAGS', True)
			if [ ! -f ${B}/${DTS_NAME}_${RLOC}.dtb ]; then

				echo "Warning: ${DTS_NAME}_${RLOC}.dtb is not available!"
    for f in os.listdir(WORKDIR):
				continue
        if f.endswith(".dts"):
			fi

			install -d ${D}/boot/devicetree
            DTS_NAME = os.path.splitext(f)[0]
			install -m 0644 ${B}/${DTS_NAME}_${RLOC}.dtb ${D}/boot/devicetree/${DTS_NAME}_${RLOC}.dtb
            eyesis = False
		done

	done
            print("Found dts file: "+f)
            if f.startswith("elphel393_eyesis"):
                print("Device tree type: Eyesis4Pi 393 (panoramic camera)")
                eyesis = True
            else:
                print("Device tree type: 10393 (regular)")

            if not eyesis:
                for RLOC in PRODUCTION_ROOT_LOCATION.split():
                    os.system("ln -sf "+WORKDIR+"/elphel393-bootargs-"+RLOC+".dtsi "+WORKDIR+"/elphel393-bootargs.dtsi")
                    for REV in ["rev0-B","revC"]:
                        os.system("ln -sf "+WORKDIR+"/elphel393-revision-"+REV+".dtsi "+WORKDIR+"/elphel393-revision.dtsi")
                        os.system("dtc -I dts -O dtb "+DEVICETREE_FLAGS+" -o "+DTS_NAME+"_"+REV+"_"+RLOC+".dtb "+f)
            else:
                for RLOC in PRODUCTION_ROOT_LOCATION.split():
                    os.system("dtc -I dts -O dtb "+DEVICETREE_FLAGS+" -o "+DTS_NAME+"_"+RLOC+".dtb "+f)
}

python do_install(){

    B = d.getVar('B', True)
    D = d.getVar('D', True)

    os.system("install -d "+D+"/boot/devicetree")

    for f in os.listdir(B):
        if not f.startswith("elphel393_eyesis"):
            src = B+"/"+f
            dst = D+"/boot/devicetree/"+f
            os.system("install -m 0644 "+src+" "+dst)
}
}


REMOTE_USER ??= "root"
REMOTE_USER ??= "root"