device-tree.bbappend 5.75 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 10
# include all
# MACHINE_DEVICETREE - in case something new is added
11
SRC_URI += "file://${MACHINE_DEVICETREE} \
12 13 14 15 16
            file://elphel393_4_mt9p006.dts \
            file://elphel393_4_mt9f002.dts \
            file://elphel393_4_lepton35.dts \
            file://elphel393_eyesis.dts \
            file://elphel393_eyesis_bottom2.dts \
17
            file://elphel393-zynq-base.dtsi \
18
            file://elphel393-common.dtsi \
19 20 21
            file://elphel393-bootargs-mmc.dtsi \
            file://elphel393-bootargs-nand.dtsi \
            file://elphel393-bootargs-ram.dtsi \
22 23
            file://elphel393-revision-rev0-B.dtsi \
            file://elphel393-revision-revC.dtsi \
24 25
            "

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
26
do_deploy(){
27

28 29 30 31 32 33 34
	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
35

36 37
		install -d ${DEPLOY_DIR_IMAGE}
		install -m 0644 ${B}/${DTS_NAME}_${RLOC}.dtb ${DEPLOY_DIR_IMAGE}/${DTS_NAME}_${RLOC}.dtb
38

39 40 41 42 43
		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}
44
		fi
45 46 47

		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
48 49 50
	done
}

51 52 53 54 55 56 57 58 59 60 61
python do_deploy(){

    import shutil

    B                        = d.getVar('B', True)
    DEPLOY_DIR_IMAGE         = d.getVar('DEPLOY_DIR_IMAGE', True)
    MACHINE_DEVICETREE       = d.getVar('MACHINE_DEVICETREE', True)
    PRODUCTION_DEVICETREE    = d.getVar('PRODUCTION_DEVICETREE', True)
    PRODUCTION_ROOT_LOCATION = d.getVar('PRODUCTION_ROOT_LOCATION', True)

    DTS_NAME = os.path.splitext(MACHINE_DEVICETREE)[0]
62 63 64 65 66 67
    BOARD_DEFAULT_REVISION = "revC"

    dtb_dir_path = os.path.join(DEPLOY_DIR_IMAGE,"dtb")
    os.makedirs(dtb_dir_path,exist_ok=True)
    for f in os.listdir(B):
        shutil.copyfile(os.path.join(B,f),os.path.join(dtb_dir_path,f))
68 69 70

    for RLOC in PRODUCTION_ROOT_LOCATION.split():

71 72 73 74 75 76 77 78 79 80 81 82 83
        if not DTS_NAME.startswith("elphel393_eyesis"):

            dtb_name = DTS_NAME+"_"+BOARD_DEFAULT_REVISION+"_"+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)
84

85
            os.makedirs(rloc_path,exist_ok=True)
86

87
            shutil.copyfile(dtb_build_path,dtb_deploy_path)
88

89
            print("Deployed "+dtb_deploy_path)
90

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
91 92
}

93 94 95 96 97
python do_compile(){

    WORKDIR                  = d.getVar('WORKDIR', True)
    PRODUCTION_ROOT_LOCATION = d.getVar('PRODUCTION_ROOT_LOCATION', True)
    DEVICETREE_FLAGS         = d.getVar('DEVICETREE_FLAGS', True)
98 99
    if DEVICETREE_FLAGS is None:
        DEVICETREE_FLAGS = ''
100 101 102 103 104 105 106 107 108 109 110 111 112 113

    for f in os.listdir(WORKDIR):
        if f.endswith(".dts"):

            DTS_NAME = os.path.splitext(f)[0]
            eyesis = False

            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)")

114 115
            f = os.path.join(WORKDIR,f)

116 117 118 119 120
            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")
121
                        os.system("dtc -I dts -O dtb "+str(DEVICETREE_FLAGS)+" -o "+DTS_NAME+"_"+REV+"_"+RLOC+".dtb "+f)
122 123
            else:
                for RLOC in PRODUCTION_ROOT_LOCATION.split():
124 125 126 127
                    print("running: ")
                    print("dtc -I dts -O dtb "+str(DEVICETREE_FLAGS)+" -o "+DTS_NAME+"_"+RLOC+".dtb "+f)
                    os.system("ln -sf "+WORKDIR+"/elphel393-bootargs-"+RLOC+".dtsi "+WORKDIR+"/elphel393-bootargs.dtsi")
                    os.system("dtc -I dts -O dtb "+str(DEVICETREE_FLAGS)+" -o "+DTS_NAME+"_"+RLOC+".dtb "+f)
128 129 130 131 132 133 134 135 136 137 138 139 140 141
}

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)
142 143 144 145 146 147 148 149
}

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

do_target_scp () {
    # mmc device tree only
150 151
    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
152
    ssh -i ${IDENTITY_FILE} ${REMOTE_USER}@${REMOTE_IP} sync
153 154 155 156 157
}

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)"