[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-mediatek/recipes-devtools/11acsigma/mtk11acsigma.bb b/meta/meta-mediatek/recipes-devtools/11acsigma/mtk11acsigma.bb
new file mode 100644
index 0000000..093e68e
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/11acsigma/mtk11acsigma.bb
@@ -0,0 +1,8 @@
+DESCRIPTION = "Wi-Fi sigma tool for certification"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=d7810fab7487fb0aad327b76f1be7cd7"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/wifi-sigma/TGac-pmf-sigma"
+
+INSANE_SKIP_${PN} += "ldflags"
diff --git a/meta/meta-mediatek/recipes-devtools/11apsigma/mtk11apsigma.bb b/meta/meta-mediatek/recipes-devtools/11apsigma/mtk11apsigma.bb
new file mode 100644
index 0000000..022a5f9
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/11apsigma/mtk11apsigma.bb
@@ -0,0 +1,8 @@
+DESCRIPTION = "Wi-Fi sigma tool for certification"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/wifi-sigma/AP-TGn-sigma"
+
+INSANE_SKIP_${PN} += "ldflags"
diff --git a/meta/meta-mediatek/recipes-devtools/11nsigma/mtk11nsigma.bb b/meta/meta-mediatek/recipes-devtools/11nsigma/mtk11nsigma.bb
new file mode 100644
index 0000000..d4a1122
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/11nsigma/mtk11nsigma.bb
@@ -0,0 +1,8 @@
+DESCRIPTION = "Wi-Fi sigma tool for certification"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/wifi-sigma/TGn-sigma"
+
+INSANE_SKIP_${PN} += "ldflags"
diff --git a/meta/meta-mediatek/recipes-devtools/aee/aee.bb b/meta/meta-mediatek/recipes-devtools/aee/aee.bb
new file mode 100644
index 0000000..98a881a
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/aee/aee.bb
@@ -0,0 +1,68 @@
+DESCRIPTION = "Mediatek debug tool"

+SECTION = "base"

+LICENSE = "MediaTekProprietary"

+

+AEE_SRC = "${TOPDIR}/../src/devtools/aee"

+

+WORKONSRC = "${AEE_SRC}"

+

+DEPENDS = "zlib libunwind libsncfg platform-libs-header"

+TARGET_CC_ARCH = "-pthread"

+BB_CFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -g"

+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST}"

+BB_INCLUDE_ADD  = "-I${MTK_SRC}/inc \

+                   -I${STAGING_DIR_HOST}  \

+                   -I${STAGING_INCDIR} \

+                   "

+

+inherit deploy workonsrc

+

+#Parameters passed to do_compile

+EXTRA_OEMAKE = "BB_INCLUDE_ADD=${BB_INCLUDE_ADD} \

+                BB_LDFLAGS_ADD=${BB_LDFLAGS_ADD}"

+

+FILES_${PN} = "${libdir}/*.so ${bindir}"

+FILES_${PN}-dev = "${includedir}"

+

+# Avoid QA Issue: No GNU_HASH in the elf binary

+INSANE_SKIP_${PN} = "ldflags"

+

+# Avoid QA Issue: Files/directories were installed but not shipped in any package

+INSANE_SKIP_${PN} += "installed-vs-shipped"

+

+#Skip strip check in QA test.

+INSANE_SKIP_${PN} += "already-stripped"

+

+do_compile () {

+	oe_runmake CFLAGS="${BB_CFLAGS_ADD}" TUNE_FEATURES="${TUNE_FEATURES}"

+}

+

+do_install () {

+	oe_runmake PREFIX="${prefix}" DESTDIR="${D}" PACKAGE_ARCH="${PACKAGE_ARCH}" install

+}

+

+inherit systemd

+SYSTEMD_PACKAGES = "${PN}"

+SYSTEMD_SERVICE_${PN} = "aed.service"

+FILES_${PN} += "${systemd_unitdir}/system/aed.service"

+do_install_append() {

+	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then

+		install -d ${D}${systemd_unitdir}/system

+		if [ -s ${B}/aed.service ] && [ -f ${B}/aed.service ]; then

+			install -m 0644 ${B}/aed.service ${D}${systemd_unitdir}/system

+		fi

+		if [ -s ${B}/lib/systemd/system/aed.service ] && [ -f ${B}/lib/systemd/system/aed.service ]; then

+			install -m 0644 ${B}/lib/systemd/system/aed.service ${D}${systemd_unitdir}/system

+		fi

+	fi

+}

+

+create_misc_mount_point() {

+	install -d ${IMAGE_ROOTFS}/misc

+}

+ROOTFS_PREPROCESS_COMMAND += "create_misc_mount_point;"

+

+addtask bachclean

+do_bachclean () {

+	oe_runmake clean

+}

