Yocto 2.5

Move OpenBMC to Yocto 2.5(sumo)

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I5c5ad6904a16e14c1c397f0baf10c9d465594a78
diff --git a/import-layers/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi.inc b/import-layers/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi.inc
index da36ca7..65c2ab7 100644
--- a/import-layers/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi.inc
+++ b/import-layers/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi.inc
@@ -19,26 +19,21 @@
 KBUILD_DEFCONFIG_raspberrypi3-64 ?= "bcmrpi3_defconfig"
 
 # CMDLINE for raspberrypi
-CMDLINE ?= "dwc_otg.lpm_enable=0 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
+SERIAL = "${@oe.utils.conditional("ENABLE_UART", "1", "console=serial0,115200", "", d)}"
+CMDLINE ?= "dwc_otg.lpm_enable=0 ${SERIAL} root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
 
 # Add the kernel debugger over console kernel command line option if enabled
-CMDLINE_append = ' ${@base_conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}'
+CMDLINE_append = ' ${@oe.utils.conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}'
 
 # Disable rpi logo on boot
-CMDLINE_append += ' ${@base_conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}'
+CMDLINE_append += ' ${@oe.utils.conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}'
 
 # You can define CMDLINE_DEBUG as "debug" in your local.conf or distro.conf
 # to enable kernel debugging.
 CMDLINE_DEBUG ?= ""
 CMDLINE_append = " ${CMDLINE_DEBUG}"
 
-# Quirk for udev greater or equal 141
-UDEV_GE_141 ?= "1"
-
-# Enable OABI compat for people stuck with obsolete userspace
-ARM_KEEP_OABI ?= "1"
-
-KERNEL_INITRAMFS ?= '${@base_conditional("INITRAMFS_IMAGE_BUNDLE", "1", "1", "", d)}'
+KERNEL_INITRAMFS ?= '${@oe.utils.conditional("INITRAMFS_IMAGE_BUNDLE", "1", "1", "", d)}'
 
 KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains("MACHINE_FEATURES", "pitft28r", "stmpe-ts", "", d)}"
 
@@ -61,83 +56,54 @@
     fi
 }
 
