From 836d83d94ab7f5fbc8a81ec40058da9be3f691b1 Mon Sep 17 00:00:00 2001 From: Gilles Doffe Date: Mon, 16 May 2022 19:22:56 +0000 Subject: [PATCH 1/2] rpi-config: Add RPI_CONFIG_STRIP to strip down config.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The size of the file config.txt is over 52k, and it may grows over the versions of the firmware. Even the deprecated options are maintained. This adds the variable RPI_CONFIG_STRIP to allow the strip down of the file config.txt to the very bare minimal: it removes the leading white spaces, the empty lines and the comments. Signed-off-by: Gilles Doffe Signed-off-by: Gaël PORTAY --- recipes-bsp/bootfiles/rpi-config_git.bb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/recipes-bsp/bootfiles/rpi-config_git.bb b/recipes-bsp/bootfiles/rpi-config_git.bb index ee0f407b..a03cf935 100644 --- a/recipes-bsp/bootfiles/rpi-config_git.bb +++ b/recipes-bsp/bootfiles/rpi-config_git.bb @@ -37,6 +37,8 @@ WM8960="${@bb.utils.contains("MACHINE_FEATURES", "wm8960", "1", "0", d)}" GPIO_SHUTDOWN_PIN ??= "" +RPI_CONFIG_STRIP ??= "0" + inherit deploy nopackages do_deploy() { @@ -328,10 +330,19 @@ do_deploy:append:raspberrypi3-64() { } do_deploy:append() { + # Clean comments, empty lines and leading spaces + if [ "${RPI_CONFIG_STRIP}" = "1" ]; then + sed -i '/^#/d' $CONFIG + sed -i '/^$/d' $CONFIG + sed -i 's/^\s*//g' $CONFIG + fi + + # Warn about too long lines! if grep -q -E '^.{80}.$' ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/config.txt; then bbwarn "config.txt contains lines longer than 80 characters, this is not supported" fi } +do_deploy[vardeps] += "${RPI_CONFIG_STRIP}" addtask deploy before do_build after do_install do_deploy[dirs] += "${DEPLOYDIR}/${BOOTFILES_DIR_NAME}" From a61e6d97052903a7d2e9f2bd38803da095d67a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Thu, 14 Dec 2023 21:07:17 +0100 Subject: [PATCH 2/2] rpi-config: warn on config.txt exceeding 16k MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The firmware has a size limit in handling config.txt depending the hardware and it may prevent the hardware from booting if file exceeds it. That limit is not documented yet[1] but the links[2][3] mention about 16k. This warns if the config.txt is larger than 16k. [1]: https://www.raspberrypi.com/documentation/computers/config_txt.html [2]: https://forums.raspberrypi.com/viewtopic.php?p=2159238 [3]: https://github.com/raspberrypi/firmware/issues/1848 Signed-off-by: Gaël PORTAY --- recipes-bsp/bootfiles/rpi-config_git.bb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes-bsp/bootfiles/rpi-config_git.bb b/recipes-bsp/bootfiles/rpi-config_git.bb index a03cf935..dd4fc055 100644 --- a/recipes-bsp/bootfiles/rpi-config_git.bb +++ b/recipes-bsp/bootfiles/rpi-config_git.bb @@ -341,6 +341,12 @@ do_deploy:append() { if grep -q -E '^.{80}.$' ${DEPLOYDIR}/${BOOTFILES_DIR_NAME}/config.txt; then bbwarn "config.txt contains lines longer than 80 characters, this is not supported" fi + + # Warn about too big file! + size=$(stat -c '%s' $CONFIG) + if [ "$size" -gt 16384 ]; then + bbfatal "config.txt larger than 16k is not necessarily supported" + fi } do_deploy[vardeps] += "${RPI_CONFIG_STRIP}"