Merge pull request #12 from bradbishop/master

Build support for Palmetto netboot
diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/layer.conf b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/layer.conf
index ce5a49b..a12e3f4 100644
--- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/layer.conf
+++ b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/layer.conf
@@ -1,9 +1,5 @@
 # We have a conf and classes directory, add to BBPATH
 BBPATH .= ":${LAYERDIR}"
 
-# We have a recipes-* directories, add to BBFILES
-BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
-	${LAYERDIR}/recipes-*/*/*.bbappend"
-
 BBFILE_COLLECTIONS += "ast2400"
 BBFILE_PATTERN_ast2400 = ""
diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/machine/include/ast2400.inc b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/machine/include/ast2400.inc
index 492b473..58af4bb 100644
--- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/machine/include/ast2400.inc
+++ b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/conf/machine/include/ast2400.inc
@@ -3,7 +3,6 @@
 #@DESCRIPTION: Common machine configuration for the Aspeed AST2400 Chip
 
 PREFERRED_PROVIDER_virtual/kernel ?= "linux-obmc"
-KERNEL_CONFIG_COMMAND ?= "oe_runmake aspeed_defconfig"
 
 UBOOT_MACHINE ?= "versatileab_config"
 UBOOT_ENTRYPOINT ?= "0x40001000"
diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc.bbappend b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc.bbappend
deleted file mode 100644
index 065b1c4..0000000
--- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc.bbappend
+++ /dev/null
@@ -1,3 +0,0 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += "file://0000-config.patch"
diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc/0000-config.patch b/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc/0000-config.patch
deleted file mode 100644
index 04611ee..0000000
--- a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes-kernel/linux/linux-obmc/0000-config.patch
+++ /dev/null
@@ -1,17 +0,0 @@
---- a/arch/arm/configs/aspeed_defconfig
-+++ b/arch/arm/configs/aspeed_defconfig
-@@ -1,12 +1,12 @@
- CONFIG_CROSS_COMPILE="arm-linux-"
--CONFIG_LOCALVERSION="-joel"
-+# CONFIG_LOCALVERSION is not set
- CONFIG_KERNEL_XZ=y
- # CONFIG_SWAP is not set
- CONFIG_SYSVIPC=y
- CONFIG_IRQ_DOMAIN_DEBUG=y
- CONFIG_LOG_BUF_SHIFT=14
- CONFIG_BLK_DEV_INITRD=y
--CONFIG_INITRAMFS_SOURCE="~/ibm/openbmc/buildroot-arm-rootfs.cpio.gz"
-+# CONFIG_INITRAMFS_SOURCE is not set
- CONFIG_CC_OPTIMIZE_FOR_SIZE=y
- CONFIG_KALLSYMS_ALL=y
- CONFIG_EMBEDDED=y
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/layer.conf b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/layer.conf
index ac8a2a2..b34e780 100644
--- a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/layer.conf
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/layer.conf
@@ -1,5 +1,9 @@
 # We have a conf and classes directory, add to BBPATH
 BBPATH .= ":${LAYERDIR}"
 
+# We have a recipes-* directories, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
+	${LAYERDIR}/recipes-*/*/*.bbappend"
+
 BBFILE_COLLECTIONS += "palmetto"
 BBFILE_PATTERN_palmetto = ""
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/machine/palmetto.conf b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/machine/palmetto.conf
index f846787..82a9b1c 100644
--- a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/machine/palmetto.conf
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf/machine/palmetto.conf
@@ -19,6 +19,8 @@
        "
 
 # UBOOT_MACHINE_${MACHINE} = "${MACHINE}_config
+KMACHINE = "aspeed"
+KERNEL_DEVICETREE = "${KMACHINE}-bmc-opp-${MACHINE}.dtb"
 
 require conf/machine/include/ast2400.inc
 require conf/machine/include/obmc-bsp-common.inc
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/recipes-kernel/linux/linux-obmc_%.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/recipes-kernel/linux/linux-obmc_%.bbappend
new file mode 100644
index 0000000..de6d3d6
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/recipes-kernel/linux/linux-obmc_%.bbappend
@@ -0,0 +1 @@
+KERNEL_CONFIG_COMMAND = "oe_runmake_call -C ${S} O=${B} ${KMACHINE}_defconfig"
diff --git a/meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes.txt b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/recipes.txt
similarity index 100%
rename from meta-openbmc-bsp/meta-aspeed/meta-ast2400/recipes.txt
rename to meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/recipes.txt
diff --git a/meta-phosphor/classes/kernel-cuimage.bbclass b/meta-phosphor/classes/kernel-cuimage.bbclass
new file mode 100644
index 0000000..25d8f24
--- /dev/null
+++ b/meta-phosphor/classes/kernel-cuimage.bbclass
@@ -0,0 +1,45 @@
+# Essentially kernel-uimage, but for cuImage.
+
+inherit kernel-uboot
+
+KBUILD_HAS_CUIMAGE ?= "no"
+
+python __anonymous () {
+    kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
+    if kerneltype == 'cuImage':
+        depends = d.getVar("DEPENDS", True)
+        depends = "%s u-boot-mkimage-native" % depends
+        d.setVar("DEPENDS", depends)
+
+	# Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
+	# to kernel.bbclass . We override the variable here, since we need
+	# to build cuImage using the kernel build system if and only if
+	# KBUILD_HAS_CUIMAGE == yes. Otherwise, we pack compressed vmlinux into
+	# the cuImage .
+	if d.getVar("KBUILD_HAS_CUIMAGE", True) != 'yes':
+            d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
+}
+
+do_uboot_mkcimage() {
+        dt="arch/${ARCH}/boot/dts/${KERNEL_DEVICETREE}"
+        if ! test -r $dt; then
+		dt=""
+        fi
+
+	if test "x${KERNEL_IMAGETYPE}" = "xcuImage" ; then
+		if test "x${KBUILD_HAS_CUIMAGE}" != "xyes" ; then
+			uboot_prep_kimage
+                        cat linux.bin $dt > linux-dts.bin
+			ENTRYPOINT=${UBOOT_ENTRYPOINT}
+			if test -n "${UBOOT_ENTRYSYMBOL}"; then
+				ENTRYPOINT=`${HOST_PREFIX}nm ${S}/vmlinux | \
+					awk '$3=="${UBOOT_ENTRYSYMBOL}" {print $1}'`
+			fi
+
+			uboot-mkimage -A ${UBOOT_ARCH} -O linux -T kernel -C "${linux_comp}" -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux-dts.bin arch/${ARCH}/boot/cuImage
+			rm -f linux.bin linux-dts.bin
+		fi
+	fi
+}
+
+addtask uboot_mkcimage before do_bundle_initramfs after do_compile
diff --git a/meta-phosphor/common/recipes-extended/shadow/shadow-securetty/securetty.patch b/meta-phosphor/common/recipes-extended/shadow/shadow-securetty/securetty.patch
new file mode 100644
index 0000000..6533e4a
--- /dev/null
+++ b/meta-phosphor/common/recipes-extended/shadow/shadow-securetty/securetty.patch
@@ -0,0 +1,10 @@
+--- a/securetty
++++ b/securetty
+@@ -7,6 +7,7 @@ ttyS0
+ ttyS1
+ ttyS2
+ ttyS3
++ttyS4
+ 
+ # ARM AMBA SoCs
+ ttyAM0
diff --git a/meta-phosphor/common/recipes-extended/shadow/shadow-securetty_%.bbappend b/meta-phosphor/common/recipes-extended/shadow/shadow-securetty_%.bbappend
new file mode 100644
index 0000000..70ab435
--- /dev/null
+++ b/meta-phosphor/common/recipes-extended/shadow/shadow-securetty_%.bbappend
@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://securetty.patch"
+
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/initrd-source.patch b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/initrd-source.patch
new file mode 100644
index 0000000..a685df5
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/initrd-source.patch
@@ -0,0 +1,11 @@
+--- a/arch/arm/configs/aspeed_defconfig
++++ b/arch/arm/configs/aspeed_defconfig
+@@ -6,7 +6,7 @@ CONFIG_SYSVIPC=y
+ CONFIG_IRQ_DOMAIN_DEBUG=y
+ CONFIG_LOG_BUF_SHIFT=14
+ CONFIG_BLK_DEV_INITRD=y
+-CONFIG_INITRAMFS_SOURCE="~/ibm/openbmc/buildroot-arm-rootfs.cpio.gz"
++CONFIG_INITRAMFS_SOURCE=""
+ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+ CONFIG_KALLSYMS_ALL=y
+ CONFIG_EMBEDDED=y
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-config.cfg b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-config.cfg
new file mode 100644
index 0000000..17c8b50
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-config.cfg
@@ -0,0 +1,8 @@
+#
+# Used by yocto-kernel to manage config options.
+#
+# yocto-kernel may change the contents of this file in any
+# way it sees fit, including removing comments like this,
+# so don't manually make any modifications you don't want
+# to lose.
+#
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-patches.scc b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-patches.scc
new file mode 100644
index 0000000..7a598d9
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp-user-patches.scc
@@ -0,0 +1,8 @@
+#
+# Used by yocto-kernel to manage patches.
+#
+# yocto-kernel may change the contents of this file in any
+# way it sees fit, including removing comments like this,
+# so don't manually make any modifications you don't want
+# to lose.
+#
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.cfg b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.cfg
new file mode 100644
index 0000000..95170b1
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.cfg
@@ -0,0 +1,3 @@
+#
+# A convenient place to add config options, nothing more.
+#
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.scc b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.scc
new file mode 100644
index 0000000..88e76e6
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/obmc-bsp.scc
@@ -0,0 +1,17 @@
+#
+# The top-level 'feature' for the meta-obmc-bsp custom kernel.
+#
+# Essentially this is a convenient top-level container or starting
+# point for adding lower-level config fragements and features.
+#
+
+# meta-obmc-bsp.cfg in the linux-yocto-custom subdir is just a
+# convenient place for adding random config fragments.
+
+kconf hardware obmc-bsp.cfg
+
+# These are used by yocto-kernel to add config fragments and features.
+# Don't remove if you plan on using yocto-kernel with this BSP.
+
+kconf hardware obmc-bsp-user-config.cfg
+include obmc-bsp-user-patches.scc
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/systemd-reqs.patch b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/systemd-reqs.patch
new file mode 100644
index 0000000..f6530d7
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/systemd-reqs.patch
@@ -0,0 +1,8 @@
+--- a/arch/arm/configs/aspeed_defconfig
++++ b/arch/arm/configs/aspeed_defconfig
+@@ -192,3 +192,5 @@ CONFIG_CRYPTO_GHASH=y
+ # CONFIG_CRYPTO_HW is not set
+ CONFIG_CRC_CCITT=y
+ CONFIG_AVERAGE=y
++CONFIG_CGROUPS=y
++CONFIG_FHANDLE=y
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc_4.2.bb b/meta-phosphor/common/recipes-kernel/linux/linux-obmc_4.2.bb
new file mode 100644
index 0000000..b38d1a8
--- /dev/null
+++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc_4.2.bb
@@ -0,0 +1,29 @@
+DESCRIPTION = "Linux kernel for OpenBMC"
+SECTION = "kernel"
+LICENSE = "GPLv2"
+
+KBRANCH ?= "dev"
+
+SRC_URI = "git://github.com/openbmc/linux;protocol=git;branch=${KBRANCH}"
+SRC_URI += "file://systemd-reqs.patch file://initrd-source.patch"
+SRC_URI += "file://obmc-bsp.scc \
+            file://obmc-bsp.cfg \
+            file://obmc-bsp-user-config.cfg \
+            file://obmc-bsp-user-patches.scc \
+           "
+
+LINUX_VERSION ?= "4.2"
+LINUX_VERSION_EXTENSION ?= "-openbmc-${SRCPV}"
+
+SRCREV="${AUTOREV}"
+
+PV = "${LINUX_VERSION}+git${SRCPV}"
+
+COMPATIBLE_MACHINE_${MACHINE} = "openbmc"
+
+inherit kernel
+require recipes-kernel/linux/linux-yocto.inc
+
+do_configure_prepend() {
+        sed -i 's/CONFIG_LOCALVERSION=.\+/CONFIG_LOCALVERSION=${LINUX_VERSION_EXTENSION}/' ${S}/arch/${ARCH}/configs/${KMACHINE}_defconfig
+}
diff --git a/meta-phosphor/common/recipes.txt b/meta-phosphor/common/recipes.txt
index c2c88b7..d38d789 100644
--- a/meta-phosphor/common/recipes.txt
+++ b/meta-phosphor/common/recipes.txt
@@ -1 +1,5 @@
-recipes-phosphor      - Phosphor OpenBMC applications and configuration
+recipes-connectivity - Libraries and applications related to communication with other devices 
+recipes-extended     - Applications which whilst not essential add features compared to the alternatives in
+                       core. May be needed for full tool functionality or LSB compliance.
+recipes-kernel       - The kernel and generic applications/libraries with strong kernel dependencies
+recipes-phosphor     - Phosphor OpenBMC applications and configuration
diff --git a/meta-phosphor/conf/machine/include/obmc-bsp-common.inc b/meta-phosphor/conf/machine/include/obmc-bsp-common.inc
new file mode 100644
index 0000000..ca65285
--- /dev/null
+++ b/meta-phosphor/conf/machine/include/obmc-bsp-common.inc
@@ -0,0 +1,15 @@
+#@TYPE: Machine
+#@NAME: OpenBMC
+#@DESCRIPTION: Common machine configuration for OpenBMC chips
+
+MACHINE_EXTRA_RRECOMMENDS = " kernel-modules"
+EXTRA_IMAGEDEPENDS += "u-boot"
+
+KERNEL_CLASSES ?= "kernel-uimage kernel-cuimage"
+KERNEL_IMAGETYPE ?= "cuImage"
+KERNEL_EXTRA_ARGS += "LOADADDR=${UBOOT_ENTRYPOINT}"
+
+UBOOT_SUFFIX ?= "bin"
+IMAGE_BOOT_FILES ?= "u-boot.${UBOOT_SUFFIX}"
+
+MACHINEOVERRIDES =. "openbmc:"