[rdkb][common][bsp][Refactor BB file for kirkstone build pass]

[Description]
Refactor BB file for kirkstone build pass

[Release-log]

Change-Id: I82abe730b8b4324db279af33aa4f68397383feb5
diff --git a/conf/layer.conf b/conf/layer.conf
index f99dc3f..5a79cbe 100644
--- a/conf/layer.conf
+++ b/conf/layer.conf
@@ -9,4 +9,4 @@
 BBFILE_PATTERN_filogic = "^${LAYERDIR}/"
 BBFILE_PRIORITY_filogic = "8"
 
-LAYERSERIES_COMPAT_filogic = "dunfell"
+LAYERSERIES_COMPAT_filogic = "dunfell kirkstone"
diff --git a/conf/machine/filogic.conf b/conf/machine/filogic.conf
index 6278e7c..bfeba0e 100644
--- a/conf/machine/filogic.conf
+++ b/conf/machine/filogic.conf
@@ -6,7 +6,6 @@
 
 DEFAULTTUNE ?= "cortexa53"
 
-require conf/machine/include/tune-cortexa53.inc
 include conf/machine/include/soc-family.inc
 
 SOC_FAMILY = "mediatek"
@@ -79,3 +78,5 @@
 IMAGE_CLASSES += "image_types-mtk"
 
 SERIAL_CONSOLE ?= "115200 ttyS0"
+
+
diff --git a/recipes-ccsp/hal/hal-ethsw-generic_git.bbappend b/recipes-ccsp/hal/hal-ethsw-generic_git.bbappend
index 4f9c9ed..a7f1486 100644
--- a/recipes-ccsp/hal/hal-ethsw-generic_git.bbappend
+++ b/recipes-ccsp/hal/hal-ethsw-generic_git.bbappend
@@ -1,4 +1,4 @@
-SRC_URI += "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;destsuffix=git/source/ethsw/rdkb_hal"
+SRC_URI += "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;branch=master;destsuffix=git/source/ethsw/rdkb_hal"
 
 SRCREV = "${AUTOREV}"
 
diff --git a/recipes-ccsp/hal/hal-fwupgrade.bb b/recipes-ccsp/hal/hal-fwupgrade.bb
index c10a5f0..687aabb 100644
--- a/recipes-ccsp/hal/hal-fwupgrade.bb
+++ b/recipes-ccsp/hal/hal-fwupgrade.bb
@@ -6,7 +6,7 @@
 RPROVIDES_${PN} = "hal-fwupgrade"
 
 DEPENDS += "ccsp-common-library halinterface"
-SRC_URI = "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;name=fwupgradehal \
+SRC_URI = "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;branch=master;protocol=https;name=fwupgradehal \
            file://LICENSE;subdir=git \
           "
 
diff --git a/recipes-ccsp/hal/hal-platform-generic_git.bbappend b/recipes-ccsp/hal/hal-platform-generic_git.bbappend
index be61467..9cd0f29 100644
--- a/recipes-ccsp/hal/hal-platform-generic_git.bbappend
+++ b/recipes-ccsp/hal/hal-platform-generic_git.bbappend
@@ -1,6 +1,6 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
 
-SRC_URI += "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;destsuffix=git/source/platform/rdkb_hal"
+SRC_URI += "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;branch=master;protocol=https;destsuffix=git/source/platform/rdkb_hal"
 
 
 SRCREV = "${AUTOREV}"
diff --git a/recipes-devtools/init-filogic/files/99-local-usb-mount.rules b/recipes-devtools/init-filogic/files/init-service/99-local-usb-mount.rules
similarity index 100%
rename from recipes-devtools/init-filogic/files/99-local-usb-mount.rules
rename to recipes-devtools/init-filogic/files/init-service/99-local-usb-mount.rules
diff --git a/recipes-devtools/init-filogic/files/factorydefault b/recipes-devtools/init-filogic/files/init-service/factorydefault
similarity index 100%
rename from recipes-devtools/init-filogic/files/factorydefault
rename to recipes-devtools/init-filogic/files/init-service/factorydefault
diff --git a/recipes-devtools/init-filogic/files/init-IPv6.service b/recipes-devtools/init-filogic/files/init-service/init-IPv6.service
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-IPv6.service
rename to recipes-devtools/init-filogic/files/init-service/init-IPv6.service
diff --git a/recipes-devtools/init-filogic/files/init-IPv6.sh b/recipes-devtools/init-filogic/files/init-service/init-IPv6.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-IPv6.sh
rename to recipes-devtools/init-filogic/files/init-service/init-IPv6.sh
diff --git a/recipes-devtools/init-filogic/files/init-Lanbridge.service b/recipes-devtools/init-filogic/files/init-service/init-Lanbridge.service
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-Lanbridge.service
rename to recipes-devtools/init-filogic/files/init-service/init-Lanbridge.service
diff --git a/recipes-devtools/init-filogic/files/init-PPPQ.service b/recipes-devtools/init-filogic/files/init-service/init-PPPQ.service
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-PPPQ.service
rename to recipes-devtools/init-filogic/files/init-service/init-PPPQ.service
diff --git a/recipes-devtools/init-filogic/files/init-PPPQ.sh b/recipes-devtools/init-filogic/files/init-service/init-PPPQ.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-PPPQ.sh
rename to recipes-devtools/init-filogic/files/init-service/init-PPPQ.sh
diff --git a/recipes-devtools/init-filogic/files/init-bridge.sh b/recipes-devtools/init-filogic/files/init-service/init-bridge.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/init-bridge.sh
rename to recipes-devtools/init-filogic/files/init-service/init-bridge.sh
diff --git a/recipes-devtools/init-filogic/files/l2tp_config.sh b/recipes-devtools/init-filogic/files/init-service/l2tp_config.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/l2tp_config.sh
rename to recipes-devtools/init-filogic/files/init-service/l2tp_config.sh
diff --git a/recipes-devtools/init-filogic/files/lan_config.sh b/recipes-devtools/init-filogic/files/init-service/lan_config.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/lan_config.sh
rename to recipes-devtools/init-filogic/files/init-service/lan_config.sh
diff --git a/recipes-devtools/init-filogic/files/pppoe_config.sh b/recipes-devtools/init-filogic/files/init-service/pppoe_config.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/pppoe_config.sh
rename to recipes-devtools/init-filogic/files/init-service/pppoe_config.sh
diff --git a/recipes-devtools/init-filogic/files/pptp_config.sh b/recipes-devtools/init-filogic/files/init-service/pptp_config.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/pptp_config.sh
rename to recipes-devtools/init-filogic/files/init-service/pptp_config.sh
diff --git a/recipes-devtools/init-filogic/files/staticIP_config.sh b/recipes-devtools/init-filogic/files/init-service/staticIP_config.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/staticIP_config.sh
rename to recipes-devtools/init-filogic/files/init-service/staticIP_config.sh
diff --git a/recipes-devtools/init-filogic/files/usb-mount.sh b/recipes-devtools/init-filogic/files/init-service/usb-mount.sh
similarity index 100%
rename from recipes-devtools/init-filogic/files/usb-mount.sh
rename to recipes-devtools/init-filogic/files/init-service/usb-mount.sh
diff --git a/recipes-devtools/init-filogic/files/usb-mount@.service b/recipes-devtools/init-filogic/files/init-service/usb-mount@.service
similarity index 100%
rename from recipes-devtools/init-filogic/files/usb-mount@.service
rename to recipes-devtools/init-filogic/files/init-service/usb-mount@.service
diff --git a/recipes-devtools/init-filogic/init-filogic.bb b/recipes-devtools/init-filogic/init-filogic.bb
index 37e7bb6..83e80af 100644
--- a/recipes-devtools/init-filogic/init-filogic.bb
+++ b/recipes-devtools/init-filogic/init-filogic.bb
@@ -7,7 +7,8 @@
 inherit systemd
 
 SRC_URI = " \
-    file://* \
+    file://init-service/ \
+    file://COPYING \
     "
 
 RDEPENDS_${PN} += "bash"