diff --git a/meta/meta-mediatek/recipes-devtools/clang/clang-cross_git.bbappend b/meta/meta-mediatek/recipes-devtools/clang/clang-cross_git.bbappend
new file mode 100644
index 0000000..4985a5c
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/clang-cross_git.bbappend
@@ -0,0 +1,12 @@
+do_install_append() {
+
+	rm -f ${D}${bindir}/${TARGET_PREFIX}llvm-ar
+	cat > ${D}${bindir}/${TARGET_PREFIX}llvm-ar << 'EOF'
+#!/bin/sh
+basedir=$(dirname "$0")
+"${basedir}/../llvm-ar" "$@"
+exit "$?"
+EOF
+	chmod +x ${D}${bindir}/${TARGET_PREFIX}llvm-ar
+
+}
diff --git a/meta/meta-mediatek/recipes-devtools/clang/compiler-rt_git.bbappend b/meta/meta-mediatek/recipes-devtools/clang/compiler-rt_git.bbappend
new file mode 100644
index 0000000..2733168
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/compiler-rt_git.bbappend
@@ -0,0 +1 @@
+baselib = "lib"
diff --git a/meta/meta-mediatek/recipes-devtools/clang/files/0002-use-gcc_s-instead-unwind.patch b/meta/meta-mediatek/recipes-devtools/clang/files/0002-use-gcc_s-instead-unwind.patch
new file mode 100644
index 0000000..c885d9e
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/files/0002-use-gcc_s-instead-unwind.patch
@@ -0,0 +1,27 @@
+From 10085819b632fecf6b4cd16dbb26f65ac56fa86e Mon Sep 17 00:00:00 2001
+From: Jizhou Deng <jizhou.deng@mediatek.com>
+Date: Fri, 26 Jul 2019 11:33:54 +0800
+Subject: [PATCH] use gcc_s instead unwind
+
+---
+ clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
+index 5f6b24e33eb..cb4854710cb 100644
+--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
++++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
+@@ -1192,9 +1192,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
+   case ToolChain::RLT_CompilerRT:
+     CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
+     CmdArgs.push_back("--as-needed");
+-    CmdArgs.push_back("-l:libunwind.a");
+-    CmdArgs.push_back("-lpthread");
+-    CmdArgs.push_back("-ldl");
++    CmdArgs.push_back("-lgcc_s");
+     CmdArgs.push_back("--no-as-needed");
+ 
+     break;
+-- 
+2.18.0
+
diff --git a/meta/meta-mediatek/recipes-devtools/clang/libcxx_%.bbappend b/meta/meta-mediatek/recipes-devtools/clang/libcxx_%.bbappend
new file mode 100644
index 0000000..2733168
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/libcxx_%.bbappend
@@ -0,0 +1 @@
+baselib = "lib"
diff --git a/meta/meta-mediatek/recipes-devtools/clang/libcxx_git.bbappend b/meta/meta-mediatek/recipes-devtools/clang/libcxx_git.bbappend
new file mode 100644
index 0000000..2975a45
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/libcxx_git.bbappend
@@ -0,0 +1,5 @@
+TARGET_CXXFLAGS_remove_toolchain-clang = "--stdlib=libc++ "
+TUNE_CCARGS_append_toolchain-clang = " -Wl,-lgcc_s "
+PACKAGECONFIG_arm = ""
+PACKAGECONFIG_aarch64 = ""
+ 
diff --git a/meta/meta-mediatek/recipes-devtools/clang/llvm-project-source.bbappend b/meta/meta-mediatek/recipes-devtools/clang/llvm-project-source.bbappend
new file mode 100644
index 0000000..5bf7379
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/clang/llvm-project-source.bbappend
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/files"
+
+SRC_URI_append = " \
+                  file://0002-use-gcc_s-instead-unwind.patch \
+"
+
diff --git a/meta/meta-mediatek/recipes-devtools/cpumem-debug-tool/cpumem-debug-tool.bb b/meta/meta-mediatek/recipes-devtools/cpumem-debug-tool/cpumem-debug-tool.bb
new file mode 100644
index 0000000..705253c
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/cpumem-debug-tool/cpumem-debug-tool.bb
@@ -0,0 +1,18 @@
+DESCRIPTION = "Mediatek cpumem-debug-tool"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://${WORKDIR}/README;md5=ecf62296074513b19f1c6e1ae1bd704a"
+BBCLASSEXTEND += "native"
+APPS_SRC = "${TOPDIR}/../src/devtools/debug-utils"
+
+WORKONSRC = "${APPS_SRC}"
+
+inherit deploy workonsrc
+
+do_deploy () {
+    install -d ${DEPLOYDIR}
+    if [ -f "${S}/Collect_CPU_Mem_info.py" ]; then
+        install -m 755 ${S}/Collect_CPU_Mem_info.py -t ${DEPLOYDIR}
+    fi
+}
+
+addtask deploy before do_build after do_compile
diff --git a/meta/meta-mediatek/recipes-devtools/crypttool/crypttool.bb b/meta/meta-mediatek/recipes-devtools/crypttool/crypttool.bb
new file mode 100644
index 0000000..1cc2b2c
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/crypttool/crypttool.bb
@@ -0,0 +1,31 @@
+inherit deploy workonsrc
+
+DESCRIPTION = "crypt_tool"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+MTK_SRC = "${TOPDIR}/../src/devtools/nfsb/crypt_tool"
+
+WORKONSRC = "${MTK_SRC}"
+
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+INSANE_SKIP_${PN} += "already-stripped"
+
+EXTRA_OEMAKE = "CROSS=${TARGET_PREFIX} OUT=${WORKDIR} ARCH=${KERNEL_ARCH} DM_PROTECT_KEY=${MTK_KEY_DIR}/${DM_PROTECT_ENC_KEY}"
+
+INSANE_SKIP_${PN} = "ldflags"
+INSANE_SKIP_${PN}-dev = "ldflags already-stripped"
+FILES_${PN} = "${bindir}/crypt_target_tool"
+FILES_${PN} += "${bindir}/dmsetup"
+FILES_${PN} += "${libdir}/libdevmapper.so.1.02"
+
+DEPENDS += " tzapp "
+
+do_compile () {
+        oe_runmake all
+}
+
+do_install () {
+    oe_runmake install DESTDIR="${D}"
+}
+
+
diff --git a/meta/meta-mediatek/recipes-devtools/factory/factory.bb b/meta/meta-mediatek/recipes-devtools/factory/factory.bb
new file mode 100644
index 0000000..e11b2e7
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/factory/factory.bb
@@ -0,0 +1,24 @@
+DESCRIPTION = "factory is a tool to test driver function"

+inherit workonsrc

+WORKONSRC = "${TOPDIR}/../src/devtools/factory/factory"

+LICENSE = "MediaTekProprietary"

+#LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"

+

+do_compile() {

+    if [ -d "${TOPDIR}/../src/devtools/factory/${TARGET_PLATFORM}/${MTK_PROJECT}" ]; then

+        oe_runmake FACTORY_CUSTOM="${TOPDIR}/../src/devtools/factory/${TARGET_PLATFORM}/${MTK_PROJECT}"

+    else

+        oe_runmake FACTORY_CUSTOM="${TOPDIR}/../src/devtools/factory/factory/common"

+    fi

+}

+

+do_install() {

+    install -d ${D}${bindir}

+    install -m 0755 ${S}/factory ${D}${bindir}

+    install -d ${D}/etc

+    if [ -d "${TOPDIR}/../src/devtools/factory/${TARGET_PLATFORM}/${MTK_PROJECT}" ]; then

+        install -m 0755 "${TOPDIR}/../src/devtools/factory/${TARGET_PLATFORM}/${MTK_PROJECT}"/factory.ini ${D}/etc/

+    else

+        install -m 0755 "${TOPDIR}/../src/devtools/factory/factory/common"/factory.ini ${D}/etc/

+    fi

+}

