1eb8dc403SDave CobbleyDESCRIPTION = "Linux Kernel for Raspberry Pi" 2eb8dc403SDave CobbleySECTION = "kernel" 3eb8dc403SDave CobbleyLICENSE = "GPLv2" 4eb8dc403SDave CobbleyLIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7" 5eb8dc403SDave Cobbley 6eb8dc403SDave CobbleyCOMPATIBLE_MACHINE = "^rpi$" 7eb8dc403SDave Cobbley 8eb8dc403SDave CobbleyPE = "1" 9eb8dc403SDave CobbleyPV = "${LINUX_VERSION}+git${SRCPV}" 10eb8dc403SDave Cobbley 11eb8dc403SDave Cobbleyinherit kernel siteinfo 12eb8dc403SDave Cobbleyrequire recipes-kernel/linux/linux-yocto.inc 13eb8dc403SDave Cobbley 149392c69cSBrad BishopSRC_URI += "file://rpi-kernel-misc.cfg" 159392c69cSBrad Bishop 16eb8dc403SDave CobbleyKCONFIG_MODE = "--alldefconfig" 17eb8dc403SDave CobbleyKBUILD_DEFCONFIG_raspberrypi0-wifi ?= "bcmrpi_defconfig" 18eb8dc403SDave CobbleyKBUILD_DEFCONFIG_raspberrypi ?= "bcmrpi_defconfig" 19eb8dc403SDave CobbleyKBUILD_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig" 20eb8dc403SDave CobbleyKBUILD_DEFCONFIG_raspberrypi3 ?= "bcm2709_defconfig" 21eb8dc403SDave CobbleyKBUILD_DEFCONFIG_raspberrypi3-64 ?= "bcmrpi3_defconfig" 2226bdd445SBrad BishopKBUILD_DEFCONFIG_raspberrypi4 ?= "bcm2711_defconfig" 2326bdd445SBrad BishopKBUILD_DEFCONFIG_raspberrypi4-64 ?= "bcm2711_defconfig" 24eb8dc403SDave Cobbley 25*870eb53cSBrad BishopLINUX_VERSION_EXTENSION ?= "" 26*870eb53cSBrad Bishop 27eb8dc403SDave Cobbley# CMDLINE for raspberrypi 28eb8dc403SDave CobbleySERIAL = "${@oe.utils.conditional("ENABLE_UART", "1", "console=serial0,115200", "", d)}" 29eb8dc403SDave CobbleyCMDLINE ?= "dwc_otg.lpm_enable=0 ${SERIAL} root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" 30eb8dc403SDave Cobbley 31eb8dc403SDave Cobbley# Add the kernel debugger over console kernel command line option if enabled 32eb8dc403SDave CobbleyCMDLINE_append = ' ${@oe.utils.conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}' 33eb8dc403SDave Cobbley 34eb8dc403SDave Cobbley# Disable rpi logo on boot 35eb8dc403SDave CobbleyCMDLINE_append += ' ${@oe.utils.conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}' 36eb8dc403SDave Cobbley 37eb8dc403SDave Cobbley# You can define CMDLINE_DEBUG as "debug" in your local.conf or distro.conf 38eb8dc403SDave Cobbley# to enable kernel debugging. 39eb8dc403SDave CobbleyCMDLINE_DEBUG ?= "" 40eb8dc403SDave CobbleyCMDLINE_append = " ${CMDLINE_DEBUG}" 41eb8dc403SDave Cobbley 42eb8dc403SDave CobbleyKERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains("MACHINE_FEATURES", "pitft28r", "stmpe-ts", "", d)}" 43eb8dc403SDave Cobbley 44eb8dc403SDave Cobbley# A LOADADDR is needed when building a uImage format kernel. This value is not 45eb8dc403SDave Cobbley# set by default in rpi-4.8.y and later branches so we need to provide it 46eb8dc403SDave Cobbley# manually. This value unused if KERNEL_IMAGETYPE is not uImage. 47eb8dc403SDave CobbleyKERNEL_EXTRA_ARGS += "LOADADDR=0x00008000" 48eb8dc403SDave Cobbley 49eb8dc403SDave Cobbley# Set a variable in .configure 50eb8dc403SDave Cobbley# $1 - Configure variable to be set 51eb8dc403SDave Cobbley# $2 - value [n/y/value] 52eb8dc403SDave Cobbleykernel_configure_variable() { 53eb8dc403SDave Cobbley # Remove the config 54eb8dc403SDave Cobbley CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;" 55eb8dc403SDave Cobbley if test "$2" = "n" 56eb8dc403SDave Cobbley then 57eb8dc403SDave Cobbley echo "# CONFIG_$1 is not set" >> ${B}/.config 58eb8dc403SDave Cobbley else 59eb8dc403SDave Cobbley echo "CONFIG_$1=$2" >> ${B}/.config 60eb8dc403SDave Cobbley fi 61eb8dc403SDave Cobbley} 62eb8dc403SDave Cobbley 63eb8dc403SDave Cobbleyconfig_setup() { 64eb8dc403SDave Cobbley # From kernel.bbclass. Unfortunately, this is needed to support builds that 65eb8dc403SDave Cobbley # use devtool. The reason is as follows: 66eb8dc403SDave Cobbley # 67eb8dc403SDave Cobbley # - In devtool builds, externalsrc.bbclass gets inherited and sets a list of 68eb8dc403SDave Cobbley # SRCTREECOVEREDTASKS, which don't get run because they affect the source 69eb8dc403SDave Cobbley # tree and, when using devtool, we want the developer's changes to be the 70eb8dc403SDave Cobbley # single source of truth. kernel-yocto.bbclass adds do_kernel_configme to 71eb8dc403SDave Cobbley # SRCTREECOVEREDTASKS, so it doesn't run in a devtool build., In a normal 72eb8dc403SDave Cobbley # non-devtool build, do_kernel_configme creates ${B}.config. 73eb8dc403SDave Cobbley # 74eb8dc403SDave Cobbley # - Normally (e.g. in linux-yocto), it would be OK that do_kernel_configme 75eb8dc403SDave Cobbley # doesn't run, because the first few lines of do_configure in kernel.bbclass 76eb8dc403SDave Cobbley # populate ${B}.config from either ${S}.config (if it exists) for custom 77eb8dc403SDave Cobbley # developer changes, or otherwise from ${WORDIR}/defconfig. 78eb8dc403SDave Cobbley # 79eb8dc403SDave Cobbley # - In linux-raspberrypi, we add do_configure_prepend, which tweaks 80eb8dc403SDave Cobbley # ${B}.config. Since this runs *before* the kernel.bbclass do_configure, 81eb8dc403SDave Cobbley # ${B}.config doesn't yet exist and we hit an error. Thus we need to move 82eb8dc403SDave Cobbley # the logic from do_configure up to before our do_configure_prepend. Because 83eb8dc403SDave Cobbley # we are copying only a portion of do_configure and not the whole thing, 84eb8dc403SDave Cobbley # there is no clean way to do it using OE functionality, so we just 85eb8dc403SDave Cobbley # copy-and-paste. 86eb8dc403SDave Cobbley if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then 87eb8dc403SDave Cobbley mv "${S}/.config" "${B}/.config" 88eb8dc403SDave Cobbley fi 89eb8dc403SDave Cobbley 90eb8dc403SDave Cobbley # Copy defconfig to .config if .config does not exist. This allows 91eb8dc403SDave Cobbley # recipes to manage the .config themselves in do_configure_prepend(). 92eb8dc403SDave Cobbley if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then 93eb8dc403SDave Cobbley cp "${WORKDIR}/defconfig" "${B}/.config" 94eb8dc403SDave Cobbley fi 95eb8dc403SDave Cobbley} 96eb8dc403SDave Cobbley 97eb8dc403SDave Cobbleydo_configure_prepend() { 98eb8dc403SDave Cobbley config_setup 99eb8dc403SDave Cobbley 100eb8dc403SDave Cobbley mv -f ${B}/.config ${B}/.config.patched 101eb8dc403SDave Cobbley CONF_SED_SCRIPT="" 102eb8dc403SDave Cobbley 1031a4b7ee2SBrad Bishop if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then 104eb8dc403SDave Cobbley kernel_configure_variable OVERLAY_FS y 105eb8dc403SDave Cobbley kernel_configure_variable SQUASHFS y 106eb8dc403SDave Cobbley kernel_configure_variable UBIFS_FS y 107eb8dc403SDave Cobbley fi 108eb8dc403SDave Cobbley 109eb8dc403SDave Cobbley # Activate the configuration options for VC4 110eb8dc403SDave Cobbley VC4GRAPHICS="${@bb.utils.contains("MACHINE_FEATURES", "vc4graphics", "1", "0", d)}" 1111a4b7ee2SBrad Bishop if [ "${VC4GRAPHICS}" = "1" ]; then 112eb8dc403SDave Cobbley kernel_configure_variable I2C_BCM2835 y 113eb8dc403SDave Cobbley kernel_configure_variable DRM y 114eb8dc403SDave Cobbley kernel_configure_variable DRM_FBDEV_EMULATION y 115eb8dc403SDave Cobbley kernel_configure_variable DRM_VC4 y 116eb8dc403SDave Cobbley fi 117eb8dc403SDave Cobbley 118eb8dc403SDave Cobbley # Keep this the last line 119eb8dc403SDave Cobbley # Remove all modified configs and add the rest to .config 120eb8dc403SDave Cobbley sed -e "${CONF_SED_SCRIPT}" < '${B}/.config.patched' >> '${B}/.config' 121eb8dc403SDave Cobbley rm -f ${B}/.config.patched 122eb8dc403SDave Cobbley} 123eb8dc403SDave Cobbley 12426bdd445SBrad Bishopdo_compile_append() { 12526bdd445SBrad Bishop if [ "${SITEINFO_BITS}" = "64" ]; then 126eb8dc403SDave Cobbley cc_extra=$(get_cc_option) 127eb8dc403SDave Cobbley oe_runmake dtbs CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} 12826bdd445SBrad Bishop fi 129eb8dc403SDave Cobbley} 130eb8dc403SDave Cobbley 131eb8dc403SDave Cobbleydo_deploy_append() { 132eb8dc403SDave Cobbley # Deploy cmdline.txt 133eb8dc403SDave Cobbley install -d ${DEPLOYDIR}/bcm2835-bootfiles 134eb8dc403SDave Cobbley PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}" 135eb8dc403SDave Cobbley if [ ${PITFT} = "1" ]; then 136eb8dc403SDave Cobbley PITFT_PARAMS="fbcon=map:10 fbcon=font:VGA8x8" 137eb8dc403SDave Cobbley fi 138eb8dc403SDave Cobbley echo "${CMDLINE}${PITFT_PARAMS}" > ${DEPLOYDIR}/bcm2835-bootfiles/cmdline.txt 139eb8dc403SDave Cobbley} 140