Yocto 2.3

Move OpenBMC to Yocto 2.3(pyro).

Tested: Built and verified Witherspoon and Palmetto images
Change-Id: I50744030e771f4850afc2a93a10d3507e76d36bc
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Resolves: openbmc/openbmc#2461
diff --git a/import-layers/meta-openembedded/meta-initramfs/README b/import-layers/meta-openembedded/meta-initramfs/README
index 906a859..9c05e1fd 100644
--- a/import-layers/meta-openembedded/meta-initramfs/README
+++ b/import-layers/meta-openembedded/meta-initramfs/README
@@ -12,7 +12,7 @@
 This layer depends on:
 
 URI: git://github.com/openembedded/oe-core.git
-branch: morty
+branch: pyro
 revision: HEAD
 
 
@@ -20,12 +20,12 @@
 -----------
 
 Send patches / pull requests to openembedded-devel@lists.openembedded.org
-with '[meta-initramfs]' in the subject.
+with '[meta-initramfs][pyro]' in the subject.
 
 When sending single patches, please using something like:
-'git send-email -M -1 --to openembedded-devel@lists.openembedded.org --subject-prefix=meta-initramfs][morty][PATCH'
+'git send-email -M -1 --to openembedded-devel@lists.openembedded.org --subject-prefix=meta-initramfs][pyro][PATCH'
 
-morty branch maintainer(s):
+pyro Branch Maintainer:
 Armin Kuster <akuster808@gmail.com>
 
 
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
index 45ff50d..835b307 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
@@ -3,10 +3,13 @@
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
+inherit image
+
 IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
 
 # avoid circular dependencies
 EXTRA_IMAGEDEPENDS = ""
+KERNELDEPMODDEPEND = ""
 
 # We really need just kexecboot, kexec and ubiattach
 IMAGE_INSTALL = "kexecboot kexec mtd-utils-ubifs"
@@ -18,7 +21,8 @@
 
 FEED_DEPLOYDIR_BASE_URI = ""
 LDCONFIGDEPEND = ""
-
 IMAGE_ROOTFS_EXTRA_SPACE = "0"
 
-inherit image
+# disable runtime dependency on run-postinsts -> update-rc.d
+ROOTFS_BOOTSTRAP_INSTALL = ""
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
index da3023f..6b845bd 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
@@ -7,7 +7,6 @@
 IMAGE_INSTALL = "kexecboot-klibc kexec-klibc ubiattach-klibc"
 
 python () {
-    if d.getVar('TARGET_ARCH', True) == "nios2":
+    if d.getVar('TARGET_ARCH') == "nios2":
         raise bb.parse.SkipPackage("'nios2' not supported arch")
 }
-
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
index 69f3872..085955c 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
@@ -57,4 +57,4 @@
 INHIBIT_DEFAULT_DEPS = "1"
 
 # Note: for qvga the label is currently limited to about 24 chars
-KEXECBOOT_LABEL ?= "${@d.getVar('DISTRO', True) or d.getVar('DISTRO_VERSION', True)}-${MACHINE}"
+KEXECBOOT_LABEL ?= "${@d.getVar('DISTRO') or d.getVar('DISTRO_VERSION')}-${MACHINE}"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
index c806370..b91f3fa 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
@@ -27,7 +27,7 @@
                "
 
 # RDEPEND on systemd optionally
-PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
+PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
 PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,,,systemd"
 
 EXTRA_OEMAKE += 'libdir=${prefix}/lib'
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
index 2f4afce..b285b2e 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
@@ -3,6 +3,10 @@
 require klibc.inc
 DEPENDS = "klibc"
 
+# no packaging for this crossscript
+PACKAGES = ""
+inherit nopackages
+
 FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
 
 SRC_URI += "file://use-env-for-perl.patch"