diff --git a/meta/meta-mediatek/recipes-devtools/flashtool/flashtool.bb b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool.bb
new file mode 100644
index 0000000..8e20452
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool.bb
@@ -0,0 +1,15 @@
+DESCRIPTION = "Mediatek FlashScript"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://${WORKDIR}/README;md5=ecf62296074513b19f1c6e1ae1bd704a"
+SRC_URI = "file://README file://flashimage.py file://flashimage_NoEnforce.py"
+BBCLASSEXTEND += "native"
+
+inherit deploy
+
+do_deploy () {
+	install -d ${DEPLOYDIR}
+	install -m 755 ${WORKDIR}/flashimage.py -t ${DEPLOYDIR}
+	install -m 755 ${WORKDIR}/flashimage_NoEnforce.py -t ${DEPLOYDIR}
+}
+
+addtask deploy before do_build after do_compile
diff --git a/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/README b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/README
new file mode 100644
index 0000000..cf13d27
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/README
@@ -0,0 +1 @@
+flashimage.py -h to get information
diff --git a/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage.py b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage.py
new file mode 100644
index 0000000..6e0d6f3
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage.py
@@ -0,0 +1,428 @@
+from __future__ import print_function

+

+

+import sys

+import platform

+import os

+import os.path

+import time

+import re

+import argparse

+import subprocess

+

+try:

+    input = raw_input

+except NameError:

+    pass

+

+arguments = None

+fastboot_name = "fastboot"

+fbtool_name = "fbtool.py"

+prod_out_path = os.path.abspath(".")

+

+

+def initialize_env():

+    global fastboot_name

+

+    # check python version

+    if sys.version_info[:2] == (2, 7) or sys.version_info[:2][0] == 3:

+        pass

+    else:

+        print("Python 2.7.x / Python 3.x.x required")

+        exit(1)

+

+    # set fastboot

+    if "Windows" in platform.system():

+        fastboot_name += ".exe"

+    elif "CYGWIN" in platform.system():

+        fastboot_name += ".exe"

+    elif "Linux" in platform.system():

+        if "arm" in platform.machine():

+            fastboot_name += "-linux-arm"

+        elif "aarch64" in platform.machine():

+            fastboot_name += "-linux-arm"

+        elif "x86_64" in platform.machine():

+            fastboot_name += "-linux-x86_64"

+    elif "Darwin" in platform.system():

+        fastboot_name += "-darwin"

+

+

+def set_arguments():

+    global arguments

+

+    parser = argparse.ArgumentParser(

+        description='''

+Auto device flasher, Python 2.7.x / Python 3.x.x required

+''',

+        formatter_class=argparse.RawTextHelpFormatter)

+

+    parser.add_argument("--productdir", default=None,

+                        help='''

+The product out dir is where to find images.

+The Following is the path priority order:

+    1. --productdir specified

+    2. current directory

+''')

+

+    parser.add_argument("--toolsdir", default=None,

+                        help='''

+The tools dir is where to find fbtool and fastboot.

+The Following is the path priority order:

+    1. --toolsdir specified

+    2. current directory

+    3. $PATH

+''')

+

