summaryrefslogtreecommitdiffstats
path: root/external/meta-openembedded/meta-initramfs
diff options
context:
space:
mode:
authorToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:24:26 +0900
committerToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:24:26 +0900
commit5b80bfd7bffd4c20d80b7c70a7130529e9a755dd (patch)
treeb4bb18dcd1487dbf1ea8127e5671b7bb2eded033 /external/meta-openembedded/meta-initramfs
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
agl-basesystem
Diffstat (limited to 'external/meta-openembedded/meta-initramfs')
-rw-r--r--external/meta-openembedded/meta-initramfs/COPYING.MIT17
-rw-r--r--external/meta-openembedded/meta-initramfs/README36
-rw-r--r--external/meta-openembedded/meta-initramfs/classes/klibc.bbclass16
-rw-r--r--external/meta-openembedded/meta-initramfs/conf/layer.conf23
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb22
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb28
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb12
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh31
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb14
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm43
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb66
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb30
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch33
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb69
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch24
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch25
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch76
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest3
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb40
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_git.bb40
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb34
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch87
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch49
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch28
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch28
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch28
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch29
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch29
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch30
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch28
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-add-getrandom-syscall.patch27
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-static-utils-do-not-build-shared-binaries.patch213
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc_2.0.4-add-kexec_file_load-syscall.patch27
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch27
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch26
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch22
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-cross-accept-clang-options.patch19
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch24
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch29
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch151
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch25
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb18
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc58
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb14
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc85
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb24
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch40
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch326
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch34
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch38
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch56
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb52
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch25
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch29
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch92
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch30
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch134
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch71
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch37
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch32
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch57
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch47
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch38
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch31
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch36
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch152
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch29
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch34
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch61
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch40
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch44
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump.patch31
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch88
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc-purgatory-Makefile-remove-unknown-flags.patch34
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch35
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch30
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch30
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch36
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch43
-rw-r--r--external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb97
80 files changed, 3796 insertions, 0 deletions
diff --git a/external/meta-openembedded/meta-initramfs/COPYING.MIT b/external/meta-openembedded/meta-initramfs/COPYING.MIT
new file mode 100644
index 00000000..fb950dc6
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/COPYING.MIT
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/external/meta-openembedded/meta-initramfs/README b/external/meta-openembedded/meta-initramfs/README
new file mode 100644
index 00000000..ba2ba5f5
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/README
@@ -0,0 +1,36 @@
+meta-initramfs
+==============
+
+This layer contains the metadata necessary to build the klibc library and
+utilities (shared and static) plus other tools useful for the creation of
+small-sized initramfs.
+
+
+Dependencies
+------------
+
+This layer depends on:
+
+URI: git://github.com/openembedded/oe-core.git
+branch: thud
+revision: HEAD
+
+
+Maintenance
+-----------
+
+Send patches / pull requests to openembedded-devel@lists.openembedded.org
+with '[meta-initramfs][thud]' 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][thud][PATCH'
+
+Thud maintainer: Armin Kuster <akuster808@gmail.com>
+
+
+License
+-------
+
+All metadata is MIT licensed unless otherwise stated. Source code included
+in tree for individual recipes is under the LICENSE stated in each recipe
+(.bb file) unless otherwise stated.
diff --git a/external/meta-openembedded/meta-initramfs/classes/klibc.bbclass b/external/meta-openembedded/meta-initramfs/classes/klibc.bbclass
new file mode 100644
index 00000000..b7b72b72
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/classes/klibc.bbclass
@@ -0,0 +1,16 @@
+# klcc-cross depends on klibc
+DEPENDS =+ "klcc-cross"
+
+# Default for klcc is to build static binaries.
+# Set CC = "${TARGET_PREFIX}klcc -shared" to build the dynamic version.
+CC_forcevariable = "${TARGET_PREFIX}klcc ${TOOLCHAIN_OPTIONS}"
+CC_forcevariable_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc ${TOOLCHAIN_OPTIONS} -march=armv4 -mthumb-interwork"
+CC_append_armv7ve = " ${@' -mfloat-abi=${TUNE_CCARGS_MFLOAT}' if (d.getVar('TUNE_CCARGS_MFLOAT') != '') else ''}"
+CC_append_armv7a = " ${@' -mfloat-abi=${TUNE_CCARGS_MFLOAT}' if (d.getVar('TUNE_CCARGS_MFLOAT') != '') else ''}"
+
+CPP_forcevariable = "${CC} -E"
+
+# klcc uses own optimizations by default. See klcc(1) man file.
+export CFLAGS="${TUNE_CCARGS}"
+export CPPFLAGS="${TUNE_CCARGS}"
+export LDFLAGS="${TUNE_CCARGS}"
diff --git a/external/meta-openembedded/meta-initramfs/conf/layer.conf b/external/meta-openembedded/meta-initramfs/conf/layer.conf
new file mode 100644
index 00000000..bd92ddfb
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/conf/layer.conf
@@ -0,0 +1,23 @@
+# Layer configuration for meta-initramfs layer
+
+# We have a conf and classes directory, append to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes directory, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "meta-initramfs"
+BBFILE_PATTERN_meta-initramfs := "^${LAYERDIR}/"
+
+# Define the priority for recipes (.bb files) from this layer,
+# choosing carefully how this layer interacts with all of the
+# other layers.
+
+BBFILE_PRIORITY_meta-initramfs = "8"
+LAYERDEPENDS_meta-initramfs = "core"
+
+LAYERSERIES_COMPAT_meta-initramfs = "thud"
+
+SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
+ dracut->virtual/kernel \
+"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
new file mode 100644
index 00000000..be7350ad
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
@@ -0,0 +1,22 @@
+# Simple initramfs image. Mostly used for live images.
+DESCRIPTION = "Small image capable of booting a device. The kernel includes \
+the Minimal RAM-based Initial Root Filesystem (initramfs), which one can use \
+to check the hardware efficiently."
+
+PACKAGE_INSTALL = "initramfs-debug busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+export IMAGE_BASENAME = "initramfs-debug-image"
+IMAGE_LINGUAS = ""
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+IMAGE_ROOTFS_EXTRA_SPACE = "0"
+
+BAD_RECOMMENDATIONS += "busybox-syslog"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
new file mode 100644
index 00000000..2573eb48
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
@@ -0,0 +1,28 @@
+SUMMARY = "Initramfs image for kexecboot kernel"
+DESCRIPTION = "This image provides kexecboot (linux as bootloader) and helpers."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+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"
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+IMAGE_LINGUAS = ""
+
+FEED_DEPLOYDIR_BASE_URI = ""
+LDCONFIGDEPEND = ""
+IMAGE_ROOTFS_EXTRA_SPACE = "0"
+
+# disable runtime dependency on run-postinsts -> update-rc.d
+ROOTFS_BOOTSTRAP_INSTALL = ""
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
new file mode 100644
index 00000000..3a8d9f74
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
@@ -0,0 +1,12 @@
+require initramfs-kexecboot-image.bb
+
+SUMMARY = "Initramfs image for kexecboot kernel (klibc-static binaries)"
+
+# We really need just kexecboot, kexec and ubiattach
+# statically compiled against klibc
+IMAGE_INSTALL = "kexecboot-klibc kexec-klibc ubiattach-klibc"
+
+python () {
+ if d.getVar('TARGET_ARCH') == "nios2":
+ raise bb.parse.SkipRecipe("'nios2' not supported arch")
+}
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh b/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh
new file mode 100644
index 00000000..7edbd70c
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+do_mount_fs() {
+ grep -q "$1" /proc/filesystems || return
+ test -d "$2" || mkdir -p "$2"
+ mount -t "$1" "$1" "$2"
+}
+
+do_mknod() {
+ test -e "$1" || mknod "$1" "$2" "$3" "$4"
+}
+
+mkdir -p /proc
+mount -t proc proc /proc
+
+do_mount_fs sysfs /sys
+do_mount_fs debugfs /sys/kernel/debug
+do_mount_fs devtmpfs /dev
+do_mount_fs devpts /dev/pts
+do_mount_fs tmpfs /dev/shm
+
+mkdir -p /run
+mkdir -p /var/run
+
+do_mknod /dev/console c 5 1
+do_mknod /dev/null c 1 3
+do_mknod /dev/zero c 1 5
+
+exec sh </dev/console >/dev/console 2>/dev/console
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb
new file mode 100644
index 00000000..667690f8
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb
@@ -0,0 +1,14 @@
+SUMMARY = "Extremely basic live image init script"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+SRC_URI = "file://init-debug.sh"
+
+S = "${WORKDIR}"
+
+do_install() {
+ install -m 0755 ${WORKDIR}/init-debug.sh ${D}/init
+}
+
+inherit allarch
+
+FILES_${PN} += " /init "
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm
new file mode 100644
index 00000000..6e6fd776
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm
@@ -0,0 +1,43 @@
+/* XPM */
+static char * icon_xpm[] = {
+"32 32 8 1",
+" c None",
+". c #D6DBDE",
+"+ c #9BA6AE",
+"@ c #60727D",
+"# c #B8BFC5",
+"$ c #A9E8F6",
+"% c #12BCE4",
+"& c #57D2EC",
+" ",
+" ",
+" ",
+" .++@@@@++. ",
+" +@@@@@@@@@@@@+ ",
+" #@@@@@@@@@@@@@@@@# ",
+" +@@@@@@@@@@@@@@@@@@+ ",
+" .@@@@@@@@++##+@@@@@@@@@. ",
+" @@@@@@@. .@@@@@@@ ",
+" +@@@@@+ $$$$ #@@@@@+ ",
+" #@@@@@. $%%%%%%%%$ .@@@@@# ",
+" @@@@@. &%%%%%%%%%%& .@@@@@ ",
+" #@@@@+ %%%%%%%%%%%%%% +@@@@# ",
+" @@@@@ &%%%%%%%%%%%%%%& @@@@@ ",
+".@@@@. $%%%%%& $%%%%%& .@@@@.",
+"+@@@@ %%%%% $%%%%%& @@@@+",
+"+@@@+ %%%%$ $%%%%%& $$ +@@@+",
+"@@@@+ $%%%% $%%%%%& $%$ +@@@@",
+"@@@@# &%%%& &%%%%& $%%& #@@@@",
+"@@@@. &%%%& %%%%& $%%%& .@@@@",
+"@@@@# $%%%& &%%& &%%%$ #@@@@",
+"+@@@+ $%%%% %%%%$ +@@@+",
+"+@@@@ %%%%& &%%%% @@@@+",
+"#@@@@ &%%%%& &%%%%& @@@@#",
+" @@@@+ %%%%%%&$$&%%%%%% +@@@@ ",
+" +@@@@. $%%%%%%%%%%%%%%$ .@@@@+ ",
+" .@@@@@ $%%%%%%%%%%%%$ @@@@@. ",
+" #++++. &%%%%%%%%& .++++# ",
+" $&&%%&&$ ",
+" ",
+" ",
+" "};
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
new file mode 100644
index 00000000..f90e2344
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
@@ -0,0 +1,66 @@
+SUMMARY = "Configuration files for kexecboot"
+DESCRIPTION = "Default icon and boot.cfg for kexecboot linux-as-bootloader."
+SECTION = "base"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "file://icon.xpm"
+
+S = "${WORKDIR}"
+
+do_install_prepend () {
+echo '# /boot/boot.cfg - KEXECBOOT configuration file.
+#
+# First kernel stanza.
+# Show this label in kexecboot menu.
+#
+LABEL=${KEXECBOOT_LABEL}
+#
+# Specify full kernel path on target.
+KERNEL=/boot/${KERNEL_IMAGETYPE}
+#
+# Specify which device tree blob to use
+# DTB=/boot/my-own-dtb
+#
+# Append this tags to the kernel cmdline.
+APPEND=${CMDLINE} ${CMDLINE_DEBUG}
+#
+# Overwrite kernel command line instead of appending to it
+# CMDLINE=console=/dev/tty0 root=/dev/sdb1
+#
+# Specify optional initrd/initramfs.
+# INITRD=/boot/initramfs.cpio.gz
+#
+# Specify full path for a custom icon for the menu-item.
+# If not set, use device-icons as default (NAND, SD, CF, ...).
+# ICON=/boot/icon.xpm
+#
+# Priority of item in kexecboot menu.
+# Items with highest priority will be shown at top of menu.
+# Default: 0 (lowest, ordered by device ordering)
+# PRIORITY=10
+#
+#
+# Second kernel stanza.
+# LABEL=${KEXECBOOT_LABEL}-test
+# KERNEL=/boot/${KERNEL_IMAGETYPE}-test
+# APPEND=${CMDLINE}
+#' > ${S}/boot.cfg
+}
+do_install () {
+ install -d ${D}/boot
+ install -m 0644 boot.cfg ${D}/boot/boot.cfg
+ install -m 0644 icon.xpm ${D}/boot/icon.xpm
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES_${PN} += "/boot/*"
+
+CMDLINE ?= ""
+CMDLINE_DEBUG ?= "quiet"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Note: for qvga the label is currently limited to about 24 chars
+KEXECBOOT_LABEL ?= "${@d.getVar('DISTRO') or d.getVar('DISTRO_VERSION')}-${MACHINE}"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb
new file mode 100644
index 00000000..6d79e8f8
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb
@@ -0,0 +1,30 @@
+SUMMARY = "kexecboot linux-as-bootloader"
+DESCRIPTION = "kexecboot is a graphical linux-as-bootloader implementation based on kexec."
+HOMEPAGE = "http://kexecboot.org"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+PV = "0.6+git${SRCPV}"
+S = "${WORKDIR}/git"
+SRC_URI = "git://github.com/kexecboot/kexecboot.git"
+SRCREV = "4c01d6960aa6a9d03675605062469ab777fa2b01"
+inherit autotools
+
+EXTRA_OECONF = "--enable-textui --enable-delay=2 --enable-evdev-rate=1000,250"
+
+do_install () {
+ install -D -m 0755 ${B}/src/kexecboot ${D}${bindir}/kexecboot
+ install -d ${D}/proc
+ install -d ${D}/mnt
+ install -d ${D}/dev
+ install -d ${D}/sys
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES_${PN} += " ${bindir}/kexecboot /init /proc /mnt /dev /sys"
+
+pkg_postinst_${PN} () {
+ ln -sf ${bindir}/kexecboot $D/init
+}
+
+BBCLASSEXTEND = "klibc"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch
new file mode 100644
index 00000000..32714038
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch
@@ -0,0 +1,33 @@
+From 06011ce55b1e892e863568a73d64eebc6389544f Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 13 Jul 2017 17:14:05 -0700
+Subject: [PATCH] util.h: include <sys/reg.h> when libc != glibc
+
+For musl libc it is required to include <sys/reg.h> to
+have __WORDSIZE defined to e.g. 32 for arm*-musl.
+
+Taken from void-linux
+https://github.com/voidlinux/void-packages/blob/master/srcpkgs/dracut/patches/musl-__wordsize.patch
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ install/util.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/install/util.h b/install/util.h
+index 2ad3254d..062626ec 100644
+--- a/install/util.h
++++ b/install/util.h
+@@ -36,6 +36,9 @@
+ #include <sys/stat.h>
+ #include <dirent.h>
+ #include <sys/resource.h>
++#if !defined(__GLIBC__)
++#include <sys/reg.h>
++#endif
+
+ #include "macro.h"
+
+--
+2.13.2
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
new file mode 100644
index 00000000..dd2e8bbb
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
@@ -0,0 +1,69 @@
+SUMMARY = "Initramfs generator using udev"
+HOMEPAGE = "https://dracut.wiki.kernel.org/index.php/Main_Page"
+DESCRIPTION = "Dracut is an event driven initramfs infrastructure. dracut (the tool) is used to create an initramfs image by copying tools and files from an installed system and combining it with the dracut framework, usually found in /usr/lib/dracut/modules.d."
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+PE = "1"
+PV = "049"
+
+# v048 tag
+SRCREV = "225e4b94cbdb702cf512490dcd2ad9ca5f5b22c1"
+SRC_URI = "git://git.kernel.org/pub/scm/boot/dracut/dracut.git;protocol=http \
+ file://0001-util.h-include-sys-reg.h-when-libc-glibc.patch \
+ "
+
+DEPENDS += "kmod"
+DEPENDS_append_libc-musl = " fts"
+
+inherit bash-completion pkgconfig
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--prefix=${prefix} \
+ --libdir=${prefix}/lib \
+ --datadir=${datadir} \
+ --sysconfdir=${sysconfdir} \
+ --sbindir=${sbindir} \
+ --disable-documentation \
+ --bindir=${bindir} \
+ --includedir=${includedir} \
+ --localstatedir=${localstatedir} \
+ "
+
+# RDEPEND on systemd optionally
+PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,,,systemd"
+
+EXTRA_OEMAKE += 'libdir=${prefix}/lib LDLIBS="${LDLIBS}"'
+
+LDLIBS_append_libc-musl = " -lfts"
+
+do_configure() {
+ ./configure ${EXTRA_OECONF}
+}
+
+do_install() {
+ oe_runmake install DESTDIR=${D}
+ # Its Makefile uses cp -arx to install modules.d, so fix the owner
+ # to root:root
+ chown -R root:root ${D}/${prefix}/lib/dracut/modules.d
+}
+
+FILES_${PN} += "${prefix}/lib/kernel \
+ ${prefix}/lib/dracut \
+ ${systemd_unitdir} \
+ "
+FILES_${PN}-dbg += "${prefix}/lib/dracut/.debug"
+
+CONFFILES_${PN} += "${sysconfdir}/dracut.conf"
+
+RDEPENDS_${PN} = "findutils cpio util-linux-blkid util-linux-getopt util-linux bash ldd"
+
+# This could be optimized a bit, but let's avoid non-booting systems :)
+RRECOMMENDS_${PN} = " \
+ kernel-modules \
+ busybox \
+ coreutils \
+ "
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch
new file mode 100644
index 00000000..dfbe7ba6
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch
@@ -0,0 +1,24 @@
+From b7b3caa9b5c8abcd3c371d0683001cd681e104b3 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 15 Jul 2017 10:19:22 -0700
+Subject: [PATCH 1/2] Add another variable LIBS to provides libraries from env
+
+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 cc7e823..ae30a07 100644
+--- a/Makefile
++++ b/Makefile
+@@ -31,7 +31,7 @@ ifneq ($(VERBOSE_TEST),)
+ VERBOSE_TEST="--verbose"
+ endif
+
+-grubby_LIBS = -lblkid -lpopt
++grubby_LIBS = -lblkid -lpopt ${LIBS}
+
+ all: grubby
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch
new file mode 100644
index 00000000..de8133a3
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch
@@ -0,0 +1,25 @@
+From 8f844ac7f44b8dc428d06cd6958c5f32d383d01c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 15 Jul 2017 10:19:50 -0700
+Subject: [PATCH 2/2] include paths.h for _PATH_MOUNTED
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ grubby.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/grubby.c b/grubby.c
+index 47a1a15..59f74a9 100644
+--- a/grubby.c
++++ b/grubby.c
+@@ -34,6 +34,7 @@
+ #include <libgen.h>
+ #include <execinfo.h>
+ #include <signal.h>
++#include <paths.h>
+ #include <blkid/blkid.h>
+
+ #include "log.h"
+--
+2.13.3
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch
new file mode 100644
index 00000000..e693916e
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch
@@ -0,0 +1,76 @@
+From 15f0572f2f456c2c1b700bc790d9ce7a5c13cc74 Mon Sep 17 00:00:00 2001
+From: Jackie Huang <jackie.huang@windriver.com>
+Date: Tue, 4 Aug 2015 23:54:41 -0700
+Subject: [PATCH] rename grub2-editenv to grub-editenv
+
+We don't use the name grub2-editenv for grub2.
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+
+---
+ grubby.c | 4 ++--
+ test.sh | 8 ++++----
+ 2 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/grubby.c b/grubby.c
+index 396041a..3ceae69 100644
+--- a/grubby.c
++++ b/grubby.c
+@@ -301,7 +301,7 @@ static char *grub2GetEnv(struct configFileInfo *info, char *name)
+ char *ret = NULL;
+ char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv";
+ int rc =
+- asprintf(&s, "grub2-editenv %s list | grep '^%s='", envFile, name);
++ asprintf(&s, "grub-editenv %s list | grep '^%s='", envFile, name);
+
+ if (rc < 0)
+ return NULL;
+@@ -373,7 +373,7 @@ static int grub2SetEnv(struct configFileInfo *info, char *name, char *value)
+ if (!value)
+ return -1;
+
+- rc = asprintf(&s, "grub2-editenv %s set '%s=%s'", envFile, name, value);
++ rc = asprintf(&s, "grub-editenv %s set '%s=%s'", envFile, name, value);
+ free(value);
+ if (rc < 0)
+ return -1;
+diff --git a/test.sh b/test.sh
+index 33d24cf..009479c 100755
+--- a/test.sh
++++ b/test.sh
+@@ -573,7 +573,7 @@ if [ "$testgrub2" == "y" ]; then
+ --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \
+ --boot-filesystem=/boot/
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64"
+
+ # copy a stanza and add arguments as well, while using --set-index=
+@@ -627,7 +627,7 @@ if [ "$testgrub2" == "y" ]; then
+ --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
+ --copy-default
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64"
+
+ testing="GRUB2 add kernel with default=saved_entry and a terrible title"
+@@ -640,13 +640,13 @@ if [ "$testgrub2" == "y" ]; then
+ testing="GRUB2 set default with default=saved_entry and a terrible name"
+ grub2Test grub2.9 add/g2-1.9 --env grubenv.1 --set-default-index=0
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ 'saved_entry=Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)'
+
+ testing="GRUB2 set default with default=saved_entry"
+ grub2Test grub2.8 add/g2-1.8 --env grubenv.1 --set-default-index=0
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=title"
+
+ testing="GRUB2 --default-index with default=saved_entry"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest
new file mode 100644
index 00000000..b06ac594
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+./test.sh -v
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb
new file mode 100644
index 00000000..dc3a70bb
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb
@@ -0,0 +1,40 @@
+SUMMARY = "A command line tool for updating and displaying info about boot loaders"
+DESCRIPTION = "grubby is a command line tool for updating and displaying information \
+about the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc) and \
+zipl (s390) boot loaders. It is primarily designed to be used from scripts which install \
+new kernels and need to find information about the current boot environment. \
+"
+HOMEPAGE = "https://github.com/rhboot/grubby"
+LICENSE = "GPLv2+"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=892f569a555ba9c07a568a7c0c4fa63a"
+
+DEPENDS = "popt util-linux"
+DEPENDS_append_libc-musl = " libexecinfo"
+
+S = "${WORKDIR}/git"
+SRCREV = "79c5cfa02c567efdc5bb18cdd584789e2e35aa23"
+SRC_URI = "git://github.com/rhboot/grubby.git;protocol=https; \
+ file://grubby-rename-grub2-editenv-to-grub-editenv.patch \
+ file://run-ptest \
+ file://0001-Add-another-variable-LIBS-to-provides-libraries-from.patch \
+ file://0002-include-paths.h-for-_PATH_MOUNTED.patch \
+ "
+
+RDEPENDS_${PN} += "dracut"
+
+inherit autotools-brokensep ptest
+
+EXTRA_OEMAKE = "-e 'CC=${CC}' 'LDFLAGS=${LDFLAGS}' LIBS='${LIBS}'"
+
+LIBS_libc-musl = "-lexecinfo"
+LIBS ?= ""
+do_install_ptest() {
+ install -d ${D}${PTEST_PATH}
+ cp -r ${S}/test ${S}/test.sh ${D}${PTEST_PATH}
+ sed -i 's|./grubby|grubby|' ${D}${PTEST_PATH}/test.sh
+}
+
+RDEPENDS_${PN}-ptest = "util-linux-getopt bash"
+
+COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux|freebsd.*)'
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_git.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_git.bb
new file mode 100644
index 00000000..8430b7e1
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_git.bb
@@ -0,0 +1,40 @@
+SUMMARY = "A command line tool for updating and displaying info about boot loaders"
+DESCRIPTION = "grubby is a command line tool for updating and displaying information \
+about the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc) and \
+zipl (s390) boot loaders. It is primarily designed to be used from scripts which install \
+new kernels and need to find information about the current boot environment. \
+"
+HOMEPAGE = "https://github.com/rhboot/grubby"
+LICENSE = "GPLv2+"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=892f569a555ba9c07a568a7c0c4fa63a"
+
+DEPENDS = "popt util-linux"
+DEPENDS_append_libc-musl = " libexecinfo"
+
+S = "${WORKDIR}/git"
+SRCREV = "a1d2ae93408c3408e672d7eba4550fdf27fb0201"
+SRC_URI = "git://github.com/rhboot/grubby.git;protocol=https; \
+ file://grubby-rename-grub2-editenv-to-grub-editenv.patch \
+ file://run-ptest \
+ file://0001-Add-another-variable-LIBS-to-provides-libraries-from.patch \
+ file://0002-include-paths.h-for-_PATH_MOUNTED.patch \
+ "
+
+RDEPENDS_${PN} += "dracut"
+
+inherit autotools-brokensep ptest
+
+EXTRA_OEMAKE = "-e 'CC=${CC}' 'LDFLAGS=${LDFLAGS}' LIBS='${LIBS}'"
+
+LIBS_libc-musl = "-lexecinfo"
+LIBS ?= ""
+do_install_ptest() {
+ install -d ${D}${PTEST_PATH}
+ cp -r ${S}/test ${S}/test.sh ${D}${PTEST_PATH}
+ sed -i 's|./grubby|grubby|' ${D}${PTEST_PATH}/test.sh
+}
+
+RDEPENDS_${PN}-ptest = "util-linux-getopt bash"
+
+COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux|freebsd.*)'
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
new file mode 100644
index 00000000..b285b2e8
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
@@ -0,0 +1,34 @@
+SUMMARY = "The klcc crosscompiler for klibc"
+
+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"
+
+# disable task already run in klibc recipe
+do_configure[noexec] = "1"
+
+do_compile() {
+ oe_runmake 'INSTALLDIR=${STAGING_DIR_TARGET}${libdir}/klibc' klcc
+}
+
+do_install() {
+ install -d ${D}${bindir_crossscripts}/
+ install -m 0755 klcc/klcc ${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_DIRS += "${bindir_crossscripts}"
+SSTATE_SCAN_FILES += "*-klcc"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch b/external/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 00000000..e7a0cce8
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch
@@ -0,0 +1,87 @@
+From 57e3a60b23891905733bfea7a1cb78c2377cc524 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/net/if.h | 11 +++++++++++
+ usr/include/netinet/in.h | 36 ++++++++++++++++++++++++++++++++++++
+ 2 files changed, 47 insertions(+)
+
+diff --git a/usr/include/net/if.h b/usr/include/net/if.h
+index 116a176..6246b12 100644
+--- a/usr/include/net/if.h
++++ b/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/usr/include/netinet/in.h b/usr/include/netinet/in.h
+index 2952bb2..0c95bc9 100644
+--- a/usr/include/netinet/in.h
++++ b/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> */
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch
new file mode 100644
index 00000000..eee144dc
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-ulocked_-fgets-fread-fwrite-aliases.patch
@@ -0,0 +1,49 @@
+From 241f423a015279cb29b7ad1a34386ef1c32007fc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Dec 2018 16:47:16 -0800
+Subject: [PATCH] Define ulocked_{fgets|fread|fwrite} aliases
+
+latest clang converts the normal calls to the unlocked variant
+equivalents
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Cc: Andrea Adami <andrea.adami@gmail.com>
+---
+ usr/klibc/fgets.c | 2 ++
+ usr/klibc/fread2.c | 2 ++
+ usr/klibc/fwrite2.c | 2 ++
+ 3 files changed, 6 insertions(+)
+
+diff --git a/usr/klibc/fgets.c b/usr/klibc/fgets.c
+index dbf742c6..2e9fcb65 100644
+--- a/usr/klibc/fgets.c
++++ b/usr/klibc/fgets.c
+@@ -25,3 +25,5 @@ char *fgets(char *s, int n, FILE *f)
+
+ return s;
+ }
++char *fgets_unlocked(char *s, int n, FILE *f)
++ __alias("fgets");
+diff --git a/usr/klibc/fread2.c b/usr/klibc/fread2.c
+index 7dca56b1..5c234766 100644
+--- a/usr/klibc/fread2.c
++++ b/usr/klibc/fread2.c
+@@ -11,3 +11,5 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE * f)
+ {
+ return _fread(ptr, size * nmemb, f) / size;
+ }
++size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *f)
++ __alias("fread");
+diff --git a/usr/klibc/fwrite2.c b/usr/klibc/fwrite2.c
+index cebc017c..3e0bb57d 100644
+--- a/usr/klibc/fwrite2.c
++++ b/usr/klibc/fwrite2.c
+@@ -11,3 +11,5 @@ size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * f)
+ {
+ return _fwrite(ptr, size * nmemb, f) / size;
+ }
++size_t fwrite_unlocked(void *ptr, size_t size, size_t nmemb, FILE *f)
++ __alias("fwrite");
+--
+2.19.2
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch
new file mode 100644
index 00000000..181dcfb6
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch
@@ -0,0 +1,28 @@
+From 4b4147b76518d31a88fb2c58cdbf2236e159a25c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 8 Sep 2017 23:10:54 -0700
+Subject: [PATCH] Kbuild.klibc: Add path to compiler headers via -isystem
+
+We need to include this path so it can find compiler headers e.g.
+stdarg.h which is called from wrapper stdarg.h using include_next
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ scripts/Kbuild.klibc | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
+index 101f86f..1d5cdc4 100644
+--- a/scripts/Kbuild.klibc
++++ b/scripts/Kbuild.klibc
+@@ -105,7 +105,8 @@ KLIBCOBJCOPY := $(OBJCOPY)
+ KLIBCOBJDUMP := $(OBJDUMP)
+
+ # klibc include paths
+-KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
++KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
++ -isystem $(shell $(CC) -print-file-name=include) \
+ -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \
+ -I$(KLIBCINC)/bits$(KLIBCBITSIZE) \
+ -I$(KLIBCOBJ)/../include \
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch
new file mode 100644
index 00000000..1ba05a81
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch
@@ -0,0 +1,28 @@
+From b6185401fc3daa7fa8ba2b84db3e4da3b94a9867 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 26 Jul 2017 16:13:16 -0700
+Subject: [PATCH] Kbuild.klibc: Use -print-libgcc-file-name instead of
+ --print-libgcc
+
+-print-libgcc-file-name works with clang and gcc unlike --print-libgcc
+which is gcc specific
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ scripts/Kbuild.klibc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
+index f500d53..101f86f 100644
+--- a/scripts/Kbuild.klibc
++++ b/scripts/Kbuild.klibc
+@@ -128,7 +128,7 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \
+ KLIBCAFLAGS += -D__ASSEMBLY__ $(KLIBCCFLAGS)
+ KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note
+
+-KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
++KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) -print-libgcc-file-name)
+ KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
+ KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
+ KLIBCLIBC := $(KLIBCOBJ)/libc.a
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
new file mode 100644
index 00000000..de04d691
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
@@ -0,0 +1,28 @@
+From 63ab5102d6ef362a597941e62470bf19e6f1652b 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 dc10fc5..40647be 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
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch
new file mode 100644
index 00000000..fcf4f891
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch
@@ -0,0 +1,29 @@
+From ebd2b0e414c98467156b961abb470b5d07f37ea8 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 29 Sep 2017 23:11:53 -0700
+Subject: [PATCH] arm: Do not set a fallback march and mtune
+
+In OE we pass the options explicitly, there is
+no need to set it inside the makefiles, we will
+need to compute values for CPU_ARCH and CPU_TUNE
+which is a bit harder in OE
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/klibc/arch/arm/MCONFIG | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/klibc/arch/arm/MCONFIG b/usr/klibc/arch/arm/MCONFIG
+index 303c6ac..48d2685 100644
+--- a/usr/klibc/arch/arm/MCONFIG
++++ b/usr/klibc/arch/arm/MCONFIG
+@@ -10,7 +10,7 @@
+ CPU_ARCH ?= armv4
+ CPU_TUNE ?= strongarm
+
+-KLIBCOPTFLAGS += -Os -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
++KLIBCOPTFLAGS += -Os
+ KLIBCBITSIZE = 32
+ KLIBCREQFLAGS += -fno-exceptions
+ KLIBCSTRIPFLAGS += -R .ARM.exidx
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
new file mode 100644
index 00000000..46a23987
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
@@ -0,0 +1,29 @@
+From 8beffe501c1ac5b35d62004735c4157c74183901 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 009bbfe..299bcac 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)");
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
new file mode 100644
index 00000000..04c97fc5
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
@@ -0,0 +1,30 @@
+From d966d52d1e569cbc2293d841285e2b8941f28c61 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 dba68dc..d145c0b 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);
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch
new file mode 100644
index 00000000..94818e36
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch
@@ -0,0 +1,28 @@
+From cdc6edc2cfcd0ce88d6e66654d605dad303b1a75 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 11 Sep 2018 17:03:36 -0700
+Subject: [PATCH] klibc/Kbuild: Accept EXTRA_KLIBCAFLAGS
+
+For passing additional assembler flags
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ usr/klibc/Kbuild | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
+index 98caf2e9..b34521e0 100644
+--- a/usr/klibc/Kbuild
++++ b/usr/klibc/Kbuild
+@@ -168,7 +168,8 @@ $(SOHASH): $(SOLIB) $(SOLIB).hash
+ targets += interp.o
+
+ quiet_cmd_interp = BUILD $@
+- cmd_interp = $(KLIBCCC) $(klibccflags) -D__ASSEMBLY__ \
++ cmd_interp = $(KLIBCCC) $(klibccflags) $(EXTRA_KLIBCAFLAGS) \
++ -D__ASSEMBLY__ \
+ -DLIBDIR=\"$(SHLIBDIR)\" \
+ -DSOHASH=\"$(SOLIBHASH)\" \
+ -c -o $@ $<
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-add-getrandom-syscall.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-add-getrandom-syscall.patch
new file mode 100644
index 00000000..0768f6d5
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-add-getrandom-syscall.patch
@@ -0,0 +1,27 @@
+From e4d5d5224609d7d5c824dd231f5baec868befdfa Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 4 Sep 2018 23:56:00 +0200
+Subject: [PATCH 1/1] klibc: add getrandom() syscall
+
+needed by latest kexec-tools for qemuarm64 (kashan)
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ usr/klibc/SYSCALLS.def | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
+index 6b3bf4c..d4184ba 100644
+--- a/usr/klibc/SYSCALLS.def
++++ b/usr/klibc/SYSCALLS.def
+@@ -274,6 +274,7 @@ int syslog::klogctl(int, char *, int);
+ int sysinfo(struct sysinfo *);
+ long kexec_load(void *, unsigned long, struct kexec_segment *, unsigned long);
+ <x86_64,ppc64,s390x> long kexec_file_load(int, int, unsigned long, const char *, unsigned long);
++ssize_t getrandom(void *, size_t, unsigned int);
+
+ /*
+ * Low-level I/O (generally architecture-specific);
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-static-utils-do-not-build-shared-binaries.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-static-utils-do-not-build-shared-binaries.patch
new file mode 100644
index 00000000..2f7cd355
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc-static-utils-do-not-build-shared-binaries.patch
@@ -0,0 +1,213 @@
+From c034dceae17b7d8d437871afe5eba55a55434222 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 10 Oct 2018 00:48:31 +0200
+Subject: [PATCH] klibc-static-utils: do not build shared binaries
+
+We were building some shared utilities and this was leading to linker errors
+for x86 with security flags enabled.
+
+Fix
+ i586-oe-linux-musl-ld.bfd: discarded output section: `.got.plt'
+
+Upstream-Status: Inappropriate [Embedded Specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ usr/dash/Kbuild | 6 +-----
+ usr/kinit/Kbuild | 4 +---
+ usr/kinit/fstype/Kbuild | 4 +---
+ usr/kinit/ipconfig/Kbuild | 4 +---
+ usr/kinit/nfsmount/Kbuild | 4 +---
+ usr/kinit/resume/Kbuild | 5 +----
+ usr/kinit/run-init/Kbuild | 5 +----
+ usr/utils/Kbuild | 7 ++-----
+ 8 files changed, 9 insertions(+), 30 deletions(-)
+
+diff --git a/usr/dash/Kbuild b/usr/dash/Kbuild
+index 1a6920a..b3a4e64 100644
+--- a/usr/dash/Kbuild
++++ b/usr/dash/Kbuild
+@@ -25,12 +25,8 @@ gen-h-files := builtins.h nodes.h syntax.h token.h
+
+ static-y := sh
+
+-# The shared binary
+-shared-y := sh.shared
+-sh.shared-y := $(sh-y)
+-
+ # For cleaning
+-targets := sh sh.g sh.shared sh.shared.g $(gen-o-files)
++targets := sh sh.g $(gen-o-files)
+
+ # explicit dependency for all generated files
+ $(addprefix $(obj)/, $(sh-y)): $(addprefix $(obj)/, $(gen-h-files))
+diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
+index f7fdccd..8db06ab 100644
+--- a/usr/kinit/Kbuild
++++ b/usr/kinit/Kbuild
+@@ -18,8 +18,6 @@ kinit-y += fstype/
+ kinit-y += resume/
+
+ static-y := kinit
+-shared-y := kinit.shared
+-kinit.shared-y := $(kinit-y)
+
+ # Additional include paths files
+ KLIBCCFLAGS += -I$(srctree)/$(src)/fstype \
+@@ -29,7 +27,7 @@ KLIBCCFLAGS += -I$(srctree)/$(src)/fstype \
+ -I$(srctree)/$(src)/run-init
+
+ # Cleaning
+-targets += kinit kinit.g kinit.shared kinit.shared.g
++targets += kinit kinit.g
+ subdir- := fstype ipconfig nfsmount resume run-init
+
+
+diff --git a/usr/kinit/fstype/Kbuild b/usr/kinit/fstype/Kbuild
+index 367611d..8d453ea 100644
+--- a/usr/kinit/fstype/Kbuild
++++ b/usr/kinit/fstype/Kbuild
+@@ -3,7 +3,6 @@
+ #
+
+ static-y := static/fstype
+-shared-y := shared/fstype
+
+ # common .o files
+ objs := main.o fstype.o
+@@ -16,8 +15,7 @@ lib-y := $(objs)
+
+ # .o files used to built executables
+ static/fstype-y := $(objs)
+-shared/fstype-y := $(objs)
+
+ # Cleaning
+-clean-dirs := static shared
++clean-dirs := static
+
+diff --git a/usr/kinit/ipconfig/Kbuild b/usr/kinit/ipconfig/Kbuild
+index eb1d472..ef87e7e 100644
+--- a/usr/kinit/ipconfig/Kbuild
++++ b/usr/kinit/ipconfig/Kbuild
+@@ -3,7 +3,6 @@
+ #
+
+ static-y := static/ipconfig
+-shared-y := shared/ipconfig
+
+ # common .o files
+ objs := main.o netdev.o packet.o
+@@ -22,8 +21,7 @@ lib-y := $(objs)
+
+ # .o files used to built executables
+ static/ipconfig-y := $(objs)
+-shared/ipconfig-y := $(objs)
+
+ # Cleaning
+-clean-dirs := static shared
++clean-dirs := static
+
+diff --git a/usr/kinit/nfsmount/Kbuild b/usr/kinit/nfsmount/Kbuild
+index ba31708..01bedce 100644
+--- a/usr/kinit/nfsmount/Kbuild
++++ b/usr/kinit/nfsmount/Kbuild
+@@ -4,7 +4,6 @@
+
+ static-y := static/nfsmount
+ #FIXME - build is broken static-y := dummypmap
+-shared-y := shared/nfsmount
+
+ objs := main.o mount.o portmap.o dummypmap.o sunrpc.o
+
+@@ -13,7 +12,6 @@ lib-y := $(objs)
+
+ # .o files used for executables
+ static/nfsmount-y := $(objs)
+-shared/nfsmount-y := $(objs)
+
+ # dummypmap uses a single .o file (rename src file?)
+ dummypmap-y := dummypmap_test.o
+@@ -21,5 +19,5 @@ dummypmap-y := dummypmap_test.o
+ # TODO - do we want a stripped version
+ # TODO - do we want the static.g + shared.g directories?
+
+-clean-dirs := static shared
++clean-dirs := static
+
+diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
+index c1342e1..15b9590 100644
+--- a/usr/kinit/resume/Kbuild
++++ b/usr/kinit/resume/Kbuild
+@@ -3,7 +3,6 @@
+ #
+
+ static-y := static/resume
+-shared-y := shared/resume
+
+ # common .o files
+ objs := resume.o resumelib.o
+@@ -20,9 +19,7 @@ KLIBCCFLAGS += -I$(srctree)/$(src)/..
+ # .o files used to built executables
+ static/resume-y := $(objs)
+ static/resume-lib := ../lib.a
+-shared/resume-y := $(objs)
+-shared/resume-lib := ../lib.a
+
+ # Cleaning
+-clean-dirs := static shared
++clean-dirs := static
+
+diff --git a/usr/kinit/run-init/Kbuild b/usr/kinit/run-init/Kbuild
+index c153b0a..a1ea834 100644
+--- a/usr/kinit/run-init/Kbuild
++++ b/usr/kinit/run-init/Kbuild
+@@ -3,7 +3,6 @@
+ #
+
+ static-y := static/run-init
+-shared-y := shared/run-init
+
+ # common .o files
+ objs := run-init.o runinitlib.o
+@@ -24,9 +23,7 @@ KLIBCCFLAGS += -I$(srctree)/$(src)/..
+ # .o files used to built executables
+ static/run-init-y := $(objs)
+ static/run-init-lib := ../lib.a
+-shared/run-init-y := $(objs)
+-shared/run-init-lib := ../lib.a
+
+ # Cleaning
+-clean-dirs := static shared
++clean-dirs := static
+
+diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
+index 67d9486..1573363 100644
+--- a/usr/utils/Kbuild
++++ b/usr/utils/Kbuild
+@@ -7,7 +7,6 @@ progs += true false sleep ln mv nuke minips cat ls losetup
+ progs += uname halt kill readlink cpio sync dmesg
+
+ static-y := $(addprefix static/, $(progs))
+-shared-y := $(addprefix shared/, $(progs))
+
+ # The binary is placed in a subdir, so we need to tell kbuild this
+ static/chroot-y := chroot.o
+@@ -62,13 +61,11 @@ static/losetup-y := losetup.o
+ shared/losetup-y := losetup.o
+
+ # Additionally linked targets
+-always := static/reboot static/poweroff shared/reboot shared/poweroff
++always := static/reboot static/poweroff
+
+ $(obj)/static/reboot $(obj)/static/poweroff: $(obj)/static/halt
+ $(call cmd,ln)
+-$(obj)/shared/reboot $(obj)/shared/poweroff: $(obj)/shared/halt
+- $(call cmd,ln)
+
+ # Clean deletes the static and shared dir
+-clean-dirs := static shared
++clean-dirs := static
+
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc_2.0.4-add-kexec_file_load-syscall.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc_2.0.4-add-kexec_file_load-syscall.patch
new file mode 100644
index 00000000..3d8d987c
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-klibc_2.0.4-add-kexec_file_load-syscall.patch
@@ -0,0 +1,27 @@
+From 90683d5eaabfa684a71411d6e3262153ac191ad8 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 4 Sep 2018 23:44:30 +0200
+Subject: [PATCH 1/1] klibc_2.0.4: add kexec_file_load syscall
+
+for supported archs only (matched in kexec-tools)
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ usr/klibc/SYSCALLS.def | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
+index c56e8f9..6b3bf4c 100644
+--- a/usr/klibc/SYSCALLS.def
++++ b/usr/klibc/SYSCALLS.def
+@@ -273,6 +273,7 @@ int reboot::__reboot(int, int, int, void *);
+ int syslog::klogctl(int, char *, int);
+ int sysinfo(struct sysinfo *);
+ long kexec_load(void *, unsigned long, struct kexec_segment *, unsigned long);
++<x86_64,ppc64,s390x> long kexec_file_load(int, int, unsigned long, const char *, unsigned long);
+
+ /*
+ * Low-level I/O (generally architecture-specific);
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
new file mode 100644
index 00000000..3bc081d4
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
@@ -0,0 +1,27 @@
+From cf97079009ba48d10e52052b2eab7461ea4dd09b 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 5a758b2..f1f577e 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;
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
new file mode 100644
index 00000000..e8423530
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
@@ -0,0 +1,26 @@
+From d2fb484d995221277cce7abddcd7dfa0e8bceec3 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Fri, 11 Jan 2013 17:26:40 +0000
+Subject: [PATCH] klibc_2.0.2: apply FIX_V4BX patch for armv4 targets only
+
+Status: not applicable upstream, in OE/Yocto we use $(FIX_V4BX)
+which is "" in case of armv5 or thumbs.
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ usr/klibc/arch/arm/MCONFIG | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/usr/klibc/arch/arm/MCONFIG b/usr/klibc/arch/arm/MCONFIG
+index 53bc1dc..303c6ac 100644
+--- a/usr/klibc/arch/arm/MCONFIG
++++ b/usr/klibc/arch/arm/MCONFIG
+@@ -29,6 +29,7 @@ else
+ KLIBCSHAREDFLAGS = -Ttext 0x01800200
+ ifeq ($(CONFIG_AEABI),y)
+ KLIBCREQFLAGS += -mabi=aapcs-linux -mno-thumb-interwork
++KLIBCLDFLAGS += $(FIX_ARMV4_EABI_BX)
+ else
+ KLIBCREQFLAGS += -mabi=apcs-gnu -mno-thumb-interwork
+ endif
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
new file mode 100644
index 00000000..5f47d3f2
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
@@ -0,0 +1,22 @@
+From 0cb26cf2d25d36c1fdcc4f1635e4329436ed866a Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Fri, 19 Sep 2014 23:09:29 +0200
+
+---
+ klcc/klcc.in | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/klcc/klcc.in b/klcc/klcc.in
+index 43d0984..61e9385 100644
+--- a/klcc/klcc.in
++++ b/klcc/klcc.in
+@@ -204,6 +204,9 @@ while ( defined($a = shift(@ARGV)) ) {
+ # Libraries
+ push(@libs, $a);
+ push(@libs, shift(@ARGV)) if ( $2 eq '' );
++ } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
++ # Override gcc encoded sysroot
++ push(@ccopt, $a);
+ } else {
+ die "$0: unknown option: $a\n";
+ }
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-cross-accept-clang-options.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-cross-accept-clang-options.patch
new file mode 100644
index 00000000..07703aa5
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-cross-accept-clang-options.patch
@@ -0,0 +1,19 @@
+meta-clang passes this option to compiler defaults
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Index: git/klcc/klcc.in
+===================================================================
+--- git.orig/klcc/klcc.in
++++ git/klcc/klcc.in
+@@ -207,6 +207,9 @@ while ( defined($a = shift(@ARGV)) ) {
+ } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
+ # Override gcc encoded sysroot
+ push(@ccopt, $a);
++ } elsif ( $a eq '-no-integrated-as' ) {
++ # Allow clang options
++ push(@ccopt, $a);
+ } else {
+ die "$0: unknown option: $a\n";
+ }
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
new file mode 100644
index 00000000..f28cd542
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
@@ -0,0 +1,24 @@
+From 1118cc971917abe19ddb029aa80417f6fd6bb343 Mon Sep 17 00:00:00 2001
+From: Thomas Kunze <thommycheck@gmx.de>
+Date: Sat, 6 Aug 2011 05:30:14 +0000
+Subject: [PATCH] klibc: initial commit of version 1.5.24
+
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id b6764cf32ec93547531130dca364fb95e1c495f4
+Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
+
+---
+ defconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/defconfig b/defconfig
+index 04b98e9..0cb23d0 100644
+--- a/defconfig
++++ b/defconfig
+@@ -6,4 +6,4 @@ CONFIG_KLIBC_ZLIB=y
+ CONFIG_REGPARM=y
+ # ARM options
+ # CONFIG_KLIBC_THUMB is not set
+-# CONFIG_AEABI is not set
++CONFIG_AEABI=y
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
new file mode 100644
index 00000000..a5563b74
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
@@ -0,0 +1,29 @@
+From 1be2bc41f915922102a3ba671b54c2df6f0052e6 Mon Sep 17 00:00:00 2001
+From: Ben Hutchings <ben@decadent.org.uk>
+Date: Sun, 14 Mar 2010 18:41:56 +0000
+Subject: [PATCH] klibc_1.5.26: now build against linux-libc-headers
+
+commit 43adf69062254fb4f8d4d11fb5fe36a60ae25d5a
+
+ Taken from debian "Fix klibc Debian specific build trouble"
+ Adapted for klibc_2.0.2
+
+---
+ scripts/Kbuild.install | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
+index 8af5697..d32a8a5 100644
+--- a/scripts/Kbuild.install
++++ b/scripts/Kbuild.install
+@@ -95,7 +95,9 @@ header:
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
+- $(Q)$(MAKE) -C $(KLIBCKERNELSRC) ARCH=$(KLIBCARCH) INSTALL_HDR_PATH=$(INSTALLROOT)$(INSTALLDIR)/$(KCROSS) headers_install
++ $(Q)for x in ../../../include/asm ../../../include/asm-generic ../../../include/linux ../../../include/mtd; do \
++ ln -sf $${x} $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
++ done
+ $(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
+ $(Q)chmod -R a+rX,go-w $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
new file mode 100644
index 00000000..5c7a6625
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
@@ -0,0 +1,151 @@
+From 1892079b827cf8f8316305b6d6e0985db82441a2 Mon Sep 17 00:00:00 2001
+From: Thomas Kunze <thommycheck@gmx.de>
+Date: Sat, 6 Aug 2011 05:30:14 +0000
+Subject: [PATCH] klibc: initial commit of version 1.5.24
+
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id eefb99a313bbcc8f34c8b32bf0c5aa2dd2580735
+Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
+
+Minor edits following upstream changes
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ scripts/Kbuild.install | 4 ----
+ usr/dash/Kbuild | 2 --
+ usr/gzip/Kbuild | 2 --
+ usr/kinit/Kbuild | 2 --
+ usr/kinit/fstype/Kbuild | 2 --
+ usr/kinit/ipconfig/Kbuild | 2 --
+ usr/kinit/nfsmount/Kbuild | 2 --
+ usr/kinit/resume/Kbuild | 2 --
+ usr/kinit/run-init/Kbuild | 2 --
+ usr/klibc/Kbuild | 2 --
+ usr/utils/Kbuild | 2 --
+ 11 files changed, 24 deletions(-)
+
+diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
+index d32a8a5..fda699d 100644
+--- a/scripts/Kbuild.install
++++ b/scripts/Kbuild.install
+@@ -88,19 +88,15 @@ else
+ header:
+ $(Q)echo " INSTALL headers + man pages to $(INSTALLROOT)$(INSTALLDIR)"
+ $(Q)mkdir -p $(INSTALLROOT)$(bindir)
+- $(Q)mkdir -p $(INSTALLROOT)$(mandir)/man1
+- $(Q)mkdir -p $(INSTALLROOT)$(SHLIBDIR)
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)
+ $(Q)-rm -rf $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
+- $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
+ $(Q)for x in ../../../include/asm ../../../include/asm-generic ../../../include/linux ../../../include/mtd; do \
+ ln -sf $${x} $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
+ done
+ $(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
+ $(Q)chmod -R a+rX,go-w $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+- $(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
+ $(Q)$(install-bin) $(objtree)/klcc/$(KCROSS)klcc $(INSTALLROOT)$(bindir)
+
+ footer: header
+diff --git a/usr/dash/Kbuild b/usr/dash/Kbuild
+index 3a98c1f..1a6920a 100644
+--- a/usr/dash/Kbuild
++++ b/usr/dash/Kbuild
+@@ -92,5 +92,3 @@ $(obj)/syntax.c: $(obj)/mksyntax
+ $(obj)/syntax.h: $(obj)/syntax.c
+ $(Q):
+
+-# Targets to install
+-install-y := sh.shared
+diff --git a/usr/gzip/Kbuild b/usr/gzip/Kbuild
+index 9bbf0a4..c497d02 100644
+--- a/usr/gzip/Kbuild
++++ b/usr/gzip/Kbuild
+@@ -21,5 +21,3 @@ $(obj)/gunzip $(obj)/zcat: $(obj)/gzip
+ # Cleaning
+ targets := gzip gzip.g gunzip zcat
+
+-# Targets to install
+-install-y := gzip gunzip zcat
+diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
+index 5320127..f7fdccd 100644
+--- a/usr/kinit/Kbuild
++++ b/usr/kinit/Kbuild
+@@ -33,5 +33,3 @@ targets += kinit kinit.g kinit.shared kinit.shared.g
+ subdir- := fstype ipconfig nfsmount resume run-init
+
+
+-# install binary
+-install-y := kinit kinit.shared
+diff --git a/usr/kinit/fstype/Kbuild b/usr/kinit/fstype/Kbuild
+index 9b20db1..367611d 100644
+--- a/usr/kinit/fstype/Kbuild
++++ b/usr/kinit/fstype/Kbuild
+@@ -21,5 +21,3 @@ shared/fstype-y := $(objs)
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/ipconfig/Kbuild b/usr/kinit/ipconfig/Kbuild
+index 7f8d181..eb1d472 100644
+--- a/usr/kinit/ipconfig/Kbuild
++++ b/usr/kinit/ipconfig/Kbuild
+@@ -27,5 +27,3 @@ shared/ipconfig-y := $(objs)
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/nfsmount/Kbuild b/usr/kinit/nfsmount/Kbuild
+index 461e6f3..ba31708 100644
+--- a/usr/kinit/nfsmount/Kbuild
++++ b/usr/kinit/nfsmount/Kbuild
+@@ -23,5 +23,3 @@ dummypmap-y := dummypmap_test.o
+
+ clean-dirs := static shared
+
+-# Install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
+index 034195d..c1342e1 100644
+--- a/usr/kinit/resume/Kbuild
++++ b/usr/kinit/resume/Kbuild
+@@ -26,5 +26,3 @@ shared/resume-lib := ../lib.a
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/run-init/Kbuild b/usr/kinit/run-init/Kbuild
+index f7832b7..c153b0a 100644
+--- a/usr/kinit/run-init/Kbuild
++++ b/usr/kinit/run-init/Kbuild
+@@ -30,5 +30,3 @@ shared/run-init-lib := ../lib.a
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
+index eba6add..98caf2e 100644
+--- a/usr/klibc/Kbuild
++++ b/usr/klibc/Kbuild
+@@ -185,5 +185,3 @@ install-rule:
+ $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
+ $(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+ $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib
+- $(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+- $(INSTALLROOT)$(SHLIBDIR)
+diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
+index 05aa794..67d9486 100644
+--- a/usr/utils/Kbuild
++++ b/usr/utils/Kbuild
+@@ -72,5 +72,3 @@ $(obj)/shared/reboot $(obj)/shared/poweroff: $(obj)/shared/halt
+ # Clean deletes the static and shared dir
+ clean-dirs := static shared
+
+-# install only install the shared binaries
+-install-y := $(shared-y) shared/reboot shared/poweroff
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch
new file mode 100644
index 00000000..eac128cc
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch
@@ -0,0 +1,25 @@
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id 676cbb54d42c89a4832871064cfcb7ee2ad372ee
+
+klcc-cross: Add patch to use /usr/bin/env perl
+Certain configurations (such as autobuilders) may build in very
+deep paths (that are longer than the #! mechanism allows) which
+makes it unsafe to use the direct path for perl. In our case we know
+that /usr/bin/env perl will always return ours (if it has been built).
+
+Signed-off-by: Tom Rini <tom_rini@mentor.com>
+
+Index: klibc-1.5.20/klcc/makeklcc.pl
+===================================================================
+--- a/klcc/makeklcc.pl
++++ b/klcc/makeklcc.pl
+@@ -26,7 +26,7 @@ sub pathsearch($) {
+ return undef;
+ }
+
+-print "#!${perlpath}\n";
++print "#!/usr/bin/env perl\n";
+
+ open(KLIBCCONF, "< $klibcconf\0")
+ or die "$0: cannot open $klibcconf: $!\n";
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb
new file mode 100644
index 00000000..16778630
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb
@@ -0,0 +1,18 @@
+SUMMARY = "klibc utils for initramfs statically compiled"
+
+FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
+
+PACKAGES = "${PN}"
+FILES_${PN} = ""
+
+KLIBC_UTILS_VARIANT = "static"
+KLIBC_UTILS_PKGNAME = "klibc-static-utils"
+
+require klibc-utils.inc
+require klibc.inc
+
+SRC_URI += "file://0001-klibc-static-utils-do-not-build-shared-binaries.patch"
+
+# avoid textrel if linking with -pie
+SECURITY_CFLAGS = ""
+SECURITY_LDFLAGS = ""
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc
new file mode 100644
index 00000000..2aac9e6e
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc
@@ -0,0 +1,58 @@
+do_install() {
+ install -d ${D}${base_bindir}
+ install -d ${D}${base_sbindir}
+ if [ "${KLIBC_UTILS_VARIANT}" = "shared" ]; then
+ install -m 755 usr/kinit/kinit.shared ${D}${base_bindir}/kinit.shared
+ install -m 755 usr/dash/sh.shared ${D}${base_bindir}/sh.shared
+ else
+ install -m 755 usr/dash/sh ${D}${base_bindir}/sh
+ install -m 755 usr/kinit/kinit ${D}${base_bindir}/kinit
+ install -m 755 usr/gzip/gzip ${D}${base_bindir}
+ ln -s gzip ${D}${base_bindir}/gunzip
+ ln -s gzip ${D}${base_bindir}/zcat
+ fi
+ install -m 755 usr/kinit/fstype/${KLIBC_UTILS_VARIANT}/fstype ${D}${base_bindir}
+ install -m 755 usr/kinit/ipconfig/${KLIBC_UTILS_VARIANT}/ipconfig ${D}${base_bindir}
+ install -m 755 usr/kinit/nfsmount/${KLIBC_UTILS_VARIANT}/nfsmount ${D}${base_bindir}
+ install -m 755 usr/kinit/resume/${KLIBC_UTILS_VARIANT}/resume ${D}${base_bindir}
+ install -m 755 usr/kinit/run-init/${KLIBC_UTILS_VARIANT}/run-init ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cat ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/chroot ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cpio ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dd ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dmesg ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/false ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/halt ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/kill ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ln ${D}${base_bindir}
+ # losetup goes in ${base_sbindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/losetup ${D}${base_sbindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ls ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/minips ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkdir ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkfifo ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mknod ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mount ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mv ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/nuke ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/pivot_root ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/poweroff ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/readlink ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/reboot ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sleep ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sync ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/true ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/umount ${D}${base_bindir}
+ install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/uname ${D}${base_bindir}
+}
+
+EXTRA_KLIBC_DEPS = "${@oe.utils.conditional('KLIBC_UTILS_VARIANT', 'shared', '${THIS_LIBKLIBC}', '', d)}"
+
+PACKAGES_DYNAMIC += "^${KLIBC_UTILS_PKGNAME}-.*"
+
+python populate_packages_prepend () {
+ base_bin_dir = d.expand('${base_bindir}')
+ do_split_packages(d, base_bin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', extra_depends='${EXTRA_KLIBC_DEPS}', allow_links=True, allow_dirs=True)
+ base_sbin_dir = d.expand('${base_sbindir}')
+ do_split_packages(d, base_sbin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', extra_depends='${EXTRA_KLIBC_DEPS}', allow_dirs=True)
+}
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb
new file mode 100644
index 00000000..06e71cb7
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb
@@ -0,0 +1,14 @@
+SUMMARY = "klibc utils for initramfs"
+
+FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
+
+PACKAGES = "${PN}"
+FILES_${PN} = ""
+
+KLIBC_UTILS_VARIANT = "shared"
+KLIBC_UTILS_PKGNAME = "klibc-utils"
+
+require klibc-utils.inc
+require klibc.inc
+
+DEPENDS = "klibc"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
new file mode 100644
index 00000000..ec52e973
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
@@ -0,0 +1,85 @@
+DESCRIPTION = "klibc is intended to be a minimalistic libc subset for \
+use with initramfs. It is deliberately written for small size, \
+minimal entaglement, and portability, not speed."
+SECTION = "libs"
+LICENSE = "BSD-3-Clause & GPL-2.0 & MIT & Zlib"
+LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8b"
+DEPENDS = "linux-libc-headers perl-native"
+SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c"
+
+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://klcc-cross-accept-clang-options.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 \
+ file://0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch \
+ file://0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch \
+ file://0001-arm-Do-not-set-a-fallback-march-and-mtune.patch \
+ file://0001-klibc_2.0.4-add-kexec_file_load-syscall.patch \
+ file://0001-klibc-add-getrandom-syscall.patch \
+ file://0001-klibc-Kbuild-Accept-EXTRA_KLIBCAFLAGS.patch \
+ file://0001-Define-ulocked_-fgets-fread-fwrite-aliases.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}' \
+ 'KLIBCLIBGCC=${STAGING_DIR_TARGET}${libdir}/${TARGET_SYS}/*/libgcc.a' \
+ 'prefix=${exec_prefix}' \
+ 'INSTALLROOT=${D}' \
+ 'INSTALLDIR=${libdir}/klibc' \
+ 'SHLIBDIR=${libdir}' \
+ '${KLIBCTHUMB}' \
+ 'KLIBCOPTFLAGS=${TUNE_CCARGS} -Os' \
+ V=1 \
+ "
+EXTRA_OEMAKE += "'EXTRA_KLIBCAFLAGS=${SECURITY_CFLAGS} -Wa,--noexecstack' \
+ 'EXTRA_KLIBCLDFLAGS=${SECURITY_LDFLAGS} -z noexecstack'"
+
+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
+}
+
+do_compile_prepend_toolchain-clang() {
+ sed -i -e 's#$(KLIBCROSS)gcc#$(KLIBCROSS)clang#g' ${S}/Makefile
+}
+
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
+INSANE_SKIP_${PN} = "already-stripped"
+INSANE_SKIP_libklibc-dev = "dev-elf"
+KLIBC_ARCH = "${TARGET_ARCH}"
+KLIBC_ARCH_aarch64 = "arm64"
+KLIBC_ARCH_armeb = "arm"
+KLIBC_ARCH_mipsel = "mips"
+KLIBC_ARCH_mips64el = "mips64"
+KLIBC_ARCH_x86 = "i386"
+KLIBC_ARCH_x86-64 = "x86_64"
+KLIBC_ARCH_powerpc = "ppc"
+KLIBC_ARCH_powerpc64 = "ppc64"
+THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})"
+
+GCCPIE ?= ""
+SECURITY_LDFLAGS = "${@'-z relro -z now -pie' if '${GCCPIE}' else ''}"
+SECURITY_LDFLAGS_mips = ""
+SECURITY_LDFLAGS_mipsel = ""
+SECURITY_LDFLAGS_mips64 = ""
+SECURITY_LDFLAGS_mips64el = ""
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb
new file mode 100644
index 00000000..bc80f382
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb
@@ -0,0 +1,24 @@
+SUMMARY = "klibc, a small C library for use with initramfs"
+
+do_install() {
+ oe_runmake install
+ # the crosscompiler is packaged by klcc-cross
+ # remove klcc
+ rm ${D}${bindir}/klcc
+ # remove now empty dir
+ rmdir ${D}${bindir}
+ install -d ${D}${libdir}
+ install -m 755 usr/klibc/klibc-*.so ${D}${libdir}
+ (cd ${D}${libdir}; ln -s klibc-*.so klibc.so)
+}
+
+PACKAGES = "libklibc libklibc-staticdev libklibc-dev"
+
+FILES_libklibc = "${libdir}/klibc-*.so"
+FILES_libklibc-staticdev = "${libdir}/klibc/lib/libc.a"
+FILES_libklibc-dev = "${libdir}/klibc.so \
+ ${libdir}/klibc/lib/* \
+ ${libdir}/klibc/include/* \
+ "
+
+require klibc.inc
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch
new file mode 100644
index 00000000..4ee9bd9a
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch
@@ -0,0 +1,40 @@
+From e596ae99059c28fa9bb3461e03e7ecaacbf41727 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 23 May 2018 15:34:59 +0200
+Subject: [PATCH] libmissing.h: fix klibc build when using glibc toolchain
+
+klibc lacks execinfo.h so adda guard around it.
+Note: build with musl toolchain is ok even without this patch.
+
+Fix build error:
+
+| In file included from ../git/lib/execinfo.c:1:0:
+| ../git/include/libmissing.h:7:10: fatal error: execinfo.h:
+ No such file or directory
+
+Upstream-Status: Inappropriate [klibc specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/libmissing.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/libmissing.h b/include/libmissing.h
+index 0196033..832c372 100644
+--- a/include/libmissing.h
++++ b/include/libmissing.h
+@@ -3,9 +3,11 @@
+
+ #include "config.h"
+
++#ifndef __KLIBC__
+ #ifdef HAVE_EXECINFO_H
+ #include <execinfo.h>
+ #endif
++#endif
+
+ #ifndef HAVE_EXECINFO_H
+ int backtrace(void **buffer, int size);
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
new file mode 100644
index 00000000..5c6e0974
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
@@ -0,0 +1,326 @@
+From 01c98d5d5d044d9a125abcdbb2f3d771966365b0 Mon Sep 17 00:00:00 2001
+From: mirabilos <m@mirbsd.org>
+Date: Thu, 1 Feb 2018 15:34:07 +0100
+Subject: [PATCH] Instead of doing preprocessor magic, just output off_t as
+ long long
+
+Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):
+
+In file included from ../git/lib/libmtd.c:40:0:
+../git/lib/libmtd.c: In function 'mtd_read':
+../git/include/common.h:110:18: warning: format '%ld' expects argument of
+ type 'long int', but argument 5 has type 'off_t {aka long long int}'
+ [-Wformat=]
+
+../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
+ errmsg(fmt, ##__VA_ARGS__); \
+ ^~~~~~
+../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
+ return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+ ^~~~~~~~~~
+
+/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
+ #define PRId32 "d"
+
+Upstream-Status: Submitted
+
+Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
+---
+ include/common.h | 18 ------------------
+ jffsX-utils/mkfs.jffs2.c | 20 ++++++++++----------
+ lib/libmtd.c | 8 ++++----
+ misc-utils/flash_erase.c | 6 +++---
+ misc-utils/flash_otp_write.c | 2 +-
+ misc-utils/ftl_check.c | 2 +-
+ misc-utils/mtd_debug.c | 4 ++--
+ misc-utils/serve_image.c | 4 ++--
+ tests/fs-tests/integrity/integck.c | 4 ++--
+ tests/mtd-tests/nandpagetest.c | 4 ++--
+ tests/ubi-tests/integ.c | 6 +++---
+ ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 +++---
+ 12 files changed, 33 insertions(+), 51 deletions(-)
+
+diff --git a/include/common.h b/include/common.h
+index f8f72ea..642c212 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -70,24 +70,6 @@ extern "C" {
+ #define O_CLOEXEC 0
+ #endif
+
+-/* define a print format specifier for off_t */
+-#if (SIZEOF_OFF_T >= 8)
+-#define PRIxoff_t PRIx64
+-#define PRIdoff_t PRId64
+-#else
+-#define PRIxoff_t "l"PRIx32
+-#define PRIdoff_t "l"PRId32
+-#endif
+-
+-/* define a print format specifier for loff_t */
+-#if (SIZEOF_LOFF_T >= 8)
+-#define PRIxloff_t PRIx64
+-#define PRIdloff_t PRId64
+-#else
+-#define PRIxloff_t "l"PRIx32
+-#define PRIdloff_t "l"PRId32
+-#endif
+-
+ /* Verbose messages */
+ #define bareverbose(verbose, fmt, ...) do { \
+ if (verbose) \
+diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
+index 9aa6c39..0661786 100644
+--- a/jffsX-utils/mkfs.jffs2.c
++++ b/jffsX-utils/mkfs.jffs2.c
+@@ -1237,8 +1237,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
+ } else switch (e->sb.st_mode & S_IFMT) {
+ case S_IFDIR:
+ if (verbose) {
+- printf("\td %04o %9" PRIdoff_t " %5d:%-3d %s\n",
+- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
++ printf("\td %04o %9lld %5d:%-3d %s\n",
++ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
+ (int) (e->sb.st_uid), (int) (e->sb.st_gid),
+ e->name);
+ }
+@@ -1247,8 +1247,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
+ break;
+ case S_IFSOCK:
+ if (verbose) {
+- printf("\ts %04o %9" PRIdoff_t " %5d:%-3d %s\n",
+- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
++ printf("\ts %04o %9lld %5d:%-3d %s\n",
++ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
+ (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
+ }
+ write_pipe(e);
+@@ -1256,8 +1256,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
+ break;
+ case S_IFIFO:
+ if (verbose) {
+- printf("\tp %04o %9" PRIdoff_t " %5d:%-3d %s\n",
+- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
++ printf("\tp %04o %9lld %5d:%-3d %s\n",
++ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
+ (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
+ }
+ write_pipe(e);
+@@ -1285,8 +1285,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
+ break;
+ case S_IFLNK:
+ if (verbose) {
+- printf("\tl %04o %9" PRIdoff_t " %5d:%-3d %s -> %s\n",
+- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
++ printf("\tl %04o %9lld %5d:%-3d %s -> %s\n",
++ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
+ (int) e->sb.st_uid, (int) e->sb.st_gid, e->name,
+ e->link);
+ }
+@@ -1297,8 +1297,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
+ wrote = write_regular_file(e);
+ write_xattr_entry(e);
+ if (verbose) {
+- printf("\tf %04o %9" PRIdoff_t " (%9u) %5d:%-3d %s\n",
+- e->sb.st_mode & ~S_IFMT, e->sb.st_size, wrote,
++ printf("\tf %04o %9lld (%9u) %5d:%-3d %s\n",
++ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size, wrote,
+ (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
+ }
+ break;
+diff --git a/lib/libmtd.c b/lib/libmtd.c
+index 86c89ae..f375381 100644
+--- a/lib/libmtd.c
++++ b/lib/libmtd.c
+@@ -1079,8 +1079,8 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
+ /* Seek to the beginning of the eraseblock */
+ seek = (off_t)eb * mtd->eb_size + offs;
+ if (lseek(fd, seek, SEEK_SET) != seek)
+- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+- mtd->mtd_num, seek);
++ return sys_errmsg("cannot seek mtd%d to offset %lld",
++ mtd->mtd_num, (long long)seek);
+
+ while (rd < len) {
+ ret = read(fd, buf + rd, len - rd);
+@@ -1188,8 +1188,8 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
+ if (data) {
+ /* Seek to the beginning of the eraseblock */
+ if (lseek(fd, seek, SEEK_SET) != seek)
+- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
+- mtd->mtd_num, seek);
++ return sys_errmsg("cannot seek mtd%d to offset %lld",
++ mtd->mtd_num, (long long)seek);
+ ret = write(fd, data, len);
+ if (ret != len)
+ return sys_errmsg("cannot write %d bytes to mtd%d "
+diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
+index 0c9449f..ec4b2e1 100644
+--- a/misc-utils/flash_erase.c
++++ b/misc-utils/flash_erase.c
+@@ -53,8 +53,8 @@ int target_endian = __BYTE_ORDER;
+ static void show_progress(struct mtd_dev_info *mtd, off_t start, int eb,
+ int eb_start, int eb_cnt)
+ {
+- bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
+- mtd->eb_size / 1024, start, ((eb - eb_start) * 100) / eb_cnt);
++ bareverbose(!quiet, "\rErasing %d Kibyte @ %llx -- %2i %% complete ",
++ mtd->eb_size / 1024, (unsigned long long)start, ((eb - eb_start) * 100) / eb_cnt);
+ fflush(stdout);
+ }
+
+@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
+ if (!noskipbad) {
+ int ret = mtd_is_bad(&mtd, fd, eb);
+ if (ret > 0) {
+- verbose(!quiet, "Skipping bad block at %08"PRIxoff_t, offset);
++ verbose(!quiet, "Skipping bad block at %08llx", (unsigned long long)offset);
+ continue;
+ } else if (ret < 0) {
+ if (errno == EOPNOTSUPP) {
+diff --git a/misc-utils/flash_otp_write.c b/misc-utils/flash_otp_write.c
+index b02d0b0..04c96c6 100644
+--- a/misc-utils/flash_otp_write.c
++++ b/misc-utils/flash_otp_write.c
+@@ -76,7 +76,7 @@ int main(int argc,char *argv[])
+ return errno;
+ }
+
+- printf("Writing OTP user data on %s at offset 0x%"PRIxoff_t"\n", argv[2], offset);
++ printf("Writing OTP user data on %s at offset 0x%llx\n", argv[2], (unsigned long long)offset);
+
+ if (mtd_type_is_nand_user(&mtdInfo))
+ len = mtdInfo.writesize;
+diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
+index a853cf4..e854922 100644
+--- a/misc-utils/ftl_check.c
++++ b/misc-utils/ftl_check.c
+@@ -131,7 +131,7 @@ static void check_partition(int fd)
+ perror("read failed");
+ break;
+ }
+- printf("\nErase unit %"PRIdoff_t":\n", i);
++ printf("\nErase unit %lld:\n", (long long)i);
+ if ((hdr2.FormattedSize != hdr.FormattedSize) ||
+ (hdr2.NumEraseUnits != hdr.NumEraseUnits) ||
+ (hdr2.SerialNumber != hdr.SerialNumber))
+diff --git a/misc-utils/mtd_debug.c b/misc-utils/mtd_debug.c
+index ac37e23..d65ad36 100644
+--- a/misc-utils/mtd_debug.c
++++ b/misc-utils/mtd_debug.c
+@@ -160,7 +160,7 @@ retry:
+ if (buf != NULL)
+ free(buf);
+ close(outfd);
+- printf("Copied %zu bytes from address 0x%.8"PRIxoff_t" in flash to %s\n", len, offset, filename);
++ printf("Copied %zu bytes from address 0x%.8llx in flash to %s\n", len, (unsigned long long)offset, filename);
+ return 0;
+
+ err2:
+@@ -225,7 +225,7 @@ retry:
+ if (buf != NULL)
+ free(buf);
+ fclose(fp);
+- printf("Copied %d bytes from %s to address 0x%.8"PRIxoff_t" in flash\n", len, filename, offset);
++ printf("Copied %d bytes from %s to address 0x%.8llx in flash\n", len, filename, (unsigned long long)offset);
+ return 0;
+ }
+
+diff --git a/misc-utils/serve_image.c b/misc-utils/serve_image.c
+index f2475d6..6c8c8fb 100644
+--- a/misc-utils/serve_image.c
++++ b/misc-utils/serve_image.c
+@@ -129,8 +129,8 @@ int main(int argc, char **argv)
+ }
+
+ if (st.st_size % erasesize) {
+- fprintf(stderr, "Image size %" PRIdoff_t " bytes is not a multiple of erasesize %d bytes\n",
+- st.st_size, erasesize);
++ fprintf(stderr, "Image size %lld bytes is not a multiple of erasesize %d bytes\n",
++ (long long)st.st_size, erasesize);
+ exit(1);
+ }
+ image = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, rfd, 0);
+diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
+index 84753d6..0a7f142 100644
+--- a/tests/fs-tests/integrity/integck.c
++++ b/tests/fs-tests/integrity/integck.c
+@@ -897,8 +897,8 @@ static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
+ remains = size;
+ actual = 0;
+ written = IO_BUFFER_SIZE;
+- v("write %zd bytes, offset %"PRIdoff_t", file %s",
+- size, offset, get_file_name(file));
++ v("write %zd bytes, offset %lld, file %s",
++ size, (long long)offset, get_file_name(file));
+ while (remains) {
+ /* Fill up buffer with random data */
+ if (written < IO_BUFFER_SIZE) {
+diff --git a/tests/mtd-tests/nandpagetest.c b/tests/mtd-tests/nandpagetest.c
+index c6812df..465e548 100644
+--- a/tests/mtd-tests/nandpagetest.c
++++ b/tests/mtd-tests/nandpagetest.c
+@@ -232,8 +232,8 @@ static int verify_eraseblock(int ebnum)
+ return err;
+
+ if (lseek(fd, addr, SEEK_SET) != addr) {
+- fprintf(stderr, "cannot seek mtd%d to offset %"PRIdloff_t,
+- mtd.mtd_num, addr);
++ fprintf(stderr, "cannot seek mtd%d to offset %lld",
++ mtd.mtd_num, (long long)addr);
+ return -1;
+ }
+
+diff --git a/tests/ubi-tests/integ.c b/tests/ubi-tests/integ.c
+index 26c2ce5..1cd0649 100644
+--- a/tests/ubi-tests/integ.c
++++ b/tests/ubi-tests/integ.c
+@@ -243,7 +243,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
+ while (size)
+ if (read_buffer[--size] != 0xff) {
+ fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
+- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
++ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
+ fprintf(stderr, "size = %ld\n" , (long) bytes_read);
+ error_exit("verify 0xff failed");
+ }
+@@ -254,7 +254,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
+ errno = 0;
+ bytes_read = read(fd, read_buffer, w->size);
+ if (bytes_read != w->size) {
+- fprintf(stderr, "offset = %"PRIdoff_t"\n" , w->offset);
++ fprintf(stderr, "offset = %lld\n" , (long long)w->offset);
+ fprintf(stderr, "size = %ld\n" , (long) w->size);
+ fprintf(stderr, "bytes_read = %ld\n" , (long) bytes_read);
+ error_exit("read failed");
+@@ -279,7 +279,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
+ while (size)
+ if (read_buffer[--size] != 0xff) {
+ fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
+- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
++ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
+ fprintf(stderr, "size = %ld\n" , (long) bytes_read);
+ error_exit("verify 0xff failed!");
+ }
+diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+index c916f48..f0237ab 100644
+--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
++++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+@@ -772,11 +772,11 @@ int write_leb(int lnum, int len, void *buf)
+ return sys_err_msg("ubi_leb_change_start failed");
+
+ if (lseek(out_fd, pos, SEEK_SET) != pos)
+- return sys_err_msg("lseek failed seeking %"PRIdoff_t, pos);
++ return sys_err_msg("lseek failed seeking %lld", (long long)pos);
+
+ if (write(out_fd, buf, c->leb_size) != c->leb_size)
+- return sys_err_msg("write failed writing %d bytes at pos %"PRIdoff_t,
+- c->leb_size, pos);
++ return sys_err_msg("write failed writing %d bytes at pos %lld",
++ c->leb_size, (long long)pos);
+
+ return 0;
+ }
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch
new file mode 100644
index 00000000..38ab7a91
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch
@@ -0,0 +1,34 @@
+From 139d93bc405272a3261d57be26da842e737fe4d0 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 28 Jan 2018 23:10:34 +0100
+Subject: [PATCH] Makefile.am: only build ubi-utils
+
+We only target the ubi-utils, static, small.
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ Makefile.am | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 5a6e77c..98715dd 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -34,9 +34,9 @@ EXTRA_DIST += $(GLOBAL_HEADER) $(GLOBAL_EXTRA)
+
+ include lib/Makemodule.am
+ include ubi-utils/Makemodule.am
+-include misc-utils/Makemodule.am
+-include nand-utils/Makemodule.am
+-include nor-utils/Makemodule.am
++#include misc-utils/Makemodule.am
++#include nand-utils/Makemodule.am
++#include nor-utils/Makemodule.am
+
+ if BUILD_UBIFS
+ include ubifs-utils/Makemodule.am
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch
new file mode 100644
index 00000000..2844a502
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch
@@ -0,0 +1,38 @@
+From ae1cf6d0eb1833e46549328a4473222c259723d7 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Thu, 1 Feb 2018 00:25:00 +0100
+Subject: [PATCH] mtd-utils: common.h: no features.h for klibc builds
+
+Add guard around features.h to fix missing include (here first error):
+
+ ../git/include/common.h:29:10:
+ fatal error: features.h: No such file or directory
+ #include <features.h>
+ ^~~~~~~~~~~~
+ compilation terminated
+
+Upstream-Status: Submitted
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/common.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/include/common.h b/include/common.h
+index 642c212..f7c71fe 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -26,7 +26,10 @@
+ #include <string.h>
+ #include <fcntl.h>
+ #include <errno.h>
++#if defined(__KLIBC__)
++#else
+ #include <features.h>
++#endif
+ #include <inttypes.h>
+ #include <unistd.h>
+ #include <sys/sysmacros.h>
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch
new file mode 100644
index 00000000..a556ed3d
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch
@@ -0,0 +1,56 @@
+From 2137eb1a6cd0326510bd3b9faf8037d9bf34ca3d Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 23 May 2018 15:52:34 +0200
+Subject: [PATCH] common.h: replace getline() with fgets
+
+There is an unofficial upstream patch adding a simple getline()
+to libmissing.h. Unfortunately the patch creates issues if the
+toolchain is using glibc (autotools cache?) so for the moment
+keep the old hack and wait for commits upstream.
+
+Fix:
+
+| ubi-utils/ubiformat.o: In function `prompt.constprop.4':
+| ubiformat.c:(.text+0x70): undefined reference to `getline'
+
+Upstream-Status: Inappropriate [klibc specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/common.h | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/include/common.h b/include/common.h
+index a1d59d0..96b0bdb 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -126,15 +126,26 @@ extern "C" {
+ */
+ static inline bool prompt(const char *msg, bool def)
+ {
++
++#ifndef __KLIBC__
+ char *line = NULL;
+ size_t len;
++#else
++ char *line;
++ const int sizeof_line = 2;
++ line = malloc(sizeof_line);
++#endif
+ bool ret = def;
+
+ do {
+ normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N');
+ fflush(stdout);
+
++#ifndef __KLIBC__
+ while (getline(&line, &len, stdin) == -1) {
++#else
++ while (fgets(line, sizeof_line, stdin) == NULL) {
++#endif
+ printf("failed to read prompt; assuming '%s'\n",
+ def ? "yes" : "no");
+ break;
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb
new file mode 100644
index 00000000..0475cbea
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb
@@ -0,0 +1,52 @@
+SUMMARY = "UBI utils statically compiled against klibc"
+DESCRIPTION = "Small sized tools from mtd-utils for use with initramfs."
+SECTION = "base"
+DEPENDS = "zlib lzo e2fsprogs util-linux"
+HOMEPAGE = "http://www.linux-mtd.infradead.org/"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+ file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
+
+inherit autotools pkgconfig klibc
+
+SRCREV = "64f61a9dc71b158c7084006cbce4ea23886f0b47"
+SRC_URI = "git://git.infradead.org/mtd-utils.git \
+ file://0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch \
+ file://0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch \
+ file://0003-Makefile.am-only-build-ubi-utils.patch \
+ file://0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch \
+ file://0005-common.h-replace-getline-with-fgets.patch \
+ "
+
+S = "${WORKDIR}/git/"
+
+EXTRA_OECONF += "--disable-tests --without-jffs --without-ubifs"
+
+PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}"
+PACKAGECONFIG[xattr] = ",,acl,"
+
+EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} ${@bb.utils.contains('PACKAGECONFIG', 'xattr', '', '-DWITHOUT_XATTR', d)} -I${S}/include' 'BUILDDIR=${S}'"
+
+do_install () {
+ oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
+}
+
+PACKAGES = "ubi-utils-klibc-dbg ubi-utils-klibc-doc"
+
+PACKAGES =+ "mtdinfo-klibc ubiattach-klibc ubiblock-klibc ubicrc32-klibc ubidetach-klibc \
+ ubiformat-klibc ubimkvol-klibc ubinfo-klibc ubinize-klibc ubirename-klibc \
+ ubirmvol-klibc ubirsvol-klibc ubiupdatevol-klibc"
+
+FILES_mtdinfo-klibc = "${sbindir}/mtdinfo"
+FILES_ubiattach-klibc = "${sbindir}/ubiattach"
+FILES_ubiblock-klibc = "${sbindir}/ubiblock"
+FILES_ubicrc32-klibc = "${sbindir}/ubicrc32"
+FILES_ubidetach-klibc = "${sbindir}/ubidetach"
+FILES_ubiformat-klibc = "${sbindir}/ubiformat"
+FILES_ubimkvol-klibc = "${sbindir}/ubimkvol"
+FILES_ubinfo-klibc = "${sbindir}/ubinfo"
+FILES_ubinize-klibc = "${sbindir}/ubinize"
+FILES_ubirename-klibc = "${sbindir}/ubirename"
+FILES_ubirmvol-klibc = "${sbindir}/ubirmvol"
+FILES_ubirsvol-klibc = "${sbindir}/ubirsvol"
+FILES_ubiupdatevol-klibc = "${sbindir}/ubiupdatevol"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch
new file mode 100644
index 00000000..4744e7a3
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0001-force-static-build.patch
@@ -0,0 +1,25 @@
+From d6af515cfcc8185f423860f80ff28719975b701f Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:00 +0200
+Subject: [PATCH] force static build
+
+Upstream-Status: Inappropriate [embedded specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 54c206f..79188d8 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -47,7 +47,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@
+ # where necessary.
+ CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \
+ -Iinclude/ $($(ARCH)_CPPFLAGS)
+-CFLAGS = @CFLAGS@ -fno-strict-aliasing -Wall -Wstrict-prototypes
++CFLAGS = @CFLAGS@ -static -fno-strict-aliasing -Wall -Wstrict-prototypes
+ PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@
+ ASFLAGS = @ASFLAGS@ $($(ARCH)_ASFLAGS)
+ LDFLAGS = @LDFLAGS@
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
new file mode 100644
index 00000000..1d96a2b3
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
@@ -0,0 +1,29 @@
+From 0976d2d5be1ed44c2324b609c7d16c1e93181c4b 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
+
+Upstream-Status: Inappropriate [embedded specific]
+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 9679ad7..82c6141 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/socket.h>
+ #include <sys/time.h>
+
+-#include <net/if.h>
+ #include <netinet/in.h>
++#include <net/if.h>
+
+ /*
+ * First, we find all shaper devices and down them. Then we
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch
new file mode 100644
index 00000000..ae9e7bbc
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0003-kexec-elf-rel-use-our-elf.h.patch
@@ -0,0 +1,92 @@
+From 7f91875d65778154709e4fa0ccb23f3b2a98b0dc Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:00 +0200
+Subject: [PATCH] kexec-elf-rel: use our elf.h
+
+Fix:
+
+ kexec-elf-rel.c: In function 'elf_rel_load':
+ kexec-elf-rel.c:386:39: error: 'STT_NOTYPE' undeclared
+
+and similar.
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/arch/arm/kexec-elf-rel-arm.c | 2 +-
+ kexec/arch/i386/kexec-elf-rel-x86.c | 2 +-
+ kexec/arch/ppc/kexec-elf-rel-ppc.c | 2 +-
+ kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 2 +-
+ kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 2 +-
+ kexec/kexec-elf-rel.c | 2 +-
+ 6 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/kexec/arch/arm/kexec-elf-rel-arm.c b/kexec/arch/arm/kexec-elf-rel-arm.c
+index a939cf4..2551dc0 100644
+--- a/kexec/arch/arm/kexec-elf-rel-arm.c
++++ b/kexec/arch/arm/kexec-elf-rel-arm.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+diff --git a/kexec/arch/i386/kexec-elf-rel-x86.c b/kexec/arch/i386/kexec-elf-rel-x86.c
+index 55a214e..e7583d1 100644
+--- a/kexec/arch/i386/kexec-elf-rel-x86.c
++++ b/kexec/arch/i386/kexec-elf-rel-x86.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+diff --git a/kexec/arch/ppc/kexec-elf-rel-ppc.c b/kexec/arch/ppc/kexec-elf-rel-ppc.c
+index 1acbd86..a60c66c 100644
+--- a/kexec/arch/ppc/kexec-elf-rel-ppc.c
++++ b/kexec/arch/ppc/kexec-elf-rel-ppc.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+index 5f8e3f2..765bf6e 100644
+--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
++++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include <string.h>
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+index 7fdde73..cd5d729 100644
+--- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
++++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+diff --git a/kexec/kexec-elf-rel.c b/kexec/kexec-elf-rel.c
+index 9a6e63d..a856636 100644
+--- a/kexec/kexec-elf-rel.c
++++ b/kexec/kexec-elf-rel.c
+@@ -4,7 +4,7 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
+-#include "elf.h"
++#include "../include/elf.h"
+ #include <boot/elf_boot.h>
+ #include "kexec.h"
+ #include "kexec-elf.h"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch
new file mode 100644
index 00000000..1080e8bb
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0004-kexec-elf-exec.c-replace-with-our-err.h.patch
@@ -0,0 +1,30 @@
+From 8b9da93ac9a4ea79ae953f80f6fe6e4f080341f2 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 17 Apr 2018 10:57:23 +0200
+Subject: [PATCH] kexec-elf-exec.c: replace with our elf.h
+
+Fix
+
+ kexec-elf-exec.c: In function 'elf_exec_load':
+ error: 'EM_AARCH64' undeclared
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/kexec-elf-exec.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/kexec-elf-exec.c b/kexec/kexec-elf-exec.c
+index a9329ac..0dd0700 100644
+--- a/kexec/kexec-elf-exec.c
++++ b/kexec/kexec-elf-exec.c
+@@ -4,7 +4,7 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
+-#include "elf.h"
++#include "../include/elf.h"
+ #include <boot/elf_boot.h>
+ #include "kexec.h"
+ #include "kexec-elf.h"
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch
new file mode 100644
index 00000000..4f7506d4
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch
@@ -0,0 +1,134 @@
+From 1cfee75d9662c3382bb7cb8f1c952333837598ae Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 18 Apr 2018 02:21:30 +0200
+Subject: [PATCH] crashdump-elf.c: work around for _SC_NPROCESSORS_CONF
+
+klibc sysconf lacks this so the implementation
+of Linus Torvalds was taken (simplified):
+
+https://sourceware.org/ml/libc-alpha/2011-06/msg00079.html
+
+Have fun reding the thread!
+
+Fix
+
+ crashdump-elf.c:117:21: error: '_SC_NPROCESSORS_CONF' undeclared
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/crashdump-elf.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 92 insertions(+)
+
+diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
+index b8bb686..7e6767c 100644
+--- a/kexec/crashdump-elf.c
++++ b/kexec/crashdump-elf.c
+@@ -25,6 +25,94 @@ do { \
+ } while(0)
+ #endif
+
++#ifdef __KLIBC__
++#ifndef KLIBC_SYSFS_CPU_H
++#define KLIBC_SYSFS_CPU_H
++
++
++static int __get_sysfs_cpus(const char *path);
++int __get_nprocs (void);
++int __get_nprocs_conf (void);
++
++
++
++static int __get_sysfs_cpus(const char *path)
++{
++ FILE *file;
++ int nr_cpus = 0;
++ int prev = -1;
++ char *p;
++ char line[10];
++
++
++ file = fopen(path, "r");
++ if (!file)
++ return -1;
++ for (;;) {
++ char sep;
++ int cpu;
++ int n;
++
++ /* int n = fscanf(file, "%u%c", &cpu, &sep); */
++ p = fgets(line, sizeof(line), file);
++ if (p == NULL)
++ return -1;
++ else
++ n = sscanf(line, "%u%c", &cpu, &sep);
++
++ if (n <= 0)
++ break;
++
++ /* EOF == EOLN */
++ if (n == 1)
++ sep = '\n';
++
++ /* Was the previous CPU a range? */
++ if (prev >= 0) {
++ nr_cpus += cpu - prev + 1;
++ prev = -1;
++ } else if (sep == '-')
++ prev = cpu;
++ else
++ nr_cpus++;
++
++ if (sep == '\n')
++ break;
++ }
++ fclose(file);
++ return nr_cpus;
++}
++
++int __get_nprocs ()
++{
++ long ret;
++ static int cached = -1;
++
++ ret = cached;
++ if (ret < 0)
++ {
++ ret = __get_sysfs_cpus("/sys/devices/system/cpu/online");
++ cached = ret;
++ }
++ return ret;
++}
++
++int __get_nprocs_conf ()
++{
++ long ret;
++ static int cached = -1;
++
++ ret = cached;
++ if (ret < 0)
++ {
++ ret = __get_sysfs_cpus("/sys/devices/system/cpu/possible");
++ cached = ret;
++ }
++ return ret;
++}
++#endif
++#endif
++
+ /* Prepares the crash memory headers and stores in supplied buffer. */
+ int FUNC(struct kexec_info *info,
+ struct crash_elf_info *elf_info,
+@@ -46,7 +134,11 @@ int FUNC(struct kexec_info *info,
+ if (xen_present())
+ nr_cpus = xen_get_nr_phys_cpus();
+ else
++#ifndef __KLIBC__
+ nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
++#else
++ nr_cpus = __get_nprocs_conf();
++#endif
+
+ if (nr_cpus < 0) {
+ return -1;
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch
new file mode 100644
index 00000000..3020f767
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch
@@ -0,0 +1,71 @@
+From 45a80fe7d247898d83edfeabe32b9de80a50a6be Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Fri, 31 Aug 2018 11:33:51 +0200
+Subject: [PATCH] kexec-syscall.h: work around missing syscall() wrapper
+
+Fix
+
+ kexec-syscall.h: In function 'kexec_load':
+ kexec-syscall.h:80:16: warning: implicit declaration of function 'syscall'
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/kexec-syscall.h | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
+index 33638c2..204007d 100644
+--- a/kexec/kexec-syscall.h
++++ b/kexec/kexec-syscall.h
+@@ -74,11 +74,16 @@
+
+ struct kexec_segment;
+
++#ifndef __KLIBC__
+ static inline long kexec_load(void *entry, unsigned long nr_segments,
+ struct kexec_segment *segments, unsigned long flags)
+ {
+ return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
+ }
++#else
++extern long kexec_load(void *entry, unsigned long nr_segments,
++ struct kexec_segment *segments, unsigned long flags);
++#endif
+
+ static inline int is_kexec_file_load_implemented(void) {
+ if (__NR_kexec_file_load != 0xffffffff)
+@@ -86,6 +91,21 @@ static inline int is_kexec_file_load_implemented(void) {
+ return 0;
+ }
+
++#ifdef __KLIBC__
++/* Stub provided by klibc only for the following archs */
++#if defined (__x86_64__) || defined (__powerpc_64__) || defined (__s390x__)
++extern long kexec_file_load(int kernel_fd, int initrd_fd,
++ unsigned long cmdline_len, const char *cmdline_ptr,
++ unsigned long flags);
++#else
++static inline long kexec_file_load(int kernel_fd, int initrd_fd,
++ unsigned long cmdline_len, const char *cmdline_ptr,
++ unsigned long flags)
++{
++ return -1;
++}
++#endif
++#else
+ static inline long kexec_file_load(int kernel_fd, int initrd_fd,
+ unsigned long cmdline_len, const char *cmdline_ptr,
+ unsigned long flags)
+@@ -93,6 +113,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd,
+ return (long) syscall(__NR_kexec_file_load, kernel_fd, initrd_fd,
+ cmdline_len, cmdline_ptr, flags);
+ }
++#endif
+
+ #define KEXEC_ON_CRASH 0x00000001
+ #define KEXEC_PRESERVE_CONTEXT 0x00000002
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch
new file mode 100644
index 00000000..3d446839
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0007-kexec.c-add-guard-around-ENOTSUP.patch
@@ -0,0 +1,37 @@
+From e6bd7a1bcfbd3e54efc81fbd7d60d915f9af0632 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 17 Apr 2018 11:35:14 +0200
+Subject: [PATCH] kexec.c: add guard around ENOTSUP
+
+Fix
+
+ kexec.c: In function 'main':
+ kexec.c:1515:11: error: 'ENOTSUP' undeclared
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/kexec.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/kexec/kexec.c b/kexec/kexec.c
+index 313d9fe..b5a8a1e 100644
+--- a/kexec/kexec.c
++++ b/kexec/kexec.c
+@@ -1501,6 +1501,7 @@ int main(int argc, char *argv[])
+ */
+ case -EINVAL:
+ case -ENOEXEC:
++#ifndef __KLIBC__
+ /*
+ * ENOTSUP can be unsupported image
+ * type or unsupported PE signature
+@@ -1513,6 +1514,7 @@ int main(int argc, char *argv[])
+ * kernel bug
+ */
+ case -ENOTSUP:
++#endif
+ do_kexec_file_syscall = 0;
+ break;
+ }
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch
new file mode 100644
index 00000000..cfc51cf7
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0008-kexec.c-replace-mising-BLKGETSIZE64.patch
@@ -0,0 +1,32 @@
+From 12c7b09c3152f2b3475d081691a26bd1a5633256 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 17 Apr 2018 11:38:42 +0200
+Subject: [PATCH] kexec.c: replace missing BLKGETSIZE64
+
+Fix
+
+ kexec.c: In function 'slurp_file_generic':
+ kexec.c:564:19: error: 'BLKGETSIZE64' undeclared
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/kexec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/kexec/kexec.c b/kexec/kexec.c
+index b5a8a1e..7842f8b 100644
+--- a/kexec/kexec.c
++++ b/kexec/kexec.c
+@@ -54,6 +54,10 @@
+ #define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded"
+ #define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded"
+
++#ifndef BLKGETSIZE64
++#define BLKGETSIZE64 _IOR(0x12,114,size_t)
++#endif
++
+ unsigned long long mem_min = 0;
+ unsigned long long mem_max = ULONG_MAX;
+ static unsigned long kexec_flags = 0;
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch
new file mode 100644
index 00000000..df980b11
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch
@@ -0,0 +1,57 @@
+From ad598a71ffff6f86462211f252ac0c7b5de53869 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 17 Apr 2018 13:14:12 +0200
+Subject: [PATCH] vmcore-dmesg.c: work around missing imaxdiv()
+
+Convert to integer arithmetic for klibc.
+
+Fix
+
+ vmcore-dmesg.c: In function 'dump_dmesg_structured':
+ vmcore-dmesg.c:578:2: error: unknown type name 'imaxdiv_t'
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ vmcore-dmesg/vmcore-dmesg.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
+index e340ef4..1b27b71 100644
+--- a/vmcore-dmesg/vmcore-dmesg.c
++++ b/vmcore-dmesg/vmcore-dmesg.c
+@@ -575,8 +575,11 @@ static void dump_dmesg_structured(int fd)
+ ssize_t ret;
+ char *msg;
+ uint16_t text_len;
++#ifndef __KLIBC__
+ imaxdiv_t imaxdiv_sec, imaxdiv_usec;
+-
++#else
++ int64_t imaxdiv_sec, imaxdiv_usec;
++#endif
+ if (!log_buf_vaddr) {
+ fprintf(stderr, "Missing the log_buf symbol\n");
+ exit(60);
+@@ -645,12 +648,20 @@ static void dump_dmesg_structured(int fd)
+ exit(65);
+ }
+ ts_nsec = struct_val_u64(buf, log_offset_ts_nsec);
++#ifndef __KLIBC__
+ imaxdiv_sec = imaxdiv(ts_nsec, 1000000000);
+ imaxdiv_usec = imaxdiv(imaxdiv_sec.rem, 1000);
+
+ len += sprintf(out_buf + len, "[%5llu.%06llu] ",
+ (long long unsigned int)imaxdiv_sec.quot,
+ (long long unsigned int)imaxdiv_usec.quot);
++#else
++ imaxdiv_sec = ts_nsec / 1000000000;
++ imaxdiv_usec = (ts_nsec % 1000000000) / 1000;
++ len += sprintf(out_buf + len, "[%5llu.%06llu] ",
++ (long long unsigned int)imaxdiv_sec,
++ (long long unsigned int)imaxdiv_usec);
++#endif
+
+ /* escape non-printable characters */
+ text_len = struct_val_u16(buf, log_offset_text_len);
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch
new file mode 100644
index 00000000..cff1485e
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0010-fs2dt.c-work-around-missing-getline.patch
@@ -0,0 +1,47 @@
+From edefda702d906d472ee7a675f6b506d5cfca7ac8 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 17 Apr 2018 13:48:25 +0200
+Subject: [PATCH] fs2dt.c: work around missing getline()
+
+This simple case can be rewrtten with fgets()
+
+Fix
+
+ fs2dt.c: In function 'dt_copy_old_root_param':
+ fs2dt.c:541:6: warning: implicit declaration of function 'getline'
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/fs2dt.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
+index 07a5e2f..d635636 100644
+--- a/kexec/fs2dt.c
++++ b/kexec/fs2dt.c
+@@ -531,6 +531,9 @@ static void dt_copy_old_root_param(void)
+ char *last_cmdline = NULL;
+ char *p, *old_param;
+ size_t len = 0;
++#ifdef __KLIBC__
++ char buf[512];
++#endif
+
+ strcpy(filename, pathname);
+ strcat(filename, "bootargs");
+@@ -538,8 +541,13 @@ static void dt_copy_old_root_param(void)
+ if (!fp)
+ return;
+
++#ifndef __KLIBC__
+ if (getline(&last_cmdline, &len, fp) == -1)
+ die("unable to read %s\n", filename);
++#else
++ last_cmdline = fgets(buf, 200, fp);
++ last_cmdline[strlen(last_cmdline) - 1] = '\0';
++#endif
+
+ p = strstr(last_cmdline, "root=");
+ if (p) {
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch
new file mode 100644
index 00000000..636151be
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0011-purgatory-Makefile-adapt-to-klcc.patch
@@ -0,0 +1,38 @@
+From 9b6866b106eb3ad11115bd591a23e65a68dd847d Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Tue, 21 Aug 2018 16:31:44 +0200
+Subject: [PATCH 11/11] purgatory Makefile: adapt to klcc
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ purgatory/Makefile | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/purgatory/Makefile b/purgatory/Makefile
+index 49ce80a..72eefaa 100644
+--- a/purgatory/Makefile
++++ b/purgatory/Makefile
+@@ -47,7 +47,7 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
+ $(PURGATORY): CC=$(TARGET_CC)
+ $(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
+ $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+- -Os -fno-builtin -ffreestanding \
++ -Os -fno-builtin -ffreestanding -nostdinc \
+ -fno-zero-initialized-in-bss \
+ -fno-PIC -fno-PIE -fno-stack-protector
+
+@@ -59,8 +59,8 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -Iinclude \
+ -I$(shell $(CC) -print-file-name=include)
+ $(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
+- -Wl,--no-undefined -nostartfiles -nostdlib \
+- -nodefaultlibs -e purgatory_start -r \
++ -Wl,--no-undefined -Wl,-no-pie -Wl,-nostartfiles -Wl,-nostdlib \
++ -Wl,-nodefaultlibs -Wl,--entry=purgatory_start -Wl,-r \
+ -Wl,-Map=$(PURGATORY_MAP)
+
+ $(PURGATORY): $(PURGATORY_OBJS)
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch
new file mode 100644
index 00000000..20934da8
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0012-purgatory-string.c-avoid-inclusion-of-string.h.patch
@@ -0,0 +1,31 @@
+From 2d2ad16f9328a7cbb3f5b8479ae93eb923a0727f Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Thu, 19 Apr 2018 00:28:14 +0200
+Subject: [PATCH] purgatory/string.c: avoid inclusion of string.h
+
+Fix
+
+ purgatory/string.c:39:5: error: conflicting types for 'memcmp'
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ purgatory/string.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/purgatory/string.c b/purgatory/string.c
+index f06c460..c5e978a 100644
+--- a/purgatory/string.c
++++ b/purgatory/string.c
+@@ -1,5 +1,7 @@
+ #include <stddef.h>
++#ifndef __KLIBC__
+ #include <string.h>
++#endif
+
+ size_t strnlen(const char *s, size_t max)
+ {
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch
new file mode 100644
index 00000000..5d1664f7
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0013-sha256.h-avoid-inclusion-of-sys-types.h.patch
@@ -0,0 +1,36 @@
+From ec6000b9f287e62cb0746e26cfa4372c7ea528f4 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Thu, 19 Apr 2018 23:26:43 +0200
+Subject: [PATCH] sha256.h: avoid inclusion of sys/types.h
+
+Fix
+
+ purgatory/printf.c:2:10: fatal error: limits.h:
+ No such file or directory
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ util_lib/include/sha256.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/util_lib/include/sha256.h b/util_lib/include/sha256.h
+index 467fb22..40fd3ed 100644
+--- a/util_lib/include/sha256.h
++++ b/util_lib/include/sha256.h
+@@ -1,7 +1,11 @@
+ #ifndef SHA256_H
+ #define SHA256_H
+
++#ifndef __KLIBC__
+ #include <sys/types.h>
++#else
++#include <stddef.h>
++#endif
+ #include <stdint.h>
+
+ typedef struct
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch
new file mode 100644
index 00000000..ad212669
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0014-add-if_nameindex-from-musl.patch
@@ -0,0 +1,152 @@
+From b15e9610b4ab52c381e712241d50dea96d50d873 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 2 May 2018 23:14:19 +0200
+Subject: [PATCH 14/14] add if_nameindex from musl
+
+Taken from musl, minimal changes.
+klibc lacks struct and func
+
+Fix
+
+ ifdown.o: In function `ifdown':
+ ifdown.c (.text+0x30): undefined reference to `if_nameindex'
+
+While there add klibc-specific guard and include sys/types.h
+to fix :
+
+ /kexec/if_nameindex.c:2:
+ /usr/lib/klibc/include/linux/types.h:22:0:
+ warning: "__bitwise" redefined
+ #define __bitwise __bitwise__
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ kexec/Makefile | 2 +-
+ kexec/if_nameindex.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ kexec/if_nameindex.h | 15 ++++++++++++
+ kexec/ifdown.c | 3 +++
+ 4 files changed, 83 insertions(+), 1 deletion(-)
+ create mode 100644 kexec/if_nameindex.c
+ create mode 100644 kexec/if_nameindex.h
+
+diff --git a/kexec/Makefile b/kexec/Makefile
+index 4db84d8..fb7520b 100644
+--- a/kexec/Makefile
++++ b/kexec/Makefile
+@@ -11,7 +11,7 @@ KEXEC_SRCS = $(KEXEC_SRCS_base)
+ KEXEC_GENERATED_SRCS =
+
+ KEXEC_SRCS_base += kexec/kexec.c
+-KEXEC_SRCS_base += kexec/ifdown.c
++KEXEC_SRCS_base += kexec/if_nameindex kexec/ifdown.c
+ KEXEC_SRCS_base += kexec/kexec-elf.c
+ KEXEC_SRCS_base += kexec/kexec-elf-exec.c
+ KEXEC_SRCS_base += kexec/kexec-elf-core.c
+diff --git a/kexec/if_nameindex.c b/kexec/if_nameindex.c
+new file mode 100644
+index 0000000..e586e41
+--- /dev/null
++++ b/kexec/if_nameindex.c
+@@ -0,0 +1,64 @@
++#define _GNU_SOURCE
++#ifdef __KLIBC__
++#include <sys/types.h>
++#endif
++#include <netinet/in.h>
++#include <net/if.h>
++#include <stdlib.h>
++#include <sys/socket.h>
++#include <sys/ioctl.h>
++#include <errno.h>
++#include <sys/syscall.h>
++#include <stdio.h>
++#ifdef __KLIBC__
++#include "if_nameindex.h"
++#endif
++
++static void *do_nameindex(int s, size_t n)
++{
++ size_t i, len, k;
++ struct ifconf conf;
++ struct if_nameindex *idx;
++
++ idx = malloc(n * (sizeof(struct if_nameindex)+sizeof(struct ifreq)));
++ if (!idx) return 0;
++
++ conf.ifc_buf = (void *)&idx[n];
++ conf.ifc_len = len = n * sizeof(struct ifreq);
++ if (ioctl(s, SIOCGIFCONF, &conf) < 0) {
++ free(idx);
++ return 0;
++ }
++ if (conf.ifc_len == len) {
++ free(idx);
++ return (void *)-1;
++ }
++
++ n = conf.ifc_len / sizeof(struct ifreq);
++ for (i=k=0; i<n; i++) {
++ if (ioctl(s, SIOCGIFINDEX, &conf.ifc_req[i]) < 0) {
++ k++;
++ continue;
++ }
++ idx[i-k].if_index = conf.ifc_req[i].ifr_ifindex;
++ idx[i-k].if_name = conf.ifc_req[i].ifr_name;
++ }
++ idx[i-k].if_name = 0;
++ idx[i-k].if_index = 0;
++
++ return idx;
++}
++
++struct if_nameindex *if_nameindex()
++{
++ size_t n;
++ void *p = 0;
++ int s = socket(AF_UNIX, SOCK_DGRAM, 0);
++ if (s>=0) {
++ for (n=0; (p=do_nameindex(s, n)) == (void *)-1; n++);
++/* __syscall(SYS_close, s); */
++ close(s);
++ }
++ errno = ENOBUFS;
++ return p;
++}
+diff --git a/kexec/if_nameindex.h b/kexec/if_nameindex.h
+new file mode 100644
+index 0000000..1725fbd
+--- /dev/null
++++ b/kexec/if_nameindex.h
+@@ -0,0 +1,15 @@
++#ifndef _NET_IF__NAMEINDEX_H
++#define _NET_IF_NAMEINDEX_H
++
++struct if_nameindex
++{
++ unsigned int if_index;
++ char *if_name;
++};
++
++unsigned int if_nametoindex (const char *);
++char *if_indextoname (unsigned int, char *);
++struct if_nameindex *if_nameindex (void);
++void if_freenameindex (struct if_nameindex *);
++
++#endif
+diff --git a/kexec/ifdown.c b/kexec/ifdown.c
+index 82c6141..cc3ca9f 100644
+--- a/kexec/ifdown.c
++++ b/kexec/ifdown.c
+@@ -18,6 +18,9 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
+
+ #include <netinet/in.h>
+ #include <net/if.h>
++#ifdef __KLIBC__
++#include "if_nameindex.h"
++#endif
+
+ /*
+ * First, we find all shaper devices and down them. Then we
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch
new file mode 100644
index 00000000..0b88b94c
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/0015-vmcore-dmesg-fix-warning.patch
@@ -0,0 +1,29 @@
+From 3294266c6a875c5009065c1ae5d0b86200c4147c Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Apr 2018 00:52:31 +0200
+Subject: [PATCH 6/6] vmcore-dmesg: fix warning
+
+ # define __bitwise
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ vmcore-dmesg/vmcore-dmesg.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
+index e340ef4..91e4789 100644
+--- a/vmcore-dmesg/vmcore-dmesg.c
++++ b/vmcore-dmesg/vmcore-dmesg.c
+@@ -2,6 +2,9 @@
+ #define _GNU_SOURCE
+ #define _LARGEFILE_SOURCE 1
+ #define _FILE_OFFSET_BITS 64
++#ifdef __KLIBC__
++#include <sys/types.h>
++#endif
+ #include <endian.h>
+ #include <byteswap.h>
+ #include <stdio.h>
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch
new file mode 100644
index 00000000..24be4dd7
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64-crashdump-arm64.c-fix-warning.patch
@@ -0,0 +1,34 @@
+From 6f69f489a442b3a192e4c08748ee8c4d31c75dae Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Apr 2018 00:46:16 +0200
+Subject: [PATCH 5/6] arm64: crashdump-arm64.c: fix warning
+
+ from ../git/kexec/kexec.h:6,
+ from ../git/kexec/arch/arm64/crashdump-arm64.c:18:
+/tmp/build/tmp-musl/work/aarch64-oe-linux-musl/kexec-tools-klibc/0.6+gitAUTOINC+
+0481e9ed61-r0/recipe-sysroot/usr/lib/klibc/include/klibc/compiler.h:144:0: warni
+ng: "__bitwise" redefined
+ # define __bitwise
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ kexec/arch/arm64/crashdump-arm64.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
+index 4fd7aa8..890d88f 100644
+--- a/kexec/arch/arm64/crashdump-arm64.c
++++ b/kexec/arch/arm64/crashdump-arm64.c
+@@ -13,6 +13,9 @@
+ #define _GNU_SOURCE
+
+ #include <errno.h>
++#ifdef __KLIBC__
++#include <sys/types.h>
++#endif
+ #include <linux/elf.h>
+
+ #include "kexec.h"
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch
new file mode 100644
index 00000000..b22ac3ac
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch
@@ -0,0 +1,61 @@
+From 10afeecd10499fbd64b2c68d3b076c6906df441f Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Wed, 5 Sep 2018 17:07:48 +0200
+Subject: [PATCH] kexec-arm64.c: workaround for getrandom() syscall
+
+The syscall was added to OE's klibc.
+Fix
+
+| ../git/kexec/arch/arm64/kexec-arm64.c:19:10: fatal error: syscall.h: No such file or directory
+| #include <syscall.h>
+
+and
+
+| ../git/kexec/arch/arm64/kexec-arm64.c: In function 'setup_2nd_dtb':
+| ../git/kexec/arch/arm64/kexec-arm64.c:499:12: warning: implicit declaration of function 'getrandom'; did you mean 'srandom'? [-Wimplicit-function-declaration]
+| result = getrandom(&fdt_val64,
+
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ kexec/arch/arm64/kexec-arm64.c | 12 +++++++++++-
+ 1 file changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
+index 7a12479..8a7f5c5 100644
+--- a/kexec/arch/arm64/kexec-arm64.c
++++ b/kexec/arch/arm64/kexec-arm64.c
+@@ -16,7 +16,11 @@
+ #include <elf.h>
+
+ #include <unistd.h>
++
++#ifndef __KLIBC__
+ #include <syscall.h>
++#endif
++
+ #include <errno.h>
+ #include <linux/random.h>
+
+@@ -487,10 +491,16 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash)
+ * have a valid random seed to pass to the
+ * secondary kernel.
+ */
++#ifndef __KLIBC__
+ result = syscall(SYS_getrandom, &fdt_val64,
+ sizeof(fdt_val64),
+ GRND_NONBLOCK);
+-
++#else
++ extern ssize_t getrandom(void *, size_t, unsigned int);
++ result = getrandom(&fdt_val64,
++ sizeof(fdt_val64),
++ GRND_NONBLOCK);
++#endif
+ if(result == -1) {
+ dbgprintf("%s: Reading random bytes failed.\n",
+ __func__);
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch
new file mode 100644
index 00000000..7decbac4
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm64_kexec-image-header.h-add-missing-le64toh.patch
@@ -0,0 +1,40 @@
+From af7d06a753a4c377b7ffe587da67a6ba56048bea Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Thu, 19 Apr 2018 10:47:17 +0200
+Subject: [PATCH 2/2] kexec/arm64: image-header.h: add macro for le64toh
+
+Fix
+
+ kexec-arm64.c:(.text+0x370): undefined reference to `le64toh'
+ kexec-arm64.c:(.text+0x380): undefined reference to `le64toh'
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/arch/arm64/image-header.h | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/kexec/arch/arm64/image-header.h b/kexec/arch/arm64/image-header.h
+index 158d411..10ed2d6 100644
+--- a/kexec/arch/arm64/image-header.h
++++ b/kexec/arch/arm64/image-header.h
+@@ -8,6 +8,15 @@
+ #include <endian.h>
+ #include <stdint.h>
+
++#ifdef __KLIBC__
++#if __BYTE_ORDER == __LITTLE_ENDIAN
++#define le64toh(x) (x)
++#endif
++#if __BYTE_ORDER == __BIG_ENDIAN
++#define le64toh(x) __bswap_64(x)
++#endif
++#endif
++
+ /**
+ * struct arm64_image_header - arm64 kernel image header.
+ *
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch
new file mode 100644
index 00000000..c6afdfae
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump-fix-buffer-align.patch
@@ -0,0 +1,44 @@
+From 06b0d43c20f7c6200902d4c6db3d33416877f71c Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 26 Aug 2018 21:40:06 +0200
+Subject: [PATCH 1/1] arm- backport from oe-core
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ kexec/arch/arm/crashdump-arm.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
+index 2530b29..af2600d 100644
+--- a/kexec/arch/arm/crashdump-arm.c
++++ b/kexec/arch/arm/crashdump-arm.c
+@@ -240,6 +240,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+ void *buf;
+ int err;
+ int last_ranges;
++ unsigned short align_bit_shift = 20;
+
+ /*
+ * First fetch all the memory (RAM) ranges that we are going to pass to
+@@ -281,6 +282,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+
+ /* for support LPAE enabled kernel*/
+ elf_info.class = ELFCLASS64;
++ align_bit_shift = 21;
+
+ err = crash_create_elf64_headers(info, &elf_info,
+ usablemem_rgns.ranges,
+@@ -302,8 +304,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+ * 1MB) so that available memory passed in kernel command line will be
+ * aligned to 1MB. This is because kernel create_mapping() wants memory
+ * regions to be aligned to SECTION_SIZE.
++ * The SECTION_SIZE of LPAE kernel is '1UL << 21' defined in pgtable-3level.h
+ */
+- elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20,
++ elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << align_bit_shift,
+ crash_kernel_mem.start,
+ crash_kernel_mem.end, -1, 0);
+
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump.patch
new file mode 100644
index 00000000..95962636
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/arm_crashdump.patch
@@ -0,0 +1,31 @@
+From 6dae4752a53973c152b3e91e8a4ca74a486dae8b Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:00 +0200
+Subject: [PATCH] use our elf.h header
+
+Fix
+
+ kexec/arch/arm/crashdump-arm.c:70:13: error: 'EM_ARM' undeclared here
+ (not in a function); did you mean 'EM_860'?
+ .machine = EM_ARM,
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/arch/arm/crashdump-arm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
+index daa4788..2530b29 100644
+--- a/kexec/arch/arm/crashdump-arm.c
++++ b/kexec/arch/arm/crashdump-arm.c
+@@ -21,7 +21,7 @@
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ #include <limits.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch
new file mode 100644
index 00000000..26d18eb6
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/kexec-x32.patch
@@ -0,0 +1,88 @@
+x86_64: Add support to build kexec-tools with x32 ABI
+
+Summary of changes,
+
+configure.ac: Add test for detect x32 ABI.
+purgatory/arch/x86_64/Makefile: Not use mcmodel large when
+ x32 ABI is set.
+kexec/arch/x86_64/kexec-elf-rel-x86_64.c: When x32 ABI is set
+ use ELFCLASS32 instead of ELFCLASS64.
+kexec/kexec-syscall.h: Add correct syscall number for x32 ABI.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
+Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
+
+---
+ configure.ac | 9 +++++++++
+ kexec/arch/x86_64/kexec-elf-rel-x86_64.c | 4 ++++
+ kexec/kexec-syscall.h | 4 ++++
+ purgatory/arch/x86_64/Makefile | 4 +++-
+ 4 files changed, 20 insertions(+), 1 deletion(-)
+
+Index: kexec-tools-2.0.10/configure.ac
+===================================================================
+--- kexec-tools-2.0.10.orig/configure.ac
++++ kexec-tools-2.0.10/configure.ac
+@@ -56,6 +56,15 @@ case $target_cpu in
+ ;;
+ ia64|x86_64|alpha|m68k )
+ ARCH="$target_cpu"
++
++ dnl ---Test for x32 ABI in x86_64
++ if test "x$ARCH" = "xx86_64" ; then
++ AC_EGREP_CPP(x32_test,
++ [#if defined(__x86_64__) && defined (__ILP32__)
++ x32_test
++ #endif
++ ], SUBARCH='x32', SUBARCH='64')
++ fi
+ ;;
+ * )
+ AC_MSG_ERROR([unsupported architecture $target_cpu])
+Index: kexec-tools-2.0.10/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+===================================================================
+--- kexec-tools-2.0.10.orig/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
++++ kexec-tools-2.0.10/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+@@ -8,7 +8,11 @@ int machine_verify_elf_rel(struct mem_eh
+ if (ehdr->ei_data != ELFDATA2LSB) {
+ return 0;
+ }
++#ifdef __ILP32__
++ if (ehdr->ei_class != ELFCLASS32) {
++#else
+ if (ehdr->ei_class != ELFCLASS64) {
++#endif
+ return 0;
+ }
+ if (ehdr->e_machine != EM_X86_64) {
+Index: kexec-tools-2.0.10/kexec/kexec-syscall.h
+===================================================================
+--- kexec-tools-2.0.10.orig/kexec/kexec-syscall.h
++++ kexec-tools-2.0.10/kexec/kexec-syscall.h
+@@ -31,8 +31,12 @@
+ #define __NR_kexec_load 268
+ #endif
+ #ifdef __x86_64__
++#ifdef __ILP32__
++#define __NR_kexec_load 528
++#else
+ #define __NR_kexec_load 246
+ #endif
++#endif
+ #ifdef __s390x__
+ #define __NR_kexec_load 277
+ #endif
+Index: kexec-tools-2.0.10/purgatory/arch/x86_64/Makefile
+===================================================================
+--- kexec-tools-2.0.10.orig/purgatory/arch/x86_64/Makefile
++++ kexec-tools-2.0.10/purgatory/arch/x86_64/Makefile
+@@ -23,4 +23,6 @@ x86_64_PURGATORY_SRCS += purgatory/arch/
+ x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
+ x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c
+
+-x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
++ifeq ($(SUBARCH),64)
++ x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
++endif
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc-purgatory-Makefile-remove-unknown-flags.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc-purgatory-Makefile-remove-unknown-flags.patch
new file mode 100644
index 00000000..c3b2071b
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc-purgatory-Makefile-remove-unknown-flags.patch
@@ -0,0 +1,34 @@
+From 709dfe457c07aa0275f3da14634cbce5cf1029dc Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Thu, 19 Apr 2018 19:26:53 +0200
+Subject: [PATCH 3/3] powerpc/purgatory: Makefile: remove unknown flags for
+ powerpc
+
+Fix
+
+ powerpc-oe-linux-musl-ld: unrecognised emulation mode: soft-float
+ Supported emulations: elf32ppclinux elf32ppc elf32ppcsim elf32lppclinux
+ elf32lppc elf32lppcsim elf64ppc elf64lppc
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ purgatory/arch/ppc/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/purgatory/arch/ppc/Makefile b/purgatory/arch/ppc/Makefile
+index c85c58a..cd44a16 100644
+--- a/purgatory/arch/ppc/Makefile
++++ b/purgatory/arch/ppc/Makefile
+@@ -7,7 +7,7 @@ ppc_PURGATORY_SRCS += purgatory/arch/ppc/misc.S
+ ppc_PURGATORY_SRCS += purgatory/arch/ppc/purgatory-ppc.c
+ ppc_PURGATORY_SRCS += purgatory/arch/ppc/console-ppc.c
+
+-ppc_PURGATORY_EXTRA_CFLAGS += -msoft-float
++#ppc_PURGATORY_EXTRA_CFLAGS += -msoft-float
+
+ dist += purgatory/arch/ppc/Makefile $(ppc_PURGATORY_SRCS) \
+ purgatory/arch/ppc/purgatory-ppc.h purgatory/arch/ppc/ppc_asm.h
+--
+2.7.4
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch
new file mode 100644
index 00000000..dc97d930
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/powerpc_change-the-memory-size-limit.patch
@@ -0,0 +1,35 @@
+From b19b68eab567aa534cf8dec79fe18e3dc0e14043 Mon Sep 17 00:00:00 2001
+From: Quanyang Wang <quanyang.wang@windriver.com>
+Date: Tue, 16 Jun 2015 12:59:57 +0800
+Subject: [PATCH] powerpc: change the memory size limit
+
+When run "kexec" in powerpc board, the kexec has a limit that
+the kernel text and bss size must be less than 24M. But now
+some kernel size exceed the limit. So we need to change the limit,
+else will get the error log as below:
+
+my_load:669: do
+Could not find a free area of memory of 0x12400 bytes...
+Could not find a free area of memory of 0x13000 bytes...
+locate_hole failed
+
+Upstream-Status: Pending
+
+Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
+---
+ kexec/arch/ppc/kexec-ppc.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: kexec-tools-2.0.10/kexec/arch/ppc/kexec-ppc.h
+===================================================================
+--- kexec-tools-2.0.10.orig/kexec/arch/ppc/kexec-ppc.h
++++ kexec-tools-2.0.10/kexec/arch/ppc/kexec-ppc.h
+@@ -42,7 +42,7 @@ void dol_ppc_usage(void);
+ * During inital setup the kernel does not map the whole memory but a part of
+ * it. On Book-E that is 64MiB, 601 24MiB or 256MiB (if possible).
+ */
+-#define KERNEL_ACCESS_TOP (24 * 1024 * 1024)
++#define KERNEL_ACCESS_TOP (36 * 1024 * 1024)
+
+ /* boot block version 17 as defined by the linux kernel */
+ struct bootblock {
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch
new file mode 100644
index 00000000..0d0ed23c
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_basename.patch
@@ -0,0 +1,30 @@
+From 5f47c30759684cea9a7a409646686c1a358b78ac Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:05 +0200
+Subject: [PATCH] replace basename() with sscanf()
+
+klibc lacks basename()
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/arch/i386/x86-linux-setup.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
+index 6c7d260..7850083 100644
+--- a/kexec/arch/i386/x86-linux-setup.c
++++ b/kexec/arch/i386/x86-linux-setup.c
+@@ -304,9 +304,9 @@ static int add_edd_entry(struct x86_linux_param_header *real_mode,
+ memset(edd_info, 0, sizeof(struct edd_info));
+
+ /* extract the device number */
+- if (sscanf(basename(sysfs_name), "int13_dev%hhx", &devnum) != 1) {
++ if (sscanf(strrchr(sysfs_name,'/') + 1, "int13_dev%hhx", &devnum) != 1) {
+ fprintf(stderr, "Invalid format of int13_dev dir "
+- "entry: %s\n", basename(sysfs_name));
++ "entry: %s\n", strrchr(sysfs_name,'/') + 1);
+ return -1;
+ }
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch
new file mode 100644
index 00000000..1c471f55
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_kexec_test.patch
@@ -0,0 +1,30 @@
+From 9de68ec5af8db2eff352f12da28145fe5e96244d Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:05 +0200
+Subject: [PATCH] do not build test
+
+The purpose of this recipe is to build the smallest
+binaries. kexek klibc-static for armv5 is around 86 KiB
+
+Upstream-Status: Inappropriate [embedded specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ Makefile.in | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index fb01134..440730d 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -173,8 +173,8 @@ PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
+ PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
+
+ MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE)
+-BINARIES_i386:=$(KEXEC_TEST)
+-BINARIES_x86_64:=$(KEXEC_TEST)
++#BINARIES_i386:=$(KEXEC_TEST)
++#BINARIES_x86_64:=$(KEXEC_TEST)
+ BINARIES:=$(KEXEC) $(VMCORE_DMESG) $(BINARIES_$(ARCH))
+
+ UNINSTALL_KDUMP = $(sbindir)/kdump
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch
new file mode 100644
index 00000000..493f298a
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_sys_io.patch
@@ -0,0 +1,36 @@
+From a992ee014efacdc98d5658be9930dcab0eaadfd7 Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:04 +0200
+Subject: [PATCH] i386: replace with our io.h
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ purgatory/arch/i386/pic.c | 2 +-
+ purgatory/arch/i386/vga.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/purgatory/arch/i386/pic.c b/purgatory/arch/i386/pic.c
+index c23c459..c5f7046 100644
+--- a/purgatory/arch/i386/pic.c
++++ b/purgatory/arch/i386/pic.c
+@@ -16,7 +16,7 @@
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+-#include <sys/io.h>
++#include "include/arch/io.h"
+ #include <purgatory.h>
+ #include "purgatory-x86.h"
+
+diff --git a/purgatory/arch/i386/vga.c b/purgatory/arch/i386/vga.c
+index e65976c..d079d96 100644
+--- a/purgatory/arch/i386/vga.c
++++ b/purgatory/arch/i386/vga.c
+@@ -1,4 +1,4 @@
+-#include <sys/io.h>
++#include "include/arch/io.h"
+ #include <purgatory.h>
+ #include "purgatory-x86.h"
+
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch
new file mode 100644
index 00000000..2f0ad2ea
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc/x86_vfscanf.patch
@@ -0,0 +1,43 @@
+From 423c3f6f41fe04f4512e2a97a130f072d53dd4cf Mon Sep 17 00:00:00 2001
+From: OpenEmbedded <oe.patch@oe>
+Date: Wed, 11 Apr 2018 22:51:05 +0200
+Subject: [PATCH] x86-linux-setup.c: replace vfscanf() with vsscanf()
+
+klibc lacks vfscanf()
+
+Upstream-Status: Inappropriate [klibc specific]
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+---
+ kexec/arch/i386/x86-linux-setup.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
+index 7850083..e190356 100644
+--- a/kexec/arch/i386/x86-linux-setup.c
++++ b/kexec/arch/i386/x86-linux-setup.c
+@@ -200,6 +200,8 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line,
+ FILE *fp;
+ int retno;
+ char filename[PATH_MAX];
++ long line_size = MAX_LINE;
++ char *line;
+
+ snprintf(filename, PATH_MAX, "%s/%s", dir, file);
+ filename[PATH_MAX-1] = 0;
+@@ -210,7 +212,14 @@ static int file_scanf(const char *dir, const char *file, const char *scanf_line,
+ }
+
+ va_start(argptr, scanf_line);
+- retno = vfscanf(fp, scanf_line, argptr);
++
++ line = xmalloc(sizeof(line) * line_size);
++ while(fgets(line, sizeof(line), fp) != NULL ) {
++ line_size += MAX_LINE;
++ line = xrealloc(line,line_size);
++ }
++ retno = vsscanf(line, scanf_line, argptr);
++
+ va_end(argptr);
+
+ fclose(fp);
diff --git a/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb
new file mode 100644
index 00000000..cc1c5518
--- /dev/null
+++ b/external/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_git.bb
@@ -0,0 +1,97 @@
+# the binaries are statically linked against klibc
+SUMMARY = "Kexec tools, statically compiled against klibc"
+AUTHOR = "Eric Biederman"
+HOMEPAGE = "http://kernel.org/pub/linux/utils/kernel/kexec/"
+SECTION = "kernel/userland"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=ea5bed2f60d357618ca161ad539f7c0a \
+ file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09"
+PV = "2.0.17+git${SRCPV}"
+
+DEPENDS = "zlib xz"
+
+inherit klibc autotools
+
+SRC_URI = "git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git"
+SRCREV = "b9de21ef51a7ceab7122a707c188602eae22c4ee"
+
+BUILD_PATCHES = "file://0001-force-static-build.patch \
+ file://0002-Adjust-the-order-of-headers-to-fix-build-for-musl.patch"
+
+KLIBC_PATCHES += " \
+ file://0003-kexec-elf-rel-use-our-elf.h.patch \
+ file://0004-kexec-elf-exec.c-replace-with-our-err.h.patch \
+ file://0005-crashdump-elf.c-work-around-for-sysconf-_SC_NPROCESS.patch \
+ file://0006-kexec-syscall.h-work-around-missing-syscall-wrapper.patch \
+ file://0007-kexec.c-add-guard-around-ENOTSUP.patch \
+ file://0008-kexec.c-replace-mising-BLKGETSIZE64.patch \
+ file://0009-vmcore-dmesg.c-work-around-missing-imaxdiv.patch \
+ file://0010-fs2dt.c-work-around-missing-getline.patch \
+ file://0011-purgatory-Makefile-adapt-to-klcc.patch \
+ file://0012-purgatory-string.c-avoid-inclusion-of-string.h.patch \
+ file://0013-sha256.h-avoid-inclusion-of-sys-types.h.patch \
+ file://0014-add-if_nameindex-from-musl.patch \
+ file://0015-vmcore-dmesg-fix-warning.patch"
+
+WARNING_FIXES = ""
+FROM_OE_CORE = "file://arm_crashdump-fix-buffer-align.patch \
+ file://powerpc_change-the-memory-size-limit.patch \
+ file://kexec-x32.patch"
+
+SRC_URI += "${BUILD_PATCHES} ${KLIBC_PATCHES} ${WARNING_FIXES} ${FROM_OE_CORE}"
+
+SRC_URI_append_arm = " file://arm_crashdump.patch"
+
+SRC_URI_append_x86 = " file://x86_sys_io.patch file://x86_basename.patch \
+ file://x86_vfscanf.patch file://x86_kexec_test.patch"
+
+SRC_URI_append_x86-64 = " file://x86_sys_io.patch file://x86_basename.patch \
+ file://x86_vfscanf.patch file://x86_kexec_test.patch"
+
+SRC_URI_append_aarch64 = " file://arm64_kexec-image-header.h-add-missing-le64toh.patch \
+ file://arm64-crashdump-arm64.c-fix-warning.patch \
+ file://arm64_kexec-arm64.c-workaround-for-getrandom-syscall.patch"
+
+SRC_URI_append_powerpc = " file://powerpc-purgatory-Makefile-remove-unknown-flags.patch"
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF += "--without-zlib --without-lzma --without-xen"
+
+# fix purgatory/printf.c:2:10: fatal error: limits.h: No such file or directory
+# fix include/limits.h:42:10: fatal error: bitsize/limits.h: No such file or directory
+COMMON_CFLAGS += "-O2 -I${STAGING_DIR_HOST}${libdir}/klibc/include -I${S}/purgatory/include"
+CFLAGS_x86_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+CFLAGS_x86-64_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits64"
+CFLAGS_arm_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+CFLAGS_aarch64_append = "${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits64"
+CFLAGS_mips_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+CFLAGS_mipsel_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+CFLAGS_mips64_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits64"
+CFLAGS_mips64el_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits64"
+CFLAGS_powerpc_append = " ${COMMON_CFLAGS} -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+
+
+do_compile_prepend() {
+ # Remove the prepackaged config.h from the source tree as it overrides
+ # the same file generated by configure and placed in the build tree
+ rm -f ${S}/include/config.h
+
+ # Remove the '*.d' file to make sure the recompile is OK
+ for dep in `find ${B} -type f -name '*.d'`; do
+ dep_no_d="`echo $dep | sed 's#.d$##'`"
+ # Remove file.d when there is a file.o
+ if [ -f "$dep_no_d.o" ]; then
+ rm -f $dep
+ fi
+ done
+}
+
+PACKAGES =+ "kexec-klibc vmcore-dmesg-klibc"
+
+FILES_kexec-klibc = "${sbindir}/kexec"
+FILES_vmcore-dmesg-klibc = "${sbindir}/vmcore-dmesg"
+
+INSANE_SKIP_${PN} = "arch"
+
+COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|powerpc.*|mips.*)-(linux|freebsd.*)'