[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-mediatek-mt2731/classes/md-fitimage.bbclass b/meta/meta-mediatek-mt2731/classes/md-fitimage.bbclass
new file mode 100644
index 0000000..2ed7191
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/classes/md-fitimage.bbclass
@@ -0,0 +1,148 @@
+inherit hsm-sign-env
+
+python __anonymous () {
+ depends = d.getVar("DEPENDS", True)
+ depends = "%s u-boot-mkimage-native lz4-native" % depends
+ d.setVar("DEPENDS", depends)
+}
+
+#
+# Emit the fitImage ITS header
+#
+fitimage_emit_fit_header() {
+ cat << EOF >> ${WORKDIR}/fit-image.its
+/dts-v1/;
+
+/ {
+ description = "MD fitImage";
+ #address-cells = <1>;
+EOF
+}
+
+#
+# Emit the fitImage section bits
+#
+# $1 ... Section bit type: imagestart - image section start
+# confstart - configuration section start
+# sectend - section end
+# fitend - fitimage end
+#
+fitimage_emit_section_maint() {
+ case $1 in
+ imagestart)
+ cat << EOF >> ${WORKDIR}/fit-image.its
+
+ images {
+EOF
+ ;;
+ confstart)
+ cat << EOF >> ${WORKDIR}/fit-image.its
+
+ configurations {
+EOF
+ ;;
+ sectend)
+ cat << EOF >> ${WORKDIR}/fit-image.its
+ };
+EOF
+ ;;
+ fitend)
+ cat << EOF >> ${WORKDIR}/fit-image.its
+};
+EOF
+ ;;
+ esac
+}
+
+fitimage_emit_section_md() {
+
+ if [ -n "${IMAGE_HASH_ALGO}" ] ; then
+ md_csum="${IMAGE_HASH_ALGO}"
+ else
+ md_csum="sha256"
+ fi
+
+ cat << EOF >> ${WORKDIR}/fit-image.its
+ md1img@1 {
+ description = "LK based MD Image";
+ data = /incbin/("${1}");
+ type = "kernel";
+ arch = "arm";
+ os = "linux";
+ compression = "none";
+ load = <${MD_LOADADDRESS}>;
+ entry = <${MD_ENTRYPOINT}>;
+ hash@1 {
+ algo = "${md_csum}";
+ };
+ };
+EOF
+}
+
+#
+# Emit the fitImage ITS configuration section
+#
+fitimage_emit_section_config_md() {
+
+ if [ -n "${VB_HASH_ALGO}" ] && [ -n "${VB_RSA_ALGO}" ] ; then
+ conf_csum="${VB_HASH_ALGO},${VB_RSA_ALGO}"
+ else
+ conf_csum="sha256,rsa2048"
+ fi
+ conf_key_name="dev"
+
+ conf_desc="${MTK_PROJECT} configuration"
+
+ cat << EOF >> ${WORKDIR}/fit-image.its
+ default = "conf@1";
+ conf@1 {
+ description = "${conf_desc}";
+ kernel = "md1img@1";
+ signature@1 {
+ algo = "${conf_csum}";
+ key-name-hint="${conf_key_name}";
+ sign-images = "kernel";
+ };
+ };
+EOF
+}
+
+do_assemble_mdfitimage() {
+
+ rm -f ${WORKDIR}/fit-image.its
+
+ fitimage_emit_fit_header
+
+ #
+ # Step 1: Prepare a md image section.
+ #
+ fitimage_emit_section_maint imagestart
+
+
+ fitimage_emit_section_md ${WORKDIR}/md1img-org.img
+
+ fitimage_emit_section_maint sectend
+
+ #
+ # Step 2: Prepare a configurations section
+ #
+ fitimage_emit_section_maint confstart
+
+ fitimage_emit_section_config_md
+
+ fitimage_emit_section_maint sectend
+
+ fitimage_emit_section_maint fitend
+
+ #
+ # Step 3: Assemble the image
+ #
+ ${HSM_ENV} HSM_KEY_NAME=${VERIFIED_KEY} uboot-mkimage -f ${WORKDIR}/fit-image.its ${WORKDIR}/${MD_IMAGE}
+
+ if [ "${SECURE_BOOT_ENABLE}" = "yes" ]; then
+ mkdir -p ./mykeys
+ cp ${MTK_KEY_DIR}/${VERIFIED_KEY}.crt ./mykeys/dev.crt
+ cp ${MTK_KEY_DIR}/${VERIFIED_KEY}.pem ./mykeys/dev.key
+ ${HSM_ENV} HSM_KEY_NAME=${VERIFIED_KEY} uboot-mkimage -D "-I dts -O dtb -p 1024" -k ./mykeys -f ${WORKDIR}/fit-image.its -r ${WORKDIR}/${MD_IMAGE}
+ fi
+}
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/classes/mkuserdataimg.bbclass b/meta/meta-mediatek-mt2731/classes/mkuserdataimg.bbclass
new file mode 100644
index 0000000..446d4ca
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/classes/mkuserdataimg.bbclass
@@ -0,0 +1,68 @@
+STATE_DIR_IMAGE_SIZE ?= "131072"
+STATE_DIR_IMAGE_PATH = "${DEPLOY_DIR_IMAGE}/state"
+STATE_DIR_CONTENT ?= "${IMAGE_ROOTFS}/home ${IMAGE_ROOTFS}/var ${IMAGE_ROOTFS}/usr/lib/tmpfiles.d ${STATE_DIR_IMAGE_PATH}/usr/local ${STATE_DIR_IMAGE_PATH}/srv"
+IMAGE_FSTYPES_NO_WHITESPACE="$(echo "${IMAGE_FSTYPES}" | tr -d '[:space:]')"
+DEPENDS += "mtd-utils-native"
+
+mk_state_image() {
+ rm -rf ${STATE_DIR_IMAGE_PATH}
+ install -d ${STATE_DIR_CONTENT}
+ for i in ${STATE_DIR_CONTENT}; do
+ STATE_DIR_FILE_PATH=${STATE_DIR_IMAGE_PATH}/${i##${IMAGE_ROOTFS}}
+ install -d ${STATE_DIR_FILE_PATH}
+ cp -a ${i}/. ${STATE_DIR_FILE_PATH}
+ done
+
+ # remove package management data
+ if [ -d "${STATE_DIR_IMAGE_PATH}/var/lib/dnf" ]; then
+ rm -rf ${STATE_DIR_IMAGE_PATH}/var/lib/dnf
+ fi
+ if [ -d "${STATE_DIR_IMAGE_PATH}/var/lib/rpm" ]; then
+ rm -rf ${STATE_DIR_IMAGE_PATH}/var/lib/rpm
+ fi
+
+ if test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "ubi" || test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "squashfs"; then
+ STATE_PARTITION="userdata.ubifs"
+ STATE_UBI="userdata.ubi"
+ STATE_UBINIZE_CFG="ubinize-state.cfg"
+ dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} seek=${STATE_DIR_IMAGE_SIZE} count=0 bs=1k
+ cat << EOF > ${STATE_UBINIZE_CFG}
+[ubifs]
+mode=ubi
+image=${DEPLOY_DIR_IMAGE}/${STATE_PARTITION}
+vol_id=0
+vol_type=dynamic
+vol_name=state
+vol_flags=autoresize
+EOF
+ mkfs.ubifs -r ${STATE_DIR_IMAGE_PATH} -o ${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} ${MKUBIFS_ARGS}
+ ubinize -o ${DEPLOY_DIR_IMAGE}/${STATE_UBI} ${UBINIZE_ARGS} ${STATE_UBINIZE_CFG}
+ elif test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "ext4"; then
+ STATE_PARTITION="userdata.ext4"
+ dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} seek=${STATE_DIR_IMAGE_SIZE} count=0 bs=1k
+ mkfs.ext4 -F -i 4096 ${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} -d ${STATE_DIR_IMAGE_PATH}
+ else
+ echo "No method to make ${IMAGE_FSTYPES_NO_WHITESPACE} type state image"
+ fi
+}
+
+ROOTFS_POSTPROCESS_COMMAND += " mk_state_image;"
+
+mk_rootfs_folder() {
+ install -d ${IMAGE_ROOTFS}/mnt/userdata ${IMAGE_ROOTFS}/srv
+ if test "${DISTRO}" != "poky-agl"; then
+ install -d ${IMAGE_ROOTFS}/usr/local
+ fi
+}
+
+ROOTFS_PREPROCESS_COMMAND += " mk_rootfs_folder;"
+
+do_sparse_userdata_image() {
+if test -e ${DEPLOY_DIR_IMAGE}/userdata.ubi ; then
+ img2simg ${DEPLOY_DIR_IMAGE}/userdata.ubi ${DEPLOY_DIR_IMAGE}/userdata.img
+elif test -e ${DEPLOY_DIR_IMAGE}/userdata.ext4 ; then
+ img2simg ${DEPLOY_DIR_IMAGE}/userdata.ext4 ${DEPLOY_DIR_IMAGE}/userdata.img
+fi
+}
+
+do_image_complete[postfuncs] += "do_sparse_userdata_image"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/bblayers.conf.sample
new file mode 100644
index 0000000..85a6bd7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/bblayers.conf.sample
@@ -0,0 +1,27 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/local.conf.sample
new file mode 100644
index 0000000..3a2e48f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main-user/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-main-user"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/bblayers.conf.sample
new file mode 100644
index 0000000..85a6bd7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/bblayers.conf.sample
@@ -0,0 +1,27 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/local.conf.sample
new file mode 100644
index 0000000..1b8346b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-main/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-main"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/bblayers.conf.sample
new file mode 100644
index 0000000..b554f6a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/bblayers.conf.sample
@@ -0,0 +1,28 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-clang \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/local.conf.sample
new file mode 100644
index 0000000..a597af0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-test/local.conf.sample
@@ -0,0 +1,26 @@
+MACHINE ??= "auto2731evb-ivt-test"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+IMAGE_INSTALL_append = "valgrind"
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/bblayers.conf.sample
new file mode 100644
index 0000000..6ac99d3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/bblayers.conf.sample
@@ -0,0 +1,32 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
+
+METADIR := "${@os.path.abspath('##OEROOT##/..')}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-anwbt' if os.path.exists('${METADIR}/meta-mediatek-anwbt') else ''}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-trustonic' if os.path.exists('${METADIR}/meta-mediatek-trustonic') else ''}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-adr' if os.path.exists('${METADIR}/meta-mediatek-adr') else ''}"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/local.conf.sample
new file mode 100644
index 0000000..8c60a8f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp1/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-vp1"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+HOSTTOOLS += "java"
+VOLATILE_LOG_DIR = "no"
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/bblayers.conf.sample
new file mode 100644
index 0000000..6ac99d3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/bblayers.conf.sample
@@ -0,0 +1,32 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
+
+METADIR := "${@os.path.abspath('##OEROOT##/..')}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-anwbt' if os.path.exists('${METADIR}/meta-mediatek-anwbt') else ''}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-trustonic' if os.path.exists('${METADIR}/meta-mediatek-trustonic') else ''}"
+BBLAYERS += "${@'${METADIR}/meta-mediatek-adr' if os.path.exists('${METADIR}/meta-mediatek-adr') else ''}"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/local.conf.sample
new file mode 100644
index 0000000..0a8f65d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp2/local.conf.sample
@@ -0,0 +1,29 @@
+MACHINE ??= "auto2731evb-ivt-vp2"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+HOSTTOOLS += "java"
+VOLATILE_LOG_DIR = "no"
+TRUSTONIC_DIR ?= "${TOPDIR}/../src/bsp/trustzone/trustonic/mt2731"
+TRUSTONIC_ENABLE ?= "${@int(os.path.isdir('${TRUSTONIC_DIR}') == True)}"
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/bblayers.conf.sample
new file mode 100644
index 0000000..85a6bd7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/bblayers.conf.sample
@@ -0,0 +1,27 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/local.conf.sample
new file mode 100644
index 0000000..4f80e72
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3-user/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-vp3-user"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/bblayers.conf.sample
new file mode 100644
index 0000000..85a6bd7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/bblayers.conf.sample
@@ -0,0 +1,27 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/local.conf.sample
new file mode 100644
index 0000000..8e3d818
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp3/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-vp3"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/bblayers.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/bblayers.conf.sample
new file mode 100644
index 0000000..85a6bd7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/bblayers.conf.sample
@@ -0,0 +1,27 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "6"
+
+BBPATH = "${TOPDIR}"
+BBFILES ?= ""
+
+BBLAYERS ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ ##OEROOT##/meta-yocto-bsp \
+ ##OEROOT##/../meta-gplv2 \
+ ##OEROOT##/../meta-openembedded/meta-filesystems \
+ ##OEROOT##/../meta-openembedded/meta-oe \
+ ##OEROOT##/../meta-openembedded/meta-python \
+ ##OEROOT##/../meta-openembedded/meta-networking \
+ ##OEROOT##/../meta-openembedded/meta-multimedia \
+ ##OEROOT##/../meta-mediatek \
+ ##OEROOT##/../meta-mediatek-gpl \
+ ##OEROOT##/../meta-mediatek-ivt \
+ ##OEROOT##/../meta-mediatek-mt2731 \
+ ##OEROOT##/../meta-mediatek-mt2731-gpl \
+ "
+BBLAYERS_NON_REMOVABLE ?= " \
+ ##OEROOT##/meta \
+ ##OEROOT##/meta-poky \
+ "
diff --git a/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/local.conf.sample b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/local.conf.sample
new file mode 100644
index 0000000..74146a7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/base/auto2731evb-ivt-vp4/local.conf.sample
@@ -0,0 +1,27 @@
+MACHINE ??= "auto2731evb-ivt-vp4"
+DISTRO ?= "poky-ivt-systemd"
+PACKAGE_CLASSES ?= "package_rpm"
+EXTRA_IMAGE_FEATURES = "debug-tweaks"
+USER_CLASSES ?= "buildstats image-mklibs image-prelink"
+PATCHRESOLVE = "noop"
+SSTATE_DIR ?= "${TOPDIR}/../sstate-cache"
+BB_DISKMON_DIRS = "\
+ STOPTASKS,${TMPDIR},1G,100K \
+ STOPTASKS,${DL_DIR},1G,100K \
+ STOPTASKS,${SSTATE_DIR},1G,100K \
+ ABORT,${TMPDIR},100M,1K \
+ ABORT,${DL_DIR},100M,1K \
+ ABORT,${SSTATE_DIR},100M,1K"
+CONF_VERSION = "1"
+DL_DIR ?= "${TOPDIR}/../downloads"
+INHERIT += "buildhistory"
+BUILDHISTORY_COMMIT = "1"
+INCOMPATIBLE_LICENSE ?= "GPL-3.0 LGPL-3.0 AGPL-3.0"
+CONNECTIVITY_CHECK_URIS = ""
+VOLATILE_LOG_DIR = "no"
+
+LICENSE_FLAGS_WHITELIST = "\
+ commercial_faac \
+ commercial_faad2"
+
+BBMASK += "meta-mediatek/recipes-devtools/clang"
diff --git a/meta/meta-mediatek-mt2731/conf/layer.conf b/meta/meta-mediatek-mt2731/conf/layer.conf
new file mode 100644
index 0000000..23d39e1
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/layer.conf
@@ -0,0 +1,14 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes-* directories, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+ ${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "mediatek-mt2731"
+BBFILE_PATTERN_mediatek-mt2731 = "^${LAYERDIR}/"
+BBFILE_PRIORITY_mediatek-mt2731 = "10"
+LICENSE_PATH += "${LAYERDIR}/files/additional-licenses"
+
+#add hosttools for make ota package
+HOSTTOOLS += "zip unzip"
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main-user.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main-user.conf
new file mode 100644
index 0000000..3259349
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main-user.conf
@@ -0,0 +1,191 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+#LYNQ
+LYNQ_SW_VERSION = "T102v01.MP2_MR1.01b01"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-main-user"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+# lynq
+YK_SRC = "${TOPDIR}/../src/lynq"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "no"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+VERIFIED_KEY = "verified_key"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# AB update
+AB_OTA_UPDATER = "yes"
+AB_OTA_PARTITIONS = "boot system"
+# LK
+LK_PROJECT = "auto2731evb-ivt-mcp_nand_ab"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBDA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-mcp_nand-bl33_ab"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand"
+
+# Image FS
+IMAGE_FSTYPES ?= "squashfs"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 2048 -e 126976 -c 1400 -F"
+UBINIZE_ARGS = "-m 2048 -p 128KiB -O 2048"
+
+MKUBIFS_CONFIG_ARGS = "-m 2048 -e 126976 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP2"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main.conf
new file mode 100644
index 0000000..bf2353a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-main.conf
@@ -0,0 +1,196 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+#LYNQ
+LYNQ_SW_VERSION = "T103CM2v01.MP2_MR2.01b03"
+SMS_INDEX = "0"
+SMS_FLAG = "0"
+# lynq
+YK_SRC = "${TOPDIR}/../src/lynq"
+# Project
+MTK_PROJECT = "mt2731evb-ivt-main"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "C/Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "yes"
+SECURE_BOOT_TYPE = "avb"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+#VERIFIED_KEY = "verified_key"
+VB_HASH_ALGO = "sha256"
+VB_RSA_ALGO = "rsa2048"
+VERIFIED_KEY = "verified_${VB_RSA_ALGO}_key"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# AB update
+AB_OTA_UPDATER = "yes"
+AB_OTA_PARTITIONS = "boot system bl2 bl33 md1img tee vbmeta"
+# LK
+LK_PROJECT = "auto2731evb-ivt-mcp_nand"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBDA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-mcp_nand-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand"
+
+# Image FS
+IMAGE_FSTYPES ?= "squashfs"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone scatter spmfw flashtool mdcert"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 2048 -e 126976 -c 1400 -F"
+UBINIZE_ARGS = "-m 2048 -p 128KiB -O 2048"
+
+MKUBIFS_CONFIG_ARGS = "-m 2048 -e 126976 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP2"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+#MTK_USB_OR_PCIE = "PCIe"
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-test.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-test.conf
new file mode 100644
index 0000000..cf8a8bd
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-test.conf
@@ -0,0 +1,184 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-test"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "C/Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "no"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_ALGO = "rsa"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+
+SBC_RSA_ALGO = "rsa2048"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+
+SBC_ECC_ALGO = "nistp521"
+SBC_KEY_ECC256 = "p256"
+SBC_KEY_ECC384 = "p384"
+SBC_KEY_ECC521 = "p521"
+
+VERIFIED_KEY = "verified_key"
+MTEE_KEY = "mtee_key"
+
+TKC_SUPPORT = ""
+TKC_PUBLIC_KEY_TIER = "ecc_p521_tier_public"
+TKC_PUBLIC_KEY_OEM = "p521_public"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-emmc"
+BOOTDEV_TYPE = "emmc"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=2 -Os"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-emmc-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.2"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_emmc"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-emmc_512MB.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-emmc_512MB.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731evb1-ivt-emmc_ab"
+
+STATE_DIR_IMAGE_SIZE = "1048576"
+
+# Image FS
+IMAGE_FSTYPES ?= "ext4"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP4X"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp1.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp1.conf
new file mode 100644
index 0000000..9e84fe5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp1.conf
@@ -0,0 +1,223 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-vp1"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "Lf/Lt/W/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+# secure boot
+SECURE_BOOT_ENABLE = "yes"
+# blank or not setting means fitboot
+SECURE_BOOT_TYPE = "avb"
+# only for AVB, enable antirollback feature and set firmware version
+#AVB_ENABLE_ANTIROLLBACK = "yes"
+#AVB_ANTIROLLBACK_VERSION = "0"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_ALGO = "rsa"
+# possible value for 2712 E2 brom sbc RSA algo: {rsa|rsassa-pss}{2048|3072|4096}
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+# verify boot algo, for both fit and avb verify
+VB_HASH_ALGO="sha256"
+VB_RSA_ALGO="rsa2048"
+VERIFIED_KEY = "verified_${VB_RSA_ALGO}_key"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "${@'yes' if os.path.exists('${DEPLOY_DIR}/images/${MACHINE}/md1img.img') else 'no'}"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# AB update
+AB_OTA_UPDATER = "yes"
+AB_OTA_PARTITIONS = "boot system vbmeta md1img tee"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-vp3"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBFA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-vp3-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "mt2731-common-optee"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+
+# Trustonic
+TRUSTONIC_AVAILABLE = "${@1 if os.path.exists('${TOPDIR}/../src/bsp/trustzone/trustonic/mt2731') else 0}"
+TBASE_VER = "410a"
+PREFERRED_VERSION_tee-tbase = "410"
+TBASE_RELEASE_VER = "t-base-MTK-ARMv8-Linux-410a-V001"
+
+# OP-TEE
+TEE_TEST_SUPPORT = "optee"
+TEE_ARCH= "${KERNEL_ARCH}"
+TRUSTEDOS_SIZE = "0x900000"
+TRUSTEDOS_SHMEM_SIZE = "0x100000"
+# tee common
+TEE_INSTALL_MODE = "Release"
+
+#default setting, will be overite by project conf.
+TEE_SUPPORT = "optee"
+TRUSTEDOS_ENTRYPOINT = "${@bb.utils.contains('TEE_SUPPORT', 'none', '', '0x43040000', d)}"
+TRUSTEDOS_LOADADDRESS = "${@bb.utils.contains('TEE_SUPPORT', 'none', '', '0x43040000', d)}"
+
+
+# HSM OS
+HSM_OS_SUPPORT = "yes"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand_trustonic_ab.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand_trustonic_ab.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand_lp4"
+
+# Image FS
+IMAGE_FSTYPES ?= "squashfs"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert hsm"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 4096 -e 253952 -c 1400 -F"
+UBINIZE_ARGS = "-m 4096 -p 256KiB -O 4096"
+
+MKUBIFS_CONFIG_ARGS = "-m 4096 -e 253952 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP4X"
+
+#anw soft
+ANW_SUPPORT ?= "${@'YES' if os.path.exists('${TOPDIR}/../prebuilt/connectivity/bluetooth/anwsoft/common') else 'NO'}"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+#adr
+ADR_SUPPORT ?= "${@'YES' if os.path.exists('${TOPDIR}/../meta/meta-mediatek-adr') else 'NO'}"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp2.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp2.conf
new file mode 100644
index 0000000..8e15ae0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp2.conf
@@ -0,0 +1,214 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-vp2"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+## secure boot
+SECURE_BOOT_ENABLE = "yes"
+# blank or not setting means fitboot
+SECURE_BOOT_TYPE = "avb"
+# only for AVB, enable antirollback feature and set firmware version
+#AVB_ENABLE_ANTIROLLBACK = "yes"
+#AVB_ANTIROLLBACK_VERSION = "0"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_ALGO = "rsa"
+# possible value for 2712 E2 brom sbc RSA algo: {rsa|rsassa-pss}{2048|3072|4096}
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+# verify boot algo, for both fit and avb verify
+VB_HASH_ALGO="sha256"
+VB_RSA_ALGO="rsa2048"
+
+AB_OTA_UPDATER = "yes"
+AB_OTA_PARTITIONS = "boot system md1img tee"
+BOARD_AVB_ENABLE = "true"
+
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+
+SBC_ECC_ALGO = "nistp521"
+SBC_KEY_ECC256 = "p256"
+SBC_KEY_ECC384 = "p384"
+SBC_KEY_ECC521 = "p521"
+
+VERIFIED_KEY = "verified_${VB_RSA_ALGO}_key"
+MTEE_KEY = "mtee_key"
+
+TKC_SUPPORT = ""
+TKC_PUBLIC_KEY_TIER = "ecc_p521_tier_public"
+TKC_PUBLIC_KEY_OEM = "p521_public"
+
+MD_VERIFY = "${@'yes' if os.path.exists('${DEPLOY_DIR}/images/${MACHINE}/md1img.img') else 'no'}"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-emmc"
+BOOTDEV_TYPE = "emmc"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=2 -Os"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-emmc-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', 'mt2731-common-tbase', '${MTK_PROJECT}', d)}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', 'tbase', 'none', d)}"
+TBASE_VER = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', '410a', '', d)}"
+PREFERRED_VERSION_tee-tbase = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', '410', '', d)}"
+TEE_INSTALL_MODE = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', 'Release', '', d)}"
+TRUSTEDOS_ENTRYPOINT = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', '0x43040000', '', d)}"
+TRUSTEDOS_LOADADDRESS = "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', '0x43040000', '', d)}"
+#KERNEL_CFG += "${@bb.utils.contains('TRUSTONIC_ENABLE', '1', 'trustonic.cfg', '', d)}"
+TBASE_RELEASE_VER = "t-base-MTK-ARMv8-Linux-410a-V001"
+
+# HSM OS
+HSM_OS_SUPPORT = "yes"
+
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_emmc"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-emmc_trustonic.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-emmc_trustonic.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731evb1-ivt-emmc"
+
+STATE_DIR_IMAGE_SIZE = "524288"
+
+# Image FS
+IMAGE_FSTYPES ?= "ext4"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert hsm"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP4X"
+
+#anw soft
+ANW_SUPPORT ?= "${@'YES' if os.path.exists('${TOPDIR}/../prebuilt/connectivity/bluetooth/anwsoft/common') else 'NO'}"
+
+#bluetooth
+BT_AUDIO_PCM_INTERFACE = "yes"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT3303"
+
+#adr
+ADR_SUPPORT ?= "${@'YES' if os.path.exists('${TOPDIR}/../meta/meta-mediatek-adr') else 'NO'}"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3-user.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3-user.conf
new file mode 100644
index 0000000..2b51d1d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3-user.conf
@@ -0,0 +1,181 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-vp3-user"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "C/Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "no"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+VERIFIED_KEY = "verified_key"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-vp3"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBFA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-vp3-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand_lp4"
+
+# Image FS
+IMAGE_FSTYPES ?= "ubi"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 4096 -e 253952 -c 1400 -F"
+UBINIZE_ARGS = "-m 4096 -p 256KiB -O 4096"
+
+MKUBIFS_CONFIG_ARGS = "-m 4096 -e 253952 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "user"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP4X"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3.conf
new file mode 100644
index 0000000..bab7124
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp3.conf
@@ -0,0 +1,187 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-vp3"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "C/Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "no"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+VERIFIED_KEY = "verified_key"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-vp3"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBFA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-vp3-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp4_nand.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand_lp4"
+
+# Image FS
+IMAGE_FSTYPES ?= "ubi"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 4096 -e 253952 -c 1400 -F"
+UBINIZE_ARGS = "-m 4096 -p 256KiB -O 4096"
+
+MKUBIFS_CONFIG_ARGS = "-m 4096 -e 253952 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP4X"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "USB"
+
+DEBUG_SUPPORT = "yes"
+
+#v2x
+V2X_SUPPORT ?= "${@'yes' if os.path.exists('${TOPDIR}/../prebuilt/connectivity/v2x') else 'no'}"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT6630"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
+
diff --git a/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp4.conf b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp4.conf
new file mode 100644
index 0000000..1da703c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/conf/machine/auto2731evb-ivt-vp4.conf
@@ -0,0 +1,183 @@
+#@TYPE: Machine
+#@NAME:MT2731
+#@DESCRIPTION: Machine configuration for mt2731 32bit
+
+DEFAULTTUNE ?= "cortexa7hf-neon-vfpv4"
+include ${TOPDIR}/../meta/meta-mediatek/conf/machine/arch-arm64-tune-cortexa7-multilib.inc
+
+#Customer Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/customer_feature_option.inc
+#Internal Feature Options
+include ${TOPDIR}/../meta/meta-mediatek-ivt/recipes-yummy/features/internal_feature_option.inc
+
+require conf/multilib.conf
+MULTILIBS = "multilib:lib64"
+DEFAULTTUNE_virtclass-multilib-lib64 = "aarch64"
+
+# Project
+MTK_PROJECT = "mt2731evb-ivt-main"
+TARGET_PLATFORM = "mt2731"
+PROJ = "mt6735_mifi"
+PRJ_FILENAME = "MT2731_IVT_DSDS"
+#LINUX_KERNEL = "linux-4.9.77"
+#KERNELDIR = "../kernel/linux/v4.9"
+LINUX_KERNEL = "linux-3.18.19"
+KERNELDIR = "../kernel/linux/v3.18"
+COMPLIST = "${LINUX_KERNEL}"
+EXTERNALSRC_SYMLINKS = ""
+INHERIT += "packagebbclassappend"
+
+# BACH
+BACH_SRC = "${TOPDIR}/../src/bach/build.bach/work"
+BACH_PREBUILT = "${TOPDIR}/../prebuilt/bach/build.bach/work"
+BACH_PREFIX = "${STAGING_INCDIR}/install"
+
+# Telephony
+TELEPHONY_SRC = "${TOPDIR}/../src/telephony"
+TELEPHONY_PREBUILT = "${TOPDIR}/../prebuilt/telephony"
+
+# Modem
+MODEM_SRC = "${TOPDIR}/../src/modem"
+MODEM_PREBUILT = "${TOPDIR}/../prebuilt/modem"
+
+# Telephony/Modem Feature Options
+# [S] ss / dsss / dsds; [N] dsda / tsts / qsqs
+MTK_MULTI_SIM_SUPPORT = "dsds"
+# [S] C/Lf/Lt/W/T/G, Lf/Lt/W/T/G, Lf/Lt/W/G; [N] Lf/Lt/T/G, W/T/G, W/G, T/G, G
+MTK_PROTOCOL1_RAT_CONFIG = "C/Lf/Lt/W/T/G"
+MTK_PROTOCOL2_RAT_CONFIG = "L/W/G"
+#MTK_PROTOCOL3_RAT_CONFIG = "G"
+# yes / no
+RAT_CONFIG_C2K_SUPPORT = "yes"
+SINGLE_BIN_MODEM_SUPPORT = "yes"
+
+# secure boot
+SECURE_BOOT_ENABLE ?= "no"
+MTK_KEY_DIR = "${TOPDIR}/../meta/meta-mediatek/conf/machine/keys"
+SBC_RSA_ALGO = "rsa2048"
+SBC_HASH_ALGO = "sha256"
+IMAGE_HASH_ALGO = "sha256"
+SBC_KEY = "sbc_key"
+SBC_KEY_RSA3072 = "sbc_key_3072"
+SBC_KEY_RSA4096 = "sbc_key_4096"
+VERIFIED_KEY = "verified_key"
+MTEE_KEY = "mtee_key"
+
+MD_VERIFY = "no"
+
+# Preloader
+PRELOADER_PROJECT = "${MTK_PROJECT}"
+
+# LK
+LK_PROJECT = "auto2731evb-ivt-mcp_nand"
+BOOTDEV_TYPE = "nand"
+TARGET_CFLAGS += "-DMTK_BOOTDEV_TYPE=1 -Os"
+NAND_TYPE = "mcp_nand"
+#nand name should be the same with the one in nand-utils/nand_device_list.txt
+NAND_CHIP_NAME = "MT29F4G08ABBDA"
+#nand brom header version:
+# 1.0 or null: header sytle from Tablet SOC, which is independent of PMBR
+# 2.0: header sytle from mt2712, which is designed for GPT, and is part of PMBR
+NAND_HEADER_VERSION = "3.0"
+FIT_LK_IMAGE = "yes"
+LK_LOAD_OFFSET = "0x1000"
+LK_LOADADDRESS = "0x201000"
+LK_ENTRYPOINT = "0x201000"
+LK_MAX_SIZE = "0x3c000"
+
+# BL33
+BL33_PROJECT = "auto2731evb-ivt-mcp_nand-bl33"
+BL33_LOAD_OFFSET = "0x0"
+BL33_LOADADDRESS = "0x42110000"
+BL33_ENTRYPOINT = "0x42110000"
+BL33_COMPRESS = "none"
+BL33_MAX_SIZE = "0xfd000"
+
+# SPMFW
+SPMFW_IMAGETYPE = "fitImage"
+SPMFW_LOADADDRESS = "0x42100000"
+SPMFW_ENTRYPOINT = "0x42100000"
+SPMFW_COMPRESS = "lz4"
+
+# Trustzone
+TZ_PROJECT = "${MTK_PROJECT}"
+TZ_PLATFORM = "${TARGET_PLATFORM}"
+ATF_SUPPORT = "yes"
+PREFERRED_VERSION_atf = "1.6"
+ATF_INSTALL_MODE = "debug"
+MTK_MACH_TYPE = "mt2731"
+TRUSTZONE_HEADER = "fit"
+TRUSTZONE_ENTRYPOINT = "0x43001000"
+TRUSTZONE_LOADADDRESS = "0x43001000"
+TRUSTZONE_COMPRESS = "none"
+TEE_SUPPORT = "none"
+
+# Kernel
+KERNEL_ARCH = "arm"
+PREFERRED_PROVIDER_virtual/kernel = "linux-mtk-extension"
+PREFERRED_VERSION_linux-mtk-extension ?= "4.14%"
+KERNEL_IMAGETYPE = "fitImage"
+KERNEL_CONFIG = "auto2731evb_ivt_mcp_lp2_nand"
+KBUILD_DEFCONFIG = "${KERNEL_CONFIG}_defconfig"
+DTB_LOADADDRESS = "0x43e30000"
+KERNEL_OUT_DIR = "${BASE_WORKDIR}/${MACHINE_ARCH}-poky-linux-gnueabi/${PREFERRED_PROVIDER_virtual/kernel}/4.14-r0/${PREFERRED_PROVIDER_virtual/kernel}-4.14"
+KERNEL_SRC_DIR = "${KERNEL_OUT_DIR}/source"
+KERNEL_COMPRESS = "lz4"
+KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand_pcie_rc.dtb"
+RECOVERY_KERNEL_DEVICETREE = "auto2731evb-ivt-mcp_lp2_nand_pcie_rc.dtb"
+# GLIBC version control
+OLDEST_KERNEL_EXTRA ?= "3.18"
+OLDEST_KERNEL = "${OLDEST_KERNEL_EXTRA}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
+
+# LOADER ENTRYPOINT, LOADADDRESS
+UBOOT_ENTRYPOINT = "0x40008000"
+UBOOT_LOADADDRESS = "0x40008000"
+
+# Scatter File
+SCATTER_PROJECT = "auto2731-ivt-mcp_nand"
+
+# Image FS
+IMAGE_FSTYPES ?= "ubi"
+IMAGE_ROOTFS_ALIGNMENT = "4"
+EXTRA_IMAGEDEPENDS += "lib64-bl33 lk lib64-trustzone spmfw mdcert"
+EXTRA_IMAGEDEPENDS += "fbtool flashtool platform-tools scatter"
+SERIAL_CONSOLES = "921600;ttyGS1"
+
+#UBI/UBIFS ARGS
+MKUBIFS_ARGS = "-m 2048 -e 126976 -c 1400 -F"
+UBINIZE_ARGS = "-m 2048 -p 128KiB -O 2048"
+
+MKUBIFS_CONFIG_ARGS = "-m 2048 -e 126976 -c 22 -F"
+
+# Build Load Type
+BUILD_LOAD_TYPE ?= "eng"
+
+# DRAM TYPE
+MTK_DRAM_TYPE = "LP2"
+
+#anw soft
+ANW_SUPPORT = "NO"
+
+# PMIC chip type
+MTK_PMIC_CHIP_TYPE = "MT6389"
+
+# USB 3.1/PCIe
+MTK_USB_OR_PCIE = "PCIe"
+
+DEBUG_SUPPORT = "yes"
+
+# GNSS
+MTK_GNSS_CHIP_TYPE = "MT3303"
+
+# For AEE Kernel Config
+KERNEL_AEE_CFG = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE LK Config
+MTK_KEDUMP_MINI_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+MTK_MRDUMP_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'no', 'no', d)}"
+MTK_BOOT_REASON_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+# For AEE Native Service Config
+MTK_AEE_SUPPORT = "${@bb.utils.contains('DEBUG_SUPPORT', 'yes', 'yes', 'no', d)}"
+
+#COMBO CHIP
+COMBO_CHIP_ID="mt6630"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-apps/thermal-manager/thermal-manager.bb b/meta/meta-mediatek-mt2731/recipes-apps/thermal-manager/thermal-manager.bb
new file mode 100644
index 0000000..43f8f1c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-apps/thermal-manager/thermal-manager.bb
@@ -0,0 +1,44 @@
+DESCRIPTION = "thermal manager"
+LICENSE = "MediaTekProprietary"
+
+SRC = "${TOPDIR}/../src/apps/ivt-base/thermal-manager"
+
+S = "${WORKDIR}"
+
+inherit workonsrc
+
+WORKONSRC = "${SRC}"
+
+CFLAGS += "-Wl,--hash-style=gnu"
+
+do_compile() {
+ oe_runmake
+}
+
+do_install_append() {
+if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system
+ install -m 644 ${S}/thermal-manager.service ${D}${systemd_unitdir}/system
+fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/thermal_manager ${D}${bindir}/
+ install -d ${D}${libdir}/
+ install -m 0755 ${S}/${base_libdir}/libmtcloader.so ${D}${libdir}/
+ install -d ${D}/data/thermal
+ install -m 0777 ${S}/thermal.conf ${D}/data/thermal
+ install -m 0777 ${S}/dis_thermal.conf ${D}/data/thermal
+}
+
+
+# if systemd service include.
+inherit systemd
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "thermal-manager.service"
+FILES_${PN} += "${systemd_unitdir}/system/thermal-manager.service"
+
+FILES_${PN} += "${libdir} /data/thermal/thermal.conf"
+FILES_${PN} += "${libdir} /data/thermal/dis_thermal.conf"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-bach/build.mt2731/build.mt2731_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-bach/build.mt2731/build.mt2731_1.0.0.bb
new file mode 100644
index 0000000..3b56805
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bach/build.mt2731/build.mt2731_1.0.0.bb
@@ -0,0 +1,102 @@
+#Basic Configuration
+DESCRIPTION = "Provide modem related functionalities."
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+MTK_SRC = "${BACH_SRC}/build.${TARGET_PLATFORM}"
+CROSS = "${TARGET_PREFIX}"
+PROJECT = "${PROJ}"
+PRODUCT_MODE = "${PROD_MODE}"
+WORKONSRC = "${MTK_SRC}"
+DEPENDS = "custom"
+
+inherit deploy workonsrc
+
+#Skip strip check in QA test
+INSANE_SKIP_${PN} += "already-stripped"
+
+FILES_${PN} = "${datadir}/bach/bach_common \
+ ${datadir}/bach/bach_sncfg \
+ ${datadir}/bach/bach_modem \
+ ${datadir}/bach/bach_meta \
+ ${datadir}/bach/bach_ims \
+ ${base_bindir}/getprop \
+ ${base_bindir}/setprop \
+ /usr/cfg/* \
+ /usr/etc/init.d/gen_mmcblk_name\
+ /usr/etc/init.d/yocto_mnt_folders\
+ /usr/etc/init.d/gen_modem_link.sh"
+
+
+#Systemd Settings
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+#SYSTEMD_SERVICE_${PN} = "bach_common.service bach_sncfg.service bach_modem.service bach_meta.service bach_speech.service bach_telephony.service"
+SYSTEMD_SERVICE_${PN} = "bach_modem.service bach_meta.service bach_speech.service bach_telephony.service"
+#FILES_${PN} += "${systemd_unitdir}/system/bach_common.service"
+#FILES_${PN} += "${systemd_unitdir}/system/bach_sncfg.service"
+FILES_${PN} += "${systemd_unitdir}/system/bach_modem.service"
+FILES_${PN} += "${systemd_unitdir}/system/bach_meta.service"
+FILES_${PN} += "${systemd_unitdir}/system/bach_speech.service"
+FILES_${PN} += "${systemd_unitdir}/system/bach_telephony.service"
+
+
+do_install_append() {
+ mkdir -p ${D}/usr/etc/init.d/
+ cp -af src/rootfs/etc/init.d/gen_modem_link.sh ${D}/usr/etc/init.d/gen_modem_link.sh
+ cp -af src/rootfs/etc/init.d/yocto_mnt_folders ${D}/usr/etc/init.d/yocto_mnt_folders
+
+ #install -d ${D}/usr/cfg
+ #install -m 0755 cfg/*.* ${D}/usr/cfg/
+
+ if [ -d "${WORKONSRC}" ]; then
+ #Since systemd.bbclass would delete the /etc/init.d DIR, we move the daemons from /etc/init.d to /usr/bin.
+ install -d ${D}${datadir}/bach
+ install -d ${D}${base_bindir}
+ install -m 0755 src/script/bach_common ${D}${datadir}/bach/bach_common
+ install -m 0755 src/script/bach_sncfg ${D}${datadir}/bach/bach_sncfg
+ install -m 0755 src/script/bach_modem ${D}${datadir}/bach/bach_modem
+ install -m 0755 src/script/bach_meta ${D}${datadir}/bach/bach_meta
+ install -m 0755 src/script/bach_ims ${D}${datadir}/bach/bach_ims
+ install -m 0755 src/script/getprop ${D}${base_bindir}/getprop
+ install -m 0755 src/script/setprop ${D}${base_bindir}/setprop
+ else
+ install -d ${D}${datadir}/bach
+ install -d ${D}${base_bindir}
+ install -m 0755 .${datadir}/bach/bach_common ${D}${datadir}/bach/bach_common
+ install -m 0755 .${datadir}/bach/bach_sncfg ${D}${datadir}/bach/bach_sncfg
+ install -m 0755 .${datadir}/bach/bach_modem ${D}${datadir}/bach/bach_modem
+ install -m 0755 .${datadir}/bach/bach_meta ${D}${datadir}/bach/bach_meta
+ install -m 0755 .${datadir}/bach/bach_ims ${D}${datadir}/bach/bach_ims
+ install -m 0755 .${datadir}/bach/getprop ${D}${base_bindir}/getprop
+ install -m 0755 .${datadir}/bach/setprop ${D}${base_bindir}/setprop
+ fi
+
+ if [ -d "${WORKONSRC}" ]; then
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ #install -m 0644 ${B}/service/bach_common.service ${D}${systemd_unitdir}/system
+ #install -m 0644 ${B}/service/bach_sncfg.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}/service/bach_modem.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}/service/bach_meta.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}/service/bach_speech.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}/service/bach_telephony.service ${D}${systemd_unitdir}/system
+ fi
+ else
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ #install -m 0644 ${B}${systemd_unitdir}/system/bach_common.service ${D}${systemd_unitdir}/system
+ #install -m 0644 ${B}${systemd_unitdir}/system/bach_sncfg.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}${systemd_unitdir}/system/bach_modem.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}${systemd_unitdir}/system/bach_meta.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}${systemd_unitdir}/system/bach_speech.service ${D}${systemd_unitdir}/system
+ install -m 0644 ${B}${systemd_unitdir}/system/bach_telephony.service ${D}${systemd_unitdir}/system
+ fi
+ fi
+}
+
+do_clean () {
+ oe_runmake clean
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-bach/packagegroups/packagegroup-bach-mt2731.bb b/meta/meta-mediatek-mt2731/recipes-bach/packagegroups/packagegroup-bach-mt2731.bb
new file mode 100755
index 0000000..0a3ea3e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bach/packagegroups/packagegroup-bach-mt2731.bb
@@ -0,0 +1,14 @@
+SUMMARY = "BACH Package Group - MT2731"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+RDEPENDS_packagegroup-bach-mt2731 = "\
+ packagegroup-modem-mt2731 \
+ \
+ packagegroup-telephony-mt2731 \
+ \
+ packagegroup-bach-ivt \
+ \
+ build.mt2731 \
+ "
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/autologin/systemd-serialgetty.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/autologin/systemd-serialgetty.bbappend
new file mode 100644
index 0000000..c11630a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/autologin/systemd-serialgetty.bbappend
@@ -0,0 +1,3 @@
+do_install_prepend() {
+ sed -i 's/sbin\/agetty/sbin\/agetty --autologin root/g' ${WORKDIR}/serial-getty@.service
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/bl33/bl33_1.0.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/bl33/bl33_1.0.bbappend
new file mode 100644
index 0000000..bb2e493
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/bl33/bl33_1.0.bbappend
@@ -0,0 +1,57 @@
+do_compile[nostamp] = "1"
+
+do_compile () {
+ if [ "${DEFAULTTUNE}" = "aarch64" ]; then
+ oe_runmake ARCH_arm64_TOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX} \
+ NOECHO="" \
+ BUILDROOT=${BL33_OUT} \
+ LIBGCC="" \
+ CFLAGS="" \
+ DEBUG=0 \
+ SECURE_BOOT_ENABLE=${SECURE_BOOT_ENABLE} \
+ SECURE_BOOT_TYPE=${SECURE_BOOT_TYPE} \
+ MD_VERIFY=${MD_VERIFY} \
+ HSM_OS_SUPPORT=${HSM_OS_SUPPORT} \
+ MTK_KEDUMP_MINI_SUPPORT=${MTK_KEDUMP_MINI_SUPPORT} \
+ MTK_MRDUMP_SUPPORT=${MTK_MRDUMP_SUPPORT} \
+ MTK_BOOT_REASON_SUPPORT=${MTK_BOOT_REASON_SUPPORT} \
+ AVB_ENABLE_ANTIROLLBACK=${AVB_ENABLE_ANTIROLLBACK} \
+ AB_OTA_UPDATER=${AB_OTA_UPDATER} \
+ MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE} \
+ BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE} \
+ SINGLE_BIN_MODEM_SUPPORT=${SINGLE_BIN_MODEM_SUPPORT} \
+ BOOTDEV_TYPE=${BOOTDEV_TYPE} \
+ ${BL33_PROJECT}
+ else
+ oe_runmake TOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX} \
+ NOECHO="" \
+ BUILDROOT=${BL33_OUT} \
+ LIBGCC="$(${CC} --sysroot ${STAGING_DIR_HOST} -print-libgcc-file-name)" \
+ CFLAGS="" \
+ DEBUG=0 \
+ SECURE_BOOT_ENABLE=${SECURE_BOOT_ENABLE} \
+ SECURE_BOOT_TYPE=${SECURE_BOOT_TYPE} \
+ MD_VERIFY=${MD_VERIFY} \
+ HSM_OS_SUPPORT=${HSM_OS_SUPPORT} \
+ MTK_KEDUMP_MINI_SUPPORT=${MTK_KEDUMP_MINI_SUPPORT} \
+ MTK_MRDUMP_SUPPORT=${MTK_MRDUMP_SUPPORT} \
+ MTK_BOOT_REASON_SUPPORT=${MTK_BOOT_REASON_SUPPORT} \
+ AVB_ENABLE_ANTIROLLBACK=${AVB_ENABLE_ANTIROLLBACK} \
+ AB_OTA_UPDATER=${AB_OTA_UPDATER} \
+ MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE} \
+ BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE} \
+ SINGLE_BIN_MODEM_SUPPORT=${SINGLE_BIN_MODEM_SUPPORT} \
+ BOOTDEV_TYPE=${BOOTDEV_TYPE} \
+ ${BL33_PROJECT}
+ fi
+ # add filesize check
+ start=$(grep -w _start -n ${BL33_OUT}/build-${BL33_PROJECT}/lk.elf.sym.sorted | \
+ sed -E 's/(.*):([0-9a-fA-F]+)(.*)/\2/' | tr '[:lower:]' '[:upper:]')
+ end=$(grep -w _end -n ${BL33_OUT}/build-${BL33_PROJECT}/lk.elf.sym.sorted | \
+ sed -E 's/(.*):([0-9a-fA-F]+)(.*)/\2/' | tr '[:lower:]' '[:upper:]')
+ fs=`echo "obase=16;ibase=16; $end - $start" | bc`
+ maxsize=${BL33_MAX_SIZE}
+ if [ ${BL33_MAX_SIZE} != "" ] && [[ 0x$fs -gt $maxsize ]]; then
+ bberror "Little kernel image size overflow, please have a check."
+ fi
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/lk/lk_2.0.0.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/lk/lk_2.0.0.bbappend
new file mode 100644
index 0000000..935e948
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/lk/lk_2.0.0.bbappend
@@ -0,0 +1,75 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+SRC_URI_remove = "file://gfh"
+
+# override the common fit image tool setting in lk 2.0 bb file.
+FIT_IMG_TOOL = "brom-mkimage"
+
+fitimage_emit_fit_conf_section() {
+
+ cat << EOF >> $1
+
+ configurations {
+ default = "conf@1";
+ conf@1 {
+ description = "bl";
+ kernel = "bl@1";
+ a32;
+ signature@1 {
+ algo = "${2},${3}";
+ key-name-hint = "${4}";
+ sign-images = "kernel";
+ };
+ };
+ };
+EOF
+}
+
+do_compile () {
+ if [ "${DEFAULTTUNE}" = "aarch64" ]; then
+ oe_runmake ARCH_arm64_TOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX} \
+ NOECHO="" \
+ BUILDROOT=${LK_OUT} \
+ LIBGCC="" \
+ CFLAGS="" \
+ DEBUG=0 \
+ SECURE_BOOT_ENABLE=${SECURE_BOOT_ENABLE} \
+ SECURE_BOOT_TYPE=${SECURE_BOOT_TYPE} \
+ MD_VERIFY_ENABLE=${MD_VERIFY_ENABLE} \
+ HSM_OS_SUPPORT=${HSM_OS_SUPPORT} \
+ AVB_ENABLE_ANTIROLLBACK=${AVB_ENABLE_ANTIROLLBACK} \
+ AB_OTA_UPDATER=${AB_OTA_UPDATER} \
+ CLK32K_EXT_REMOVAL=${CLK32K_EXT_REMOVAL} \
+ MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE} \
+ BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE} \
+ ${LK_PROJECT}
+ else
+ oe_runmake TOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX} \
+ NOECHO="" \
+ BUILDROOT=${LK_OUT} \
+ LIBGCC="$(${CC} --sysroot ${STAGING_DIR_HOST} -print-libgcc-file-name)" \
+ CFLAGS="" \
+ DEBUG=0 \
+ SECURE_BOOT_ENABLE=${SECURE_BOOT_ENABLE} \
+ SECURE_BOOT_TYPE=${SECURE_BOOT_TYPE} \
+ MD_VERIFY_ENABLE=${MD_VERIFY_ENABLE} \
+ HSM_OS_SUPPORT=${HSM_OS_SUPPORT} \
+ AVB_ENABLE_ANTIROLLBACK=${AVB_ENABLE_ANTIROLLBACK} \
+ AB_OTA_UPDATER=${AB_OTA_UPDATER} \
+ CLK32K_EXT_REMOVAL=${CLK32K_EXT_REMOVAL} \
+ MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE} \
+ BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE} \
+ ${LK_PROJECT}
+ fi
+ # add filesize check
+ start=$(grep -w _start -n ${LK_OUT}/build-${LK_PROJECT}/lk.elf.sym.sorted | \
+ sed -E 's/(.*):([0-9a-fA-F]+)(.*)/\2/' | tr '[:lower:]' '[:upper:]')
+ end=$(grep -w _end -n ${LK_OUT}/build-${LK_PROJECT}/lk.elf.sym.sorted | \
+ sed -E 's/(.*):([0-9a-fA-F]+)(.*)/\2/' | tr '[:lower:]' '[:upper:]')
+ fs=`echo "obase=10;ibase=16; $end - $start" | bc`
+ maxsize=$(printf '%d' ${LK_MAX_SIZE})
+
+ if [ ${LK_MAX_SIZE} != "" ] && [ $fs -gt $maxsize ]; then
+ bberror "Little kernel image size overflow, please have a check. $fs > $maxsize"
+ fi
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/__init__.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/__init__.py
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/cert_gen.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/cert_gen.py
new file mode 100644
index 0000000..6edc0f0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/cert_gen.py
@@ -0,0 +1,259 @@
+"""
+This module is for x509 certificate generation with asn1.der encoding
+"""
+import os
+import shutil
+import stat
+import argparse
+import lib.cert
+import lib.asn1_gen
+import pbp
+
+class CertGenArgs(object):
+ """
+ CertGenArgs is used to pass argument to this module: cert_gen
+ """
+ def __init__(self):
+ """
+ contructor for CertGenArgs
+ """
+ self.config_file = None
+ self.prvk_file_path = None
+ self.root_key_padding = 'legacy'
+ self.x509cert_file = None
+ self.env = os.path.join(os.path.dirname(__file__), 'env.cfg')
+ return
+
+ def reset(self):
+ """
+ reset all arguments
+ """
+ self.__init__()
+ return
+
+ def dump(self):
+ """
+ dump parameters
+ """
+ get_arg = lambda arg: 'Not Set' if arg is None else arg
+ print 'config_file = ' + get_arg(self.config_file)
+ print 'prvk_file_path = ' + get_arg(self.prvk_file_path)
+ print 'root_key_padding = ' + get_arg(self.root_key_padding)
+ print 'x509cert_file = ' + get_arg(self.x509cert_file)
+ print 'env = ' + get_arg(self.env)
+ return
+
+def cert_gen_op(cert_gen_args):
+ """
+ generate certificate
+ """
+ env_args = {}
+ parse_env_cfg(cert_gen_args.env, env_args)
+
+ config_file = cert_gen_args.config_file
+ prvk_file_path = cert_gen_args.prvk_file_path
+ root_key_padding = cert_gen_args.root_key_padding
+ x509cert_file = cert_gen_args.x509cert_file
+
+ in_file = os.path.basename(os.path.abspath(config_file))
+ out_folder = os.path.dirname(os.path.abspath(x509cert_file))
+ #core name will be used to create hash/sig and other temporary files
+ core_name = os.path.splitext(in_file)[0]
+
+ create_cert_intermediate_folder(out_folder)
+ intermediate_folder_path = os.path.join(out_folder, "cert_intermediate")
+
+ hash_file_path = os.path.join(intermediate_folder_path, "tbs_" + core_name + ".hash")
+ sig_file_path = os.path.join(intermediate_folder_path, "tbs_" + core_name + ".sig")
+ tbs_cert_file_path = os.path.join(intermediate_folder_path, "tbs_" + core_name + ".der")
+ pubk_file_path = os.path.join(intermediate_folder_path, core_name + "_pubk.pem")
+
+ #generate public key
+ print "Generating public key from private key..."
+ if lib.cert.is_prvk(prvk_file_path):
+ lib.cert.prvk_to_pubk(os.path.abspath(prvk_file_path), pubk_file_path)
+ elif lib.cert.is_pubk(prvk_file_path):
+ #will delegate image signing to HSM.
+ shutil.copy2(prvk_file_path, pubk_file_path)
+ else:
+ print 'unknown key format'
+ return
+
+ print "Generating tbsCertificate..."
+ #update public key path in config file
+ tbs_config_file_path = os.path.join(intermediate_folder_path, "tbs_" + core_name + ".cfg")
+ #generate tbs config file
+ gen_tbs_config_file(config_file, tbs_config_file_path, pubk_file_path, root_key_padding)
+
+ lib.asn1_gen.asn1_gen(tbs_config_file_path, tbs_cert_file_path, False)
+ lib.cert.sig_gen(tbs_cert_file_path, prvk_file_path, 'pss', sig_file_path)
+
+ print "Generating x509cert..."
+ #update signature file path in x509 config file
+ x509cert_config_file_path = os.path.join(intermediate_folder_path, "x509_" + core_name + ".cfg")
+ #generate x509 config file
+ gen_x509_config_file(os.path.join(env_args['x509_template_path'], 'x509cert_template.cfg'), \
+ x509cert_config_file_path, \
+ tbs_config_file_path, \
+ sig_file_path)
+ lib.asn1_gen.asn1_gen(x509cert_config_file_path, x509cert_file, False)
+ print "Done"
+ return
+
+def pubk_to_gfh(pubk, gfh_file_path, padding):
+ """
+ convert pem format of root public key to gfh, which is needed for public key authentication.
+ """
+ pbp_args = pbp.PbpArgs()
+
+ if padding == 'pss':
+ pbp_args.op = 'keybin_pss'
+ elif padding == 'legacy':
+ pbp_args.op = 'keybin_legacy'
+ else:
+ return -1
+
+ pbp_args.key_path = pubk
+ pbp_args.output_path = gfh_file_path
+ if pbp.pbp_op(pbp_args):
+ print 'public key to gfh conversion fails'
+ return -2
+
+ return 0
+
+def update_tbs_config_file(config_file_path, pubk_pem_path, root_key_padding):
+ """
+ compose configuration for tbsCertificate
+ """
+ config_file = open(config_file_path, 'r')
+ lines = config_file.readlines()
+ config_file.close()
+
+ out_config_file = open(config_file_path, 'w')
+ for line in lines:
+ component = line.split()
+ if (component[0] == 'pubk') and (component[1] == 'EXTERNAL_PEM'):
+ line_regen = " pubk EXTERNAL_PEM ::= " + pubk_pem_path + '\n'
+ out_config_file.write(line_regen)
+ elif (component[0] == 'rootpubk') and (component[1] == 'EXTERNAL_BITSTRING'):
+ #this is root cert, must generate gfh and oemkey.h
+ #pubk is generated from prvk, and we assuem pubk is in out_folder
+ intermediate_folder_path = os.path.dirname(os.path.abspath(pubk_pem_path))
+ #generate gfh from pubk
+ gfh_file_path = os.path.join(intermediate_folder_path, "gfh_sec_key.bin")
+ pubk_to_gfh(pubk_pem_path, gfh_file_path, root_key_padding)
+ #generate final path of gfh
+ line_regen = " rootpubk EXTERNAL_BITSTRING ::= " + gfh_file_path + '\n'
+ out_config_file.write(line_regen)
+ else:
+ out_config_file.write(line)
+
+ out_config_file.close()
+ return
+
+def gen_tbs_config_file(config_file, tbs_config_file, pubk_file, root_key_padding):
+ """
+ generate configuration file for tbs(to-be-signed) certificate in x509 certificate.
+ """
+ shutil.copy2(config_file, tbs_config_file)
+ update_tbs_config_file(tbs_config_file, pubk_file, root_key_padding)
+
+def update_x509_config_file(x509cert_cfg, tbs_cert_cfg, sig_path):
+ """
+ compose x509 certificate with tbsCertificate and signature
+ """
+ config_file = open(x509cert_cfg, 'r')
+ lines = config_file.readlines()
+ config_file.close()
+
+ out_config_file = open(x509cert_cfg, 'w')
+ for line in lines:
+ component = line.split()
+ if (component[0] == 'tbsCertificate') and (component[1] == 'EXTERNAL_CFG'):
+ line_regen = " tbsCertificate EXTERNAL_CFG ::= " + tbs_cert_cfg + '\n'
+ out_config_file.write(line_regen)
+ elif (component[0] == 'sigValue') and (component[1] == 'EXTERNAL_BITSTRING'):
+ line_regen = " sigValue EXTERNAL_BITSTRING ::= " + sig_path + '\n'
+ out_config_file.write(line_regen)
+ else:
+ out_config_file.write(line)
+
+ out_config_file.close()
+ return
+
+def gen_x509_config_file(x509cert_template_cfg, x509cert_config_file, tbs_config_file, sig_file):
+ """
+ generate configuration file for final x509 certificate
+ """
+ shutil.copy2(x509cert_template_cfg, x509cert_config_file)
+ os.chmod(x509cert_config_file, stat.S_IWRITE + stat.S_IREAD)
+ update_x509_config_file(x509cert_config_file, tbs_config_file, sig_file)
+
+def create_cert_intermediate_folder(out_folder_path):
+ """
+ create folder to intermediate data
+ """
+ intermediate_folder_path = os.path.abspath(os.path.join(out_folder_path, "cert_intermediate"))
+
+ try:
+ os.makedirs(intermediate_folder_path)
+ except OSError, error:
+ if error.errno != os.errno.EEXIST:
+ raise
+
+def parse_env_cfg(env_cfg_path, env_args):
+ """
+ get environment arguments from the given environment configuration file
+ """
+ print '=============================='
+ print 'env_cfg parsing'
+ print '=============================='
+ cfg_file = open(env_cfg_path, 'r')
+ cfg_file_dir = os.path.dirname(os.path.abspath(env_cfg_path))
+ for line in cfg_file.readlines():
+ line = line.strip()
+ if line:
+ elements = line.split('=')
+ field = elements[0].strip()
+ value = elements[1].strip()
+ if field == 'x509_template_path':
+ env_args['x509_template_path'] = os.path.join(cfg_file_dir, value)
+ else:
+ print 'ignored: ' + field
+ print '=============================='
+ return
+
+def main():
+ """
+ main function which is the entry point when this script is invoked from cmdline.
+ """
+
+ parser = argparse.ArgumentParser(description="x509 certificate generation tool")
+ parser.add_argument('-cert_cfg',
+ dest='config_file',
+ required=True,
+ help='certificate configuration')
+ parser.add_argument('-prvk',
+ dest='prvk_file_path',
+ required=True,
+ help='private key for certificate signature generation.')
+ parser.add_argument('-padding',
+ dest='root_key_padding',
+ default='legacy',
+ help='private key for certificate signature generation.')
+ parser.add_argument('-out',
+ dest='x509cert_file',
+ required=True,
+ help='output path for certificate')
+ parser.add_argument('-env',
+ dest='env',
+ default=os.path.join(os.path.dirname(__file__), 'env.cfg'),
+ help='output path for certificate')
+ cert_gen_args = parser.parse_args()
+
+ cert_gen_op(cert_gen_args)
+
+ return
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_extractor b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_extractor
new file mode 100644
index 0000000..e75b990
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_extractor
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_to_pem.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_to_pem.py
new file mode 100644
index 0000000..7bdafa7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/der_to_pem.py
@@ -0,0 +1,39 @@
+#-------------------------------------------------------------------------------
+# Name: cert_gen
+# Purpose:
+#
+# Author: MTK02464
+#
+# Created: 08/06/2015
+# Copyright: (c) MTK02464 2015
+# Licence: <your licence>
+#-------------------------------------------------------------------------------
+import base64
+import os
+import sys
+import subprocess
+
+def der_to_pem(der_file_path, pem_file_path):
+ in_file = open(der_file_path, 'rb')
+ in_data = ""
+ while True:
+ byte = in_file.read(1)
+ if byte == "":
+ break;
+ in_data = in_data + byte
+
+ out_data = base64.standard_b64encode(in_data)
+
+ out_file = open(pem_file_path, 'w')
+ out_file.write(out_data)
+ out_file.close()
+ return
+
+def main():
+ in_file = sys.argv[1]
+ out_file = sys.argv[2]
+
+ der_to_pem(in_file, out_file)
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/pem_to_der.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/pem_to_der.py
new file mode 100644
index 0000000..f7111ef
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/der_extractor/pem_to_der.py
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------------------------
+# Name: cert_gen
+# Purpose:
+#
+# Author: MTK02464
+#
+# Created: 08/06/2015
+# Copyright: (c) MTK02464 2015
+# Licence: <your licence>
+#-------------------------------------------------------------------------------
+import base64
+import os
+import sys
+import subprocess
+
+def pem_to_der(pem_file_path, der_file_path):
+ in_file = open(pem_file_path, 'r')
+ in_data = ""
+ while True:
+ line = in_file.readline()
+ if line == '':
+ break
+ if line[0] != '-':
+ in_data = in_data + line
+
+ out_data = base64.standard_b64decode(in_data)
+
+ out_file = open(der_file_path, 'wb')
+ out_file.write(out_data)
+ out_file.close()
+ return
+
+def main():
+ in_file = sys.argv[1]
+ out_file = sys.argv[2]
+
+ pem_to_der(in_file, out_file)
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/env.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/env.cfg
new file mode 100644
index 0000000..30f222f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/env.cfg
@@ -0,0 +1,8 @@
+in_path = out
+out_path = out
+cert1_dir = ../../custom/${PLATFORM}/security/cert_config/cert1
+cert2_key_dir = ../../custom/${PLATFORM}/security/cert_config/cert2_key
+img_list_path = ../../custom/${PLATFORM}/security/cert_config/img_list.txt
+img_ver_path = ../../custom/${PLATFORM}/security/cert_config/img_ver.txt
+x509_template_path = x509_template/
+mkimage_tool_path = mkimage20/
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm.py
new file mode 100644
index 0000000..afad840
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm.py
@@ -0,0 +1,89 @@
+"""
+This module is used to delegate signature generation to HSM(Hardware Security Module)
+If public key is given for signing instead of private key, we'll know that
+we're trying to delegate signature to HSM. Then we look up key table created
+here to find HSM parameters. Here public key is used only as id for HSM
+parameters and won't act as a public key.
+"""
+import filecmp
+import os
+import lib.cert
+
+class HsmParam(object):
+ """
+ Parameter for HSM
+ """
+ def __init__(self):
+ # you can add parameter required by your HSM here
+ self.m_prvk = None
+
+def create_key_table():
+ """
+ create key table for public key to private key mapping
+ """
+ prvk_list = []
+ pubk_list = []
+ key_database_path = os.path.join(os.path.dirname(__file__), 'hsm_test_keys')
+ keys = os.listdir(key_database_path)
+ key_table = {}
+
+ for key in keys:
+ key_path = os.path.join(key_database_path, key)
+ if lib.cert.is_prvk(key_path):
+ prvk_list.append(key_path)
+ elif lib.cert.is_pubk(key_path):
+ pubk_list.append(key_path)
+
+ for pubk in pubk_list:
+ for prvk in prvk_list:
+ tmp_pubk = os.path.join(os.path.dirname(__file__), 'tmp_pubk.pem')
+ lib.cert.prvk_to_pubk(prvk, tmp_pubk)
+ if filecmp.cmp(pubk, tmp_pubk, False) is True:
+ key_table[pubk] = os.path.join(key_database_path, prvk)
+ os.remove(tmp_pubk)
+ break
+ os.remove(tmp_pubk)
+
+ return key_table
+
+def query_key_table(key_table, key):
+ """
+ get private key from public key.
+ In your implementation, you should convert input public
+ key to parameter passed to HSM, so HSM knows how to sign
+ message. Here as an example, we search public keys in a folder
+ as public key data base, and use corresponding private key
+ to sign message.
+ """
+ for pubk in key_table.keys():
+ if filecmp.cmp(key, pubk, False) is True:
+ return key_table[pubk]
+
+ return None
+
+
+def hsm_rsa_sign(data, key, padding, sig):
+ """
+ sign data with HSM
+ """
+ # note that key is pubk actually, use it as index for
+ # HSM parameters such as key selection
+ hsm_param_obj = HsmParam()
+ key_table = create_key_table()
+ hsm_param_obj.m_prvk = query_key_table(key_table, key)
+ if hsm_param_obj.m_prvk is None:
+ print 'not valid HSM parameter'
+ return -1
+
+ print "========================"
+ print "HSM parameter:"
+ print " m_prvk = " + hsm_param_obj.m_prvk
+ print "========================"
+
+ # place hsm request here -- start
+ # we re-direct it to signing with private key to mimic HSM
+ # data is not hashed here, you can hash data here to reduce
+ # network usage
+ lib.cert.sig_gen(data, hsm_param_obj.m_prvk, padding, sig)
+ # place hsm request here -- end
+ return 0
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_prvk.pem b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_prvk.pem
new file mode 100644
index 0000000..de54ca9
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_prvk.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpgIBAAKCAQEA5rT8/XparBVsl/AUbMEr7D6VpGyjdWTQhwCB0zxMokWzqCBS
+ktC3WHbk0bGDMOfqewrgx26FQJ8e1mwDGpOCDqn08Z5P8KwwgEEFlBEAd+RKJ5vY
+KJv74bVn3a0FBkKh9EJNZ3uNVn5I2dK6jmNPT4WcJm3b5vieScNt6BGPbWEw2OtD
+Du+z/6AITVddx4Dt37WzrfJfkycjf1ah4Qk4yDebY6a+Punp3mCljgsj4DQGans7
+ica68PIhwrt2vI8zeO1tsAGsxGKmJHeqfaTooHGqrUQz1LkQdzy6Shdw9+hZgaAU
+55qMuIA9ZVktqYjhGgZNt2TlKxI4CDpQAg1SXwIDAQABAoIBAQDHAdBJhsW4MzLd
+TUcRGQCeZM4Ia34EwdXu3k0evaENSTrUCC2yX0AIm2Z+S7Vy9lqZkKSc44UmXRvo
+sntq7Vr+8zRLR9iFLsMXnv8E3jWdNduRlyk6vnLkG+tgmOMAp3G0lYzXewhMV9rX
+qqMqOBgt7H7p11IdRtCjqGSiDqO+ILj4y0SC8HbIbEjJ28bU812S1Oy+OZ8Cfnsv
+iGTyRtbMNH1VDmJELeRq08J4hFqHncykS4sGs9dARjluG8/7J8olygkxhW16tqFJ
+vKanSjYMoGQsgcMUzl2Y3B735kvaeorbI7/DUO9jUKeMgvT9GKojF2UHAEjiVQQd
+VLTx/ogBAoGBAPg3mnL8m28OTCPHf3X/7fZSm8GgTxd9uw1ekmJ7yzHpPA7kfi+f
+JTBVT0TW0xmThET2bKdzsdXuQimKRDXh98B4tW0iaAi1Sd0hRvsY57atK12cBhhW
+iCtznd5dfDnh5eZDjBDlZTOPvuvvPI0i6kBL/mDCM2TLdTVbq13/B/VfAoGBAO3w
+1VzJU6nsFDe+ykNACbVj5k4zgLJySLiUfxsQx4XHi/rfy8OYSWwrOGgkGvQ8vrwH
+I4n8nnVytqn32U+jp2tncpFyM1JLG1bXLvHHvoeK3+tN0u5OT2MWqxYo1BMzCO3G
+C6JO026M3nfbZFUHKiSQgpcybfvAcLGDrBRzosMBAoGBANCSAHEQvBckf2wtLXhc
+1nr9zS11ZCBMIQpJ5l1kwkgtQK8O5s1jP9+OP66LiRTbtPAx1PkcKVmm++dl7I0O
+VJ1hkKmkmKCAnRF37en+cm44stDU0vZOd9tzKjt4eHM203SaW66y40fhSL995nZ9
+2TKv6I8rf/35TILKhYPVUb2nAoGBAJgheWmf13w3Ux3pQI0K7qopO2EYkNqHM3PA
+jhwR+F/Sm+9FE5T1U0xzvdbn7svl4tV5gwGAoRfaxmuZ6jl/G1YSiC/yYlnlZ494
+ea1g1rL22gAqfAidzSg/oBfE9wNnh/fuvhWCbLCsJLlhbp7mu80xEC33slZaTjNR
+Sr6wyIoBAoGBALsN/kwEt9aSxiPKuMiNk9Yo1E/oT8lVFLH1mK3cd9pErr3KsgAi
+NC092Gcl27EXdDg4Rymv0TuMi/mf1IHInFoIHw8jKOETDZnWCOrcD7/qGkRksB2n
+R0XqSmpmOLE/gd2jGr2AD7rsnlaXTj4HfXxg5Lp2+qbtr9N9+3wmYiS/
+-----END RSA PRIVATE KEY-----
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_pubk.pem b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_pubk.pem
new file mode 100644
index 0000000..9c1b325
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/img_pubk.pem
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5rT8/XparBVsl/AUbMEr
+7D6VpGyjdWTQhwCB0zxMokWzqCBSktC3WHbk0bGDMOfqewrgx26FQJ8e1mwDGpOC
+Dqn08Z5P8KwwgEEFlBEAd+RKJ5vYKJv74bVn3a0FBkKh9EJNZ3uNVn5I2dK6jmNP
+T4WcJm3b5vieScNt6BGPbWEw2OtDDu+z/6AITVddx4Dt37WzrfJfkycjf1ah4Qk4
+yDebY6a+Punp3mCljgsj4DQGans7ica68PIhwrt2vI8zeO1tsAGsxGKmJHeqfaTo
+oHGqrUQz1LkQdzy6Shdw9+hZgaAU55qMuIA9ZVktqYjhGgZNt2TlKxI4CDpQAg1S
+XwIDAQAB
+-----END PUBLIC KEY-----
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_prvk.pem b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_prvk.pem
new file mode 100644
index 0000000..e849250
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_prvk.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAm7c0d0RD13VXp24ksQczeHdQ2Q0JyGnNYG1U8ol46mIg3JlI
+s8nokoT4VR1hZvN1S2o7iQrJzanjffqgwTF+NRzlEHxCc3lZScbM5jgxSrGjRThd
+dkLLjQVaH0EMfX4kpvCiqrgYTnc9IbN1SpR1QWgPLBqNa6W+/TtuH8KOwLYdVbFF
+Q4Pyw+i9JxcKJZeGCPZ4i5Ci/DTwzjUFa/dSB5XIxgIyy7wLA5k2evk3hpykXPc3
+qKBmEniT6TFmxDMpjdb9AJ5nkOdDszkqyo6pn2Hfx3vZlBbdpLip1+TaJCF0J/NY
+QRmkkyAW8XNcxjsSZQ/d2nPI/PvHngWPNiGdPQIDAQABAoIBAQCSjSpj1WvELDwC
+6DbAJfbbOfBtV0gNxwXz6vI4EgorDY/ADsPN8glhXKQb9zrkmd2azLCbmfu0BGCH
+AIqrSNlvQ3KSwWAJLfxK4z+UrO43TlhLnXDZDKRmZNMc9yu6MC5ur6to4Tp/Htn6
+DdwmBPMWS8l7yMGwvp2x120dlw6jb0r4rSzgq1t8prT5nBM/o/j/nJLah0OU0Ojx
+vbuDyOgRo0SltaclHJtPtK0KxJSixQoaefqbOZLXSVNbaR3C8BbO5JPkHNIDMZDE
+wEl/aJ5IuuXTrSjLDo0X2uf06MA0q2CrMw9nj7/dLJcWv6amFzOdJItG3xWT1TF7
+OvRKhkZBAoGBAMjib5qsEGAQx87S/pYX5oQKWqp3sL6tuhq4HRNDPGDMCrZzSbqx
+5pOlG1zcgqsNDLxERxq2jZDmt5QJVH2FViLTiwQI5IcCRkakV01uVgv0SgXlYtb1
+3RXmr07OmIZLpqjRfVzmfTkhiuNbf98Er9H73yluxd8vKNgcKGvsBW9LAoGBAMZw
+O/+rEuZn8k5rIm1uN7ZXgTtawWsyK/QoZOxgGHYA28v16CmhFwIs86uI372E8avM
+93rS6UUQRvcWy99vBH+G2ayQMbeEdCWsVFurCazvuF0LH/9le8FXNHRnl/G01lkG
+BrSnDJ3+DISFuERKOBHGZGatPykk+NUCT20+k+iXAoGANa2L9OCVX5YcTf/DV4f7
+aLz7jSF+cPUrDYi0/DizIYpkMmyL/v8ahclQjne90sch6Ay2k0TEfzunQj9b/E5s
+vdGZC/L0Xb8V2DqBuYcKJxeX0AuDZb083mVN4tkBmKEOX33a6cANJf74hdglSwqN
+kKak8wVOilynpVeg1XWz3hECgYAx8FrZG8d03qH3JDUUzxEMPXdTZaKZhJXVKzlC
+12gwgkTOToNvvo+Yx5FHEPolqshbEQkTCvMTo2YIlt8Vys2Z/mjXaa5pXdcRCA5u
+x1t2/xkpqTwTPQno/TZBOTTe6kCrRL35RrUBKccirrhRz0/PAVuRD3Z+t0Q77wno
+F0CH3wKBgGbaXCdZejBVnjqt9Ue8GD1IJoluyKksulvr6v7xWmgDp2iwN/D9SngK
+3Wta9T/DZC+kARWdFoc2Q1urisjSRe5FWkPVeKA/nC4/HV6prYplcwFmLTHbVLQj
+/3gce9KXav+xCL0gXYGM3Q7+eSqvlhFap4yQ6FYH1O+Be36IbQ2x
+-----END RSA PRIVATE KEY-----
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_pubk.pem b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_pubk.pem
new file mode 100644
index 0000000..7e79fb4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/hsm_test_keys/root_pubk.pem
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm7c0d0RD13VXp24ksQcz
+eHdQ2Q0JyGnNYG1U8ol46mIg3JlIs8nokoT4VR1hZvN1S2o7iQrJzanjffqgwTF+
+NRzlEHxCc3lZScbM5jgxSrGjRThddkLLjQVaH0EMfX4kpvCiqrgYTnc9IbN1SpR1
+QWgPLBqNa6W+/TtuH8KOwLYdVbFFQ4Pyw+i9JxcKJZeGCPZ4i5Ci/DTwzjUFa/dS
+B5XIxgIyy7wLA5k2evk3hpykXPc3qKBmEniT6TFmxDMpjdb9AJ5nkOdDszkqyo6p
+n2Hfx3vZlBbdpLip1+TaJCF0J/NYQRmkkyAW8XNcxjsSZQ/d2nPI/PvHngWPNiGd
+PQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/img_key_deploy.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/img_key_deploy.py
new file mode 100644
index 0000000..d16419e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/img_key_deploy.py
@@ -0,0 +1,440 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+"""
+This module is used to deploy key certificate and image key for verified boot
+"""
+import sys
+import os
+import struct
+import re
+import shutil
+from collections import namedtuple
+import sign
+import lib.cert
+
+IMG_HDR_MAGIC = 0x58881688
+MKIMG_HDR_FMT = "<2I 32s 2I 8I"
+
+TmpPath = namedtuple('TmpPath', ' \
+tmp_out_path, \
+out_cert1_dir, \
+out_cert1md_dir, \
+cert1_dir, \
+cert2_key_dir, \
+out_cert1_path, \
+out_cert1md_path \
+')
+
+Env = namedtuple('Env', ' \
+in_path, \
+out, \
+img_ver_path, \
+')
+
+def create_out_dir(path):
+ """
+ create output directory
+ """
+ out_dir = os.path.abspath(path)
+ print "Create dir:" + out_dir
+
+ if not os.path.exists(out_dir):
+ os.makedirs(out_dir)
+
+def create_folder(tmp_path):
+ """
+ create temporary folders for output
+ """
+ create_out_dir(tmp_path.tmp_out_path)
+ create_out_dir(tmp_path.out_cert1_dir)
+ create_out_dir(tmp_path.out_cert1md_dir)
+ create_out_dir(tmp_path.cert1_dir)
+ create_out_dir(tmp_path.cert2_key_dir)
+ return
+
+def set_path(args):
+ """
+ initialize paths needed in deployment process
+ """
+
+ tmp_path = TmpPath(tmp_out_path='', \
+ out_cert1_dir='', \
+ out_cert1md_dir='', \
+ cert1_dir='', \
+ cert2_key_dir='', \
+ out_cert1_path='', \
+ out_cert1md_path='' \
+ )
+
+ env = Env(in_path=None, out=None, img_ver_path=None)
+
+ #load environment settings from env.cfg
+ cfg_file = open(args['env_cfg'], 'r')
+ cfg_file_dir = os.path.dirname(os.path.abspath(args['env_cfg']))
+ for line in cfg_file.readlines():
+ line = line.strip()
+ if line:
+ elements = line.split('=')
+ field = elements[0].strip()
+ value = elements[1].strip()
+ value = value.replace("${PLATFORM}", args['platform'])
+ value = value.replace("${PROJECT}", args['project'])
+ if field == 'out_path':
+ out = os.environ.get('PRODUCT_OUT')
+ if out is None:
+ out = os.path.join(cfg_file_dir, value)
+ tmp_out_path = os.path.join(out, 'resign')
+ env = env._replace(out=out)
+ tmp_path = tmp_path._replace(tmp_out_path=tmp_out_path)
+ # in_path is optional, hence we give it default value here
+ if env.in_path is None:
+ env = env._replace(in_path=out)
+ elif field == 'in_path':
+ env = env._replace(in_path=os.environ.get('PRODUCT_OUT'))
+ if env.in_path is None:
+ env = env._replace(in_path=os.path.join(cfg_file_dir, value))
+ elif field == 'cert1_dir':
+ tmp_path = tmp_path._replace(cert1_dir=os.path.join(cfg_file_dir, value))
+ elif field == 'cert2_key_dir':
+ tmp_path = tmp_path._replace(cert2_key_dir=os.path.join(cfg_file_dir, value))
+ elif field == 'img_ver_path':
+ env = env._replace(img_ver_path=os.path.join(cfg_file_dir, value))
+ else:
+ print "ignore " + field
+
+ out_cert1_dir = os.path.join(tmp_out_path, "cert", "cert1")
+ out_cert1_path = os.path.join(out_cert1_dir, "cert1.der")
+ out_cert1md_dir = os.path.join(tmp_out_path, "cert", "${PACKAGE}", "cert1md")
+ out_cert1md_path = os.path.join(out_cert1md_dir, "cert1md.der")
+
+ #tmp path
+ tmp_path = tmp_path._replace(out_cert1_dir=out_cert1_dir)
+ tmp_path = tmp_path._replace(out_cert1md_dir=out_cert1md_dir)
+ tmp_path = tmp_path._replace(out_cert1_path=out_cert1_path)
+ tmp_path = tmp_path._replace(out_cert1md_path=out_cert1md_path)
+
+ return env, tmp_path
+
+def fill_arg_dict(input_str, key, args):
+ """
+ parse one input argument into input argument dictionary
+ """
+ prefix = input_str.split("=")[0]
+ fmt = re.compile(key, re.I)
+ if fmt.search(prefix):
+ val = input_str.split("=")[1]
+ args[key] = val
+ print key + ": " + val
+ return args
+
+def parse_arg(argv):
+ """
+ parse one input arguments
+ """
+ args = {'cert2_key_path': 0, 'cert1_key_path': 0, 'root_key_padding': 0, 'env_cfg': 0}
+
+ for input_str in argv:
+ for key in args:
+ args = fill_arg_dict(input_str, key, args)
+
+ args['platform'] = argv[1]
+ args['project'] = argv[2]
+
+ if args['env_cfg'] == 0:
+ #env_cfg is not given, we set it to env.cfg in path of this tool
+ args['env_cfg'] = os.path.join(os.path.dirname(__file__), 'env.cfg')
+
+ return args
+
+
+def get_img_list(env):
+ """
+ get image list from image version configuration file
+ """
+ pattern1 = r"\["
+ format1 = re.compile(pattern1)
+ file1 = open(env.img_ver_path, 'r')
+ img_list = []
+ for line in file1:
+ if not line.strip():
+ continue
+
+ if format1.match(line):
+ bin_name = line[line.index("[")+1:line.index("]")]
+ img_list.append(bin_name)
+
+ file1.close()
+ return img_list
+
+def get_img_ver_group(img_name, env):
+ """
+ get image version group
+ """
+ img_ver = 0
+ img_group = 0
+ target_line = 0
+
+ file1 = open(env.img_ver_path, 'r')
+
+ pattern0 = r"\["
+ format0 = re.compile(pattern0)
+ pattern1 = r"\[" + img_name + r"\]"
+ format1 = re.compile(pattern1)
+ pattern2 = r"img_ver[\w]*"
+ format2 = re.compile(pattern2)
+ pattern3 = r"img_group[\w]*"
+ format3 = re.compile(pattern3)
+ for line in file1:
+ if not line.strip():
+ continue
+ if format0.match(line):
+ if format1.match(line):
+ target_line = 1
+ else:
+ target_line = 0
+ elif format2.match(line):
+ if target_line == 1:
+ img_ver = line.split("=")[1].strip()
+ elif format3.match(line):
+ if target_line == 1:
+ img_group = line.split("=")[1].strip()
+ file1.close()
+
+ return img_ver, img_group
+
+
+def check_img_type(img, env):
+ """
+ get image type
+ """
+ is_raw = 0
+ is_md = 0
+ img_file = os.path.join(env.in_path, img + ".img")
+ if not os.path.exists(img_file):
+ img_file = os.path.join(env.in_path, img + ".bin")
+ if not os.path.exists(img_file):
+ is_raw = 1
+ is_md = 0
+ return is_raw, is_md
+ print img_file
+
+ file1 = open(img_file, "rb")
+ header_size = struct.calcsize(MKIMG_HDR_FMT)
+ fin = file1.read(header_size)
+
+ unpack_array = struct.unpack(MKIMG_HDR_FMT, fin)
+ file1.close()
+
+ img_type = unpack_array[8]
+
+ if cmp(unpack_array[0], int(IMG_HDR_MAGIC)) == 0:
+ img_type_byte0 = img_type & 0xFF
+ img_type_byte3 = (img_type >> 24) & 0xFF
+
+ if img_type == 0:
+ print "Raw IMG"
+ is_raw = 1
+ elif img_type_byte3 == 1:
+ if img_type_byte0 == 0:
+ print "MD IMG:LTE"
+ is_raw = 1
+ is_md = 1
+ elif img_type_byte0 == 1:
+ print "MD IMG:C2K"
+ is_raw = 1
+ is_md = 2
+ else:
+ print "Not Raw Img"
+ is_raw = 0
+ return is_raw, is_md
+
+
+def gen_cert2_key(img_list, args, tmp_path):
+ """
+ generate private key for image signing
+ """
+ print "Start gen cert2 key to " + tmp_path.cert2_key_dir
+
+ print "clean up cert2_key_dir"
+ for old_file in os.listdir(tmp_path.cert2_key_dir):
+ os.remove(os.path.join(tmp_path.cert2_key_dir, old_file))
+
+ for img in img_list:
+ prvk = img + '_privk2.pem'
+ pubk = img + '_pubk2.pem'
+ final_prvk = os.path.join(tmp_path.cert2_key_dir, prvk)
+ final_pubk = os.path.join(tmp_path.cert2_key_dir, pubk)
+ if args['cert2_key_path'] == 'auto':
+ print "Gen(auto) " + prvk
+ lib.cert.rsa_key_gen(final_prvk, 2048)
+ else:
+ if lib.cert.is_prvk(args["cert2_key_path"]):
+ print "Gen " + prvk
+ shutil.copy2(args["cert2_key_path"], final_prvk)
+ elif lib.cert.is_pubk(args["cert2_key_path"]):
+ print "Gen " + pubk
+ shutil.copy2(args["cert2_key_path"], final_pubk)
+ else:
+ print 'Unknown key type: ignored'
+
+def img_name_to_part_name(img_name):
+ """
+ map image name to partition name
+ """
+ if re.match('md1rom', img_name):
+ part_name = 'md1img'
+ elif re.match('md3rom', img_name):
+ part_name = 'md3img'
+ else:
+ part_name = img_name
+
+ return part_name
+
+def gen_cert1(img_list, args, env, tmp_path):
+ """
+ generate key certificate
+ """
+
+ is_raw = 0
+ is_md = 0
+
+ print "clean up cert1_dir"
+ for old_file in os.listdir(tmp_path.cert1_dir):
+ os.remove(os.path.join(tmp_path.cert1_dir, old_file))
+
+ for img in img_list:
+ need_to_clear_pubk = False
+ cert2_prvk_path = os.path.join(tmp_path.cert2_key_dir, img + "_privk2.pem")
+ cert2_pubk_path = os.path.join(tmp_path.cert2_key_dir, img + "_pubk2.pem")
+
+ if not os.path.isfile(cert2_pubk_path):
+ need_to_clear_pubk = True
+ lib.cert.prvk_to_pubk(cert2_prvk_path, cert2_pubk_path)
+
+ img_ver, img_group = get_img_ver_group(img, env)
+ part_name = img_name_to_part_name(img)
+ is_raw, is_md = check_img_type(part_name, env)
+ print "img: " + str(img)
+ print "img_ver: " + str(img_ver)
+ print "img_group: " + str(img_group)
+ print "is_raw: " + str(is_raw)
+ print "is_md: " + str(is_md)
+ if is_md == 0:
+ if args["root_key_padding"]:
+ sign_obj = sign.Sign()
+ sign_obj.args['platform'] = args['platform']
+ sign_obj.args['project'] = args['project']
+ sign_obj.args['type'] = 'cert1'
+ sign_obj.args['img'] = ''
+ sign_obj.args['privk'] = args['cert1_key_path']
+ sign_obj.args['pubk'] = cert2_pubk_path
+ sign_obj.args['ver'] = str(img_ver)
+ sign_obj.args['group'] = str(img_group)
+ sign_obj.args['root_key_padding'] = str(args['root_key_padding'])
+ sign_obj.sign_op()
+ else:
+ sign_obj = sign.Sign()
+ sign_obj.args['platform'] = args['platform']
+ sign_obj.args['project'] = args['project']
+ sign_obj.args['type'] = 'cert1'
+ sign_obj.args['img'] = ''
+ sign_obj.args['privk'] = args['cert1_key_path']
+ sign_obj.args['pubk'] = cert2_pubk_path
+ sign_obj.args['ver'] = str(img_ver)
+ sign_obj.args['group'] = str(img_group)
+ sign_obj.sign_op()
+ tmp_cert1_out_path = tmp_path.out_cert1_path
+ else:
+ md_img = os.path.join(env.in_path, part_name + ".img")
+ if os.path.isfile(md_img):
+ print md_img + " exist"
+ if args["root_key_padding"]:
+ sign_obj = sign.Sign()
+ sign_obj.args['platform'] = args['platform']
+ sign_obj.args['project'] = args['project']
+ sign_obj.args['type'] = 'cert1md'
+ sign_obj.args['img'] = md_img
+ sign_obj.args['privk'] = args['cert1_key_path']
+ sign_obj.args['pubk'] = cert2_pubk_path
+ sign_obj.args['ver'] = str(img_ver)
+ sign_obj.args['group'] = str(img_group)
+ sign_obj.args['root_key_padding'] = str(args['root_key_padding'])
+ sign_obj.sign_op()
+ else:
+ sign_obj = sign.Sign()
+ sign_obj.args['platform'] = args['platform']
+ sign_obj.args['project'] = args['project']
+ sign_obj.args['type'] = 'cert1md'
+ sign_obj.args['img'] = md_img
+ sign_obj.args['privk'] = args['cert1_key_path']
+ sign_obj.args['pubk'] = cert2_pubk_path
+ sign_obj.args['ver'] = str(img_ver)
+ sign_obj.args['group'] = str(img_group)
+ sign_obj.sign_op()
+ tmp_cert1_out_path = tmp_path.out_cert1md_path
+ tmp_cert1_out_path = tmp_cert1_out_path.replace("${PACKAGE}", part_name)
+ else:
+ print md_img + " Not exist"
+ print"Bypass md image cert1 Gen!"
+ print img
+ cert1_path = os.path.join(tmp_path.cert1_dir, img + '_cert1.der')
+ print cert1_path
+ shutil.copy2(tmp_cert1_out_path, cert1_path)
+ if need_to_clear_pubk is True:
+ os.remove(cert2_pubk_path)
+ print "--------"
+
+def main():
+ """
+ main function, which is executed when this is executed from cmdline.
+ """
+ if len(sys.argv) < 4:
+ print "img_key_deploy.py <platform> <project>\
+cert1_key_path=<key_path> \
+cert2_key_path=<key_path> \
+root_key_padding=<padding_type>"
+ print "For security2.0:"
+ print " img_key_deploy.py mt6797 k97v1_64 \
+cert1_key_path=privk1.pem \
+cert2_key_path=privk2.pem"
+ print "For security2.1:"
+ print " img_key_deploy.py mt6799 k99v1_64 \
+cert1_key_path=privk1.pem \
+cert2_key_path=privk2.pem \
+root_key_padding=pss"
+ sys.exit()
+
+ args = parse_arg(sys.argv)
+
+ env, tmp_path = set_path(args)
+ create_folder(tmp_path)
+ img_list = get_img_list(env)
+
+ if args["cert2_key_path"] == 0:
+ print "cert2_key_path is not given!"
+ sys.exit()
+ else:
+ if os.path.isfile(args["cert2_key_path"]):
+ gen_cert2_key(img_list, args, tmp_path)
+ elif args['cert2_key_path'] == 'auto':
+ gen_cert2_key(img_list, args, tmp_path)
+ else:
+ print "cert2_key not exists, please check cert2 key path!"
+ sys.exit()
+
+ if args["cert1_key_path"] == 0:
+ print "cert1_key_path is not given!"
+ sys.exit()
+ else:
+ if os.path.isfile(args["cert1_key_path"]):
+ gen_cert1(img_list, args, env, tmp_path)
+ else:
+ print "cert1_key not exists, please check cert1 key path!"
+ sys.exit()
+
+ print "Gen pass!"
+ sys.exit()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.py
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.pyc
new file mode 100644
index 0000000..78b1f4b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/__init__.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/asn1_gen.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/asn1_gen.pyc
new file mode 100644
index 0000000..9a44921
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/asn1_gen.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/cert.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/cert.pyc
new file mode 100644
index 0000000..47ccfde
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/cert.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/dainfo.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/dainfo.pyc
new file mode 100644
index 0000000..a44a537
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/dainfo.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/getPublicKey.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/getPublicKey.pyc
new file mode 100644
index 0000000..fabfd53
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/getPublicKey.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/gfh.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/gfh.pyc
new file mode 100644
index 0000000..874bb08
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/gfh.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/hsm_hook.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/hsm_hook.pyc
new file mode 100644
index 0000000..cfb2019
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/hsm_hook.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/mkimghdr.pyc b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/mkimghdr.pyc
new file mode 100644
index 0000000..8040cf4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/lib/mkimghdr.pyc
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mdtool/getPublicKey b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mdtool/getPublicKey
new file mode 100644
index 0000000..03de7cc
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mdtool/getPublicKey
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/img_hdr.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/img_hdr.cfg
new file mode 100644
index 0000000..403d347
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/img_hdr.cfg
@@ -0,0 +1,7 @@
+LOAD_ADDR = 0x12345678
+LOAD_ADDR_H = 0x22345678
+#LOAD_MODE = 0
+NAME = test
+IMG_TYPE = 2
+IMG_LIST_END = 0
+ALIGN_SIZE = 16
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage
new file mode 100644
index 0000000..be602a3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage20.c b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage20.c
new file mode 100644
index 0000000..ef76fd5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/mkimage20/mkimage20.c
@@ -0,0 +1,326 @@
+/* Copyright Statement:
+ *
+ * This software/firmware and related documentation ("MediaTek Software") are
+ * protected under relevant copyright laws. The information contained herein
+ * is confidential and proprietary to MediaTek Inc. and/or its licensors.
+ * Without the prior written permission of MediaTek inc. and/or its licensors,
+ * any reproduction, modification, use or disclosure of MediaTek Software,
+ * and information contained herein, in whole or in part, shall be strictly prohibited.
+ */
+/* MediaTek Inc. (C) 2010. All rights reserved.
+ *
+ * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+ * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+ * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
+ * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+ * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+ * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+ * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
+ * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
+ * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
+ * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
+ * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+ * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
+ * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+ * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+ * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
+ * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+ *
+ * The following software/firmware and/or related documentation ("MediaTek Software")
+ * have been modified by MediaTek Inc. All revisions are subject to any receiver's
+ * applicable license agreements with MediaTek Inc.
+ */
+
+
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define IMG_MAGIC 0x58881688
+#define EXT_MAGIC 0x58891689
+
+#define IMG_NAME_SIZE 32
+#define IMG_HDR_SIZE 512
+
+/* image types */
+#define IMG_TYPE_ID_OFFSET (0)
+#define IMG_TYPE_RESERVED0_OFFSET (8)
+#define IMG_TYPE_RESERVED1_OFFSET (16)
+#define IMG_TYPE_GROUP_OFFSET (24)
+
+#define IMG_TYPE_ID_MASK (0xffU << IMG_TYPE_ID_OFFSET)
+#define IMG_TYPE_RESERVED0_MASK (0xffU << IMG_TYPE_RESERVED0_OFFSET)
+#define IMG_TYPE_RESERVED1_MASK (0xffU << IMG_TYPE_RESERVED1_OFFSET)
+#define IMG_TYPE_GROUP_MASK (0xffU << IMG_TYPE_GROUP_OFFSET)
+
+#define IMG_TYPE_GROUP_AP (0x00U << IMG_TYPE_GROUP_OFFSET)
+#define IMG_TYPE_GROUP_MD (0x01U << IMG_TYPE_GROUP_OFFSET)
+#define IMG_TYPE_GROUP_CERT (0x02U << IMG_TYPE_GROUP_OFFSET)
+
+/* AP group */
+#define IMG_TYPE_IMG_AP_BIN (0x00 | IMG_TYPE_GROUP_AP)
+
+/* MD group */
+#define IMG_TYPE_IMG_MD_LTE (0x00 | IMG_TYPE_GROUP_MD)
+#define IMG_TYPE_IMG_MD_C2K (0x01 | IMG_TYPE_GROUP_MD)
+
+/* CERT group */
+#define IMG_TYPE_CERT1 (0x00 | IMG_TYPE_GROUP_CERT)
+#define IMG_TYPE_CERT1_MD (0x01 | IMG_TYPE_GROUP_CERT)
+#define IMG_TYPE_CERT2 (0x02 | IMG_TYPE_GROUP_CERT)
+
+#define HDR_VERSION 1
+
+#define IMG_PATH_IDX 1
+#define IMG_CFG_IDX 2
+
+//#define DEBUG_MODE
+
+typedef union {
+ struct {
+ unsigned int magic; /* always IMG_MAGIC */
+ unsigned int
+ dsize; /* image size, image header and padding are not included */
+ char name[IMG_NAME_SIZE];
+ unsigned int maddr; /* image load address in RAM */
+ unsigned int mode; /* maddr is counted from the beginning or end of RAM */
+ /* extension */
+ unsigned int ext_magic; /* always EXT_MAGIC */
+ unsigned int
+ hdr_size; /* header size is 512 bytes currently, but may extend in the future */
+ unsigned int hdr_version; /* see HDR_VERSION */
+ unsigned int
+ img_type; /* please refer to #define beginning with IMG_TYPE_ */
+ unsigned int
+ img_list_end; /* end of image list? 0: this image is followed by another image 1: end */
+ unsigned int
+ align_size; /* image size alignment setting in bytes, 16 by default for AES encryption */
+ unsigned int
+ dsize_extend; /* high word of image size for 64 bit address support */
+ unsigned int
+ maddr_extend; /* high word of image load address in RAM for 64 bit address support */
+ } info;
+ unsigned char data[IMG_HDR_SIZE];
+} IMG_HDR_T;
+
+unsigned int filesize(char *name)
+{
+ struct stat statbuf;
+
+ if (stat(name, &statbuf) != 0) {
+ fprintf(stderr, "Cannot open file %s\n", name);
+ exit(0);
+ }
+ return statbuf.st_size;
+}
+
+char *readfile(char *name, unsigned int size)
+{
+ FILE *f;
+ char *buf = NULL;
+
+ f = fopen(name, "rb");
+ if (f == NULL) {
+ fprintf(stderr, "Cannot open file %s\n", name);
+ goto _end;
+ }
+
+ buf = (char *)malloc(size);
+ if (!buf) {
+ fprintf(stderr, "error while malloc(%d)\n", size);
+ goto _error;
+ }
+
+ if (fread(buf, 1, size, f) != size) {
+ fprintf(stderr, "Error while reading file %s\n", name);
+ free(buf);
+ buf = NULL;
+ goto _error;
+ }
+
+_error:
+ fclose(f);
+_end:
+ return buf;
+}
+
+char xtod(char c)
+{
+ if (c >= '0' && c <= '9') return c - '0';
+ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+ return 0;
+}
+
+unsigned long long hex2dec(char *hex, int l)
+{
+ if (*hex == 0)
+ return l;
+ return hex2dec(hex + 1, l * 16 + xtod(*hex));
+}
+
+unsigned long long xstr2int(char *hex)
+{
+ return hex2dec(hex, 0);
+}
+
+int remove_chr_from_string(char *string, char c)
+{
+ int final_str_len = 0;
+ final_str_len = strlen(string);
+ int i = 0;
+
+ while (i < final_str_len) {
+ if (string[i] == c) {
+ memmove(&string[i], &string[i + 1], final_str_len - i - 1);
+ final_str_len--;
+ string[final_str_len] = 0;
+ }
+ i++;
+ }
+
+ return 0;
+}
+
+int get_img_hdr_setting_from_cfg(const char *cfg_path, IMG_HDR_T *img_hdr)
+{
+#define MAX_LINE_LENGTH (80)
+ int ret = 0;
+ FILE *fp = NULL;
+ char line[MAX_LINE_LENGTH] = {0};
+
+ fp = fopen(cfg_path, "r");
+ if (NULL == fp) {
+ fprintf(stderr, "Cannot open file %s\n", cfg_path);
+ exit(0);
+ }
+
+ while (fgets(line, MAX_LINE_LENGTH, fp) != NULL) {
+ int i = 0;
+ char *obj_name = NULL;
+ char *obj_value_str = NULL;
+ unsigned int obj_value = 0;
+ ret = remove_chr_from_string(line, ' ');
+ ret = remove_chr_from_string(line, '\n');
+ obj_name = strtok(line, "=");
+ if (NULL == obj_name)
+ continue;
+ obj_value_str = strtok(NULL, "=");
+ if (NULL == obj_value_str || !strcmp(obj_name, "NAME"))
+ obj_value = 0;
+ else if (obj_value_str[0] == '0' && obj_value_str[1] == 'x')
+ obj_value = xstr2int(obj_value_str);
+ else
+ obj_value = atoi(obj_value_str);
+
+#ifdef DEBUG_MODE
+ fprintf(stderr, "name = %s, value_str = %s, value = %d\n", obj_name,
+ obj_value_str, obj_value);
+#endif
+
+ if (!strcmp(obj_name, "LOAD_ADDR"))
+ img_hdr->info.maddr = obj_value;
+ else if (!strcmp(obj_name, "LOAD_ADDR_H"))
+ img_hdr->info.maddr_extend = obj_value;
+ else if (!strcmp(obj_name, "LOAD_MODE"))
+ img_hdr->info.mode = obj_value;
+ else if (!strcmp(obj_name, "NAME"))
+ strncpy(img_hdr->info.name, obj_value_str, IMG_NAME_SIZE);
+ else if (!strcmp(obj_name, "IMG_TYPE"))
+ img_hdr->info.img_type = obj_value;
+ else if (!strcmp(obj_name, "IMG_LIST_END"))
+ img_hdr->info.img_list_end = obj_value;
+ else if (!strcmp(obj_name, "ALIGN_SIZE"))
+ img_hdr->info.align_size = obj_value;
+ else {
+#ifdef DEBUG_MODE
+ fprintf(stderr, "==> unknown object\n");
+#endif
+ }
+ }
+
+ fclose(fp);
+_end:
+ return ret;
+}
+
+int main(int argc, char *argv[])
+{
+ IMG_HDR_T img_hdr;
+ char *img = NULL;
+ char *img_padding = NULL;
+ uint32_t img_padding_size = 0;
+ int ret = 0;
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: ./mkimage <img_path> <cfg_path> > out_image\n");
+ return 0;
+ }
+
+ memset(&img_hdr, 0xff, sizeof(IMG_HDR_T));
+
+ /* legacy fields */
+ img_hdr.info.magic = IMG_MAGIC;
+ img_hdr.info.dsize = (unsigned int)(filesize(argv[IMG_PATH_IDX]) & 0xffffffff);
+ memset(img_hdr.info.name, 0x0, sizeof(img_hdr.info.name));
+ img_hdr.info.maddr = 0xffffffff;
+ img_hdr.info.mode = 0xffffffff;
+
+ /* extension fields */
+ img_hdr.info.ext_magic = EXT_MAGIC;
+ img_hdr.info.hdr_size = IMG_HDR_SIZE;
+ img_hdr.info.hdr_version = HDR_VERSION;
+ img_hdr.info.img_type = IMG_TYPE_IMG_AP_BIN;
+ img_hdr.info.img_list_end = 0;
+ img_hdr.info.align_size = 16;
+ img_hdr.info.dsize_extend = 0;
+ img_hdr.info.maddr_extend = 0;
+
+ /* if external config exists, use it to override */
+ /* add code here */
+ if (argc > IMG_CFG_IDX)
+ ret = get_img_hdr_setting_from_cfg(argv[IMG_CFG_IDX], &img_hdr);
+ if (ret)
+ goto _error;
+
+#ifdef DEBUG_MODE
+ {
+ int i = 0;
+ for (i = 0; i < 512; i++) {
+ fprintf(stderr, "%02x ", img_hdr.data[i]);
+ if ((i + 1) % 16 == 0)
+ fprintf(stderr, "\n");
+ }
+ }
+#endif
+
+ /* current implementation will encounter malloc fail issue if image size is extremely large */
+ img = readfile(argv[1], img_hdr.info.dsize);
+ img_padding_size = ((img_hdr.info.dsize + (img_hdr.info.align_size - 1)) /
+ img_hdr.info.align_size) * img_hdr.info.align_size - img_hdr.info.dsize;
+#ifdef DEBUG_MODE
+ fprintf(stderr, "img_padding_size = 0x%x\n", img_padding_size);
+#endif
+ img_padding = malloc(img_padding_size);
+ if (img_padding)
+ memset(img_padding, 0x0, img_padding_size);
+
+ /* for linux version mkimage, we only support this method */
+ write(STDOUT_FILENO, &img_hdr, sizeof(IMG_HDR_T));
+ write(STDOUT_FILENO, img, img_hdr.info.dsize);
+ write(STDOUT_FILENO, img_padding, img_padding_size);
+
+ return 0;
+_error:
+ free(img);
+ free(img_padding);
+ exit(1);
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/pbp.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/pbp.py
new file mode 100644
index 0000000..6ca7326
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/pbp.py
@@ -0,0 +1,367 @@
+"""
+pbp is a tool that signs/re-signs bootloader and generate data for root public key authentication.
+"""
+import os
+import shutil
+import argparse
+from lib import gfh
+from lib import cert
+
+
+def get_file_sizeb(file_path):
+ """
+ Get size of binary file
+ """
+ if not os.path.isfile(file_path):
+ return 0
+ file_handle = open(file_path, "rb")
+ file_handle.seek(0, 2)
+ file_size = file_handle.tell()
+ file_handle.close()
+ return file_size
+
+
+def concatb(file1_path, file2_path):
+ """
+ Concatenate binary files
+ """
+ file2_size = get_file_sizeb(file2_path)
+ file1 = open(file1_path, "ab+")
+ file2 = open(file2_path, "rb")
+ file1.write(file2.read(file2_size))
+ file2.close()
+ file1.close()
+
+
+class Bl(object):
+ """
+ Bl, which stands for preloader in Mediatek solution.
+ Mediatek preloader is loaded/verified by BootROM and its format is determined by BootROM
+ and is different from other images due to several reasons.
+ It has basic format as follows:
+ =======================
+ GFH
+ =======================
+ Preloader_NO_GFH.bin
+ =======================
+ Sig
+ =======================
+ Where Preloader_NO_GFH.bin is converted from preloader.elf.
+ """
+ def __init__(self, out_path, in_bootloader_file_path, out_bootloader_file_path):
+ self.m_gfh = gfh.ImageGFH()
+ self.m_out_path = out_path
+ if not os.path.exists(self.m_out_path):
+ os.makedirs(self.m_out_path)
+ self.m_in_bl_file_path = in_bootloader_file_path
+ self.m_out_bl_file_path = out_bootloader_file_path
+ self.m_bl_is_signed = False
+ self.m_bl_content_offset = 0
+ # initialize content size to bl file size
+ self.m_bl_content_length = get_file_sizeb(self.m_in_bl_file_path)
+ self.m_bl_sig_size = 0
+ # generate file path for bl without gfh and signature
+ bl_path = os.path.splitext(in_bootloader_file_path)
+ self.m_bl_no_gfh_file_path = bl_path[0] + "_plain.bin"
+ self.m_sig_ver = 0
+ self.m_sw_ver = 0
+ self.m_root_prvk_path = ""
+ self.m_img_prvk_path = ""
+ self.m_ac_key = 0
+ self.m_sig_handler = None
+
+ def is_signed(self):
+ """
+ GFH and signature are added after bootloader image has been processed by pbp.
+ We use this fact to determine whether bootloader image is signed.
+ """
+ if self.m_in_bl_file_path:
+ bl_file = open(self.m_in_bl_file_path, "rb")
+ gfh_hdr_obj = gfh.GFHHeader()
+ gfh_hdr_size = gfh_hdr_obj.get_size()
+ gfh_hdr_buf = bl_file.read(gfh_hdr_size)
+ self.m_bl_is_signed = gfh_hdr_obj.is_gfh(gfh_hdr_buf)
+ bl_file.close()
+ return self.m_bl_is_signed
+
+ def parse(self):
+ """
+ If image is signed, we remove GFH and signature. Removed GFH is parsed and
+ stored. Stored GFH will be used later if GFH ini file is not given.
+ """
+ print "===parse bootloader==="
+ # image will be decomposed if it's signed
+ if self.is_signed():
+ gfh_total_size = self.m_gfh.parse(self.m_in_bl_file_path)
+ self.m_bl_content_offset = gfh_total_size
+ self.m_bl_content_length -= gfh_total_size
+ self.m_bl_content_length -= self.m_gfh.get_sig_size()
+ self.m_bl_sig_size = self.m_gfh.get_sig_size()
+ in_file = open(self.m_in_bl_file_path, "rb")
+ out_file = open(self.m_bl_no_gfh_file_path, "wb")
+ in_file.seek(self.m_bl_content_offset)
+ out_file.write(in_file.read(self.m_bl_content_length))
+ out_file.close()
+ in_file.close()
+ else:
+ shutil.copyfile(self.m_in_bl_file_path, self.m_bl_no_gfh_file_path)
+ print "bootloader content size = " + hex(self.m_bl_content_length)
+
+ def create_gfh(self, gfh_config):
+ """
+ GFH creation. GFH may be created from parsed/stored GFH config or from GFH config file
+ provided by user.
+ """
+ self.parse()
+ if gfh_config:
+ if self.is_signed():
+ del self.m_gfh.gfhs[:]
+ self.m_gfh.load_ini(gfh_config)
+ elif not self.is_signed():
+ print "GFH_CONFIG.ini does not exist!!"
+ return -1
+ # self.m_gfh.dump()
+ return 0
+
+ def sign(self, key_ini_path, key_cert_path, content_config_file_path):
+ """
+ Sign bootloader according to its signature type, which is stored in GFH.
+ """
+ self.m_gfh.finalize(self.m_bl_content_length, key_ini_path)
+ # create tbs_bootloader.bin
+ tbs_bl_file_path = os.path.join(self.m_out_path, "tbs_preloader.bin")
+ tbs_bl_file = open(tbs_bl_file_path, "wb")
+ tbs_bl_file.write(self.m_gfh.pack())
+ bl_no_gfh_file = open(self.m_bl_no_gfh_file_path, "rb")
+ tbs_bl_file.write(bl_no_gfh_file.read(self.m_bl_content_length))
+ bl_no_gfh_file.close()
+ tbs_bl_file.close()
+ print "===sign==="
+ if self.m_gfh.get_sig_type() == "CERT_CHAIN":
+ self.m_sig_handler = cert.CertChainV2()
+ # create key cert if key cert does not exist
+ if key_cert_path == "":
+ key_cert_path = os.path.join(self.m_out_path, "key_cert.bin")
+ if not os.path.isfile(key_cert_path):
+ key_cert_file_name = os.path.basename(os.path.abspath(key_cert_path))
+ self.m_sig_handler.create_key_cert(key_ini_path,
+ self.m_out_path,
+ key_cert_file_name)
+ key_cert_path = os.path.join(self.m_out_path, key_cert_file_name)
+ else:
+ self.m_sig_handler.set_key_cert(key_cert_path)
+ # create content cert
+ content_cert_name = "content_cert.bin"
+ self.m_sig_handler.create_content_cert(content_config_file_path,
+ tbs_bl_file_path,
+ self.m_out_path,
+ content_cert_name)
+ # create final cert chain
+ sig_name = "preloader.sig"
+ sig_file_path = os.path.join(self.m_out_path, sig_name)
+ self.m_sig_handler.output(self.m_out_path, sig_name)
+ # output final cert chain size
+ sig_size_name = "sig_size.txt"
+ sig_size_file_path = os.path.join(self.m_out_path, sig_size_name)
+ sig_size_file = open(sig_size_file_path, 'w')
+ sig_size_file.write(hex(get_file_sizeb(sig_file_path)))
+ sig_size_file.close()
+ # create final preloader image
+ if os.path.isfile(self.m_out_bl_file_path):
+ os.remove(self.m_out_bl_file_path)
+ concatb(self.m_out_bl_file_path, tbs_bl_file_path)
+ concatb(self.m_out_bl_file_path, sig_file_path)
+ # clean up
+ os.remove(os.path.join(self.m_out_path, content_cert_name))
+ elif self.m_gfh.get_sig_type() == "SINGLE_AND_PHASH":
+ self.m_sig_handler = cert.SigSingleAndPhash(self.m_gfh.get_pad_type())
+ self.m_sig_handler.set_out_path(self.m_out_path)
+ self.m_sig_handler.create(key_ini_path, tbs_bl_file_path)
+ # signature generation
+ self.m_sig_handler.sign()
+ sig_name = "preloader.sig"
+ sig_file_path = os.path.join(self.m_out_path, sig_name)
+ self.m_sig_handler.output(self.m_out_path, sig_name)
+ # output signature size
+ sig_size_name = "sig_size.txt"
+ sig_size_file_path = os.path.join(self.m_out_path, sig_size_name)
+ sig_size_file = open(sig_size_file_path, 'w')
+ sig_size_file.write(hex(get_file_sizeb(sig_file_path)))
+ sig_size_file.close()
+ # create final preloader image
+ if os.path.isfile(self.m_out_bl_file_path):
+ os.remove(self.m_out_bl_file_path)
+ concatb(self.m_out_bl_file_path, tbs_bl_file_path)
+ concatb(self.m_out_bl_file_path, sig_file_path)
+ else:
+ print "unknown signature type"
+ # clean up
+ os.remove(self.m_bl_no_gfh_file_path)
+ os.remove(tbs_bl_file_path)
+ os.remove(sig_file_path)
+ return
+
+class PbpArgs(object):
+ """
+ PbpArgs is used to pass parameter to pbp.
+ This structure is both used when user executes this python script directly or imports
+ this module and use exported method.
+ """
+ def __init__(self):
+ self.op = None
+ self.padding = None
+ self.key_ini_path = None
+ self.key_path = None
+ self.gfh_cfg_ini_path = None
+ self.cnt_cfg_ini_path = None
+ self.key_cert_path = None
+ self.input_bl_path = None
+ self.tmp_output_path = None
+ self.output_path = None
+ def reset(self):
+ self.__init__()
+ def dump(self):
+ """
+ dump parameters.
+ """
+ f = lambda arg: 'Not Set' if arg is None else arg
+ print "op = " + f(self.op)
+ print "padding = " + f(self.padding)
+ print "key_ini_path = " + f(self.key_ini_path)
+ print "key_path = " + f(self.key_path)
+ print "gfh_cfg_ini_path = " + f(self.gfh_cfg_ini_path)
+ print "cnt_cfg_ini_path = " + f(self.cnt_cfg_ini_path)
+ print "key_cert_path = " + f(self.key_cert_path)
+ print "input_bl_path = " + f(self.input_bl_path)
+ print "tmp_output_path = " + f(self.tmp_output_path)
+ print "output_path = " + f(self.output_path)
+
+def _op_sign(args):
+ """
+ Sign/re-sign operation
+ """
+ bl_obj = Bl(args.tmp_output_path, args.input_bl_path, args.output_path)
+ bl_obj.create_gfh(args.gfh_cfg_ini_path)
+ bl_obj.sign(args.key_ini_path, args.key_cert_path, args.cnt_cfg_ini_path)
+ return 0
+
+def _op_keybin(args):
+ """
+ Generate root key data structure for root public key authentication.
+ """
+ key = cert.CtKey(args.padding)
+ key.create(args.key_path)
+ key_bin = key.pack()
+ out_file = open(args.output_path, "wb")
+ out_file.write(key_bin)
+ out_file.close()
+ return 0
+
+def _op_keybin_pss(args):
+ """
+ Root key data structures are different for different padding. Here we handles pss padding.
+ """
+ args.padding = 'pss'
+ return _op_keybin(args)
+
+def _op_keybin_legacy(args):
+ """
+ Root key data structures are different for different padding. Here we handles legacy padding.
+ """
+ args.padding = 'legacy'
+ return _op_keybin(args)
+
+def _op_keyhash(args):
+ """
+ Generate hash of root key data structure, which is dependent on padding used.
+ """
+ key = cert.CtKey(args.padding)
+ key.create(args.key_path)
+ key_bin = key.pack()
+ tmp_key_bin_path = os.path.join(args.tmp_output_path, "tmp_keybin.bin")
+ out_file = open(tmp_key_bin_path, "wb")
+ out_file.write(key_bin)
+ out_file.close()
+ cert.hash_gen(tmp_key_bin_path, args.output_path)
+ os.remove(tmp_key_bin_path)
+ return 0
+
+def _op_keyhash_pss(args):
+ """
+ Root key data struture hash for pss padding.
+ """
+ args.padding = 'pss'
+ return _op_keyhash(args)
+
+def _op_keyhash_legacy(args):
+ """
+ Root key data struture hash for legacy padding.
+ """
+ args.padding = 'legacy'
+ return _op_keyhash(args)
+
+def pbp_op(args):
+ """
+ Handles and dispatches all operations supported by pbp.
+ """
+ supported_ops = {
+ 'sign': _op_sign,
+ 'keybin_pss': _op_keybin_pss,
+ 'keybin_legacy': _op_keybin_legacy,
+ 'keyhash_pss': _op_keyhash_pss,
+ 'keyhash_legacy': _op_keyhash_legacy
+ }
+
+ if args.output_path is None:
+ print "output path is not given!"
+ return -1
+
+ if args.op is None:
+ print "op is not given!"
+ return -1
+
+ if args.op == 'sign':
+ if not args.input_bl_path:
+ print "bootloader path is not given!"
+ return -1
+ if (args.key_ini_path is None) and (args.key_cert_path is None):
+ print "key path is not given!"
+ return -1
+ else:
+ if (args.key_ini_path is None) and (args.key_path is None):
+ print "key path is not given!"
+ return -1
+
+ args.tmp_output_path = os.path.dirname(os.path.abspath(args.output_path))
+ if not os.path.exists(args.tmp_output_path):
+ os.makedirs(args.tmp_output_path)
+
+ op_f = supported_ops.get(args.op)
+ return op_f(args)
+
+
+def main():
+ """
+ Main function for pbp, which is used when pbp.py is executed directly.
+ Note that we changed input bootloader parameter to -in_bl $BL_PATH.
+ Please remember to add -in_bl if you're migrating from previous version.
+ """
+ parser = argparse.ArgumentParser(description='pbp tool for preloader gfh \
+creation/replacement and signing/re-signing')
+ parser.add_argument('-i', dest='key_ini_path', help='key configuartion path')
+ parser.add_argument('-j', dest='key_path', help='key path (with pem format)')
+ parser.add_argument('-g', dest='gfh_cfg_ini_path', help='gfh(generaic file header) \
+configuration path')
+ parser.add_argument('-c', dest='cnt_cfg_ini_path', help='content certificate \
+configuration path')
+ parser.add_argument('-k', dest='key_cert_path', help='key certificate path')
+ parser.add_argument('-func', dest='op', help='operation to be performed', required=True)
+ parser.add_argument('-o', dest='output_path', help='output file path')
+ parser.add_argument('input_bl_path', nargs='?', help='input file path')
+
+ pbp_args = parser.parse_args()
+ return pbp_op(pbp_args)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign.py
new file mode 100644
index 0000000..47c86af
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign.py
@@ -0,0 +1,1132 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+"""
+This module supports image signing, including single bin and multi bin.
+Multi bin means a composite image composed of multiple sub-images.
+"""
+import sys
+import os
+import struct
+import re
+import subprocess
+import ntpath
+import shutil
+import stat
+import lib.mkimghdr
+import lib.getPublicKey
+import lib.cert
+import cert_gen
+
+CERT1_REPLACE_TARGET = r"(\s)*pubk2"
+CERT2_REPLACE_HASH = r"(\s)*imgHash EXTERNAL_BITSTRING"
+CERT2_REPLACE_HEADER_HASH = r"(\s)*imgHdrHash EXTERNAL_BITSTRING"
+CERT2_REPLACE_IMG_HASH_MULTI = r"(\s)*imgHash_Multi EXTERNAL_BITSTRING"
+CERT2_REPLACE_SOCID = r"(\s)*socid PRINTABLESTRING"
+CERT1MD_REPLACE_TARGET = r"(\s)*pubkHash EXTERNAL_BITSTRING"
+SW_ID_REPLACE_TARGET = r"(\s)*swID INTEGER"
+IMG_VER_REPLACE_TARGET = r"(\s)*imgVer INTEGER"
+IMG_GROUP_REPLACE_TARGET = r"(\s)*imgGroup INTEGER"
+MKIMAGE_HDR_MAGIC = 0x58881688
+MKIMAGE_HDR_FMT = "<2I 32s 2I 8I"
+BOOTIMG_HDR_MAGIC = "ANDROID"
+BOOTIMG_HDR_FMT = "<8c 10I 16c 512c 8I 1024c I Q I I Q"
+CCCI_HDR_FMT = "<8c 10I 16c 512c 8I"
+DTBO_HDR_MAGIC = 0xD7B7AB1E
+DTBO_HDR_FMT = ">8I"
+
+class Sign(object):
+ """
+ Sign is used to pass parameter to module 'sign'.
+ """
+ def __init__(self):
+ """
+ initialization of arguments
+ """
+ self.args = {}
+ self.context = {}
+
+ self.args['type'] = 0
+ self.args['img'] = 0
+ self.args['privk'] = 0
+ self.args['pubk'] = 0
+ self.args['cert1'] = 0
+ self.args['swID'] = 0
+ self.args['ver'] = 0
+ self.args['name'] = ''
+ self.args['group'] = 0
+ self.args['root_key_padding'] = 0
+ self.args['getHashList'] = 0
+ self.args['platform'] = 'NOT_SET'
+ self.args['project'] = 'NOT_SET'
+ self.args['env_cfg'] = os.path.join(os.path.dirname(__file__), \
+ 'env.cfg')
+ self.args['socid'] = '0'
+
+ return
+
+ def reset(self):
+ """
+ reset all arguments
+ """
+ self.__init__()
+
+ def get_arg(self, field_name):
+ """
+ get value of field and returns 'NOT_SET' if it's not defined
+ """
+ try:
+ return self.args[field_name]
+ except KeyError, error:
+ print 'KeyError: ' + str(error)
+ return 'NOT_SET'
+
+ def set_context(self):
+ """
+ Set temporary path for certificate generation.
+ """
+ img_name = self.args['name']
+ if self.args['img'] != 0:
+ package_name = os.path.splitext(os.path.basename(self.args['img']))[0]
+ else:
+ package_name = ''
+
+ print '=============================='
+ print 'env_cfg parsing'
+ print '=============================='
+ cfg_file = open(self.args['env_cfg'], 'r')
+ cfg_file_dir = os.path.dirname(os.path.abspath(self.args['env_cfg']))
+ for line in cfg_file.readlines():
+ line = line.strip()
+ if line:
+ elements = line.split('=')
+ field = elements[0].strip()
+ value = elements[1].strip()
+ value = value.replace("${PLATFORM}", self.get_arg('platform'))
+ value = value.replace("${PROJECT}", self.get_arg('project'))
+ if field == 'out_path':
+ self.context['out'] = os.environ.get('PRODUCT_OUT')
+ if self.context['out'] is None:
+ print 'Use out path in env.cfg'
+ self.context['out'] = os.path.join(cfg_file_dir, value)
+ else:
+ print 'Use out path in Android'
+ self.context['out_path'] = os.path.join(self.context['out'], "resign")
+ elif field == 'x509_template_path':
+ x509_template_path = os.path.join(cfg_file_dir, value)
+ elif field == 'mkimage_tool_path':
+ mkimage_tool_path = os.path.join(cfg_file_dir, value)
+ else:
+ print 'ignored: ' + field
+ print '=============================='
+
+ self.context['bin_path'] = os.path.join(self.context['out_path'], "bin")
+ self.context['tmpcert_name'] = os.path.join(self.context['out_path'], \
+ "cert", \
+ package_name, \
+ img_name, \
+ "tmp.der")
+
+ #tool path
+ mkimage_config = os.path.join(mkimage_tool_path, "img_hdr.cfg")
+ cert_out = os.path.join(self.context['out_path'], "cert", package_name, img_name)
+
+ self.context['mkimage_config'] = mkimage_config
+
+ mkimage_config_out = ""
+ if self.args['type'] == "cert1md":
+ cert1md_tmp = os.path.join(cert_out, "cert1md", "intermediate")
+ cert1md_name = os.path.join(cert_out, "cert1md", "cert1md.der")
+ cert1md_hash_path = os.path.join(cert1md_tmp, "hash")
+ cert1md_config = os.path.join(x509_template_path, "cert1md.cfg")
+ cert1md_config_out = os.path.join(cert1md_tmp, "cert1md.cfg")
+ mkimage_config_out = os.path.join(cert1md_tmp, "img_hdr.cfg")
+ self.context['cert1md_name'] = cert1md_name
+ self.context['cert1md_config'] = cert1md_config
+ self.context['cert1md_config_out'] = cert1md_config_out
+ self.context['cert1md_hash_path'] = cert1md_hash_path
+ elif self.args['type'] == "cert1":
+ cert1_tmp = os.path.join(cert_out, "cert1", "intermediate")
+ cert1_name = os.path.join(cert_out, "cert1", "cert1.der")
+ cert1_config = os.path.join(x509_template_path, "cert1.cfg")
+ cert1_config_out = os.path.join(cert1_tmp, "cert1.cfg")
+ mkimage_config_out = os.path.join(cert1_tmp, "img_hdr.cfg")
+ self.context['cert1_name'] = cert1_name
+ self.context['cert1_config'] = cert1_config
+ self.context['cert1_config_out'] = cert1_config_out
+ elif self.args['type'] == "cert2":
+ cert2_tmp = os.path.join(cert_out, "cert2", "intermediate")
+ cert2_name = os.path.join(cert_out, "cert2", "cert2.der")
+ cert2_hash_path = os.path.join(cert2_tmp, "hash")
+ cert2_config = os.path.join(x509_template_path, "cert2.cfg")
+ cert2_config_out = os.path.join(cert2_tmp, "cert2.cfg")
+ dm_cert = os.path.join(cert2_tmp, "dm_cert.der")
+ bin_tmp_path = os.path.join(cert2_tmp, "tmp_bin")
+ sig_path = os.path.join(self.context['out'], "sig", package_name)
+ mkimage_config_out = os.path.join(cert2_tmp, "img_hdr.cfg")
+ self.context['bin_tmp_path'] = bin_tmp_path
+ self.context['cert2_name'] = cert2_name
+ self.context['cert2_config'] = cert2_config
+ self.context['cert2_config_out'] = cert2_config_out
+ self.context['cert2_hash_path'] = cert2_hash_path
+ self.context['dm_cert'] = dm_cert
+ self.context['sig_path'] = sig_path
+
+ self.context['mkimage_config_out'] = mkimage_config_out
+ return
+
+ def __create_out_dir(self, path):
+ """
+ create output folder
+ """
+ dir_path = os.path.dirname(path)
+ print "Create dir:" + dir_path
+
+ try:
+ os.makedirs(dir_path)
+ except OSError, error:
+ if error.errno != os.errno.EEXIST:
+ raise
+
+ def __create_abs_dir(self, path):
+ """
+ create output folder based on absolute path
+ """
+ dir_path = os.path.abspath(path)
+ print "Create dir:" + dir_path
+
+ try:
+ os.makedirs(dir_path)
+ except OSError, error:
+ if error.errno != os.errno.EEXIST:
+ raise
+
+ def __create_folder(self):
+ """
+ Create output folder for certificate generation.
+ """
+ mkimage_config_out = self.context['mkimage_config_out']
+ bin_path = self.context['bin_path']
+
+ self.__create_out_dir(mkimage_config_out)
+ self.__create_abs_dir(bin_path)
+
+ if self.args['type'] == "cert1md":
+ cert1md_name = self.context['cert1md_name']
+ cert1md_hash_path = self.context['cert1md_hash_path']
+ self.__create_out_dir(cert1md_name)
+ self.__create_abs_dir(cert1md_hash_path)
+ elif self.args['type'] == "cert1":
+ cert1_name = self.context['cert1_name']
+ cert1_config_out = self.context['cert1_config_out']
+ self.__create_out_dir(cert1_name)
+ self.__create_out_dir(cert1_config_out)
+ elif self.args['type'] == "cert2":
+ cert2_name = self.context['cert2_name']
+ cert2_hash_path = self.context['cert2_hash_path']
+ sig_path = self.context['sig_path']
+ bin_tmp_path = self.context['bin_tmp_path']
+ self.__create_out_dir(cert2_name)
+ self.__create_abs_dir(cert2_hash_path)
+ self.__create_abs_dir(sig_path)
+ self.__create_abs_dir(bin_tmp_path)
+ return
+
+ def gen_cert(self, cert_config, privk_key, cert_der, root_key_padding):
+ """
+ Generate certificate based on the configuration given.
+ """
+ cert_gen_args = cert_gen.CertGenArgs()
+ cert_gen_args.config_file = cert_config
+ cert_gen_args.prvk_file_path = privk_key
+ #root key padding will be set to 'legacy' by default
+ if root_key_padding != 0:
+ cert_gen_args.root_key_padding = root_key_padding
+ cert_gen_args.x509cert_file = cert_der
+ cert_gen.cert_gen_op(cert_gen_args)
+
+ def gen_cert1(self):
+ """
+ Generate cert1, which is key certificate for images
+ other than modem image.
+ """
+ cert1_config = self.context['cert1_config']
+ cert1_config_out = self.context['cert1_config_out']
+ #copy cert1 config
+ shutil.copy2(cert1_config, cert1_config_out)
+ sw_id = self.args['swID']
+ img_ver = self.args['ver']
+ img_group = self.args['group']
+
+ cert1_name = self.context['cert1_name']
+
+ if self.args['root_key_padding'] == 0:
+ root_key_padding = 'legacy'
+ else:
+ root_key_padding = self.args['root_key_padding']
+ print "root_key_padding = " + root_key_padding
+
+ if int(sw_id) != 0:
+ fill_cert_config(cert1_config_out, sw_id, SW_ID_REPLACE_TARGET)
+ if int(img_ver) != 0:
+ fill_cert_config(cert1_config_out, img_ver, IMG_VER_REPLACE_TARGET)
+ if int(img_group) != 0:
+ fill_cert_config(cert1_config_out, img_group, IMG_GROUP_REPLACE_TARGET)
+
+ fill_cert_config(cert1_config_out, self.args['pubk'], CERT1_REPLACE_TARGET)
+ #gen cert
+ self.gen_cert(cert1_config_out, \
+ self.args['privk'], \
+ cert1_name, \
+ root_key_padding)
+ cert1_img_type = 0x2 << 24
+ add_mkimg_header(cert1_name, 0, cert1_img_type, "cert1", self.context)
+ print "output path:" + cert1_name
+ return
+
+ def gen_cert1md(self):
+ """
+ Generate cert1md, which is key certificate for modem image.
+ """
+ img_file = self.args['img']
+ cert_privk = self.args['privk']
+ cert1md_hash_path = self.context['cert1md_hash_path']
+ cert1md_config = self.context['cert1md_config']
+ cert1md_config_out = self.context['cert1md_config_out']
+
+ if self.args['root_key_padding'] == 0:
+ root_key_padding = 'legacy'
+ else:
+ root_key_padding = self.args['root_key_padding']
+ print "root_key_padding = " + root_key_padding
+
+ print img_file
+ #check is Raw
+ is_raw, is_md, hdr_size = check_is_raw(img_file)
+
+ if is_raw == 0:
+ print "Is not raw image"
+ return
+
+ if is_md < 1:
+ print "Wrong MD image type"
+ return
+
+ cert1md_name = self.context['cert1md_name']
+
+ #SV5 Image(MD)
+ split_header, split_image = img_split(img_file, cert1md_hash_path, hdr_size)
+ key_hash_tmp = os.path.join(cert1md_hash_path, "key_tmp.hash")
+ key_hash = os.path.join(cert1md_hash_path, "key.hash")
+ header_hash = os.path.join(cert1md_hash_path, "header.hash")
+
+ #get md key
+ md_key = get_md_key(split_image, is_md, self.context)
+ #gen header hash
+ lib.cert.hash_gen(split_header, header_hash)
+ #gen key hash
+ lib.cert.hash_gen(md_key, key_hash_tmp)
+ #Endiness conversion
+ endiness_convert(key_hash_tmp, key_hash)
+
+ #fill config
+ shutil.copy2(cert1md_config, cert1md_config_out)
+ fill_cert_config(cert1md_config_out, key_hash, CERT1MD_REPLACE_TARGET)
+ fill_cert_config(cert1md_config_out, self.args['pubk'], CERT1_REPLACE_TARGET)
+
+ sw_id = self.args['swID']
+ img_ver = self.args['ver']
+ img_group = self.args['group']
+ if int(sw_id) != 0:
+ fill_cert_config(cert1md_config_out, sw_id, SW_ID_REPLACE_TARGET)
+ if int(img_ver) != 0:
+ fill_cert_config(cert1md_config_out, img_ver, IMG_VER_REPLACE_TARGET)
+ if int(img_group) != 0:
+ fill_cert_config(cert1md_config_out, img_group, IMG_GROUP_REPLACE_TARGET)
+ #gen cert
+ self.gen_cert(cert1md_config_out, cert_privk, cert1md_name, root_key_padding)
+ #add mkimage header on cert1md
+
+ cert1md_img_type = 0x2 << 24 | 0x1
+ add_mkimg_header(cert1md_name, 0, cert1md_img_type, "cert1md", self.context)
+ print "output path:" + cert1md_name
+
+ def gen_cert2(self):
+ """
+ Generate cert2, which is content certificate.
+ """
+ img_file = self.args['img']
+ cert1 = self.args['cert1']
+ cert_privk = self.args['privk']
+ img_name = self.args['name']
+ img_ver = self.args['ver']
+ socid = self.args['socid']
+ is_img_hash_list = 0
+ is_raw = 0
+ is_boot = 0
+ is_dtbo = 0
+
+ if self.get_arg('getHashList') is '1':
+ is_img_hash_list = 1
+
+ img_array = []
+ size_array = []
+ offset_array = []
+ img_name_array = []
+
+ bin_path = self.context['bin_path']
+ bin_tmp_path = self.context['bin_tmp_path']
+ cert2_name = self.context['cert2_name']
+ cert2_config = self.context['cert2_config']
+ cert2_config_out = self.context['cert2_config_out']
+ cert2_hash_path = self.context['cert2_hash_path']
+ dm_cert = self.context['dm_cert']
+ sig_path = self.context['sig_path']
+ out = self.context['out']
+
+ is_raw, is_md, hdr_size = check_is_raw(img_file)
+ if not is_raw:
+ is_boot, boot_img_size, hdr_size = check_is_boot(img_file)
+
+ if is_boot:
+ has_dm_cert = get_vboot10_cert(img_file, boot_img_size, self.context)
+
+ if (not is_raw) and (not is_boot):
+ is_dtbo, dtbo_img_size, hdr_size = check_is_dtbo(img_file)
+
+ if is_raw:
+ img_array, \
+ size_array, \
+ offset_array, \
+ img_name_array = parse_multi_bin(img_file, img_name, self.context)
+ if img_array is None:
+ return
+ elif is_boot:
+ img_array.append(os.path.join(bin_tmp_path, "tmp.bin"))
+ size_array.append(boot_img_size)
+ offset_array.append(0)
+ img_name_array.append(img_name)
+ elif is_dtbo:
+ img_array.append(os.path.join(bin_tmp_path, "tmp.bin"))
+ size_array.append(dtbo_img_size)
+ offset_array.append(0)
+ img_name_array.append(img_name)
+ elif not is_img_hash_list:
+ print "wrong image format"
+ return
+
+ if is_img_hash_list:
+ print "get pure image hash..."
+ self.gen_img_hash_list(img_file, cert1, cert_privk, img_name, img_ver)
+ return
+
+ get_pure_img(img_file, img_array, size_array, offset_array)
+ print "bin_number:" + str(len(img_array))
+ #Get hash from image
+ i = 0
+ img_list_end = 0
+ for img in img_array:
+ if i == len(img_array) - 1:
+ img_list_end = 1
+
+ if is_raw == 1 or is_boot == 1 or is_md == 1 or is_md == 2 or is_dtbo:
+ #Raw Image
+ if img_name_array[i] == img_name:
+ split_header, split_image = img_split(img, cert2_hash_path, hdr_size)
+
+ image_hash = os.path.join(cert2_hash_path, "image.hash")
+ header_hash = os.path.join(cert2_hash_path, "header.hash")
+
+ #gen header hash
+ lib.cert.hash_gen(split_header, header_hash)
+ #gen image hash
+ lib.cert.hash_gen(split_image, image_hash)
+
+ #if exist DM cert, append it after hash calculate
+ if is_boot == 1 and has_dm_cert == 1:
+ append_file(img, dm_cert)
+
+ #cat cert1
+ append_file(img, cert1)
+
+ #fill cert2 config
+ shutil.copy2(cert2_config, cert2_config_out)
+ fill_cert_config(cert2_config_out, image_hash, CERT2_REPLACE_HASH)
+ fill_cert_config(cert2_config_out, header_hash, CERT2_REPLACE_HEADER_HASH)
+ fill_cert_config(cert2_config_out, socid.upper(), CERT2_REPLACE_SOCID)
+
+ if int(img_ver) != 0:
+ fill_cert_config(cert2_config_out, img_ver, IMG_VER_REPLACE_TARGET)
+ #gen cert2
+ self.gen_cert(cert2_config_out, cert_privk, cert2_name, 0)
+ #add mkimage header on cert2
+ cert2_img_type = 0x2 << 24 | 0x2
+ add_mkimg_header(cert2_name, \
+ img_list_end, \
+ cert2_img_type, \
+ "cert2", \
+ self.context)
+ #cat cert2
+ append_file(img, cert2_name)
+ #cat sig file
+ sig_file = os.path.join(sig_path, img_name + ".sig")
+ print img_ver
+ print "sig:" + sig_file
+ shutil.copy2(cert1, sig_file)
+ append_file(sig_file, cert2_name)
+
+ i += 1
+
+ img_name = ntpath.split(img_file)[1]
+ img_name = img_name.split(".")[0] + "-verified." + img_name.split(".")[1]
+ final_bin = os.path.join(bin_tmp_path, img_name)
+
+ #cat all bin to img_array[0]
+ cat_img(img_array, final_bin)
+
+ #Post Process
+ shutil.copy2(final_bin, os.path.join(bin_path, img_name))
+ shutil.copy2(os.path.join(bin_path, img_name), os.path.join(out, img_name))
+ print "output path:" + os.path.join(out, img_name)
+ return
+
+ def gen_img_hash_list(self, img_file, cert1, cert_privk, img_name, img_ver):
+ """
+ Generate image hash list. This is a verified boot mechanism
+ for images that are too big to fit into DRAM at once. In this
+ case, image is split into 128MB chunks and sent to DA one by one.
+ DA will receive a signed image hash list and verifies it before
+ flashing. After that, DA will calculate hash on receiving a chunk
+ and compares it against the hash in signed image hash list.
+ """
+ data_size = 128 * 1048576
+
+ img_size = os.path.getsize(img_file)
+ print "img_size => "+ str(img_size)
+ file1 = open(img_file, 'rb')
+ package_num = (img_size + (data_size - 1)) / data_size
+ print "package_num => "+ str(package_num)
+ print "get " + img_name + " hash list..."
+
+ bin_tmp_path = self.context['bin_tmp_path']
+ cert2_name = self.context['cert2_name']
+ cert2_config = self.context['cert2_config']
+ cert2_config_out = self.context['cert2_config_out']
+ cert2_hash_path = self.context['cert2_hash_path']
+ sig_path = self.context['sig_path']
+ out = self.context['out']
+
+ for i in range(package_num):
+ div_out = os.path.join(bin_tmp_path, img_name + "_" + str(i) + ".bin")
+ div_hash_out = os.path.join(cert2_hash_path, img_name + "_" + str(i) + ".hash")
+ output_file = open(div_out, 'wb')
+ content = file1.read(data_size)
+ output_file.write(content)
+ output_file.close()
+ lib.cert.hash_gen(div_out, div_hash_out)
+ file1.close()
+
+ img_hash_file = os.path.join(cert2_hash_path, img_name + "_total.hash")
+ file2 = open(img_hash_file, 'wb')
+ for i in range(package_num):
+ hash_file = open(os.path.join(cert2_hash_path, img_name + "_" + str(i) + ".hash"), 'rb')
+ img_hash = hash_file.read()
+ file2.write(img_hash)
+ file2.close()
+
+ shutil.copy2(cert2_config, cert2_config_out)
+
+ fill_cert_config(cert2_config_out, img_hash_file, CERT2_REPLACE_IMG_HASH_MULTI)
+ if int(img_ver) != 0:
+ fill_cert_config(cert2_config_out, img_ver, IMG_VER_REPLACE_TARGET)
+ #gen cert2
+ self.gen_cert(cert2_config_out, cert_privk, cert2_name, 0)
+ img_list_end = 1
+ #add mkimage header on cert2
+ cert2_img_type = 0x2 << 24 | 0x2
+ add_mkimg_header(cert2_name, img_list_end, cert2_img_type, "cert2", self.context)
+ sig_file = os.path.join(sig_path, img_name + ".sig")
+ shutil.copy2(cert1, sig_file)
+ append_file(sig_file, cert2_name)
+ shutil.copy2(sig_file, os.path.join(out, img_name + ".sig"))
+
+ return
+
+ def sign_op(self):
+ """
+ perform image signing
+ """
+ self.set_context()
+
+ if self.args['type'] == "cert1":
+ self.__create_folder()
+ self.gen_cert1()
+ elif self.args['type'] == "cert2":
+ self.__create_folder()
+ self.gen_cert2()
+ elif self.args['type'] == "cert1md":
+ self.__create_folder()
+ self.gen_cert1md()
+ else:
+ print "wrong cert type !"
+
+ return
+
+ def dump(self):
+ """
+ dump parameters
+ """
+ print 'cert_type = ' + self.get_arg(self.args['type'])
+ print 'platform = ' + self.get_arg(self.args['platform'])
+ print 'project = ' + self.get_arg(self.args['project'])
+ print 'img = ' + self.get_arg(self.args['img'])
+ print 'name = ' + self.get_arg(self.args['name'])
+ print 'cert1_path = ' + self.get_arg(self.args['cert1'])
+ print 'root_prvk = ' + self.get_arg(self.args['privk'])
+ print 'img_pubk = ' + self.get_arg(self.args['pubk'])
+ print 'group = ' + self.get_arg(self.args['group'])
+ print 'ver = ' + self.get_arg(self.args['ver'])
+ print 'root_padding = ' + self.get_arg(self.args['root_key_padding'])
+ print 'getHashList = ' + self.get_arg(self.args['getHashList'])
+ print 'env_cfg = ' + self.get_arg(self.args['env_cfg'])
+ return
+
+def parse_multi_bin(img_file, target_img_name, context):
+ """
+ we may concatenate multiple images to form a composite image.
+ This function is used to parse the composite image to get
+ information of sub-image with name target_img_name.
+ """
+ #parse bin
+ img_size = 0
+ index = 0
+ file1 = open(img_file, 'rb')
+ last_pos = 0
+ pre_pos = 0
+
+ img_array = []
+ size_array = []
+ offset_array = []
+ img_name_array = []
+
+ file_size = os.path.getsize(img_file)
+ print "file_size: "+ str(hex(file_size))
+
+ first_img = 1
+ final_size = 0
+ match_target = 0
+ img_name = 0
+
+ bin_tmp_path = context['bin_tmp_path']
+
+ while True:
+ file1.seek(last_pos)
+ header_size = struct.calcsize(MKIMAGE_HDR_FMT)
+ fin = file1.read(header_size)
+ unpack_array = struct.unpack(MKIMAGE_HDR_FMT, fin)
+ file1.seek(last_pos)
+
+ magic_number = unpack_array[0]
+ dsize = unpack_array[1]
+ hdr_size = unpack_array[6]
+ align_size = unpack_array[10]
+ img_type = unpack_array[8]
+
+ if ~cmp(magic_number, int(MKIMAGE_HDR_MAGIC)) == 0:
+ print "wrong image header magic"
+ sys.exit()
+
+ # include header + image + padding size to 16 bytes align
+ img_size = (dsize + hdr_size + (align_size - 1)) / align_size * align_size
+ print "img-" + str(index) + " size:" + hex(img_size)
+
+ img_type_byte3 = (img_type >> 24) & 0xFF
+
+ if img_type_byte3 != 2:
+ # image not cert
+ pre_img_name = img_name
+ img_name = unpack_array[2].rstrip('\t\r\n\0')
+ if target_img_name == img_name:
+ print "Target image, remove cert for replace"
+ is_target = 1
+ match_target = 1
+ else:
+ print "Not target image, retain cert"
+ is_target = 0
+ is_raw = 1
+ else:
+ #image is cert
+ is_raw = 0
+
+ if is_raw and first_img == 0:
+ print "add index" + str(index) + " image"
+ img_str = os.path.join(bin_tmp_path, "tmp_" + str(index) + ".bin")
+ img_array.append(img_str)
+ size_array.append(final_size)
+ offset_array.append(pre_pos)
+ img_name_array.append(pre_img_name)
+ pre_pos = last_pos
+ final_size = 0
+ index += 1
+
+ first_img = 0
+
+ if is_target:
+ if is_raw:
+ final_size = img_size
+ else:
+ print "is cert, discard it"
+ else:
+ final_size += img_size
+
+ last_pos += img_size
+
+ if last_pos >= file_size:
+ print "add index" + str(index) + " image, this is final image"
+ img_str = os.path.join(bin_tmp_path, "tmp_" + str(index) + ".bin")
+ img_array.append(img_str)
+ size_array.append(final_size)
+ offset_array.append(pre_pos)
+ img_name_array.append(img_name)
+ pre_pos = last_pos
+ final_size = 0
+ break
+
+ file1.close()
+ if match_target == 0:
+ print "img name not match,exit!!"
+ return None, None, None, None
+ return img_array, size_array, offset_array, img_name_array
+
+def check_is_raw(img_file):
+ """
+ check whether image is raw image format, which includes
+ images with mkimage header and modem image.
+ """
+ is_raw = 0
+ is_md = 0
+ print img_file
+ file1 = open(img_file, 'rb')
+ header_size = struct.calcsize(MKIMAGE_HDR_FMT)
+ fin = file1.read(header_size)
+
+ unpack_array = struct.unpack(MKIMAGE_HDR_FMT, fin)
+ file1.close()
+
+ hdr_size = unpack_array[6]
+ img_type = unpack_array[8]
+
+ if cmp(unpack_array[0], int(MKIMAGE_HDR_MAGIC)) == 0:
+ img_type_byte0 = img_type & 0xFF
+ img_type_byte3 = (img_type >> 24) & 0xFF
+
+ if img_type == 0:
+ print "Raw IMG"
+ is_raw = 1
+ elif img_type_byte3 == 1:
+ if img_type_byte0 == 0:
+ print "MD IMG:LTE"
+ is_raw = 1
+ is_md = 1
+ elif img_type_byte0 == 1:
+ print "MD IMG:C2K"
+ is_raw = 1
+ is_md = 2
+ else:
+ print "Not Raw Img"
+ is_raw = 0
+ return is_raw, is_md, hdr_size
+
+def get_vboot10_cert(img_file, img_size, context):
+ """
+ parse certificate that follows boot image on vboot1.0
+ """
+ has_dm_cert = 0
+ dm_cert = context['dm_cert']
+ file_size = os.path.getsize(img_file)
+ if file_size <= img_size + 4:
+ return has_dm_cert
+
+ file1 = open(img_file, 'rb')
+ fin = file1.read(img_size)
+ fin = file1.read(4)
+
+ unpack_array = struct.unpack("<4c", fin)
+
+ if ord(unpack_array[0]) == 0x30:
+ cert_size = (ord(unpack_array[2]) << 8) + ord(unpack_array[3]) + 4
+ print hex(cert_size)
+ file2 = open(dm_cert, 'wb')
+ file1.seek(img_size)
+ file2.write(file1.read(cert_size))
+ file2.close()
+ has_dm_cert = 1
+ padding_file(dm_cert, 16)
+ file1.close()
+ return has_dm_cert
+
+
+def check_is_md(img_file):
+ """
+ check whether it's modem image.
+ """
+ #parse bin
+ file1 = open(img_file, 'rb')
+ header_size = struct.calcsize(CCCI_HDR_FMT)
+ fin = file1.read(header_size)
+ unpack_array = struct.unpack(CCCI_HDR_FMT, fin)
+ file1.close()
+ magic_str = ""
+ for i in range(0, 7):
+ magic_str = magic_str + unpack_array[i]
+ return 0
+
+def check_is_boot(img_file):
+ """
+ check whether it's boot/recovery image.
+ """
+ #parse bin
+ img_size = 0
+ is_boot = 0
+ hdr_size = 0
+
+ file1 = open(img_file, 'rb')
+ header_size = struct.calcsize(BOOTIMG_HDR_FMT)
+
+ fin = file1.read(header_size)
+ unpack_array = struct.unpack(BOOTIMG_HDR_FMT, fin)
+ file1.close()
+ magic_str = ""
+ for i in range(0, 7):
+ magic_str = magic_str + unpack_array[i]
+
+ if cmp(magic_str, BOOTIMG_HDR_MAGIC) == 0:
+ print "Is Boot Img"
+ page_size = unpack_array[15]
+ hdr_size = page_size
+ kernel_size = (unpack_array[8] + (page_size - 1)) / page_size * page_size
+ ramdisk_size = (unpack_array[10] + (page_size - 1)) / page_size * page_size
+ #recovery dtbo image
+ dtbo_size = (unpack_array[1578] + (page_size - 1)) / page_size * page_size
+ #dtb image
+ dtb_size = (unpack_array[1581] + (page_size - 1)) / page_size * page_size
+ print "Header size:" + `hex(header_size)`
+ print "Kernel size:" + `hex(kernel_size)`
+ print "Ramdisk size:" + `hex(ramdisk_size)`
+ print "DTBO size:" + `hex(dtbo_size)`
+ print "dtb size:" + `hex(dtb_size)`
+ print "page size:" + `hex(unpack_array[15])`
+ img_size = (kernel_size + ramdisk_size + hdr_size + dtbo_size + dtb_size + (16 - 1)) / 16 * 16
+ print "Total Size(include header and padding):" + `hex(img_size)`
+ print hex(img_size)
+ is_boot = 1
+ else:
+ print "Not Boot Img"
+
+ return is_boot, img_size, hdr_size
+
+def check_is_dtbo(img_file):
+ """
+ check whether it's dtbo image.
+ """
+ #parse bin
+ img_size = 0
+ is_dtbo = 0
+ hdr_size = 0
+ file1 = open(img_file, 'rb')
+ header_size = struct.calcsize(DTBO_HDR_FMT)
+
+ fin = file1.read(header_size)
+ unpack_array = struct.unpack(DTBO_HDR_FMT, fin)
+ file1.close()
+
+ if unpack_array[0] == DTBO_HDR_MAGIC:
+ print "Is DTBO Img"
+ hdr_size = unpack_array[2]
+ img_size = unpack_array[1]
+ print "Header size:" + `hex(hdr_size)`
+ print "Image size:" + `hex(img_size)`
+ print "Total Size" + `hex(unpack_array[1])`
+ is_dtbo = 1
+ else:
+ print "Not dtbo Img"
+
+ return is_dtbo, img_size, hdr_size
+
+def fill_cert_config(cert_path, replace_str, tgt_line_pattern):
+ """
+ We provide certificate configuration template and could
+ generate cerificate based on the configuration. Before that,
+ you need to fill up the configuration template so certificate
+ generation engine knows how to generate certificate.
+ """
+ os.chmod(cert_path, stat.S_IWRITE + stat.S_IREAD)
+
+ file1 = open(cert_path, 'r')
+ lines = file1.readlines()
+ file1.close()
+
+ file2 = open(cert_path, 'w')
+
+ format1 = re.compile(tgt_line_pattern)
+ for line in lines:
+ if format1.match(line):
+ print line
+ line2 = line.split("::=")[0] + "::= " + replace_str + "\n"
+ print line2
+ file2.write(line2)
+ else:
+ file2.write(line)
+
+def padding_file(input_file, align_num):
+ """
+ Fill 0 to make input_file size multiple of align_num.
+ """
+ filesize = os.stat(input_file).st_size
+ file1 = open(input_file, 'ab+')
+ padding = filesize % align_num
+ if padding != 0:
+ padding = align_num - padding
+ for _ in range(padding):
+ file1.write("\x00")
+ file1.close()
+
+def append_file(img_file, cert_file):
+ """
+ Append cert_file to the end of img_file.
+ """
+ padding_file(img_file, 16)
+ file1 = open(img_file, 'ab+')
+ file2 = open(cert_file, 'rb')
+ file1.write(file2.read())
+ file1.close()
+ file2.close()
+
+def get_pure_img(img_file, img_array, size_array, offset_array):
+ """
+ Put sub-image data into array for composite image.
+ """
+ index = 0
+ file2 = open(img_file, 'rb')
+ for sub_img in img_array:
+ img_size = size_array[index]
+ offset = offset_array[index]
+ file2.seek(offset)
+ file1 = open(sub_img, 'wb+')
+ file1.write(file2.read(img_size))
+ file1.close()
+ index += 1
+ file2.close()
+
+def backup_file(tmp_file, target_file, backup_file_path):
+ """
+ Backup target_file to backup_file_path
+ """
+ if backup_file_path != "":
+ shutil.move(target_file, backup_file_path)
+ shutil.move(tmp_file, target_file)
+
+def cat_img(img_array, final_bin):
+ """
+ Concatenate data in img_array to form final_bin,
+ which is a composite image.
+ """
+ file1 = open(final_bin, 'wb')
+ index = 0
+ for img in img_array:
+ file2 = open(img, 'rb')
+ file1.write(file2.read())
+ file2.close()
+ index += 1
+ file1.close()
+
+def add_mkimg_header(cert_name, img_list_end, img_type, img_name, context):
+ """
+ mkimage header is the header for Mediatek proprietary images.
+ This function is used to generate mkimage header for
+ certificate files.
+
+ """
+ mkimage_config = context['mkimage_config']
+ mkimage_config_out = context['mkimage_config_out']
+ tmpcert_name = context['tmpcert_name']
+ file1 = open(mkimage_config, 'r')
+ file2 = open(mkimage_config_out, 'w+')
+ format1 = re.compile("IMG_LIST_END")
+ format2 = re.compile("IMG_TYPE")
+ format3 = re.compile("NAME")
+ for line in file1:
+ if format1.match(line):
+ end = line.split("=")[1]
+ line2 = line.replace(end, str(img_list_end))
+ file2.write(line2 + "\n")
+ elif format2.match(line):
+ end = line.split("=")[1]
+ line2 = line.replace(end, str(img_type))
+ file2.write(line2 + "\n")
+ elif format3.match(line):
+ end = line.split("=")[1]
+ line2 = line.replace(end, str(img_name))
+ file2.write(line2 + "\n")
+ else:
+ file2.write(line)
+
+ file1.close()
+ file2.close()
+
+ img_hdr = lib.mkimghdr.mkimage_hdr()
+ img_hdr.update_mkimage_hdr(cert_name, mkimage_config_out)
+ img_hdr.pack()
+ img_hdr.output(cert_name, tmpcert_name)
+ shutil.move(tmpcert_name, cert_name)
+
+def get_md_key(md_img, is_md, context):
+ """
+ Get modem public key from modem image
+ """
+ found = 0
+ cert1md_hash_path = context['cert1md_hash_path']
+ md_key_path = os.path.join(cert1md_hash_path, "md_key.bin")
+
+ if is_md == 1:
+ md1_handler = lib.getPublicKey.md1_image()
+ found = md1_handler.parse(md_img)
+ if found:
+ md1_handler.output(md_img, md_key_path)
+ print "output file done"
+ elif is_md == 2:
+ md3_handler = lib.getPublicKey.md3_image()
+ found = md3_handler.parse(md_img)
+ if found:
+ md3_handler.output(md_img, md_key_path)
+ print "output file done"
+ else:
+ print "wrong md type!!!"
+
+ return md_key_path
+
+def img_split(img, split_path, hdr_size):
+ """
+ split image into header and image body
+ """
+ split_header = os.path.join(split_path, "header.bin")
+ split_image = os.path.join(split_path, "image.bin")
+
+ file1 = open(img, 'rb')
+ file2 = open(split_header, 'wb')
+ file2.write(file1.read(hdr_size))
+ file2.close()
+ file2 = open(split_image, 'wb')
+ file2.write(file1.read())
+ file2.close()
+ file1.close()
+ padding_file(split_image, 16)
+
+ return split_header, split_image
+
+def endiness_convert(in_file, out_file):
+ """
+ Converts endian of in_file and save result to out_file.
+ """
+ endian = sys.byteorder
+ if endian == "little":
+ file1 = open(out_file, "wb")
+ file2 = open(in_file, "rb")
+ from array import array
+ for _ in range(8, 0, -1):
+ tmp = array("B", file2.read(4))
+ tmp.reverse()
+ tmp.tofile(file1)
+ file2.close()
+ file1.close()
+
+def fill_arg_dict(input_string, key, args):
+ """
+ Fill up argument dictionary from input parameters
+ """
+ prefix = input_string.split("=")[0].strip()
+ fmt = re.compile(key, re.I)
+ if fmt.search(prefix):
+ val = input_string.split("=")[1].strip()
+ args[key] = val
+ print key + ": " + val
+ print args[key]
+ return args
+
+def parse_arg(argv):
+ """
+ Parse input arguments and save the result into argument dictionary.
+ """
+ args = {'type': 0, \
+ 'img': 0, \
+ 'privk': 0, \
+ 'pubk': 0, \
+ 'cert1': 0, \
+ 'swID': 0, \
+ 'ver': 0, \
+ 'name': '', \
+ 'group': 0, \
+ 'root_key_padding': 0, \
+ 'getHashList': 0, \
+ 'env_cfg': 0, \
+ 'platform': 'NOT_SET', \
+ 'project': 'NOT_SET', \
+ 'socid': '0'}
+ for input_string in argv:
+ for key in args:
+ args = fill_arg_dict(input_string, key, args)
+ input_wrong = 0
+
+ #check input
+ if args['type'] == "cert1":
+ if args['privk'] == "" or args['pubk'] == "":
+ print "wrong cert1 input"
+ input_wrong = 1
+ elif args['type'] == "cert2":
+ if args['privk'] == "" or args['cert1'] == "" or args['img'] == "" or args['name'] == "":
+ print "wrong cert2 input"
+ elif args['type'] == "cert1md":
+ if args['img'] == "" or args['privk'] == "":
+ print "wrong cert1md input"
+ else:
+ print "wrong cert type!"
+ input_wrong = 1
+ if input_wrong == 1:
+ help_menu()
+ sys.exit()
+
+ if args['env_cfg'] == 0:
+ #env_cfg is not given, we set it to env.cfg in path of this tool
+ args['env_cfg'] = os.path.join(os.path.dirname(__file__), 'env.cfg')
+ return args
+
+def help_menu():
+ """
+ Print usage for this tool.
+ """
+ print "Gen Cert1:"
+ print " usage: python sign.py type=cert1 privk=[cert1_privk.pem] pubk=[cert2_pubk.pem]"
+ print " optional: swID=[number] ver=[number] group=[number] "
+ print " output: cert1"
+ print "Gen Cert2 and append cert1,cert2 to the image:"
+ print " usage: python sign.py type=cert2 img=[xxx.bin] name=[img name] cert1=[cert1.der] \
+privk=[cert2_privk.pem]"
+ print " optional:ver=number"
+ print " output: image append with cert1 and cert2"
+ print "Gen Cert1md:"
+ print " usage: python sign.py type=cert1md img=[xxx.bin] privk=[cert1md_privk.pem] \
+pubk=[cert2_pubk.pem]"
+ print " output: cert1md"
+
+def main():
+ """
+ Main function when this tool is executed from command line.
+ """
+ if len(sys.argv) < 3:
+ help_menu()
+
+ sign = Sign()
+ sign.args = parse_arg(sys.argv)
+ sign.sign_op()
+
+if __name__ == '__main__':
+ main()
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign_flow.py b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign_flow.py
new file mode 100644
index 0000000..db17b37
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/sign_flow.py
@@ -0,0 +1,387 @@
+"""
+This module integrates image signing flow so user could sign all images
+in one shot.
+"""
+import os
+import re
+import shutil
+import argparse
+import sign
+import sys
+import traceback
+
+SIGN_TOOL_VERSION_MAJOR = 1
+SIGN_TOOL_VERSION_MINOR = 0
+SIGN_TOOL_VERSION_SUB = 0
+
+def get_release_string():
+ """
+ get release string
+ """
+ return 'sign_flow.py version {}.{}.{}'.format(SIGN_TOOL_VERSION_MAJOR,
+ SIGN_TOOL_VERSION_MINOR,
+ SIGN_TOOL_VERSION_SUB)
+
+def create_out_dir(path):
+ """
+ create output folder if it does not exist
+ """
+ folder_path = os.path.abspath(path)
+ print "Create dir:" + folder_path
+
+ try:
+ os.makedirs(folder_path)
+ except OSError, error:
+ if error.errno != os.errno.EEXIST:
+ raise
+
+class SignFlow(object):
+ """
+ sign flow class for android image signing/resigning
+ """
+ def __init__(self):
+ self.in_path = None
+ self.out_path = None
+ self.cert1_dir = None
+ self.cert2_key_dir = None
+ self.img_list_path = None
+ self.img_ver_path = None
+ self.bin_tmp_path = None
+ self.platform = None
+ self.project = None
+
+ def set_path(self, platform, project, cfg_file_path):
+ """
+ set up environment for image signing
+ """
+ self.platform = platform
+ self.project = project
+ cfg_file_dir = os.path.dirname(os.path.abspath(cfg_file_path))
+ cfg_file = open(cfg_file_path, 'r')
+ for line in cfg_file.readlines():
+ line = line.strip()
+ if line:
+ elements = line.split('=')
+ field = elements[0].strip()
+ value = elements[1].strip()
+ value = value.replace("${PLATFORM}", platform)
+ value = value.replace("${PROJECT}", project)
+ if field == 'out_path':
+ self.out_path = os.environ.get('PRODUCT_OUT')
+ if self.out_path is None:
+ print 'Use out path in env.cfg'
+ self.out_path = os.path.join(cfg_file_dir, value)
+ else:
+ print 'Use out path in Android'
+ # in_path is optional, hence we give it default value here
+ if self.in_path is None:
+ self.in_path = self.out_path
+ elif field == 'in_path':
+ self.in_path = os.environ.get('PRODUCT_OUT')
+ if self.in_path is None:
+ self.in_path = os.path.join(cfg_file_dir, value)
+ elif field == 'cert1_dir':
+ self.cert1_dir = os.path.join(cfg_file_dir, value)
+ elif field == 'cert2_key_dir':
+ self.cert2_key_dir = os.path.join(cfg_file_dir, value)
+ elif field == 'img_list_path':
+ self.img_list_path = os.path.join(cfg_file_dir, value)
+ elif field == 'img_ver_path':
+ self.img_ver_path = os.path.join(cfg_file_dir, value)
+
+ self.bin_tmp_path = os.path.join(self.out_path,
+ "resign",
+ "bin",
+ "multi_tmp")
+
+ print "==================================="
+ print "environment configuration"
+ print "==================================="
+ print 'in_path = ' + self.in_path
+ print 'out_path = ' + self.out_path
+ print 'cert1_dir = ' + self.cert1_dir
+ print 'cert2_key_dir = ' + self.cert2_key_dir
+ print 'img_list_path = ' + self.img_list_path
+ print 'img_ver_path = ' + self.img_ver_path
+ print 'bin_tmp_path = ' + self.bin_tmp_path
+
+ cfg_file.close()
+
+ create_out_dir(self.bin_tmp_path)
+
+ def parse_img_list(self):
+ """
+ parse image list file and get image signing settings
+ """
+ img_type = 'SINGLE_BIN'
+ pattern1 = r"\[single_bin\]"
+ format1 = re.compile(pattern1)
+ pattern2 = r"\[multi_bin\]"
+ format2 = re.compile(pattern2)
+ pattern3 = r"\[image_hash_list\]"
+ format3 = re.compile(pattern3)
+ img_list_file = open(self.img_list_path, 'r')
+ single_bin_dict = {}
+ multi_bin_dict = {}
+ img_hash_list = []
+ for line in img_list_file:
+ if not line.strip():
+ continue
+
+ if format1.match(line):
+ img_type = 'SINGLE_BIN'
+ elif format2.match(line):
+ img_type = 'MULTI_BIN'
+ elif format3.match(line):
+ img_type = 'HASH_LIST'
+ else:
+ if img_type == 'SINGLE_BIN':
+ bin_name = line.split("=")[0].strip()
+ img_name = line.split("=")[1].strip()
+ single_bin_dict[bin_name] = img_name
+ elif img_type == 'MULTI_BIN':
+ bin_name = line.split("=")[0].strip()
+ img_name = line.split("=")[1].strip()
+ multi_bin_dict[bin_name] = img_name
+ elif img_type == 'HASH_LIST':
+ img_hash_list.append(line.strip())
+
+ img_list_file.close()
+ return single_bin_dict, multi_bin_dict, img_hash_list
+
+ def get_img_ver(self, img_name):
+ """
+ get image version of specified image from image version setting file
+ """
+ img_ver = 0
+ target_line = 0
+
+ img_ver_file = open(self.img_ver_path, 'r')
+
+ pattern1 = r"\[" + img_name + r"\]"
+ format1 = re.compile(pattern1)
+ pattern2 = "img_ver*"
+ format2 = re.compile(pattern2)
+ for line in img_ver_file:
+ if not line.strip():
+ continue
+
+ if format1.match(line):
+ target_line = 1
+ elif format2.match(line):
+ if target_line == 1:
+ img_ver = line.split("=")[1].strip()
+ target_line = 0
+
+ img_ver_file.close()
+ return img_ver
+
+ def gen_cert2(self, args, img_path, img_name, get_hash_list):
+ """
+ In certificate chain design, cert1, which is image public key certificate,
+ is already generated by security owner, so it's prebuilt binary.
+ Image owner will use this module to generate cert2, which is image content
+ certificate and inject it into proper place in image.
+ """
+ prvk_path = os.path.join(self.cert2_key_dir, img_name + '_privk2.pem')
+ pubk_path = os.path.join(self.cert2_key_dir, img_name + '_pubk2.pem')
+ cert_path = os.path.join(self.cert1_dir, img_name + '_cert1.der')
+ # image signing will be forwarded to HSM if public key is given.
+ # public key has higher priority than private key.
+ if os.path.isfile(pubk_path):
+ key_path = pubk_path
+ elif os.path.isfile(prvk_path):
+ key_path = prvk_path
+ ver = self.get_img_ver(img_name)
+
+ # check bin exist in out folder
+ if os.path.isfile(img_path):
+ sign_obj = sign.Sign()
+ sign_obj.args['type'] = 'cert2'
+ sign_obj.args['img'] = img_path
+ sign_obj.args['name'] = img_name
+ sign_obj.args['cert1'] = cert_path
+ sign_obj.args['privk'] = key_path
+ sign_obj.args['ver'] = str(ver)
+ sign_obj.args['getHashList'] = get_hash_list
+ sign_obj.args['platform'] = self.platform
+ sign_obj.args['project'] = self.project
+ sign_obj.args['socid'] = args.socid
+ sign_obj.sign_op()
+ return
+
+ def sign_single_bin(self, args, single_bin_dict, img):
+ """
+ sign image with only one sub-image
+ """
+ img_name = single_bin_dict[img]
+ in_img_path = os.path.join(self.in_path, img)
+ self.gen_cert2(args, in_img_path, img_name, 0)
+ return
+
+ def sign_multi_bin(self, args, multi_bin_dict, img):
+ """
+ sign image with multiple sub-images
+ """
+ in_img_path = os.path.join(self.in_path, img)
+ img_name_list = multi_bin_dict[img].split(",")
+ multi_tmp_bin_in = os.path.join(self.bin_tmp_path, img)
+ multi_tmp_bin_out = os.path.join(self.out_path,
+ "resign",
+ "bin",
+ img.split(".")[0] +
+ "-verified." +
+ img.split(".")[1])
+ if not os.path.exists(in_img_path):
+ print "no " + str(img) + " image"
+ return
+ print "image name path = " + in_img_path
+ print "image name = " + multi_tmp_bin_in
+ shutil.copy2(in_img_path, multi_tmp_bin_in)
+
+ for img_name in img_name_list:
+ img_name = img_name.strip()
+ self.gen_cert2(args, multi_tmp_bin_in, img_name, 0)
+ shutil.copy2(multi_tmp_bin_out, multi_tmp_bin_in)
+ return
+
+ def sign_img_hash_list(self, args, img):
+ """
+ sign image without mkimg header, which is generally too big
+ to put all of it into ram so we split them into chunks and
+ flash it chunk by chunk.
+ """
+ in_img_path = os.path.join(self.in_path, img)
+ if not os.path.exists(in_img_path):
+ print "no " + str(img) + " image"
+ return
+ img_name = img.split('.')[0].strip()
+ self.gen_cert2(args, in_img_path, img_name, 1)
+ return
+
+ def sign_all_img(self, args, single_bin_dict, multi_bin_dict, img_hash_list):
+ """
+ sign all images if it's in image list file and is also found
+ in output folder.
+ """
+ for img in single_bin_dict.keys():
+ self.sign_single_bin(args, single_bin_dict, img)
+
+ for img in multi_bin_dict.keys():
+ self.sign_multi_bin(args, multi_bin_dict, img)
+
+ for img in img_hash_list:
+ self.sign_img_hash_list(args, img)
+
+ return
+
+ def sign_single_img(self, args, single_bin_dict, multi_bin_dict, img_hash_list, tgt):
+ """
+ sign only specified image in image list file.
+ """
+ if single_bin_dict.get(tgt) is not None:
+ self.sign_single_bin(args, single_bin_dict, tgt)
+ elif multi_bin_dict.get(tgt) is not None:
+ self.sign_multi_bin(args, multi_bin_dict, tgt)
+ elif tgt in img_hash_list is True:
+ self.sign_img_hash_list(args, tgt)
+
+ return
+ def version(self, _):
+ """
+ print sign_flow.py tool version
+ """
+ print get_release_string()
+
+ def sign_images(self, args):
+ """
+ entry point for image signing
+ """
+ get_setting_str = lambda arg: 'Not Set' if arg is None else arg
+ print "=========================================="
+ print "platform = " + get_setting_str(args.plat)
+ print "project = " + get_setting_str(args.proj)
+ print "target = " + get_setting_str(args.tgt)
+ print "socid = " + get_setting_str(args.socid)
+ print "=========================================="
+
+ self.set_path(args.plat, args.proj, args.env_cfg)
+ single_bin_dict, multi_bin_dict, img_hash_list = self.parse_img_list()
+
+ board_avb_enable = os.environ.get('BOARD_AVB_ENABLE')
+ if board_avb_enable is None:
+ board_avb_enable = 'false'
+ else:
+ board_avb_enable = board_avb_enable.lower()
+ print "avb = " + get_setting_str(board_avb_enable)
+
+ #bypass boot/recovery image if avb2.0 is enabled because both images fill up the partition
+ if board_avb_enable == 'true':
+ if single_bin_dict.get('boot.img', 0) != 0:
+ del single_bin_dict['boot.img']
+ if single_bin_dict.get('recovery.img', 0) != 0:
+ del single_bin_dict['recovery.img']
+
+ if args.tgt is None:
+ return self.sign_all_img(args,
+ single_bin_dict,
+ multi_bin_dict,
+ img_hash_list)
+
+ return self.sign_single_img(args,
+ single_bin_dict,
+ multi_bin_dict,
+ img_hash_list,
+ args.tgt)
+ def run(self, argv):
+ """
+ entry point for sign_flow.py
+ """
+ env_cfg_default_path = os.path.join(os.path.dirname(__file__), 'env.cfg')
+
+ parser = argparse.ArgumentParser(description='Integrated Flow for Image Signing')
+
+ subparsers = parser.add_subparsers(title='subcommands')
+ sub_parser = subparsers.add_parser('version',
+ help='Prints version of sign_flow.py.')
+ sub_parser.set_defaults(func=self.version)
+
+ sub_parser = subparsers.add_parser('sign_images',
+ help='sign MTK proprietary images.')
+ sub_parser.add_argument('plat',
+ help='platform name. ex. mt6739.')
+ sub_parser.add_argument('proj',
+ help='project name. ex. k39v1_64.')
+ sub_parser.add_argument('-env_cfg',
+ dest='env_cfg',
+ help='configuration file for environment',
+ default=env_cfg_default_path)
+ sub_parser.add_argument('-target',
+ dest='tgt',
+ help='target image name. ex. lk.img. \
+ If this option is ignored, then all images found will be signed.')
+ sub_parser.add_argument('--socid',
+ dest='socid',
+ help='please fill socid',
+ default='0')
+ sub_parser.set_defaults(func=self.sign_images)
+
+ #the following process is designed for backward compatible
+ find = 0
+ arg_tmp = argv
+ for name, arg in subparsers.choices.items():
+ if re.match(arg_tmp[1], name):
+ find = 1
+ if find == 0:
+ arg_tmp.insert(1, "sign_images")
+
+ args = parser.parse_args(arg_tmp[1:])
+
+ try:
+ args.func(args)
+ except:
+ traceback.print_exc()
+
+if __name__ == '__main__':
+ tool = SignFlow()
+ tool.run(sys.argv)
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1.cfg
new file mode 100644
index 0000000..84617ea
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1.cfg
@@ -0,0 +1,69 @@
+tbsCertificate SEQUENCE ::= {
+ dummy EXPLICIT:0 ::= {
+ VERSION INTEGER ::= 2
+ }
+ serial INTEGER ::= 10217578998209204828
+ sigAlgo SEQUENCE ::= {
+ sigAlgo OID ::= 1.2.840.113549.1.1.11
+ NULL
+ }
+ issuer SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ validity SEQUENCE ::= {
+ notBefore UTCTIME ::= 2015-06-04-03-14-44
+ notAfter UTCTIME ::= 2035-06-04-03-14-44
+ }
+ subject SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ pubk EXTERNAL_PEM ::=
+ certver OID ::= 2.16.886.2454.3.1
+ certver INTEGER ::= 0
+ cert2pubk OID ::= 2.16.886.2454.1.2
+ pubk2 EXTERNAL_PEM ::=
+ rootpubk OID ::= 2.16.886.2454.1.1
+ rootpubk EXTERNAL_BITSTRING ::=
+ imgVer OID ::= 2.16.886.2454.2.2
+ imgVer INTEGER ::= 0
+ imgGroup OID ::= 2.16.886.2454.2.5
+ imgGroup INTEGER ::= 0
+ swID OID ::= 2.16.886.2454.2.3
+ swID INTEGER ::= 0
+ applySig OID ::= 2.16.886.2454.3.2
+ applySig INTEGER ::= 1
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1md.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1md.cfg
new file mode 100644
index 0000000..7282876
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert1md.cfg
@@ -0,0 +1,71 @@
+tbsCertificate SEQUENCE ::= {
+ dummy EXPLICIT:0 ::= {
+ VERSION INTEGER ::= 2
+ }
+ serial INTEGER ::= 10217578998209204828
+ sigAlgo SEQUENCE ::= {
+ sigAlgo OID ::= 1.2.840.113549.1.1.11
+ NULL
+ }
+ issuer SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ validity SEQUENCE ::= {
+ notBefore UTCTIME ::= 2015-06-04-03-14-44
+ notAfter UTCTIME ::= 2035-06-04-03-14-44
+ }
+ subject SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ pubk EXTERNAL_PEM ::=
+ certver OID ::= 2.16.886.2454.3.1
+ certver INTEGER ::= 0
+ cert2pubk OID ::= 2.16.886.2454.1.2
+ pubk2 EXTERNAL_PEM ::=
+ pubkHash OID ::= 2.16.886.2454.1.3
+ pubkHash EXTERNAL_BITSTRING ::=
+ rootpubk OID ::= 2.16.886.2454.1.1
+ rootpubk EXTERNAL_BITSTRING ::=
+ imgVer OID ::= 2.16.886.2454.2.2
+ imgVer INTEGER ::= 0
+ imgGroup OID ::= 2.16.886.2454.2.5
+ imgGroup INTEGER ::= 0
+ swID OID ::= 2.16.886.2454.2.3
+ swID INTEGER ::= 0
+ applySig OID ::= 2.16.886.2454.3.2
+ applySig INTEGER ::= 1
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert2.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert2.cfg
new file mode 100644
index 0000000..f5aa8b6
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert2.cfg
@@ -0,0 +1,69 @@
+tbsCertificate SEQUENCE ::= {
+ dummy EXPLICIT:0 ::= {
+ VERSION INTEGER ::= 2
+ }
+ serial INTEGER ::= 10217578998209204828
+ sigAlgo SEQUENCE ::= {
+ sigAlgo OID ::= 1.2.840.113549.1.1.11
+ NULL
+ }
+ issuer SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ validity SEQUENCE ::= {
+ notBefore UTCTIME ::= 2015-06-04-03-14-44
+ notAfter UTCTIME ::= 2035-06-04-03-14-44
+ }
+ subject SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ pubk EXTERNAL_PEM ::=
+ certver OID ::= 2.16.886.2454.3.1
+ certver INTEGER ::= 0
+ imgHash OID ::= 2.16.886.2454.2.1
+ imgHash EXTERNAL_BITSTRING ::= 0
+ imgVer OID ::= 2.16.886.2454.2.2
+ imgVer INTEGER ::= 0
+ imgHdrHash OID ::= 2.16.886.2454.2.4
+ imgHdrHash EXTERNAL_BITSTRING ::= 0
+ imgHash_Multi OID ::= 2.16.886.2454.2.6
+ imgHash_Multi EXTERNAL_BITSTRING ::= 0
+ applySig OID ::= 2.16.886.2454.3.2
+ applySig INTEGER ::= 1
+ socid OID ::= 2.16.886.2454.2.7
+ socid PRINTABLESTRING ::= 0
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert_template.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert_template.cfg
new file mode 100644
index 0000000..e3854e8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/cert_template.cfg
@@ -0,0 +1,55 @@
+tbsCertificate SEQUENCE ::= {
+ dummy EXPLICIT:0 ::= {
+ VERSION INTEGER ::= 2
+ }
+ serial INTEGER ::= 10217578998209204828
+ sigAlgo SEQUENCE ::= {
+ sigAlgo OID ::= 1.2.840.113549.1.1.11
+ NULL
+ }
+ issuer SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ validity SEQUENCE ::= {
+ notBefore UTCTIME ::= 2015-06-04-03-14-44
+ notAfter UTCTIME ::= 2035-06-04-03-14-44
+ }
+ subject SEQUENCE ::= {
+ countryName SET ::= {
+ countryName SEQUENCE ::= {
+ countryName OID ::= 2.5.4.6
+ countryName PRINTABLESTRING ::= AU
+ }
+ }
+ stateOrProvinceName SET ::= {
+ stateOrProvinceName SEQUENCE ::= {
+ stateOrProvinceName OID ::= 2.5.4.8
+ stateOrProvinceName UTF8STRING ::= Some-State
+ }
+ }
+ organizationName SET ::= {
+ organizationName SEQUENCE ::= {
+ organizationName OID ::= 2.5.4.10
+ organizationName UTF8STRING ::= Mediatek
+ }
+ }
+ }
+ pubk EXTERNAL_PEM ::=
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/x509cert_template.cfg b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/x509cert_template.cfg
new file mode 100644
index 0000000..f355bb2
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/files/sign_image/x509_template/x509cert_template.cfg
@@ -0,0 +1,30 @@
+x509certificate SEQUENCE ::= {
+ tbsCertificate EXTERNAL_CFG ::=
+ sigAlgorithm SEQUENCE ::= {
+ sigAlgo OID ::= 1.2.840.113549.1.1.10
+ pssParam SEQUENCE ::= {
+ hashAlgorithm EXPLICIT:0 ::= {
+ hashAlgorithm SEQUENCE ::= {
+ hashAlgorithm OID ::= 2.16.840.1.101.3.4.2.1
+ NULL
+ }
+ }
+ maskGenAlgorithm EXPLICIT:1 ::= {
+ maskGenAlgorithm SEQUENCE ::= {
+ maskGenAlgorithm OID ::= 1.2.840.113549.1.1.8
+ hashAlgorithm SEQUENCE ::= {
+ hashAlgorithm OID ::= 2.16.840.1.101.3.4.2.1
+ NULL
+ }
+ }
+ }
+ saltLength EXPLICIT:2 ::= {
+ saltLength INTEGER ::= 32
+ }
+ trailerField EXPLICIT:3 ::= {
+ trailerField INTEGER ::= 1
+ }
+ }
+ }
+ sigValue EXTERNAL_BITSTRING ::=
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/mdcert.bb b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/mdcert.bb
new file mode 100644
index 0000000..1c01e09
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/mdcert/mdcert.bb
@@ -0,0 +1,28 @@
+DESCRIPTION = "MD certification"
+LICENSE = "MIT"
+
+DEPENDS += "u-boot-mkimage-native bc-native dtc-native"
+
+inherit deploy nopackages
+inherit md-fitimage staging-copyfile
+
+SSTATE_DUPWHITELIST += "${DEPLOY_DIR_IMAGE}"
+
+
+MD_IMAGE = "md1img.img"
+
+do_deploy[nostamp] = "1"
+do_install[noexec] = "1"
+
+MD_IMAGE = "md1img.img"
+MD_OUT = "${WORKDIR}"
+
+do_deploy () {
+ if [ "${SECURE_BOOT_ENABLE}" = "yes" ] && [ -f "${DEPLOY_DIR}/images/${MACHINE}/md1img.img" ]; then
+ cp ${DEPLOY_DIR}/images/${MACHINE}/md1img.img ${WORKDIR}/md1img-org.img
+ do_assemble_mdfitimage
+ install ${MD_OUT}/${MD_IMAGE} ${DEPLOYDIR}/${MD_IMAGE}
+ fi
+}
+
+addtask deploy after do_configure
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/gen-partitions.ini b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/gen-partitions.ini
new file mode 100644
index 0000000..52534ff
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/gen-partitions.ini
@@ -0,0 +1,2 @@
+partition_nand.xml scatter_emmc.json MBR_NAND
+partition_emmc.xml scatter_emmc.json MBR_EMMC
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_emmc.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_emmc.xml
new file mode 100644
index 0000000..89f3931
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_emmc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<partition lba="30785535">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="16778239" name="log"/>
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_nand.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_nand.xml
new file mode 100644
index 0000000..37f84f1
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand/partition_nand.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partition lba="261632" lbs="2048">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="128" end="319" attributes="4" name="bl2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="320" end="639" name="bl33" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="640" end="831" name="spm" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="832" end="1023" name="dtbo" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="4223" name="nvdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4224" end="4351" name="hsm_os" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4352" end="6655" name="protect_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="6656" end="8959" name="protect_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="8960" end="14847" name="sncfg" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="14848" end="51199" name="md1img_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="51200" end="87551" name="md1img_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="87552" end="95743" name="boot_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="95744" end="103935" name="boot_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="103936" end="142335" name="system_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="142336" end="180735" name="system_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="180736" end="180927" name="misc" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="180928" end="181567" name="tee_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="181568" end="182207" name="tee_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="182208" end="225279" name="userdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="225280" end="225471" name="vbmeta_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="225472" end="225663" name="vbmeta_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="225664" end="251263" name="delta" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="251264" end="261567" name="expdb" />
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/gen-partitions.ini b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/gen-partitions.ini
new file mode 100644
index 0000000..52534ff
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/gen-partitions.ini
@@ -0,0 +1,2 @@
+partition_nand.xml scatter_emmc.json MBR_NAND
+partition_emmc.xml scatter_emmc.json MBR_EMMC
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_emmc.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_emmc.xml
new file mode 100644
index 0000000..89f3931
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_emmc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<partition lba="30785535">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="16778239" name="log"/>
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_nand.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_nand.xml
new file mode 100644
index 0000000..2621ad8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-mcp_nand_lp4/partition_nand.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partition lba="130560" lbs="4096">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="128" end="255" attributes="4" name="bl2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="256" end="447" name="bl33" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="448" end="575" name="spm" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="576" end="703" name="dtbo" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="704" end="2303" name="nvdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2304" end="2367" name="hsm_os" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2368" end="3903" name="protect_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="3904" end="5439" name="protect_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="5440" end="8383" name="sncfg" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="8384" end="26559" name="md1img_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="26560" end="44735" name="md1img_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="44736" end="48831" name="boot_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="48832" end="52927" name="boot_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="52928" end="72127" name="system_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="72128" end="91327" name="system_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="91328" end="91455" name="misc" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="91456" end="91775" name="tee_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="91776" end="92095" name="tee_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="92096" end="125183" name="userdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="125184" end="125311" name="vbmeta_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="125312" end="125439" name="vbmeta_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="125440" end="130495" name="expdb" />
+</partition>
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/gen-partitions.ini b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/gen-partitions.ini
new file mode 100644
index 0000000..e6d88d0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/gen-partitions.ini
@@ -0,0 +1,2 @@
+partition_nand.xml scatter_emmc.json MBR_NAND
+partition_emmc.xml scatter_emmc.json MBR_EMMC
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_emmc.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_emmc.xml
new file mode 100644
index 0000000..89f3931
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_emmc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<partition lba="30785535">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="16778239" name="log"/>
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_nand.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_nand.xml
new file mode 100644
index 0000000..a4ec317
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731-ivt-spi_nand/partition_nand.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partition lba="130560" lbs="4096">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="128" end="255" name="bl1" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="256" end="383" name="data" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="384" end="639" attributes="4" name="uboot" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="640" end="767" name="hsm" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="768" end="895" name="spm" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="896" end="1023" name="dtbo" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="2559" name="nvram" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2560" end="4095" name="nvdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4096" end="4351" name="proinfo" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4352" end="4607" name="protect1" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4608" end="4863" name="protect2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4864" end="4991" name="factoryconfig" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4992" end="5119" name="configpack1" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="5120" end="5247" name="configpack2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="5248" end="17535" name="md1img" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="17536" end="21631" name="md1dsp" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="21632" end="21887" name="tee1" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="21888" end="22143" name="tee2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="22144" end="25727" name="boot" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="25728" end="29311" name="recoveryboot" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="29312" end="31871" name="recoveryrootfs" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="31872" end="121471" name="rootfs" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="121472" end="125055" name="state" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="125056" end="125183" name="unitest" />
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/gen-partitions.ini b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/gen-partitions.ini
new file mode 100644
index 0000000..b40e7b0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/gen-partitions.ini
@@ -0,0 +1,2 @@
+partition_emmc.xml scatter_emmc.json MBR_EMMC
+partition_emmc_boot0.xml scatter_emmc.json MBR_EMMC_BOOT0
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc.xml
new file mode 100644
index 0000000..a311820
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<partition lba="30785535">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="1024" end="2047" name="bl33" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2048" end="2175" name="spm" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2176" end="2687" name="dtbo" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2688" end="14975" name="nvdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="14976" end="15487" name="hsm_os" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="15488" end="16511" name="protect_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="16512" end="17535" name="protect_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="17536" end="26751" name="sncfg" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="26752" end="172159" name="md1img_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="172160" end="317567" name="md1img_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="317568" end="350335" name="boot_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="350336" end="383103" name="boot_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="383104" end="2480255" name="system_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2480256" end="4577407" name="system_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4577408" end="4577919" name="misc" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4577920" end="4579967" name="tee_a" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4579968" end="4582015" name="tee_b" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4582016" end="6679167" name="userdata" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="6679168" end="6720127" name="expdb" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="6720128" end="29656191" name="log" />
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc_boot0.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc_boot0.xml
new file mode 100644
index 0000000..73c1697
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-emmc/partition_emmc_boot0.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partition lba="8192">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="34" end="545" attributes="4" name="bl2" />
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="546" end="1057" name="dummyboot0" />
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/gen-partitions.ini b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/gen-partitions.ini
new file mode 100644
index 0000000..b9ea408
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/gen-partitions.ini
@@ -0,0 +1 @@
+partition_nand.xml scatter_emmc.json MBR_NAND
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/partition_nand.xml b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/partition_nand.xml
new file mode 100644
index 0000000..48c4e05
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/files/auto2731evb1-ivt-nand/partition_nand.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<partition lba="131000" lbs="4096">
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="128" end="319" attributes="4" name="UBOOT"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="320" end="511" name="HSM"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="512" end="575" name="SPM"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="576" end="639" name="DTBO"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="640" end="2175" name="NVRAM"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="2176" end="3711" name="NVDATA"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="3712" end="3967" name="PROINFO"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="3968" end="4223" name="PROTECT1"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4224" end="4479" name="PROTECT2"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4480" end="4543" name="FactoryConfig"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4544" end="4607" name="ConfigPack1"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4608" end="4671" name="ConfigPack2"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="4672" end="16959" name="MODEM"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="16960" end="21055" name="DSP"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="21056" end="21311" name="TEE1"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="21312" end="21567" name="TEE2"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="21568" end="25151" name="BOOTIMG"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="25152" end="28735" name="RECOVERYBOOT"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="28736" end="31295" name="RECOVERYROOTFS"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="31296" end="108607" name="ROOTFS"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="108608" end="112191" name="STATE"/>
+ <entry type="{0FC63DAF-8483-4772-8E79-3D69D8477DE4}" start="112192" end="115775" name="UNITEST"/>
+</partition>
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/scatter/scatter.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/scatter.bbappend
new file mode 100644
index 0000000..330d585
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/scatter/scatter.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+SRC_URI_append = " file://${SCATTER_PROJECT}"
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/spmfw/spmfw.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/spmfw/spmfw.bbappend
new file mode 100644
index 0000000..d0cb918
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/spmfw/spmfw.bbappend
@@ -0,0 +1,8 @@
+SPMFW_INFO = "verName"
+SPMFW_VERSION = "spmfw_version.txt"
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install ${SPMFW_OUT}/${SPMFW_BINARY} ${DEPLOYDIR}/${SPMFW_BINARY}
+ install ${SPMFW_PREBUILT}/${SPMFW_INFO} ${DEPLOYDIR}/${SPMFW_VERSION}
+}
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.2.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.2.bbappend
new file mode 100644
index 0000000..57d30f0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.2.bbappend
@@ -0,0 +1,13 @@
+
+EXTRA_OEMAKE = "'CROSS_COMPILE=${TARGET_PREFIX}' \
+ 'KERNEL_ARCH=${KERNEL_ARCH}' \
+ 'PLAT=${MTK_MACH_TYPE}' \
+ 'MACH_TYPE=${MTK_MACH_TYPE}' \
+ 'SECURE_OS=${TEE_SUPPORT}' \
+ 'BUILD_BASE=${ATF_OUT}' \
+ 'MTK_DRAM_TYPE=${MTK_DRAM_TYPE}' \
+ 'MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE}' \
+ 'MTK_USB_OR_PCIE=${MTK_USB_OR_PCIE}' \
+ 'TBASE_VER=${@oe.utils.conditional('TEE_SUPPORT', 'tbase', '${TBASE_VER}', '', d)}' \
+ "
+
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.6.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.6.bbappend
new file mode 100644
index 0000000..c3fbb2d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/atf_1.6.bbappend
@@ -0,0 +1,14 @@
+
+EXTRA_OEMAKE = "'CROSS_COMPILE=${TARGET_PREFIX}' \
+ 'KERNEL_ARCH=${KERNEL_ARCH}' \
+ 'PLAT=${MTK_MACH_TYPE}' \
+ 'MACH_TYPE=${MTK_MACH_TYPE}' \
+ 'SECURE_OS=${TEE_SUPPORT}' \
+ 'DEBUG=${@bb.utils.contains("ATF_INSTALL_MODE", "debug", "1", "0", d)}' \
+ 'BUILD_BASE=${ATF_OUT}' \
+ 'MTK_DRAM_TYPE=${MTK_DRAM_TYPE}' \
+ 'MTK_PMIC_CHIP_TYPE=${MTK_PMIC_CHIP_TYPE}' \
+ 'MTK_USB_OR_PCIE=${MTK_USB_OR_PCIE}' \
+ 'TBASE_VER=${@oe.utils.conditional('TEE_SUPPORT', 'tbase', '${TBASE_VER}', '', d)}' \
+ "
+
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-example_%.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-example_%.bbappend
new file mode 100644
index 0000000..acb5c55
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-example_%.bbappend
@@ -0,0 +1,11 @@
+inherit optee-build
+DEPENDS_remove=" optee-os "
+DEPENDS_append=" lib64-optee-os "
+
+EXTRA_OEMAKE_remove="TA_DEV_KIT_DIR=${STAGING_INCDIR}/optee/export-user_ta \
+ HOST_CROSS_COMPILE=${TEE_TOOLCHAIN}"
+
+EXTRA_OEMAKE_append="TA_DEV_KIT_DIR=${WORKDIR}/lib64-recipe-sysroot${includedir}/optee/export-user_ta \
+ TA_CROSS_COMPILE=${OPTEE_BULID_SA}aarch64-pokymllib64-linux- \
+ HOST_CROSS_COMPILE=${TARGET_PREFIX} \
+ "
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-os_3.2.0.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-os_3.2.0.bbappend
new file mode 100644
index 0000000..6d828a4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-os_3.2.0.bbappend
@@ -0,0 +1,10 @@
+EXTRA_OEMAKE_append = "'PLATFORM_FLAVOR=mt2731' \
+ 'CROSS_COMPILE=${TEE_TOOLCHAIN}' \
+ 'ta-targets=ta_arm64' \
+ "
+
+do_install_prepend() {
+ if [ ! -d ${WORKDIR}/out/${OPTEE_ARCH}-plat-${OPTEEOUTPUTMACHINE}/export-ta_${OPTEE_ARCH}/ ]; then
+ ln -s ${WORKDIR}/out/${OPTEE_ARCH}-plat-${OPTEEOUTPUTMACHINE}/export-ta_arm64 ${WORKDIR}/out/${OPTEE_ARCH}-plat-${OPTEEOUTPUTMACHINE}/export-ta_${OPTEE_ARCH}
+ fi
+}
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-services.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-services.bbappend
new file mode 100644
index 0000000..ca08f05
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-services.bbappend
@@ -0,0 +1,6 @@
+LIC_FILES_CHKSUM_remove = "file://${S}/LICENSE;md5=cd95ab417e23b94f381dafc453d70c30"
+LIC_FILES_CHKSUM_append = "file://${S}/LICENSE;md5=cb3d385c0d64a57fad9b9e0e9029f607"
+
+EXTRA_OEMAKE_remove="TA_DEV_KIT_DIR=${TA_DEV_KIT_DIR}"
+
+EXTRA_OEMAKE_append="TA_DEV_KIT_DIR=${WORKDIR}/lib64-recipe-sysroot${includedir}/optee/export-user_ta"
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-test_%.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-test_%.bbappend
new file mode 100644
index 0000000..565568b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/trustzone/optee-test_%.bbappend
@@ -0,0 +1,9 @@
+DEPENDS_remove=" optee-os "
+DEPENDS_append=" lib64-optee-os optee-services "
+
+EXTRA_OEMAKE_remove="TA_DEV_KIT_DIR=${STAGING_INCDIR}/optee/export-user_ta \
+ CROSS_COMPILE_TA=${TEE_TOOLCHAIN}"
+
+EXTRA_OEMAKE_append="TA_DEV_KIT_DIR=${WORKDIR}/lib64-recipe-sysroot${includedir}/optee/export-user_ta \
+ CROSS_COMPILE_TA=${OPTEE_BULID_SA}aarch64-pokymllib64-linux- \
+ CFG_PKCS11_TA=y"
diff --git a/meta/meta-mediatek-mt2731/recipes-bsp/uboot/u-boot-mkimage_2018.07.bbappend b/meta/meta-mediatek-mt2731/recipes-bsp/uboot/u-boot-mkimage_2018.07.bbappend
new file mode 100644
index 0000000..84a3476
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-bsp/uboot/u-boot-mkimage_2018.07.bbappend
@@ -0,0 +1,3 @@
+do_install_append() {
+ ln -sf uboot-mkimage ${D}${bindir}/brom-mkimage
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/hostapd/hostapd_%.bbappend b/meta/meta-mediatek-mt2731/recipes-connectivity/hostapd/hostapd_%.bbappend
new file mode 100644
index 0000000..1196033
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/hostapd/hostapd_%.bbappend
@@ -0,0 +1,13 @@
+do_install_append(){
+}
+
+do_configure_append () {
+ # Enable PMF
+ echo "CONFIG_IEEE80211W=y" >> ${WORKDIR}/hostapd-${PV}/hostapd/.config
+ # Enable 80211AC MODE
+ echo "CONFIG_IEEE80211AC=y" >> ${WORKDIR}/hostapd-${PV}/hostapd/.config
+ # Enable SAE for WPA3
+ echo "CONFIG_SAE=y" >> ${WORKDIR}/hostapd-${PV}/hostapd/.config
+ # Enable OWE for WPA3
+ echo "CONFIG_OWE=y" >> ${WORKDIR}/hostapd-${PV}/hostapd/.config
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/mnld/mnld.bbappend b/meta/meta-mediatek-mt2731/recipes-connectivity/mnld/mnld.bbappend
new file mode 100644
index 0000000..48e9dce
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/mnld/mnld.bbappend
@@ -0,0 +1 @@
+FLAGS += " -DMTK_AGPS_SUPPORT"
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/LICENSE b/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/LICENSE
new file mode 100644
index 0000000..7d4bcac
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/LICENSE
@@ -0,0 +1,3 @@
+All metadata is MediaTekProprietary licensed unless otherwise stated. Source code included
+in tree for individual recipes is under the LICENSE stated in the associated
+recipe (.bb file) unless otherwise stated.
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/v2x.bb b/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/v2x.bb
new file mode 100644
index 0000000..94454d3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/v2x/v2x.bb
@@ -0,0 +1,33 @@
+DESCRIPTION = "v2x SDK"
+LICENSE = "v2x"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=1c9062d34a99c5134caaa2c193ed588f"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../prebuilt/connectivity/v2x"
+
+
+FILES_${PN}-dev = ""
+FILES_${PN} += "opt/v2x/*"
+FILES_${PN}-staticdev += "opt/v2x/lib/libtomcrypt.a opt/v2x/lib/libtommath.a"
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "v2x_proxy.service v2x_service.service"
+FILES_${PN} += "${systemd_unitdir}/system/v2x_proxy.service"
+FILES_${PN} += "${systemd_unitdir}/system/v2x_service.service"
+
+INSANE_SKIP_${PN}_append += "already-stripped"
+INSANE_SKIP_${PN} = "ldflags"
+
+do_install_append() {
+ if [ -d ${TOPDIR}/../prebuilt/connectivity/v2x ]; then
+ install -d ${D}/opt/
+ cp -rf opt/v2x ${D}/opt/
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 v2x_proxy.service ${D}${systemd_unitdir}/system
+ install -m 0644 v2x_service.service ${D}${systemd_unitdir}/system
+ fi
+ fi
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-11KVR.patch b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-11KVR.patch
new file mode 100644
index 0000000..fb7b9a5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-11KVR.patch
@@ -0,0 +1,34 @@
+From 95ac7f93949902e6290d6819586842d77c2c48d7 Mon Sep 17 00:00:00 2001
+From: "jianling.fu" <jianling.fu@mediatek.com>
+Date: Mon, 21 Jan 2019 16:48:38 +0800
+Subject: [PATCH] 11KVR
+
+---
+ wpa_supplicant/defconfig | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig
+index 1d05198..011d3ca 100644
+--- a/wpa_supplicant/defconfig
++++ b/wpa_supplicant/defconfig
+@@ -371,7 +371,7 @@ CONFIG_PEERKEY=y
+ #CONFIG_DYNAMIC_EAP_METHODS=y
+
+ # IEEE Std 802.11r-2008 (Fast BSS Transition)
+-#CONFIG_IEEE80211R=y
++CONFIG_IEEE80211R=y
+
+ # Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+ #CONFIG_DEBUG_FILE=y
+@@ -456,7 +456,7 @@ CONFIG_PEERKEY=y
+
+ # Wireless Network Management (IEEE Std 802.11v-2011)
+ # Note: This is experimental and not complete implementation.
+-#CONFIG_WNM=y
++CONFIG_WNM=y
+
+ # Interworking (IEEE 802.11u)
+ # This can be used to enable functionality to improve interworking with
+--
+1.9.1
+
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-Add-WPA3-Patch-in-supplicant.patch b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-Add-WPA3-Patch-in-supplicant.patch
new file mode 100644
index 0000000..574c352
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-Add-WPA3-Patch-in-supplicant.patch
@@ -0,0 +1,423 @@
+From 3068b274569a9ffa85fea32f81889970b87b5b47 Mon Sep 17 00:00:00 2001
+From: "tao.yin" <tao.yin@mediatek.com>
+Date: Tue, 21 May 2019 06:44:06 +0800
+Subject: [PATCH] Add WPA3 Patch in supplicant
+
+---
+ src/common/defs.h | 3 ++
+ src/common/ieee802_11_defs.h | 2 +
+ src/common/wpa_common.c | 52 ++++++++++++++++++++++++-
+ src/common/wpa_common.h | 1 +
+ src/drivers/driver_nl80211.c | 21 +++++++---
+ src/rsn_supp/wpa.c | 23 +++--------
+ wpa_supplicant/ctrl_iface.c | 75 ++++++++++++++++++++++++++++++++++++
+ wpa_supplicant/wpa_cli.c | 19 +++++++++
+ 8 files changed, 172 insertions(+), 24 deletions(-)
+
+diff --git a/src/common/defs.h b/src/common/defs.h
+index 4f56794..25d6718 100644
+--- a/src/common/defs.h
++++ b/src/common/defs.h
+@@ -51,6 +51,7 @@ typedef enum { FALSE = 0, TRUE = 1 } Boolean;
+ #define WPA_KEY_MGMT_OSEN BIT(15)
+ #define WPA_KEY_MGMT_IEEE8021X_SUITE_B BIT(16)
+ #define WPA_KEY_MGMT_IEEE8021X_SUITE_B_192 BIT(17)
++#define WPA_KEY_MGMT_OWE BIT(22)
+
+ static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
+ {
+@@ -89,6 +90,8 @@ static inline int wpa_key_mgmt_sha256(int akm)
+ {
+ return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
+ WPA_KEY_MGMT_IEEE8021X_SHA256 |
++ WPA_KEY_MGMT_SAE |
++ WPA_KEY_MGMT_FT_SAE |
+ WPA_KEY_MGMT_OSEN |
+ WPA_KEY_MGMT_IEEE8021X_SUITE_B));
+ }
+diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
+index d453aec..f48d851 100644
+--- a/src/common/ieee802_11_defs.h
++++ b/src/common/ieee802_11_defs.h
+@@ -1393,8 +1393,10 @@ enum plink_action_field {
+ #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
+ #define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
+ #define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
++#define WLAN_AKM_SUITE_SAE 0x000FAC08
+ #define WLAN_AKM_SUITE_8021X_SUITE_B 0x000FAC11
+ #define WLAN_AKM_SUITE_8021X_SUITE_B_192 0x000FAC12
++#define WLAN_AKM_SUITE_OWE 0x000FAC18
+ #define WLAN_AKM_SUITE_CCKM 0x00409600
+ #define WLAN_AKM_SUITE_OSEN 0x506f9a01
+
+diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
+index 299b8bb..8502162 100644
+--- a/src/common/wpa_common.c
++++ b/src/common/wpa_common.c
+@@ -43,6 +43,38 @@ unsigned int wpa_mic_len(int akmp)
+ return 16;
+ }
+
++/**
++ * wpa_use_akm_defined - Is AKM-defined Key Descriptor Version used
++ * @akmp: WPA_KEY_MGMT_* used in key derivation
++ * Returns: 1 if AKM-defined Key Descriptor Version is used; 0 otherwise
++ */
++int wpa_use_akm_defined(int akmp)
++{
++ return akmp == WPA_KEY_MGMT_OSEN ||
++ akmp == WPA_KEY_MGMT_OWE ||
++ wpa_key_mgmt_sae(akmp) ||
++ wpa_key_mgmt_suite_b(akmp);
++}
++
++/**
++ * wpa_use_aes_key_wrap - Is AES Keywrap algorithm used for EAPOL-Key Key Data
++ * @akmp: WPA_KEY_MGMT_* used in key derivation
++ * Returns: 1 if AES Keywrap is used; 0 otherwise
++ *
++ * Note: AKM 00-0F-AC:1 and 00-0F-AC:2 have special rules for selecting whether
++
++ * to use AES Keywrap based on the negotiated pairwise cipher. This function
++ * does not cover those special cases.
++ */
++int wpa_use_aes_key_wrap(int akmp)
++{
++ return akmp == WPA_KEY_MGMT_OSEN ||
++ akmp == WPA_KEY_MGMT_OWE ||
++ wpa_key_mgmt_ft(akmp) ||
++ wpa_key_mgmt_sha256(akmp) ||
++ wpa_key_mgmt_sae(akmp) ||
++ wpa_key_mgmt_suite_b(akmp);
++}
+
+ /**
+ * wpa_eapol_key_mic - Calculate EAPOL-Key MIC
+@@ -85,6 +117,13 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver,
+ #endif /* CONFIG_IEEE80211R || CONFIG_IEEE80211W */
+ case WPA_KEY_INFO_TYPE_AKM_DEFINED:
+ switch (akmp) {
++#ifdef CONFIG_SAE
++ case WPA_KEY_MGMT_SAE:
++ case WPA_KEY_MGMT_FT_SAE:
++ wpa_printf(MSG_DEBUG,
++ "WPA: EAPOL-Key MIC using AES-CMAC (AKM-defined - SAE)");
++ return omac1_aes_128(key, buf, len, mic);
++#endif /* CONFIG_SAE */
+ #ifdef CONFIG_HS20
+ case WPA_KEY_MGMT_OSEN:
+ return omac1_aes_128(key, buf, len, mic);
+@@ -108,6 +147,9 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver,
+ }
+ break;
+ default:
++ wpa_printf(MSG_DEBUG,
++ "WPA: EAPOL-Key MIC algorithm not known (ver=%d)",
++ ver);
+ return -1;
+ }
+
+@@ -657,7 +699,9 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
+ pos += RSN_SELECTOR_LEN;
+ left -= RSN_SELECTOR_LEN;
+ }
+- } else if (left == 1) {
++ }
++
++ if (left == 1) {
+ wpa_printf(MSG_DEBUG, "%s: ie too short (for capabilities)",
+ __func__);
+ return -7;
+@@ -669,6 +713,12 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len,
+ left -= 2;
+ }
+
++ if (left == 1) {
++ wpa_printf(MSG_DEBUG, "%s: ie too short (for PMKID)",
++ __func__);
++ return -8;
++ }
++
+ if (left >= 2) {
+ u16 num_pmkid = WPA_GET_LE16(pos);
+ pos += 2;
+diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
+index 1021ccb..7dcd0ea 100644
+--- a/src/common/wpa_common.h
++++ b/src/common/wpa_common.h
+@@ -61,6 +61,7 @@ WPA_CIPHER_GTK_NOT_USED)
+ #define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192 RSN_SELECTOR(0x00, 0x0f, 0xac, 12)
+ #define RSN_AUTH_KEY_MGMT_FT_802_1X_SUITE_B_192 \
+ RSN_SELECTOR(0x00, 0x0f, 0xac, 13)
++#define RSN_AUTH_KEY_MGMT_OWE RSN_SELECTOR(0x00, 0x0f, 0xac, 18)
+ #define RSN_AUTH_KEY_MGMT_CCKM RSN_SELECTOR(0x00, 0x40, 0x96, 0x00)
+ #define RSN_AUTH_KEY_MGMT_OSEN RSN_SELECTOR(0x50, 0x6f, 0x9a, 0x01)
+
+diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
+index 1210d43..883acf8 100644
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -2913,7 +2913,8 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
+ int reason_code)
+ {
+ int ret;
+-
++ int drv_associated = drv->associated;
++
+ wpa_printf(MSG_DEBUG, "%s(reason_code=%d)", __func__, reason_code);
+ nl80211_mark_disconnected(drv);
+ /* Disconnect command doesn't need BSSID - it uses cached value */
+@@ -2922,9 +2923,8 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
+ /*
+ * For locally generated disconnect, supplicant already generates a
+ * DEAUTH event, so ignore the event from NL80211.
+- */
+- drv->ignore_next_local_disconnect = ret == 0;
+-
++ */
++ drv->ignore_next_local_disconnect = drv_associated && (ret == 0);
+ return ret;
+ }
+
+@@ -2934,6 +2934,7 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
+ {
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+ int ret;
++ int drv_associated = drv->associated;
+
+ if (drv->nlmode == NL80211_IFTYPE_ADHOC) {
+ nl80211_mark_disconnected(drv);
+@@ -2949,8 +2950,8 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
+ /*
+ * For locally generated deauthenticate, supplicant already generates a
+ * DEAUTH event, so ignore the event from NL80211.
+- */
+- drv->ignore_next_local_deauth = ret == 0;
++ */
++ drv->ignore_next_local_deauth = drv_associated && (ret == 0);
+ return ret;
+ }
+
+@@ -4905,6 +4906,8 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv,
+
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_PSK ||
++ params->key_mgmt_suite == WPA_KEY_MGMT_OWE ||
++ params->key_mgmt_suite == WPA_KEY_MGMT_SAE ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_FT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_FT_PSK ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_CCKM ||
+@@ -4943,6 +4946,12 @@ static int nl80211_connect_common(struct wpa_driver_nl80211_data *drv,
+ case WPA_KEY_MGMT_IEEE8021X_SUITE_B_192:
+ mgmt = WLAN_AKM_SUITE_8021X_SUITE_B_192;
+ break;
++ case WPA_KEY_MGMT_OWE:
++ mgmt = WLAN_AKM_SUITE_OWE;
++ break;
++ case WPA_KEY_MGMT_SAE:
++ mgmt = WLAN_AKM_SUITE_SAE;
++ break;
+ case WPA_KEY_MGMT_PSK:
+ default:
+ mgmt = WLAN_AKM_SUITE_PSK;
+diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
+index 2a53c6f..9cfa58f 100644
+--- a/src/rsn_supp/wpa.c
++++ b/src/rsn_supp/wpa.c
+@@ -1708,8 +1708,7 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm,
+ #endif /* CONFIG_NO_RC4 */
+ } else if (ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES ||
+ ver == WPA_KEY_INFO_TYPE_AES_128_CMAC ||
+- sm->key_mgmt == WPA_KEY_MGMT_OSEN ||
+- wpa_key_mgmt_suite_b(sm->key_mgmt)) {
++ wpa_use_aes_key_wrap(sm->key_mgmt)) {
+ u8 *buf;
+ if (*key_data_len < 8 || *key_data_len % 8) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
+@@ -1922,23 +1921,14 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
+ ver != WPA_KEY_INFO_TYPE_AES_128_CMAC &&
+ #endif /* CONFIG_IEEE80211R || CONFIG_IEEE80211W */
+ ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES &&
+- !wpa_key_mgmt_suite_b(sm->key_mgmt) &&
+- sm->key_mgmt != WPA_KEY_MGMT_OSEN) {
++ !wpa_use_akm_defined(sm->key_mgmt)) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+ "WPA: Unsupported EAPOL-Key descriptor version %d",
+ ver);
+ goto out;
+ }
+
+- if (sm->key_mgmt == WPA_KEY_MGMT_OSEN &&
+- ver != WPA_KEY_INFO_TYPE_AKM_DEFINED) {
+- wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+- "OSEN: Unsupported EAPOL-Key descriptor version %d",
+- ver);
+- goto out;
+- }
+-
+- if (wpa_key_mgmt_suite_b(sm->key_mgmt) &&
++ if (wpa_use_akm_defined(sm->key_mgmt) &&
+ ver != WPA_KEY_INFO_TYPE_AKM_DEFINED) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+ "RSN: Unsupported EAPOL-Key descriptor version %d (expected AKM defined = 0)",
+@@ -1959,8 +1949,7 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
+ #ifdef CONFIG_IEEE80211W
+ if (wpa_key_mgmt_sha256(sm->key_mgmt)) {
+ if (ver != WPA_KEY_INFO_TYPE_AES_128_CMAC &&
+- sm->key_mgmt != WPA_KEY_MGMT_OSEN &&
+- !wpa_key_mgmt_suite_b(sm->key_mgmt)) {
++ !wpa_use_akm_defined(sm->key_mgmt)) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+ "WPA: AP did not use the "
+ "negotiated AES-128-CMAC");
+@@ -1969,7 +1958,7 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
+ } else
+ #endif /* CONFIG_IEEE80211W */
+ if (sm->pairwise_cipher == WPA_CIPHER_CCMP &&
+- !wpa_key_mgmt_suite_b(sm->key_mgmt) &&
++ !wpa_use_akm_defined(sm->key_mgmt) &&
+ ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+ "WPA: CCMP is used, but EAPOL-Key "
+@@ -1989,7 +1978,7 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
+ } else
+ goto out;
+ } else if (sm->pairwise_cipher == WPA_CIPHER_GCMP &&
+- !wpa_key_mgmt_suite_b(sm->key_mgmt) &&
++ !wpa_use_akm_defined(sm->key_mgmt) &&
+ ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) {
+ wpa_msg(sm->ctx->msg_ctx, MSG_INFO,
+ "WPA: GCMP is used, but EAPOL-Key "
+diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
+index d814fdf..eae83c2 100644
+--- a/wpa_supplicant/ctrl_iface.c
++++ b/wpa_supplicant/ctrl_iface.c
+@@ -4533,6 +4533,73 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
+ return ret;
+ }
+
++//Shaomin
++// Refer to "wpa_config_process_sae_groups", but no notify changing.
++// Need to "RECONFIGURE" manually in sigma.
++static int * wpa_config_parse_int_array(const char *value)
++{
++ int *freqs;
++ size_t used, len;
++ const char *pos;
++ used = 0;
++ len = 10;
++ freqs = os_calloc(len + 1, sizeof(int));
++ if (freqs == NULL)
++ return NULL;
++ pos = value;
++ while (pos) {
++ while (*pos == ' ')
++ pos++;
++ if (used == len) {
++ int *n;
++ size_t i;
++ n = os_realloc_array(freqs, len * 2 + 1, sizeof(int));
++ if (n == NULL) {
++ os_free(freqs);
++ return NULL;
++ }
++ for (i = len; i <= len * 2; i++)
++ n[i] = 0;
++ freqs = n;
++ len *= 2;
++ }
++ freqs[used] = atoi(pos);
++ if (freqs[used] == 0)
++ break;
++ used++;
++ pos = os_strchr(pos + 1, ' ');
++ }
++ return freqs;
++}
++
++static int wpa_supplicant_ctrl_iface_sae_groups(
++ struct wpa_supplicant *wpa_s, char *cmd)
++{
++ int *groups = wpa_config_parse_int_array(cmd);
++ if (groups == NULL) {
++ wpa_printf(MSG_ERROR, "Ctrl Iface: Invalid sae_groups '%s'", cmd);
++ return -1;
++ }
++ os_free(wpa_s->conf->sae_groups);
++ wpa_s->conf->sae_groups = groups;
++ return 0;
++}
++
++static int wpa_supplicant_ctrl_iface_openssl_ciphers(
++ struct wpa_supplicant *wpa_s, char *cmd)
++{
++ if (cmd == NULL) {
++ wpa_printf(MSG_ERROR, "Ctrl Iface: Invalid openssl_ciphers '%s'", cmd);
++ return -1;
++ }
++ wpa_printf(MSG_INFO, "Ctrl Iface: Set openssl_ciphers '%s'", cmd);
++ os_free(wpa_s->conf->openssl_ciphers);
++ if(os_strlen(cmd)) {
++ wpa_s->conf->openssl_ciphers = os_strdup(cmd);
++ }
++ return 0;
++}
++//Shaomin <<<
+
+ static int wpa_supplicant_ctrl_iface_ap_scan(
+ struct wpa_supplicant *wpa_s, char *cmd)
+@@ -9353,6 +9420,14 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
+ } else if (os_strncmp(buf, "GET_PREF_FREQ_LIST ", 19) == 0) {
+ reply_len = wpas_ctrl_iface_get_pref_freq_list(
+ wpa_s, buf + 19, reply, reply_size);
++//Shaomin >>>
++ } else if (os_strncmp(buf, "SAE_GROUPS ", 11) == 0) {
++ if (wpa_supplicant_ctrl_iface_sae_groups(wpa_s, buf + 11))
++ reply_len = -1;
++ } else if (os_strncmp(buf, "OPENSSL_CIPHERS ", 16) == 0) {
++ if (wpa_supplicant_ctrl_iface_openssl_ciphers(wpa_s, buf + 16))
++ reply_len = -1;
++// Shaomin <<<
+ } else {
+ os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
+ reply_len = 16;
+diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
+index a848b77..32f7a1f 100644
+--- a/wpa_supplicant/wpa_cli.c
++++ b/wpa_supplicant/wpa_cli.c
+@@ -594,6 +594,17 @@ static int wpa_cli_cmd_preauthenticate(struct wpa_ctrl *ctrl, int argc,
+ return wpa_cli_cmd(ctrl, "PREAUTH", 1, argc, argv);
+ }
+
++//Shaomin >>>
++static int wpa_cli_cmd_sae_groups(struct wpa_ctrl *ctrl, int argc, char *argv[])
++{
++ return wpa_cli_cmd(ctrl, "SAE_GROUPS", 1, argc, argv);
++}
++
++static int wpa_cli_cmd_openssl_ciphers(struct wpa_ctrl *ctrl, int argc, char *argv[])
++{
++ return wpa_cli_cmd(ctrl, "OPENSSL_CIPHERS", 1, argc, argv);
++}
++//Shaomin <<<
+
+ static int wpa_cli_cmd_ap_scan(struct wpa_ctrl *ctrl, int argc, char *argv[])
+ {
+@@ -2740,6 +2751,14 @@ struct wpa_cli_cmd {
+ };
+
+ static const struct wpa_cli_cmd wpa_cli_commands[] = {
++ //Shaomin >>>
++ { "sae_groups", wpa_cli_cmd_sae_groups, NULL,
++ cli_cmd_flag_none,
++ "supported sae groups list, ex 19 20" },
++ { "openssl_ciphers", wpa_cli_cmd_openssl_ciphers, NULL,
++ cli_cmd_flag_none,
++ "supported openssl ciphers, ex ECDHE-ECDSA-AES256-GCM-SHA384" },
++ //Shaomin <<<
+ { "status", wpa_cli_cmd_status, NULL,
+ cli_cmd_flag_none,
+ "[verbose] = get current WPA/EAPOL/EAP status" },
+--
+2.21.0
+
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-wpa_supplicant_modify_ctrl_dir.patch b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-wpa_supplicant_modify_ctrl_dir.patch
new file mode 100644
index 0000000..b9b9934
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/0001-wpa_supplicant_modify_ctrl_dir.patch
@@ -0,0 +1,25 @@
+From 7fda8988a02425f790ab60cecde255a9bd825245 Mon Sep 17 00:00:00 2001
+From: "jianling.fu" <jianling.fu@mediatek.com>
+Date: Tue, 19 Feb 2019 14:46:46 +0800
+Subject: [PATCH] wpa_supplicant_modify_ctrl_dir
+
+---
+ wpa_supplicant/Makefile | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
+index f3e86c1..27c2556 100644
+--- a/wpa_supplicant/Makefile
++++ b/wpa_supplicant/Makefile
+@@ -44,6 +44,8 @@ CONFIG_WPS_TESTING=y
+ CONFIG_TDLS_TESTING=y
+ endif
+
++CFLAGS += -DCONFIG_CTRL_IFACE_DIR=\"/tmp/wpa_supplicant\"
++
+ BINALL=wpa_supplicant wpa_cli
+
+ ifndef CONFIG_NO_WPA_PASSPHRASE
+--
+1.9.1
+
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/defconfig b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/defconfig
new file mode 100644
index 0000000..43c2c03
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/files/defconfig
@@ -0,0 +1,555 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+# Note: WEXT is deprecated in the current Linux kernel version and no new
+# functionality is added to it. nl80211-based interface is the new
+# replacement for WEXT and its use allows wpa_supplicant to properly control
+# the driver to improve existing functionality like roaming and to support new
+# functionality.
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# driver_nl80211.c requires libnl. If you are compiling it yourself
+# you may need to point hostapd to your version of libnl.
+#
+#CFLAGS += -I$<path to libnl include files>
+#LIBS += -L$<path to libnl library files>
+
+# Use libnl v2.0 (or 3.0) libraries.
+#CONFIG_LIBNL20=y
+
+# Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored)
+CONFIG_LIBNL32=y
+
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: If OpenSSL is used as the TLS library, OpenSSL 1.0 or newer is needed
+# for EAP-FAST support. Older OpenSSL releases would need to be patched, e.g.,
+# with openssl-0.9.8x-tls-extensions.patch, to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+CONFIG_EAP_GTC=y
+
+# EAP-OTP
+CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-pwd (secure authentication using only a password)
+#CONFIG_EAP_PWD=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+# Enable WSC 2.0 support
+#CONFIG_WPS2=y
+# Enable WPS external registrar functionality
+#CONFIG_WPS_ER=y
+# Disable credentials for an open network by default when acting as a WPS
+# registrar.
+#CONFIG_WPS_REG_DISABLE_OPEN=y
+# Enable WPS support with NFC config method
+#CONFIG_WPS_NFC=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# EAP-EKE
+#CONFIG_EAP_EKE=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Support HT overrides (disable HT/HT40, mask MCS rates, etc.)
+#CONFIG_HT_OVERRIDES=y
+
+# Support VHT overrides (disable VHT, mask MCS rates, etc.)
+#CONFIG_VHT_OVERRIDES=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# udp-remote = UDP sockets with remote access (only for tests systems/purpose)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Include internal line edit mode in wpa_cli. This can be used as a replacement
+# for GNU Readline to provide limited command line editing and history support.
+#CONFIG_WPA_CLI_EDIT=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+#CONFIG_ELOOP=eloop
+
+# Should we use poll instead of select? Select is used by default.
+#CONFIG_ELOOP_POLL=y
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection), also known as PMF
+# Driver support is also needed for IEEE 802.11w.
+CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+#CONFIG_TLS=openssl
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.1)
+# can be enabled to get a stronger construction of messages when block ciphers
+# are used. It should be noted that some existing TLS v1.0 -based
+# implementation may not be compatible with TLS v1.1 message (ClientHello is
+# sent prior to negotiating which version will be used)
+#CONFIG_TLSV11=y
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.2)
+# can be enabled to enable use of stronger crypto algorithms. It should be
+# noted that some existing TLS v1.0 -based implementation may not be compatible
+# with TLS v1.2 message (ClientHello is sent prior to negotiating which version
+# will be used)
+#CONFIG_TLSV12=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+#CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Send debug messages to syslog instead of stdout
+#CONFIG_DEBUG_SYSLOG=y
+# Set syslog facility for debug messages
+#CONFIG_DEBUG_SYSLOG_FACILITY=LOG_DAEMON
+
+# Add support for sending all debug messages (regardless of debug verbosity)
+# to the Linux kernel tracing facility. This helps debug the entire stack by
+# making it easy to record everything happening from the driver up into the
+# same file, e.g., using trace-cmd.
+#CONFIG_DEBUG_LINUX_TRACING=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, uncomment these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, uncomment these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+CONFIG_TLS = %ssl%
+CONFIG_CTRL_IFACE_DBUS=y
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# wpa_supplicant depends on strong random number generation being available
+# from the operating system. os_get_random() function is used to fetch random
+# data when needed, e.g., for key generation. On Linux and BSD systems, this
+# works by reading /dev/urandom. It should be noted that the OS entropy pool
+# needs to be properly initialized before wpa_supplicant is started. This is
+# important especially on embedded devices that do not have a hardware random
+# number generator and may by default start up with minimal entropy available
+# for random number generation.
+#
+# As a safety net, wpa_supplicant is by default trying to internally collect
+# additional entropy for generating random data to mix in with the data fetched
+# from the OS. This by itself is not considered to be very strong, but it may
+# help in cases where the system pool is not initialized properly. However, it
+# is very strongly recommended that the system pool is initialized with enough
+# entropy either by using hardware assisted random number generator or by
+# storing state over device reboots.
+#
+# wpa_supplicant can be configured to maintain its own entropy store over
+# restarts to enhance random number generation. This is not perfect, but it is
+# much more secure than using the same sequence of random numbers after every
+# reboot. This can be enabled with -e<entropy file> command line option. The
+# specified file needs to be readable and writable by wpa_supplicant.
+#
+# If the os_get_random() is known to provide strong random data (e.g., on
+# Linux/BSD, the board in question is known to have reliable source of random
+# data from /dev/urandom), the internal wpa_supplicant random pool can be
+# disabled. This will save some in binary size and CPU use. However, this
+# should only be considered for builds that are known to be used on devices
+# that meet the requirements described above.
+#CONFIG_NO_RANDOM_POOL=y
+
+# IEEE 802.11n (High Throughput) support (mainly for AP mode)
+CONFIG_IEEE80211N=y
+
+# IEEE 802.11ac (Very High Throughput) support (mainly for AP mode)
+# (depends on CONFIG_IEEE80211N)
+CONFIG_IEEE80211AC=y
+
+# Wireless Network Management (IEEE Std 802.11v-2011)
+# Note: This is experimental and not complete implementation.
+CONFIG_WNM=y
+
+# Interworking (IEEE 802.11u)
+# This can be used to enable functionality to improve interworking with
+# external networks (GAS/ANQP to learn more about the networks and network
+# selection based on available credentials).
+#CONFIG_INTERWORKING=y
+
+# Hotspot 2.0
+#CONFIG_HS20=y
+
+# Disable roaming in wpa_supplicant
+#CONFIG_NO_ROAMING=y
+
+# AP mode operations with wpa_supplicant
+# This can be used for controlling AP mode operations with wpa_supplicant. It
+# should be noted that this is mainly aimed at simple cases like
+# WPA2-Personal while more complex configurations like WPA2-Enterprise with an
+# external RADIUS server can be supported with hostapd.
+CONFIG_AP=y
+
+CONFIG_BGSCAN_SIMPLE=y
+
+# P2P (Wi-Fi Direct)
+# This can be used to enable P2P support in wpa_supplicant. See README-P2P for
+# more information on P2P operations.
+#CONFIG_P2P=y
+
+# Enable TDLS support
+CONFIG_TDLS=y
+
+# Wi-Fi Direct
+# This can be used to enable Wi-Fi Direct extensions for P2P using an external
+# program to control the additional information exchanges in the messages.
+#CONFIG_WIFI_DISPLAY=y
+
+# Autoscan
+# This can be used to enable automatic scan support in wpa_supplicant.
+# See wpa_supplicant.conf for more information on autoscan usage.
+#
+# Enabling directly a module will enable autoscan support.
+# For exponential module:
+CONFIG_AUTOSCAN_EXPONENTIAL=y
+# For periodic module:
+#CONFIG_AUTOSCAN_PERIODIC=y
+
+# Password (and passphrase, etc.) backend for external storage
+# These optional mechanisms can be used to add support for storing passwords
+# and other secrets in external (to wpa_supplicant) location. This allows, for
+# example, operating system specific key storage to be used
+#
+# External password backend for testing purposes (developer use)
+#CONFIG_EXT_PASSWORD_TEST=y
+
+# Support WPA3
+CONFIG_SAE=y
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-AP-Silently-ignore-management-frame-from-unexpected-.patch b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-AP-Silently-ignore-management-frame-from-unexpected-.patch
new file mode 100644
index 0000000..7b0713c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-AP-Silently-ignore-management-frame-from-unexpected-.patch
@@ -0,0 +1,82 @@
+hostapd before 2.10 and wpa_supplicant before 2.10 allow an incorrect indication
+of disconnection in certain situations because source address validation is
+mishandled. This is a denial of service that should have been prevented by PMF
+(aka management frame protection). The attacker must send a crafted 802.11 frame
+from a location that is within the 802.11 communications range.
+
+CVE: CVE-2019-16275
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+
+From 8c07fa9eda13e835f3f968b2e1c9a8be3a851ff9 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j@w1.fi>
+Date: Thu, 29 Aug 2019 11:52:04 +0300
+Subject: [PATCH] AP: Silently ignore management frame from unexpected source
+ address
+
+Do not process any received Management frames with unexpected/invalid SA
+so that we do not add any state for unexpected STA addresses or end up
+sending out frames to unexpected destination. This prevents unexpected
+sequences where an unprotected frame might end up causing the AP to send
+out a response to another device and that other device processing the
+unexpected response.
+
+In particular, this prevents some potential denial of service cases
+where the unexpected response frame from the AP might result in a
+connected station dropping its association.
+
+Signed-off-by: Jouni Malinen <j@w1.fi>
+---
+ src/ap/drv_callbacks.c | 13 +++++++++++++
+ src/ap/ieee802_11.c | 12 ++++++++++++
+ 2 files changed, 25 insertions(+)
+
+diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
+index 31587685fe3b..34ca379edc3d 100644
+--- a/src/ap/drv_callbacks.c
++++ b/src/ap/drv_callbacks.c
+@@ -131,6 +131,19 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
+ "hostapd_notif_assoc: Skip event with no address");
+ return -1;
+ }
++
++ if (is_multicast_ether_addr(addr) ||
++ is_zero_ether_addr(addr) ||
++ os_memcmp(addr, hapd->own_addr, ETH_ALEN) == 0) {
++ /* Do not process any frames with unexpected/invalid SA so that
++ * we do not add any state for unexpected STA addresses or end
++ * up sending out frames to unexpected destination. */
++ wpa_printf(MSG_DEBUG, "%s: Invalid SA=" MACSTR
++ " in received indication - ignore this indication silently",
++ __func__, MAC2STR(addr));
++ return 0;
++ }
++
+ random_add_randomness(addr, ETH_ALEN);
+
+ hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
+diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
+index c85a28db44b7..e7065372e158 100644
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -4626,6 +4626,18 @@ int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
+ fc = le_to_host16(mgmt->frame_control);
+ stype = WLAN_FC_GET_STYPE(fc);
+
++ if (is_multicast_ether_addr(mgmt->sa) ||
++ is_zero_ether_addr(mgmt->sa) ||
++ os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
++ /* Do not process any frames with unexpected/invalid SA so that
++ * we do not add any state for unexpected STA addresses or end
++ * up sending out frames to unexpected destination. */
++ wpa_printf(MSG_DEBUG, "MGMT: Invalid SA=" MACSTR
++ " in received frame - ignore this frame silently",
++ MAC2STR(mgmt->sa));
++ return 0;
++ }
++
+ if (stype == WLAN_FC_STYPE_BEACON) {
+ handle_beacon(hapd, mgmt, len, fi);
+ return 1;
+--
+2.20.1
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-replace-systemd-install-Alias-with-WantedBy.patch b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-replace-systemd-install-Alias-with-WantedBy.patch
new file mode 100644
index 0000000..a476cf0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/0001-replace-systemd-install-Alias-with-WantedBy.patch
@@ -0,0 +1,52 @@
+From 94c401733a5a3d294cc412671166e6adfb409f53 Mon Sep 17 00:00:00 2001
+From: Joshua DeWeese <jdeweese@hennypenny.com>
+Date: Wed, 30 Jan 2019 16:19:47 -0500
+Subject: [PATCH] replace systemd install Alias with WantedBy
+
+According to the systemd documentation "WantedBy=foo.service in a
+service bar.service is mostly equivalent to
+Alias=foo.service.wants/bar.service in the same file." However,
+this is not really the intended purpose of install Aliases.
+
+Upstream-Status: Submitted [hostap@lists.infradead.org]
+
+Signed-off-by: Joshua DeWeese <jdeweese@hennypenny.com>
+---
+ wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in | 2 +-
+ wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in | 2 +-
+ wpa_supplicant/systemd/wpa_supplicant.service.arg.in | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
+index 03ac507..da69a87 100644
+--- a/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
++++ b/wpa_supplicant/systemd/wpa_supplicant-nl80211.service.arg.in
+@@ -12,4 +12,4 @@ Type=simple
+ ExecStart=@BINDIR@/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-nl80211-%I.conf -Dnl80211 -i%I
+
+ [Install]
+-Alias=multi-user.target.wants/wpa_supplicant-nl80211@%i.service
++WantedBy=multi-user.target
+diff --git a/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
+index c8a744d..ca3054b 100644
+--- a/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
++++ b/wpa_supplicant/systemd/wpa_supplicant-wired.service.arg.in
+@@ -12,4 +12,4 @@ Type=simple
+ ExecStart=@BINDIR@/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wired-%I.conf -Dwired -i%I
+
+ [Install]
+-Alias=multi-user.target.wants/wpa_supplicant-wired@%i.service
++WantedBy=multi-user.target
+diff --git a/wpa_supplicant/systemd/wpa_supplicant.service.arg.in b/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
+index 7788b38..55d2b9c 100644
+--- a/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
++++ b/wpa_supplicant/systemd/wpa_supplicant.service.arg.in
+@@ -12,4 +12,4 @@ Type=simple
+ ExecStart=@BINDIR@/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
+
+ [Install]
+-Alias=multi-user.target.wants/wpa_supplicant@%i.service
++WantedBy=multi-user.target
+--
+2.7.4
+
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/99_wpa_supplicant b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/99_wpa_supplicant
new file mode 100644
index 0000000..6ff4dd8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/99_wpa_supplicant
@@ -0,0 +1 @@
+d root root 0700 /var/run/wpa_supplicant none
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/defconfig b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/defconfig
new file mode 100644
index 0000000..f04e398
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/defconfig
@@ -0,0 +1,552 @@
+# Example wpa_supplicant build time configuration
+#
+# This file lists the configuration options that are used when building the
+# hostapd binary. All lines starting with # are ignored. Configuration option
+# lines must be commented out complete, if they are not to be included, i.e.,
+# just setting VARIABLE=n is not disabling that variable.
+#
+# This file is included in Makefile, so variables like CFLAGS and LIBS can also
+# be modified from here. In most cases, these lines should use += in order not
+# to override previous values of the variables.
+
+
+# Uncomment following two lines and fix the paths if you have installed OpenSSL
+# or GnuTLS in non-default location
+#CFLAGS += -I/usr/local/openssl/include
+#LIBS += -L/usr/local/openssl/lib
+
+# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
+# the kerberos files are not in the default include path. Following line can be
+# used to fix build issues on such systems (krb5.h not found).
+#CFLAGS += -I/usr/include/kerberos
+
+# Example configuration for various cross-compilation platforms
+
+#### sveasoft (e.g., for Linksys WRT54G) ######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
+#LIBS += -L/opt/brcm/hndtools-mipsel-uclibc-0.9.19/lib -lssl
+###############################################################################
+
+#### openwrt (e.g., for Linksys WRT54G) #######################################
+#CC=mipsel-uclibc-gcc
+#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
+#CFLAGS += -Os
+#CPPFLAGS=-I../src/include -I../openssl-0.9.7d/include \
+# -I../WRT54GS/release/src/include
+#LIBS = -lssl
+###############################################################################
+
+
+# Driver interface for Host AP driver
+CONFIG_DRIVER_HOSTAP=y
+
+# Driver interface for Agere driver
+#CONFIG_DRIVER_HERMES=y
+# Change include directories to match with the local setup
+#CFLAGS += -I../../hcf -I../../include -I../../include/hcf
+#CFLAGS += -I../../include/wireless
+
+# Driver interface for madwifi driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_MADWIFI=y
+# Set include directory to the madwifi source tree
+#CFLAGS += -I../../madwifi
+
+# Driver interface for ndiswrapper
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_NDISWRAPPER=y
+
+# Driver interface for Atmel driver
+# CONFIG_DRIVER_ATMEL=y
+
+# Driver interface for old Broadcom driver
+# Please note that the newer Broadcom driver ("hybrid Linux driver") supports
+# Linux wireless extensions and does not need (or even work) with the old
+# driver wrapper. Use CONFIG_DRIVER_WEXT=y with that driver.
+#CONFIG_DRIVER_BROADCOM=y
+# Example path for wlioctl.h; change to match your configuration
+#CFLAGS += -I/opt/WRT54GS/release/src/include
+
+# Driver interface for Intel ipw2100/2200 driver
+# Deprecated; use CONFIG_DRIVER_WEXT=y instead.
+#CONFIG_DRIVER_IPW=y
+
+# Driver interface for Ralink driver
+#CONFIG_DRIVER_RALINK=y
+
+# Driver interface for generic Linux wireless extensions
+# Note: WEXT is deprecated in the current Linux kernel version and no new
+# functionality is added to it. nl80211-based interface is the new
+# replacement for WEXT and its use allows wpa_supplicant to properly control
+# the driver to improve existing functionality like roaming and to support new
+# functionality.
+CONFIG_DRIVER_WEXT=y
+
+# Driver interface for Linux drivers using the nl80211 kernel interface
+CONFIG_DRIVER_NL80211=y
+
+# driver_nl80211.c requires libnl. If you are compiling it yourself
+# you may need to point hostapd to your version of libnl.
+#
+#CFLAGS += -I$<path to libnl include files>
+#LIBS += -L$<path to libnl library files>
+
+# Use libnl v2.0 (or 3.0) libraries.
+#CONFIG_LIBNL20=y
+
+# Use libnl 3.2 libraries (if this is selected, CONFIG_LIBNL20 is ignored)
+CONFIG_LIBNL32=y
+
+
+# Driver interface for FreeBSD net80211 layer (e.g., Atheros driver)
+#CONFIG_DRIVER_BSD=y
+#CFLAGS += -I/usr/local/include
+#LIBS += -L/usr/local/lib
+#LIBS_p += -L/usr/local/lib
+#LIBS_c += -L/usr/local/lib
+
+# Driver interface for Windows NDIS
+#CONFIG_DRIVER_NDIS=y
+#CFLAGS += -I/usr/include/w32api/ddk
+#LIBS += -L/usr/local/lib
+# For native build using mingw
+#CONFIG_NATIVE_WINDOWS=y
+# Additional directories for cross-compilation on Linux host for mingw target
+#CFLAGS += -I/opt/mingw/mingw32/include/ddk
+#LIBS += -L/opt/mingw/mingw32/lib
+#CC=mingw32-gcc
+# By default, driver_ndis uses WinPcap for low-level operations. This can be
+# replaced with the following option which replaces WinPcap calls with NDISUIO.
+# However, this requires that WZC is disabled (net stop wzcsvc) before starting
+# wpa_supplicant.
+# CONFIG_USE_NDISUIO=y
+
+# Driver interface for development testing
+#CONFIG_DRIVER_TEST=y
+
+# Driver interface for wired Ethernet drivers
+CONFIG_DRIVER_WIRED=y
+
+# Driver interface for the Broadcom RoboSwitch family
+#CONFIG_DRIVER_ROBOSWITCH=y
+
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
+# Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
+# included)
+CONFIG_IEEE8021X_EAPOL=y
+
+# EAP-MD5
+CONFIG_EAP_MD5=y
+
+# EAP-MSCHAPv2
+CONFIG_EAP_MSCHAPV2=y
+
+# EAP-TLS
+CONFIG_EAP_TLS=y
+
+# EAL-PEAP
+CONFIG_EAP_PEAP=y
+
+# EAP-TTLS
+CONFIG_EAP_TTLS=y
+
+# EAP-FAST
+# Note: If OpenSSL is used as the TLS library, OpenSSL 1.0 or newer is needed
+# for EAP-FAST support. Older OpenSSL releases would need to be patched, e.g.,
+# with openssl-0.9.8x-tls-extensions.patch, to add the needed functions.
+#CONFIG_EAP_FAST=y
+
+# EAP-GTC
+CONFIG_EAP_GTC=y
+
+# EAP-OTP
+CONFIG_EAP_OTP=y
+
+# EAP-SIM (enable CONFIG_PCSC, if EAP-SIM is used)
+#CONFIG_EAP_SIM=y
+
+# EAP-PSK (experimental; this is _not_ needed for WPA-PSK)
+#CONFIG_EAP_PSK=y
+
+# EAP-pwd (secure authentication using only a password)
+#CONFIG_EAP_PWD=y
+
+# EAP-PAX
+#CONFIG_EAP_PAX=y
+
+# LEAP
+CONFIG_EAP_LEAP=y
+
+# EAP-AKA (enable CONFIG_PCSC, if EAP-AKA is used)
+#CONFIG_EAP_AKA=y
+
+# EAP-AKA' (enable CONFIG_PCSC, if EAP-AKA' is used).
+# This requires CONFIG_EAP_AKA to be enabled, too.
+#CONFIG_EAP_AKA_PRIME=y
+
+# Enable USIM simulator (Milenage) for EAP-AKA
+#CONFIG_USIM_SIMULATOR=y
+
+# EAP-SAKE
+#CONFIG_EAP_SAKE=y
+
+# EAP-GPSK
+#CONFIG_EAP_GPSK=y
+# Include support for optional SHA256 cipher suite in EAP-GPSK
+#CONFIG_EAP_GPSK_SHA256=y
+
+# EAP-TNC and related Trusted Network Connect support (experimental)
+#CONFIG_EAP_TNC=y
+
+# Wi-Fi Protected Setup (WPS)
+CONFIG_WPS=y
+# Enable WSC 2.0 support
+#CONFIG_WPS2=y
+# Enable WPS external registrar functionality
+#CONFIG_WPS_ER=y
+# Disable credentials for an open network by default when acting as a WPS
+# registrar.
+#CONFIG_WPS_REG_DISABLE_OPEN=y
+# Enable WPS support with NFC config method
+#CONFIG_WPS_NFC=y
+
+# EAP-IKEv2
+#CONFIG_EAP_IKEV2=y
+
+# EAP-EKE
+#CONFIG_EAP_EKE=y
+
+# PKCS#12 (PFX) support (used to read private key and certificate file from
+# a file that usually has extension .p12 or .pfx)
+CONFIG_PKCS12=y
+
+# Smartcard support (i.e., private key on a smartcard), e.g., with openssl
+# engine.
+CONFIG_SMARTCARD=y
+
+# PC/SC interface for smartcards (USIM, GSM SIM)
+# Enable this if EAP-SIM or EAP-AKA is included
+#CONFIG_PCSC=y
+
+# Support HT overrides (disable HT/HT40, mask MCS rates, etc.)
+#CONFIG_HT_OVERRIDES=y
+
+# Support VHT overrides (disable VHT, mask MCS rates, etc.)
+#CONFIG_VHT_OVERRIDES=y
+
+# Development testing
+#CONFIG_EAPOL_TEST=y
+
+# Select control interface backend for external programs, e.g, wpa_cli:
+# unix = UNIX domain sockets (default for Linux/*BSD)
+# udp = UDP sockets using localhost (127.0.0.1)
+# named_pipe = Windows Named Pipe (default for Windows)
+# udp-remote = UDP sockets with remote access (only for tests systems/purpose)
+# y = use default (backwards compatibility)
+# If this option is commented out, control interface is not included in the
+# build.
+CONFIG_CTRL_IFACE=y
+
+# Include support for GNU Readline and History Libraries in wpa_cli.
+# When building a wpa_cli binary for distribution, please note that these
+# libraries are licensed under GPL and as such, BSD license may not apply for
+# the resulting binary.
+#CONFIG_READLINE=y
+
+# Include internal line edit mode in wpa_cli. This can be used as a replacement
+# for GNU Readline to provide limited command line editing and history support.
+#CONFIG_WPA_CLI_EDIT=y
+
+# Remove debugging code that is printing out debug message to stdout.
+# This can be used to reduce the size of the wpa_supplicant considerably
+# if debugging code is not needed. The size reduction can be around 35%
+# (e.g., 90 kB).
+#CONFIG_NO_STDOUT_DEBUG=y
+
+# Remove WPA support, e.g., for wired-only IEEE 802.1X supplicant, to save
+# 35-50 kB in code size.
+#CONFIG_NO_WPA=y
+
+# Remove IEEE 802.11i/WPA-Personal ASCII passphrase support
+# This option can be used to reduce code size by removing support for
+# converting ASCII passphrases into PSK. If this functionality is removed, the
+# PSK can only be configured as the 64-octet hexstring (e.g., from
+# wpa_passphrase). This saves about 0.5 kB in code size.
+#CONFIG_NO_WPA_PASSPHRASE=y
+
+# Disable scan result processing (ap_mode=1) to save code size by about 1 kB.
+# This can be used if ap_scan=1 mode is never enabled.
+#CONFIG_NO_SCAN_PROCESSING=y
+
+# Select configuration backend:
+# file = text file (e.g., wpa_supplicant.conf; note: the configuration file
+# path is given on command line, not here; this option is just used to
+# select the backend that allows configuration files to be used)
+# winreg = Windows registry (see win_example.reg for an example)
+CONFIG_BACKEND=file
+
+# Remove configuration write functionality (i.e., to allow the configuration
+# file to be updated based on runtime configuration changes). The runtime
+# configuration can still be changed, the changes are just not going to be
+# persistent over restarts. This option can be used to reduce code size by
+# about 3.5 kB.
+#CONFIG_NO_CONFIG_WRITE=y
+
+# Remove support for configuration blobs to reduce code size by about 1.5 kB.
+#CONFIG_NO_CONFIG_BLOBS=y
+
+# Select program entry point implementation:
+# main = UNIX/POSIX like main() function (default)
+# main_winsvc = Windows service (read parameters from registry)
+# main_none = Very basic example (development use only)
+#CONFIG_MAIN=main
+
+# Select wrapper for operatins system and C library specific functions
+# unix = UNIX/POSIX like systems (default)
+# win32 = Windows systems
+# none = Empty template
+#CONFIG_OS=unix
+
+# Select event loop implementation
+# eloop = select() loop (default)
+# eloop_win = Windows events and WaitForMultipleObject() loop
+#CONFIG_ELOOP=eloop
+
+# Should we use poll instead of select? Select is used by default.
+#CONFIG_ELOOP_POLL=y
+
+# Select layer 2 packet implementation
+# linux = Linux packet socket (default)
+# pcap = libpcap/libdnet/WinPcap
+# freebsd = FreeBSD libpcap
+# winpcap = WinPcap with receive thread
+# ndis = Windows NDISUIO (note: requires CONFIG_USE_NDISUIO=y)
+# none = Empty template
+#CONFIG_L2_PACKET=linux
+
+# PeerKey handshake for Station to Station Link (IEEE 802.11e DLS)
+CONFIG_PEERKEY=y
+
+# IEEE 802.11w (management frame protection), also known as PMF
+# Driver support is also needed for IEEE 802.11w.
+#CONFIG_IEEE80211W=y
+
+# Select TLS implementation
+# openssl = OpenSSL (default)
+# gnutls = GnuTLS
+# internal = Internal TLSv1 implementation (experimental)
+# none = Empty template
+#CONFIG_TLS=openssl
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.1)
+# can be enabled to get a stronger construction of messages when block ciphers
+# are used. It should be noted that some existing TLS v1.0 -based
+# implementation may not be compatible with TLS v1.1 message (ClientHello is
+# sent prior to negotiating which version will be used)
+#CONFIG_TLSV11=y
+
+# TLS-based EAP methods require at least TLS v1.0. Newer version of TLS (v1.2)
+# can be enabled to enable use of stronger crypto algorithms. It should be
+# noted that some existing TLS v1.0 -based implementation may not be compatible
+# with TLS v1.2 message (ClientHello is sent prior to negotiating which version
+# will be used)
+#CONFIG_TLSV12=y
+
+# If CONFIG_TLS=internal is used, additional library and include paths are
+# needed for LibTomMath. Alternatively, an integrated, minimal version of
+# LibTomMath can be used. See beginning of libtommath.c for details on benefits
+# and drawbacks of this option.
+#CONFIG_INTERNAL_LIBTOMMATH=y
+#ifndef CONFIG_INTERNAL_LIBTOMMATH
+#LTM_PATH=/usr/src/libtommath-0.39
+#CFLAGS += -I$(LTM_PATH)
+#LIBS += -L$(LTM_PATH)
+#LIBS_p += -L$(LTM_PATH)
+#endif
+# At the cost of about 4 kB of additional binary size, the internal LibTomMath
+# can be configured to include faster routines for exptmod, sqr, and div to
+# speed up DH and RSA calculation considerably
+#CONFIG_INTERNAL_LIBTOMMATH_FAST=y
+
+# Include NDIS event processing through WMI into wpa_supplicant/wpasvc.
+# This is only for Windows builds and requires WMI-related header files and
+# WbemUuid.Lib from Platform SDK even when building with MinGW.
+#CONFIG_NDIS_EVENTS_INTEGRATED=y
+#PLATFORMSDKLIB="/opt/Program Files/Microsoft Platform SDK/Lib"
+
+# Add support for old DBus control interface
+# (fi.epitest.hostap.WPASupplicant)
+#CONFIG_CTRL_IFACE_DBUS=y
+
+# Add support for new DBus control interface
+# (fi.w1.hostap.wpa_supplicant1)
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# Add introspection support for new DBus control interface
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+
+# Add support for loading EAP methods dynamically as shared libraries.
+# When this option is enabled, each EAP method can be either included
+# statically (CONFIG_EAP_<method>=y) or dynamically (CONFIG_EAP_<method>=dyn).
+# Dynamic EAP methods are build as shared objects (eap_*.so) and they need to
+# be loaded in the beginning of the wpa_supplicant configuration file
+# (see load_dynamic_eap parameter in the example file) before being used in
+# the network blocks.
+#
+# Note that some shared parts of EAP methods are included in the main program
+# and in order to be able to use dynamic EAP methods using these parts, the
+# main program must have been build with the EAP method enabled (=y or =dyn).
+# This means that EAP-TLS/PEAP/TTLS/FAST cannot be added as dynamic libraries
+# unless at least one of them was included in the main build to force inclusion
+# of the shared code. Similarly, at least one of EAP-SIM/AKA must be included
+# in the main build to be able to load these methods dynamically.
+#
+# Please also note that using dynamic libraries will increase the total binary
+# size. Thus, it may not be the best option for targets that have limited
+# amount of memory/flash.
+#CONFIG_DYNAMIC_EAP_METHODS=y
+
+# IEEE Std 802.11r-2008 (Fast BSS Transition)
+#CONFIG_IEEE80211R=y
+
+# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
+#CONFIG_DEBUG_FILE=y
+
+# Send debug messages to syslog instead of stdout
+#CONFIG_DEBUG_SYSLOG=y
+# Set syslog facility for debug messages
+#CONFIG_DEBUG_SYSLOG_FACILITY=LOG_DAEMON
+
+# Add support for sending all debug messages (regardless of debug verbosity)
+# to the Linux kernel tracing facility. This helps debug the entire stack by
+# making it easy to record everything happening from the driver up into the
+# same file, e.g., using trace-cmd.
+#CONFIG_DEBUG_LINUX_TRACING=y
+
+# Enable privilege separation (see README 'Privilege separation' for details)
+#CONFIG_PRIVSEP=y
+
+# Enable mitigation against certain attacks against TKIP by delaying Michael
+# MIC error reports by a random amount of time between 0 and 60 seconds
+#CONFIG_DELAYED_MIC_ERROR_REPORT=y
+
+# Enable tracing code for developer debugging
+# This tracks use of memory allocations and other registrations and reports
+# incorrect use with a backtrace of call (or allocation) location.
+#CONFIG_WPA_TRACE=y
+# For BSD, uncomment these.
+#LIBS += -lexecinfo
+#LIBS_p += -lexecinfo
+#LIBS_c += -lexecinfo
+
+# Use libbfd to get more details for developer debugging
+# This enables use of libbfd to get more detailed symbols for the backtraces
+# generated by CONFIG_WPA_TRACE=y.
+#CONFIG_WPA_TRACE_BFD=y
+# For BSD, uncomment these.
+#LIBS += -lbfd -liberty -lz
+#LIBS_p += -lbfd -liberty -lz
+#LIBS_c += -lbfd -liberty -lz
+
+CONFIG_TLS = %ssl%
+CONFIG_CTRL_IFACE_DBUS=y
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+
+# wpa_supplicant depends on strong random number generation being available
+# from the operating system. os_get_random() function is used to fetch random
+# data when needed, e.g., for key generation. On Linux and BSD systems, this
+# works by reading /dev/urandom. It should be noted that the OS entropy pool
+# needs to be properly initialized before wpa_supplicant is started. This is
+# important especially on embedded devices that do not have a hardware random
+# number generator and may by default start up with minimal entropy available
+# for random number generation.
+#
+# As a safety net, wpa_supplicant is by default trying to internally collect
+# additional entropy for generating random data to mix in with the data fetched
+# from the OS. This by itself is not considered to be very strong, but it may
+# help in cases where the system pool is not initialized properly. However, it
+# is very strongly recommended that the system pool is initialized with enough
+# entropy either by using hardware assisted random number generator or by
+# storing state over device reboots.
+#
+# wpa_supplicant can be configured to maintain its own entropy store over
+# restarts to enhance random number generation. This is not perfect, but it is
+# much more secure than using the same sequence of random numbers after every
+# reboot. This can be enabled with -e<entropy file> command line option. The
+# specified file needs to be readable and writable by wpa_supplicant.
+#
+# If the os_get_random() is known to provide strong random data (e.g., on
+# Linux/BSD, the board in question is known to have reliable source of random
+# data from /dev/urandom), the internal wpa_supplicant random pool can be
+# disabled. This will save some in binary size and CPU use. However, this
+# should only be considered for builds that are known to be used on devices
+# that meet the requirements described above.
+#CONFIG_NO_RANDOM_POOL=y
+
+# IEEE 802.11n (High Throughput) support (mainly for AP mode)
+#CONFIG_IEEE80211N=y
+
+# IEEE 802.11ac (Very High Throughput) support (mainly for AP mode)
+# (depends on CONFIG_IEEE80211N)
+#CONFIG_IEEE80211AC=y
+
+# Wireless Network Management (IEEE Std 802.11v-2011)
+# Note: This is experimental and not complete implementation.
+#CONFIG_WNM=y
+
+# Interworking (IEEE 802.11u)
+# This can be used to enable functionality to improve interworking with
+# external networks (GAS/ANQP to learn more about the networks and network
+# selection based on available credentials).
+#CONFIG_INTERWORKING=y
+
+# Hotspot 2.0
+#CONFIG_HS20=y
+
+# Disable roaming in wpa_supplicant
+#CONFIG_NO_ROAMING=y
+
+# AP mode operations with wpa_supplicant
+# This can be used for controlling AP mode operations with wpa_supplicant. It
+# should be noted that this is mainly aimed at simple cases like
+# WPA2-Personal while more complex configurations like WPA2-Enterprise with an
+# external RADIUS server can be supported with hostapd.
+CONFIG_AP=y
+
+CONFIG_BGSCAN_SIMPLE=y
+
+# P2P (Wi-Fi Direct)
+# This can be used to enable P2P support in wpa_supplicant. See README-P2P for
+# more information on P2P operations.
+#CONFIG_P2P=y
+
+# Enable TDLS support
+#CONFIG_TDLS=y
+
+# Wi-Fi Direct
+# This can be used to enable Wi-Fi Direct extensions for P2P using an external
+# program to control the additional information exchanges in the messages.
+#CONFIG_WIFI_DISPLAY=y
+
+# Autoscan
+# This can be used to enable automatic scan support in wpa_supplicant.
+# See wpa_supplicant.conf for more information on autoscan usage.
+#
+# Enabling directly a module will enable autoscan support.
+# For exponential module:
+CONFIG_AUTOSCAN_EXPONENTIAL=y
+# For periodic module:
+#CONFIG_AUTOSCAN_PERIODIC=y
+
+# Password (and passphrase, etc.) backend for external storage
+# These optional mechanisms can be used to add support for storing passwords
+# and other secrets in external (to wpa_supplicant) location. This allows, for
+# example, operating system specific key storage to be used
+#
+# External password backend for testing purposes (developer use)
+#CONFIG_EXT_PASSWORD_TEST=y
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa-supplicant.sh b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa-supplicant.sh
new file mode 100644
index 0000000..35a1aa6
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa-supplicant.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+
+WPA_SUP_BIN="/usr/sbin/wpa_supplicant"
+WPA_SUP_PNAME="wpa_supplicant"
+WPA_SUP_PIDFILE="/var/run/wpa_supplicant.$IFACE.pid"
+WPA_COMMON_CTRL_IFACE="/var/run/wpa_supplicant"
+WPA_SUP_OPTIONS="-B -P $WPA_SUP_PIDFILE -i $IFACE"
+
+VERBOSITY=0
+
+
+if [ -s "$IF_WPA_CONF" ]; then
+ WPA_SUP_CONF="-c $IF_WPA_CONF"
+else
+ exit 0
+fi
+
+if [ ! -x "$WPA_SUP_BIN" ]; then
+
+ if [ "$VERBOSITY" = "1" ]; then
+ echo "$WPA_SUP_PNAME: binaries not executable or missing from $WPA_SUP_BIN"
+ fi
+
+ exit 1
+fi
+
+if [ "$MODE" = "start" ] ; then
+ # driver type of interface, defaults to wext when undefined
+ if [ -s "/etc/wpa_supplicant/driver.$IFACE" ]; then
+ IF_WPA_DRIVER=$(cat "/etc/wpa_supplicant/driver.$IFACE")
+ elif [ -z "$IF_WPA_DRIVER" ]; then
+
+ if [ "$VERBOSITY" = "1" ]; then
+ echo "$WPA_SUP_PNAME: wpa-driver not provided, using \"wext\""
+ fi
+
+ IF_WPA_DRIVER="wext"
+ fi
+
+ # if we have passed the criteria, start wpa_supplicant
+ if [ -n "$WPA_SUP_CONF" ]; then
+
+ if [ "$VERBOSITY" = "1" ]; then
+ echo "$WPA_SUP_PNAME: $WPA_SUP_BIN $WPA_SUP_OPTIONS $WPA_SUP_CONF -D $IF_WPA_DRIVER"
+ fi
+
+ start-stop-daemon --start --quiet \
+ --name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \
+ -- $WPA_SUP_OPTIONS $WPA_SUP_CONF -D $IF_WPA_DRIVER
+ fi
+
+ # if the interface socket exists, then wpa_supplicant was invoked successfully
+ if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ]; then
+
+ if [ "$VERBOSITY" = "1" ]; then
+ echo "$WPA_SUP_PNAME: ctrl_interface socket located at $WPA_COMMON_CTRL_IFACE/$IFACE"
+ fi
+
+ exit 0
+
+ fi
+
+elif [ "$MODE" = "stop" ]; then
+
+ if [ -f "$WPA_SUP_PIDFILE" ]; then
+
+ if [ "$VERBOSITY" = "1" ]; then
+ echo "$WPA_SUP_PNAME: terminating $WPA_SUP_PNAME daemon"
+ fi
+
+ start-stop-daemon --stop --quiet \
+ --name $WPA_SUP_PNAME --pidfile $WPA_SUP_PIDFILE
+
+ if [ -S "$WPA_COMMON_CTRL_IFACE/$IFACE" ]; then
+ rm -f $WPA_COMMON_CTRL_IFACE/$IFACE
+ fi
+
+ if [ -f "$WPA_SUP_PIDFILE" ]; then
+ rm -f $WPA_SUP_PIDFILE
+ fi
+ fi
+
+fi
+
+exit 0
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf
new file mode 100644
index 0000000..68258f5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf
@@ -0,0 +1,690 @@
+##### Example wpa_supplicant configuration file ###############################
+#
+# This file describes configuration file format and lists all available option.
+# Please also take a look at simpler configuration examples in 'examples'
+# subdirectory.
+#
+# Empty lines and lines starting with # are ignored
+
+# NOTE! This file may contain password information and should probably be made
+# readable only by root user on multiuser systems.
+
+# Note: All file paths in this configuration file should use full (absolute,
+# not relative to working directory) path in order to allow working directory
+# to be changed. This can happen if wpa_supplicant is run in the background.
+
+# Whether to allow wpa_supplicant to update (overwrite) configuration
+#
+# This option can be used to allow wpa_supplicant to overwrite configuration
+# file whenever configuration is changed (e.g., new network block is added with
+# wpa_cli or wpa_gui, or a password is changed). This is required for
+# wpa_cli/wpa_gui to be able to store the configuration changes permanently.
+# Please note that overwriting configuration file will remove the comments from
+# it.
+#update_config=1
+
+# global configuration (shared by all network blocks)
+#
+# Parameters for the control interface. If this is specified, wpa_supplicant
+# will open a control interface that is available for external programs to
+# manage wpa_supplicant. The meaning of this string depends on which control
+# interface mechanism is used. For all cases, the existence of this parameter
+# in configuration is used to determine whether the control interface is
+# enabled.
+#
+# For UNIX domain sockets (default on Linux and BSD): This is a directory that
+# will be created for UNIX domain sockets for listening to requests from
+# external programs (CLI/GUI, etc.) for status information and configuration.
+# The socket file will be named based on the interface name, so multiple
+# wpa_supplicant processes can be run at the same time if more than one
+# interface is used.
+# /var/run/wpa_supplicant is the recommended directory for sockets and by
+# default, wpa_cli will use it when trying to connect with wpa_supplicant.
+#
+# Access control for the control interface can be configured by setting the
+# directory to allow only members of a group to use sockets. This way, it is
+# possible to run wpa_supplicant as root (since it needs to change network
+# configuration and open raw sockets) and still allow GUI/CLI components to be
+# run as non-root users. However, since the control interface can be used to
+# change the network configuration, this access needs to be protected in many
+# cases. By default, wpa_supplicant is configured to use gid 0 (root). If you
+# want to allow non-root users to use the control interface, add a new group
+# and change this value to match with that group. Add users that should have
+# control interface access to this group. If this variable is commented out or
+# not included in the configuration file, group will not be changed from the
+# value it got by default when the directory or socket was created.
+#
+# When configuring both the directory and group, use following format:
+# DIR=/var/run/wpa_supplicant GROUP=wheel
+# DIR=/var/run/wpa_supplicant GROUP=0
+# (group can be either group name or gid)
+#
+# For UDP connections (default on Windows): The value will be ignored. This
+# variable is just used to select that the control interface is to be created.
+# The value can be set to, e.g., udp (ctrl_interface=udp)
+#
+# For Windows Named Pipe: This value can be used to set the security descriptor
+# for controlling access to the control interface. Security descriptor can be
+# set using Security Descriptor String Format (see http://msdn.microsoft.com/
+# library/default.asp?url=/library/en-us/secauthz/security/
+# security_descriptor_string_format.asp). The descriptor string needs to be
+# prefixed with SDDL=. For example, ctrl_interface=SDDL=D: would set an empty
+# DACL (which will reject all connections). See README-Windows.txt for more
+# information about SDDL string format.
+#
+ctrl_interface=/var/run/wpa_supplicant
+
+# IEEE 802.1X/EAPOL version
+# wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which defines
+# EAPOL version 2. However, there are many APs that do not handle the new
+# version number correctly (they seem to drop the frames completely). In order
+# to make wpa_supplicant interoperate with these APs, the version number is set
+# to 1 by default. This configuration value can be used to set it to the new
+# version (2).
+eapol_version=1
+
+# AP scanning/selection
+# By default, wpa_supplicant requests driver to perform AP scanning and then
+# uses the scan results to select a suitable AP. Another alternative is to
+# allow the driver to take care of AP scanning and selection and use
+# wpa_supplicant just to process EAPOL frames based on IEEE 802.11 association
+# information from the driver.
+# 1: wpa_supplicant initiates scanning and AP selection
+# 0: driver takes care of scanning, AP selection, and IEEE 802.11 association
+# parameters (e.g., WPA IE generation); this mode can also be used with
+# non-WPA drivers when using IEEE 802.1X mode; do not try to associate with
+# APs (i.e., external program needs to control association). This mode must
+# also be used when using wired Ethernet drivers.
+# 2: like 0, but associate with APs using security policy and SSID (but not
+# BSSID); this can be used, e.g., with ndiswrapper and NDIS drivers to
+# enable operation with hidden SSIDs and optimized roaming; in this mode,
+# the network blocks in the configuration file are tried one by one until
+# the driver reports successful association; each network block should have
+# explicit security policy (i.e., only one option in the lists) for
+# key_mgmt, pairwise, group, proto variables
+ap_scan=1
+
+# EAP fast re-authentication
+# By default, fast re-authentication is enabled for all EAP methods that
+# support it. This variable can be used to disable fast re-authentication.
+# Normally, there is no need to disable this.
+fast_reauth=1
+
+# OpenSSL Engine support
+# These options can be used to load OpenSSL engines.
+# The two engines that are supported currently are shown below:
+# They are both from the opensc project (http://www.opensc.org/)
+# By default no engines are loaded.
+# make the opensc engine available
+#opensc_engine_path=/usr/lib/opensc/engine_opensc.so
+# make the pkcs11 engine available
+#pkcs11_engine_path=/usr/lib/opensc/engine_pkcs11.so
+# configure the path to the pkcs11 module required by the pkcs11 engine
+#pkcs11_module_path=/usr/lib/pkcs11/opensc-pkcs11.so
+
+# Dynamic EAP methods
+# If EAP methods were built dynamically as shared object files, they need to be
+# loaded here before being used in the network blocks. By default, EAP methods
+# are included statically in the build, so these lines are not needed
+#load_dynamic_eap=/usr/lib/wpa_supplicant/eap_tls.so
+#load_dynamic_eap=/usr/lib/wpa_supplicant/eap_md5.so
+
+# Driver interface parameters
+# This field can be used to configure arbitrary driver interace parameters. The
+# format is specific to the selected driver interface. This field is not used
+# in most cases.
+#driver_param="field=value"
+
+# Maximum lifetime for PMKSA in seconds; default 43200
+#dot11RSNAConfigPMKLifetime=43200
+# Threshold for reauthentication (percentage of PMK lifetime); default 70
+#dot11RSNAConfigPMKReauthThreshold=70
+# Timeout for security association negotiation in seconds; default 60
+#dot11RSNAConfigSATimeout=60
+
+# network block
+#
+# Each network (usually AP's sharing the same SSID) is configured as a separate
+# block in this configuration file. The network blocks are in preference order
+# (the first match is used).
+#
+# network block fields:
+#
+# disabled:
+# 0 = this network can be used (default)
+# 1 = this network block is disabled (can be enabled through ctrl_iface,
+# e.g., with wpa_cli or wpa_gui)
+#
+# id_str: Network identifier string for external scripts. This value is passed
+# to external action script through wpa_cli as WPA_ID_STR environment
+# variable to make it easier to do network specific configuration.
+#
+# ssid: SSID (mandatory); either as an ASCII string with double quotation or
+# as hex string; network name
+#
+# scan_ssid:
+# 0 = do not scan this SSID with specific Probe Request frames (default)
+# 1 = scan with SSID-specific Probe Request frames (this can be used to
+# find APs that do not accept broadcast SSID or use multiple SSIDs;
+# this will add latency to scanning, so enable this only when needed)
+#
+# bssid: BSSID (optional); if set, this network block is used only when
+# associating with the AP using the configured BSSID
+#
+# priority: priority group (integer)
+# By default, all networks will get same priority group (0). If some of the
+# networks are more desirable, this field can be used to change the order in
+# which wpa_supplicant goes through the networks when selecting a BSS. The
+# priority groups will be iterated in decreasing priority (i.e., the larger the
+# priority value, the sooner the network is matched against the scan results).
+# Within each priority group, networks will be selected based on security
+# policy, signal strength, etc.
+# Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are not
+# using this priority to select the order for scanning. Instead, they try the
+# networks in the order that used in the configuration file.
+#
+# mode: IEEE 802.11 operation mode
+# 0 = infrastructure (Managed) mode, i.e., associate with an AP (default)
+# 1 = IBSS (ad-hoc, peer-to-peer)
+# Note: IBSS can only be used with key_mgmt NONE (plaintext and static WEP)
+# and key_mgmt=WPA-NONE (fixed group key TKIP/CCMP). In addition, ap_scan has
+# to be set to 2 for IBSS. WPA-None requires following network block options:
+# proto=WPA, key_mgmt=WPA-NONE, pairwise=NONE, group=TKIP (or CCMP, but not
+# both), and psk must also be set.
+#
+# proto: list of accepted protocols
+# WPA = WPA/IEEE 802.11i/D3.0
+# RSN = WPA2/IEEE 802.11i (also WPA2 can be used as an alias for RSN)
+# If not set, this defaults to: WPA RSN
+#
+# key_mgmt: list of accepted authenticated key management protocols
+# WPA-PSK = WPA pre-shared key (this requires 'psk' field)
+# WPA-EAP = WPA using EAP authentication (this can use an external
+# program, e.g., Xsupplicant, for IEEE 802.1X EAP Authentication
+# IEEE8021X = IEEE 802.1X using EAP authentication and (optionally) dynamically
+# generated WEP keys
+# NONE = WPA is not used; plaintext or static WEP could be used
+# If not set, this defaults to: WPA-PSK WPA-EAP
+#
+# auth_alg: list of allowed IEEE 802.11 authentication algorithms
+# OPEN = Open System authentication (required for WPA/WPA2)
+# SHARED = Shared Key authentication (requires static WEP keys)
+# LEAP = LEAP/Network EAP (only used with LEAP)
+# If not set, automatic selection is used (Open System with LEAP enabled if
+# LEAP is allowed as one of the EAP methods).
+#
+# pairwise: list of accepted pairwise (unicast) ciphers for WPA
+# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
+# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
+# NONE = Use only Group Keys (deprecated, should not be included if APs support
+# pairwise keys)
+# If not set, this defaults to: CCMP TKIP
+#
+# group: list of accepted group (broadcast/multicast) ciphers for WPA
+# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
+# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]
+# WEP104 = WEP (Wired Equivalent Privacy) with 104-bit key
+# WEP40 = WEP (Wired Equivalent Privacy) with 40-bit key [IEEE 802.11]
+# If not set, this defaults to: CCMP TKIP WEP104 WEP40
+#
+# psk: WPA preshared key; 256-bit pre-shared key
+# The key used in WPA-PSK mode can be entered either as 64 hex-digits, i.e.,
+# 32 bytes or as an ASCII passphrase (in which case, the real PSK will be
+# generated using the passphrase and SSID). ASCII passphrase must be between
+# 8 and 63 characters (inclusive).
+# This field is not needed, if WPA-EAP is used.
+# Note: Separate tool, wpa_passphrase, can be used to generate 256-bit keys
+# from ASCII passphrase. This process uses lot of CPU and wpa_supplicant
+# startup and reconfiguration time can be optimized by generating the PSK only
+# only when the passphrase or SSID has actually changed.
+#
+# eapol_flags: IEEE 802.1X/EAPOL options (bit field)
+# Dynamic WEP key required for non-WPA mode
+# bit0 (1): require dynamically generated unicast WEP key
+# bit1 (2): require dynamically generated broadcast WEP key
+# (3 = require both keys; default)
+# Note: When using wired authentication, eapol_flags must be set to 0 for the
+# authentication to be completed successfully.
+#
+# proactive_key_caching:
+# Enable/disable opportunistic PMKSA caching for WPA2.
+# 0 = disabled (default)
+# 1 = enabled
+#
+# wep_key0..3: Static WEP key (ASCII in double quotation, e.g. "abcde" or
+# hex without quotation, e.g., 0102030405)
+# wep_tx_keyidx: Default WEP key index (TX) (0..3)
+#
+# peerkey: Whether PeerKey negotiation for direct links (IEEE 802.11e DLS) is
+# allowed. This is only used with RSN/WPA2.
+# 0 = disabled (default)
+# 1 = enabled
+#peerkey=1
+#
+# Following fields are only used with internal EAP implementation.
+# eap: space-separated list of accepted EAP methods
+# MD5 = EAP-MD5 (unsecure and does not generate keying material ->
+# cannot be used with WPA; to be used as a Phase 2 method
+# with EAP-PEAP or EAP-TTLS)
+# MSCHAPV2 = EAP-MSCHAPv2 (cannot be used separately with WPA; to be used
+# as a Phase 2 method with EAP-PEAP or EAP-TTLS)
+# OTP = EAP-OTP (cannot be used separately with WPA; to be used
+# as a Phase 2 method with EAP-PEAP or EAP-TTLS)
+# GTC = EAP-GTC (cannot be used separately with WPA; to be used
+# as a Phase 2 method with EAP-PEAP or EAP-TTLS)
+# TLS = EAP-TLS (client and server certificate)
+# PEAP = EAP-PEAP (with tunnelled EAP authentication)
+# TTLS = EAP-TTLS (with tunnelled EAP or PAP/CHAP/MSCHAP/MSCHAPV2
+# authentication)
+# If not set, all compiled in methods are allowed.
+#
+# identity: Identity string for EAP
+# anonymous_identity: Anonymous identity string for EAP (to be used as the
+# unencrypted identity with EAP types that support different tunnelled
+# identity, e.g., EAP-TTLS)
+# password: Password string for EAP
+# ca_cert: File path to CA certificate file (PEM/DER). This file can have one
+# or more trusted CA certificates. If ca_cert and ca_path are not
+# included, server certificate will not be verified. This is insecure and
+# a trusted CA certificate should always be configured when using
+# EAP-TLS/TTLS/PEAP. Full path should be used since working directory may
+# change when wpa_supplicant is run in the background.
+# On Windows, trusted CA certificates can be loaded from the system
+# certificate store by setting this to cert_store://<name>, e.g.,
+# ca_cert="cert_store://CA" or ca_cert="cert_store://ROOT".
+# Note that when running wpa_supplicant as an application, the user
+# certificate store (My user account) is used, whereas computer store
+# (Computer account) is used when running wpasvc as a service.
+# ca_path: Directory path for CA certificate files (PEM). This path may
+# contain multiple CA certificates in OpenSSL format. Common use for this
+# is to point to system trusted CA list which is often installed into
+# directory like /etc/ssl/certs. If configured, these certificates are
+# added to the list of trusted CAs. ca_cert may also be included in that
+# case, but it is not required.
+# client_cert: File path to client certificate file (PEM/DER)
+# Full path should be used since working directory may change when
+# wpa_supplicant is run in the background.
+# Alternatively, a named configuration blob can be used by setting this
+# to blob://<blob name>.
+# private_key: File path to client private key file (PEM/DER/PFX)
+# When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be
+# commented out. Both the private key and certificate will be read from
+# the PKCS#12 file in this case. Full path should be used since working
+# directory may change when wpa_supplicant is run in the background.
+# Windows certificate store can be used by leaving client_cert out and
+# configuring private_key in one of the following formats:
+# cert://substring_to_match
+# hash://certificate_thumbprint_in_hex
+# for example: private_key="hash://63093aa9c47f56ae88334c7b65a4"
+# Note that when running wpa_supplicant as an application, the user
+# certificate store (My user account) is used, whereas computer store
+# (Computer account) is used when running wpasvc as a service.
+# Alternatively, a named configuration blob can be used by setting this
+# to blob://<blob name>.
+# private_key_passwd: Password for private key file (if left out, this will be
+# asked through control interface)
+# dh_file: File path to DH/DSA parameters file (in PEM format)
+# This is an optional configuration file for setting parameters for an
+# ephemeral DH key exchange. In most cases, the default RSA
+# authentication does not use this configuration. However, it is possible
+# setup RSA to use ephemeral DH key exchange. In addition, ciphers with
+# DSA keys always use ephemeral DH keys. This can be used to achieve
+# forward secrecy. If the file is in DSA parameters format, it will be
+# automatically converted into DH params.
+# subject_match: Substring to be matched against the subject of the
+# authentication server certificate. If this string is set, the server
+# sertificate is only accepted if it contains this string in the subject.
+# The subject string is in following format:
+# /C=US/ST=CA/L=San Francisco/CN=Test AS/emailAddress=as@example.com
+# altsubject_match: Semicolon separated string of entries to be matched against
+# the alternative subject name of the authentication server certificate.
+# If this string is set, the server sertificate is only accepted if it
+# contains one of the entries in an alternative subject name extension.
+# altSubjectName string is in following format: TYPE:VALUE
+# Example: EMAIL:server@example.com
+# Example: DNS:server.example.com;DNS:server2.example.com
+# Following types are supported: EMAIL, DNS, URI
+# phase1: Phase1 (outer authentication, i.e., TLS tunnel) parameters
+# (string with field-value pairs, e.g., "peapver=0" or
+# "peapver=1 peaplabel=1")
+# 'peapver' can be used to force which PEAP version (0 or 1) is used.
+# 'peaplabel=1' can be used to force new label, "client PEAP encryption",
+# to be used during key derivation when PEAPv1 or newer. Most existing
+# PEAPv1 implementation seem to be using the old label, "client EAP
+# encryption", and wpa_supplicant is now using that as the default value.
+# Some servers, e.g., Radiator, may require peaplabel=1 configuration to
+# interoperate with PEAPv1; see eap_testing.txt for more details.
+# 'peap_outer_success=0' can be used to terminate PEAP authentication on
+# tunneled EAP-Success. This is required with some RADIUS servers that
+# implement draft-josefsson-pppext-eap-tls-eap-05.txt (e.g.,
+# Lucent NavisRadius v4.4.0 with PEAP in "IETF Draft 5" mode)
+# include_tls_length=1 can be used to force wpa_supplicant to include
+# TLS Message Length field in all TLS messages even if they are not
+# fragmented.
+# sim_min_num_chal=3 can be used to configure EAP-SIM to require three
+# challenges (by default, it accepts 2 or 3)
+# phase2: Phase2 (inner authentication with TLS tunnel) parameters
+# (string with field-value pairs, e.g., "auth=MSCHAPV2" for EAP-PEAP or
+# "autheap=MSCHAPV2 autheap=MD5" for EAP-TTLS)
+# Following certificate/private key fields are used in inner Phase2
+# authentication when using EAP-TTLS or EAP-PEAP.
+# ca_cert2: File path to CA certificate file. This file can have one or more
+# trusted CA certificates. If ca_cert2 and ca_path2 are not included,
+# server certificate will not be verified. This is insecure and a trusted
+# CA certificate should always be configured.
+# ca_path2: Directory path for CA certificate files (PEM)
+# client_cert2: File path to client certificate file
+# private_key2: File path to client private key file
+# private_key2_passwd: Password for private key file
+# dh_file2: File path to DH/DSA parameters file (in PEM format)
+# subject_match2: Substring to be matched against the subject of the
+# authentication server certificate.
+# altsubject_match2: Substring to be matched against the alternative subject
+# name of the authentication server certificate.
+#
+# fragment_size: Maximum EAP fragment size in bytes (default 1398).
+# This value limits the fragment size for EAP methods that support
+# fragmentation (e.g., EAP-TLS and EAP-PEAP). This value should be set
+# small enough to make the EAP messages fit in MTU of the network
+# interface used for EAPOL. The default value is suitable for most
+# cases.
+#
+# EAP-PSK variables:
+# eappsk: 16-byte (128-bit, 32 hex digits) pre-shared key in hex format
+# nai: user NAI
+#
+# EAP-PAX variables:
+# eappsk: 16-byte (128-bit, 32 hex digits) pre-shared key in hex format
+#
+# EAP-SAKE variables:
+# eappsk: 32-byte (256-bit, 64 hex digits) pre-shared key in hex format
+# (this is concatenation of Root-Secret-A and Root-Secret-B)
+# nai: user NAI (PEERID)
+#
+# EAP-GPSK variables:
+# eappsk: Pre-shared key in hex format (at least 128 bits, i.e., 32 hex digits)
+# nai: user NAI (ID_Client)
+#
+# EAP-FAST variables:
+# pac_file: File path for the PAC entries. wpa_supplicant will need to be able
+# to create this file and write updates to it when PAC is being
+# provisioned or refreshed. Full path to the file should be used since
+# working directory may change when wpa_supplicant is run in the
+# background. Alternatively, a named configuration blob can be used by
+# setting this to blob://<blob name>
+# phase1: fast_provisioning=1 option enables in-line provisioning of EAP-FAST
+# credentials (PAC)
+#
+# wpa_supplicant supports number of "EAP workarounds" to work around
+# interoperability issues with incorrectly behaving authentication servers.
+# These are enabled by default because some of the issues are present in large
+# number of authentication servers. Strict EAP conformance mode can be
+# configured by disabling workarounds with eap_workaround=0.
+
+# Example blocks:
+
+# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
+network={
+ ssid="simple"
+ psk="very secret passphrase"
+ priority=5
+}
+
+# Same as previous, but request SSID-specific scanning (for APs that reject
+# broadcast SSID)
+network={
+ ssid="second ssid"
+ scan_ssid=1
+ psk="very secret passphrase"
+ priority=2
+}
+
+# Only WPA-PSK is used. Any valid cipher combination is accepted.
+network={
+ ssid="example"
+ proto=WPA
+ key_mgmt=WPA-PSK
+ pairwise=CCMP TKIP
+ group=CCMP TKIP WEP104 WEP40
+ psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
+ priority=2
+}
+
+# Only WPA-EAP is used. Both CCMP and TKIP is accepted. An AP that used WEP104
+# or WEP40 as the group cipher will not be accepted.
+network={
+ ssid="example"
+ proto=RSN
+ key_mgmt=WPA-EAP
+ pairwise=CCMP TKIP
+ group=CCMP TKIP
+ eap=TLS
+ identity="user@example.com"
+ ca_cert="/etc/cert/ca.pem"
+ client_cert="/etc/cert/user.pem"
+ private_key="/etc/cert/user.prv"
+ private_key_passwd="password"
+ priority=1
+}
+
+# EAP-PEAP/MSCHAPv2 configuration for RADIUS servers that use the new peaplabel
+# (e.g., Radiator)
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=PEAP
+ identity="user@example.com"
+ password="foobar"
+ ca_cert="/etc/cert/ca.pem"
+ phase1="peaplabel=1"
+ phase2="auth=MSCHAPV2"
+ priority=10
+}
+
+# EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
+# unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=TTLS
+ identity="user@example.com"
+ anonymous_identity="anonymous@example.com"
+ password="foobar"
+ ca_cert="/etc/cert/ca.pem"
+ priority=2
+}
+
+# EAP-TTLS/MSCHAPv2 configuration with anonymous identity for the unencrypted
+# use. Real identity is sent only within an encrypted TLS tunnel.
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=TTLS
+ identity="user@example.com"
+ anonymous_identity="anonymous@example.com"
+ password="foobar"
+ ca_cert="/etc/cert/ca.pem"
+ phase2="auth=MSCHAPV2"
+}
+
+# WPA-EAP, EAP-TTLS with different CA certificate used for outer and inner
+# authentication.
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=TTLS
+ # Phase1 / outer authentication
+ anonymous_identity="anonymous@example.com"
+ ca_cert="/etc/cert/ca.pem"
+ # Phase 2 / inner authentication
+ phase2="autheap=TLS"
+ ca_cert2="/etc/cert/ca2.pem"
+ client_cert2="/etc/cer/user.pem"
+ private_key2="/etc/cer/user.prv"
+ private_key2_passwd="password"
+ priority=2
+}
+
+# Both WPA-PSK and WPA-EAP is accepted. Only CCMP is accepted as pairwise and
+# group cipher.
+network={
+ ssid="example"
+ bssid=00:11:22:33:44:55
+ proto=WPA RSN
+ key_mgmt=WPA-PSK WPA-EAP
+ pairwise=CCMP
+ group=CCMP
+ psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
+}
+
+# Special characters in SSID, so use hex string. Default to WPA-PSK, WPA-EAP
+# and all valid ciphers.
+network={
+ ssid=00010203
+ psk=000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
+}
+
+
+# IEEE 802.1X/EAPOL with dynamically generated WEP keys (i.e., no WPA) using
+# EAP-TLS for authentication and key generation; require both unicast and
+# broadcast WEP keys.
+network={
+ ssid="1x-test"
+ key_mgmt=IEEE8021X
+ eap=TLS
+ identity="user@example.com"
+ ca_cert="/etc/cert/ca.pem"
+ client_cert="/etc/cert/user.pem"
+ private_key="/etc/cert/user.prv"
+ private_key_passwd="password"
+ eapol_flags=3
+}
+
+
+# LEAP with dynamic WEP keys
+network={
+ ssid="leap-example"
+ key_mgmt=IEEE8021X
+ eap=LEAP
+ identity="user"
+ password="foobar"
+}
+
+# Plaintext connection (no WPA, no IEEE 802.1X)
+network={
+ ssid="plaintext-test"
+ key_mgmt=NONE
+}
+
+
+# Shared WEP key connection (no WPA, no IEEE 802.1X)
+network={
+ ssid="static-wep-test"
+ key_mgmt=NONE
+ wep_key0="abcde"
+ wep_key1=0102030405
+ wep_key2="1234567890123"
+ wep_tx_keyidx=0
+ priority=5
+}
+
+
+# Shared WEP key connection (no WPA, no IEEE 802.1X) using Shared Key
+# IEEE 802.11 authentication
+network={
+ ssid="static-wep-test2"
+ key_mgmt=NONE
+ wep_key0="abcde"
+ wep_key1=0102030405
+ wep_key2="1234567890123"
+ wep_tx_keyidx=0
+ priority=5
+ auth_alg=SHARED
+}
+
+
+# IBSS/ad-hoc network with WPA-None/TKIP.
+network={
+ ssid="test adhoc"
+ mode=1
+ proto=WPA
+ key_mgmt=WPA-NONE
+ pairwise=NONE
+ group=TKIP
+ psk="secret passphrase"
+}
+
+
+# Catch all example that allows more or less all configuration modes
+network={
+ ssid="example"
+ scan_ssid=1
+ key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
+ pairwise=CCMP TKIP
+ group=CCMP TKIP WEP104 WEP40
+ psk="very secret passphrase"
+ eap=TTLS PEAP TLS
+ identity="user@example.com"
+ password="foobar"
+ ca_cert="/etc/cert/ca.pem"
+ client_cert="/etc/cert/user.pem"
+ private_key="/etc/cert/user.prv"
+ private_key_passwd="password"
+ phase1="peaplabel=0"
+}
+
+# Example of EAP-TLS with smartcard (openssl engine)
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=TLS
+ proto=RSN
+ pairwise=CCMP TKIP
+ group=CCMP TKIP
+ identity="user@example.com"
+ ca_cert="/etc/cert/ca.pem"
+ client_cert="/etc/cert/user.pem"
+
+ engine=1
+
+ # The engine configured here must be available. Look at
+ # OpenSSL engine support in the global section.
+ # The key available through the engine must be the private key
+ # matching the client certificate configured above.
+
+ # use the opensc engine
+ #engine_id="opensc"
+ #key_id="45"
+
+ # use the pkcs11 engine
+ engine_id="pkcs11"
+ key_id="id_45"
+
+ # Optional PIN configuration; this can be left out and PIN will be
+ # asked through the control interface
+ pin="1234"
+}
+
+# Example configuration showing how to use an inlined blob as a CA certificate
+# data instead of using external file
+network={
+ ssid="example"
+ key_mgmt=WPA-EAP
+ eap=TTLS
+ identity="user@example.com"
+ anonymous_identity="anonymous@example.com"
+ password="foobar"
+ ca_cert="blob://exampleblob"
+ priority=20
+}
+
+blob-base64-exampleblob={
+SGVsbG8gV29ybGQhCg==
+}
+
+
+# Wildcard match for SSID (plaintext APs only). This example select any
+# open AP regardless of its SSID.
+network={
+ key_mgmt=NONE
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane
new file mode 100644
index 0000000..c91ffe0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant/wpa_supplicant.conf-sane
@@ -0,0 +1,7 @@
+ctrl_interface=/var/run/wpa_supplicant
+ctrl_interface_group=0
+update_config=1
+
+network={
+ key_mgmt=NONE
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend
new file mode 100644
index 0000000..e634ef6
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_%.bbappend
@@ -0,0 +1,13 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+do_install_append(){
+}
+
+DEPENDS+="openssl"
+PACKAGECONFIG = "openssl"
+
+do_configure_append () {
+ echo "wowlan_triggers=disconnect" >> ../wpa_supplicant.conf-sane
+ # Enable OWE for WPA3
+ echo "CONFIG_OWE=y" >> ${WORKDIR}/wpa_supplicant-${PV}/wpa_supplicant/.config
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_2.9.bb b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_2.9.bb
new file mode 100644
index 0000000..3e92427
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-connectivity/wpa-supplicant/wpa-supplicant_2.9.bb
@@ -0,0 +1,110 @@
+SUMMARY = "Client for Wi-Fi Protected Access (WPA)"
+HOMEPAGE = "http://w1.fi/wpa_supplicant/"
+BUGTRACKER = "http://w1.fi/security/"
+SECTION = "network"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://COPYING;md5=279b4f5abb9c153c285221855ddb78cc \
+ file://README;beginline=1;endline=56;md5=e7d3dbb01f75f0b9799e192731d1e1ff \
+ file://wpa_supplicant/wpa_supplicant.c;beginline=1;endline=12;md5=0a8b56d3543498b742b9c0e94cc2d18b"
+DEPENDS = "dbus libnl"
+RRECOMMENDS_${PN} = "wpa-supplicant-passphrase wpa-supplicant-cli"
+
+PACKAGECONFIG ??= "gnutls"
+PACKAGECONFIG[gnutls] = ",,gnutls libgcrypt"
+PACKAGECONFIG[openssl] = ",,openssl"
+
+inherit pkgconfig systemd
+
+SYSTEMD_SERVICE_${PN} = "wpa_supplicant.service wpa_supplicant-nl80211@.service wpa_supplicant-wired@.service"
+SYSTEMD_AUTO_ENABLE = "disable"
+
+SRC_URI = "http://w1.fi/releases/wpa_supplicant-${PV}.tar.gz \
+ file://defconfig \
+ file://wpa-supplicant.sh \
+ file://wpa_supplicant.conf \
+ file://wpa_supplicant.conf-sane \
+ file://99_wpa_supplicant \
+ file://0001-replace-systemd-install-Alias-with-WantedBy.patch \
+ file://0001-AP-Silently-ignore-management-frame-from-unexpected-.patch \
+ "
+SRC_URI[md5sum] = "2d2958c782576dc9901092fbfecb4190"
+SRC_URI[sha256sum] = "fcbdee7b4a64bea8177973299c8c824419c413ec2e3a95db63dd6a5dc3541f17"
+
+CVE_PRODUCT = "wpa_supplicant"
+
+S = "${WORKDIR}/wpa_supplicant-${PV}"
+
+PACKAGES_prepend = "wpa-supplicant-passphrase wpa-supplicant-cli "
+FILES_wpa-supplicant-passphrase = "${bindir}/wpa_passphrase"
+FILES_wpa-supplicant-cli = "${sbindir}/wpa_cli"
+FILES_${PN} += "${datadir}/dbus-1/system-services/*"
+CONFFILES_${PN} += "${sysconfdir}/wpa_supplicant.conf"
+
+do_configure () {
+ ${MAKE} -C wpa_supplicant clean
+ install -m 0755 ${WORKDIR}/defconfig wpa_supplicant/.config
+
+ if echo "${PACKAGECONFIG}" | grep -qw "openssl"; then
+ ssl=openssl
+ elif echo "${PACKAGECONFIG}" | grep -qw "gnutls"; then
+ ssl=gnutls
+ fi
+ if [ -n "$ssl" ]; then
+ sed -i "s/%ssl%/$ssl/" wpa_supplicant/.config
+ fi
+
+ # For rebuild
+ rm -f wpa_supplicant/*.d wpa_supplicant/dbus/*.d
+}
+
+export EXTRA_CFLAGS = "${CFLAGS}"
+export BINDIR = "${sbindir}"
+
+do_compile () {
+ unset CFLAGS CPPFLAGS CXXFLAGS
+ sed -e "s:CFLAGS\ =.*:& \$(EXTRA_CFLAGS):g" -i ${S}/src/lib.rules
+ oe_runmake -C wpa_supplicant
+}
+
+do_install () {
+ install -d ${D}${sbindir}
+ install -m 755 wpa_supplicant/wpa_supplicant ${D}${sbindir}
+ install -m 755 wpa_supplicant/wpa_cli ${D}${sbindir}
+
+ install -d ${D}${bindir}
+ install -m 755 wpa_supplicant/wpa_passphrase ${D}${bindir}
+
+ install -d ${D}${docdir}/wpa_supplicant
+ install -m 644 wpa_supplicant/README ${WORKDIR}/wpa_supplicant.conf ${D}${docdir}/wpa_supplicant
+
+ install -d ${D}${sysconfdir}
+ install -m 600 ${WORKDIR}/wpa_supplicant.conf-sane ${D}${sysconfdir}/wpa_supplicant.conf
+
+ install -d ${D}${sysconfdir}/network/if-pre-up.d/
+ install -d ${D}${sysconfdir}/network/if-post-down.d/
+ install -d ${D}${sysconfdir}/network/if-down.d/
+ install -m 755 ${WORKDIR}/wpa-supplicant.sh ${D}${sysconfdir}/network/if-pre-up.d/wpa-supplicant
+ cd ${D}${sysconfdir}/network/ && \
+ ln -sf ../if-pre-up.d/wpa-supplicant if-post-down.d/wpa-supplicant
+
+ install -d ${D}/${sysconfdir}/dbus-1/system.d
+ install -m 644 ${S}/wpa_supplicant/dbus/dbus-wpa_supplicant.conf ${D}/${sysconfdir}/dbus-1/system.d
+ install -d ${D}/${datadir}/dbus-1/system-services
+ install -m 644 ${S}/wpa_supplicant/dbus/*.service ${D}/${datadir}/dbus-1/system-services
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}/${systemd_unitdir}/system
+ install -m 644 ${S}/wpa_supplicant/systemd/*.service ${D}/${systemd_unitdir}/system
+ fi
+
+ install -d ${D}/etc/default/volatiles
+ install -m 0644 ${WORKDIR}/99_wpa_supplicant ${D}/etc/default/volatiles
+}
+
+pkg_postinst_wpa-supplicant () {
+ # If we're offline, we don't need to do this.
+ if [ "x$D" = "x" ]; then
+ killall -q -HUP dbus-daemon || true
+ fi
+
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/LICENSE b/meta/meta-mediatek-mt2731/recipes-core/initial/files/LICENSE
new file mode 100755
index 0000000..77f59ed
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common
new file mode 100755
index 0000000..2c0f45c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common
@@ -0,0 +1,8 @@
+#!/bin/busybox sh
+
+echo "=== Initial: COMMON Configuration Start ===" > /dev/kmsg
+
+echo off > /sys/power/autosleep
+echo dpidle 1 >/sys/kernel/debug/cpuidle/dpidle_state
+
+echo "=== Initial: COMMON Configuration End ===" > /dev/kmsg
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common.service b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common.service
new file mode 100755
index 0000000..3a5dd7d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_common.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Common Configuration
+Requires=init_network.service
+After=init_network.service
+
+[Service]
+Type=oneshot
+StandardOutput=kmsg+console
+RemainAfterExit=yes
+ExecStartPre=/bin/grep NORMAL /proc/boot_mode
+ExecStart=/bin/sh /usr/share/init/init_common
+
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount
new file mode 100644
index 0000000..228fd49
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount
@@ -0,0 +1,190 @@
+#!/bin/busybox sh
+
+echo "=== Initial: MOUNT Start ===" > /dev/kmsg
+
+BLK_PATH=/dev/disk/by-partlabel
+NVDATA_PATH=/mnt/vendor/nvdata
+PROTECT1_PATH=/mnt/vendor/protect_f
+PROTECT2_PATH=/mnt/vendor/protect_s
+SNCFG_PATH=/mnt/sncfg
+
+mnt_folder(){
+ BLK_NAME=$1
+ MNT_FOLDER=$2
+
+ echo "=== Initial: mount $MNT_FOLDER to $BLK_NAME ===" > /dev/kmsg
+ # first mount
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ mntdone=`mount -t ext4 $BLK_PATH/$BLK_NAME $MNT_FOLDER 2>&1`
+ echo "mount: mount by partlabel"
+ elif [ $BLK_NAME == "userdata" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p18 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p18"
+ elif [ $BLK_NAME == "log" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p20 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p20"
+ elif [ $BLK_NAME == "protect_a" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p6 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p6"
+ elif [ $BLK_NAME == "protect_b" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p7 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p7"
+ elif [ $BLK_NAME == "sncfg" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p8 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p8"
+ fi
+
+ # check need to format or not
+ if [ ! "$mntdone" == "" ]; then
+ echo "=== Initial: new, need format ===" > /dev/kmsg
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ # format
+ mkfs -t ext4 $BLK_PATH/$BLK_NAME
+ # remount
+ mount -t ext4 $BLK_PATH/$BLK_NAME $MNT_FOLDER
+ echo "mount: format mount by partlabel"
+ elif [ $BLK_NAME == "userdata" ]; then
+ mkfs -t ext4 /dev/mmcblk0p18
+ mntdone=`mount -t ext4 /dev/mmcblk0p18 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p18"
+ elif [ $BLK_NAME == "log" ]; then
+ mkfs -t ext4 /dev/mmcblk0p20
+ mntdone=`mount -t ext4 /dev/mmcblk0p20 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p20"
+ elif [ $BLK_NAME == "protect_a" ]; then
+ mkfs -t ext4 /dev/mmcblk0p6
+ mntdone=`mount -t ext4 /dev/mmcblk0p6 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p6"
+ elif [ $BLK_NAME == "protect_b" ]; then
+ mkfs -t ext4 /dev/mmcblk0p7
+ mntdone=`mount -t ext4 /dev/mmcblk0p7 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p7"
+ elif [ $BLK_NAME == "sncfg" ]; then
+ mkfs -t ext4 /dev/mmcblk0p8
+ mntdone=`mount -t ext4 /dev/mmcblk0p8 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p8"
+ fi
+ fi
+}
+mnt_data_folder(){
+ BLK_NAME=$1
+ MNT_FOLDER=$2
+
+ #echo "=== Initial: mount $MNT_FOLDER to $BLK_NAME ===" > /dev/kmsg
+ # first mount
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ mntdone=`mount -t ext4 $BLK_PATH/$BLK_NAME $MNT_FOLDER 2>&1`
+ echo "mount: mnt_data_folder by partlabel"
+ elif [ $BLK_NAME == "nvdata" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p4 $MNT_FOLDER 2>&1`
+ echo "mount: mnt_data_folder by mmcblk0p4"
+ fi
+
+ # check need to format or not
+ if [ ! "$mntdone" == "" ]; then
+ #echo "=== Initial: new, need format ===" > /dev/kmsg
+ # format
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ mkfs -t ext4 $BLK_PATH/$BLK_NAME
+ # remount
+ mount -t ext4 $BLK_PATH/$BLK_NAME $MNT_FOLDER
+ cp -a /usr/share/data/* $MNT_FOLDER
+ elif [ $BLK_NAME == "nvdata" ]; then
+ mkfs -t ext4 /dev/mmcblk0p4
+ mntdone=`mount -t ext4 /dev/mmcblk0p4 $MNT_FOLDER 2>&1`
+ echo "mount: mnt_data_folder by mmcblk0p4"
+ fi
+ fi
+}
+mnt_bind_folder(){
+ DST_FOLDER=$1
+ SRC_FOLDER=$2
+
+ #echo "=== Initial: mount bind $DST_FOLDER to $SRC_FOLDER ===" > /dev/kmsg
+ mntdone=`mount -o bind $DST_FOLDER $SRC_FOLDER 2>&1`
+
+ if [ ! "$mntdone" == "" ]; then
+ #echo "=== Initial: new, need create state folder and copy ===" > /dev/kmsg
+ mkdir -p $DST_FOLDER
+
+ if test "$(ls -A "$SRC_FOLDER")"; then
+ cp -a $SRC_FOLDER/* $DST_FOLDER
+ else
+ echo The directory $SRC_FOLDER is empty '(or non-existent)'
+ fi
+
+ mount -o bind $DST_FOLDER $SRC_FOLDER
+ fi
+}
+mnt_bind_file(){
+ DST_FILE=$1
+ SRC_FILE=$2
+
+ #echo "=== Initial: mount bind $DST_FILE to $SRC_FILE ===" > /dev/kmsg
+ mntdone=`mount -o bind $DST_FILE $SRC_FILE 2>&1`
+
+ if [ ! "$mntdone" == "" ]; then
+ #echo "=== Initial: new, need copy ===" > /dev/kmsg
+ cp -a $SRC_FILE $DST_FILE
+ sync
+ mount -o bind $DST_FOLDER $SRC_FOLDER
+ fi
+}
+# mount nvram and link it
+#mnt_folder nvdata $NVDATA_PATH
+
+# work-around for /data mount to nvdata partition
+#cp -rf /usr/share/data /
+
+mnt_folder log /log
+mnt_bind_folder /log /var/log
+
+#mnt_folder userdata /STATE
+
+#mount -v -t tmpfs -o defaults,size=30M tmpfs /var/volatile
+
+#mnt_bind_folder /STATE/usr/lib/tmpfiles.d /usr/lib/tmpfiles.d
+#mnt_bind_folder /STATE/etc/firmware /etc/firmware
+#mnt_bind_folder /STATE/etc/syslog /etc/syslog
+
+#mnt_bind_folder /STATE/home /home
+#mnt_bind_folder /STATE/mnt /mnt
+#mnt_bind_folder /STATE/srv /srv
+#mnt_bind_folder /STATE/usr/local /usr/local
+#mnt_bind_folder /STATE/system/etc/firmware /system/etc/firmware
+#mnt_bind_folder /STATE/system/etc/audio_param /system/etc/audio_param
+#mnt_bind_folder /STATE/custom/etc/firmware /custom/etc/firmware
+
+#mnt_bind_folder /STATE/var/lib /var/lib
+#mnt_bind_folder /STATE/data /data
+#mkdir -p /data/vendor
+#mnt_bind_folder /STATE/system/etc/tele /system/etc/tele
+
+mnt_data_folder nvdata $NVDATA_PATH
+mkdir -p /data/nvram
+mnt_folder protect_a $PROTECT1_PATH
+mnt_folder protect_b $PROTECT2_PATH
+#mnt_folder sncfg $SNCFG_PATH
+
+mkdir -p /run/media
+# link /var/log --> /run/media/mmcblk1p1 for AP/MD/Networking logging storage
+ln -sf /var/log /run/media/mmcblk1p1
+
+if [ ! -e /mnt/sdcard ] ; then
+ ln -sf /var/log /mnt/sdcard
+fi
+
+#soft link for temp solution
+mkdir -p /dev/disk/by-partlabel
+if [ -d "/dev/disk/by-partlabel" ]; then
+ cd /dev/disk/by-partlabel
+ ln -s ../../mmcblk0p18 userdata
+ ln -s ../../mmcblk0p20 log
+ ln -s ../../mmcblk0p4 nvdata
+ ln -s ../../mmcblk0p6 protect_a
+ ln -s ../../mmcblk0p7 protect_b
+ ln -s ../../mmcblk0p8 sncfg
+ ln -s ../../mmcblk0p9 md1img
+fi
+
+echo "=== Initial: MOUNT Configuration End ===" > /dev/kmsg
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount.service b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount.service
new file mode 100755
index 0000000..dc0e1fe
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Start MOUNT settings
+DefaultDependencies=no
+After=local-fs.target
+Before=sysinit.target systemd-tmpfiles-setup.service busybox-syslog.service
+
+[Service]
+Type=oneshot
+StandardOutput=kmsg+console
+RemainAfterExit=yes
+ExecStart=/bin/sh /usr/share/init/init_mount
+
+
+[Install]
+WantedBy=sysinit.target
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount_nand b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount_nand
new file mode 100644
index 0000000..61334ac
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_mount_nand
@@ -0,0 +1,211 @@
+#!/bin/busybox sh
+
+echo "=== Initial: MOUNT Start ===" > /dev/kmsg
+
+BLK_PATH=/dev/disk/by-partlabel
+NVDATA_PATH=/mnt/vendor/nvdata
+PROTECT1_PATH=/mnt/vendor/protect_f
+PROTECT2_PATH=/mnt/vendor/protect_s
+SNCFG_PATH=/mnt/sncfg
+
+mnt_folder(){
+ BLK_NAME=$1
+ MNT_FOLDER=$2
+ echo "=== Initial: new, need format ===" > /dev/kmsg
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ mntdone=`mount -t ubifs $BLK_PATH/$BLK_NAME $MNT_FOLDER 2>&1`
+ echo "mount: mount by partlabel"
+ elif [ $BLK_NAME == "userdata" ]; then
+ mntdone=`mount -t ubifs /dev/ubi1_0 $MNT_FOLDER 2>&1`
+ echo "mount: format mount 18"
+ elif [ $BLK_NAME == "log" ]; then
+ mntdone=`mount -t ext4 /dev/mmcblk0p1 $MNT_FOLDER 2>&1`
+ echo "mount: mount /dev/mmcblk0p1"
+ elif [ $BLK_NAME == "protect_a" ]; then
+ mntdone=`mount -t ubifs /dev/ubi3_0 $MNT_FOLDER 2>&1`
+ echo "mount: format mount 6"
+ elif [ $BLK_NAME == "protect_b" ]; then
+ mntdone=`mount -t ubifs /dev/ubi4_0 $MNT_FOLDER 2>&1`
+ echo "mount: format mount 7"
+ elif [ $BLK_NAME == "sncfg" ]; then
+ mntdone=`mount -t ubifs /dev/ubi5_0 $MNT_FOLDER 2>&1`
+ echo "mount: format mount 8"
+ fi
+
+ if [ ! "$mntdone" == "" ]; then
+ if [ $BLK_NAME == "userdata" ]; then
+ ubidetach -m 18
+ ubiformat /dev/mtd18
+ ubiattach /dev/ubi_ctrl -m 18 -b 2
+ ubimkvol /dev/ubi1 -m -N userdata
+ mount -t ubifs /dev/ubi1_0 $MNT_FOLDER
+ echo "mount: format mount userdata"
+ elif [ $BLK_NAME == "log" ]; then
+ mkfs -t ext4 /dev/mmcblk0p1
+ mntdone=`mount -t ext4 /dev/mmcblk0p1 $MNT_FOLDER 2>&1`
+ echo "mount: format mount /dev/mmcblk0p1"
+ elif [ $BLK_NAME == "protect_a" ]; then
+ ubidetach -m 6
+ ubiformat /dev/mtd6
+ ubiattach /dev/ubi_ctrl -m 6 -b 1
+ ubimkvol /dev/ubi3 -m -N protect_a
+ mount -t ubifs /dev/ubi3_0 $MNT_FOLDER
+ echo "mount: format mount protect_a"
+ elif [ $BLK_NAME == "protect_b" ]; then
+ ubidetach -m 7
+ ubiformat /dev/mtd7
+ ubiattach /dev/ubi_ctrl -m 7 -b 1
+ ubimkvol /dev/ubi4 -m -N protect_b
+ mount -t ubifs /dev/ubi4_0 $MNT_FOLDER
+ echo "mount: format mount protect_b"
+ elif [ $BLK_NAME == "sncfg" ]; then
+ ubidetach -m 8
+ ubiattach /dev/ubi_ctrl -m 8 -b 1
+ ubimkvol /dev/ubi5 -m -N sncfg
+ mount -t ubifs /dev/ubi5_0 $MNT_FOLDER
+ echo "mount: format mount sncfg"
+ fi
+ fi
+}
+mnt_data_folder(){
+ BLK_NAME=$1
+ MNT_FOLDER=$2
+ #echo "=== Initial: mount $MNT_FOLDER to $BLK_NAME ===" > /dev/kmsg
+ # check need to format or not
+ if [ -f "/dev/disk/by-partlabel/$BLK_NAME" ]; then
+ mntdone=`mount -t ubifs $BLK_PATH/$BLK_NAME $MNT_FOLDER 2>&1`
+ echo "mount: mnt_data_folder by partlabel"
+ elif [ $BLK_NAME == "nvdata" ]; then
+ mntdone=`mount -t ubifs /dev/ubi2_0 $MNT_FOLDER 2>&1`
+ echo "mount: mnt_data_folder nvdata"
+ fi
+
+ if [ ! "$mntdone" == "" ]; then
+ if [ $BLK_NAME == "nvdata" ]; then
+ ubidetach -m 4
+ ubiformat /dev/mtd4
+ ubiattach /dev/ubi_ctrl -m 4 -b 1
+ ubimkvol /dev/ubi2 -m -N nvdata
+ mount -t ubifs /dev/ubi2_0 $MNT_FOLDER
+ echo "mount: format mount nvdata"
+ fi
+ fi
+}
+mnt_bind_folder(){
+ DST_FOLDER=$1
+ SRC_FOLDER=$2
+ #echo "=== Initial: mount bind $DST_FOLDER to $SRC_FOLDER ===" > /dev/kmsg
+ mntdone=`mount -o bind $DST_FOLDER $SRC_FOLDER 2>&1`
+ if [ ! "$mntdone" == "" ]; then
+ #echo "=== Initial: new, need create state folder and copy ===" > /dev/kmsg
+ mkdir -p $DST_FOLDER
+
+ if test "$(ls -A "$SRC_FOLDER")"; then
+ cp -a $SRC_FOLDER/* $DST_FOLDER
+ else
+ echo The directory $SRC_FOLDER is empty '(or non-existent)'
+ fi
+
+ mount -o bind $DST_FOLDER $SRC_FOLDER
+ fi
+}
+mnt_bind_file(){
+ DST_FILE=$1
+ SRC_FILE=$2
+
+ #echo "=== Initial: mount bind $DST_FILE to $SRC_FILE ===" > /dev/kmsg
+ mntdone=`mount -o bind $DST_FILE $SRC_FILE 2>&1`
+ if [ ! "$mntdone" == "" ]; then
+ #echo "=== Initial: new, need copy ===" > /dev/kmsg
+ cp -a $SRC_FILE $DST_FILE
+ sync
+ mount -o bind $DST_FOLDER $SRC_FOLDER
+ fi
+}
+# mount nvram and link it
+#mnt_folder nvdata $NVDATA_PATH
+
+# work-around for /data mount to nvdata partition
+#cp -rf /usr/share/data /
+
+init_log() {
+ mnt_folder log /log
+ mnt_bind_folder /log /var/log
+}
+init_log &
+
+#mnt_folder userdata /STATE
+
+#mount -v -t tmpfs -o defaults,size=30M tmpfs /var/volatile
+
+#mnt_bind_folder /STATE/usr/lib/tmpfiles.d /usr/lib/tmpfiles.d
+#mnt_bind_folder /STATE/etc/firmware /etc/firmware
+#mnt_bind_folder /STATE/etc/syslog /etc/syslog
+
+#mnt_bind_folder /STATE/home /home
+#mnt_bind_folder /STATE/mnt /mnt
+#mnt_bind_folder /STATE/srv /srv
+#mnt_bind_folder /STATE/usr/local /usr/local
+#mnt_bind_folder /STATE/system/etc/firmware /system/etc/firmware
+#mnt_bind_folder /STATE/system/etc/audio_param /system/etc/audio_param
+#mnt_bind_folder /STATE/custom/etc/firmware /custom/etc/firmware
+
+#mnt_bind_folder /STATE/var/lib /var/lib
+#mnt_bind_folder /STATE/data /data
+
+init_nvram() {
+ mkdir -p /data/vendor
+ #mnt_bind_folder /STATE/system/etc/tele /system/etc/tele
+
+ mnt_data_folder nvdata $NVDATA_PATH
+ mkdir -p /data/nvram
+
+ mnt_folder protect_a $PROTECT1_PATH
+ mnt_folder protect_b $PROTECT2_PATH
+ #mnt_folder sncfg $SNCFG_PATH
+}
+init_nvram &
+
+init_log2() {
+ # link /var/log --> /run/media/mmcblk1p1 for legacy AP/MD/Network logging storage
+ mkdir -p /run/media
+ if [ ! -e /run/media/mmcblk1p1 ] ; then
+ ln -sf /var/log /run/media/mmcblk1p1
+ fi
+ # Link /var/log --> /mnt/sdcard for MD logging storage
+ if [ ! -e /mnt/sdcard ] ; then
+ #rm -rf /mnt/sdcard
+ ln -sf /var/log /mnt/sdcard
+ fi
+}
+init_log2 &
+
+init_partlabel() {
+ mkdir -p /dev/disk/by-partlabel
+ if [ -d "/dev/disk/by-partlabel" ]; then
+ cd /dev/disk/by-partlabel
+ ln -s ../../mtd5 hsm_os
+ ln -s ../../mtd6 protect_a
+ ln -s ../../mtd7 protect_b
+ ln -s ../../mtd9 md1img_a
+ ln -s ../../mtd10 md1img_b
+ ln -s ../../mtd11 boot_a
+ ln -s ../../mtd12 boot_b
+ ln -s ../../mtd13 system_a
+ ln -s ../../mtd14 system_b
+ ln -s ../../mtd15 misc
+ ln -s ../../mtd16 tee_a
+ ln -s ../../mtd17 tee_b
+ ln -s ../../mtd19 vbmeta_a
+ ln -s ../../mtd20 vbmeta_b
+ ln -s ../../mtd21 delta
+ ln -s ../../mtd22 expdb
+ fi
+
+ mount -t tmpfs /dev/disk/by-partlabel/misc /misc
+}
+init_partlabel &
+
+wait
+
+echo "=== Initial: MOUNT Configuration End ===" > /dev/kmsg
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network
new file mode 100755
index 0000000..4b88390
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network
@@ -0,0 +1,85 @@
+#!/bin/busybox sh
+
+echo "=== Initial: NETWORK Configuration Start ===" > /dev/kmsg
+
+#
+# IPv6 initial default forwarding state, it must be before any NIC modules instered.
+# NM (Network Manager) has to take over once IPv6 enabling is
+# configurable for system or for each NIC in the future.
+#
+echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
+echo 0 > /proc/sys/net/ipv6/conf/default/forwarding
+
+# WMID and SBP setting
+#eval `sncfg mget WM_ID SBP_ID`
+#echo -ne \\x$(printf '%x' $WM_ID) > /data/wmid
+#echo -ne \\x$(printf '%x' $SBP_ID) > /data/sbp
+
+
+# Change local routing table priority for IPPT
+ip rule del priority 0 lookup local
+ip rule add priority 3 lookup local
+ip -6 rule del priority 0 lookup local
+ip -6 rule add priority 3 lookup local
+
+
+if [ -n "$(cat /proc/boot_mode | grep NORMAL)" ] ; then # META mode: META_BOOT_SKIP_PRELOADER
+
+ LanIf=br0
+ /sbin/sncfg set LanIf "$LanIf" > /dev/null 2>&1
+
+ ifconfig lo 127.0.0.1 up
+
+ eval `sncfg mget DEV_MAC USBHOST_MAC LAN_IP LAN_MASK LAN_IP6 LAN_PREFIX6`
+
+ # Init network sncfg key
+ WanStatus=down
+ WanIf=lte0
+ /sbin/sncfg set WanStatus "$WanStatus" > /dev/null 2>&1
+ /sbin/sncfg set WanIf "$WanIf" > /dev/null 2>&1
+ /etc/init.d/sysinit6 start
+
+ eval `sncfg mget MODEM_CONTROL_INF`
+ if [ "$MODEM_CONTROL_INF" == "RIL" ] ; then
+ echo "MODEM_CONTROL_INF=RIL"
+ elif [ "$MODEM_CONTROL_INF" == "ATCMD" ] ; then
+ echo "MODEM_CONTROL_INF=ATCMD"
+ /etc/init.d/bach_nnmd start
+ else
+ echo "MODEM_CONTROL_INF=$MODEM_CONTROL_INF"
+ fi
+
+ if [ -n "$DEV_MAC" ] && [ "$DEV_MAC" != "00:00:00:00:00:00" ] ; then
+ LanMac=$DEV_MAC
+ else
+ LanMac="00:0C:E7:0B:01:02"
+ fi
+ if [ -n "$USBHOST_MAC" ] && [ "$USBHOST_MAC" != "00:00:00:00:00:00" ] ; then
+ UsbHostMac=$USBHOST_MAC
+ else
+ UsbHostMac=$(echo "$LanMac" | sed -n 's/00:/02:/p')
+ fi
+
+
+ echo "$LanMac" /sys/module/g_android/parameters/dev_addr
+ echo "$UsbHostMac" /sys/module/g_android/parameters/host_addr
+
+ /sbin/sncfg set LanIp "$LAN_IP" > /dev/null 2>&1
+ /sbin/sncfg set LanMac "$LanMac" > /dev/null 2>&1
+ /sbin/sncfg set UsbHostMac "$UsbHostMac" > /dev/null 2>&1
+
+ #brctl addbr $LanIf
+ #brctl setfd $LanIf 0
+ #ifconfig $LanIf hw ether $LanMac
+ #ifconfig dummy0 hw ether $LanMac
+ #brctl addif $LanIf dummy0
+
+ #ip -6 addr add $LAN_IP6 dev $LanIf
+ #ip -6 addr add fe80::11:22:33:44/64 dev $LanIf
+ #ip -6 route add $LAN_PREFIX6 dev $LanIf
+ #LLAddr=$(ifconfig $LanIf | grep fe80 | awk -F "::" '{ print $2 }' | awk -F "/" '{ print $1 }')
+ /sbin/sncfg set LanLinkAddr "$LLAddr" > /dev/null 2>&1
+ #ifconfig $LanIf $LAN_IP netmask $LAN_MASK
+fi
+
+echo "=== Initial: NETWORK Configuration End ===" > /dev/kmsg
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network.service b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network.service
new file mode 100755
index 0000000..fd5175a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/init_network.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Network Configuration
+Requires=bach_sncfg.service
+After=bach_sncfg.service
+
+[Service]
+Type=oneshot
+StandardOutput=kmsg+console
+RemainAfterExit=yes
+ExecStart=/bin/sh /usr/share/init/init_network
+
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/files/usb_switch b/meta/meta-mediatek-mt2731/recipes-core/initial/files/usb_switch
new file mode 100755
index 0000000..2678765
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/files/usb_switch
@@ -0,0 +1,16 @@
+#!/bin/busybox sh
+#
+# @author Chuanrui Liu
+#
+
+echo "=== Initial: USB Switch Start ===" > /dev/kmsg
+
+if [ ! -z $2 ]; then
+ #echo 0123456789ABCDEF > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
+ echo $2 > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
+fi
+
+setprop sys.usb.config none
+setprop sys.usb.config $1
+
+echo "=== Initial: USB Switch End ===" > /dev/kmsg
diff --git a/meta/meta-mediatek-mt2731/recipes-core/initial/init-2731_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-core/initial/init-2731_1.0.0.bb
new file mode 100644
index 0000000..8021986
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/initial/init-2731_1.0.0.bb
@@ -0,0 +1,57 @@
+#Basic Configuration
+DESCRIPTION = "Initial settting"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+SRC_URI = "file://LICENSE"
+SRC_URI += "file://init_network"
+SRC_URI += "file://init_common"
+SRC_URI += "file://init_mount"
+SRC_URI += "file://init_mount_nand"
+SRC_URI += "file://usb_switch"
+SRC_URI += "file://init_network.service"
+SRC_URI += "file://init_common.service"
+SRC_URI += "file://init_mount.service"
+
+
+
+S = "${WORKDIR}"
+
+#Skip strip check in QA test
+INSANE_SKIP_${PN} += "already-stripped"
+
+FILES_${PN} = "${datadir}/init/init_network \
+ ${datadir}/init/init_common \
+ ${datadir}/init/init_mount \
+ ${datadir}/init/usb_switch "
+
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "init_network.service init_common.service init_mount.service"
+FILES_${PN} += "${systemd_unitdir}/system/init_network.service \
+ ${systemd_unitdir}/system/init_common.service \
+ ${systemd_unitdir}/system/init_mount.service "
+
+
+do_install_append() {
+ install -d ${D}${datadir}/init
+ install -m 0755 init_network ${D}${datadir}/init/init_network
+ install -m 0755 init_common ${D}${datadir}/init/init_common
+ install -m 0755 usb_switch ${D}${datadir}/init/usb_switch
+
+ if ${@bb.utils.contains('BOOTDEV_TYPE','nand','true','false',d)}; then
+ install -m 0755 init_mount_nand ${D}${datadir}/init/init_mount
+ else
+ install -m 0755 init_mount ${D}${datadir}/init/init_mount
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 init_network.service ${D}${systemd_unitdir}/system
+ install -m 0644 init_common.service ${D}${systemd_unitdir}/system
+ install -m 0644 init_mount.service ${D}${systemd_unitdir}/system
+ fi
+
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2.inc b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2.inc
new file mode 100644
index 0000000..bce55ac
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2.inc
@@ -0,0 +1,68 @@
+SUMMARY = "TCP / IP networking and traffic control utilities"
+DESCRIPTION = "Iproute2 is a collection of utilities for controlling \
+TCP / IP networking and traffic control in Linux. Of the utilities ip \
+and tc are the most important. ip controls IPv4 and IPv6 \
+configuration and tc stands for traffic control."
+HOMEPAGE = "http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2"
+SECTION = "base"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a \
+ file://ip/ip.c;beginline=3;endline=8;md5=689d691d0410a4b64d3899f8d6e31817"
+
+DEPENDS = "flex-native bison-native iptables elfutils libcap"
+
+inherit update-alternatives bash-completion pkgconfig
+
+CLEANBROKEN = "1"
+
+PACKAGECONFIG ??= "tipc"
+PACKAGECONFIG[tipc] = ",,libmnl,"
+
+EXTRA_OEMAKE = "CC='${CC}' KERNEL_INCLUDE=${STAGING_INCDIR} DOCDIR=${docdir}/iproute2 SUBDIRS='lib tc ip bridge misc genl \
+ ${@bb.utils.contains('PACKAGECONFIG', 'tipc', 'tipc', '', d)}' SBINDIR='${base_sbindir}' LIBDIR='${libdir}'"
+
+do_configure_append () {
+ sh configure ${STAGING_INCDIR}
+ # Explicitly disable ATM support
+ sed -i -e '/TC_CONFIG_ATM/d' config.mk
+}
+
+do_install () {
+ oe_runmake DESTDIR=${D} install
+ mv ${D}${base_sbindir}/ip ${D}${base_sbindir}/ip.iproute2
+ install -d ${D}${datadir}
+ mv ${D}/share/* ${D}${datadir}/ || true
+ rm ${D}/share -rf || true
+}
+
+# The .so files in iproute2-tc are modules, not traditional libraries
+INSANE_SKIP_${PN}-tc = "dev-so"
+
+PACKAGES =+ "${PN}-tc \
+ ${PN}-lnstat \
+ ${PN}-ifstat \
+ ${PN}-genl \
+ ${PN}-rtacct \
+ ${PN}-nstat \
+ ${PN}-ss \
+ ${@bb.utils.contains('PACKAGECONFIG', 'tipc', '${PN}-tipc', '', d)}"
+FILES_${PN}-tc = "${base_sbindir}/tc* \
+ ${libdir}/tc/*.so"
+FILES_${PN}-lnstat = "${base_sbindir}/lnstat \
+ ${base_sbindir}/ctstat \
+ ${base_sbindir}/rtstat"
+FILES_${PN}-ifstat = "${base_sbindir}/ifstat"
+FILES_${PN}-genl = "${base_sbindir}/genl"
+FILES_${PN}-rtacct = "${base_sbindir}/rtacct"
+FILES_${PN}-nstat = "${base_sbindir}/nstat"
+FILES_${PN}-ss = "${base_sbindir}/ss"
+FILES_${PN}-tipc = "${base_sbindir}/tipc"
+
+ALTERNATIVE_${PN} = "ip"
+ALTERNATIVE_TARGET[ip] = "${base_sbindir}/ip.${BPN}"
+ALTERNATIVE_LINK_NAME[ip] = "${base_sbindir}/ip"
+ALTERNATIVE_PRIORITY = "100"
+
+ALTERNATIVE_${PN}-tc = "tc"
+ALTERNATIVE_LINK_NAME[tc] = "${base_sbindir}/tc"
+ALTERNATIVE_PRIORITY_${PN}-tc = "100"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-ip-Remove-unneed-header.patch b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-ip-Remove-unneed-header.patch
new file mode 100644
index 0000000..814f10c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-ip-Remove-unneed-header.patch
@@ -0,0 +1,29 @@
+From 02ed10fc5215c4a32e6740b0a0c2439659be6801 Mon Sep 17 00:00:00 2001
+From: Changhyeok Bae <changhyeok.bae@gmail.com>
+Date: Mon, 13 Nov 2017 15:59:35 +0000
+Subject: [PATCH] ip: Remove unneed header
+
+Fix redefinition of struct ethhdr with a suitably patched musl libc
+that suppresses the kernel if_ether.h.
+
+Signed-off-by: Changhyeok Bae <changhyeok.bae@gmail.com>
+
+Upstream-Status: Pending [netdev@vger.kernel.org]
+---
+ ip/iplink_bridge.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
+index cccdec1..f065b22 100644
+--- a/ip/iplink_bridge.c
++++ b/ip/iplink_bridge.c
+@@ -13,7 +13,6 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <netinet/in.h>
+-#include <netinet/ether.h>
+ #include <linux/if_link.h>
+ #include <linux/if_bridge.h>
+ #include <net/if.h>
+--
+2.7.4
diff --git a/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-libc-compat.h-add-musl-workaround.patch b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-libc-compat.h-add-musl-workaround.patch
new file mode 100644
index 0000000..03e5de5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/0001-libc-compat.h-add-musl-workaround.patch
@@ -0,0 +1,40 @@
+From b7d96340c55afb7023ded0041107c63dbd886196 Mon Sep 17 00:00:00 2001
+From: Baruch Siach <baruch@tkos.co.il>
+Date: Thu, 22 Dec 2016 15:26:30 +0200
+Subject: [PATCH] libc-compat.h: add musl workaround
+
+The libc-compat.h kernel header uses glibc specific macros (__GLIBC__ and
+__USE_MISC) to solve conflicts with libc provided headers. This patch makes
+libc-compat.h work for musl libc as well.
+
+Upstream-Status: Pending
+
+Taken From:
+https://git.buildroot.net/buildroot/tree/package/iproute2/0001-Add-the-musl-workaround-to-the-libc-compat.h-copy.patch
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+Signed-off-by: Maxin B. John <maxin.john@intel.com>
+---
+ include/uapi/linux/libc-compat.h | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
+index f38571d..30f0b67 100644
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -49,10 +49,12 @@
+ #define _LIBC_COMPAT_H
+
+ /* We have included glibc headers... */
+-#if defined(__GLIBC__)
++#if 1
++#define __USE_MISC
+
+ /* Coordinate with glibc net/if.h header. */
+ #if defined(_NET_IF_H) && defined(__USE_MISC)
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
+
+ /* GLIBC headers included first so don't define anything
+ * that would already be defined. */
+--
+2.4.0
diff --git a/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/configure-cross.patch b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/configure-cross.patch
new file mode 100644
index 0000000..a96d94a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2/configure-cross.patch
@@ -0,0 +1,38 @@
+From 3835b1cc4a55361443c2b37dea688da652217635 Mon Sep 17 00:00:00 2001
+From: Koen Kooi <koen@dominion.thruhere.net>
+Date: Sun, 31 Mar 2019 17:32:07 +0200
+Subject: [PATCH] make configure cross compile safe
+
+According to Kevin Tian:
+Upstream-Status: Pending
+
+Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
+Signed-off-by: Shane Wang <shane.wang@intel.com>
+
+---
+ configure | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 45fcffb6..0c5c9146 100755
+--- a/configure
++++ b/configure
+@@ -3,6 +3,7 @@
+ # This is not an autoconf generated configure
+ #
+ INCLUDE=${1:-"$PWD/include"}
++SYSROOT=$1
+
+ # Output file which is input to Makefile
+ CONFIG=config.mk
+@@ -162,7 +163,7 @@ check_ipt_lib_dir()
+ return
+ fi
+
+- for dir in /lib /usr/lib /usr/local/lib; do
++ for dir in $SYSROOT/lib $SYSROOT/usr/lib $SYSROOT/usr/local/lib; do
+ for file in "xtables" "iptables"; do
+ file="$dir/$file/lib*t_*so"
+ if [ -f $file ]; then
+--
+2.17.1
diff --git a/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2_5.0.0.bb b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2_5.0.0.bb
new file mode 100644
index 0000000..f57255f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/iproute2/iproute2_5.0.0.bb
@@ -0,0 +1,14 @@
+require iproute2.inc
+
+SRC_URI = "${KERNELORG_MIRROR}/linux/utils/net/${BPN}/${BP}.tar.xz \
+ file://configure-cross.patch \
+ file://0001-libc-compat.h-add-musl-workaround.patch \
+ file://0001-ip-Remove-unneed-header.patch \
+ "
+
+SRC_URI[md5sum] = "d22107b4d7cfb999eeb8ad8a0aec1124"
+SRC_URI[sha256sum] = "df047302a39650ef832c07e8dab5df7a23218cd398bd310c8628e386161d20ba"
+
+# CFLAGS are computed in Makefile and reference CCOPTS
+#
+EXTRA_OEMAKE_append = " CCOPTS='${CFLAGS}'"
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-core/meta/target-sdk-provides-dummy.bbappend b/meta/meta-mediatek-mt2731/recipes-core/meta/target-sdk-provides-dummy.bbappend
new file mode 100644
index 0000000..6234a89
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/meta/target-sdk-provides-dummy.bbappend
@@ -0,0 +1,3 @@
+DUMMYPROVIDES += "\
+ /bin/busybox \
+"
diff --git a/meta/meta-mediatek-mt2731/recipes-core/systemd/systemd_%.bbappend b/meta/meta-mediatek-mt2731/recipes-core/systemd/systemd_%.bbappend
new file mode 100644
index 0000000..4526ffb
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-core/systemd/systemd_%.bbappend
@@ -0,0 +1,8 @@
+# remove unused systemd packages
+
+PACKAGECONFIG[networkd] = "-Dnetworkd=false"
+PACKAGECONFIG[backlight] = "-Dbacklight=false"
+PACKAGECONFIG[machined] = "-Dmachined=false"
+PACKAGECONFIG[quotacheck] = "-Dquotacheck=false"
+PACKAGECONFIG[polkit] = "-Dpolkit=false"
+PACKAGECONFIG[vconsole] = "-Dvconsole=false"
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup
new file mode 100755
index 0000000..a719804
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup
@@ -0,0 +1,92 @@
+#!/bin/busybox sh
+
+if [ "$1" == "pre" ]; then
+ echo "=== Initial: USB Configuration Start ===" > /dev/kmsg
+
+ if [ -e "/dev/usb-ffs" ] ; then
+ echo "=== Bypass Pre Configuration ===" > /dev/kmsg
+ else # first boot
+ mkdir -p /dev/usb-ffs
+ mkdir -p /dev/usb-ffs/adb
+ mount none /sys/kernel/config -t configfs
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/ffs.adb
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/rndis.gs4
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/ncm.f0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/ecm.f0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/eem.f0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/mass_storage.usb0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/acm.gs0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/acm.gs1
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/acm.gs2
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/acm.gs3
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/via_modem.gs0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/via_ets.gs0
+ mkdir -p /sys/kernel/config/usb_gadget/g1/functions/via_atc.gs0
+ mount adb /dev/usb-ffs/adb -t functionfs -o uid=2000,gid=2000
+ fi
+
+elif [ "$1" == "post" ];then
+
+ echo 0x0e8d > /sys/kernel/config/usb_gadget/g1/idVendor
+ echo 0x0223 > /sys/kernel/config/usb_gadget/g1/bcdDevice
+ echo 0x0200 > /sys/kernel/config/usb_gadget/g1/bcdUSB
+ mkdir -p /sys/kernel/config/usb_gadget/g1/strings/0x409
+
+ if [ "$(cat /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber)" == "" ]; then
+ if [[ "$(cat /etc/hostname)" == "auto2731evb-ivt-vp1" || "$(cat /etc/hostname)" == "auto2731evb-ivt-vp2" ]]; then
+ echo "MT-96533493F01B518C" > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
+ else
+ echo 0123456789ABCDEF > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
+ fi
+ else
+ echo "=== usb serial number exist, keep it ===" > /dev/kmsg
+ fi
+
+ echo MediaTek > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
+ echo auto2731-ivt > /sys/kernel/config/usb_gadget/g1/strings/0x409/product
+
+ mkdir -p /sys/kernel/config/usb_gadget/g1/configs/b.1
+ mkdir -p /sys/kernel/config/usb_gadget/g1/configs/b.1/strings/0x409
+ echo 500 > /sys/kernel/config/usb_gadget/g1/configs/b.1/MaxPower
+
+ if [ -n "$(cat /proc/boot_mode | grep META)" ] ; then # META mode: META_BOOT_SKIP_PRELOADER
+
+ # ADB + CDC-ACM*2 (META mode)
+ #setprop sys.usb.config adb,meta,elt
+ #################### START ####################
+ sleep 1
+ echo meta_elt_adb > /sys/kernel/config/usb_gadget/g1/configs/b.1/strings/0x409/configuration
+ echo 0x2040 > /sys/kernel/config/usb_gadget/g1/idProduct
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/mass_storage.usb0 /sys/kernel/config/usb_gadget/g1/configs/b.1/f1
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/ffs.adb /sys/kernel/config/usb_gadget/g1/configs/b.1/f2
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/acm.gs0 /sys/kernel/config/usb_gadget/g1/configs/b.1/f3
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/acm.gs3 /sys/kernel/config/usb_gadget/g1/configs/b.1/f4
+ echo musb-hdrc > /sys/kernel/config/usb_gadget/g1/UDC
+ #################### END ####################
+ sleep 1
+ echo musb-hdrc > /sys/kernel/config/usb_gadget/g1/UDC
+
+ else # Normal mode
+
+ # ADB + CDC-ACM*3 (normal mode)
+ #setprop sys.usb.config adb,acm
+ #################### START ####################
+ sleep 1
+ echo gs1gs3_dual_acm > /sys/kernel/config/usb_gadget/g1/configs/b.1/strings/0x409/configuration
+ echo 0x202f > /sys/kernel/config/usb_gadget/g1/idProduct
+ echo 1 > /sys/devices/platform/soc/mt_usb/saving
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/ffs.adb /sys/kernel/config/usb_gadget/g1/configs/b.1/f1
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/acm.gs0 /sys/kernel/config/usb_gadget/g1/configs/b.1/f2
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/acm.gs1 /sys/kernel/config/usb_gadget/g1/configs/b.1/f3
+ ln -sf /sys/kernel/config/usb_gadget/g1/functions/acm.gs3 /sys/kernel/config/usb_gadget/g1/configs/b.1/f4
+ #################### END ####################
+ sleep 1
+ echo musb-hdrc > /sys/kernel/config/usb_gadget/g1/UDC
+ fi
+
+ if [ -e "/proc/bootprof" ] ; then
+ echo usb_active > /proc/bootprof
+ fi
+
+ echo "=== Initial: USB Configuration End ===" > /dev/kmsg
+fi
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf_1.0.bbappend b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf_1.0.bbappend
new file mode 100644
index 0000000..e848f22
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools-conf_1.0.bbappend
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
+
+do_install_append() {
+ install -d ${D}${bindir}
+ ln -sf /usr/share/init/usb_switch ${D}${bindir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0003-adb-force-root.patch b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0003-adb-force-root.patch
new file mode 100644
index 0000000..038de0a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0003-adb-force-root.patch
@@ -0,0 +1,21 @@
+diff --git a/system/core/adb/adb.c b/system/core/adb/adb.c
+index 10a1e0d..c805df3 100644
+--- a/system/core/adb/adb.c
++++ b/system/core/adb/adb.c
+@@ -1261,6 +1261,8 @@ static void drop_capabilities_bounding_set_if_needed() {
+ }
+
+ static int should_drop_privileges() {
++ return 0;
++#if 0
+ #ifndef ALLOW_ADBD_ROOT
+ return 1;
+ #else /* ALLOW_ADBD_ROOT */
+@@ -1290,6 +1292,7 @@ static int should_drop_privileges() {
+ }
+ return secure;
+ #endif /* ALLOW_ADBD_ROOT */
++#endif /* if 0 */
+ }
+ #endif /* !ADB_HOST */
+
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0004-adb-enable-reboot.patch b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0004-adb-enable-reboot.patch
new file mode 100644
index 0000000..9490d63
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/0004-adb-enable-reboot.patch
@@ -0,0 +1,38 @@
+diff --git a/system/core/adb/services.c b/system/core/adb/services.c
+index 21b08dc..7dde38c 100644
+--- a/system/core/adb/services.c
++++ b/system/core/adb/services.c
+@@ -114,6 +114,8 @@ void restart_usb_service(int fd, void *cookie)
+
+ void reboot_service(int fd, void *arg)
+ {
++#if 0 /* android sequence */
++
+ char buf[100];
+ char property_val[PROPERTY_VALUE_MAX];
+ int ret;
+@@ -136,6 +138,24 @@ void reboot_service(int fd, void *arg)
+ // Don't return early. Give the reboot command time to take effect
+ // to avoid messing up scripts which do "adb reboot && adb wait-for-device"
+ while(1) { pause(); }
++#else /* yocto sequence */
++
++ char buf[100];
++ int ret;
++
++ sync();
++
++ ret = execl("/sbin/reboot", "reboot", "-f", (char*)arg, NULL);
++ if (ret < 0) {
++ snprintf(buf, sizeof(buf), "reboot failed: %d\n", ret);
++ writex(fd, buf, strlen(buf));
++ goto cleanup;
++ }
++ // Don't return early. Give the reboot command time to take effect
++ // to avoid messing up scripts which do "adb reboot && adb wait-for-device"
++ while(1) { pause(); }
++#endif
++
+ cleanup:
+ free(arg);
+ adb_close(fd);
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/android-tools-adbd.service b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/android-tools-adbd.service
new file mode 100644
index 0000000..51e1413
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/android-tools-adbd.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Android Debug Bridge
+
+[Service]
+Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/data/usr/sbin:/data/usr/bin ; \
+ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
+Type=simple
+Restart=on-failure
+ExecStartPre=/usr/bin/android-gadget-setup pre
+ExecStart=/usr/bin/adbd
+ExecStartPost=/usr/bin/android-gadget-setup post
+StandardOutput=null
+
+[Install]
+WantedBy=basic.target
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/fix_monotonic_time.patch b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/fix_monotonic_time.patch
new file mode 100644
index 0000000..807e673
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools/fix_monotonic_time.patch
@@ -0,0 +1,32 @@
+diff --git a/system/core/libutils/Timers.cpp b/system/core/libutils/Timers.cpp
+index 4687d4d597..6edac2a72d 100644
+--- a/system/core/libutils/Timers.cpp
++++ b/system/core/libutils/Timers.cpp
+@@ -48,15 +48,22 @@ nsecs_t systemTime(int clock)
+ return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec;
+ }
+ #else
+-nsecs_t systemTime(int /*clock*/)
++nsecs_t systemTime(int clock)
+ {
+ // Clock support varies widely across hosts. Mac OS doesn't support
+ // posix clocks, older glibcs don't support CLOCK_BOOTTIME and Windows
+ // is windows.
+- struct timeval t;
+- t.tv_sec = t.tv_usec = 0;
+- gettimeofday(&t, NULL);
+- return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL;
++ if (clock == SYSTEM_TIME_MONOTONIC) {
++ struct timespec t;
++ t.tv_sec = t.tv_nsec = 0;
++ clock_gettime(CLOCK_MONOTONIC, &t);
++ return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec;
++ } else { // use real time
++ struct timeval t;
++ t.tv_sec = t.tv_usec = 0;
++ gettimeofday(&t, NULL);
++ return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL;
++ }
+ }
+ #endif
+
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools_5.1.1.r37.bbappend b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools_5.1.1.r37.bbappend
new file mode 100644
index 0000000..9de21ea
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/android-tools/android-tools_5.1.1.r37.bbappend
@@ -0,0 +1,14 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
+
+SRC_URI += " \
+ file://0003-adb-force-root.patch \
+ file://0004-adb-enable-reboot.patch \
+ file://fix_monotonic_time.patch \
+"
+
+TOOLS_remove = " \
+ adb \
+ fastboot \
+ ext4_utils \
+ mkbootimg \
+"
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/align_4kb.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/align_4kb.py
new file mode 100644
index 0000000..c9c9a99
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/align_4kb.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import sys
+import os
+
+
+if len(sys.argv) != 2:
+ print('Usage : align_4kb [file_name]')
+ sys.exit()
+
+if not os.path.isfile(sys.argv[1]):
+ print(sys.argv[1] + ' not exist')
+ sys.exit()
+
+if os.path.getsize(sys.argv[1]) % 4096 == 0:
+ print('file size is 4KB alignment')
+ sys.exit()
+
+file_src = sys.argv[1]
+file_dst = os.path.splitext(
+ file_src)[0] + "_original" + os.path.splitext(file_src)[1]
+
+if os.path.exists(file_dst):
+ os.remove(file_dst)
+
+os.rename(file_src, file_dst)
+
+file_src = file_dst
+file_dst = sys.argv[1]
+
+with open(file_dst, 'ab') as fdst:
+ with open(file_src, 'rb') as fsrc:
+ data = fsrc.read()
+ len_diff = 4096 - len(data) % 4096
+ fdst.write(data)
+ if len_diff:
+ fdst.write(b'\xff' * len_diff)
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main-user/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main-user/flashproc.py
new file mode 100644
index 0000000..22e7e45
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main-user/flashproc.py
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT' : [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0'] ]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT' : [ ['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0'] ]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+# return procedure list
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main/flashproc.py
new file mode 100644
index 0000000..db2a1eb
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-main/flashproc.py
@@ -0,0 +1,142 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img'],
+ ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'],
+ ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img'],
+ ['fastboot', 'erase', 'vbmeta_a'],
+ ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'],
+ ['fastboot', 'erase', 'vbmeta_b'],
+ ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-test/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-test/flashproc.py
new file mode 100644
index 0000000..c623175
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-test/flashproc.py
@@ -0,0 +1,139 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'flash', 'mmc0boot0', 'MBR_EMMC_BOOT0'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ext4'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.ext4']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp1/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp1/flashproc.py
new file mode 100644
index 0000000..c58be5c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp1/flashproc.py
@@ -0,0 +1,146 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img'],
+ ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'],
+ ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img'],
+ ['fastboot', 'flash', 'hsm_os', 'hsm_os.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.ubi'],
+ ['fastboot', 'erase', 'vbmeta_a'],
+ ['fastboot', 'flash', 'vbmeta_a', 'vbmeta.img'],
+ ['fastboot', 'erase', 'vbmeta_b'],
+ ['fastboot', 'flash', 'vbmeta_b', 'vbmeta.img']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp2/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp2/flashproc.py
new file mode 100644
index 0000000..7104ae8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp2/flashproc.py
@@ -0,0 +1,140 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'flash', 'mmc0boot0', 'MBR_EMMC_BOOT0'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ext4'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img'],
+ ['fastboot', 'flash', 'hsm_os', 'hsm_os.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ext4'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3-user/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3-user/flashproc.py
new file mode 100644
index 0000000..22e7e45
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3-user/flashproc.py
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT' : [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0'] ]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT' : [ ['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0'] ]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+# return procedure list
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3/flashproc.py
new file mode 100644
index 0000000..5904b5c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp3/flashproc.py
@@ -0,0 +1,139 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp4/flashproc.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp4/flashproc.py
new file mode 100644
index 0000000..5904b5c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/auto2731evb-ivt-vp4/flashproc.py
@@ -0,0 +1,139 @@
+#!/usr/bin/python
+import os
+
+procedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'mmc0'],
+ ['fastboot', 'erase', 'mmc0boot0'],
+ ['fastboot', 'erase', 'nand0'],
+ ['fastboot', 'flash', 'nand0', 'MBR_NAND'],
+ ['fastboot', 'flash', 'mmc0', 'MBR_EMMC'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'flash', 'sncfg', 'sncfg.ubi'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+userprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'system'],
+ ['fastboot', 'flash', 'system', 'system.ubi'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+bootprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'flash', 'boot', 'boot.img'],
+ ['fastboot', 'oem', 'set_active', '0']]
+}
+
+testprocedures = {
+ # product : fastboot args
+ 'DEFAULT': [['fbWait'],
+ ['fastboot', 'flash', 'EMPTY', 'bl2.img'],
+ ['fastboot', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'flash', 'download:tz', 'tee.img'],
+ ['fastboot', 'flash', 'download:bl33', 'bl33.img'],
+ ['fastboot', 'flash', 'download:spmfw', 'spmfw.img'],
+ ['fastboot', 'oem', 'continue'],
+ ['fbWait'],
+ ['fastboot', 'erase', 'bl2'],
+ ['fastboot', 'flash', 'bl2', 'bl2.img'],
+ ['fastboot', 'erase', 'bl33'],
+ ['fastboot', 'flash', 'bl33', 'bl33.img'],
+ ['fastboot', 'erase', 'spm'],
+ ['fastboot', 'flash', 'spm', 'spmfw.img'],
+ ['fastboot', 'erase', 'boot_a'],
+ ['fastboot', 'flash', 'boot_a', 'boot.img'],
+ ['fastboot', 'erase', 'boot_b'],
+ ['fastboot', 'flash', 'boot_b', 'boot.img'],
+ ['fastboot', 'erase', 'dtbo'],
+ ['fastboot', 'flash', 'dtbo', 'combo.dtbo'],
+ ['fastboot', 'erase', 'tee_a'],
+ ['fastboot', 'flash', 'tee_a', 'tee.img'],
+ ['fastboot', 'erase', 'tee_b'],
+ ['fastboot', 'flash', 'tee_b', 'tee.img'],
+ ['fastboot', 'erase', 'md1img_a'],
+ ['fastboot', 'flash', 'md1img_a', 'md1img.img'],
+ ['fastboot', 'erase', 'md1img_b'],
+ ['fastboot', 'flash', 'md1img_b', 'md1img.img'],
+ ['fastboot', 'erase', 'system_a'],
+ ['fastboot', 'flash', 'system_a', 'system.img'],
+ ['fastboot', 'erase', 'system_b'],
+ ['fastboot', 'flash', 'system_b', 'system.img'],
+ ['fastboot', 'erase', 'userdata'],
+ ['fastboot', 'flash', 'userdata', 'userdata.img']]
+}
+
+# return procedure list
+
+
+def getFlashProc(product):
+ try:
+ ret = procedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashUserProc(product):
+ try:
+ ret = userprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashBootProc(product):
+ try:
+ ret = bootprocedures[product.upper()]
+ return ret
+ except:
+ return None
+
+
+def getFlashTestProc(product):
+ try:
+ ret = testprocedures[product.upper()]
+ return ret
+ except:
+ return None
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/flashimage.py b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/flashimage.py
new file mode 100644
index 0000000..9bdef11
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/files/flashimage.py
@@ -0,0 +1,387 @@
+#!/usr/bin/python
+
+import os
+import os.path
+import sys
+import platform
+import argparse
+import shlex
+import subprocess
+import time
+import re
+
+################################################################################
+# check python version
+if sys.hexversion >= 0x02070000:
+ pass
+else:
+ print('Please install Python 2.7.x or newer to run this script')
+ exit(1)
+
+# override input() in python2
+try:
+ input = raw_input
+except NameError:
+ pass
+
+################################################################################
+
+verbose = False
+for_nata = False
+skipFlash = False
+
+fbtool = 'fbtool.py'
+fastboot = 'fastboot'
+
+system = platform.system()
+machine = platform.machine()
+product_out = os.path.abspath('.')
+
+if 'Windows' in system or 'CYGWIN' in system:
+ fastboot += '.exe'
+elif 'Linux' in system:
+ if 'x86_64' in machine:
+ fastboot += '-linux-x86_64'
+ elif 'arm' in machine or 'aarch64' in machine:
+ fastboot += '-linux-arm'
+elif 'Darwin' in system:
+ fastboot += '-darwin'
+
+# Generate image list from procedure list
+
+
+def getImageList(procs):
+ imgs = []
+ try:
+ for p in procs:
+ if p[0] == 'fastboot' and p[1] == 'flash' and p[3] not in imgs:
+ imgs.append(p[3])
+ except Exception as e:
+ print(e)
+ return imgs
+
+
+def call(cmd):
+ '''cmd: the command list for subprocess.call'''
+ if verbose:
+ print('call:', ' '.join(cmd))
+ if for_nata is True:
+ return subprocess.call(cmd, stdout=sys.stdout, stderr=subprocess.STDOUT, shell=True)
+ else:
+ return subprocess.call(formatArgsForSubprocess(cmd))
+
+def check_output(cmd):
+ '''cmd: the command list for subprocess.check_output'''
+ if verbose:
+ print('check_output:', ' '.join(cmd))
+ return subprocess.check_output(formatArgsForSubprocess(cmd), stderr=subprocess.STDOUT)
+
+
+def checkImage(filename, needreboot=True, _verbose=False):
+ filepath = os.path.join(product_out, filename)
+ if os.path.exists(filepath):
+ if _verbose:
+ print(filename.rjust(39, ' ') + ':' + ' PASS')
+ return filepath
+ if needreboot:
+ print(filename.rjust(39, ' ') + ':' + ' FAIL')
+ if args.nata:
+ print('[AT] Image not exist!')
+ else:
+ call([fastboot, 'reboot'])
+ exit(1)
+ return None
+
+# return 0 if success
+
+
+def cmdRun(cmd, dryrun=False):
+ ret = 1
+ raw_cmd = []
+ if cmd[0] == 'daWait':
+ daWait()
+ print('')
+ return 0
+ elif cmd[0] == 'fbWait':
+ fbWait()
+ print('')
+ return 0
+ elif cmd[0] == 'fastboot': # processing fastboot commands
+ cmd[0] = fastboot
+ if cmd[1] == 'flash':
+ # check if image path exits and valid
+ filepath = checkImage(cmd[3], False, False)
+ if filepath != None:
+ if 'CYGWIN' in system:
+ p = subprocess.check_output(
+ 'cygpath --absolute --mixed %s' % filepath)
+ if p:
+ filepath = p.strip()
+ raw_cmd += [cmd[0], cmd[1], cmd[2], filepath]
+ else:
+ raw_cmd += cmd
+ else:
+ print('FAIL: Unknown command!')
+ return -1
+ if dryrun:
+ print(' '.join(raw_cmd))
+ ret = 0
+ else:
+ ret = call(raw_cmd)
+ # Bypass fastboot continue
+ if cmd[1] == 'continue':
+ ret = 0
+ if ret == 0 and cmd[0] == 'fastboot' and cmd[1] == 'reboot-bootloader' and not dryrun:
+ fbWait()
+ return ret
+
+
+def daWait(secs=60):
+ print('Waiting for DA mode')
+ ret = None
+ for i in range(secs):
+ sys.stdout.write('.')
+ sys.stdout.flush()
+ time.sleep(1)
+ ret = check_output('python %s ' % fbtool)
+ if ret != None and len(ret) != 0:
+ print('')
+ print('datool - device detected: ')
+ break
+ if ret == None:
+ print('No device detected. Please ensure that datool is running')
+ exit(1)
+
+
+def fbWait(secs=60):
+ print('Waiting for fastboot mode')
+ ret = None
+ for i in range(secs):
+ sys.stdout.write('.')
+ sys.stdout.flush()
+ time.sleep(1)
+ ret = check_output('%s devices' % fastboot)
+ if ret != None and len(ret) != 0:
+ print('')
+ print('Fastboot - device detected: %s' % (ret.split())[0])
+ break
+ if ret == None:
+ print('No device detected. Please ensure that fastboot is running on the target device')
+ exit(1)
+
+
+def cmdReboot(toBootloader=True):
+ if toBootloader:
+ call([fastboot, 'reboot-bootloader'])
+ fbWait()
+ else:
+ call([fastboot, 'reboot'])
+
+
+def formatArgsForSubprocess(cmd):
+ if not 'Windows' in system:
+ return shlex.split(cmd)
+ else:
+ return cmd
+
+
+if __name__ == '__main__':
+ # parse args
+ parser = argparse.ArgumentParser(
+ description='''
+Auto device flasher, Python 2.7.x required
+''',
+ formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument('partition', nargs='?', default='all',
+ help='partition to flash [default: all] , not include test partition')
+ parser.add_argument('-d', '--dryrun', action='store_true', default=False,
+ help='dryrun for debug, no image would be flashed')
+ parser.add_argument('-u', '--user', action='store_true', default=False,
+ help='Flash user data partition')
+ parser.add_argument('-b', '--boot', action='store_true', default=False,
+ help='Flash boot partition')
+ parser.add_argument('-t', '--test', action='store_true', default=False,
+ help='Flash test partition')
+ parser.add_argument('-v', '--verbose', action='store_true', default=False,
+ help='print more information while flashing')
+ parser.add_argument('-n', '--nata', action = 'store_true', default = False,
+ help = 'Flash image in nata')
+ parser.add_argument('--toolsdir', default=None,
+ help='''\
+The tools dir where to find fbtool and fastboot.
+Path priority order:
+ 1. --toolsdir specified
+ 2. current directory
+ 3. $PATH
+''')
+ parser.add_argument('--productdir', default=None,
+ help='''\
+The product out directory where to find images.
+Path priority order:
+ 1. --productdir specified
+ 2. current directory
+''')
+
+ args = parser.parse_args()
+ verbose = args.verbose
+ if args.dryrun:
+ verbose = True
+
+ print('')
+ parser.print_usage()
+ print('')
+ print(''.center(80, '*'))
+ print(('Running flasher on ' + platform.platform()).center(80))
+ print(''.center(80, '*'))
+ print('')
+
+ if args.nata:
+ for_nata = True
+ args.toolsdir = os.path.abspath(os.path.dirname(__file__))
+ args.productdir = args.toolsdir
+ print ('[AT] Flash Dir: %s' %args.productdir)
+
+ try:
+ from flashproc import getFlashProc
+ except ImportError as e:
+ print('ImportError:', e)
+ print('')
+ exit(1)
+ try:
+ from flashproc import getFlashUserProc
+ except:
+ getFlashUserProc = getFlashProc
+ try:
+ from flashproc import getFlashBootProc
+ except:
+ getFlashBootProc = getFlashProc
+ try:
+ from flashproc import getFlashTestProc
+ except:
+ getFlashTestProc = getFlashProc
+
+ # check flash tools
+ toolsdir = ''
+ try:
+ if args.toolsdir:
+ toolsdir = os.path.abspath(args.toolsdir)
+ fbtool = os.path.join(toolsdir, fbtool)
+ fastboot = os.path.join(toolsdir, fastboot)
+ if not os.path.exists(fbtool) or not os.path.exists(fastboot):
+ raise Exception(str(toolsdir))
+ else:
+ toolsdir = os.path.abspath('.')
+ if os.path.exists(os.path.join(toolsdir, fbtool)) and os.path.exists(os.path.join(toolsdir, fastboot)):
+ fbtool = os.path.join(toolsdir, fbtool)
+ fastboot = os.path.join(toolsdir, fastboot)
+ except Exception as e:
+ print('Can not find fbtool or fastboot in %s' % str(e))
+ print('')
+ exit(1)
+
+ devProduct = 'DEFAULT'
+
+ procs = getFlashProc(devProduct)
+ if args.user:
+ procs = getFlashUserProc(devProduct)
+ if args.boot:
+ procs = getFlashBootProc(devProduct)
+ if args.test:
+ procs = getFlashTestProc(devProduct)
+ if procs:
+ if verbose:
+ print('Flash procedure'.center(80))
+ print(''.center(80, '-'))
+ for p in procs:
+ print('fastboot', ' '.join(p))
+ print('')
+ else:
+ print('Can not retrieve flash procedure according to product type of', devProduct)
+ print('Exit !')
+ exit(1)
+
+ # check image path
+ if args.productdir:
+ # take user specific product directory
+ product_out = os.path.abspath(args.productdir)
+ else:
+ # check current directory
+ product_out = os.path.abspath('.')
+ for img in getImageList(procs):
+ if checkImage(img, False, False) is None:
+ product_out = None
+ break
+ if product_out is None:
+ product_out = os.getenv('PRODUCT_OUT', '.')
+ product_out = os.path.abspath(product_out)
+
+ print(''.center(80, '*'))
+ print('* flash images under:'.ljust(79, ' ') + '*')
+ print('* ' + product_out.ljust(73, ' ') + '*')
+ print(''.center(80, '*'))
+ print('')
+
+ # check images
+ print('Checking image'.center(80))
+ print(''.center(80, '-'))
+ images = getImageList(procs)
+ try:
+ for img in images:
+ checkImage(img, _verbose=True)
+ except Exception as e:
+ print(e)
+ time.sleep(2)
+ if args.nata:
+ print ('[AT] Check image fail, stop to flash!')
+ else:
+ cmdReboot(False)
+ input('Fail, press enter to exit: ')
+ exit(1)
+ # For NATA
+ if args.nata:
+ #POWER OFF
+ print ('[AT] POWER PIN KEY:0, %s' %time.ctime())
+ time.sleep(2)
+ #PRESS DOWNLOAD KEY
+ print ('[AT] DOWNLOAD KEY:1, %s' %time.ctime())
+ time.sleep(2)
+ #POWER ON
+ print ('[AT] POWER PIN KEY:1, %s' %time.ctime())
+ time.sleep(2)
+
+ # align 4kb for modem related images
+ os.system('python align_4kb.py \"%s\"' % checkImage('md1img.img', False, False))
+
+ # flash images
+ print('')
+ print('Start flashing'.center(80))
+ print(''.center(80, '-'))
+ try:
+ for proc in procs:
+ if skipFlash == False:
+ if 0 != cmdRun(proc, args.dryrun):
+ raise Exception('<<FAILED>> %s' % ' '.join(proc))
+ else:
+ if proc[0] == 'fastboot' and proc[1] == 'flash':
+ print('Skip flashing', proc[3])
+ except Exception as e:
+ print(e)
+ if args.nata:
+ #RELEASE DOWNLOAD KEY
+ print ('[AT] DOWNLOAD KEY:0, %s' %time.ctime())
+ time.sleep(2)
+ time.sleep(2)
+ cmdReboot(False)
+ exit(1)
+
+ if args.nata:
+ #RELEASE DOWNLOAD KEY
+ print ('[AT] DOWNLOAD KEY:0, %s' %time.ctime())
+ time.sleep(2)
+ time.sleep(2)
+ cmdReboot(False)
+ print('')
+ if args.nata:
+ print ('[AT] Flash Success')
+ else:
+ print('Success')
diff --git a/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/flashtool.bbappend b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/flashtool.bbappend
new file mode 100644
index 0000000..062cc1c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-devtools/flashtool/flashtool.bbappend
@@ -0,0 +1,14 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+SRC_URI = "file://README file://flashimage.py file://align_4kb.py file://${MACHINE}"
+
+SSTATE_DUPWHITELIST += "${DEPLOY_DIR_IMAGE}"
+
+do_compile[nostamp] = "1"
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install -m 755 ${WORKDIR}/flashimage.py -t ${DEPLOYDIR}
+ install -m 755 ${WORKDIR}/align_4kb.py -t ${DEPLOYDIR}
+ install -m 755 ${WORKDIR}/${MACHINE}/flashproc.py -t ${DEPLOYDIR}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/LICENSE b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/Makefile b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/Makefile
new file mode 100644
index 0000000..446af06
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/Makefile
@@ -0,0 +1,21 @@
+TARGET := keepalive
+SOURCES := keepalive.c
+OBJECTS := $(SOURCES:.c=.o)
+
+GET_LOCAL_DIR = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+
+.PHONY: all clean install
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
+
+clean:
+ $(RM) $(OBJECTS) $(TARGET)
+
+install: $(TARGET)
+ install -d $(DESTDIR)$(PREFIX)/bin/
+ install -d $(DESTDIR)$(PREFIX)/lib/
+ install -d $(DESTDIR)$(PREFIX)/lib/pkgconfig/
+ install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/keepalive.c b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/keepalive.c
new file mode 100644
index 0000000..c6d5aeb
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/files/keepalive.c
@@ -0,0 +1,352 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <string.h>
+#include <sys/un.h>
+
+#define SERVERNAME "/tmp/socket-demoapp"
+#define STARTKEEPALIVE "RIL_REQUEST_START_KEEPALIVE_PRO"
+#define STOPKEEPALIVE "RIL_REQUEST_STOP_KEEPALIVE_PRO"
+#define KEEPALIVESTATUS "RIL_UNSOL_KEEPALIVE_STATUS_PRO"
+
+typedef enum {
+ IPV4_TCP = 0,
+ IPV4_UDP = 1,
+ IPV6_TCP = 2,
+ IPV6_UDP = 3
+} PacketType;
+
+#define MAX_INADDR_LEN 16
+typedef struct {
+ PacketType type; /* Type of keepalive packet */
+ char sourceAddress[MAX_INADDR_LEN]; /* Source address in network-byte order */
+ int sourcePort; /* Source port if applicable, or 0x7FFFFFFF;
+ the maximum value is 65535 */
+ char destinationAddress[MAX_INADDR_LEN]; /* Destination address in network-byte order */
+ int destinationPort; /* Destination port if applicable or 0x7FFFFFFF;
+ the maximum value is 65535 */
+ int netif_id;
+ int keepIdleTime; /*Sec. If no data during these time, start detecting, */
+ int keepIntervalTime; /*seconds between two packets*/
+ int retryCount; /*Detecting counts*/
+} Keepalive_Pro;
+
+typedef enum{
+ KEEPALIVE_ACTIVE,
+ KEEPALIVE_INACTIVE,
+ KEEPALIVE_PENDING
+} KeepaliveStatusCode;
+
+typedef struct{
+ uint32_t sessionHandle;
+ KeepaliveStatusCode code;
+} KeepaliveStatus;
+
+
+int TCPkeepaliveonoff(int sockfd,int onoff,Keepalive_Pro *KLpro)
+{
+ setsockopt(sockfd, SOL_TCP, TCP_KEEPCNT, &(KLpro->retryCount), sizeof(KLpro->retryCount));
+ setsockopt(sockfd, SOL_TCP, TCP_KEEPIDLE, &(KLpro->keepIdleTime), sizeof(KLpro->keepIdleTime));
+ setsockopt(sockfd, SOL_TCP, TCP_KEEPINTVL, &(KLpro->keepIntervalTime), sizeof(KLpro->keepIntervalTime));
+ setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &onoff, sizeof(onoff));
+}
+
+int createsock(char *serverip,int server_port)
+{
+ int clientSocket;
+ struct sockaddr_in serverAddr;
+ if((clientSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ {
+ printf("create socket error");
+ return 1;
+ }
+
+ serverAddr.sin_family = AF_INET;
+ serverAddr.sin_port = htons(server_port);
+ serverAddr.sin_addr.s_addr = inet_addr(serverip);
+ if(connect(clientSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0)
+ {
+ printf("connect to server error");
+ return 1;
+ }
+ return clientSocket;
+
+}
+
+int getipif(char* ip,char *iface)
+{
+ struct ifaddrs *addrs, *iap;
+ struct sockaddr_in *sa;
+ char buf[32];
+
+ getifaddrs(&addrs);
+ for (iap = addrs; iap != NULL; iap = iap->ifa_next)
+ {
+ if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET)
+ {
+ sa = (struct sockaddr_in *)(iap->ifa_addr);
+ inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, sizeof(buf));
+ if (!strcmp(ip, buf))
+ {
+ strcpy(iface,iap->ifa_name);
+ }
+ }
+ }
+ freeifaddrs(addrs);
+ return 0;
+}
+
+int printsockinfo(int sockfd)
+{
+ struct sockaddr_in local_addr;
+ char local_ip[MAX_INADDR_LEN];
+ int local_port=0;
+ char iface[10];
+ socklen_t local_addr_len=sizeof(local_addr);
+ getsockname(sockfd,(struct sockaddr *)&local_addr,&local_addr_len);
+ inet_ntop(AF_INET,&local_addr.sin_addr,local_ip,sizeof(local_ip));
+ local_port=ntohs(local_addr.sin_port);
+ getipif(local_ip,iface);
+ printf("local ip %s port %d interface %s\n",local_ip,local_port,iface);
+}
+
+int getKLpara(int sockfd,Keepalive_Pro *KLpro)
+{
+ struct sockaddr_in source_addr;
+
+ char iface[10];
+ socklen_t source_addr_len=sizeof(source_addr);
+ getsockname(sockfd,(struct sockaddr *)&source_addr,&source_addr_len);
+ //get source ip
+ inet_ntop(AF_INET,&source_addr.sin_addr,KLpro->sourceAddress,sizeof(KLpro->sourceAddress));
+ //get source port
+ KLpro->sourcePort=ntohs(source_addr.sin_port);
+
+ getipif(KLpro->sourceAddress,iface);
+ if(strstr(iface,"ccmni"))
+ {
+ KLpro->netif_id=atoi(iface+5);
+ }
+ printf(" ip %s port %d interface %s\n",KLpro->sourceAddress,KLpro->sourcePort,iface);
+}
+
+
+int sendinfotoserver(int sockfd)
+{
+ int ret=0;
+ ret=send(sockfd,"\0",1,0);
+ if(ret<=0)
+ {
+ printf("send info to server error\n");
+ return -1;
+ }
+ printf("send info to server\n");
+ return 0;
+}
+
+int setkeepaliveenable(int *sockfd,Keepalive_Pro *KLpro)
+{
+ int sessionhandle=0;
+ struct sockaddr_un client;
+ //create unix domain socket to connection demoapp
+ *sockfd = socket(AF_UNIX,SOCK_STREAM,0);
+
+ client.sun_family = AF_UNIX;
+ strcpy(client.sun_path,SERVERNAME);
+ bind(*sockfd,(struct sockaddr *)&client,sizeof(client));
+
+ int result = 0;
+ result = connect(*sockfd,(struct sockaddr *)&client,sizeof(client));
+ if(result <0){
+ printf("error in connect to demoapp\n");
+ return 0;
+ }
+ char buf[256];
+ memset(buf,0,sizeof(buf));
+ snprintf(buf,256,"%s,%d,%s,%d,%s,%d,%d,%d,%d,%d",
+ STARTKEEPALIVE,
+ 0,
+ KLpro->sourceAddress,
+ KLpro->sourcePort,
+ KLpro->destinationAddress,
+ KLpro->destinationPort,
+ KLpro->netif_id,
+ KLpro->keepIdleTime,
+ KLpro->keepIntervalTime,
+ KLpro->retryCount);
+ printf("send buf %s\n",buf);
+ if( write(*sockfd,buf,sizeof(buf))>0)
+ {
+ printf("send buf to demoapp\n");
+ }
+ int ret=0;
+ memset(buf,0,sizeof(buf));
+ if( ret=read(*sockfd,buf,256) >0)
+ {
+ printf("recv buf %s\n",buf);
+ if(strstr(buf,STARTKEEPALIVE))
+ {
+ if(strstr(buf,"ok"))
+ {
+ char *newbuf=buf+sizeof(STARTKEEPALIVE)+3;
+ char *p=strtok(newbuf,",");
+ char *q=strtok(NULL,",");
+ sessionhandle=atoi(p);
+ printf("code is %s\n",q);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ printf("read buf from demoapp fail\n");
+ return -1;
+ }
+ printf("sessionhandle is %d\n",sessionhandle);
+ return sessionhandle;
+}
+int keepalivestatuswait(int clientfd)
+{
+ char buf[256];
+ int ret;
+ while(1)
+ {
+ memset(buf,0,256);
+ if( (ret=read(clientfd,buf,256)) >0)
+ {
+ buf[ret]='\0';
+ printf("recv buf %s\n",buf);
+ if(strstr(buf,KEEPALIVESTATUS))
+ {
+ char *newbuf=buf+sizeof(KEEPALIVESTATUS);
+ printf("newbuf %s\n",newbuf);
+ char *p=strtok(newbuf,",");
+ char *q=strtok(NULL,",");
+ int sessionhandle=atoi(p);
+ int code= atoi(q);
+ printf("code is %d\n",code);
+ if(code==KEEPALIVE_INACTIVE)
+ {
+ printf("keepalive is fail\n");
+ break;
+ }
+ }
+ }
+
+ }
+ return 0;
+}
+int setkeepalivedisable(int sessionhandle)
+{
+
+ struct sockaddr_un client;
+ //create unix domain socket to connection demoapp
+ int sockfd = socket(AF_UNIX,SOCK_STREAM,0);
+
+ client.sun_family = AF_UNIX;
+ strcpy(client.sun_path,SERVERNAME);
+ bind(sockfd,(struct sockaddr *)&client,sizeof(client));
+
+ int result = 0;
+ result = connect(sockfd,(struct sockaddr *)&client,sizeof(client));
+ if(result <0){
+ return 0;
+ }
+
+ char buf[256];
+ memset(buf,0,sizeof(buf));
+ snprintf(buf,256,"%s,%d",
+ STOPKEEPALIVE,
+ sessionhandle);
+ if( write(sockfd,buf,sizeof(buf))>0)
+ {
+ printf("send buf to demoapp");
+ }
+
+ int ret=0;
+ memset(buf,0,sizeof(buf));
+ if( ret=read(sockfd,buf,256) >0)
+ {
+ printf("recv buf %s\n",buf);
+ if(strstr(buf,STOPKEEPALIVE))
+ {
+ if(strstr(buf,"ok"))
+ {
+ printf("stop keepalive ok\n");
+ }
+ else
+ {
+ return -1;
+ printf("stop keepalive fail\n");
+ }
+ }
+ }
+ return 0;
+}
+
+int main(int argc,char *argv[])
+{
+
+ if(argc<3)
+ {
+ printf("keepalivedemo 1 destinationAddress destinationPort keepIdleTime keepIntervalTime retryCount\n");
+
+ printf("keepalivedemo 0 sessionhandle\n");
+ return 0;
+ }
+ printf("argv %s %s \n",argv[1],argv[2]);
+ if(atoi(argv[1])==1)
+ {
+ Keepalive_Pro KLdemo;
+ strcpy(KLdemo.destinationAddress,argv[2]);
+ KLdemo.destinationPort=atoi(argv[3]);
+ if(argv[4]!=NULL)
+ KLdemo.keepIdleTime=atoi(argv[4]);
+ if(argv[5]!=NULL)
+ KLdemo.keepIntervalTime=atoi(argv[5]);
+ if(argv[6]!=NULL)
+ KLdemo.retryCount=atoi(argv[6]);
+
+ //create socket connect to destinationAddress
+ int sockfd=createsock(KLdemo.destinationAddress,KLdemo.destinationPort);
+
+#if DEBUG
+ TCPkeepaliveonoff(sockfd,1,&KLdemo);
+#endif
+
+ //get keepalive parameter
+ getKLpara(sockfd,&KLdemo);
+
+ //set keepalive enable to MD
+ int clientfd;
+ int sessionhandle=setkeepaliveenable(&clientfd,&KLdemo);
+
+ //send a data to server to ensure MD get the information for keepalive
+ sendinfotoserver(sockfd);
+
+ //MD do keepalive,wait infomation
+ keepalivestatuswait(clientfd);
+
+ close(clientfd);
+ close(sockfd);
+
+ return 0;
+ }
+ else if(atoi(argv[1])==0)
+ {
+ setkeepalivedisable(atoi(argv[2]));
+ return 0;
+ }
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/keepalivedemo_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/keepalivedemo_1.0.0.bb
new file mode 100644
index 0000000..734e2b7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/keepalivedemo/keepalivedemo_1.0.0.bb
@@ -0,0 +1,14 @@
+DESCRIPTION = "keepalivedemo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+SRC_URI = "file://LICENSE"
+SRC_URI += "file://keepalive.c"
+SRC_URI += "file://Makefile"
+
+S = "${WORKDIR}"
+inherit pkgconfig
+
+do_compile () {
+ oe_runmake
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/libxcrypt/libxcrypt_4.1.1.bbappend b/meta/meta-mediatek-mt2731/recipes-extended/libxcrypt/libxcrypt_4.1.1.bbappend
new file mode 100644
index 0000000..cf98466
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/libxcrypt/libxcrypt_4.1.1.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+CFLAGS = "-Wno-error=inline"
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/procps/procps/sysctl.conf b/meta/meta-mediatek-mt2731/recipes-extended/procps/procps/sysctl.conf
new file mode 100644
index 0000000..d57965c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/procps/procps/sysctl.conf
@@ -0,0 +1,65 @@
+# This configuration file is taken from Debian.
+#
+# /etc/sysctl.conf - Configuration file for setting system variables
+# See sysctl.conf (5) for information.
+#
+
+#kernel.domainname = example.com
+
+# Uncomment the following to stop low-level messages on console
+#kernel.printk = 4 4 1 7
+
+##############################################################3
+# Functions previously found in netbase
+#
+
+# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
+# Turn on Source Address Verification in all interfaces to
+# prevent some spoofing attacks
+net.ipv4.conf.default.rp_filter=0
+net.ipv4.conf.all.rp_filter=0
+
+# Uncomment the next line to enable TCP/IP SYN cookies
+#net.ipv4.tcp_syncookies=1
+
+# Uncomment the next line to enable packet forwarding for IPv4
+#net.ipv4.ip_forward=1
+
+# Uncomment the next line to enable packet forwarding for IPv6
+#net.ipv6.conf.all.forwarding=1
+
+
+###################################################################
+# Additional settings - these settings can improve the network
+# security of the host and prevent against some network attacks
+# including spoofing attacks and man in the middle attacks through
+# redirection. Some network environments, however, require that these
+# settings are disabled so review and enable them as needed.
+#
+# Ignore ICMP broadcasts
+#net.ipv4.icmp_echo_ignore_broadcasts = 1
+#
+# Ignore bogus ICMP errors
+#net.ipv4.icmp_ignore_bogus_error_responses = 1
+#
+# Do not accept ICMP redirects (prevent MITM attacks)
+#net.ipv4.conf.all.accept_redirects = 0
+#net.ipv6.conf.all.accept_redirects = 0
+# _or_
+# Accept ICMP redirects only for gateways listed in our default
+# gateway list (enabled by default)
+# net.ipv4.conf.all.secure_redirects = 1
+#
+# Do not send ICMP redirects (we are not a router)
+#net.ipv4.conf.all.send_redirects = 0
+#
+# Do not accept IP source route packets (we are not a router)
+#net.ipv4.conf.all.accept_source_route = 0
+#net.ipv6.conf.all.accept_source_route = 0
+#
+# Log Martian Packets
+#net.ipv4.conf.all.log_martians = 1
+#
+
+#kernel.shmmax = 141762560
+vm.watermark_scale_factor = 100
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/procps/procps_%.bbappend b/meta/meta-mediatek-mt2731/recipes-extended/procps/procps_%.bbappend
new file mode 100644
index 0000000..e2d315a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/procps/procps_%.bbappend
@@ -0,0 +1,8 @@
+DEPENDS = "ncurses"
+
+inherit autotools gettext pkgconfig update-alternatives
+
+do_install_append () {
+ install -d ${D}${sysconfdir}
+ install -m 0644 ${TOPDIR}/../meta/meta-mediatek-mt2731/recipes-extended/procps/procps/sysctl.conf ${D}${sysconfdir}/sysctl.conf
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-extended/vnstat/vnstat_1.18.bb b/meta/meta-mediatek-mt2731/recipes-extended/vnstat/vnstat_1.18.bb
new file mode 100644
index 0000000..fbf2db9
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-extended/vnstat/vnstat_1.18.bb
@@ -0,0 +1,24 @@
+# Copyright (C) 2016 Gernot Tenchio <gernot.tenchio@securepoint.de>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = ""
+HOMEPAGE = "http://humdi.net/vnstat/"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+SECTION = "console/utils"
+DEPENDS = "gd"
+PR = "r0"
+
+SRC_URI = "\
+ https://humdi.net/vnstat/vnstat-${PV}.tar.gz \
+"
+# file://vnstat-cross-build.patch
+SRC_URI[md5sum] = "c9abaeb0ce758c16f6cdfa247bd8606c"
+SRC_URI[sha256sum] = "d7193592b9e7445fa5cbe8af7d3b39982f165ee8fc58041ff41f509b37c687d5"
+
+inherit autotools pkgconfig
+
+PACKAGES_prepend += " ${PN}i "
+FILES_${PN}i += "/usr/bin/vnstati"
+RDEPENDS_${PN}i = "${PN}"
+BB_NO_NETWORK = "0"
diff --git a/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/bootloader.json b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/bootloader.json
new file mode 100644
index 0000000..68e980e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/bootloader.json
@@ -0,0 +1,93 @@
+{
+ "version": "0.0.2",
+ "magic_num": "0x000100000046504d",
+ "bl_version": 0,
+
+ /* NIST P256 hex key */
+ "public_key": "0x2ecc5c840b628386025e74b69180ce2afced3c4bcd53a31d53e6a0dc631d9120223f3e9d4c98b8e243dbe22719046bd990a81d54c9f5b75b744ad4caccfae50b",
+ /* NIST P384 hex key */
+ # "public_key": "0xcc72f96eb58964c8726ebe6978139ef567499d38af85055bebd2c9adac992c1c844d33117e12f9f3ad110e951f93b1e6b82ee2b5e62cee846a5218e079356ef4bc338061acef96ad907b06c0655356ffc64ae2bf5b82b31720409e0423bb6f9a",
+
+ /*
+ 0: IMG_AUTH_NONE
+ 1: IMG_AUTH_CUS
+ */
+ "sbc_auth_inf": 0,
+
+ /* signature algorithm
+ 0: ECDSA NIST p256
+ 1: ECDSA NIST p384
+ 2: AES CMAC
+ 3: HMAC SHA256
+ 4: NONSB SHA256
+ 5: NONSB SHA384
+ */
+ "sbc_auth_alg": 0,
+
+ /* images information */
+ "images": [
+ {
+ /* bootloader */
+ "img_file": "bootloader.bin",
+
+ /* infomations of image encryption and key usage
+ 0: none
+ 1: customer
+ 2: master
+ */
+ "img_enc_inf": 0,
+
+ /* image encryption algorithm
+ 0: AES128 ECB
+ 1: AES128 CBC
+ 2: AES256 ECB
+ 3: AES256 CBC
+ */
+ "img_enc_alg": 0,
+
+ /* AES IV vector*/
+ "img_iv": "0xa5a5a5a5c1c1c1c1e2e2e2e298989898",
+ }
+
+ ],
+
+ "load_srcipt_cmd": [
+ {
+ /* HSM bootloader */
+ "cmd": "LOAD",
+ "img_file": "bootloader.bin",
+ "addr": "0x00010000"
+ },
+ {
+ "cmd": "MCU-ENTRY",
+ "mcu_id": 1,
+ "addr": "0x00010400"
+ }
+ ],
+
+ /*
+ 0: sign key and enc key input are from json file
+ 1: sign key and enc key input are from the command line
+ */
+ "cmd_line_key": 0,
+
+ /* sign key : ECDSA + PEM format
+ 0: use above "sign_priv_key" for AES128 CMAC, HMAC-SHA25, ECDSA
+ 1: key is from pem format, just for ECDSA
+ */
+ "pem_key_format": 0,
+
+ /* sign key for ECDSA NIST p256 */
+ "sign_priv_key": "0xc1bee4fa86af8684677caeeea88ab0723e554aef0160b8fc653c0e00080f4f78",
+
+ /* sign key for ECDSA NIST p384 */
+ #"sign_priv_key": "0x55640ac9f5c622ac328e95fb11ebc8749b1e3b69007a19a9e44681a68f8ebc1dc58257b967b19e8dea7a7bf129b6bb4c",
+
+ /* sign key for AES128 CMAC, HMAC-SHA256 */
+ # "sign_priv_key": "0x000102030405060708090a0b0c0d0e0f",
+
+ /* encrypt symmetric key */
+ #"aes_enc_sym_key": "0x000102030405060708090a0b0c0d0e0f",
+ "aes_enc_sym_key": "0x000102030405060708090a0b0c0d0e0f00000000000000000000000000000000",
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm.json b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm.json
new file mode 100644
index 0000000..c4e9c80
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm.json
@@ -0,0 +1,75 @@
+{
+ "version": "0.0.2",
+ "magic_num": "0x000100000046504d",
+ "bl_version": 0,
+ "public_key": "0x2ecc5c840b628386025e74b69180ce2afced3c4bcd53a31d53e6a0dc631d9120223f3e9d4c98b8e243dbe22719046bd990a81d54c9f5b75b744ad4caccfae50b",
+ # "public_key": "0xcc72f96eb58964c8726ebe6978139ef567499d38af85055bebd2c9adac992c1c844d33117e12f9f3ad110e951f93b1e6b82ee2b5e62cee846a5218e079356ef4bc338061acef96ad907b06c0655356ffc64ae2bf5b82b31720409e0423bb6f9a",
+
+ /*
+ 0: IMG_AUTH_NONE
+ 1: IMG_AUTH_CUS
+ */
+ "sbc_auth_inf": 0,
+
+ /* signature algorithm
+ 0: ECDSA NIST p256
+ 1: ECDSA NIST p384
+ 2: AES CMAC
+ 3: HMAC SHA256
+ 4: NONSB SHA256
+ 5: NONSB SHA384
+ */
+ "sbc_auth_alg": 0,
+
+
+ /* images information */
+ "images": [
+ {
+ /* HSM rtos */
+ "img_file": "hsm.bin",
+ "img_enc_inf": 0,
+ "img_enc_alg": 0,
+ "img_iv": "0xa5a5a5a5a6a6a6a6a7a7a7a7a8a8a8a8",
+ }
+
+ ],
+
+ "load_srcipt_cmd": [
+ {
+ /* HSM rots */
+ "cmd": "LOAD",
+ "img_file": "hsm.bin",
+ "addr": "0x14170000"
+ },
+ {
+ "cmd": "MCU-ENTRY",
+ "mcu_id": 1,
+ "addr": "0x14170400"
+ }
+ ],
+
+ /*
+ 0: sign key and enc key input are from json file
+ 1: sign key and enc key input are from the command line
+ */
+ "cmd_line_key": 0,
+ /* sign key : ECDSA + PEM format
+ 0: use above "sign_priv_key" for AES128 CMAC, HMAC-SHA25, ECDSA
+ 1: key is from pem format, just for ECDSA
+ */
+ "pem_key_format": 0,
+
+ /* sign key for ECDSA NIST p256 */
+ "sign_priv_key": "0xc1bee4fa86af8684677caeeea88ab0723e554aef0160b8fc653c0e00080f4f78",
+
+ /* sign key for ECDSA NIST p384 */
+ #"sign_priv_key": "0x55640ac9f5c622ac328e95fb11ebc8749b1e3b69007a19a9e44681a68f8ebc1dc58257b967b19e8dea7a7bf129b6bb4c",
+
+ /* sign key for AES128 CMAC, HMAC-SHA256 */
+ # "sign_priv_key": "0x000102030405060708090a0b0c0d0e0f",
+
+ /* encrypt symmetric key */
+ #"aes_enc_sym_key": "0x000102030405060708090a0b0c0d0e0f",
+ "aes_enc_sym_key": "0x000102030405060708090a0b0c0d0e0f00000000000000000000000000000000",
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm_cert.bin b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm_cert.bin
new file mode 100644
index 0000000..08e7df1
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/files/hsm_cert.bin
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-hsm/hsm/hsm_1.0.0.bbappend b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/hsm_1.0.0.bbappend
new file mode 100644
index 0000000..f7b2bb0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-hsm/hsm/hsm_1.0.0.bbappend
@@ -0,0 +1,14 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+SRC_URI += "file://hsm_cert.bin \
+ file://bootloader.json \
+ file://hsm.json"
+
+do_compile_append() {
+ oe_runmake hsm -f ${B}src/build/Makefile
+ cat ${B}../hsm_cert.bin ${B}out/bootloader.bin ${B}out/hsm.bin > ${B}out/hsm_os.img
+}
+
+do_deploy_append() {
+ cp ${B}out/hsm_os.img ${DEPLOYDIR}/hsm_os.img
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mcp_lp2_nand_defconfig.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mcp_lp2_nand_defconfig.cfg
new file mode 100644
index 0000000..d7c6d1b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mcp_lp2_nand_defconfig.cfg
@@ -0,0 +1,8 @@
+CONFIG_MTD_GPT_PARTS=y
+CONFIG_MTD_NAND_MTK=y
+#CONFIG_MTD_TESTS=m
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_UBI=y
+CONFIG_MISC_FILESYSTEMS=y
+CONFIG_UBIFS_FS=y
+CONFIG_MTD_UBI_BLOCK=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6356.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6356.cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6356.cfg
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6389.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6389.cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_mt6389.cfg
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_optee.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_optee.cfg
new file mode 100644
index 0000000..42dae62
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_optee.cfg
@@ -0,0 +1 @@
+CONFIG_OPTEE=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_spi_nand_defconfig.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_spi_nand_defconfig.cfg
new file mode 100644
index 0000000..aa550c4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_spi_nand_defconfig.cfg
@@ -0,0 +1,8 @@
+CONFIG_MTD_GPT_PARTS=y
+CONFIG_MTD_NAND_MTK=y
+#CONFIG_MTD_TESTS=m
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_UBI=y
+CONFIG_MISC_FILESYSTEMS=y
+CONFIG_UBIFS_FS=y
+
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_trustonic.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_trustonic.cfg
new file mode 100644
index 0000000..3abf328
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731evb_ivt_trustonic.cfg
@@ -0,0 +1,2 @@
+CONFIG_TRUSTONIC_TEE_SUPPORT=y
+CONFIG_TRUSTONIC_TEE_VERSION="410a"
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731fpga_ivt_mcp_nand_defconfig.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731fpga_ivt_mcp_nand_defconfig.cfg
new file mode 100644
index 0000000..aa550c4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/auto2731fpga_ivt_mcp_nand_defconfig.cfg
@@ -0,0 +1,8 @@
+CONFIG_MTD_GPT_PARTS=y
+CONFIG_MTD_NAND_MTK=y
+#CONFIG_MTD_TESTS=m
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_UBI=y
+CONFIG_MISC_FILESYSTEMS=y
+CONFIG_UBIFS_FS=y
+
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/bt_audio_pcm.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/bt_audio_pcm.cfg
new file mode 100644
index 0000000..58a0e5b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/bt_audio_pcm.cfg
@@ -0,0 +1 @@
+CONFIG_BT_AUDIO_PCM=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug.cfg
new file mode 100644
index 0000000..51ad196
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug.cfg
@@ -0,0 +1,5 @@
+CONFIG_PSTORE=y
+CONFIG_PSTORE_CONSOLE=y
+CONFIG_PSTORE_PMSG=y
+CONFIG_PSTORE_FTRACE=y
+CONFIG_PSTORE_RAM=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug_aee.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug_aee.cfg
new file mode 100644
index 0000000..30d912e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/debug_aee.cfg
@@ -0,0 +1,6 @@
+CONFIG_MTK_AEE_FEATURE=y
+CONFIG_MTK_AEE_AED=y
+CONFIG_MTK_AEE_IPANIC=y
+CONFIG_MTK_RAM_CONSOLE=y
+CONFIG_MTK_RAM_CONSOLE_USING_SRAM=y
+# CONFIG_MTK_WATCHDOG is not set
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/hsm.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/hsm.cfg
new file mode 100644
index 0000000..97129cf
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/hsm.cfg
@@ -0,0 +1,2 @@
+CONFIG_HSM_CLK=y
+CONFIG_HSM_SUPPORT=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/kernel_nfsb_enable.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/kernel_nfsb_enable.cfg
new file mode 100644
index 0000000..85f1c18
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/kernel_nfsb_enable.cfg
@@ -0,0 +1,4 @@
+CONFIG_MD=y
+CONFIG_BLK_DEV_DM=y
+CONFIG_DM_VERITY=y
+CONFIG_DM_NFSB=y
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/user_build.cfg b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/user_build.cfg
new file mode 100644
index 0000000..107e606
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/files/user_build.cfg
@@ -0,0 +1 @@
+CONFIG_CONSOLE_LOGLEVEL_DEFAULT=4
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/linux/linux-mtk-extension_4.14.bbappend b/meta/meta-mediatek-mt2731/recipes-kernel/linux/linux-mtk-extension_4.14.bbappend
new file mode 100644
index 0000000..e4cc5d7
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/linux/linux-mtk-extension_4.14.bbappend
@@ -0,0 +1,127 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+# don't include kernel-image to rootfs
+RDEPENDS_${KERNEL_PACKAGE_NAME}-base = ""
+
+DEPENDS += "kern-tools-native"
+
+SRC_URI += " \
+ file://kernel_nfsb_enable.cfg \
+ file://auto2731fpga_ivt_mcp_nand_defconfig.cfg \
+ file://auto2731evb_ivt_mcp_lp2_nand_defconfig.cfg \
+ file://auto2731evb_ivt_mt6389.cfg \
+ file://auto2731evb_ivt_mt6356.cfg \
+ file://auto2731evb_ivt_trustonic.cfg \
+ file://auto2731evb_ivt_optee.cfg \
+ file://debug_aee.cfg \
+ file://debug.cfg \
+ file://user_build.cfg \
+ file://bt_audio_pcm.cfg \
+ file://hsm.cfg \
+ "
+
+merge_defconfig_function () {
+ if [ -f "${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/$2
+ else
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/$1 ${WORKDIR}/$2
+ fi
+}
+
+do_configure_prepend () {
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731evb_ivt_emmc_defconfig" ]; then
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6389" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_defconfig ${WORKDIR}/auto2731evb_ivt_mt6389.cfg
+ fi
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6356" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_sub_defconfig ${WORKDIR}/auto2731evb_ivt_mt6356.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "tbase" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_trustonic.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "optee" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_optee.cfg
+ fi
+ if [ "${KERNEL_AEE_CFG}" = "yes" ] ; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/debug_aee.cfg
+ fi
+ fi
+
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731evb_ivt_mcp_lp2_nand_defconfig" ]; then
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6389" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_defconfig ${WORKDIR}/${KBUILD_DEFCONFIG}.cfg
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_mt6389.cfg
+ fi
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6356" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_sub_defconfig ${WORKDIR}/${KBUILD_DEFCONFIG}.cfg
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_mt6356.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "tbase" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_trustonic.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "optee" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_optee.cfg
+ fi
+ if [ "${KERNEL_AEE_CFG}" = "yes" ] ; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/debug_aee.cfg
+ fi
+ fi
+
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731evb_ivt_spi_nand_defconfig" ]; then
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6389" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_defconfig ${WORKDIR}/${KBUILD_DEFCONFIG}.cfg
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_mt6389.cfg
+ fi
+ if [ "${MTK_PMIC_CHIP_TYPE}" = "MT6356" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/mt2731_sub_defconfig ${WORKDIR}/${KBUILD_DEFCONFIG}.cfg
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_mt6356.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "tbase" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_trustonic.cfg
+ fi
+ if [ "${TEE_SUPPORT}" = "optee" ]; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/auto2731evb_ivt_optee.cfg
+ fi
+ if [ "${KERNEL_AEE_CFG}" = "yes" ] ; then
+ merge_config.sh -O ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/ -m ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${WORKDIR}/debug_aee.cfg
+ fi
+ fi
+
+ if [ "${SECURE_BOOT_ENABLE}" = "yes" ]; then
+ merge_defconfig_function mt2731_defconfig kernel_nfsb_enable.cfg
+ fi
+
+ if [ "${BT_AUDIO_PCM_INTERFACE}" = "yes" ]; then
+ merge_defconfig_function mt2731_defconfig bt_audio_pcm.cfg
+ fi
+
+ if [ "${BUILD_LOAD_TYPE}" = "eng" ]; then
+ merge_defconfig_function mt2731_defconfig debug.cfg
+ fi
+ if [ "${BUILD_LOAD_TYPE}" = "user" ]; then
+ merge_defconfig_function mt2731_defconfig user_build.cfg
+ fi
+
+ if [ "${HSM_OS_SUPPORT}" = "yes" ]; then
+ merge_defconfig_function mt2731_defconfig hsm.cfg
+ fi
+
+ if [ -f "${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config" ]; then
+ mv ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/.config ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/${KBUILD_DEFCONFIG}
+ fi
+}
+
+do_configure_append () {
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731evb_ivt_emmc_defconfig" ]; then
+ rm ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/${KBUILD_DEFCONFIG}
+ fi
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731fpga_ivt_mcp_nand_defconfig" ]; then
+ rm ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/${KBUILD_DEFCONFIG}
+ fi
+ if [ "${KBUILD_DEFCONFIG}" = "auto2731evb_ivt_mcp_lp2_nand_defconfig" ]; then
+ rm ${TOPDIR}/../src/kernel/linux/v4.14/arch/${KERNEL_ARCH}/configs/${KBUILD_DEFCONFIG}
+ fi
+}
+
+KERNEL_MODULE_AUTOLOAD += "wmt_drv"
+KERNEL_MODULE_AUTOLOAD += "stp_chrdev_bt"
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-drv-insmod.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-drv-insmod.bb
new file mode 100644
index 0000000..2bce075
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-drv-insmod.bb
@@ -0,0 +1,21 @@
+DESCRIPTION = "Mediatek MT33xx GPS Driver insmod"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+
+INSMOD_SRC = "${TOPDIR}/../meta/meta-mediatek-mt2731/recipes-kernel/modules"
+
+inherit workonsrc systemd
+
+WORKONSRC = "${INSMOD_SRC}"
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "mt33xx_drv_insmod.service"
+FILES_${PN} += "${systemd_unitdir}/system/mt33xx_drv_insmod.service"
+FILES_${PN} += "etc/mt33xx_drv_insmod.sh ${systemd_unitdir}"
+
+do_install() {
+ install -d ${D}/etc
+ install -m 755 ${WORKONSRC}/mt33xx_drv_insmod.sh ${D}/etc/mt33xx_drv_insmod.sh
+ install -d ${D}${systemd_unitdir}/system
+ install -m 755 ${WORKONSRC}/mt33xx_drv_insmod.service ${D}${systemd_unitdir}/system
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-gps-drv.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-gps-drv.bb
new file mode 100644
index 0000000..4777e75
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx-gps-drv.bb
@@ -0,0 +1,35 @@
+DESCRIPTION = "Mediatek mt33xx GPS Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS = "linux-mtk-extension"
+MT33xx_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+
+inherit workonsrc
+WORKONSRC = "${MT33xx_SRC}/gps_driver"
+MODULE_NAME = "gps33xx_drv"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+PLATFORM = "2731_YOCTO_33xx"
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt33xx gps start compile
+ echo ${WORKONSRC}
+ cd ${S} && make -f Makefile.ce TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} DRIVER_DIR=${S} LINUX_SRC=${LINUX_SRC} PACKAGE_ARCH=${PACKAGE_ARCH} TARGET_OS=${TARGET_OS} TARGET_PLATFORM=${TARGET_PLATFORM} TARGET_VENDOR=${TARGET_VENDOR} CONNECTIVITY_SRC=${MT6630_SRC} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX} PLATFORM=${PLATFORM}
+ echo mt33xx gps end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt33xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt33xx/
+}
+
+FILES_${PN} += "/lib/modules/mt33xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.service b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.service
new file mode 100644
index 0000000..4bcdf66
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=mt33xx_drv_insmod
+
+[Service]
+Type=simple
+ExecStart=/bin/sh /etc/mt33xx_drv_insmod.sh
+
+[Install]
+WantedBy=basic.target
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.sh b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.sh
new file mode 100644
index 0000000..280384b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt33xx_drv_insmod.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# insmod gps driver before MNL daemon starts
+# Check if gps_drv module is loaded
+function gps_drv_loaded()
+{
+ local GPS_DRV=`lsmod | grep gps33xx_drv`
+ if [ -n "$GPS_DRV" ]; then
+ return 1
+ fi
+ return 0
+}
+
+gps_drv_loaded
+if (( $? != 0 )); then
+ echo "info: gps33xx_drv is already loaded"
+ exit 1
+fi
+
+echo insmod gps driver
+insmod /lib/modules/mt33xx/gps33xx_drv.ko
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt6630_drv_insmod.sh b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt6630_drv_insmod.sh
new file mode 100644
index 0000000..2b00b8f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt6630_drv_insmod.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# insmod wmt driver before wmt_loader starts
+echo insmod wmt driver
+insmod /lib/modules/mt66xx/wmt_drv.ko
+
+#wmt_chrdev_wifi.ko and wlan_drv_gen3.ko are loaded from wmt_loader
+
+# insmod bt driver
+echo insmod bt driver
+insmod /lib/modules/mt66xx/bt_drv.ko
+
+# insmod gps driver
+echo insmod gps driver
+insmod /lib/modules/mt66xx/gps_drv.ko
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-bt-drv.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-bt-drv.bb
new file mode 100644
index 0000000..375ae01
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-bt-drv.bb
@@ -0,0 +1,36 @@
+DESCRIPTION = "Mediatek mt6630 BT Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS = "linux-mtk-extension"
+MT6630_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+
+inherit workonsrc
+WORKONSRC = "${MT6630_SRC}/bt_driver/mt66xx"
+MODULE_NAME = "bt_drv"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+PLATFORM = "2731_YOCTO"
+#export KERNEL_VER = "v`echo "${PREFERRED_VERSION_linux-mtk-extension}" | cut -d "%" -f 1`"
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt6630 bt start compile
+ echo ${WORKONSRC}
+ make TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} LINUX_SRC=${LINUX_SRC} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX} TARGET_PLATFORM=${TARGET_PLATFORM} CONNECTIVITY_SRC=${MT6630_SRC} TARGET_VENDOR=${TARGET_VENDOR} TARGET_OS=${TARGET_OS} PACKAGE_ARCH=${PACKAGE_ARCH} PLATFORM=${PLATFORM}
+ echo mt6630 bt end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt66xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt66xx/
+}
+
+FILES_${PN} += "/lib/modules/mt66xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-drv-insmod.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-drv-insmod.bb
new file mode 100644
index 0000000..dec56e2
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-drv-insmod.bb
@@ -0,0 +1,21 @@
+DESCRIPTION = "Mediatek MT66xx BT/WIFI/GPS Driver insmod"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+
+INSMOD_SRC = "${TOPDIR}/../meta/meta-mediatek-mt2731/recipes-kernel/modules"
+
+inherit workonsrc systemd
+
+WORKONSRC = "${INSMOD_SRC}"
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "mt66xx_drv_insmod.service"
+FILES_${PN} += "${systemd_unitdir}/system/mt66xx_drv_insmod.service"
+FILES_${PN} += "etc/mt66xx_drv_insmod.sh ${systemd_unitdir}"
+
+do_install() {
+ install -d ${D}/etc
+ install -m 755 ${WORKONSRC}/mt6630_drv_insmod.sh ${D}/etc/mt66xx_drv_insmod.sh
+ install -d ${D}${systemd_unitdir}/system
+ install -m 755 ${WORKONSRC}/mt66xx_drv_insmod.service ${D}${systemd_unitdir}/system
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-gps-drv.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-gps-drv.bb
new file mode 100644
index 0000000..c29a03f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-gps-drv.bb
@@ -0,0 +1,34 @@
+DESCRIPTION = "Mediatek mt6630 GPS Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS = "linux-mtk-extension"
+MT6630_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+
+inherit workonsrc
+WORKONSRC = "${MT6630_SRC}/gps_driver"
+MODULE_NAME = "gps_drv"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt6630 gps start compile
+ echo ${WORKONSRC}
+ cd ${S} && make -f Makefile.ce TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} DRIVER_DIR=${S} LINUX_SRC=${LINUX_SRC} PACKAGE_ARCH=${PACKAGE_ARCH} TARGET_OS=${TARGET_OS} TARGET_PLATFORM=${TARGET_PLATFORM} TARGET_VENDOR=${TARGET_VENDOR} CONNECTIVITY_SRC=${MT6630_SRC} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX}
+ echo mt6630 gps end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt66xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt66xx/
+}
+
+FILES_${PN} += "/lib/modules/mt66xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wifi-drv.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wifi-drv.bb
new file mode 100644
index 0000000..9af3e46
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wifi-drv.bb
@@ -0,0 +1,38 @@
+DESCRIPTION = "Mediatek MT66xx WiFi Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS += "mt66xx-wmt-cdev-wifi"
+MT66xx_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+
+inherit workonsrc
+WORKONSRC = "${MT66xx_SRC}/wlan_driver/gen3_mt6630"
+
+MODULE_NAME = "wlan_drv_gen3"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt66xx wifi start compile
+ echo ${WORKONSRC}
+ echo ${S}
+ echo TARGET_PLATFORM=${TARGET_PLATFORM}
+
+ cd ${S} && make -f Makefile.ce TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} DRIVER_DIR=${S} LINUX_SRC=${LINUX_SRC} PACKAGE_ARCH=${PACKAGE_ARCH} TARGET_OS=${TARGET_OS} TARGET_PLATFORM=${TARGET_PLATFORM} TARGET_VENDOR=${TARGET_VENDOR} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX}
+ echo mt66xx wifi end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt66xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt66xx/
+}
+
+FILES_${PN} += "/lib/modules/mt66xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-cdev-wifi.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-cdev-wifi.bb
new file mode 100644
index 0000000..0292724
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-cdev-wifi.bb
@@ -0,0 +1,39 @@
+DESCRIPTION = "Mediatek MT66xx WiFi Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS += "mt66xx-wmt-drv"
+MT66xx_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+
+inherit workonsrc
+WORKONSRC = "${MT66xx_SRC}/wlan_driver/adapter_mt66xx/"
+
+MODULE_NAME = "wmt_chrdev_wifi"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt66xx wifi start compile
+ echo ${WORKONSRC}
+ echo ${S}
+
+ cd ${S} && make -f Makefile.ce TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} DRIVER_DIR=${S} LINUX_SRC=${LINUX_SRC} PACKAGE_ARCH=${PACKAGE_ARCH} TARGET_OS=${TARGET_OS} TARGET_VENDOR=${TARGET_VENDOR} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX}
+
+ echo mt66xx wifi end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt66xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt66xx/
+}
+
+FILES_${PN} += "/lib/modules/mt66xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-drv.bb b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-drv.bb
new file mode 100644
index 0000000..e879da3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx-wmt-drv.bb
@@ -0,0 +1,37 @@
+DESCRIPTION = "Mediatek MT66xx WMT Driver"
+LICENSE = "GPL-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/bitbake/COPYING;md5=751419260aa954499f7abaabaa882bbe"
+DEPENDS = "linux-mtk-extension"
+MT66xx_SRC = "${TOPDIR}/../src/kernel/modules/connectivity"
+inherit workonsrc
+WORKONSRC = "${MT66xx_SRC}/wmt_mt66xx/"
+
+MODULE_NAME = "wmt_drv"
+LINUX_SRC = "${TOPDIR}/tmp/work/${MACHINE_ARCH}${TARGET_VENDOR}-${TARGET_OS}/linux-mtk-extension/4.14-r0/linux-mtk-extension-4.14/"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+export CONFIG_MTK_PLATFORM = "${TARGET_PLATFORM}"
+
+
+do_buildclean() {
+}
+
+do_configure() {
+}
+
+do_compile() {
+ echo mt66xx wmt start compile
+ echo ${WORKONSRC}
+ echo ${S}
+ cd ${S} && make -f Makefile.ce TOPDIR=${TOPDIR} MODULE_NAME=${MODULE_NAME} DRIVER_DIR=${S} LINUX_SRC=${LINUX_SRC} PACKAGE_ARCH=${PACKAGE_ARCH} ARCH=${KERNEL_ARCH} CROSS_COMPILE=${TARGET_PREFIX}
+ echo mt66xx wmt end compile
+}
+
+do_install() {
+ echo ${D}
+ install -d ${D}/lib/modules/mt66xx/
+ install -m 0644 ${S}/${MODULE_NAME}.ko ${D}/lib/modules/mt66xx/
+}
+
+FILES_${PN} += "/lib/modules/mt66xx"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN}-dev = ""
diff --git a/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx_drv_insmod.service b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx_drv_insmod.service
new file mode 100644
index 0000000..194211e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-kernel/modules/mt66xx_drv_insmod.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=mt66xx_drv_insmod
+Before=wmtd.service
+
+[Service]
+Type=simple
+ExecStart=/bin/sh /etc/mt66xx_drv_insmod.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-broadcast/liblynq-broadcast.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-broadcast/liblynq-broadcast.bb
new file mode 100644
index 0000000..0ad5a07
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-broadcast/liblynq-broadcast.bb
@@ -0,0 +1,64 @@
+inherit externalsrc package
+
+DESCRIPTION = "libbroadcast.so demo"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs libpal gstreamer1.0 glib-2.0 dtmf libapn dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-broadcast"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/liblynq-broadcast
+ cp -af ${S}/include/liblynq-broadcast ${D}${includedir}/liblynq-broadcast
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-driver-control/liblynq-driver-control.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-driver-control/liblynq-driver-control.bb
new file mode 100644
index 0000000..ef7f46c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-driver-control/liblynq-driver-control.bb
@@ -0,0 +1,69 @@
+inherit externalsrc package
+
+DESCRIPTION = "libdriver-control.so demo"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs libpal gstreamer1.0 glib-2.0 dtmf libapn dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-driver-control"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/liblynq-driver-control
+ cp -af ${S}/include/liblynq-driver-control ${D}${includedir}/liblynq-driver-control
+ cp -af ${S}/include/adc ${D}${includedir}/adc
+ cp -af ${S}/include/i2c ${D}${includedir}/i2c
+ cp -af ${S}/include/pwm ${D}${includedir}/pwm
+ cp -af ${S}/include/spi ${D}${includedir}/spi
+ cp -af ${S}/include/uart ${D}${includedir}/uart
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-fota/liblynq-fota.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-fota/liblynq-fota.bb
new file mode 100644
index 0000000..28f0c55
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-fota/liblynq-fota.bb
@@ -0,0 +1,65 @@
+inherit externalsrc package
+
+DESCRIPTION = "liblynq-fota.so demo"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+DEPENDS += "bootctrl nandapi liblynq-protcl liblynq-log"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-fota"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir}"
+
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/
+ cp -af ${S}/include/ ${D}${includedir}/
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-log/liblynq-log.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-log/liblynq-log.bb
new file mode 100644
index 0000000..d928045
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-log/liblynq-log.bb
@@ -0,0 +1,60 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-log.so demo"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs libpal nandapi "
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-log"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/liblog
+ cp -af ${S}/include/liblog ${D}${includedir}/liblog
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-protcl/liblynq-protcl.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-protcl/liblynq-protcl.bb
new file mode 100644
index 0000000..909bbd9
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-protcl/liblynq-protcl.bb
@@ -0,0 +1,65 @@
+inherit externalsrc package
+
+DESCRIPTION = "liblynq-protcl.so demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus liblynq-log mosquitto "
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-protcl/"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/ftp
+ install -d ${D}${includedir}/http
+ install -d ${D}${includedir}/lynq_mqtt
+ cp -af ${S}/include/ftp ${D}${includedir}/ftp
+ cp -af ${S}/include/http ${D}${includedir}/http
+ cp -af ${S}/include/lynq_mqtt ${D}${includedir}/lynq_mqtt
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-tele-ril/liblynq-tele-ril.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-tele-ril/liblynq-tele-ril.bb
new file mode 100644
index 0000000..2157204
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-tele-ril/liblynq-tele-ril.bb
@@ -0,0 +1,64 @@
+inherit externalsrc package
+
+DESCRIPTION = "libtel-ril.so demo"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-log"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-tele-ril"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+FILES_${PN} = "${base_libdir}/*.so \
+ ${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/libtel
+ cp -af ${S}/include/libtel ${D}${includedir}/libtel
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-receive/lynq-broadcast-receive.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-receive/lynq-broadcast-receive.bb
new file mode 100644
index 0000000..4cb53f2
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-receive/lynq-broadcast-receive.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "factory test"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs liblynq-broadcast libpal glib-2.0 libapn "
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-broadcast-receive/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-broadcast-receive ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-send/lynq-broadcast-send.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-send/lynq-broadcast-send.bb
new file mode 100644
index 0000000..12c9bca
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-broadcast-send/lynq-broadcast-send.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "broadcast send demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs liblynq-broadcast libpal glib-2.0 libapn "
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-broadcast-send/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-broadcast-send ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dbustest/lynq-dbustest.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dbustest/lynq-dbustest.bb
new file mode 100644
index 0000000..0f793b3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dbustest/lynq-dbustest.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq dbus test"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "libpal gstreamer1.0 glib-2.0 dtmf libapn dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-dbustest/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-dbustest ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dev-test/lynq-dev-test.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dev-test/lynq-dev-test.bb
new file mode 100644
index 0000000..653201f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-dev-test/lynq-dev-test.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq dev test"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "libpal gstreamer1.0 lib-dev glib-2.0 dtmf libapn dbus liblynq-media"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-dev-test/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-dev-test ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-factorytest/lynq-factorytest.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-factorytest/lynq-factorytest.bb
new file mode 100644
index 0000000..50a3e94
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-factorytest/lynq-factorytest.bb
@@ -0,0 +1,32 @@
+inherit externalsrc package
+
+DESCRIPTION = "factory test"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs libpal liblynq-driver-control libvendor-ril gpshal liblynq-log glib-2.0 dtmf liblynq-tele-ril libapn dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-factorytest/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-factorytest ${D}${bindir}/
+ install -d ${D}${includedir}
+ cp -R ${S}/factoryOpen ${D}${bindir}/
+ chmod 775 ${D}${bindir}/factoryOpen/*
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-function-test/lynq-function-test.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-function-test/lynq-function-test.bb
new file mode 100644
index 0000000..63a6323
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-function-test/lynq-function-test.bb
@@ -0,0 +1,31 @@
+inherit externalsrc package
+
+DESCRIPTION = "function test"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs libpal liblynq-driver-control libvendor-ril liblynq-broadcast gstreamer1.0 glib-2.0 dtmf libapn dbus gpshal liblynq-log liblynq-tele-ril \
+ liblynq-protcl liblynq-fota nandapi"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-function-test/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-function-test ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-konoda-rock/lynq-konoda-rock.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-konoda-rock/lynq-konoda-rock.bb
new file mode 100644
index 0000000..eb2d805
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-konoda-rock/lynq-konoda-rock.bb
@@ -0,0 +1,33 @@
+inherit externalsrc package
+
+DESCRIPTION = "carota update"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+DEPENDS += "bootctrl nandapi liblynq-protcl liblynq-log liblynq-fota"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/thirdpart/Konoda/lynq-konoda-rock/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+#EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-konoda-rock ${D}${bindir}/
+# cp otamaster ${D}${bindir}/
+# chmod 777 ${D}${bindir}/otamaster
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-logrotate-service/lynq-logrotate-service.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-logrotate-service/lynq-logrotate-service.bb
new file mode 100644
index 0000000..85873c6
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-logrotate-service/lynq-logrotate-service.bb
@@ -0,0 +1,40 @@
+inherit externalsrc package systemd
+
+DESCRIPTION = "lynq_logrotate.service demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus glib-2.0 liblynq-log liblynq-fota"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-logrotate-service/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "lynq_logrotate.service"
+FILES_${PN} += "${systemd_unitdir}/system/lynq_logrotate.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "enable"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 ${B}/lynq_logrotate.service ${D}${systemd_unitdir}/system
+ fi
+
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-logrotate-service ${D}${bindir}/
+ install -d ${D}${includedir}
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-system-service/lynq-system-service.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-system-service/lynq-system-service.bb
new file mode 100644
index 0000000..922b943
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-system-service/lynq-system-service.bb
@@ -0,0 +1,44 @@
+inherit externalsrc package systemd
+
+DESCRIPTION = "lynq_system.service"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "libpal gstreamer1.0 glib-2.0 dtmf libapn dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-system-service/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "lynq_system.service"
+FILES_${PN} += "${systemd_unitdir}/system/lynq_system.service"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ echo "Installing image PN ${PN}"
+ echo "Installing image systemd_unitdir ${systemd_unitdir}"
+ echo "Installing image D ${D}"
+ echo "Installing image B ${B}"
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 ${B}/lynq_system.service ${D}${systemd_unitdir}/system
+ fi
+ install -d ${D}/etc/dbus-1/system.d
+ install -m 0644 ${S}/driver_sdk.conf ${D}/etc/dbus-1/system.d
+ install -m 0644 ${S}/broadcast_sdk.conf ${D}/etc/dbus-1/system.d
+ install -m 0644 ${S}/test_sdk.conf ${D}/etc/dbus-1/system.d
+ install -m 0755 ${S}/lynq-system-service ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpcli/lynq-tcpcli.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpcli/lynq-tcpcli.bb
new file mode 100644
index 0000000..0287da5
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpcli/lynq-tcpcli.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-tcpcli demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus glib-2.0 liblynq-log liblynq-broadcast"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-tcpcli"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-tcpcli ${D}${bindir}/
+ #install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpser/lynq-tcpser.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpser/lynq-tcpser.bb
new file mode 100644
index 0000000..7c72041
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tcpser/lynq-tcpser.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-tcpser demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus glib-2.0 liblynq-log liblynq-broadcast"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-tcpser"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-tcpser ${D}${bindir}/
+ #install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tele-cmd-test/lynq-tele-cmd-test.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tele-cmd-test/lynq-tele-cmd-test.bb
new file mode 100644
index 0000000..4d1d3be
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-tele-cmd-test/lynq-tele-cmd-test.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-tele-cmd-test demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril liblynq-tele-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-log"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-tele-cmd-test/src"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}lynq-tele-cmd-test ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-threadhandle/lynq-threadhandle.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-threadhandle/lynq-threadhandle.bb
new file mode 100644
index 0000000..2f00edb
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-threadhandle/lynq-threadhandle.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-threadhandle demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs liblynq-tele-ril liblynq-protcl dbus glib-2.0 liblynq-log liblynq-broadcast"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-threadhandle"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-threadhandle ${D}${bindir}/
+ install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpcli/lynq-udpcli.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpcli/lynq-udpcli.bb
new file mode 100644
index 0000000..c0a3e08
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpcli/lynq-udpcli.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-udpcli demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus glib-2.0 liblynq-log liblynq-broadcast"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-udpcli"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-udpcli ${D}${bindir}/
+ #install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpser/lynq-udpser.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpser/lynq-udpser.bb
new file mode 100644
index 0000000..7c88518
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-udpser/lynq-udpser.bb
@@ -0,0 +1,30 @@
+inherit externalsrc package
+
+DESCRIPTION = "lynq-udpser demo"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus glib-2.0 liblynq-log liblynq-broadcast"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-udpser"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-udpser ${D}${bindir}/
+ #install -d ${D}${includedir}
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb b/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb
new file mode 100644
index 0000000..8d24b54
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb
@@ -0,0 +1,26 @@
+SUMMARY = "Lynq Package Group - MT2731"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+RDEPENDS_packagegroup-lync-mt2731 = "\
+ lynq-system-service \
+ liblynq-driver-control \
+ lynq-broadcast-receive \
+ lynq-broadcast-send \
+ liblynq-protcl \
+ lynq-threadhandle \
+ lynq-tcpcli \
+ lynq-tcpser \
+ lynq-udpcli \
+ lynq-udpser \
+ liblynq-log \
+ lynq-factorytest \
+ liblynq-fota \
+ liblynq-tele-ril \
+ lynq-tele-cmd-test \
+ lynq-function-test \
+ logrotate \
+ lynq-logrotate-service \
+ lynq-konoda-rock \
+"
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/LICENSE b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/README b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/README
new file mode 100644
index 0000000..5c7f39f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/README
@@ -0,0 +1,10 @@
+This module is the files of MODEM
+
+
+WHAT IT DOES?
+=============
+It handles the file of modem
+
+HOW IT WAS BUILT?
+==================
+This module would be installed into rootfs.
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.bip.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.bip.rc
new file mode 100644
index 0000000..745429b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.bip.rc
@@ -0,0 +1,30 @@
+#
+## BIP related services (Begin)
+#
+on property:vendor.mtk.md1.status=ready
+ start bip
+
+on property:vendor.mtk.md1.status=reset
+ stop bip
+
+on property:vendor.mtk.md1.status=stop
+ stop bip
+
+on property:vendor.mtk.md1.status=flightmode
+ stop bip
+
+on property:vendor.mtk.md1.status=exception
+ stop bip
+
+service bip /vendor/bin/bip
+ class core
+ socket bip stream 660 root system
+ user root
+ group system log inet radio net_admin root
+ oneshot
+ disabled
+
+#
+## BIP related services (End)
+#
+
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imcb.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imcb.rc
new file mode 100644
index 0000000..de178d4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imcb.rc
@@ -0,0 +1,17 @@
+#copy from device/mediatek/common/init.volte.rc
+
+service volte_imcb /vendor/bin/volte_imcb
+ class core
+ socket volte_imsa1 stream 660 root radio
+ socket volte_imsa2 stream 660 root radio
+# socket volte_imsvt1 stream 660 root radio
+# socket volte_imsvt2 stream 660 root radio
+ socket volte_ut stream 660 root radio
+ user root
+ group system log inet radio
+ oneshot
+ disabled
+
+#
+# VoLTE related services (End)
+#
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imsm_93.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imsm_93.rc
new file mode 100644
index 0000000..74ae512
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_imsm_93.rc
@@ -0,0 +1,61 @@
+#
+# MAL related services (Begin)
+#
+
+on property:vendor.mtk.md1.status=ready
+ start volte_imsm_93
+ start volte_stack
+ start volte_ua
+ start volte_imcb
+ wait /only_for_timeout 1
+
+on property:vendor.mtk.md1.status=reset
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=stop
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=flightmode
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=exception
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+service volte_imsm_93 /vendor/bin/volte_imsm_93
+ class core
+ user root
+ group radio cache inet misc log system wifi
+ oneshot
+ disabled
+
+#
+# MAL related services (End)
+#
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_stack.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_stack.rc
new file mode 100644
index 0000000..4c84483
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_stack.rc
@@ -0,0 +1,10 @@
+
+#copy from device/mediatek/common/init.volte.rc
+
+service volte_stack /vendor/bin/volte_stack
+ class core
+ socket volte_stack stream 660 root system
+ user root
+ group system log inet radio
+ oneshot
+ disabled
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_ua.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_ua.rc
new file mode 100644
index 0000000..5bf037c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc/init.volte_ua.rc
@@ -0,0 +1,10 @@
+#copy from device/mediatek/common/init.volte.rc
+
+service volte_ua /vendor/bin/volte_ua
+ class core
+ socket volte_ua stream 660 root system
+ user root
+ group system log inet radio net_admin root
+ oneshot
+ disabled
+
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.bip.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.bip.rc
new file mode 100755
index 0000000..c0aa293
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.bip.rc
@@ -0,0 +1,30 @@
+#
+## BIP related services (Begin)
+#
+on property:vendor.mtk.md1.status=ready
+ start bip
+
+on property:vendor.mtk.md1.status=reset_2731
+ stop bip
+
+on property:vendor.mtk.md1.status=stop
+ stop bip
+
+on property:vendor.mtk.md1.status=flightmode
+ stop bip
+
+on property:vendor.mtk.md1.status=exception
+ stop bip
+
+service bip /vendor/bin/bip
+ class core
+ socket bip stream 660 root system
+ user root
+ group system log inet radio net_admin root
+ oneshot
+ disabled
+
+#
+## BIP related services (End)
+#
+
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.volte_imsm_93.rc b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.volte_imsm_93.rc
new file mode 100755
index 0000000..48c5fdd
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/init_rc_2731/init.volte_imsm_93.rc
@@ -0,0 +1,61 @@
+#
+# MAL related services (Begin)
+#
+
+on property:vendor.mtk.md1.status=ready
+ start volte_imsm_93
+ start volte_stack
+ start volte_ua
+ start volte_imcb
+# wait /only_for_timeout 1
+
+on property:vendor.mtk.md1.status=reset_2731
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=stop
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=flightmode
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+on property:vendor.mtk.md1.status=exception
+ rm /dev/radio/pttyims
+ rm /dev/radio/ptty2ims
+ rm /dev/radio/ptty3ims
+ rm /dev/radio/ptty4ims
+ stop volte_imcb
+ stop volte_ua
+ stop volte_stack
+ stop volte_imsm_93
+
+service volte_imsm_93 /vendor/bin/volte_imsm_93
+ class core
+ user root
+ group radio cache inet misc log system wifi
+ oneshot
+ disabled
+
+#
+# MAL related services (End)
+#
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/bip b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/bip
new file mode 100644
index 0000000..563e1db
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/bip
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libcurl_xcap_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libcurl_xcap_md.so
new file mode 100644
index 0000000..a2f6616
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libcurl_xcap_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_custom_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_custom_md.so
new file mode 100644
index 0000000..3983b72
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_custom_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_md.so
new file mode 100644
index 0000000..640b97c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libutinterface_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libverno.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libverno.so
new file mode 100644
index 0000000..630a9b2
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libverno.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_core_shr.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_core_shr.so
new file mode 100644
index 0000000..bb6147f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_core_shr.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_xdmc_shr.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_xdmc_shr.so
new file mode 100644
index 0000000..004fa92
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libvolte_xdmc_shr.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libyoctodummy.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libyoctodummy.so
new file mode 100644
index 0000000..eef1d6f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/libyoctodummy.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imcb b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imcb
new file mode 100644
index 0000000..4dc7287
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imcb
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imsm_93 b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imsm_93
new file mode 100644
index 0000000..5a15fa8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_imsm_93
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_stack b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_stack
new file mode 100644
index 0000000..6d13ccc
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_stack
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_ua b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_ua
new file mode 100644
index 0000000..95a54ce
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm/volte_ua
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libcurl_xcap_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libcurl_xcap_md.so
new file mode 100644
index 0000000..3e33ff0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libcurl_xcap_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_custom_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_custom_md.so
new file mode 100644
index 0000000..1e8af5c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_custom_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_md.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_md.so
new file mode 100644
index 0000000..634bcb4
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libutinterface_md.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libverno.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libverno.so
new file mode 100644
index 0000000..f35d016
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libverno.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libyoctodummy.so b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libyoctodummy.so
new file mode 100644
index 0000000..bda4efb
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/files/lwctg/libs/arm64/libyoctodummy.so
Binary files differ
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/md-ims/md-ims_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/md-ims_1.0.0.bb
new file mode 100644
index 0000000..a424ba1
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/md-ims/md-ims_1.0.0.bb
@@ -0,0 +1,51 @@
+DESCRIPTION = "IMS RP3 (IMS/XCAP/BIP)"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+SRC_URI = "file://LICENSE"
+SRC_URI += "file://lwctg"
+
+S = "${WORKDIR}"
+
+#Skip strip check in QA test
+INSANE_SKIP_${PN} += "dev-deps already-stripped"
+
+FILES_${PN}-dev = ""
+FILES_${PN} = "/ \
+ /vendor/bin \
+ /usr/lib"
+
+do_compile[noexec] = "1"
+
+ALLOW_EMPTY_${PN} = "1"
+
+do_install_append() {
+ if [ -d lwctg/init_rc ]; then
+ # Copy rc
+ install -d ${D}/
+ install lwctg/init_rc/init.volte_* ${D}/
+ install lwctg/init_rc/init.bip.rc ${D}/
+
+ if [ -d lwctg/init_rc_2731 ]; then
+ # Copy 2731 rc
+ install -d ${D}/
+ install lwctg/init_rc_2731/init.volte_* ${D}/
+ install lwctg/init_rc_2731/init.bip.rc ${D}/
+ fi
+ fi
+
+ if [ -d lwctg/libs/arm ]; then
+ # Copy bins
+ install -d ${D}/vendor/bin/
+ install lwctg/libs/arm/volte_imcb ${D}/vendor/bin/
+ install lwctg/libs/arm/volte_stack ${D}/vendor/bin/
+ install lwctg/libs/arm/volte_ua ${D}/vendor/bin/
+ install lwctg/libs/arm/volte_imsm_93 ${D}/vendor/bin/
+ install lwctg/libs/arm/bip ${D}/vendor/bin/
+
+ # Copy libs
+ install -d ${D}/usr/lib/
+ install lwctg/libs/arm/*.so ${D}/usr/lib/
+ fi
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/mdlogger/mdlogger_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-modem/mdlogger/mdlogger_1.0.0.bb
new file mode 100644
index 0000000..9393b89
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/mdlogger/mdlogger_1.0.0.bb
@@ -0,0 +1,63 @@
+#Basic Configuration
+DESCRIPTION = "emdlogger is a MD log control application."
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+MTK_SRC = "${BACH_SRC}/telephony/frameworks/opt/mdlogger"
+EMD_OUT = "${WORKDIR}/out"
+CROSS = "${TARGET_PREFIX}"
+PROJECT = "${PROJ}"
+PRODUCT_MODE = "${PROD_MODE}"
+WORKONSRC = "${MTK_SRC}"
+DEPENDS = "platform-libs libsncfg telephonyware"
+
+CFLAGS = "--sysroot=${STAGING_DIR_HOST}\ -I${STAGING_DIR_HOST}/usr/include/logger"
+
+
+inherit deploy workonsrc
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'CROSS=${CROSS}'\
+ 'PREFIX=${BACH_PREFIX}'\
+ 'PACKAGE_ARCH=${PACKAGE_ARCH}'\
+ 'ROOT=${STAGING_DIR_HOST}'"
+
+
+FILES_${PN} = "${base_sbindir}/emdlogger1 \
+ ${base_sbindir}/emdlogger_ctrl"
+
+FILES_${PN}-dbg = "${base_sbindir}/.debug"
+
+#Skip strip check in QA test.
+#RDEPENDS_${PN} += "telephonyware-dev"
+INSANE_SKIP_${PN} += "dev-deps already-stripped"
+
+
+do_compile () {
+ if [ -d "${WORKONSRC}" ]; then
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} DEF_CFLAGS="--sysroot=${STAGING_DIR_HOST} -I${STAGING_DIR_HOST}/usr/include/logger -mhard-float"
+
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} DEF_CFLAGS=${CFLAGS}
+ fi
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST}
+ fi
+
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d ${WORKONSRC} ]; then
+ install -d ${D}${base_sbindir}
+ cp -af mdlogger.elf ${D}${base_sbindir}/emdlogger1
+ cp -af mdlogger_ctrl.elf ${D}${base_sbindir}/emdlogger_ctrl
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/meta/meta_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-modem/meta/meta_1.0.0.bb
new file mode 100644
index 0000000..940de4d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/meta/meta_1.0.0.bb
@@ -0,0 +1,81 @@
+#Basic Configuration
+DESCRIPTION = "SDIO auto cal daemon"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS = "libsncfg telephonyware nvram audio-mixer-ctrl alsa-lib hfmanager"
+MTK_SRC = "${BACH_SRC}/telephony/hardware/meta"
+
+WORKONSRC = "${MTK_SRC}"
+BB_CFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -g"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+
+BB_INCLUDE_ADD = "-I${MTK_SRC}/common/inc \
+ -I${STAGING_DIR_HOST} \
+ -I${STAGING_INCDIR} \
+ -I${STAGING_INCDIR}/nvram \
+ -I${STAGING_INCDIR}/file_op \
+ -I${STAGING_INCDIR}/custom/${LINUX_KERNEL}/common/cgen/cfgfileinc \
+ -I${STAGING_INCDIR}/custom/${LINUX_KERNEL}/common/cgen/cfgdefault \
+ -I${STAGING_INCDIR}/custom/${LINUX_KERNEL}/common/cgen/inc \
+ -I${STAGING_INCDIR}/custom/${LINUX_KERNEL}/common/cgen \
+ "
+
+
+inherit deploy workonsrc
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'CROSS=${TARGET_PREFIX}'\
+ 'PROJECT=${PROJ}'\
+ 'PREFIX=${BACH_PREFIX}'\
+ 'PACKAGE_ARCH=${PACKAGE_ARCH}'\
+ 'BB_INCLUDE_ADD=${BB_INCLUDE_ADD}'\
+ 'BB_LDFLAGS_ADD=${BB_LDFLAGS_ADD}'\
+ 'LINUX_KERNEL=${LINUX_KERNEL}'"
+
+FILES_${PN} = "${base_libdir}/*.so\
+ ${base_bindir}\
+ ${base_sbindir}\
+ /mnt\
+ /tmp\
+ /etc\
+ /test"
+
+FILES_${PN}-dev = "${includedir}"
+
+FILES_${PN}-staticdev = "${base_libdir}/*.a"
+
+FILES_${PN}-dbg = "/usr/src/debug \
+ ${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+#Skip strip check in QA test.
+#RDEPENDS_${PN} += "telephonyware-dev"
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+do_compile () {
+ unset LDFLAGS
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} CFLAGS="${BB_CFLAGS_ADD} -mfpu=neon-vfpv4 -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} CFLAGS="${BB_CFLAGS_ADD}"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${D}/include" ]; then
+ install -d ${D}${includedir}
+ cp -af ${D}/include/* ${D}${includedir}
+ rm -rf ${D}/include
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/nvram/nvram_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-modem/nvram/nvram_1.0.0.bb
new file mode 100644
index 0000000..b7b182d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/nvram/nvram_1.0.0.bb
@@ -0,0 +1,74 @@
+#Basic Configuration
+DESCRIPTION = "NVRAM."
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS = "platform-libs"
+MTK_SRC = "${BACH_SRC}/telephony/external/nvram"
+
+WORKONSRC = "${MTK_SRC}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST} -fPIC -I${STAGING_DIR_HOST}/include/logger"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu -llog"
+DEF_CFLAGS = "-DMT2635 -mfpu=neon-vfpv4"
+CXXFLAGS = "-mfpu=neon-vfpv4"
+
+inherit deploy workonsrc
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'CROSS=${TARGET_PREFIX}'\
+ 'PROJECT=${PROJ}'\
+ 'DEF_CFLAGS=${DEF_CFLAGS}'\
+ 'PREFIX=${BACH_PREFIX}'\
+ 'PACKAGE_ARCH=${PACKAGE_ARCH}'\
+ 'PLATFORM_CHIP=${PLATFORM_CHIP}'\
+ 'BB_INCLUDE_ADD=${BB_INCLUDE_ADD}'\
+ 'BB_LDFLAGS_ADD=${BB_LDFLAGS_ADD}'\
+ 'LINUX_KERNEL=${LINUX_KERNEL}'"
+
+FILES_${PN} = "${base_libdir}/*.so\
+ ${base_bindir}\
+ ${base_sbindir}\
+ /mnt\
+ /tmp\
+ /etc\
+ /usr/out\
+ /test"
+
+FILES_${PN}-dev = "${includedir} \
+ /out"
+
+FILES_${PN}-staticdev = "${base_libdir}/*.a"
+
+FILES_${PN}-dbg = "/usr/src/debug \
+ ${base_sbindir}/.debug \
+ ${base_libdir}/.debug"
+
+#Skip strip check in QA test.
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+do_compile () {
+ unset LDFLAGS
+ oe_runmake all ROOT=${STAGING_DIR_HOST}${exec_prefix}
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${D}/include" ]; then
+ install -d ${D}${includedir}
+ cp -af ${D}/include/* ${D}${includedir}
+ rm -rf ${D}/include
+ fi
+}
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install ${D}/out/APDB ${DEPLOYDIR}/APDB
+}
+addtask deploy after do_install
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-modem/packagegroups/packagegroup-modem-mt2731.bb b/meta/meta-mediatek-mt2731/recipes-modem/packagegroups/packagegroup-modem-mt2731.bb
new file mode 100755
index 0000000..1ae758d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-modem/packagegroups/packagegroup-modem-mt2731.bb
@@ -0,0 +1,13 @@
+SUMMARY = "Modem Package Group - MT2731"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+RDEPENDS_packagegroup-modem-mt2731 = "\
+ packagegroup-modem-ivt \
+ \
+ meta \
+ mdlogger \
+ nvram \
+ md-ims \
+ "
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/alsa/alsa-lib/0004-Add-mt2635-ext-codec-ucm.patch b/meta/meta-mediatek-mt2731/recipes-multimedia/alsa/alsa-lib/0004-Add-mt2635-ext-codec-ucm.patch
new file mode 100644
index 0000000..2081b73
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/alsa/alsa-lib/0004-Add-mt2635-ext-codec-ucm.patch
@@ -0,0 +1,114 @@
+From fb64ad60189a27e4b57c473e27f88da9618b3c86 Mon Sep 17 00:00:00 2001
+From: mtk10076 <garlic.tseng@mediatek.com>
+Date: Tue, 29 Mar 2016 15:09:33 +0800
+Subject: [PATCH] Add mt2635-ext-codec ucm
+
+---
+ configure.ac | 1 +
+ src/conf/ucm/Makefile.am | 2 +-
+ src/conf/ucm/mt2635-ext-codec/HiFi.conf | 47 ++++++++++++++++++++++
+ src/conf/ucm/mt2635-ext-codec/Makefile.am | 4 ++
+ .../ucm/mt2635-ext-codec/mt2635-ext-codec.conf | 7 ++++
+ 5 files changed, 59 insertions(+), 1 deletion(-)
+ create mode 100644 src/conf/ucm/mt2635-ext-codec/HiFi.conf
+ create mode 100644 src/conf/ucm/mt2635-ext-codec/Makefile.am
+ create mode 100644 src/conf/ucm/mt2635-ext-codec/mt2635-ext-codec.conf
+
+diff --git a/configure.ac b/configure.ac
+index fba0152..0c8fdb1 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -656,6 +656,7 @@ AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
+ src/conf/ucm/PandaBoardES/Makefile \
+ src/conf/ucm/SDP4430/Makefile \
+ src/conf/ucm/mt2635-mt6328/Makefile \
++ src/conf/ucm/mt2635-ext-codec/Makefile \
+ src/conf/ucm/mt2701-cs42448/Makefile \
+ src/conf/ucm/mt2701-rt5640-card/Makefile \
+ src/conf/ucm/tegraalc5632/Makefile \
+diff --git a/src/conf/ucm/Makefile.am b/src/conf/ucm/Makefile.am
+index 6bf9de7..9b5e74f 100644
+--- a/src/conf/ucm/Makefile.am
++++ b/src/conf/ucm/Makefile.am
+@@ -1 +1 @@
+-SUBDIRS=DAISY-I2S PandaBoard PandaBoardES SDP4430 mt2635-mt6328 mt2701-cs42448 mt2701-rt5640-card tegraalc5632
++SUBDIRS=DAISY-I2S PandaBoard PandaBoardES SDP4430 mt2635-mt6328 mt2635-ext-codec mt2701-cs42448 mt2701-rt5640-card tegraalc5632
+diff --git a/src/conf/ucm/mt2635-ext-codec/HiFi.conf b/src/conf/ucm/mt2635-ext-codec/HiFi.conf
+new file mode 100644
+index 0000000..d719188
+--- /dev/null
++++ b/src/conf/ucm/mt2635-ext-codec/HiFi.conf
+@@ -0,0 +1,47 @@
++SectionVerb {
++ EnableSequence [
++ cdev "hw:0"
++ cset "name='Audio_I2S1_I2S2_4pin' On"
++ cset "name='Audio_Adc_I2S2_External' On"
++ ]
++ DisableSequence [
++ ]
++ # ALSA PCM
++ Value {
++ # ALSA PCM device for HiFi
++ PlaybackPCM "hw:0,8"
++ CapturePCM "hw:0,1"
++ }
++}
++SectionDevice."Speaker" {
++ Comment "Speaker playback"
++ EnableSequence [
++ cdev "hw:0"
++
++ cset "name='Audio_I2S0dl1_hd_Switch' On"
++
++ ]
++ DisableSequence [
++ cdev "hw:0"
++
++ cset "name='Audio_I2S0dl1_hd_Switch' Off"
++
++ ]
++ Value {
++ PlaybackChannels "2"
++ }
++}
++
++SectionDevice."Microphone" {
++ Comment "Internal microphone"
++
++ EnableSequence [
++ ]
++
++ DisableSequence [
++ ]
++
++ Value {
++ CaptureChannels "2"
++ }
++}
+diff --git a/src/conf/ucm/mt2635-ext-codec/Makefile.am b/src/conf/ucm/mt2635-ext-codec/Makefile.am
+new file mode 100644
+index 0000000..3965582
+--- /dev/null
++++ b/src/conf/ucm/mt2635-ext-codec/Makefile.am
+@@ -0,0 +1,4 @@
++alsaconfigdir = @ALSA_CONFIG_DIR@
++ucmdir = $(alsaconfigdir)/ucm/mt2635-ext-codec
++ucm_DATA = HiFi.conf mt2635-ext-codec.conf
++EXTRA_DIST = $(ucm_DATA)
+diff --git a/src/conf/ucm/mt2635-ext-codec/mt2635-ext-codec.conf b/src/conf/ucm/mt2635-ext-codec/mt2635-ext-codec.conf
+new file mode 100644
+index 0000000..2a406a8
+--- /dev/null
++++ b/src/conf/ucm/mt2635-ext-codec/mt2635-ext-codec.conf
+@@ -0,0 +1,7 @@
++Comment "mt2635-mt6328 sound card"
++
++SectionUseCase."HiFi" {
++ File "HiFi.conf"
++ Comment "Default"
++}
++
+--
+1.9.1
+
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/gd/gd_2.2.5.bbappend b/meta/meta-mediatek-mt2731/recipes-multimedia/gd/gd_2.2.5.bbappend
new file mode 100644
index 0000000..6567488
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/gd/gd_2.2.5.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+CFLAGS = "-Wno-error=maybe-uninitialized"
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm.bbappend b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm.bbappend
new file mode 100644
index 0000000..cbe8cc0
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm.bbappend
@@ -0,0 +1,22 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
+
+SRC_URI_append = " file://mt-snd-card/HiFi.conf \
+ file://mt-snd-card/HiFi_pcm.conf \
+ file://mt-snd-card/mt-snd-card.conf \
+ file://mt-snd-card/phonecall.conf \
+ file://mt2635-ext-codec/HiFi.conf \
+ file://mt2635-ext-codec/mt2635-ext-codec.conf \
+"
+
+do_install_append () {
+ install -d ${D}${datadir}/alsa/ucm/mt2635-ext-codec
+ install -m 644 ${S}/mt2635-ext-codec/*.conf ${D}${datadir}/alsa/ucm/mt2635-ext-codec
+ install -d ${D}${datadir}/alsa/ucm/mt-snd-card
+ if ${@bb.utils.contains("BT_AUDIO_PCM_INTERFACE","yes",'true','false',d)}; then
+ install -m 644 ${S}/mt-snd-card/HiFi_pcm.conf ${D}${datadir}/alsa/ucm/mt-snd-card/HiFi.conf
+ else
+ install -m 644 ${S}/mt-snd-card/HiFi.conf ${D}${datadir}/alsa/ucm/mt-snd-card
+ fi
+ install -m 644 ${S}/mt-snd-card/mt-snd-card.conf ${D}${datadir}/alsa/ucm/mt-snd-card
+ install -m 644 ${S}/mt-snd-card/phonecall.conf ${D}${datadir}/alsa/ucm/mt-snd-card
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi.conf
new file mode 100644
index 0000000..bf1d73a
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi.conf
@@ -0,0 +1,115 @@
+SectionVerb {
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 1"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 1"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' 1"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 PCM_0_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH2 PCM_0_CAP_CH1' 1"
+ cset "name='PCM_0_PB_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='DAC In Mux' Normal Path"
+ cset "name='LOL Mux' Playback"
+ cset "name='Ext_Speaker_Amp Switch' 1"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 1"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 1"
+ cset "name='Mic Type Mux' ACC"
+ cset "name='ADC L Mux' Left Preamplifier"
+ cset "name='ADC R Mux' Right Preamplifier"
+ cset "name='PGA L Mux' AIN1"
+ cset "name='PGA R Mux' AIN1"
+ ]
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Ext_Speaker_Amp Switch' 0"
+ cset "name='LOL Mux' Open"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 0"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 0"
+ cset "name='PCM_0_PB_CH1 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH1 PCM_0_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH2 PCM_0_CAP_CH1' 0"
+ cset "name='DAI_CH1 PCM_0_CAP_CH1' 0"
+ cset "name='PCM_0_PB_CH1 DL3_CH1' 0"
+ cset "name='Mic Type Mux' Idle"
+ cset "name='ADC L Mux' Idle"
+ cset "name='ADC R Mux' Idle"
+ cset "name='PGA L Mux' None"
+ cset "name='PGA R Mux' None"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 0"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 0"
+ ]
+ # ALSA PCM
+ Value {
+ # ALSA PCM device for HiFi
+ PlaybackPCM "hw:0,7"
+ CapturePCM "hw:0,1"
+ }
+}
+SectionDevice."Speaker" {
+ Comment "Speaker playback"
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 1"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 1"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_0_PB_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_0_PB_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_0_PB_CH1 DL3_CH1' 1"
+ cset "name='DAC In Mux' Normal Path"
+ cset "name='LOL Mux' Playback"
+ cset "name='Ext_Speaker_Amp Switch' 1"
+ ]
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Ext_Speaker_Amp Switch' 0"
+ cset "name='LOL Mux' Open"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 0"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 0"
+ cset "name='PCM_0_PB_CH1 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_0_PB_CH1 DL3_CH1' 0"
+ ]
+ Value {
+ PlaybackChannels "2"
+ }
+}
+
+SectionDevice."Microphone" {
+ Comment "Internal microphone"
+
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 1"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' 1"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 PCM_0_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH2 PCM_0_CAP_CH1' 1"
+ cset "name='DAI_CH1 PCM_0_CAP_CH1' 1"
+ cset "name='Mic Type Mux' ACC"
+ cset "name='ADC L Mux' Left Preamplifier"
+ cset "name='ADC R Mux' Right Preamplifier"
+ cset "name='PGA L Mux' AIN1"
+ cset "name='PGA R Mux' AIN1"
+ ]
+
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Mic Type Mux' Idle"
+ cset "name='ADC L Mux' Idle"
+ cset "name='ADC R Mux' Idle"
+ cset "name='PGA L Mux' None"
+ cset "name='PGA R Mux' None"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 0"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 0"
+ cset "name='PCM_2_PB_CH1 PCM_0_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH2 PCM_0_CAP_CH1' 0"
+ cset "name='DAI_CH1 PCM_0_CAP_CH1' 0"
+ ]
+
+ Value {
+ CaptureChannels "2"
+ }
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi_pcm.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi_pcm.conf
new file mode 100644
index 0000000..7087f48
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/HiFi_pcm.conf
@@ -0,0 +1,122 @@
+SectionVerb {
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 1"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 1"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' 1"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 PCM_1_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH2 PCM_1_CAP_CH1' 1"
+ cset "name='PCM_1_PB_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_1_PB_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='DAC In Mux' Normal Path"
+ cset "name='LOL Mux' Playback"
+ cset "name='Ext_Speaker_Amp Switch' 1"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 1"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 1"
+ cset "name='Mic Type Mux' ACC"
+ cset "name='ADC L Mux' Left Preamplifier"
+ cset "name='ADC R Mux' Right Preamplifier"
+ cset "name='PGA L Mux' AIN1"
+ cset "name='PGA R Mux' AIN1"
+ ]
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Ext_Speaker_Amp Switch' 0"
+ cset "name='LOL Mux' Open"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 0"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 0"
+ cset "name='PCM_1_PB_CH1 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_1_PB_CH2 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH1 PCM_1_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH2 PCM_1_CAP_CH1' 0"
+ cset "name='DAI_CH1 PCM_0_CAP_CH1' 0"
+ cset "name='PCM_0_PB_CH1 DL3_CH1' 0"
+ cset "name='Mic Type Mux' Idle"
+ cset "name='ADC L Mux' Idle"
+ cset "name='ADC R Mux' Idle"
+ cset "name='PGA L Mux' None"
+ cset "name='PGA R Mux' None"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 0"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 0"
+ ]
+ # ALSA PCM
+ Value {
+ # ALSA PCM device for HiFi
+ PlaybackPCM "hw:0,7"
+ CapturePCM "hw:0,1"
+ }
+}
+SectionDevice."Speaker" {
+ Comment "Speaker playback"
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 1"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 1"
+ cset "name='ADDA_DL_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='ADDA_DL_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_1_PB_CH1 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_1_PB_CH2 PCM_2_CAP_CH1' 1"
+ cset "name='PCM_1_PB_CH1 DL2_CH1' 1"
+ cset "name='PCM_1_PB_CH2 DL2_CH2' 1"
+ cset "name='DAC In Mux' Normal Path"
+ cset "name='LOL Mux' Playback"
+ cset "name='Ext_Speaker_Amp Switch' 1"
+ ]
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Ext_Speaker_Amp Switch' 0"
+ cset "name='LOL Mux' Open"
+ cset "name='ADDA_DL_CH1 DL1_CH1' 0"
+ cset "name='ADDA_DL_CH2 DL1_CH2' 0"
+ cset "name='PCM_1_PB_CH1 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_1_PB_CH2 PCM_2_CAP_CH1' 0"
+ cset "name='PCM_1_PB_CH1 DL2_CH1' 0"
+ cset "name='PCM_1_PB_CH2 DL2_CH2' 0"
+ ]
+ Value {
+ PlaybackChannels "2"
+ }
+}
+
+SectionDevice."Microphone" {
+ Comment "Internal microphone"
+
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 1"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 ADDA_UL_CH1' 1"
+ cset "name='PCM_2_PB_CH2 ADDA_UL_CH2' 1"
+ cset "name='PCM_2_PB_CH1 PCM_1_CAP_CH1' 1"
+ cset "name='PCM_2_PB_CH2 PCM_1_CAP_CH1' 1"
+ cset "name='UL2_CH1 PCM_1_CAP_CH1' 1"
+ cset "name='UL2_CH2 PCM_1_CAP_CH1' 1"
+ cset "name='Mic Type Mux' ACC"
+ cset "name='ADC L Mux' Left Preamplifier"
+ cset "name='ADC R Mux' Right Preamplifier"
+ cset "name='PGA L Mux' AIN1"
+ cset "name='PGA R Mux' AIN1"
+ ]
+
+ DisableSequence [
+ cdev "hw:0"
+ cset "name='Mic Type Mux' Idle"
+ cset "name='ADC L Mux' Idle"
+ cset "name='ADC R Mux' Idle"
+ cset "name='PGA L Mux' None"
+ cset "name='PGA R Mux' None"
+ cset "name='UL1_CH1 ADDA_UL_CH1' 0"
+ cset "name='UL1_CH2 ADDA_UL_CH2' 0"
+ cset "name='PCM_2_PB_CH1 PCM_1_CAP_CH1' 0"
+ cset "name='PCM_2_PB_CH2 PCM_1_CAP_CH1' 0"
+ cset "name='UL2_CH1 PCM_1_CAP_CH1' 0"
+ cset "name='UL2_CH2 PCM_1_CAP_CH1' 0"
+ ]
+
+ Value {
+ CaptureChannels "2"
+ }
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/mt-snd-card.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/mt-snd-card.conf
new file mode 100644
index 0000000..45846d3
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/mt-snd-card.conf
@@ -0,0 +1,11 @@
+Comment "mt-snd-card sound card"
+
+SectionUseCase."HiFi" {
+ File "HiFi.conf"
+ Comment "Default"
+}
+
+SectionUseCase."phonecall" {
+ File "phonecall.conf"
+ Comment "MTK phonecall record/DTMF"
+}
\ No newline at end of file
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/phonecall.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/phonecall.conf
new file mode 100644
index 0000000..38a2c09
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt-snd-card/phonecall.conf
@@ -0,0 +1,52 @@
+SectionVerb {
+ EnableSequence [
+ # cdev "mtk_phonecall"
+ ]
+ DisableSequence [
+ # cdev "mtk_phonecall"
+ ]
+ # ALSA PCM
+ Value {
+ # ALSA PCM device for HiFi
+ PlaybackPCM "mtk_phonecall"
+ CapturePCM "mtk_phonecall"
+ }
+}
+SectionDevice."Speaker" {
+ Comment "BGS playback"
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='Speaker_Amp_Switch' On"
+ cset "name='Ext_Speaker_Amp_Switch' On"
+
+ ]
+ DisableSequence [
+ # cdev "mtk_phonecall"
+ ]
+ Value {
+ PlaybackChannels "1"
+ }
+}
+
+SectionDevice."Microphone" {
+ Comment "Incall record"
+
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='Audio_MIC1_Mode_Select' ACC"
+ cset "name='Audio_MIC2_Mode_Select' ACC"
+ cset "name='Audio_MicSource1_Setting' ADC2"
+ cset "name='Audio_ADC_1_Switch' On"
+ cset "name='Audio_ADC_2_Switch' On"
+ cset "name='Audio_Preamp1_Switch' IN_ADC2"
+ cset "name='Audio_Preamp2_Switch' IN_ADC2"
+ ]
+
+ DisableSequence [
+ # cdev "mtk_phonecall"
+ ]
+
+ Value {
+ CaptureChannels "1"
+ }
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/HiFi.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/HiFi.conf
new file mode 100644
index 0000000..232868c
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/HiFi.conf
@@ -0,0 +1,47 @@
+SectionVerb {
+ EnableSequence [
+ cdev "hw:0"
+ cset "name='Audio_I2S1_I2S2_4pin' On"
+ cset "name='Audio_Adc_I2S2_External' On"
+ ]
+ DisableSequence [
+ ]
+ # ALSA PCM
+ Value {
+ # ALSA PCM device for HiFi
+ PlaybackPCM "hw:0,8"
+ CapturePCM "hw:0,1"
+ }
+}
+SectionDevice."Speaker" {
+ Comment "Speaker playback"
+ EnableSequence [
+ cdev "hw:0"
+
+ cset "name='Audio_I2S0dl1_hd_Switch' On"
+
+ ]
+ DisableSequence [
+ cdev "hw:0"
+
+ cset "name='Audio_I2S0dl1_hd_Switch' Off"
+
+ ]
+ Value {
+ PlaybackChannels "2"
+ }
+}
+
+SectionDevice."Microphone" {
+ Comment "Internal microphone"
+
+ EnableSequence [
+ ]
+
+ DisableSequence [
+ ]
+
+ Value {
+ CaptureChannels "2"
+ }
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/mt2635-ext-codec.conf b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/mt2635-ext-codec.conf
new file mode 100644
index 0000000..2a406a8
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-multimedia/mtk-alsa-ucm/mtk-alsa-ucm/mt2635-ext-codec/mt2635-ext-codec.conf
@@ -0,0 +1,7 @@
+Comment "mt2635-mt6328 sound card"
+
+SectionUseCase."HiFi" {
+ File "HiFi.conf"
+ Comment "Default"
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/atcid/atcid.bb b/meta/meta-mediatek-mt2731/recipes-telephony/atcid/atcid.bb
new file mode 100755
index 0000000..3d81003
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/atcid/atcid.bb
@@ -0,0 +1,30 @@
+DESCRIPTION = "atcid"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+WORKONSRC = "${BACH_SRC}/telephonyware/packages/atcid"
+DEPENDS = "platform-libs nvram libsncfg telephonyware zlib service-launcher"
+
+inherit deploy workonsrc
+inherit pkgconfig
+
+EXTRA_OEMAKE = "'ROOT=${STAGING_DIR_HOST}'\
+ 'PREFIX=${BACH_PREFIX}'\
+ 'PACKAGE_ARCH=${PACKAGE_ARCH}'\
+ 'TARGET_PLATFORM=${TARGET_PLATFORM}'"
+
+CFLAGS += "-Wl,--hash-style=gnu"
+
+do_install() {
+ oe_runmake \
+ PREFIX="${prefix}" DESTDIR="${D}" PACKAGE_ARCH="${PACKAGE_ARCH}" install
+}
+
+inherit systemd
+SYSTEMD_PACKAGES = "${PN}"
+
+FILES_${PN} += "${systemd_unitdir}/system/atcid.service"
+FILES_${PN} += "${systemd_unitdir}/system/atci_service.service"
+
+INSANE_SKIP_${PN} += "already-stripped"
+
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/packagegroups/packagegroup-telephony-mt2731.bb b/meta/meta-mediatek-mt2731/recipes-telephony/packagegroups/packagegroup-telephony-mt2731.bb
new file mode 100755
index 0000000..3d84d7d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/packagegroups/packagegroup-telephony-mt2731.bb
@@ -0,0 +1,12 @@
+SUMMARY = "Telephony Package Group - MT2731"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+RDEPENDS_packagegroup-telephony-mt2731 = "\
+ packagegroup-telephony-ivt \
+ \
+ telephonyware \
+ tele-fwk \
+ atcid \
+ "
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/tele-fwk/tele-fwk_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-telephony/tele-fwk/tele-fwk_1.0.0.bb
new file mode 100755
index 0000000..b962ed1
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/tele-fwk/tele-fwk_1.0.0.bb
@@ -0,0 +1,69 @@
+#Basic Configuration
+DESCRIPTION = "Library for RILD"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS = "platform-libs platform-libs-common gstreamer1.0 glib-2.0 libapn libpal libsncfg"
+
+MTK_SRC = "${BACH_SRC}/libvendor-ril"
+WORKONSRC = "${MTK_SRC}"
+
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+
+inherit deploy workonsrc
+
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'CROSS=${TARGET_PREFIX}'\
+ 'ROOT=${STAGING_DIR_HOST}'\
+ 'PREFIX=${BACH_PREFIX}'\
+ 'PACKAGE_ARCH=${PACKAGE_ARCH}'\
+ 'PLATFORM_CHIP=${PLATFORM_CHIP}'\
+ 'BB_INCLUDE_ADD=${BB_INCLUDE_ADD}'\
+ 'BB_LDFLAGS_ADD=${BB_LDFLAGS_ADD}'\
+ 'BB_TELEFWK_OPTION=true'\
+ 'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'"
+
+FILES_${PN} = "${base_bindir}\
+ ${base_sbindir} \
+ /etc/dbus-1/system.d/"
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+do_compile () {
+ if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mfpu=neon-vfpv4 -mhard-float -Wl,--hash-style=gnu"
+ elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mfpu=neon-vfpv4 -mhard-float -Wl,--hash-style=gnu"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu"
+ fi
+}
+
+do_install () {
+ oe_runmake install ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/vendor-ril
+ cp -af ${S}/include/telephony/ril.h ${D}${includedir}/vendor-ril
+ cp -af ${S}/include/telephony ${D}${includedir}/vendor-ril
+ install -d ${D}/etc/dbus-1/system.d
+ install -m 0644 ${S}/mtk-rilproxy/telephony/sdk/data_sdk.conf ${D}/etc/dbus-1/system.d
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/LICENSE b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/ccci_mdinit.service b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/ccci_mdinit.service
new file mode 100644
index 0000000..ef6ef23
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/files/ccci_mdinit.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=ccci md init
+Requires=bach_modem.service
+After=bach_modem.service
+
+[Service]
+StandardOutput=kmsg+console
+ExecStartPre=/bin/mkdir -p /dev/radio/
+ExecStart=/usr/sbin/ccci_mdinit 0
+ExecStop=/usr/bin/killall -s KILL ccci_mdinit
+RemainAfterExit=yes
+User=root
+Group=root
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/telephonyware.bb b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/telephonyware.bb
new file mode 100644
index 0000000..422bf35
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-telephony/telephonyware/telephonyware.bb
@@ -0,0 +1,85 @@
+SUMMARY = "telephonyware layer to support interaction with modem"
+DESCRIPTION = "telephonyware include CCCI driver, MUXD, RIL-Daemon, General interface and so on. It provide channel to telephony framework & modem HW."
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+#PV = "131+git${SRCPV}"
+
+SRC_URI = "file://LICENSE"
+#SRC_URI += "file://ccci_mdinit.service"
+
+#Skip strip check in QA test
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "dev-deps"
+INSANE_SKIP_${PN} += "ldflags dev-so"
+INSANE_SKIP_${PN}-dev += "ldflags"
+DEPENDS += "platform-libs nvram libsncfg nandapi"
+
+S = "${WORKDIR}/telephonyware"
+
+inherit cmake workonsrc
+
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+#SYSTEMD_SERVICE_${PN} = "ccci_mdinit.service"
+
+FILES_SOLIBSDEV = ""
+FILES_${PN} += "${libdir}/lib*.so"
+#FILES_${PN} += "${systemd_unitdir}/system/ccci_mdinit.service"
+
+WORKONSRC="${BACH_SRC}/telephonyware/build"
+
+do_configure() {
+ :
+}
+#cp ${WORKDIR}/cmdbuild.sh ${S}
+
+do_compile() {
+ if [ -d "${WORKONSRC}" ]; then
+ mkdir -p ${S}build
+ find ${S} -type f -exec mv {} ${S}build \;
+ rsync -aL --exclude .git ${WORKONSRC}/../external ${S}
+ rsync -aL --exclude .git ${WORKONSRC}/../hardware ${S}
+ rsync -aL --exclude .git ${WORKONSRC}/../operator ${S}
+ sh ${S}build/cmdbuild.sh build,install
+ fi
+}
+
+
+do_install() {
+# oe_runmake install
+ if [ -d "${WORKONSRC}" ]; then
+ echo "installing header files..."
+ mkdir -p ${D}include/hardware
+ mkdir -p ${D}include/log
+ mkdir -p ${D}include/property
+ cp -af ${S}/hardware/ccci/include/hardware/*.h ${D}include/hardware
+ cp -af ${S}/hardware/ril/platformlib/include/log/*.h ${D}include/log
+ cp -af ${S}/hardware/ril/platformlib/include/property/*.h ${D}include/property
+
+ if [ -d "${D}include" ]; then
+ install -d ${D}${includedir}
+ cp -af ${D}include/* ${D}${includedir}
+ rm -rf ${D}include
+ fi
+
+ echo "installing libraries..."
+ install -d ${D}${libdir}
+ install ${S}out/Symbols/lib/*.so ${D}${libdir}/
+ echo "installing sbin..."
+ install -d ${D}${sbindir}
+ install -m 0755 ${S}out/Symbols/sbin/* ${D}${sbindir}/
+ echo "installing bin..."
+
+ #if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ #install -d ${D}${systemd_unitdir}/system/
+ #install -m 0644 ../ccci_mdinit.service ${D}${systemd_unitdir}/system/
+ #fi
+ else
+ cd ${WORKDIR}/${PN}-${PV}
+ oe_runmake \
+ PREFIX="${prefix}" DESTDIR="${D}" PACKAGE_ARCH="${PACKAGE_ARCH}" install
+ fi
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/autorun/autorun_1.0.0.bb b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/autorun_1.0.0.bb
new file mode 100644
index 0000000..d0a015b
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/autorun_1.0.0.bb
@@ -0,0 +1,29 @@
+DESCRIPTION = "AutoRun"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+SRC_URI = "file://LICENSE"
+SRC_URI += "file://autorunctl"
+SRC_URI += "file://autorun.service"
+
+S = "${WORKDIR}"
+
+FILES_${PN} = "${base_bindir}/autorunctl"
+
+#Systemd Settings
+inherit systemd
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "autorun.service"
+FILES_${PN} += "${systemd_unitdir}/system/autorun.service"
+
+do_install_append() {
+ install -d ${D}${base_bindir}
+ install -m 0755 autorunctl ${D}${base_bindir}
+
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 autorun.service ${D}${systemd_unitdir}/system
+ fi
+}
+
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/LICENSE b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorun.service b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorun.service
new file mode 100644
index 0000000..bedfe29
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorun.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=AutoRun Script
+Requires=dbus.service
+After=dbus.service
+After=systemd-logind.service
+
+[Service]
+RemainAfterExit=yes
+TTYPath=/dev/ttyGS1
+WorkingDirectory=/run/media/mmcblk1p1
+ExecStartPre=/bin/ls -al /run/media/mmcblk1p1
+ExecStartPre=-/bin/ls -al /run/media/mmcblk1p2
+ExecStartPre=/bin/echo "hi, waiting 10"
+ExecStartPre=/bin/sleep 10
+ExecStartPre=/bin/echo "hi, go"
+ExecStart=/bin/sh /run/media/mmcblk1p1/autorun.sh
+StandardOutput=tty
+StandardError=tty
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorunctl b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorunctl
new file mode 100644
index 0000000..65c541e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/autorun/files/autorunctl
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+case "$1" in
+ enable )
+ systemctl enable autorun.service
+ ;;
+
+ disable )
+ systemctl disable autorun.service
+ ;;
+
+ * )
+ echo "Usage: $0 [enable/disable]"
+ ;;
+esac
+
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach-tele-earlydev.inc b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach-tele-earlydev.inc
new file mode 100755
index 0000000..d734f1d
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach-tele-earlydev.inc
@@ -0,0 +1,131 @@
+IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
+
+IMAGE_LINGUAS = " "
+
+LICENSE = "MIT"
+
+inherit core-image
+inherit create-link
+inherit create-nfsb
+inherit depends-systemd
+inherit mkstatepart
+#inherit staging-copyfile
+#inherit pack-ramdisk-kernel-initramfs
+#do_rootfs[depends] += "mtk-core-image-tiny:do_image_complete"
+
+BAD_RECOMMENDATIONS = "udev-hwdb"
+
+IMAGE_FEATURES_append = " \
+ ${@base_contains("SECURE_BOOT_ENABLE", "yes", "read-only-rootfs", "", d)} \
+"
+
+
+CORE_IMAGE_EXTRA_INSTALL += " \
+ packagegroup-core-ssh-openssh \
+ packagegroup-bach-laurel \
+ packagegroup-mtk-gstreamer1.0 \
+ packagegroup-mtk-upgrade-kit-native \
+ packagegroup-mtk-upgrade-kit \
+ ${@base_contains("TEE_SUPPORT", "tbase", "packagegroup-trustonic-app-custom", "", d)} \
+"
+# packagegroup-mtk-6630
+
+IMAGE_INSTALL_append = " \
+ util-linux \
+ ppp \
+ iproute2 \
+ iproute2-tc \
+ iptables \
+ openssl \
+ ndisc6 \
+ hostapd \
+ wpa-supplicant \
+ net-snmp \
+ zlib \
+ lrzsz \
+ radvd \
+ coreutils \
+ procps \
+ alsa-utils \
+ pulseaudio-server \
+ pulseaudio-misc \
+ udev-extraconf \
+ libmicrohttpd \
+ mtk-alsa-ucm \
+ connman \
+ positioning-gnss \
+ positioning-gnss-test \
+ agps \
+ boot-assist \
+ libipsecims \
+ tcpdump \
+ hfmanager \
+ hfsensortool\
+ init-laurel \
+ e2fsprogs \
+ service-launcher \
+ thermal_daemon \
+ tzdata \
+ mtklogger \
+ libapn \
+ fsck-msdos \
+ openssh-sftp-server \
+ iftop \
+ ${@base_contains("ADR_SUPPORT", "YES", "adrd", "", d)} \
+ lsb \
+ tree \
+ boots \
+ bash \
+ dtmf \
+ iperf3 \
+ autorun \
+ lftp \
+ wget \
+ vnstat \
+ valgrind \
+ audio-xml-parser \
+ audio-ctrl-service \
+ audio-ctrl-service-bin \
+ libmodem-afe-ctrl-service \
+ mtk-phonecall-ioplugin \
+"
+
+USR_SHARE_DATA_PATH = "${IMAGE_ROOTFS}/usr/share/data"
+
+mv_root_data_folder() {
+ mkdir -p ${USR_SHARE_DATA_PATH}
+ cp -a ${IMAGE_ROOTFS}/data/* ${USR_SHARE_DATA_PATH}
+}
+
+ROOTFS_POSTPROCESS_COMMAND += " mv_root_data_folder;"
+
+gen_rel_ver() {
+ echo "" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ echo "#### Poky (Yocto Project Reference Distro)" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+
+ if grep -q "DISTRO_NAME =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf; then
+ echo $(grep "DISTRO_NAME =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf) >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "DISTRO_NAME =" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+ if grep -q "DISTRO_VERSION =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf; then
+ echo $(grep "DISTRO_VERSION =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf) >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "DISTRO_VERSION =" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+
+ echo "" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ if [ -n "${BUILD_ID}" ]; then
+ echo "BUILD_ID=${BUILD_ID}" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "BUILD_ID=" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+ if [ -n "${BUILD_LOAD_TYPE}" ]; then
+ echo "BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE}" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "BUILD_LOAD_TYPE=" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+}
+
+ROOTFS_POSTPROCESS_COMMAND += " gen_rel_ver;"
+
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.bb b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.bb
new file mode 100644
index 0000000..da48420
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.bb
@@ -0,0 +1,5 @@
+require mtk-image-bach.inc
+
+inherit avb_sign_image
+
+SUMMARY = "A bach image."
diff --git a/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.inc b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.inc
new file mode 100644
index 0000000..211928f
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-yummy/images/mtk-image-bach.inc
@@ -0,0 +1,382 @@
+IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
+
+IMAGE_LINGUAS = " "
+
+LICENSE = "MIT"
+
+IMAGE_ROOTFS_SIZE ?= "1024"
+
+STATE_DIR_CONTENT = "${IMAGE_ROOTFS}/home ${IMAGE_ROOTFS}/usr/lib/tmpfiles.d ${IMAGE_ROOTFS}/etc/firmware ${IMAGE_ROOTFS}/etc/syslog ${IMAGE_ROOTFS}/mnt ${IMAGE_ROOTFS}/srv ${IMAGE_ROOTFS}/usr/local ${IMAGE_ROOTFS}/system/etc/firmware ${IMAGE_ROOTFS}/custom/etc/firmware ${IMAGE_ROOTFS}/var/lib ${IMAGE_ROOTFS}/data ${IMAGE_ROOTFS}/system/etc/tele ${IMAGE_ROOTFS}/system/etc/adr ${IMAGE_ROOTFS}/system/etc/agps ${IMAGE_ROOTFS}/system/etc/security ${IMAGE_ROOTFS}/etc/adr ${IMAGE_ROOTFS}/usr/share/gps"
+STATE_DIR_IMAGE_SIZE ?= "14336"
+VENDOR_PROP_FILE = "${IMAGE_ROOTFS}/vendor/build.prop"
+
+inherit core-image
+inherit create-link
+inherit create-nfsb
+inherit depends-systemd
+inherit mkstatepart
+inherit mkuserdataimg
+inherit mksncfg
+inherit create-sparse-image
+inherit staging-copyfile
+inherit make_ota_full-package
+
+EXTRA_IMAGECMD_ext4 := "-i 4096 -b 4096"
+
+do_rootfs[depends] += "mtk-core-image-tiny:do_image_complete"
+
+BAD_RECOMMENDATIONS = "udev-hwdb shared-mime-info kbd kbd-consolefonts kbd-keymaps"
+
+IMAGE_FEATURES_append = " \
+ ${@bb.utils.contains("SECURE_BOOT_ENABLE", "yes", "read-only-rootfs", "", d)} \
+"
+
+
+CORE_IMAGE_EXTRA_INSTALL += " \
+ packagegroup-core-ssh-openssh \
+ packagegroup-bach-mt2731 \
+ packagegroup-lync-mt2731 \
+ packagegroup-mtk-gstreamer1.0 \
+ ${@bb.utils.contains("MTK_GNSS_CHIP_TYPE", "MT6630", "packagegroup-mtk-6630", "packagegroup-mtk-6630-without-gps", d)} \
+ ${@bb.utils.contains("MTK_GNSS_CHIP_TYPE", "MT3303", "packagegroup-mtk-3303", "", d)} \
+ ${@bb.utils.contains("TEE_SUPPORT", "tbase", "packagegroup-trustonic-app-custom", "", d)} \
+ ${@bb.utils.contains("TEE_SUPPORT", "optee", "optee-client", "", d)} \
+ ${@bb.utils.contains("TEE_SUPPORT", "optee", "optee-test", "", d)} \
+ ${@bb.utils.contains("TEE_SUPPORT", "optee", "optee-example", "", d)} \
+ ${@bb.utils.contains("TEE_SUPPORT", "optee", "optee-services", "", d)} \
+ ${@bb.utils.contains("ADR_SUPPORT", "YES", "packagegroup-mtk-adr", "", d)} \
+"
+
+IMAGE_INSTALL_append = " \
+ util-linux \
+ ppp \
+ iproute2 \
+ iproute2-tc \
+ iptables \
+ openssl \
+ zlib \
+ lrzsz \
+ radvd \
+ coreutils \
+ procps \
+ alsa-utils-alsamixer \
+ alsa-utils-alsatplg \
+ alsa-utils-aplay \
+ alsa-utils-amixer \
+ alsa-utils-aconnect \
+ alsa-utils-iecset \
+ alsa-utils-aseqnet \
+ alsa-utils-aseqdump \
+ alsa-utils-alsactl \
+ alsa-utils-alsaloop \
+ alsa-utils-alsaucm \
+ pulseaudio-server \
+ pulseaudio-misc \
+ udev-extraconf \
+ mtk-alsa-ucm \
+ connman \
+ positioning-gnss \
+ positioning-gnss-test \
+ boot-assist \
+ libipsecims \
+ ${@bb.utils.contains("BUILD_LOAD_TYPE", "user", "", "tcpdump", d)} \
+ hfmanager \
+ hfsensortool\
+ e2fsprogs \
+ service-launcher \
+ thermal-manager \
+ tzdata \
+ mtklogger \
+ libapn \
+ fsck-msdos \
+ openssh-sftp-server \
+ iftop \
+ lsb \
+ tree \
+ boots \
+ ${@bb.utils.contains("ANW_SUPPORT", "YES", "anwtool", "", d)} \
+ bash \
+ dtmf \
+ iperf3 \
+ wireless-tools\
+ agps \
+ autorun \
+ vnstat \
+ init-2731 \
+ dtbo \
+ android-tools \
+ audio-xml-parser \
+ audio-ctrl-service \
+ audio-ctrl-service-bin \
+ mtk-phonecall-ioplugin \
+ ${@bb.utils.contains("BOOTDEV_TYPE", "nand", "mtd-utils-ubifs", "", d)} \
+ ethtool \
+ linuxptp \
+ met-driver \
+ met-driver-internal \
+ met-utils \
+ ${@bb.utils.contains("AB_OTA_UPDATER", "yes", "update-verifier", "", d)} \
+ ${@bb.utils.contains("AB_OTA_UPDATER", "yes", "update-engine-sideload", "", d)} \
+ ${@bb.utils.contains("AB_OTA_UPDATER", "yes", "mtd-utils", "", d)} \
+ ${@bb.utils.contains("MTK_AEE_SUPPORT", "yes", "aee", "", d)} \
+ ${@bb.utils.contains("MTK_AEE_SUPPORT", "yes", "mrdump", "", d)} \
+ ${@bb.utils.contains("V2X_SUPPORT", "yes", "v2x", "", d)} \
+ mt66xx-wmt-drv \
+ mt66xx-wmt-cdev-wifi \
+ mt66xx-wifi-drv \
+ mt66xx-bt-drv \
+ ${@bb.utils.contains("COMBO_CHIP_ID", "mt6630", "mt66xx-gps-drv", "", d)} \
+ ${@bb.utils.contains("MTK_GNSS_CHIP_TYPE", "MT3303", "mt33xx-gps-drv", "", d)} \
+ ${@bb.utils.contains("MTK_GNSS_CHIP_TYPE", "MT3303", "mt33xx-drv-insmod", "", d)} \
+ mt66xx-drv-insmod \
+ dhcpcd \
+ mosquitto \
+"
+
+USR_SHARE_DATA_PATH = "${IMAGE_ROOTFS}/usr/share/data"
+
+
+do_populate_sdk_prepend() {
+ d.appendVar("PACKAGE_EXCLUDE", " busybox lib64-libcxx openssl openssl-dev openssl-dbg")
+ bb.note("building sdk, PACKAGE_EXCLUDE = %s" % d.getVar("PACKAGE_EXCLUDE"))
+}
+
+def get_rootfs_size_my(d):
+ import os
+ import subprocess
+
+ rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT', True))
+ overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR', True))
+ rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE', True))
+ rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE', True))
+ rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE', True)
+ image_fstypes = d.getVar('IMAGE_FSTYPES', True) or ''
+ initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES', True) or ''
+ initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE', True)
+
+ output = subprocess.check_output(['du', '-ks', d.getVar('IMAGE_ROOTFS', True)])
+ bb.debug(1, "mylog, output=%s" % output)
+
+ size_kb = int(output.split()[0])
+ base_size = size_kb * overhead_factor
+ base_size = max(base_size, rootfs_req_size) + rootfs_extra_space
+
+python do_post1() {
+ time.sleep(1)
+ get_rootfs_size_my(d)
+}
+
+def get_rootfs_tree(d):
+ import os
+ import subprocess
+
+ out = subprocess.check_output(['tree', '--du', '-s', '-F', d.getVar('IMAGE_ROOTFS', True)])
+
+python do_post2() {
+ time.sleep(1)
+#get_rootfs_tree(d)
+}
+
+def get_rootfs_du(d):
+ import os
+ import subprocess
+
+ out = subprocess.check_output("cd %s; du -a -b . |sort -k2" % d.getVar('IMAGE_ROOTFS', True), shell=True, stderr=subprocess.STDOUT)
+
+python do_post3() {
+ time.sleep(1)
+ get_rootfs_du(d)
+}
+
+def get_rootfs_md5(d):
+ import os
+ import subprocess
+
+ out = subprocess.check_output("cd %s; find . -type f -exec md5sum {} + | awk '{print $2 $1}' | sort" % d.getVar('IMAGE_ROOTFS', True), shell=True, stderr=subprocess.STDOUT)
+
+python do_post4() {
+ time.sleep(1)
+ get_rootfs_md5(d)
+}
+
+gen_rel_ver() {
+ echo "" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ echo "#### Poky (Yocto Project Reference Distro)" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+
+ if grep -q "DISTRO_NAME =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf; then
+ echo $(grep "DISTRO_NAME =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf) >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "DISTRO_NAME =" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+ if grep -q "DISTRO_VERSION =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf; then
+ echo $(grep "DISTRO_VERSION =" ${TOPDIR}/../meta/poky/meta-poky/conf/distro/poky.conf) >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "DISTRO_VERSION =" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+
+ echo "" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ if [ -n "${BUILD_ID}" ]; then
+ echo "BUILD_ID=${BUILD_ID}" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "BUILD_ID=" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+ if [ -n "${BUILD_LOAD_TYPE}" ]; then
+ echo "BUILD_LOAD_TYPE=${BUILD_LOAD_TYPE}" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ else
+ echo "BUILD_LOAD_TYPE=" >> ${IMAGE_ROOTFS}/${sysconfdir}/lsb-release
+ fi
+}
+ROOTFS_POSTPROCESS_COMMAND += " gen_rel_ver;"
+
+gen_feature_property() {
+ echo "" >> ${VENDOR_PROP_FILE}
+ echo "###### FO <=> property mapping start ######" >> ${VENDOR_PROP_FILE}
+
+ echo "persist.radio.multisim.config=${MTK_MULTI_SIM_SUPPORT}" >> ${VENDOR_PROP_FILE}
+ #echo "persist.vendor.radio.msimmode=${MTK_MULTI_SIM_SUPPORT}" >> ${VENDOR_PROP_FILE}
+
+ echo "ro.vendor.mtk_protocol1_rat_config=${MTK_PROTOCOL1_RAT_CONFIG}" >> ${VENDOR_PROP_FILE}
+ echo "ro.boot.opt_ps1_rat=${MTK_PROTOCOL1_RAT_CONFIG}" >> ${VENDOR_PROP_FILE}
+ #echo "ro.vendor.mtk_ps1_rat=${MTK_PROTOCOL1_RAT_CONFIG}" >> ${VENDOR_PROP_FILE}
+ if [ $(echo ${MTK_PROTOCOL1_RAT_CONFIG} | grep 'L') ]; then
+ echo "ro.boot.opt_lte_support=1" >> ${VENDOR_PROP_FILE}
+ #echo "ro.vendor.mtk_lte_support=1" >> ${VENDOR_PROP_FILE}
+ fi
+ if [ $(echo ${MTK_PROTOCOL1_RAT_CONFIG} | grep 'C') ]; then
+ echo "ro.boot.opt_c2k_support=1" >> ${VENDOR_PROP_FILE}
+ #echo "ro.vendor.mtk_c2k_support=1" >> ${VENDOR_PROP_FILE}
+
+ echo "ro.boot.opt_md3_support=0" >> ${VENDOR_PROP_FILE}
+ echo "ro.boot.opt_c2k_lte_mode=2" >> ${VENDOR_PROP_FILE}
+ else
+ echo "ro.boot.opt_c2k_support=0" >> ${VENDOR_PROP_FILE}
+ #echo "ro.vendor.mtk_c2k_support=0" >> ${VENDOR_PROP_FILE}
+
+ echo "ro.boot.opt_md3_support=0" >> ${VENDOR_PROP_FILE}
+ echo "ro.boot.opt_c2k_lte_mode=0" >> ${VENDOR_PROP_FILE}
+ fi
+ if [ $(echo ${MTK_PROTOCOL1_RAT_CONFIG} | grep 'C') ]; then
+ if [ $(echo ${MTK_PROTOCOL1_RAT_CONFIG} | grep 'T') ]; then
+ echo "ro.boot.opt_md1_support=12" >> ${VENDOR_PROP_FILE}
+ else
+ echo "ro.boot.opt_md1_support=11" >> ${VENDOR_PROP_FILE}
+ fi
+ else
+ if [ $(echo ${MTK_PROTOCOL1_RAT_CONFIG} | grep 'T') ]; then
+ echo "ro.boot.opt_md1_support=10" >> ${VENDOR_PROP_FILE}
+ else
+ # Not mentioned FDD 3M & TDD 3M
+ echo "ro.boot.opt_md1_support=9" >> ${VENDOR_PROP_FILE}
+ fi
+ fi
+
+ echo "persist.vendor.radio.mtk_ps2_rat=${MTK_PROTOCOL2_RAT_CONFIG}" >> ${VENDOR_PROP_FILE}
+ #echo "persist.vendor.radio.mtk_ps3_rat=${MTK_PROTOCOL3_RAT_CONFIG}" >> ${VENDOR_PROP_FILE}
+
+ if [ ${SINGLE_BIN_MODEM_SUPPORT} = 'yes' ]; then
+ echo "ro.mtk_single_bin_modem_support=1" >> ${VENDOR_PROP_FILE}
+ else
+ echo "ro.mtk_single_bin_modem_support=0" >> ${VENDOR_PROP_FILE}
+ fi
+
+ echo "ro.build.id=${BUILD_ID}" >> ${VENDOR_PROP_FILE}
+ echo "ro.build.date=$(date -R)" >> ${VENDOR_PROP_FILE}
+
+ echo "ro.build.type=${BUILD_LOAD_TYPE}" >> ${VENDOR_PROP_FILE}
+ if [ ${BUILD_LOAD_TYPE} = 'user' ]; then
+ echo "vendor.ril.emulation.production=1" >> ${VENDOR_PROP_FILE}
+ fi
+
+ echo "ro.hardware=${TARGET_PLATFORM}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.board=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.device=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.model=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.name=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.vendor.device=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.vendor.model=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.product.vendor.name=${MTK_PROJECT}" >> ${VENDOR_PROP_FILE}
+ echo "ro.lynq_sw_version=${LYNQ_SW_VERSION}" >> ${VENDOR_PROP_FILE}
+ echo "persist.sms.memory.index=${SMS_INDEX}" >> ${VENDOR_PROP_FILE}
+ echo "persist.sms.memory.flag=${SMS_FLAG}" >> ${VENDOR_PROP_FILE}
+
+ echo "###### FO <=> property mapping end ######" >> ${VENDOR_PROP_FILE}
+ echo "" >> ${VENDOR_PROP_FILE}
+ cp -af ${VENDOR_PROP_FILE} ${DEPLOY_DIR_IMAGE}/
+}
+ROOTFS_POSTPROCESS_COMMAND += " gen_feature_property;"
+
+collect_symbol() {
+ echo "BUILD_ID = ${BUILD_ID}"
+ echo "NEED_SYMBOL_FILE = ${NEED_SYMBOL_FILE}"
+ if [ -n "${BUILD_ID}" ] || [ -n "${NEED_SYMBOL_FILE}" ]; then
+ # Create new directory
+ SYMBOL_PATH="${@ d.getVar('DEPLOY_DIR_IMAGE')}/symbol"
+ if [ -d "${SYMBOL_PATH}" ]; then
+ rm -rf $SYMBOL_PATH
+ fi
+ mkdir $SYMBOL_PATH
+ cd $SYMBOL_PATH
+
+ # Extract dbg packages
+ RPM_PATH="${@ d.getVar('DEPLOY_DIR_RPM')}/"
+ for dir in `ls $RPM_PATH`; do
+ echo "dir = $dir"
+ if [ "${dir}" = "aarch64" ]; then
+ continue
+ fi
+
+ for f in `ls ${RPM_PATH}${dir}/*dbg*`; do
+ echo $f | grep iptables && continue
+ echo "$f"
+ rpm2cpio $f | cpio -idm
+ done
+ done
+
+ # Clean .debug/ & remove src/
+ rm -rf usr/src
+ for dir_path in `find . -type d -name '.debug'`; do
+ path=$(dirname ${dir_path})
+ if [ "$(ls -A ${dir_path})" ]; then
+ mv ${dir_path}/* ${path}
+ rm -r ${dir_path}
+ else
+ rm -r ${dir_path}
+ fi
+ done
+
+ # Copy vmlinux
+ cd ${WORKDIR}
+ cp ../../linux-mtk-extension/*/linux-mtk-extension-*/vmlinux ${SYMBOL_PATH}
+ fi
+}
+ROOTFS_POSTPROCESS_COMMAND += " collect_symbol;"
+
+do_squashfs_gen_image(){
+ if ${@bb.utils.contains('IMAGE_FSTYPES','squashfs','true','false',d)}; then
+ simg2img ${DEPLOY_DIR_IMAGE}/system.img ${DEPLOY_DIR_IMAGE}/system_unsparse.img
+ echo \[squashfs\] > ubinize.cfg
+ echo mode=ubi >> ubinize.cfg
+ echo image=${DEPLOY_DIR_IMAGE}/system_unsparse.img >> ubinize.cfg
+ echo vol_id=0 >> ubinize.cfg
+ echo vol_type=static >> ubinize.cfg
+ echo vol_name=rootfs >> ubinize.cfg
+ ubinize -o ${DEPLOY_DIR_IMAGE}/system.ubi ${UBINIZE_ARGS} ubinize.cfg
+ img2simg ${DEPLOY_DIR_IMAGE}/system.ubi ${DEPLOY_DIR_IMAGE}/system.img
+ mv ubinize.cfg ${DEPLOY_DIR_IMAGE}/
+ fi
+}
+addtask squashfs_gen_image after do_avb_sign_img before do_build
+addtask make_otafull_package after do_squashfs_gen_image before do_build
+
+do_mdimg_align_4kb() {
+ if [ -f "${DEPLOY_DIR}/images/${MACHINE}/md1img.img" ]; then
+ python ${DEPLOY_DIR_IMAGE}/align_4kb.py ${DEPLOY_DIR_IMAGE}/md1img.img
+ fi
+}
+addtask mdimg_align_4kb after do_make_otafull_package before do_build
+
+addtask post1 after do_image before do_image_ext4
+addtask post2 after do_post1 before do_image_ext4
+addtask post3 after do_post2 before do_image_ext4
+addtask post4 after do_post3 before do_image_ext4
+