+    parser.add_argument("partition", nargs="?", default="all",

+                        help="partition to flash (default: all) \

+                        , not include the test partition")

+

+    parser.add_argument("-b", "--boot", action="store_true", default=False,

+                        help="Flash boot partition")

+

+    parser.add_argument("-d", "--dryrun", action="store_true", default=False,

+                        help="No image would be flashed, for debug")

+

+    parser.add_argument("-s", "--userdefined",

+                        action="store_true", default=False,

+                        help="Flash user-defined partitions \

+                        and run user-defined actions")

+

+    parser.add_argument("-t", "--test", action="store_true", default=False,

+                        help="Flash test partition")

+

+    parser.add_argument("-u", "--user", action="store_true", default=False,

+                        help="Flash user data partition")

+

+    parser.add_argument("-v", "--verbose", action="store_true", default=False,

+                        help="print more information")

+

+    arguments = parser.parse_args()

+

+

+def show_info(case):

+    def print_platform():

+        print("".center(60, "="))

+        print("")

+        print(("Running flasher on " + platform.platform()).center(60))

+        print("")

+        print("".center(60, "="))

+

+    def print_imagepath():

+        global prod_out_path

+        print("".center(60, "="))

+        print("= flash images under:".ljust(58), "=")

+        print("=    ", prod_out_path.ljust(52), "=")

+        print("".center(60, "="))

+

+    def print_success():

+        if platform.system() == "Windows":

+            input("Success! press enter to exit: ")

+        else:

+            print("Success!")

+

+    def print_default():

+        print("No information about %s." % case)

+

+    information = {

+        "platform": print_platform,

+        "imagepath": print_imagepath,

+        "success": print_success

+    }

+

+    information.get(case, print_default)()

+

+

+def check_flash_tools():

+    global arguments, fbtool_name, fastboot_name

+    toolsdir = ""

+    if arguments.toolsdir:

+        try:

+            toolsdir = os.path.abspath(arguments.toolsdir)

+            fastboot_name = os.path.join(toolsdir, fastboot_name)

+            fbtool_name = os.path.join(toolsdir, fbtool_name)

+            if not os.path.exists(fbtool_name):

+                raise Exception("Cannot find " + str(fbtool_name) + " in \

+                " + str(toolsdir))

+            if not os.path.exists(fastboot_name):

+                raise Exception("Cannot find " + str(fastboot_name) + " in \

+                " + str(toolsdir))

+        except Exception as err:

+            print(str(err))

+            exit(1)

+    else:

+        toolsdir = os.path.abspath(".")

+        if os.path.exists(os.path.join(toolsdir, fbtool_name)):

+            if os.path.exists(os.path.join(toolsdir, fastboot_name)):

+                fastboot_name = os.path.join(toolsdir, fastboot_name)

+                fbtool_name = os.path.join(toolsdir, fbtool_name)

+

+

+def get_flashprocs():

+    global arguments

+    devProduct = "DEFAULT"

+

+    try:

+        from flashproc import getFlashProc

+    except ImportError as err:

+        print("ImportError: ", err)

+        exit(1)

+

+    flashprocs = getFlashProc(devProduct)

+

+    if arguments.userdefined:

+        try:

+            from flashproc import getFlashUserdefinedProc

+            flashprocs = getFlashUserdefinedProc(devProduct)

+        except:

+            flashprocs = getFlashProc(devProduct)

+

+    if arguments.user:

+        try:

+            from flashproc import getFlashUserProc

+            flashprocs = getFlashUserProc(devProduct)

+        except:

+            flashprocs = getFlashProc(devProduct)

+

+    if arguments.boot:

+        try:

+            from flashproc import getFlashBootProc

+            flashprocs = getFlashBootProc(devProduct)

+        except:

+            flashprocs = getFlashProc(devProduct)

+

+    if arguments.test:

+        try:

+            from flashproc import getFlashTestProc

+            flashprocs = getFlashTestProc(devProduct)

+        except:

+            flashprocs = getFlashProc(devProduct)

+

+    if flashprocs is None:

+        print("Cannot retrieve flash procedure according \

+        to product type of", devProduct)

+        print("Terminate program !")

+        exit(1)

+

+    if arguments.verbose:

+        print("Flash procedure".center(60))

+        print("".center(60, "-"))

+        for p in flashprocs:

+            print("fastboot", " ".join(p))

+

+    return flashprocs

+

+

+def get_img_list():

+    flashprocs = get_flashprocs()

+    imgs = []

+    try:

+        for proc in flashprocs:

+            if proc[0] == "fastboot":

+                if proc[1] == "flash":

+                    if proc[3] not in imgs:

+                        imgs.append(proc[3])

+    except Exception as err:

+        print(err)

+    return imgs

+

+

+def check_img(filename, _needreboot=True, _showdetail=False):

+    global fastboot_name, prod_out_path

+    if _showdetail:

+        print((filename).rjust(28), ": ", end="")

+    path = os.path.join(prod_out_path, filename)

+    if os.path.exists(path):

+        if _showdetail:

+            print("PASS!")

+        return path

+    if _needreboot:

+        print("FAIL!\n Rebooting...")

+        call([fastboot_name, "reboot"])

+        exit(1)

+    return None

+

+

+def call(cmd):

+    global arguments

+    if arguments.verbose:

+        print("call:", " ".join(cmd))

+    return subprocess.call(cmd)

+

+

+def check_output(cmd):

+    global arguments

+    if arguments.verbose:

+        print("check_output:", " ".join(cmd))

+    return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)

+

+

+def check_img_path():

+    global arguments, prod_out_path

+    if arguments.productdir:

+        prod_out_path = os.path.abspath(arguments.productdir)

+    else:

+        prod_out_path = os.path.abspath(".")

+        for img in get_img_list():

+            if check_img(img, _needreboot=False, _showdetail=False) is None:

+                prod_out_path = None

+                break

+        if prod_out_path is None:

+            prod_out_path = os.getenv("PRODUCT_OUT", ".")

+    prod_out_path = os.path.abspath(prod_out_path)

+

+

+def da_mode_wait(wait_secs=30):

+    global fbtool_name

+    print("\nWaiting for DA mode:")

+    ret_code = None

+    for i in range(wait_secs):

+        time.sleep(1)

+        print("# ", end="")

+        sys.stdout.flush()

+        ret_code = check_output("python %s " % fbtool_name)

+        if ret_code is not None and len(ret_code) != 0:

+            print("datool - device detected: ")

+            break

+    if ret_code is None:

+        print("No device detected.")

+        print("Please ensure that datool is running.\n")

+        exit(1)

+

+

+def fastboot_wait(wait_secs=30):

+    global fastboot_name

+    print("\nWaiting for fastboot mode:")

+    ret_code = None

+    for i in range(wait_secs):

+        time.sleep(1)

+        print("# ", end="")

+        sys.stdout.flush()

+        ret_code = check_output("%s devices" % fastboot_name).decode()

+        if ret_code is not None and len(ret_code) != 0:

+            print("Fastboot - device detected: ", (ret_code.split())[0])

+            break

+    if ret_code is None:

+        print("No device detected. ")

+        exit(1)

+

+

+def command_reboot(_tobootloader=True):

+    global fastboot_name

+    if _tobootloader:

+        call([fastboot_name, "reboot-bootloader"])

+        fastboot_wait()

+    else:

+        call([fastboot_name, "reboot"])

+

+

+def reboot_device():

+    time.sleep(3)

+    command_reboot(_tobootloader=False)

+

+

+def check_all_imgs():

+    images = get_img_list()

+    print("".center(60, "-"))

+    print("Checking image".center(60))

+    print("".center(60, "-"))

+    try:

+        for img in images:

+            check_img(img, _needreboot=True, _showdetail=True)

+    except Exception as err:

+        print(err)

+        time.sleep(3)

+        command_reboot(_tobootloader=False)

+        input("Fail, press enter to exit: ")

+        exit(1)

+

+

+def reboot_bootloader(tries=3):

+    check_output("adb devices")

+

+    for i in range(tries):

+        print(". ", end="")

+        time.sleep(2)

+        sys.stdout.flush()

+        try:

+            device_id = check_output("adb get-serialno")

+        except subprocess.CalledProcessError as err:

+            print("command '{}' return with error (code {}): {}".format(

+                err.cmd, err.returncode, err.output))

+            continue

+        print("\nAdb - device detected: ", (device_id.split())[0])

+        check_output("adb -s %s reboot bootloader" % (device_id.split())[0])

+        return

+

+    print("adb is not ready!")

+    print("Please check whether the usb cable is plugged or adb is supported.")

+    exit(1)

+

+

+def command_run(cmd, dryrun=False):

+    ret_code = 1

+    raw_cmd = []

+    if cmd[0] == "fastboot":

+        cmd[0] = fastboot_name

+        if cmd[1] == "flash":

+            path = check_img(cmd[3], _needreboot=False, _showdetail=False)

+            if path is not None:

+                if "CYGWIN" in platform.system():

+                    p = subprocess.check_output(

+                        "cygpath --absolute --mixed %s" % path, shell=True)

+                    if p:

+                        path = p.strip()

+                raw_cmd += [cmd[0], cmd[1], cmd[2], path]

+        else:

+            raw_cmd += cmd

+    elif cmd[0] == "fbWait":

+        fastboot_wait()

+        return 0

+    elif cmd[0] == "daWait":

+        da_mode_wait()

+        return 0

+    elif cmd[0] == "reboottobl":

+        reboot_bootloader()

+        return 0

+    else:

+        print("FAIL: Unknown command!\n")

+        return -1

+

+    if dryrun:

+        print(" ".join(raw_cmd))

+        ret_code = 0

+    else:

+        ret_code = call(raw_cmd)

+        if ret_code == 0:

+            if cmd[0] == "fastboot":

+                if cmd[1] == "reboot-bootloader":

+                    fastboot_wait()

+    return ret_code

+

+

+def flash_imgs():

+    print("\nStart flashing".center(60))

+    print("".center(60, "-"))

+    try:

+        for p in get_flashprocs():

+            if command_run(p, arguments.dryrun) != 0:

+                raise Exception("<FAILED> %s" % " ".join(proc))

+    except Exception as err:

+        print(err)

+        time.sleep(3)

+        command_reboot(_tobootloader=False)

+        exit(1)

+

+

+if __name__ == "__main__":

+    initialize_env()

+    set_arguments()

+    show_info("platform")

+    check_flash_tools()

+    check_img_path()

+    show_info("imagepath")

+    check_all_imgs()

+    flash_imgs()

+    reboot_device()

+    show_info("success")

+    exit(0)

diff --git a/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage_NoEnforce.py b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage_NoEnforce.py
new file mode 100644
index 0000000..980228b
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/flashtool/flashtool/flashimage_NoEnforce.py
@@ -0,0 +1,333 @@
+#!/usr/bin/python
+
+import os
+import os.path
+import sys
+import platform
+import argparse
+import subprocess
+import time
+import re
+import string
+
+################################################################################
+# check python version
+if sys.version_info[:2] == (2,7):
+    pass
+else:
+    print 'Please install Python 2.7.x to run this script'
+    exit(1)
+################################################################################
+
+verbose = False
+skipFlash = False
+
+fbtool = 'fbtool.py'
+fastboot = 'fastboot'
+adb = 'adb'
+
+system = platform.system()
+machine = platform.machine()
+product_out = os.path.abspath('.')
+
+if 'Windows' in system or 'CYGWIN' in system:
+    adb += '.exe'
+    fastboot += '.exe'
+elif 'Linux' in system:
+    if 'x86_64' in machine:
+        adb += '-linux-x86_64'
+        fastboot += '-linux-x86_64'
+    elif 'arm' in machine or 'aarch64' in machine:
+        adb += '-linux-arm'
+        fastboot += '-linux-arm'
+elif 'Darwin' in system:
+    adb += '-darwin'
+    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, e:
+        print e
+    return imgs
+
+def call(cmd):
+    '''cmd: the command list for subprocess.call'''
+    if verbose:
+        print 'call:', ' '.join(cmd)
+    return subprocess.call(cmd)
+
+def check_output(cmd):
+    '''cmd: the command list for subprocess.check_output'''
+    if verbose:
+        print 'check_output:', ' '.join(cmd)
+    return subprocess.check_output(cmd, stderr = subprocess.STDOUT, shell=True)
+
+def checkImage(filename, needreboot = True, _verbose = False):
+    if _verbose:
+        print (filename).rjust(38),':',
+    filepath = os.path.join(product_out, filename)
+    if os.path.exists(filepath):
+        if _verbose:
+            print 'PASS'
+        return filepath
+    if needreboot:
+        print 'FAIL'
+        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, shell=True)
+                    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)
+        if ret == 0 and cmd[0] == 'fastboot' and cmd[1] == 'reboot-bootloader' and not dryrun:
+            fbWait()
+    return ret
+
+def daWait(secs = 60):
+    print 'adb devices'
+    ret = None
+    adb_found = 0
+    for i in range(secs):
+        print '.',
+        sys.stdout.flush()
+        time.sleep(1)
+        ret = check_output('%s devices' % adb)
+        if ret != None and len(ret) > 29 :
+            print ''
+            print 'Adb - device detected: ', (ret.split())[4]
+            print ret
+            adb_found = 1
+            break
+    if adb_found:
+        print 'rebooting to bootloader'
+        check_output('%s reboot bootloader' % adb)
+    else:
+        print 'adb is not ready, please make sure your device is cable-in, and check your device status!'
+        exit(1)
+
+
+def fbWait(secs = 60):
+    print 'Waiting for fastboot mode'
+    ret = None
+    for i in range(secs):
+        print '.',
+        sys.stdout.flush()
+        time.sleep(1)
+        ret = check_output('%s devices' % fastboot)
+        if ret != None and len(ret) != 0:
+            print ''
+            print 'Fastboot - device detected: ', (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'])
+
+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('--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 ''
+
+    try:
+        from flashproc import getFlashProc
+    except ImportError, 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, 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(78), '*'
+    print '*    ', product_out.ljust(72), '*'
+    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, e:
+        print e
+        time.sleep(2)
+        cmdReboot(False)
+        raw_input('Fail, press enter to exit: ')
+        exit(1)
+
+    # 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, e:
+        print e
+        time.sleep(2)
+        cmdReboot(False)
+        exit(1)
+
+    time.sleep(2)
+    cmdReboot(False)
+    print ''
+    if system == "Windows":
+        raw_input('Success, press enter to exit: ')
+    else:
+        print 'Success'
diff --git a/meta/meta-mediatek/recipes-devtools/iputilssigma/mtkiputilssigma.bb b/meta/meta-mediatek/recipes-devtools/iputilssigma/mtkiputilssigma.bb
new file mode 100644
index 0000000..9683a6d
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/iputilssigma/mtkiputilssigma.bb
@@ -0,0 +1,8 @@
+DESCRIPTION = "Utilities for the IP protocol, including traceroute6, \
+tracepath, tracepath6, ping, ping6 and arping."
+LICENSE = "BSD & GPLv2+"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/wifi-sigma/iputils-sigma"
+
diff --git a/meta/meta-mediatek/recipes-devtools/m4/m4/fix-absolute-include.patch b/meta/meta-mediatek/recipes-devtools/m4/m4/fix-absolute-include.patch
new file mode 100755
index 0000000..9301378
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/m4/m4/fix-absolute-include.patch
@@ -0,0 +1,99 @@
+diff --git a/lib/stat_.h b/lib/stat_.h
+index cbf5ac0..243b4c0 100644
+--- a/lib/stat_.h
++++ b/lib/stat_.h
+@@ -23,7 +23,7 @@
+ /* This file is supposed to be used on platforms where <sys/stat.h> is
+    incomplete.  It is intended to provide definitions and prototypes
+    needed by an application.  Start with what the system provides.  */
+-#include @ABSOLUTE_SYS_STAT_H@
++#include_next <sys/stat.h>
+ 
+ #ifndef S_IFMT
+ # define S_IFMT 0170000
+diff --git a/lib/stdint_.h b/lib/stdint_.h
+index 4fa5251..788a980 100644
+--- a/lib/stdint_.h
++++ b/lib/stdint_.h
+@@ -43,7 +43,7 @@
+      Include it before <inttypes.h>, since any "#include <stdint.h>"
+      in <inttypes.h> would reinclude us, skipping our contents because
+      _GL_STDINT_H is defined.  */
+-# include @ABSOLUTE_STDINT_H@
++# include_next <stdint.h>
+ #endif
+ 
+ /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
+diff --git a/lib/stdlib_.h b/lib/stdlib_.h
+index a920408..dc33b29 100644
+--- a/lib/stdlib_.h
++++ b/lib/stdlib_.h
+@@ -26,7 +26,7 @@
+ # pragma GCC system_header
+ #endif
+ 
+-#include @ABSOLUTE_STDLIB_H@
++#include_next <stdlib.h>
+ 
+ #else
+ /* Normal invocation convention.  */
+@@ -40,7 +40,7 @@
+ # pragma GCC system_header
+ #endif
+ 
+-#include @ABSOLUTE_STDLIB_H@
++#include_next <stdlib.h>
+ 
+ 
+ /* The definition of GL_LINK_WARNING is copied here.  */
+diff --git a/lib/sys_time_.h b/lib/sys_time_.h
+index 46cdb70..f98de57 100644
+--- a/lib/sys_time_.h
++++ b/lib/sys_time_.h
+@@ -22,7 +22,7 @@
+ #define _gl_SYS_TIME_H
+ 
+ #if @HAVE_SYS_TIME_H@
+-# include @ABSOLUTE_SYS_TIME_H@
++# include_next <sys/time.h>
+ #else
+ # include <time.h>
+ #endif
+diff --git a/lib/unistd_.h b/lib/unistd_.h
+index 77df861..9241475 100644
+--- a/lib/unistd_.h
++++ b/lib/unistd_.h
+@@ -19,7 +19,7 @@
+ #define _GL_UNISTD_H
+ 
+ #if @HAVE_UNISTD_H@
+-# include @ABSOLUTE_UNISTD_H@
++# include_next <unistd.h>
+ #endif
+ 
+ 
+diff --git a/lib/wchar_.h b/lib/wchar_.h
+index 6813a21..bd86ce4 100644
+--- a/lib/wchar_.h
++++ b/lib/wchar_.h
+@@ -37,6 +37,6 @@
+ #include <time.h>
+ 
+ /* Include the original <wchar.h>.  */
+-#include @ABSOLUTE_WCHAR_H@
++#include_next <wchar.h>
+ 
+ #endif /* _GL_WCHAR_H */
+diff --git a/lib/wctype_.h b/lib/wctype_.h
+index 1297c61..fca78cd 100644
+--- a/lib/wctype_.h
++++ b/lib/wctype_.h
+@@ -47,7 +47,7 @@ typedef int __wctype_wint_t;
+ /* Include the original <wctype.h> if it exists.
+    BeOS 5 has the functions but no <wctype.h>.  */
+ #if @HAVE_WCTYPE_H@
+-# include @ABSOLUTE_WCTYPE_H@
++# include_next <wctype.h>
+ #endif
+ 
+ /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
diff --git a/meta/meta-mediatek/recipes-devtools/m4/m4_1.4.9.bbappend b/meta/meta-mediatek/recipes-devtools/m4/m4_1.4.9.bbappend
new file mode 100644
index 0000000..870f92d
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/m4/m4_1.4.9.bbappend
@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_toolchain-clang = " file://fix-absolute-include.patch"
+SRC_URI_remove_toolchain-clang = " file://disable_builtin_mul_overflow.patch"
diff --git a/meta/meta-mediatek/recipes-devtools/met/met-driver-internal.bb b/meta/meta-mediatek/recipes-devtools/met/met-driver-internal.bb
new file mode 100644
index 0000000..91763bd
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/met/met-driver-internal.bb
@@ -0,0 +1,49 @@
+DESCRIPTION = "MET-DRIVER-INTERNAL"
+LICENSE = "MediaTekProprietary"
+DEPENDS = "linux-mtk-extension"
+DEPENDS += "met-driver"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/met-driver-internal"
+export LINUX_VERSION = "${@[d.getVar('TUNE_PKGARCH'), d.getVar('PREFERRED_VERSION_linux-mtk-extension')][bool(d.getVar('PREFERRED_VERSION_linux-mtk-extension'))].replace('%', '')}"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+PRJ_DISTRO = "${@bb.utils.contains("DISTRO", "poky-agl", "agl", "poky", d)}"
+
+export KERNEL_SRC = "${TOPDIR}/../src/kernel/linux/v${LINUX_VERSION}"
+export KERNEL_OUT = "${TOPDIR}/tmp/work/${MACHINE_ARCH}-${PRJ_DISTRO}-${TARGET_OS}/${PREFERRED_PROVIDER_virtual/kernel}/${LINUX_VERSION}-${PR}/${PREFERRED_PROVIDER_virtual/kernel}-${LINUX_VERSION}/"
+export MET_DRIVER_INTERNAL_DIR = "${S}/${LINUX_VERSION}"
+#export KBUILD_EXTRA_SYMBOLS= "${TOPDIR}/../src/devtools/met-driver/${LINUX_VERSION}/Module.symvers"
+export CONFIG_MTK_PLATFORM = "${TARGET_PLATFORM}"
+export CONFIG_MET = "m"
+export CONFIG_MET_PLF = "m"
+export CONFIG_BUILD_YOCTO = "y"
+TOOLCHAIN = "gcc"
+
+do_compile() {
+	if [ -d "${MET_DRIVER_INTERNAL_DIR}" ]; then
+		if test "${TARGET_PLATFORM}" != ""; then
+			echo ${TARGET_PLATFORM} met driver internal start compile
+
+			if test "${KERNEL_ARCH}" = "arm64"; then
+				oe_runmake -f ${LINUX_VERSION}/Makefile.yocto TOPDIR=${TOPDIR} ARCH=arm64 CROSS_COMPILE=aarch64-${PRJ_DISTRO}-linux-
+			else
+				oe_runmake -f ${LINUX_VERSION}/Makefile.yocto TOPDIR=${TOPDIR} ARCH=arm CROSS_COMPILE=arm-${PRJ_DISTRO}-linux-gnueabi-
+			fi
+
+			echo ${TARGET_PLATFORM} met driver internal end compile
+		fi
+	fi
+}
+
+do_install() {
+	install -d ${D}/vendor/lib/modules
+	if [ -d "${MET_DRIVER_INTERNAL_DIR}" ]; then
+		install -m 0644 ${MET_DRIVER_INTERNAL_DIR}/met_plf.ko ${D}/vendor/lib/modules
+	fi
+}
+
+# Avoid QA Issue: No GNU_HASH in the elf binary
+PN='met-driver-internal'
+INSANE_SKIP_${PN} = "ldflags"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN} += "/vendor/lib/modules"
diff --git a/meta/meta-mediatek/recipes-devtools/met/met-driver.bb b/meta/meta-mediatek/recipes-devtools/met/met-driver.bb
new file mode 100644
index 0000000..30addcc
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/met/met-driver.bb
@@ -0,0 +1,54 @@
+DESCRIPTION = "MET-DRIVER"
+LICENSE = "GPL-2.0"
+DEPENDS = "linux-mtk-extension"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/met-driver"
+LINUX_VERSION = "${@[d.getVar('TUNE_PKGARCH'), d.getVar('PREFERRED_VERSION_linux-mtk-extension')][bool(d.getVar('PREFERRED_VERSION_linux-mtk-extension'))].replace('%', '')}"
+LDFLAGS = "-L ${RECIPE_SYSROOT}"
+PRJ_DISTRO = "${@bb.utils.contains("DISTRO", "poky-agl", "agl", "poky", d)}"
+
+export KERNEL_SRC = "${TOPDIR}/../src/kernel/linux/v${LINUX_VERSION}"
+export KERNEL_OUT = "${TOPDIR}/tmp/work/${MACHINE_ARCH}-${PRJ_DISTRO}-${TARGET_OS}/${PREFERRED_PROVIDER_virtual/kernel}/${LINUX_VERSION}-${PR}/${PREFERRED_PROVIDER_virtual/kernel}-${LINUX_VERSION}/"
+export MET_DRIVER_DIR = "${S}/${LINUX_VERSION}"
+export CONFIG_MTK_PLATFORM = "${TARGET_PLATFORM}"
+export CONFIG_MTK_MET = "m"
+export CONFIG_BUILD_YOCTO = "y"
+TOOLCHAIN = "gcc"
+
+do_compile() {
+	if [ -d "${MET_DRIVER_DIR}" ]; then
+		if test "${TARGET_PLATFORM}" != ""; then
+			echo ${TARGET_PLATFORM} met driver start compile
+
+			# for different kerenl src path naming
+			if test "${KERNELDIR}" != ""; then
+				if test "${TARGET_PLATFORM}" = "mt8183"; then
+					export KERNEL_SRC="${TOPDIR}/../src/kernel/linux/${KERNELDIR}"
+				fi
+			fi
+
+			if test "${KERNEL_ARCH}" = "arm64"; then
+				oe_runmake -f ${LINUX_VERSION}/Makefile.yocto TOPDIR=${TOPDIR} ARCH=arm64 CROSS_COMPILE=aarch64-${PRJ_DISTRO}-linux-
+			else
+				oe_runmake -f ${LINUX_VERSION}/Makefile.yocto TOPDIR=${TOPDIR} ARCH=arm CROSS_COMPILE=arm-${PRJ_DISTRO}-linux-gnueabi-
+			fi
+
+			echo ${TARGET_PLATFORM} met driver end compile
+		fi
+	fi
+}
+
+do_install() {
+	install -d ${D}/vendor/lib/modules
+	if [ -d "${MET_DRIVER_DIR}" ]; then
+		install -m 0644 ${MET_DRIVER_DIR}/met.ko ${D}/vendor/lib/modules
+	fi
+}
+
+# Avoid QA Issue: No GNU_HASH in the elf binary
+PN='met-driver'
+INSANE_SKIP_${PN} = "ldflags"
+INSANE_SKIP_${PN} += "already-stripped"
+FILES_${PN} += "/vendor/lib/modules"
+
diff --git a/meta/meta-mediatek/recipes-devtools/met/met-utils.bb b/meta/meta-mediatek/recipes-devtools/met/met-utils.bb
new file mode 100644
index 0000000..6ceacb1
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/met/met-utils.bb
@@ -0,0 +1,35 @@
+DESCRIPTION = "MET-UTILS"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b415b1f2e589c23040ce1f39702002e6"
+
+inherit get_toolchain_name
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/met-utils"
+export CONFIG_MTK_PLATFORM = "${TARGET_PLATFORM}"
+#TOOLCHAIN = "gcc"
+
+export EXTRA_CFLAGS += "-Wl,--hash-style=gnu"
+
+do_compile() {
+	if [ -d "${WORKONSRC}" ]; then
+		echo ${TARGET_PLATFORM} met-utils start compile
+
+		if test "${KERNEL_ARCH}" = "arm64"; then
+			oe_runmake -f ${WORKONSRC}/Makefile TOPDIR=${TOPDIR} ARCH=arm64 CROSS_COMPILE=aarch64-poky-linux- TOOLCHAIN_NAME=${TOOLCHAIN_NAME}
+		else
+			oe_runmake -f ${WORKONSRC}/Makefile TOPDIR=${TOPDIR} ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- TOOLCHAIN_NAME=${TOOLCHAIN_NAME}
+		fi
+
+		echo ${TARGET_PLATFORM} met-utils end compile
+	fi
+}
+
+do_install() {
+	oe_runmake \
+		PREFIX="${prefix}" DESTDIR="${D}" PACKAGE_ARCH="${PACKAGE_ARCH}" install
+}
+
+# Avoid QA Issue: No GNU_HASH in the elf binary
+PN='met-utils'
+INSANE_SKIP_${PN} += "already-stripped"
+
diff --git a/meta/meta-mediatek/recipes-devtools/mrdump/mrdump.bb b/meta/meta-mediatek/recipes-devtools/mrdump/mrdump.bb
new file mode 100644
index 0000000..0d4aaa2
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/mrdump/mrdump.bb
@@ -0,0 +1,36 @@
+DESCRIPTION = "Mediatek MRDUMP application"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+
+MRDUMP_SRC = "${TOPDIR}/../src/devtools/mrdump"
+
+WORKONSRC = "${MRDUMP_SRC}"
+
+DEPENDS = "zlib"
+LDFLAGS = "-lz"
+TARGET_CC_ARCH += "${LDFLAGS}"
+# BB_CFLAGS_ADD
+BB_LDFLAGS_ADD = "-lz"
+BB_INCLUDE_ADD  = "-I${MRDUMP_SRC}"
+
+inherit deploy workonsrc
+
+FILES_${PN} = "${libdir}/*.so ${bindir}"
+FILES_${PN}-dev = "${includedir}"
+
+# Avoid QA Issue: No GNU_HASH in the elf binary
+INSANE_SKIP_${PN} = "ldflags"
+
+# Avoid QA Issue: Files/directories were installed but not shipped in any package
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+do_compile() {
+	oe_runmake \
+		PACKAGE_ARCH="${PACKAGE_ARCH}"  \
+		CFLAGS="${CFLAGS}" \
+		LDFLAGS="${LDFLAGS}"
+}
+
+do_install() {
+	oe_runmake install PREFIX="${prefix}" DESTDIR="${D}"
+}
diff --git a/meta/meta-mediatek/recipes-devtools/nfsbmount/nfsbmount.bb b/meta/meta-mediatek/recipes-devtools/nfsbmount/nfsbmount.bb
new file mode 100644
index 0000000..8227821
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/nfsbmount/nfsbmount.bb
@@ -0,0 +1,36 @@
+inherit deploy workonsrc
+
+DESCRIPTION = "nfsb_mount"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+MTK_SRC = "${TOPDIR}/../src/devtools/nfsb/nfsb_mount"
+
+WORKONSRC = "${MTK_SRC}"
+
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+INSANE_SKIP_${PN} += "already-stripped"
+
+EXTRA_OEMAKE = "CROSS=${TARGET_PREFIX} OUT=${WORKDIR} ARCH=${KERNEL_ARCH}"
+
+INSANE_SKIP_${PN} = "ldflags"
+INSANE_SKIP_${PN}-dev = "ldflags already-stripped"
+FILES_${PN} = "${bindir}/nfsb_mount"
+
+DEPENDS += " openssl openssl-native"
+
+do_compile () {
+	IMG_KEY_FILE=""
+	if [ "${ROOTFS_VERITY_KEY}" = "" ]; then
+		IMG_KEY_FILE="${MTK_KEY_DIR}/${VERIFIED_KEY}.pem"
+	else
+		IMG_KEY_FILE="${MTK_KEY_DIR}/${ROOTFS_VERITY_KEY}.pem"
+	fi
+	python ${MTK_SRC}/pretreat-key.py ${IMG_KEY_FILE} ${WORKDIR}/nfsbmount-${PV}/
+        oe_runmake all
+}
+
+do_install () {
+    oe_runmake install DESTDIR="${D}"
+}
+
+
diff --git a/meta/meta-mediatek/recipes-devtools/sp_meta/sp-meta_1.0.0.bb b/meta/meta-mediatek/recipes-devtools/sp_meta/sp-meta_1.0.0.bb
new file mode 100644
index 0000000..78eb4d2
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/sp_meta/sp-meta_1.0.0.bb
@@ -0,0 +1,85 @@
+#Basic Configuration
+DESCRIPTION = "spmeta"
+SECTION = "base"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+MTK_SRC = "${TOPDIR}/../src/devtools/sp_meta"
+SP_PREFIX = "${STAGING_INCDIR}/install"
+LINUX_KERNEL = "linux-4.4"
+
+WORKONSRC = "${MTK_SRC}"
+BB_CFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -g"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST}"
+
+BB_INCLUDE_ADD  = "-I${MTK_SRC}/common/inc \
+                   -I${STAGING_DIR_HOST}  \
+                   -I${STAGING_INCDIR} \
+                   "
+
+inherit deploy workonsrc
+
+#Parameters passed to do_compile()
+
+
+EXTRA_OEMAKE = "CROSS=${TARGET_PREFIX} \
+                PREFIX=${SP_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}-doc = "/doc"
+
+FILES_${PN}-dbg = "/usr/src/debug \
+                   ${base_bindir}/.debug \
+                   ${base_libdir}/.debug \
+                   ${base_sbindir}/.debug"
+
+#Skip strip check in QA test.
+INSANE_SKIP_${PN} += "already-stripped"
+
+
+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} -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
+}
+inherit systemd
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "keymonitor.service"
+FILES_${PN} += "${systemd_unitdir}/system/keymonitor.service"
+do_install_append(){
+    if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+        install -d ${D}${systemd_unitdir}/system/
+        install -m 0644 ${B}/lib/systemd/system/keymonitor.service ${D}${systemd_unitdir}/system
+    fi
+}
+addtask bachclean
+do_bachclean () {
+    oe_runmake clean
+}
diff --git a/meta/meta-mediatek/recipes-devtools/wpa2improvementsigma/mtkwpa2improvementsigma.bb b/meta/meta-mediatek/recipes-devtools/wpa2improvementsigma/mtkwpa2improvementsigma.bb
new file mode 100644
index 0000000..8e474e0
--- /dev/null
+++ b/meta/meta-mediatek/recipes-devtools/wpa2improvementsigma/mtkwpa2improvementsigma.bb
@@ -0,0 +1,8 @@
+DESCRIPTION = "Wi-Fi sigma tool for certification"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=d7810fab7487fb0aad327b76f1be7cd7"
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/devtools/wifi-sigma/wpa2-improvement-sigma"
+
+INSANE_SKIP_${PN} += "ldflags"