From ccb72fc99544c218ff573a466af4910866dcfa66 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Wed, 25 Nov 2020 14:58:59 +0000 Subject: rpi-cmdline: Move cmdline.txt generation to a separate recipe Instead of generating cmdline.txt in the kernel recipe, it is generated in a standalone recipe and pulled in as a dependency of the bootfiles recipe. This simplifies the process of using a linux-yocto, linux-mainline or similiar kernel recipe instead of linux-raspberrypi. In the rpi-cmdline recipe the command line is built from fragments which can all be easily overridden. The variables `SERIAL` and `CMA` are renamed to `CMDLINE_SERIAL` and `CMDLINE_CMA` for consistency. The cmdline.txt file is created in the do_compile step to allow further customisation via do_compile_append if needed. Signed-off-by: Paul Barker (cherry picked from commit 8827040d9c218f68ae3ee6a5814929888ed61581) Signed-off-by: Ricardo Salveti --- recipes-bsp/bootfiles/bootfiles.bb | 4 +-- recipes-bsp/bootfiles/rpi-cmdline.bb | 49 ++++++++++++++++++++++++++++++ recipes-kernel/linux/linux-raspberrypi.inc | 28 ----------------- 3 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 recipes-bsp/bootfiles/rpi-cmdline.bb diff --git a/recipes-bsp/bootfiles/bootfiles.bb b/recipes-bsp/bootfiles/bootfiles.bb index 80e226d..d081806 100644 --- a/recipes-bsp/bootfiles/bootfiles.bb +++ b/recipes-bsp/bootfiles/bootfiles.bb @@ -9,7 +9,7 @@ include recipes-bsp/common/raspberrypi-firmware.inc INHIBIT_DEFAULT_DEPS = "1" -DEPENDS = "rpi-config" +DEPENDS = "rpi-config rpi-cmdline" COMPATIBLE_MACHINE = "^rpi$" @@ -34,7 +34,7 @@ do_deploy() { touch ${DEPLOYDIR}/${PN}/${PN}-${PV}.stamp } -do_deploy[depends] += "rpi-config:do_deploy" +do_deploy[depends] += "rpi-config:do_deploy rpi-cmdline:do_deploy" addtask deploy before do_build after do_install do_deploy[dirs] += "${DEPLOYDIR}/${PN}" diff --git a/recipes-bsp/bootfiles/rpi-cmdline.bb b/recipes-bsp/bootfiles/rpi-cmdline.bb new file mode 100644 index 0000000..97db4e3 --- /dev/null +++ b/recipes-bsp/bootfiles/rpi-cmdline.bb @@ -0,0 +1,49 @@ +SUMMARY = "cmdline.txt file used to boot the kernel on a Raspberry Pi device" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +COMPATIBLE_MACHINE = "^rpi$" +INHIBIT_DEFAULT_DEPS = "1" +inherit deploy nopackages + +CMDLINE_DWC_OTG ?= "dwc_otg.lpm_enable=0" +CMDLINE_ROOTFS ?= "root=/dev/mmcblk0p2 rootfstype=ext4 rootwait" + +CMDLINE_SERIAL ?= "${@oe.utils.conditional("ENABLE_UART", "1", "console=serial0,115200", "", d)}" + +CMDLINE_CMA ?= "${@oe.utils.conditional("RASPBERRYPI_CAMERA_V2", "1", "cma=64M", "", d)}" + +CMDLINE_PITFT ?= "${@bb.utils.contains("MACHINE_FEATURES", "pitft", "fbcon=map:10 fbcon=font:VGA8x8", "", d)}" + +# Add the kernel debugger over console kernel command line option if enabled +CMDLINE_KGDB ?= '${@oe.utils.conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}' + +# Disable rpi logo on boot +CMDLINE_LOGO ?= '${@oe.utils.conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}' + +# You can define CMDLINE_DEBUG as "debug" in your local.conf or distro.conf +# to enable kernel debugging. +CMDLINE_DEBUG ?= "" + +CMDLINE = " \ + ${CMDLINE_DWC_OTG} \ + ${CMDLINE_SERIAL} \ + ${CMDLINE_ROOTFS} \ + ${CMDLINE_CMA} \ + ${CMDLINE_KGDB} \ + ${CMDLINE_LOGO} \ + ${CMDLINE_PITFT} \ + ${CMDLINE_DEBUG} \ + " + +do_compile() { + echo "${CMDLINE}" > "${WORKDIR}/cmdline.txt" +} + +do_deploy() { + install -d "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}" + install -m 0644 "${WORKDIR}/cmdline.txt" "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}" +} + +addtask deploy before do_build after do_install +do_deploy[dirs] += "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}" diff --git a/recipes-kernel/linux/linux-raspberrypi.inc b/recipes-kernel/linux/linux-raspberrypi.inc index fe5da69..5b151a6 100644 --- a/recipes-kernel/linux/linux-raspberrypi.inc +++ b/recipes-kernel/linux/linux-raspberrypi.inc @@ -29,22 +29,6 @@ KBUILD_DEFCONFIG_raspberrypi4-64 ?= "bcm2711_defconfig" LINUX_VERSION_EXTENSION ?= "" -# CMDLINE for raspberrypi -SERIAL = "${@oe.utils.conditional("ENABLE_UART", "1", "console=serial0,115200", "", d)}" -CMA ?= "${@oe.utils.conditional("RASPBERRYPI_CAMERA_V2", "1", "cma=64M", "", d)}" -CMDLINE ?= "dwc_otg.lpm_enable=0 ${SERIAL} root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ${CMA}" - -# Add the kernel debugger over console kernel command line option if enabled -CMDLINE_append = ' ${@oe.utils.conditional("ENABLE_KGDB", "1", "kgdboc=serial0,115200", "", d)}' - -# Disable rpi logo on boot -CMDLINE_append = ' ${@oe.utils.conditional("DISABLE_RPI_BOOT_LOGO", "1", "logo.nologo", "", d)}' - -# You can define CMDLINE_DEBUG as "debug" in your local.conf or distro.conf -# to enable kernel debugging. -CMDLINE_DEBUG ?= "" -CMDLINE_append = " ${CMDLINE_DEBUG}" - KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains("MACHINE_FEATURES", "pitft28r", "stmpe-ts", "", d)}" # A LOADADDR is needed when building a uImage format kernel. This value is not @@ -58,15 +42,3 @@ do_compile_append() { oe_runmake dtbs CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} fi } - -do_deploy_append() { - # Deploy cmdline.txt only for the main kernel package - if [ ${KERNEL_PACKAGE_NAME} = "kernel" ]; then - install -d ${DEPLOYDIR}/${BOOTFILES_DIR_NAME} - PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}" - if [ ${PITFT} = "1" ]; then - PITFT_PARAMS="fbcon=map:10 fbcon=font:VGA8x8" - fi - echo "${CMDLINE}${PITFT_PARAMS}" > ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/cmdline.txt - fi -} -- cgit v1.2.3-54-g00ecf