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