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