| inherit kernel | |
| require recipes-kernel/linux/linux-yocto.inc | |
| require recipes-kernel/linux/linux-common.inc | |
| DEFAULT_PREFERENCE = "-1" | |
| PROVIDES += "virtual/kernel linux-gbmc" | |
| KCONFIG_MODE = "--allnoconfig" | |
| # We do not want kernel images installed into /boot | |
| RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = "" | |
| SRC_URI += " \ | |
| file://DOWNSTREAM_0001-gBMC-Splice.patch \ | |
| file://linux-gbmc \ | |
| file://gbmc-verify-pins.sh \ | |
| file://DOWNSTREAM_0001-misc-Add-gBMC-subfolder.patch \ | |
| ${@'file://asan.cfg' if (d.getVar('GBMC_SAN_MODE', False) or '' ).endswith('asan') else ''} \ | |
| ${@bb.utils.contains('PACKAGECONFIG', 'emmc', 'file://emmc.cfg', '', d)} \ | |
| ${@bb.utils.contains('PACKAGECONFIG', 'udc-nic', 'file://udc-nic.cfg', '', d)} \ | |
| ${@bb.utils.contains('PACKAGECONFIG', 'usb-host', 'file://usb-host.cfg', '', d)} \ | |
| ${@bb.utils.contains('PACKAGECONFIG', 'usb-host-net', 'file://usb-host-net.cfg', '', d)} \ | |
| " | |
| PACKAGECONFIG[diorite_c0] = "" | |
| DIORITE_C0_SUPPORTED = "0" | |
| DIORITE_C0_SUPPORTED:npcm7xx = "1" | |
| PACKAGECONFIG[emmc] = "" | |
| EMMC_SUPPORTED = "0" | |
| EMMC_SUPPORTED:npcm7xx = "1" | |
| EMMC_SUPPORTED:npcm8xx = "1" | |
| EMMC_SUPPORTED:aspeed-g7 = "1" | |
| PACKAGECONFIG[udc-nic] = "" | |
| UDC_NIC_SUPPORTED = "0" | |
| UDC_NIC_SUPPORTED:npcm7xx = "1" | |
| UDC_NIC_SUPPORTED:npcm8xx = "1" | |
| UDC_NIC_SUPPORTED:aspeed-g7 = "1" | |
| PACKAGECONFIG[usb-host] = "" | |
| USB_HOST_SUPPORTED = "0" | |
| USB_HOST_SUPPORTED:aspeed-g6 = "1" | |
| USB_HOST_SUPPORTED:aspeed-g7 = "1" | |
| USB_HOST_SUPPORTED:npcm7xx = "1" | |
| USB_HOST_SUPPORTED:npcm8xx = "1" | |
| PACKAGECONFIG[usb-host-net] = "" | |
| python __anonymous () { | |
| if bb.utils.contains('PACKAGECONFIG', 'diorite_c0', True, False, d) and d.getVar('DIORITE_C0_SUPPORTED') != "1": | |
| bb.fatal("Diorite C0 workaround not supported for this platform") | |
| if bb.utils.contains('PACKAGECONFIG', 'emmc', True, False, d) and d.getVar('EMMC_SUPPORTED') != "1": | |
| bb.fatal("EMMC not supported for this platform") | |
| if bb.utils.contains('PACKAGECONFIG', 'udc-nic', True, False, d) and d.getVar('UDC_NIC_SUPPORTED') != "1": | |
| bb.fatal("UDC NIC not supported for this platform") | |
| if bb.utils.contains('PACKAGECONFIG', 'usb-host', True, False, d) and d.getVar('USB_HOST_SUPPORTED') != "1": | |
| bb.fatal("USB Host not supported for this platform") | |
| if bb.utils.contains('PACKAGECONFIG', 'usb-host-net', True, False, d) and bb.utils.contains('PACKAGECONFIG', 'usb-host', False, True, d): | |
| bb.fatal("USB Host Networking requires usb-host") | |
| } | |
| PACKAGECONFIG:append = "${@bb.utils.contains('MACHINE_FEATURES', 'gbmc-image-on-emmc', 'emmc', '', d)}" | |
| USB_HOST_STATUS = "${@bb.utils.contains('PACKAGECONFIG', 'usb-host', '"okay"', '"disabled"', d)}" | |
| EMMC_STATUS = "${@bb.utils.contains('PACKAGECONFIG', 'emmc', '"okay"', '"disabled"', d)}" | |
| FILESEXTRAPATHS:prepend := "${THISDIR}/files:" | |
| SRC_URI:append:npcm7xx = " \ | |
| ${@bb.utils.contains('PACKAGECONFIG', 'diorite_c0', 'file://DOWNSTREAM_0001-Diorite-workaround-for-c0-card.patch', '', d)} \ | |
| " | |
| set_git_vars() { | |
| export GIT_AUTHOR_EMAIL="${PATCH_GIT_USER_EMAIL}" | |
| export GIT_AUTHOR_NAME="${PATCH_GIT_USER_NAME}" | |
| export GIT_AUTHOR_DATE="${SOURCE_DATE_EPOCH}" | |
| } | |
| do_ksrc_apply() { | |
| if [ -e ${WORKDIR}/patch-* ]; then | |
| cd ${S} | |
| check_git_config | |
| set_git_vars | |
| if git log -n1 --oneline | grep -q ksrc-apply-linux-gbmc; then | |
| git reset --hard 'HEAD^' | |
| fi | |
| git clean -d -f | |
| git apply ${WORKDIR}/patch-* | |
| git add . | |
| git commit -n -m "ksrc-apply-linux-gbmc ${LINUX_VERSION}" | |
| fi | |
| } | |
| # We only have a special flash layout for 32MB platforms, the 64MB layout is | |
| # generic and should be used by all other sized flashes with dynamic image | |
| # support turned on. | |
| FLASH_LAYOUT_SIZE = "${@32 if d.getVar('FLASH_SIZE') == '32768' else 64}" | |
| do_ksrc_splice() { | |
| # Ensure that our SPI override file is correctly in place over a valid file in the tree | |
| test -e ${S}/drivers/mtd/spi-nor/everspin.c | |
| grep -q 'everspin.o' ${S}/drivers/mtd/spi-nor/Makefile | |
| cp -r ${WORKDIR}/linux-gbmc/* ${S}/ | |
| # Fill in PACKAGECONFIG defines | |
| sed -e 's,@USB_HOST_STATUS@,${USB_HOST_STATUS},g' \ | |
| -e 's,@EMMC_STATUS@,${EMMC_STATUS},g' \ | |
| -e 's,@FLASH_LAYOUT_SIZE@,${FLASH_LAYOUT_SIZE},g' \ | |
| -e 's,@FLASH_HZ@,${@int(int(d.getVar('GBMC_BOOT_SPI_MHZ'))*1000*1000)},g' \ | |
| -i ${S}/arch/arm/boot/dts/nuvoton/npcm7xx-gbmc.dtsi | |
| # Compatability symlinks for the DTS move from `nuvoton-*` to `nuvoton/nuvoton-*` | |
| for file in ${S}/arch/arm/boot/dts/nuvoton/*.dtsi; do | |
| [ ! -L "$file" ] || continue | |
| ln -fsrv "$file" ${S}/arch/arm/boot/dts/ | |
| done | |
| dtsmake=$(dirname ${S}/arch/${ARCH}/boot/dts/${KERNEL_DEVICETREE})/Makefile | |
| dts=$(basename ${KERNEL_DEVICETREE}) | |
| if test -e $dtsmake && ! grep -q "$dts" $dtsmake; then | |
| echo "dtb-y += $dts" >>$dtsmake | |
| fi | |
| } | |
| do_ksrc_splice:prepend:npcm7xx() { | |
| mkdir -p ${S}/arch/arm/boot/dts/nuvoton | |
| cp ${WORKDIR}/npcm7xx-gbmc-common.dtsi ${S}/arch/arm/boot/dts/nuvoton/ | |
| } | |
| do_compile:prepend:npcm7xx() { | |
| # We need the file after running the preprocessor so we get the macro expanded struct values | |
| oe_runmake -C ${S} O=${B} drivers/pinctrl/nuvoton/pinctrl-npcm7xx.i | |
| # Compare the struct values to the values in the dtsi | |
| bash ${WORKDIR}/gbmc-verify-pins.sh ${B}/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.i ${S}/arch/arm/boot/dts/nuvoton/npcm7xx-gbmc-common.dtsi | |
| } | |
| # Rewrite the splice patch to include all of the dropped-in files | |
| do_ksrc_splice_post() { | |
| cd ${S} | |
| check_git_config | |
| set_git_vars | |
| git add . | |
| git commit -n -m "gBMC: Splice contents into source tree" | |
| patch="$(git format-patch 'HEAD^')" | |
| git reset --hard 'HEAD^' | |
| mv "$patch" ${WORKDIR}/DOWNSTREAM_0001-gBMC-Splice.patch | |
| } | |
| do_kernel_checkout[postfuncs] =+ "do_ksrc_apply do_ksrc_splice do_ksrc_splice_post" | |
| # We need to make sure the subsequent fetch gets overridden by our modified patch | |
| do_kernel_metadata:append() { | |
| test -e ${S}/.kernel-meta/patches/DOWNSTREAM_0001-gBMC-Splice.patch | |
| cp ${WORKDIR}/DOWNSTREAM_0001-gBMC-Splice.patch ${S}/.kernel-meta/patches/ | |
| } | |
| GBMC_CONFIGCHECK ?= "1" | |
| do_gbmc_configcheck() { | |
| st=0 | |
| gbmc-delta-kconfig.sh ${B}/.config ${S}/.kernel-meta/configs/* || st=$? | |
| if [ "${GBMC_CONFIGCHECK}" = "1" -a $st -ne 0 ]; then | |
| exit 1 | |
| fi | |
| } | |
| do_kernel_configcheck[postfuncs] =+ "do_gbmc_configcheck" | |
| do_compile_headers() { | |
| oe_runmake -C ${S} O=${B} headers | |
| } | |
| do_shared_headers() { | |
| mkdir -p ${STAGING_KERNEL_BUILDDIR}/usr | |
| cp -r ${B}/usr/include/ ${STAGING_KERNEL_BUILDDIR}/usr/ | |
| } | |
| addtask do_compile_headers after do_configure | |
| addtask do_shared_headers after do_shared_workdir do_compile_headers |