blob: f6e577484e7e4e50a3e3dc087775169f22dafab9 [file] [log] [blame]
Patrick Williams8b8bc412016-08-17 15:02:23 -05001DESCRIPTION = "Linux Kernel for Raspberry Pi"
2SECTION = "kernel"
3LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"
5
Brad Bishopd7bf8c12018-02-25 22:55:05 -05006COMPATIBLE_MACHINE = "^rpi$"
Patrick Williams8b8bc412016-08-17 15:02:23 -05007
8PE = "1"
9PV = "${LINUX_VERSION}+git${SRCPV}"
10
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011inherit kernel siteinfo
12require recipes-kernel/linux/linux-yocto.inc
13
Brad Bishop9392c692018-09-07 15:37:17 +010014SRC_URI += "file://rpi-kernel-misc.cfg"
15
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016KCONFIG_MODE = "--alldefconfig"
17KBUILD_DEFCONFIG_raspberrypi0-wifi ?= "bcmrpi_defconfig"
18KBUILD_DEFCONFIG_raspberrypi ?= "bcmrpi_defconfig"
19KBUILD_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig"
20KBUILD_DEFCONFIG_raspberrypi3 ?= "bcm2709_defconfig"
21KBUILD_DEFCONFIG_raspberrypi3-64 ?= "bcmrpi3_defconfig"
Brad Bishop26bdd442019-08-16 17:08:17 -040022KBUILD_DEFCONFIG_raspberrypi4 ?= "bcm2711_defconfig"
23KBUILD_DEFCONFIG_raspberrypi4-64 ?= "bcm2711_defconfig"
Patrick Williams8b8bc412016-08-17 15:02:23 -050024
Brad Bishop870eb532020-01-06 09:44:45 -050025LINUX_VERSION_EXTENSION ?= ""
26
Patrick Williams8b8bc412016-08-17 15:02:23 -050027# CMDLINE for raspberrypi
Brad Bishop316dfdd2018-06-25 12:45:53 -040028SERIAL = "${@oe.utils.conditional("ENABLE_UART", "1", "console=serial0,115200", "", d)}"
29CMDLINE ?= "dwc_otg.lpm_enable=0 ${SERIAL} root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
Patrick Williams8b8bc412016-08-17 15:02:23 -050030
31# Add the kernel debugger over console kernel command line option if enabled
Brad Bishop316dfdd2018-06-25 12:45:53 -040032CMDLINE_append = ' ${@oe.utils.conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}'
Patrick Williams8b8bc412016-08-17 15:02:23 -050033
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034# Disable rpi logo on boot
Brad Bishop316dfdd2018-06-25 12:45:53 -040035CMDLINE_append += ' ${@oe.utils.conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036
37# You can define CMDLINE_DEBUG as "debug" in your local.conf or distro.conf
38# to enable kernel debugging.
39CMDLINE_DEBUG ?= ""
40CMDLINE_append = " ${CMDLINE_DEBUG}"
41
Patrick Williams8b8bc412016-08-17 15:02:23 -050042KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains("MACHINE_FEATURES", "pitft28r", "stmpe-ts", "", d)}"
43
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044# A LOADADDR is needed when building a uImage format kernel. This value is not
45# set by default in rpi-4.8.y and later branches so we need to provide it
46# manually. This value unused if KERNEL_IMAGETYPE is not uImage.
47KERNEL_EXTRA_ARGS += "LOADADDR=0x00008000"
48
49# Set a variable in .configure
50# $1 - Configure variable to be set
51# $2 - value [n/y/value]
52kernel_configure_variable() {
53 # Remove the config
54 CONF_SED_SCRIPT="$CONF_SED_SCRIPT /CONFIG_$1[ =]/d;"
55 if test "$2" = "n"
56 then
57 echo "# CONFIG_$1 is not set" >> ${B}/.config
58 else
59 echo "CONFIG_$1=$2" >> ${B}/.config
60 fi
Patrick Williams8b8bc412016-08-17 15:02:23 -050061}
62
Brad Bishop316dfdd2018-06-25 12:45:53 -040063config_setup() {
64 # From kernel.bbclass. Unfortunately, this is needed to support builds that
65 # use devtool. The reason is as follows:
66 #
67 # - In devtool builds, externalsrc.bbclass gets inherited and sets a list of
68 # SRCTREECOVEREDTASKS, which don't get run because they affect the source
69 # tree and, when using devtool, we want the developer's changes to be the
70 # single source of truth. kernel-yocto.bbclass adds do_kernel_configme to
71 # SRCTREECOVEREDTASKS, so it doesn't run in a devtool build., In a normal
72 # non-devtool build, do_kernel_configme creates ${B}.config.
73 #
74 # - Normally (e.g. in linux-yocto), it would be OK that do_kernel_configme
75 # doesn't run, because the first few lines of do_configure in kernel.bbclass
76 # populate ${B}.config from either ${S}.config (if it exists) for custom
77 # developer changes, or otherwise from ${WORDIR}/defconfig.
78 #
79 # - In linux-raspberrypi, we add do_configure_prepend, which tweaks
80 # ${B}.config. Since this runs *before* the kernel.bbclass do_configure,
81 # ${B}.config doesn't yet exist and we hit an error. Thus we need to move
82 # the logic from do_configure up to before our do_configure_prepend. Because
83 # we are copying only a portion of do_configure and not the whole thing,
84 # there is no clean way to do it using OE functionality, so we just
85 # copy-and-paste.
86 if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
87 mv "${S}/.config" "${B}/.config"
88 fi
89
90 # Copy defconfig to .config if .config does not exist. This allows
91 # recipes to manage the .config themselves in do_configure_prepend().
92 if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
93 cp "${WORKDIR}/defconfig" "${B}/.config"
94 fi
95}
96
Brad Bishopd7bf8c12018-02-25 22:55:05 -050097do_configure_prepend() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040098 config_setup
99
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500100 mv -f ${B}/.config ${B}/.config.patched
101 CONF_SED_SCRIPT=""
102
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800103 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500104 kernel_configure_variable OVERLAY_FS y
105 kernel_configure_variable SQUASHFS y
106 kernel_configure_variable UBIFS_FS y
107 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500108
109 # Activate the configuration options for VC4
110 VC4GRAPHICS="${@bb.utils.contains("MACHINE_FEATURES", "vc4graphics", "1", "0", d)}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800111 if [ "${VC4GRAPHICS}" = "1" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500112 kernel_configure_variable I2C_BCM2835 y
113 kernel_configure_variable DRM y
114 kernel_configure_variable DRM_FBDEV_EMULATION y
115 kernel_configure_variable DRM_VC4 y
116 fi
117
118 # Keep this the last line
119 # Remove all modified configs and add the rest to .config
120 sed -e "${CONF_SED_SCRIPT}" < '${B}/.config.patched' >> '${B}/.config'
121 rm -f ${B}/.config.patched
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500122}
123
Brad Bishop26bdd442019-08-16 17:08:17 -0400124do_compile_append() {
125 if [ "${SITEINFO_BITS}" = "64" ]; then
126 cc_extra=$(get_cc_option)
127 oe_runmake dtbs CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
128 fi
Patrick Williams8b8bc412016-08-17 15:02:23 -0500129}
130
Patrick Williams8b8bc412016-08-17 15:02:23 -0500131do_deploy_append() {
132 # Deploy cmdline.txt
133 install -d ${DEPLOYDIR}/bcm2835-bootfiles
134 PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}"
135 if [ ${PITFT} = "1" ]; then
136 PITFT_PARAMS="fbcon=map:10 fbcon=font:VGA8x8"
137 fi
138 echo "${CMDLINE}${PITFT_PARAMS}" > ${DEPLOYDIR}/bcm2835-bootfiles/cmdline.txt
139}