@@ -17,24 +21,14 @@
 do_install() {
     install -d ${D}${bindir_crossscripts}/
     install -m 0755 klcc/klcc ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
-    # Insert an unencoded path as a comment to trigger the sstate renaming functions
-    sed -i '2i #${STAGING_DIR_TARGET}' ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
+    # Turn the horribly encoded paths into something which sstate can transform using its ususal
+    # magic by removing all the crazy escaping.
+    sed -i -e "2i \$TARGETSYSROOT = '${STAGING_DIR_TARGET}';" \
+           -e "2i \$NATIVESYSROOT = '${STAGING_DIR_NATIVE}';" \
+           -e 's#${@d.getVar("STAGING_DIR_NATIVE", True).replace("/", "\\\\/").replace("-", "\\\\-").replace(".", "\\\\.")}#${NATIVESYSROOT}#g;' \
+           -e 's#${@d.getVar("STAGING_DIR_TARGET", True).replace("/", "\\\\/").replace("-", "\\\\-").replace(".", "\\\\.")}#${TARGETSYSROOT}#g' \
+        ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
 }
 
-SYSROOT_PREPROCESS_FUNCS += "klcc_sysroot_preprocess"
-
-klcc_sysroot_preprocess () {
-       sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
-}
-
-deltask do_package
-deltask do_packagedata
-deltask do_package_write_ipk
-deltask do_package_write_rpm
-deltask do_package_write_deb
-deltask do_package_write_tar
-
-SSTATE_SCAN_FILES = "*"
-EXTRA_STAGING_FIXMES = "MANGLEDSTAGINGDIRTARGET MANGLEDSTAGINGDIR"
-MANGLEDSTAGINGDIR = "${@d.getVar("STAGING_DIR", True).replace("/", "\\\\/").replace("-", "\\\\-")}"
-MANGLEDSTAGINGDIRTARGET = "${@d.getVar("STAGING_DIR_TARGET", True).replace("/", "\\\\/").replace("-", "\\\\-")}"
+SYSROOT_DIRS += "${bindir_crossscripts}"
+SSTATE_SCAN_FILES += "*-klcc"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch
new file mode 100644
index 0000000..8d1ec69
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch
@@ -0,0 +1,85 @@
+From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 15:17:29 -0700
+Subject: [PATCH] Define in_* structs for non-glibc system libs
+
+These defines and structs are required to be coming from
+userspace netinet/in.h, which is being overridden in klibc
+however, libc-compat.h from kernel is only written keeping
+glibc in mind, and does not provide adequate guards for musl
+to infer that these structs should be defined in linux/in.h
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+Index: git/usr/include/netinet/in.h
+===================================================================
+--- git.orig/usr/include/netinet/in.h
++++ git/usr/include/netinet/in.h
+@@ -5,6 +5,42 @@
+ #ifndef _NETINET_IN_H
+ #define _NETINET_IN_H
+ 
++#ifndef __GLIBC__
++#include <linux/libc-compat.h>
++
++#undef __UAPI_DEF_IN_ADDR
++#undef __UAPI_DEF_IN_IPPROTO
++#undef __UAPI_DEF_IN_PKTINFO
++#undef __UAPI_DEF_IP_MREQ
++#undef __UAPI_DEF_SOCKADDR_IN
++#undef __UAPI_DEF_IN_CLASS
++#undef __UAPI_DEF_IN6_ADDR
++#undef __UAPI_DEF_IN6_ADDR_ALT
++#undef __UAPI_DEF_SOCKADDR_IN6
++#undef __UAPI_DEF_IPV6_MREQ
++#undef __UAPI_DEF_IPPROTO_V6
++#undef __UAPI_DEF_IPV6_OPTIONS
++#undef __UAPI_DEF_IN6_PKTINFO
++#undef __UAPI_DEF_IP6_MTUINFO
++#undef __UAPI_DEF_IF_IFREQ
++
++#define __UAPI_DEF_IN_ADDR      1
++#define __UAPI_DEF_IN_IPPROTO   1
++#define __UAPI_DEF_IN_PKTINFO   1
++#define __UAPI_DEF_IP_MREQ      1
++#define __UAPI_DEF_SOCKADDR_IN  1
++#define __UAPI_DEF_IN_CLASS     1
++#define __UAPI_DEF_IN6_ADDR     1
++#define __UAPI_DEF_IN6_ADDR_ALT 1
++#define __UAPI_DEF_SOCKADDR_IN6 1
++#define __UAPI_DEF_IPV6_MREQ    1
++#define __UAPI_DEF_IPPROTO_V6   1
++#define __UAPI_DEF_IPV6_OPTIONS 1
++#define __UAPI_DEF_IN6_PKTINFO  1
++#define __UAPI_DEF_IP6_MTUINFO  1
++#define __UAPI_DEF_IF_IFREQ     1
++#endif
++
+ #include <klibc/extern.h>
+ #include <stdint.h>
+ #include <endian.h>		/* Must be included *before* <linux/in.h> */
+Index: git/usr/include/net/if.h
+===================================================================
+--- git.orig/usr/include/net/if.h
++++ git/usr/include/net/if.h
+@@ -1,6 +1,17 @@
+ #ifndef _NET_IF_H
+ #define _NET_IF_H
+ 
++#ifndef __GLIBC__
++#include <linux/libc-compat.h>
++#undef __UAPI_DEF_IF_IFREQ
++#define __UAPI_DEF_IF_IFREQ            1
++#undef __UAPI_DEF_IF_IFNAMSIZ
++#define __UAPI_DEF_IF_IFNAMSIZ         1
++#undef __UAPI_DEF_IF_IFMAP
++#define __UAPI_DEF_IF_IFMAP            1
++#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
++#endif
+ #include <sys/socket.h>
+ #include <sys/types.h>
+ #include <linux/if.h>
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
new file mode 100644
index 0000000..41a6b9e
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
@@ -0,0 +1,30 @@
+From 9ea19bd9636806a73bcf29cfcee40a268f91eb4c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 11 Jul 2017 08:09:52 -0700
+Subject: [PATCH] always use bfd linker
+
+its possible that distros choose to default to gold linker
+therefore explicitly asking for bfd linker would fix the
+linking issues on such distros
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index dc10fc5d..40647be4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -20,7 +20,7 @@ include $(srctree)/scripts/Kbuild.include
+ KLIBCROSS	?= $(CROSS_COMPILE)
+ export KLIBCROSS
+ export CC	:= $(KLIBCROSS)gcc
+-export LD	:= $(KLIBCROSS)ld
++export LD	:= $(KLIBCROSS)ld.bfd
+ export AR	:= $(KLIBCROSS)ar
+ export RANLIB	:= $(KLIBCROSS)ranlib
+ export STRIP	:= $(KLIBCROSS)strip
+-- 
+2.13.2
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
new file mode 100644
index 0000000..ae8c1f1
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
@@ -0,0 +1,31 @@
+From 2fff607fd0b5550e5072a6fffcbb01c29d5207d2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 13:51:25 -0700
+Subject: [PATCH] dash: Specify format string in fmtstr()
+
+Fixes build with hardening flags
+
+usr/dash/jobs.c:429:3: error: format not a string literal and no format arguments [-Werror=format-security]
+   col = fmtstr(s, 32, strsignal(st));
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ usr/dash/jobs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c
+index 009bbfee..299bcacc 100644
+--- a/usr/dash/jobs.c
++++ b/usr/dash/jobs.c
+@@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly)
+ 				goto out;
+ #endif
+ 		}
+-		col = fmtstr(s, 32, strsignal(st));
++		col = fmtstr(s, 32, "%s", strsignal(st));
+ #ifdef WCOREDUMP
+ 		if (WCOREDUMP(status)) {
+ 			col += fmtstr(s + col, 16, " (core dumped)");
+-- 
+2.13.2
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
new file mode 100644
index 0000000..1b033ac
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
@@ -0,0 +1,32 @@
+From ab060a57b41f989665ade20e813bbcb67f91f1f2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 15:56:28 -0700
+Subject: [PATCH] include linux/sysinfo.h directly
+
+This is done to avoid the kernel header linux/kernel.h to use
+__GLIBC__ define to decide on if libc implements sysinfo() API
+or not. Kernel headers should be independent of such assumptions
+but until its done in right place, change the local header
+override to avoid this assumption
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ usr/include/sys/sysinfo.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h
+index dba68dc6..d145c0b1 100644
+--- a/usr/include/sys/sysinfo.h
++++ b/usr/include/sys/sysinfo.h
+@@ -5,7 +5,7 @@
+ #ifndef _SYS_SYSINFO_H
+ #define _SYS_SYSINFO_H
+ 
+-#include <linux/kernel.h>
++#include <linux/sysinfo.h>
+ 
+ extern int sysinfo(struct sysinfo *info);
+ 
+-- 
+2.13.2
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
new file mode 100644
index 0000000..9791412
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
@@ -0,0 +1,29 @@
+From b4e120f5edf06e6df138b1804a8b5180584cea6b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 10 Jul 2017 20:42:50 -0700
+Subject: [PATCH] mkfifo: Implement mkfifo
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ usr/utils/mkfifo.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c
+index 5a758b2a..f1f577e6 100644
+--- a/usr/utils/mkfifo.c
++++ b/usr/utils/mkfifo.c
+@@ -26,6 +26,11 @@ static int make_fifo(char *dir)
+ 	return 0;
+ }
+ 
++int mkfifo (const char *__p, mode_t __m)
++{
++	return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0);
++}
++
+ int main(int argc, char *argv[])
+ {
+ 	int c, ret = 0;
+-- 
+2.13.2
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
index f00e31a..cd3f398 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
@@ -7,20 +7,28 @@
 DEPENDS = "linux-libc-headers perl-native"
 SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c"
 
-SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git"
-SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \
-                                 file://armv4-fix-v4bx.patch \
-                                 "
-SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \
-                                    file://armv4-fix-v4bx.patch \
-                                    "
-SRC_URI += "file://klibc-linux-libc-dev.patch \
-            file://staging.patch \
-            file://klcc-consider-sysroot.patch \
-            "
+SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \
+           ${ARMPATCHES} \
+           file://klibc-linux-libc-dev.patch \
+           file://staging.patch \
+           file://klcc-consider-sysroot.patch \
+           file://0001-dash-Specify-format-string-in-fmtstr.patch \
+           file://0001-Define-in_-structs-for-non-glibc-system-libs.patch \
+           file://0001-include-linux-sysinfo.h-directly.patch \
+           file://0001-mkfifo-Implement-mkfifo.patch \
+           file://0001-always-use-bfd-linker.patch \
+"
+
+ARMPATCHES ?= ""
+
+ARMPATCHES_arm = "file://klibc-config-eabi.patch \
+                  file://armv4-fix-v4bx.patch \
+                 "
+
 
 S = "${WORKDIR}/git"
 
+PARALLEL_MAKE = ""
 EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \
                 'CROSS_COMPILE=${TARGET_PREFIX}' \
                 'KLIBCKERNELSRC=${STAGING_DIR_TARGET}${exec_prefix}' \
@@ -29,9 +37,12 @@
                 'INSTALLROOT=${D}' \
                 'INSTALLDIR=${libdir}/klibc' \
                 'SHLIBDIR=${libdir}' \
+                '${KLIBCTHUMB}' \
+                'KLIBCOPTFLAGS=${TUNE_CCARGS}' \
                 "
 
 export FIX_ARMV4_EABI_BX = "${FIX_V4BX}"
+KLIBCTHUMB = "${@['CONFIG_KLIBC_THUMB=n', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}"
 
 do_configure () {
     ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
@@ -50,3 +61,6 @@
 KLIBC_ARCH_powerpc = "ppc"
 KLIBC_ARCH_powerpc64 = "ppc64"
 THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})"