+config_setup() {
+    # From kernel.bbclass. Unfortunately, this is needed to support builds that
+    # use devtool. The reason is as follows:
+    #
+    # - In devtool builds, externalsrc.bbclass gets inherited and sets a list of
+    # SRCTREECOVEREDTASKS, which don't get run because they affect the source
+    # tree and, when using devtool, we want the developer's changes to be the
+    # single source of truth. kernel-yocto.bbclass adds do_kernel_configme to
+    # SRCTREECOVEREDTASKS, so it doesn't run in a devtool build., In a normal
+    # non-devtool build, do_kernel_configme creates ${B}.config.
+    #
+    # - Normally (e.g. in linux-yocto), it would be OK that do_kernel_configme
+    # doesn't run, because the first few lines of do_configure in kernel.bbclass
+    # populate ${B}.config from either ${S}.config (if it exists) for custom
+    # developer changes, or otherwise from ${WORDIR}/defconfig.
+    #
+    # - In linux-raspberrypi, we add do_configure_prepend, which tweaks
+    # ${B}.config. Since this runs *before* the kernel.bbclass do_configure,
+    # ${B}.config doesn't yet exist and we hit an error. Thus we need to move
+    # the logic from do_configure up to before our do_configure_prepend. Because
+    # we are copying only a portion of do_configure and not the whole thing,
+    # there is no clean way to do it using OE functionality, so we just
+    # copy-and-paste.
+    if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
+        mv "${S}/.config" "${B}/.config"
+    fi
+
+    # Copy defconfig to .config if .config does not exist. This allows
+    # recipes to manage the .config themselves in do_configure_prepend().
+    if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
+        cp "${WORKDIR}/defconfig" "${B}/.config"
+    fi
+}
+
 do_configure_prepend() {
+    config_setup
+
     mv -f ${B}/.config ${B}/.config.patched
     CONF_SED_SCRIPT=""
 
-    # oabi / eabi support
-    kernel_configure_variable AEABI y
-    if [ "${ARM_KEEP_OABI}" = "1" ] ; then
-        kernel_configure_variable OABI_COMPAT y
-    else
-        kernel_configure_variable OABI_COMPAT n
-    fi
-
-    # Set cmdline
-    kernel_configure_variable CMDLINE "\"${CMDLINE}\""
-
     # Localversion
     kernel_configure_variable LOCALVERSION "\"\""
-    kernel_configure_variable LOCALVERSION_AUTO n
 
-    # Udev quirks
-    # Newer versions of udev mandate that sysfs doesn't have deprecated entries
-    if [ "${UDEV_GE_141}" = "1" ] ; then
-        kernel_configure_variable SYSFS_DEPRECATED n
-        kernel_configure_variable SYSFS_DEPRECATED_V2 n
-        kernel_configure_variable HOTPLUG y
-        kernel_configure_variable UEVENT_HELPER_PATH "\"\""
-        kernel_configure_variable UNIX y
-        kernel_configure_variable SYSFS y
-        kernel_configure_variable PROC_FS y
-        kernel_configure_variable TMPFS y
-        kernel_configure_variable INOTIFY_USER y
-        kernel_configure_variable SIGNALFD y
-        kernel_configure_variable TMPFS_POSIX_ACL y
-        kernel_configure_variable BLK_DEV_BSG y
-        kernel_configure_variable DEVTMPFS y
-        kernel_configure_variable DEVTMPFS_MOUNT y
-    fi
-
-    # Newer inits like systemd need cgroup support
-    if [ "${KERNEL_ENABLE_CGROUPS}" = "1" ] ; then
-        kernel_configure_variable CGROUP_SCHED y
-        kernel_configure_variable CGROUPS y
-        kernel_configure_variable CGROUP_NS y
-        kernel_configure_variable CGROUP_FREEZER y
-        kernel_configure_variable CGROUP_DEVICE y
-        kernel_configure_variable CPUSETS y
-        kernel_configure_variable PROC_PID_CPUSET y
-        kernel_configure_variable CGROUP_CPUACCT y
-        kernel_configure_variable RESOURCE_COUNTERS y
-    fi
-
-    # root-over-nfs-over-usb-eth support. Limited, but should cover some cases
-    # Enable this by setting a proper CMDLINE_NFSROOT_USB.
-    if [ ! -z "${CMDLINE_NFSROOT_USB}" ]; then
-        oenote "Configuring the kernel for root-over-nfs-over-usb-eth with CMDLINE ${CMDLINE_NFSROOT_USB}"
-        kernel_configure_variable INET y
-        kernel_configure_variable IP_PNP y
-        kernel_configure_variable USB_GADGET y
-        kernel_configure_variable USB_GADGET_SELECTED y
-        kernel_configure_variable USB_ETH y
-        kernel_configure_variable NFS_FS y
-        kernel_configure_variable ROOT_NFS y
-        kernel_configure_variable ROOT_NFS y
-        kernel_configure_variable CMDLINE "\"${CMDLINE_NFSROOT_USB}\""
-    fi
     if [ ! -z "${KERNEL_INITRAMFS}" ]; then
-        kernel_configure_variable BLK_DEV_INITRD y
-        kernel_configure_variable INITRAMFS_SOURCE ""
-        kernel_configure_variable RD_GZIP y
         kernel_configure_variable OVERLAY_FS y
         kernel_configure_variable SQUASHFS y
         kernel_configure_variable UBIFS_FS y
     fi
-    # Activate CONFIG_LEGACY_PTYS
-    kernel_configure_variable LEGACY_PTYS y
-    # this module is built externally via drbd-utils
-    kernel_configure_variable BLK_DEV_DRBD n
 
     # Activate the configuration options for VC4
     VC4GRAPHICS="${@bb.utils.contains("MACHINE_FEATURES", "vc4graphics", "1", "0", d)}"
@@ -152,8 +118,6 @@
     # Remove all modified configs and add the rest to .config
     sed -e "${CONF_SED_SCRIPT}" < '${B}/.config.patched' >> '${B}/.config'
     rm -f ${B}/.config.patched
-
-    yes '' | oe_runmake oldconfig
 }
 
 do_compile_append_raspberrypi3-64() {
@@ -161,10 +125,6 @@
     oe_runmake dtbs CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
 }
 
-do_install_prepend() {
-    install -d ${D}/lib/firmware
-}
-
 do_deploy_append() {
     # Deploy cmdline.txt
     install -d ${DEPLOYDIR}/bcm2835-bootfiles