@@ -24,22 +25,22 @@
 
 do_install() {
     install -d ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/init-IPv6.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/init-bridge.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/factorydefault ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/lan_config.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/l2tp_config.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/pppoe_config.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/pptp_config.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/staticIP_config.sh ${D}${sbindir}
-    install -m 0755 ${WORKDIR}/init-PPPQ.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/init-IPv6.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/init-bridge.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/factorydefault ${D}${sbindir}
+    install -m 0755 ${S}/init-service/lan_config.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/l2tp_config.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/pppoe_config.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/pptp_config.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/staticIP_config.sh ${D}${sbindir}
+    install -m 0755 ${S}/init-service/init-PPPQ.sh ${D}${sbindir}
     install -d ${D}${systemd_unitdir}/system/
-    install -m 0644 ${S}/init-IPv6.service ${D}${systemd_unitdir}/system
-    install -m 0644 ${S}/init-Lanbridge.service ${D}${systemd_unitdir}/system
-    install -m 0644 ${S}/init-PPPQ.service ${D}${systemd_unitdir}/system
-    install -m 0644 ${S}/usb-mount@.service ${D}${systemd_unitdir}/system
+    install -m 0644 ${S}/init-service/init-IPv6.service ${D}${systemd_unitdir}/system
+    install -m 0644 ${S}/init-service/init-Lanbridge.service ${D}${systemd_unitdir}/system
+    install -m 0644 ${S}/init-service/init-PPPQ.service ${D}${systemd_unitdir}/system
+    install -m 0644 ${S}/init-service/usb-mount@.service ${D}${systemd_unitdir}/system
     install -d ${D}${sysconfdir}/udev/rules.d
-    install -m 0644 ${WORKDIR}/99-local-usb-mount.rules ${D}${sysconfdir}/udev/rules.d
+    install -m 0644 ${S}/init-service/99-local-usb-mount.rules ${D}${sysconfdir}/udev/rules.d
     install -d ${D}${bindir}
-    install -m 0755 ${WORKDIR}/usb-mount.sh ${D}${bindir}
+    install -m 0755 ${S}/init-service/usb-mount.sh ${D}${bindir}
 }
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers.inc b/recipes-kernel/linux-libc-headers/linux-libc-headers.inc
new file mode 100644
index 0000000..2d4429b
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers.inc
@@ -0,0 +1,96 @@
+SUMMARY = "Sanitized set of kernel headers for the C library's use"
+HOMEPAGE = "https://www.kernel.org/"
+DESCRIPTION = "Designed to maintain an Application Programming Interface (API) stable version of the Linux headers"
+SECTION = "devel"
+LICENSE = "GPLv2"
+
+#########################################################################
+####                        PLEASE READ 
+#########################################################################
+#
+# You're probably looking here thinking you need to create some new copy
+# of linux-libc-headers since you have your own custom kernel. To put 
+# this simply, you DO NOT.
+#
+# Why? These headers are used to build the libc. If you customise the 
+# headers you are customising the libc and the libc becomes machine
+# specific. Most people do not add custom libc extensions to the kernel
+# and have a machine specific libc.
+#
+# But you have some kernel headers you need for some driver? That is fine
+# but get them from STAGING_KERNEL_BUILDDIR where the kernel installs itself.
+# This will make the package using them machine specific but this is much
+# better than having a machine specific C library. This does mean your
+# recipe needs a
+#    do_configure[depends] += "virtual/kernel:do_shared_workdir"
+# but again, that is fine and makes total sense.
+#
+# There can also be a case where your kernel extremely old and you want
+# an older libc ABI for that old kernel. The headers installed by this
+# recipe should still be a standard mainline kernel, not your own custom 
+# one.
+#
+# -- RP
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
+
+python __anonymous () {
+    major = d.getVar("PV").split('.')[0]
+    if major == "3":
+        d.setVar("HEADER_FETCH_VER", "3.0")
+    elif major == "4":
+        d.setVar("HEADER_FETCH_VER", "4.x")
+    elif major == "5":
+        d.setVar("HEADER_FETCH_VER", "5.x")
+    else:
+        d.setVar("HEADER_FETCH_VER", "2.6")
+}
+
+inherit kernel-arch pkgconfig multilib_header
+
+KORG_ARCHIVE_COMPRESSION ?= "xz"
+
+SRC_URI = "${KERNELORG_MIRROR}/linux/kernel/v${HEADER_FETCH_VER}/linux-${PV}.tar.${KORG_ARCHIVE_COMPRESSION}"
+UPSTREAM_CHECK_URI = "https://www.kernel.org/"
+
+S = "${WORKDIR}/linux-${PV}"
+
+EXTRA_OEMAKE = " HOSTCC="${BUILD_CC}" HOSTCPP="${BUILD_CPP}""
+
+do_configure[noexec] = "1"
+
+do_compile[noexec] = "1"
+
+do_install() {
+	oe_runmake headers_install INSTALL_HDR_PATH=${D}${exec_prefix}
+	# Kernel should not be exporting this header
+	rm -f ${D}${exec_prefix}/include/scsi/scsi.h
+
+	# The ..install.cmd conflicts between various configure runs
+	find ${D}${includedir} -name ..install.cmd | xargs rm -f
+}
+
+do_install_append_aarch64 () {
+        do_install_armmultilib
+}
+
+do_install_append_arm () {
+	do_install_armmultilib
+}
+
+do_install_append_armeb () {
+	do_install_armmultilib
+}
+
+do_install_armmultilib () {
+	oe_multilib_header asm/auxvec.h asm/bitsperlong.h asm/byteorder.h asm/fcntl.h asm/hwcap.h asm/ioctls.h asm/kvm.h asm/kvm_para.h asm/mman.h asm/param.h asm/perf_regs.h asm/bpf_perf_event.h
+	oe_multilib_header asm/posix_types.h asm/ptrace.h  asm/setup.h  asm/sigcontext.h asm/siginfo.h asm/signal.h asm/stat.h  asm/statfs.h asm/swab.h  asm/types.h asm/unistd.h
+}
+
+BBCLASSEXTEND = "nativesdk"
+
+RDEPENDS_${PN}-dev = ""
+RRECOMMENDS_${PN}-dbg = "${PN}-dev (= ${EXTENDPKGV})"
+
+INHIBIT_DEFAULT_DEPS = "1"
+DEPENDS += "unifdef-native bison-native rsync-native"
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-include-linux-stddef.h-in-swab.h-uapi-header.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-include-linux-stddef.h-in-swab.h-uapi-header.patch
new file mode 100644
index 0000000..9d17daa
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-include-linux-stddef.h-in-swab.h-uapi-header.patch
@@ -0,0 +1,44 @@
+From 9708dc74d9f49488d669e070982f6224a888d61a Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 12 Sep 2018 17:08:58 -0700
+Subject: [PATCH] include linux/stddef.h in swab.h uapi header
+
+swab.h uses __always_inline without including the header where it is
+defined, this is exposed by musl based distributions where this macro is
+not defined by system C library headers unlike glibc where it is defined
+in sys/cdefs.h and that header gets pulled in indirectly via
+
+features.h -> sys/cdefs.h
+
+and features.h gets pulled in a lot of headers. Therefore it may work in
+cases where features.h is includes but not otherwise.
+
+Adding linux/stddef.h here ensures that __always_inline is always
+defined independent of which C library is used in userspace
+
+Upstream-Status: Submitted [https://lkml.org/lkml/2018/9/13/78]
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Cc: Philippe Ombredanne <pombredanne@nexb.com>
+Cc: Kate Stewart <kstewart@linuxfoundation.org>
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+---
+ include/uapi/linux/swab.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
+index 23cd84868cc3..acddbe50a20d 100644
+--- a/include/uapi/linux/swab.h
++++ b/include/uapi/linux/swab.h
+@@ -3,6 +3,7 @@
+ #define _UAPI_LINUX_SWAB_H
+ 
+ #include <linux/types.h>
++#include <linux/stddef.h>
+ #include <linux/compiler.h>
+ #include <asm/swab.h>
+ 
+-- 
+2.19.0
+
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-kbuild-install_headers.sh-Strip-_UAPI-from-if-define.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-kbuild-install_headers.sh-Strip-_UAPI-from-if-define.patch
new file mode 100644
index 0000000..54528b6
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-kbuild-install_headers.sh-Strip-_UAPI-from-if-define.patch
@@ -0,0 +1,38 @@
+From 9ca6c6a510bda90954aa2532711200b89dd1df89 Mon Sep 17 00:00:00 2001
+From: Dave Martin <Dave.Martin@arm.com>
+Date: Tue, 11 Dec 2018 19:26:45 +0000
+Subject: [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from
+ #if-defined() guards
+
+install_headers.sh knows how to strip the _UAPI prefix from #ifdef/
+ifndef and #define directives used to guard headers against multiple
+or inappropriate inclusion.  Currently this does not work for guards
+in the "#if defined()" style, which may be needed for non-trivial
+cases.
+
+This patch adds similar logic so that the _UAPI prefix is also
+stripped from guard directives written using "#if defined()" etc.
+
+This is not completely foolproof, but will work for simple cases of
+using #if defined() to guard against inappropriate header inclusion.
+
+Signed-off-by: Dave Martin <Dave.Martin@arm.com>
+Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
+
+Upstream-Status: Submitted [https://www.spinics.net/lists/arm-kernel/msg694800.html]
+---
+ scripts/headers_install.sh | 1 +
+ 1 file changed, 1 insertion(+)
+
+Index: linux-5.4/scripts/headers_install.sh
+===================================================================
+--- linux-5.4.orig/scripts/headers_install.sh
++++ linux-5.4/scripts/headers_install.sh
+@@ -36,6 +36,7 @@
+ 	s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
+ 	s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
+ 	s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
++        :1;s/(#(if|elif)(.*[^A-Za-z0-9_])defined\([[:space:]]*)_UAPI/\1/;t1
+ ' $INFILE > $TMPFILE || exit 1
+ 
+ scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch
new file mode 100644
index 0000000..064a391
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch
@@ -0,0 +1,90 @@
+From 2872f5d8bcef84e62b15b37ba4ffeccfb6402dad Mon Sep 17 00:00:00 2001
+From: rofl0r <retnyg@gmx.net>
+Date: Wed, 22 Jan 2014 00:48:28 +0100
+Subject: [PATCH 1/3] libc-compat.h: fix some issues arising from in6.h
+
+namely redefinition of some structs provided by netinet/in.h.
+---
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Submitted
+
+ include/uapi/linux/libc-compat.h | 25 ++++++++-----------------
+ 1 file changed, 8 insertions(+), 17 deletions(-)
+
+Index: linux-4.15/include/uapi/linux/libc-compat.h
+===================================================================
+--- linux-4.15.orig/include/uapi/linux/libc-compat.h	2018-02-05 17:37:44.724314379 -0500
++++ linux-4.15/include/uapi/linux/libc-compat.h	2018-02-05 17:38:02.148913820 -0500
+@@ -49,13 +49,12 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+ 
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++#ifndef __KERNEL__ /* we're used from userspace */
+ 
+-/* Coordinate with glibc net/if.h header. */
+-#if defined(_NET_IF_H) && defined(__USE_MISC)
++/* Coordinate with libc net/if.h header. */
++#if defined(_NET_IF_H)
+ 
+-/* GLIBC headers included first so don't define anything
++/* LIBC headers included first so don't define anything
+  * that would already be defined. */
+ 
+ #define __UAPI_DEF_IF_IFCONF 0
+@@ -99,15 +98,7 @@
+ #define __UAPI_DEF_IN_CLASS		0
+ 
+ #define __UAPI_DEF_IN6_ADDR		0
+-/* The exception is the in6_addr macros which must be defined
+- * if the glibc code didn't define them. This guard matches
+- * the guard in glibc/inet/netinet/in.h which defines the
+- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT		0
+-#else
+-#define __UAPI_DEF_IN6_ADDR_ALT		1
+-#endif
+ #define __UAPI_DEF_SOCKADDR_IN6		0
+ #define __UAPI_DEF_IPV6_MREQ		0
+ #define __UAPI_DEF_IPPROTO_V6		0
+@@ -115,10 +106,10 @@
+ #define __UAPI_DEF_IN6_PKTINFO		0
+ #define __UAPI_DEF_IP6_MTUINFO		0
+ 
+-#else
++#else /* defined(_NETINET_IN_H) */
+ 
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that libc will check the
+  * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN_ADDR		1
+ #define __UAPI_DEF_IN_IPPROTO		1
+@@ -128,7 +119,7 @@
+ #define __UAPI_DEF_IN_CLASS		1
+ 
+ #define __UAPI_DEF_IN6_ADDR		1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and libc must
+  * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT		1
+ #define __UAPI_DEF_SOCKADDR_IN6		1
+@@ -170,7 +161,7 @@
+  * or we are being included in the kernel, then define everything
+  * that we need. Check for previous __UAPI_* definitions to give
+  * unsupported C libraries a way to opt out of any kernel definition. */
+-#else /* !defined(__GLIBC__) */
++#else /* __KERNEL__ */
+ 
+ /* Definitions for if.h */
+ #ifndef __UAPI_DEF_IF_IFCONF
+@@ -262,6 +253,6 @@
+ #define __UAPI_DEF_XATTR		1
+ #endif
+ 
+-#endif /* __GLIBC__ */
++#endif /* __KERNEL__ */
+ 
+ #endif /* _UAPI_LIBC_COMPAT_H */
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch
new file mode 100644
index 0000000..bde2132
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch
@@ -0,0 +1,46 @@
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [v2,2/3] uapi glibc compat: fix build if libc defines IFF_ECHO
+From: Hauke Mehrtens <hauke@hauke-m.de>
+X-Patchwork-Id: 9686293
+Message-Id: <20170418210036.26039-3-hauke@hauke-m.de>
+To: davem@davemloft.net, netdev@vger.kernel.org
+Cc: linux-kernel@vger.kernel.org, jarod@redhat.com, jogo@openwrt.org,
+ david.heidelberger@ixit.cz, maillist-linux@barfooze.de,
+ mikko.rapeli@iki.fi, dwmw2@infradead.org, Hauke Mehrtens <hauke@hauke-m.de>
+Date: Tue, 18 Apr 2017 23:00:35 +0200
+
+musl 1.1.15 defines IFF_ECHO and the other net_device_flags options.
+When a user application includes linux/if.h and net/if.h the compile
+will fail.
+
+Activate __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO only when
+it is needed. This should also make this work in case glibc will add
+these defines.
+
+Acked-by: Mikko Rapeli <mikko.rapeli@iki.fi>
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+Upstream-Status: Submitted [https://patchwork.kernel.org/patch/9686293/]
+Signed-off-by: André Draszik <adraszik@tycoint.com>
+Acked-by: Stephane Ayotte <sayotte@tycoint.com>
+ include/uapi/linux/libc-compat.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
+index 43a81136ea6e..ce2fa8a4ced6 100644
+--- a/include/uapi/linux/libc-compat.h
++++ b/include/uapi/linux/libc-compat.h
+@@ -64,9 +64,11 @@
+ /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
+ /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
++#ifndef IFF_ECHO
+ #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
+ #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */
++#endif /* IFF_ECHO */
+ 
+ #else /* _NET_IF_H */
+ 
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-scripts-Use-fixed-input-and-output-files-instead-of-.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-scripts-Use-fixed-input-and-output-files-instead-of-.patch
new file mode 100644
index 0000000..a5ded60
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-scripts-Use-fixed-input-and-output-files-instead-of-.patch
@@ -0,0 +1,67 @@
+From 694eba7bb974f6b8bd308804cb24350150108b2b Mon Sep 17 00:00:00 2001
+From: He Zhe <zhe.he@windriver.com>
+Date: Wed, 21 Nov 2018 15:12:43 +0800
+Subject: [PATCH] scripts: Use fixed input and output files instead of pipe for here-doc
+
+There was a bug of "as" in binutils that when it checks if the input file and
+output file are the same one, it would not check if they are on the same block
+device. The check is introduced by the following commit in v2.31.
+
+https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
+67f846b59b32f3d704c601669409c2584383fea9
+
+The here-doc usage in this script creates temporary file in /tmp. When we run in
+an environment where /tmp has rarely been used, the newly created temporary file
+may have a very low inode number. If the inode number was 6 which is the same as
+/dev/null, the as would wrongly think the input file and the output file are the
+same and report the following error.
+
+*** Compiler lacks asm-goto support.. Stop.
+
+One observed case happened in docker where the /tmp could be so rarely used that
+very low number inode may be allocated and triggers the error.
+
+The fix below for the bug only exists on the master branch of binutils so far
+and has not been released from upstream. As the convict is introduced since
+v2.31, only v2.31 is affected.
+
+https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
+2a50366ded329bfb39d387253450c9d5302c3503
+
+When building linux-libc-headers we need to use "as" in binutils which does not
+contain the fix for the moment. To work around the error, we create a fixed
+temporary file to contain the program being tested.
+
+This patch also removes ">/dev/null 2>&1" so we will have more direct error
+information in case something else wrong happened.
+
+Upstream-Status: Inappropriate [A work around for binutils v2.31]
+
+Signed-off-by: He Zhe <zhe.he@windriver.com>
+---
+ scripts/gcc-goto.sh | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/gcc-goto.sh b/scripts/gcc-goto.sh
+index 8b980fb22..d256a9438 100755
+--- a/scripts/gcc-goto.sh
++++ b/scripts/gcc-goto.sh
+@@ -3,7 +3,7 @@
+ # Test for gcc 'asm goto' support
+ # Copyright (C) 2010, Jason Baron <jbaron@redhat.com>
+ 
+-cat << "END" | $@ -x c - -fno-PIE -c -o /dev/null
++cat << "END" > ./input
+ int main(void)
+ {
+ #if defined(__arm__) || defined(__aarch64__)
+@@ -20,3 +20,6 @@ entry:
+ 	return 0;
+ }
+ END
++
++$@ -x c ./input -fno-PIE -c -o ./output
++rm ./input ./output
+-- 
+2.19.1
+
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch b/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch
new file mode 100644
index 0000000..b5c4e17
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch
@@ -0,0 +1,29 @@
+From 8e69b663d6ddef132041a1186f081fdd74d4a31d Mon Sep 17 00:00:00 2001
+From: rofl0r <retnyg@gmx.net>
+Date: Mon, 20 Jan 2014 21:31:34 +0100
+Subject: [PATCH 3/3] remove inclusion of sysinfo.h in kernel.h
+
+the declaration of struct sysinfo clashes with userspace.
+it's not quite clear why that header was included from kernel.h,
+as none of its functionality is needed.
+---
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Upstream-Status: Submitted
+
+ include/uapi/linux/kernel.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+Index: linux-4.8-rc4/include/uapi/linux/kernel.h
+===================================================================
+--- linux-4.8-rc4.orig/include/uapi/linux/kernel.h
++++ linux-4.8-rc4/include/uapi/linux/kernel.h
+@@ -1,7 +1,9 @@
+ #ifndef _UAPI_LINUX_KERNEL_H
+ #define _UAPI_LINUX_KERNEL_H
+ 
++#ifdef __GLIBC__
+ #include <linux/sysinfo.h>
++#endif
+ 
+ /*
+  * 'kernel.h' contains some often-used function prototypes etc
diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers_5.4.bb b/recipes-kernel/linux-libc-headers/linux-libc-headers_5.4.bb
new file mode 100644
index 0000000..8a12103
--- /dev/null
+++ b/recipes-kernel/linux-libc-headers/linux-libc-headers_5.4.bb
@@ -0,0 +1,16 @@
+require linux-libc-headers.inc
+
+SRC_URI_append_libc-musl = "\
+    file://0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch \
+    file://0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch \
+    file://0001-libc-compat.h-musl-_does_-define-IFF_LOWER_UP-DORMAN.patch \
+    file://0001-include-linux-stddef.h-in-swab.h-uapi-header.patch \
+   "
+
+SRC_URI_append = "\
+    file://0001-scripts-Use-fixed-input-and-output-files-instead-of-.patch \
+    file://0001-kbuild-install_headers.sh-Strip-_UAPI-from-if-define.patch \
+"
+
+SRC_URI[md5sum] = "ce9b2d974d27408a61c53a30d3f98fb9"
+SRC_URI[sha256sum] = "bf338980b1670bca287f9994b7441c2361907635879169c64ae78364efc5f491"
diff --git a/recipes-wifi/hal/hal-wifi-mt76.bb b/recipes-wifi/hal/hal-wifi-mt76.bb
index dd883d8..b4ad930 100644
--- a/recipes-wifi/hal/hal-wifi-mt76.bb
+++ b/recipes-wifi/hal/hal-wifi-mt76.bb
@@ -10,7 +10,7 @@
 
 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
 
-SRC_URI = "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;destsuffix=git/ \
+SRC_URI = "git://gerrit.mediatek.inc/gateway/rdk-b/rdkb_hal;protocol=https;branch=master;destsuffix=git/ \
         file://LICENSE;subdir=git \
         "
 SRCREV_wifihal = "${AUTOREV}"
diff --git a/recipes-wifi/hal/halinterface.bbappend b/recipes-wifi/hal/halinterface.bbappend
index 9dca67d..8af71a8 100644
--- a/recipes-wifi/hal/halinterface.bbappend
+++ b/recipes-wifi/hal/halinterface.bbappend
@@ -1,5 +1,11 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
-SRC_URI_append = " file://*.patch;apply=no \
+SRC_URI_append = " \
+        file://sta-network.patch;apply=no \
+        file://add_undefined_dfs_function.patch;apply=no \
+        file://0001-Add-owe-mode.patch;apply=no \
+        file://0002-Add-EHT-support.patch;apply=no \
+        file://0003-Add-EHT-support.patch;apply=no \
+        file://2023q4dunfell-Add-EHT-support.patch;apply=no \
     "
 
 #This is workaround for missing do_patch when RDK uses external sources
diff --git a/recipes-wifi/iwinfo/iwinfo_git.bb b/recipes-wifi/iwinfo/iwinfo_git.bb
index 72106dd..997971b 100644
--- a/recipes-wifi/iwinfo/iwinfo_git.bb
+++ b/recipes-wifi/iwinfo/iwinfo_git.bb
@@ -29,11 +29,11 @@
 
 do_install() {
 	install -D -m 0755 ${B}/libiwinfo.so ${D}${libdir}/libiwinfo.so
-        install -D -m 0755 ${B}/iwinfo.so ${D}${libdir}/lua/iwinfo.so
-        install -D -m 0755 ${B}/iwinfo ${D}${bindir}/iwinfo
+    install -D -m 0755 ${B}/iwinfo.so ${D}${libdir}/lua/iwinfo.so
+    install -D -m 0755 ${B}/iwinfo ${D}${bindir}/iwinfo
 	install -D -m 0644 ${S}/include/iwinfo.h ${D}${includedir}/iwinfo.h
 	install -D -m 0644 ${S}/include/iwinfo/utils.h ${D}${includedir}/iwinfo/utils.h
 }
 
 FILES_SOLIBSDEV = ""
-FILES_${PN} += "${libdir}/libiwinfo.so"
+FILES_${PN} += "${libdir}/libiwinfo.so ${libdir}/lua/iwinfo.so"
diff --git a/recipes-wifi/linux-mt76/linux-mt76_2.x.bb b/recipes-wifi/linux-mt76/linux-mt76_2.x.bb
index 686750c..b61b5cf 100644
--- a/recipes-wifi/linux-mt76/linux-mt76_2.x.bb
+++ b/recipes-wifi/linux-mt76/linux-mt76_2.x.bb
@@ -7,7 +7,7 @@
 
 require mt76.inc
 SRC_URI = " \
-    git://git@github.com/openwrt/mt76.git;protocol=https \
+    git://git@github.com/openwrt/mt76.git;protocol=https;branch=master \
     file://COPYING;subdir=git \
     "
 SRC_URI += " \
diff --git a/recipes-wifi/linux-mt76/linux-mt76_3.x.bb b/recipes-wifi/linux-mt76/linux-mt76_3.x.bb
index b9a69c7..b8ccb5f 100644
--- a/recipes-wifi/linux-mt76/linux-mt76_3.x.bb
+++ b/recipes-wifi/linux-mt76/linux-mt76_3.x.bb
@@ -7,7 +7,7 @@
 
 require mt76.inc
 SRC_URI = " \
-    git://git@github.com/openwrt/mt76.git;protocol=https \
+    git://git@github.com/openwrt/mt76.git;protocol=https;branch=master \
     file://COPYING;subdir=git \
     "
 SRC_URI += " \
@@ -69,8 +69,6 @@
 do_install() {
     # Module
     install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
-    install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
-    install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
     install -m 0644 ${B}/mt76.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
     install -m 0644 ${B}/mt76-connac-lib.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
     install -m 0644 ${B}/mt7996/mt7996e.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
diff --git a/recipes-wifi/linux-mt76/mt76-test.bb b/recipes-wifi/linux-mt76/mt76-test.bb
index db836fc..853e974 100644
--- a/recipes-wifi/linux-mt76/mt76-test.bb
+++ b/recipes-wifi/linux-mt76/mt76-test.bb
@@ -24,20 +24,21 @@
 DEPENDS += "linux-mac80211"
 DEPENDS += "linux-mt76"
 
-FILESEXTRAPATHS_prepend := "${@bb.utils.contains('DISTRO_FEATURES','wifi_eht','${THISDIR}/files/patches-3.x:','${THISDIR}/files/patches:',d)}"
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
 
 
 CFLAGS_append = " -I=${includedir}/libnl-tiny "
 
 S = "${WORKDIR}/git/tools"
+PATCH_SRC = "${@bb.utils.contains('DISTRO_FEATURES','wifi_eht','${WORKDIR}/patches-3.x','${WORKDIR}/patches',d)}"
 
-SRC_URI += "file://*.patch;apply=no"
+SRC_URI += "file://${@bb.utils.contains('DISTRO_FEATURES','wifi_eht','patches-3.x/','patches/',d)};apply=no"
 
 do_mtk_patches() {
 	cd ${S}/../
     
 	if [ ! -e mtk_wifi_patch_applied ]; then
-        for i in ${WORKDIR}/*.patch; do patch -p1 < $i; done
+        for i in ${PATCH_SRC}/*.patch; do patch -p1 < $i; done
 	fi
 	touch mtk_wifi_patch_applied
 }
diff --git a/recipes-wifi/lua/lua/0001-Allow-building-lua-without-readline-on-Linux.patch b/recipes-wifi/lua/lua/0001-Allow-building-lua-without-readline-on-Linux.patch
new file mode 100644
index 0000000..e767900
--- /dev/null
+++ b/recipes-wifi/lua/lua/0001-Allow-building-lua-without-readline-on-Linux.patch
@@ -0,0 +1,59 @@
+From 601ef636fc4dfb2af3e7fda88d8ea1c1d92affe4 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Wed, 2 Oct 2019 17:54:15 +0200
+Subject: [PATCH] Allow building lua without readline on Linux
+
+Upstream-Status: Pending
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+---
+ Makefile      | 2 +-
+ src/Makefile  | 3 +++
+ src/luaconf.h | 5 +++++
+ 3 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 119110d..9f6df45 100644
+--- a/Makefile
++++ b/Makefile
+@@ -36,7 +36,7 @@ RM= rm -f
+ # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
+ 
+ # Convenience platforms targets.
+-PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
++PLATS= aix bsd c89 freebsd generic linux linux-no-readline macosx mingw posix solaris
+ 
+ # What to install.
+ TO_BIN= lua luac
+diff --git a/src/Makefile b/src/Makefile
+index 64c78f7..5c0428a 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -109,6 +109,9 @@ generic: $(ALL)
+ linux:
+ 	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"
+ 
++linux-no-readline:
++	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX_NO_READLINE" SYSLIBS="-Wl,-E -ldl"
++
+ macosx:
+ 	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline"
+ 
+diff --git a/src/luaconf.h b/src/luaconf.h
+index 9eeeea6..d71ca25 100644
+--- a/src/luaconf.h
++++ b/src/luaconf.h
+@@ -64,6 +64,11 @@
+ #define LUA_USE_READLINE	/* needs some extra libraries */
+ #endif
+ 
++#if defined(LUA_USE_LINUX_NO_READLINE)
++#define LUA_USE_POSIX
++#define LUA_USE_DLOPEN		/* needs an extra library: -ldl */
++#endif
++
+ 
+ #if defined(LUA_USE_MACOSX)
+ #define LUA_USE_POSIX
+-- 
+2.17.1
+
diff --git a/recipes-wifi/lua/lua/0001-Fixed-bug-barriers-cannot-be-active-during-sweep.patch b/recipes-wifi/lua/lua/0001-Fixed-bug-barriers-cannot-be-active-during-sweep.patch
new file mode 100644
index 0000000..a302874
--- /dev/null
+++ b/recipes-wifi/lua/lua/0001-Fixed-bug-barriers-cannot-be-active-during-sweep.patch
@@ -0,0 +1,90 @@
+From 1e6df25ac28dcd89f0324177bb55019422404b44 Mon Sep 17 00:00:00 2001
+From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
+Date: Thu, 3 Sep 2020 15:32:17 +0800
+Subject: [PATCH] Fixed bug: barriers cannot be active during sweep
+
+Barriers cannot be active during sweep, even in generational mode.
+(Although gen. mode is not incremental, it can hit a barrier when
+deleting a thread and closing its upvalues.)  The colors of objects are
+being changed during sweep and, therefore, cannot be trusted.
+
+Upstream-Status: Backport [https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110]
+CVE: CVE-2020-24371
+
+[Adjust code KGC_INC -> KGC_NORMAL, refer 69371c4b84becac09c445aae01d005b49658ef82]
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+---
+ src/lgc.c | 33 ++++++++++++++++++++++++---------
+ 1 file changed, 24 insertions(+), 9 deletions(-)
+
+diff --git a/src/lgc.c b/src/lgc.c
+index 973c269..7af23d5 100644
+--- a/src/lgc.c
++++ b/src/lgc.c
+@@ -142,10 +142,17 @@ static int iscleared (global_State *g, const TValue *o) {
+ 
+ 
+ /*
+-** barrier that moves collector forward, that is, mark the white object
+-** being pointed by a black object. (If in sweep phase, clear the black
+-** object to white [sweep it] to avoid other barrier calls for this
+-** same object.)
++** Barrier that moves collector forward, that is, marks the white object
++** 'v' being pointed by the black object 'o'.  In the generational
++** mode, 'v' must also become old, if 'o' is old; however, it cannot
++** be changed directly to OLD, because it may still point to non-old
++** objects. So, it is marked as OLD0. In the next cycle it will become
++** OLD1, and in the next it will finally become OLD (regular old). By
++** then, any object it points to will also be old.  If called in the
++** incremental sweep phase, it clears the black object to white (sweep
++** it) to avoid other barrier calls for this same object. (That cannot
++** be done is generational mode, as its sweep does not distinguish
++** whites from deads.)
+ */
+ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
+   global_State *g = G(L);
+@@ -154,7 +161,8 @@ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
+     reallymarkobject(g, v);  /* restore invariant */
+   else {  /* sweep phase */
+     lua_assert(issweepphase(g));
+-    makewhite(g, o);  /* mark main obj. as white to avoid other barriers */
++    if (g->gckind == KGC_NORMAL)  /* incremental mode? */
++      makewhite(g, o);  /* mark 'o' as white to avoid other barriers */
+   }
+ }
+ 
+@@ -299,10 +307,15 @@ static void markbeingfnz (global_State *g) {
+ 
+ 
+ /*
+-** Mark all values stored in marked open upvalues from non-marked threads.
+-** (Values from marked threads were already marked when traversing the
+-** thread.) Remove from the list threads that no longer have upvalues and
+-** not-marked threads.
++** For each non-marked thread, simulates a barrier between each open
++** upvalue and its value. (If the thread is collected, the value will be
++** assigned to the upvalue, but then it can be too late for the barrier
++** to act. The "barrier" does not need to check colors: A non-marked
++** thread must be young; upvalues cannot be older than their threads; so
++** any visited upvalue must be young too.) Also removes the thread from
++** the list, as it was already visited. Removes also threads with no
++** upvalues, as they have nothing to be checked. (If the thread gets an
++** upvalue later, it will be linked in the list again.)
+ */
+ static void remarkupvals (global_State *g) {
+   lua_State *thread;
+@@ -313,9 +326,11 @@ static void remarkupvals (global_State *g) {
+       p = &thread->twups;  /* keep marked thread with upvalues in the list */
+     else {  /* thread is not marked or without upvalues */
+       UpVal *uv;
++      lua_assert(!isold(thread) || thread->openupval == NULL);
+       *p = thread->twups;  /* remove thread from the list */
+       thread->twups = thread;  /* mark that it is out of list */
+       for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) {
++        lua_assert(getage(uv) <= getage(thread));
+         if (uv->u.open.touched) {
+           markvalue(g, uv->v);  /* remark upvalue's value */
+           uv->u.open.touched = 0;
+-- 
+1.9.1
+
diff --git a/recipes-wifi/lua/lua/CVE-2020-15888.patch b/recipes-wifi/lua/lua/CVE-2020-15888.patch
new file mode 100644
index 0000000..60a4125
--- /dev/null
+++ b/recipes-wifi/lua/lua/CVE-2020-15888.patch
@@ -0,0 +1,45 @@
+From 6298903e35217ab69c279056f925fb72900ce0b7 Mon Sep 17 00:00:00 2001
+From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
+Date: Mon, 6 Jul 2020 12:11:54 -0300
+Subject: [PATCH] Keep minimum size when shrinking a stack
+
+When shrinking a stack (during GC), do not make it smaller than the
+initial stack size.
+---
+ ldo.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+==== end of original header ====
+
+CVE: CVE-2020-15888
+
+Upstream-Status: backport [https://github.com/lua/lua.git]
+
+Signed-off-by: Joe Slater <joe.slater@windriver.com>
+
+====
+diff --git a/ldo.c b/ldo.c
+index c563b1d9..a89ac010 100644
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -220,7 +220,7 @@ static int stackinuse (lua_State *L) {
+ 
+ void luaD_shrinkstack (lua_State *L) {
+   int inuse = stackinuse(L);
+-  int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
++  int goodsize = inuse + BASIC_STACK_SIZE;
+   if (goodsize > LUAI_MAXSTACK)
+     goodsize = LUAI_MAXSTACK;  /* respect stack limit */
+   if (L->stacksize > LUAI_MAXSTACK)  /* had been handling stack overflow? */
+@@ -229,8 +229,7 @@ void luaD_shrinkstack (lua_State *L) {
+     luaE_shrinkCI(L);  /* shrink list */
+   /* if thread is currently not handling a stack overflow and its
+      good size is smaller than current size, shrink its stack */
+-  if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
+-      goodsize < L->stacksize)
++  if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L->stacksize)
+     luaD_reallocstack(L, goodsize);
+   else  /* don't change stack */
+     condmovestack(L,{},{});  /* (change only for debugging) */
+-- 
+2.17.1
+
diff --git a/recipes-wifi/lua/lua/CVE-2020-15945.patch b/recipes-wifi/lua/lua/CVE-2020-15945.patch
new file mode 100644
index 0000000..89ce491
--- /dev/null
+++ b/recipes-wifi/lua/lua/CVE-2020-15945.patch
@@ -0,0 +1,167 @@
+From d8d344365945a534f700c82c5dd26f704f89fef3 Mon Sep 17 00:00:00 2001
+From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
+Date: Wed, 5 Aug 2020 16:59:58 +0800
+Subject: [PATCH] Fixed bug: invalid 'oldpc' when returning to a function
+
+The field 'L->oldpc' is not always updated when control returns to a
+function; an invalid value can seg. fault when computing 'changedline'.
+(One example is an error in a finalizer; control can return to
+'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to
+fix all possible corner cases, it seems safer to be resilient to invalid
+values for 'oldpc'. Valid but wrong values at most cause an extra call
+to a line hook.
+
+CVE: CVE-2020-15945
+
+[Adjust the code to be applicable to the tree]
+
+Upstream-Status: Backport [https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3]
+
+Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
+Signed-off-by: Joe Slater <joe.slater@@windriver.com>
+
+---
+ src/ldebug.c | 30 +++++++++++++++---------------
+ src/ldebug.h |  4 ++++
+ src/ldo.c    |  2 +-
+ src/lstate.c |  1 +
+ src/lstate.h |  2 +-
+ 5 files changed, 22 insertions(+), 17 deletions(-)
+
+diff --git a/src/ldebug.c b/src/ldebug.c
+index 239affb..832b16c 100644
+--- a/src/ldebug.c
++++ b/src/ldebug.c
+@@ -34,9 +34,8 @@
+ #define noLuaClosure(f)		((f) == NULL || (f)->c.tt == LUA_TCCL)
+ 
+ 
+-/* Active Lua function (given call info) */
+-#define ci_func(ci)		(clLvalue((ci)->func))
+-
++/* inverse of 'pcRel' */
++#define invpcRel(pc, p)                ((p)->code + (pc) + 1)
+ 
+ static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
+                                     const char **name);
+@@ -71,20 +70,18 @@ static void swapextra (lua_State *L) {
+ 
+ /*
+ ** This function can be called asynchronously (e.g. during a signal).
+-** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by
+-** 'resethookcount') are for debug only, and it is no problem if they
+-** get arbitrary values (causes at most one wrong hook call). 'hookmask'
+-** is an atomic value. We assume that pointers are atomic too (e.g., gcc
+-** ensures that for all platforms where it runs). Moreover, 'hook' is
+-** always checked before being called (see 'luaD_hook').
++** Fields 'basehookcount' and 'hookcount' (set by 'resethookcount')
++** are for debug only, and it is no problem if they get arbitrary
++** values (causes at most one wrong hook call). 'hookmask' is an atomic
++** value. We assume that pointers are atomic too (e.g., gcc ensures that
++** for all platforms where it runs). Moreover, 'hook' is always checked
++** before being called (see 'luaD_hook').
+ */
+ LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
+   if (func == NULL || mask == 0) {  /* turn off hooks? */
+     mask = 0;
+     func = NULL;
+   }
+-  if (isLua(L->ci))
+-    L->oldpc = L->ci->u.l.savedpc;
+   L->hook = func;
+   L->basehookcount = count;
+   resethookcount(L);
+@@ -665,7 +662,10 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
+ void luaG_traceexec (lua_State *L) {
+   CallInfo *ci = L->ci;
+   lu_byte mask = L->hookmask;
++  const Proto *p = ci_func(ci)->p;
+   int counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
++  /* 'L->oldpc' may be invalid; reset it in this case */
++  int oldpc = (L->oldpc < p->sizecode) ? L->oldpc : 0;
+   if (counthook)
+     resethookcount(L);  /* reset count */
+   else if (!(mask & LUA_MASKLINE))
+@@ -677,15 +677,15 @@ void luaG_traceexec (lua_State *L) {
+   if (counthook)
+     luaD_hook(L, LUA_HOOKCOUNT, -1);  /* call count hook */
+   if (mask & LUA_MASKLINE) {
+-    Proto *p = ci_func(ci)->p;
+     int npc = pcRel(ci->u.l.savedpc, p);
+     int newline = getfuncline(p, npc);
+     if (npc == 0 ||  /* call linehook when enter a new function, */
+-        ci->u.l.savedpc <= L->oldpc ||  /* when jump back (loop), or when */
+-        newline != getfuncline(p, pcRel(L->oldpc, p)))  /* enter a new line */
++        ci->u.l.savedpc <= invpcRel(oldpc, p) ||  /* when jump back (loop), or when */
++        newline != getfuncline(p, oldpc))  /* enter a new line */
+       luaD_hook(L, LUA_HOOKLINE, newline);  /* call line hook */
++
++    L->oldpc = npc;  /* 'pc' of last call to line hook */
+   }
+-  L->oldpc = ci->u.l.savedpc;
+   if (L->status == LUA_YIELD) {  /* did hook yield? */
+     if (counthook)
+       L->hookcount = 1;  /* undo decrement to zero */
+diff --git a/src/ldebug.h b/src/ldebug.h
+index 0e31546..c224cc4 100644
+--- a/src/ldebug.h
++++ b/src/ldebug.h
+@@ -13,6 +13,10 @@
+ 
+ #define pcRel(pc, p)	(cast(int, (pc) - (p)->code) - 1)
+ 
++/* Active Lua function (given call info) */
++#define ci_func(ci)            (clLvalue((ci)->func))
++
++
+ #define getfuncline(f,pc)	(((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
+ 
+ #define resethookcount(L)	(L->hookcount = L->basehookcount)
+diff --git a/src/ldo.c b/src/ldo.c
+index 90b695f..f66ac1a 100644
+--- a/src/ldo.c
++++ b/src/ldo.c
+@@ -382,7 +382,7 @@ int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
+       luaD_hook(L, LUA_HOOKRET, -1);
+       firstResult = restorestack(L, fr);
+     }
+-    L->oldpc = ci->previous->u.l.savedpc;  /* 'oldpc' for caller function */
++    L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p);  /* 'oldpc' for caller function */
+   }
+   res = ci->func;  /* res == final position of 1st result */
+   L->ci = ci->previous;  /* back to caller */
+diff --git a/src/lstate.c b/src/lstate.c
+index 9194ac3..3573e36 100644
+--- a/src/lstate.c
++++ b/src/lstate.c
+@@ -236,6 +236,7 @@ static void preinit_thread (lua_State *L, global_State *g) {
+   L->nny = 1;
+   L->status = LUA_OK;
+   L->errfunc = 0;
++  L->oldpc = 0;
+ }
+ 
+ 
+diff --git a/src/lstate.h b/src/lstate.h
+index a469466..d75eadf 100644
+--- a/src/lstate.h
++++ b/src/lstate.h
+@@ -164,7 +164,6 @@ struct lua_State {
+   StkId top;  /* first free slot in the stack */
+   global_State *l_G;
+   CallInfo *ci;  /* call info for current function */
+-  const Instruction *oldpc;  /* last pc traced */
+   StkId stack_last;  /* last free slot in the stack */
+   StkId stack;  /* stack base */
+   UpVal *openupval;  /* list of open upvalues in this stack */
+@@ -174,6 +173,7 @@ struct lua_State {
+   CallInfo base_ci;  /* CallInfo for first level (C calling Lua) */
+   volatile lua_Hook hook;
+   ptrdiff_t errfunc;  /* current error handling function (stack index) */
++  int oldpc;  /* last pc traced */
+   int stacksize;
+   int basehookcount;
+   int hookcount;
+-- 
+2.13.3
+
diff --git a/recipes-wifi/lua/lua/lua.pc.in b/recipes-wifi/lua/lua/lua.pc.in
new file mode 100644
index 0000000..c27e86e
--- /dev/null
+++ b/recipes-wifi/lua/lua/lua.pc.in
@@ -0,0 +1,10 @@
+prefix=/usr
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: Lua
+Description: Lua language engine
+Version: @VERSION@
+Requires:
+Libs: -L${libdir} -llua -lm -ldl
+Cflags: -I${includedir}
diff --git a/recipes-wifi/lua/lua/run-ptest b/recipes-wifi/lua/lua/run-ptest
new file mode 100644
index 0000000..8e085e1
--- /dev/null
+++ b/recipes-wifi/lua/lua/run-ptest
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+cd test
+lua -e"_U=true" all.lua > lua-test.tmp
+
+echo "--- test output ---"
+cat lua-test.tmp
+echo ""
+echo ""
+echo "--- ptest result ---"
+
+grep "final OK \!\!\!" lua-test.tmp > /dev/null
+if [ $? -eq 0 ]; then
+   echo "PASS: lua"
+else
+   echo "FAIL: lua"
+fi
+
+rm -f lua-test.tmp
diff --git a/recipes-wifi/lua/lua/uclibc-pthread.patch b/recipes-wifi/lua/lua/uclibc-pthread.patch
new file mode 100644
index 0000000..f4cdc5d
--- /dev/null
+++ b/recipes-wifi/lua/lua/uclibc-pthread.patch
@@ -0,0 +1,13 @@
+Index: lua-5.1.4/src/Makefile                                                         
+===================================================================
+--- a/src/Makefile.orig	2013-10-22 22:17:19.929103523 -0400
++++ a/src/Makefile	2013-10-22 22:18:27.992104545 -0400
+@@ -9,7 +9,7 @@
+ CC= gcc
+ CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS)
+ LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
+-LIBS= -lm $(SYSLIBS) $(MYLIBS)
++LIBS= -lm -lpthread $(SYSLIBS) $(MYLIBS)
+ 
+ AR= ar rcu
+ RANLIB= ranlib
diff --git a/recipes-wifi/lua/lua_5.3.6.bb b/recipes-wifi/lua/lua_5.3.6.bb
new file mode 100644
index 0000000..342ed1b
--- /dev/null
+++ b/recipes-wifi/lua/lua_5.3.6.bb
@@ -0,0 +1,70 @@
+DESCRIPTION = "Lua is a powerful light-weight programming language designed \
+for extending applications."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://doc/readme.html;beginline=318;endline=352;md5=f43d8ee6bc4df18ef8b276439cc4a153"
+HOMEPAGE = "http://www.lua.org/"
+
+SRC_URI = "http://www.lua.org/ftp/lua-${PV}.tar.gz;name=tarballsrc \
+           file://lua.pc.in \
+           file://0001-Allow-building-lua-without-readline-on-Linux.patch \
+           file://CVE-2020-15888.patch \
+           file://CVE-2020-15945.patch \
+           file://0001-Fixed-bug-barriers-cannot-be-active-during-sweep.patch \
+           "
+
+# if no test suite matches PV release of Lua exactly, download the suite for the closest Lua release.
+PV_testsuites = "5.3.4"
+
+SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', \
+           'http://www.lua.org/tests/lua-${PV_testsuites}-tests.tar.gz;name=tarballtest \
+            file://run-ptest \
+           ', '', d)}"
+
+SRC_URI[tarballsrc.md5sum] = "83f23dbd5230140a3770d5f54076948d"
+SRC_URI[tarballsrc.sha256sum] = "fc5fd69bb8736323f026672b1b7235da613d7177e72558893a0bdcd320466d60"
+SRC_URI[tarballtest.md5sum] = "b14fe3748c1cb2d74e3acd1943629ba3"
+SRC_URI[tarballtest.sha256sum] = "b80771238271c72565e5a1183292ef31bd7166414cd0d43a8eb79845fa7f599f"
+
+inherit pkgconfig binconfig ptest
+
+PACKAGECONFIG ??= "readline"
+PACKAGECONFIG[readline] = ",,readline"
+
+UCLIBC_PATCHES += "file://uclibc-pthread.patch"
+SRC_URI_append_libc-uclibc = "${UCLIBC_PATCHES}"
+
+TARGET_CC_ARCH += " -fPIC ${LDFLAGS}"
+EXTRA_OEMAKE = "'CC=${CC} -fPIC' 'MYCFLAGS=${CFLAGS} -fPIC' MYLDFLAGS='${LDFLAGS}'"
+
+do_configure_prepend() {
+    sed -i -e s:/usr/local:${prefix}:g src/luaconf.h
+    sed -i -e s:lib/lua/:${baselib}/lua/:g src/luaconf.h
+}
+
+do_compile () {
+    oe_runmake ${@bb.utils.contains('PACKAGECONFIG', 'readline', 'linux', 'linux-no-readline', d)}
+}
+
+do_install () {
+    oe_runmake \
+        'INSTALL_TOP=${D}${prefix}' \
+        'INSTALL_BIN=${D}${bindir}' \
+        'INSTALL_INC=${D}${includedir}/' \
+        'INSTALL_MAN=${D}${mandir}/man1' \
+        'INSTALL_SHARE=${D}${datadir}/lua' \
+        'INSTALL_LIB=${D}${libdir}' \
+        'INSTALL_CMOD=${D}${libdir}/lua/5.3' \
+        install
+    install -d ${D}${libdir}/pkgconfig
+
+    sed -e s/@VERSION@/${PV}/ ${WORKDIR}/lua.pc.in > ${WORKDIR}/lua.pc
+    install -m 0644 ${WORKDIR}/lua.pc ${D}${libdir}/pkgconfig/
+    rmdir ${D}${datadir}/lua/5.3
+    rmdir ${D}${datadir}/lua
+}
+
+do_install_ptest () {
+        cp -R --no-dereference --preserve=mode,links -v ${WORKDIR}/lua-${PV_testsuites}-tests ${D}${PTEST_PATH}/test
+}
+
+BBCLASSEXTEND = "native nativesdk"
diff --git a/recipes-wifi/wireless-regdb/wireless-regdb_2023.09.01.bb b/recipes-wifi/wireless-regdb/wireless-regdb_2023.09.01.bb
index e016041..ebc282f 100644
--- a/recipes-wifi/wireless-regdb/wireless-regdb_2023.09.01.bb
+++ b/recipes-wifi/wireless-regdb/wireless-regdb_2023.09.01.bb
@@ -10,7 +10,7 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/files/patches:"
 require files/patches/patches.inc
 
-inherit bin_package allarch pythonnative
+inherit bin_package allarch ${@bb.utils.contains("DISTRO_FEATURES", "kirkstone", "python3native", "pythonnative", d)}
 
 S = "${WORKDIR}/${PN}-${PV}"