device-tree.bbappend 5.8 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 = ".*"

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
9 10
# include all
# MACHINE_DEVICETREE - in case something new is added
11
SRC_URI += "file://${MACHINE_DEVICETREE} \
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
12 13 14
            file://elphel393_4_mt9p006.dts \
            file://elphel393_4_mt9f002.dts \
            file://elphel393_4_lepton35.dts \
Andrey Filippov's avatar
Andrey Filippov committed
15
            file://elphel393_4_boson640.dts \
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
16 17
            file://elphel393_eyesis.dts \
            file://elphel393_eyesis_bottom2.dts \
18
            file://elphel393-zynq-base.dtsi \
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
19
            file://elphel393-common.dtsi \
20 21 22
            file://elphel393-bootargs-mmc.dtsi \
            file://elphel393-bootargs-nand.dtsi \
            file://elphel393-bootargs-ram.dtsi \
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
23 24
            file://elphel393-revision-rev0-B.dtsi \
            file://elphel393-revision-revC.dtsi \
25 26
            "

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

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

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

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

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

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
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]
    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))

    for RLOC in PRODUCTION_ROOT_LOCATION.split():

        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)

            os.makedirs(rloc_path,exist_ok=True)

            shutil.copyfile(dtb_build_path,dtb_deploy_path)

            print("Deployed "+dtb_deploy_path)

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
92 93
}

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
94 95 96 97 98
python do_compile(){

    WORKDIR                  = d.getVar('WORKDIR', True)
    PRODUCTION_ROOT_LOCATION = d.getVar('PRODUCTION_ROOT_LOCATION', True)
    DEVICETREE_FLAGS         = d.getVar('DEVICETREE_FLAGS', True)
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
99 100
    if DEVICETREE_FLAGS is None:
        DEVICETREE_FLAGS = ''
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
101 102 103 104 105 106 107 108

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

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

            print("Found dts file: "+f)
Andrey Filippov's avatar
Andrey Filippov committed
109

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
110 111 112 113 114 115
            if f.startswith("elphel393_eyesis"):
                print("Device tree type: Eyesis4Pi 393 (panoramic camera)")
                eyesis = True
            else:
                print("Device tree type: 10393 (regular)")

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
116 117
            f = os.path.join(WORKDIR,f)

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

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

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

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

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