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 <pbarker@konsulko.com>
This commit is contained in:
Paul Barker 2020-11-25 14:58:59 +00:00 committed by Andrei Gherzan
parent ba6a809a55
commit 8827040d9c
3 changed files with 51 additions and 30 deletions

View File

@ -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}"

View File

@ -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}"

View File

@ -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
}