+
+SECURITY_CFLAGS = "-fno-PIE -no-pie"
+SECURITY_LDFLAGS = "-no-pie"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb
index 8ca1ca7..8674077 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb
@@ -21,6 +21,7 @@
 S = "${WORKDIR}/git/"
 
 EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
+CFLAGS += "${TUNE_CCARGS}"
 
 do_install () {
 
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
new file mode 100644
index 0000000..a7600b3
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
@@ -0,0 +1,30 @@
+From 86b962e7c0de43b20b6210d059e4855ce87078bc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 13 Jul 2017 16:20:08 -0700
+Subject: [PATCH] Adjust the order of headers to fix build for musl
+
+Fixes
+kexec/ifdown.c:33:16: error: storage size of 'ifc' isn't known
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ kexec/ifdown.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/ifdown.c b/kexec/ifdown.c
+index 2215798..e13f777 100644
+--- a/kexec/ifdown.c
++++ b/kexec/ifdown.c
+@@ -16,8 +16,8 @@ char *v_ifdown = "@(#)ifdown.c  1.11  02-Jun-1998  miquels@cistron.nl";
+ #include <sys/time.h>
+ #include <errno.h>
+ 
+-#include <net/if.h>
+ #include <netinet/in.h>
++#include <net/if.h>
+ 
+ #define MAX_IFS	64
+ 
+-- 
+2.13.2
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb
index c9fec25..49c53a3 100644
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb
@@ -20,6 +20,7 @@
             file://sha256.patch \
             file://sysconf_nrprocessors.patch \
             file://fix-out-of-tree-build.patch \
+            file://0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch \
             "
 
 SRC_URI_append_arm = " file://arm_crashdump.patch"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot/revert-check-console.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot/revert-check-console.patch
deleted file mode 100644
index 5e5e8d9..0000000
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot/revert-check-console.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From a74e0bf51adcc867b73fc44050eb9bde985c9cba Mon Sep 17 00:00:00 2001
-From: Andrea Adami <andrea.adami@gmail.com>
-Date: Sun, 28 Feb 2016 01:09:19 +0100
-Subject: [PATCH] main.c: revert check on console device
-
-Fix kernel panic because of the missing /dev/console.
-
-Revert Yocto-specific : "check console device file on fs when booting".
-
-The initramfs used in this kernel needs to be of the smallest possible
-size so we save a few kb by deploying an empty /dev which is populated
-after boot by the init (kexecboot checks and recreates the devices
-with or without devtmpfs).
-
-Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
----
- init/main.c | 7 -------
- 1 file changed, 7 deletions(-)
-
-diff --git a/init/main.c b/init/main.c
-index d191d2a..9e64d70 100644
---- a/init/main.c
-+++ b/init/main.c
-@@ -976,7 +976,6 @@ static int __ref kernel_init(void *unused)
- 
- static noinline void __init kernel_init_freeable(void)
- {
--	struct stat console_stat;
- 	/*
- 	 * Wait until kthreadd is all set-up.
- 	 */
-@@ -1008,12 +1007,6 @@ static noinline void __init kernel_init_freeable(void)
- 
- 	do_basic_setup();
- 
--	/* Use /dev/console to infer if the rootfs is setup properly */
--	if (sys_newlstat((char __user *) "/dev/console", (struct stat __user *) &console_stat)
--			|| !S_ISCHR(console_stat.st_mode)) {
--		panic("/dev/console is missing or not a character device!\nPlease ensure your rootfs is properly configured\n");
--	}
--
- 	/* Open the /dev/console on the rootfs, this should never fail */
- 	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
- 		pr_err("Warning: unable to open an initial console.\n");
--- 
-1.9.1
-
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot_4.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot_4.4.bb
deleted file mode 100644
index 66e0e53..0000000
--- a/import-layers/meta-openembedded/meta-initramfs/recipes-kernel/linux/linux-yocto-tiny-kexecboot_4.4.bb
+++ /dev/null
@@ -1,29 +0,0 @@
-require recipes-kernel/linux/linux-yocto-tiny_${PV}.bb
-SUMMARY = "Yocto tiny kernel embedding a minimalistic kexecboot initramfs"
-
-SRC_URI += "file://revert-check-console.patch"
-
-PACKAGES = ""
-PROVIDES = ""
-
-KERNEL_IMAGE_BASE_NAME = "${KERNEL_IMAGETYPE}-yocto-tiny-kexecboot-${PV}-${MACHINE}"
-KERNEL_IMAGE_SYMLINK_NAME = "${KERNEL_IMAGETYPE}-yocto-tiny-kexecboot-${MACHINE}"
-
-INITRAMFS_IMAGE = "initramfs-kexecboot-klibc-image"
-INITRAMFS_TASK = "${INITRAMFS_IMAGE}:do_image_complete"
-
-# disable unneeded tasks
-do_shared_workdir[noexec] = "1"
-do_install[noexec] = "1"
-do_package[noexec] = "1"
-do_package_qa[noexec] = "1"
-do_packagedata[noexec] = "1"
-do_package_deb[noexec] = "1"
-do_package_ipk[noexec] = "1"
-do_package_rpm[noexec] = "1"
-do_package_tar[noexec] = "1"
-do_package_write_deb[noexec] = "1"
-do_package_write_ipk[noexec] = "1"
-do_package_write_rpm[noexec] = "1"
-do_package_write_tar[noexec] = "1"
-do_populate_sysroot[noexec] = "1"