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