From 0ce992245d0b005252aa09fa3c3b849f2cb223c2 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Tue, 12 Oct 2021 23:43:36 -0400 Subject: [PATCH 1/3] barebox: simplify defconfig condition Prefer if/elif/else over nested if/else statements. Signed-off-by: Vivien Didelot --- recipes-bsp/barebox/barebox.inc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/recipes-bsp/barebox/barebox.inc b/recipes-bsp/barebox/barebox.inc index 6e2da8e..5a1e572 100644 --- a/recipes-bsp/barebox/barebox.inc +++ b/recipes-bsp/barebox/barebox.inc @@ -49,12 +49,10 @@ EXTRA_OEMAKE = " \ do_configure() { if [ -e ${WORKDIR}/defconfig ]; then cp ${WORKDIR}/defconfig ${B}/.config + elif [ -n "${BAREBOX_CONFIG}" ]; then + oe_runmake ${BAREBOX_CONFIG} else - if [ -n "${BAREBOX_CONFIG}" ]; then - oe_runmake ${BAREBOX_CONFIG} - else - bbfatal "No defconfig given. Either add file 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG" - fi + bbfatal "No defconfig given. Either add file 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG" fi ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))} From 17866ef406a1795e7e02b3229b6a7efc4ae82f50 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Tue, 14 Sep 2021 14:27:31 -0400 Subject: [PATCH 2/3] barebox: merge all env* directories The barebox recipe currently supports only a single 'env' directory as the default environment, configured at compile time. But it can be convenient to split an environment into multiple directories to support various OVERRIDES, like per-distro or per-machine configuration. To do this, merge all env* directories in .defaultenv and set CONFIG_DEFAULT_ENVIRONMENT_PATH at configure time. Signed-off-by: Vivien Didelot --- recipes-bsp/barebox/barebox.inc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/recipes-bsp/barebox/barebox.inc b/recipes-bsp/barebox/barebox.inc index 5a1e572..5f58a2a 100644 --- a/recipes-bsp/barebox/barebox.inc +++ b/recipes-bsp/barebox/barebox.inc @@ -11,7 +11,7 @@ PACKAGE_ARCH = "${MACHINE_ARCH}" inherit kernel-arch deploy inherit cml1 -DEPENDS = "libusb1-native lzop-native bison-native flex-native" +DEPENDS = "libusb1-native lzop-native bison-native flex-native rsync-native" PACKAGES += "${PN}-bareboxenv ${PN}-bareboxcrc32 ${PN}-kernel-install \ ${PN}-bareboximd" @@ -55,7 +55,15 @@ do_configure() { bbfatal "No defconfig given. Either add file 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG" fi - ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))} + # Merge 'env*' directories into the compiled environment + mkdir -p ${S}/.defaultenv + find ${WORKDIR} -mindepth 1 -maxdepth 1 -type d -name 'env*' -execdir rsync -av '{}/' ${S}/.defaultenv ';' + echo "CONFIG_DEFAULT_ENVIRONMENT_PATH=\"${S}/.defaultenv\"" > ${B}/.defaultenv.cfg + + ${S}/scripts/kconfig/merge_config.sh -m ${B}/.config \ + ${B}/.defaultenv.cfg \ + ${@" ".join(find_cfgs(d))} + cml1_do_configure } @@ -63,17 +71,6 @@ BAREBOX_FIRMWARE_DIR ?= "" BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path" do_compile () { - # If there is an 'env' directory, append its content - # to the compiled environment - if [ -d ${WORKDIR}/env/ ]; then \ - mkdir -p ${S}/.yocto-defaultenv - cp -r ${WORKDIR}/env/* ${S}/.yocto-defaultenv/; \ - grep -q .yocto-defaultenv ${B}/.config || \ - sed -i -e "s,^\(CONFIG_DEFAULT_ENVIRONMENT_PATH=.*\)\"$,\1 .yocto-defaultenv\"," \ - ${B}/.config; \ - - fi - # If ${BAREBOX_FIRMWARE_DIR} is set, use that for CONFIG_EXTRA_FIRMWARE_DIR if [ -n "${BAREBOX_FIRMWARE_DIR}" ]; then sed -i -e "s,^\(CONFIG_EXTRA_FIRMWARE_DIR=\"\).*\"$,\1${BAREBOX_FIRMWARE_DIR}\"," \ From a1fdbced0564b0dded2919d02af8874878309ee5 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Wed, 13 Oct 2021 01:10:11 -0400 Subject: [PATCH 3/3] barebox: set firmware directory at configure time Set the CONFIG_EXTRA_FIRMWARE_DIR config entry with the value of BAREBOX_FIRMWARE_DIR at configure time, not compile time. At the same time, inconditionally merge a .firmware.cfg file to to simplify this configuration step. Signed-off-by: Vivien Didelot --- recipes-bsp/barebox/barebox.inc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/recipes-bsp/barebox/barebox.inc b/recipes-bsp/barebox/barebox.inc index 5f58a2a..25ed209 100644 --- a/recipes-bsp/barebox/barebox.inc +++ b/recipes-bsp/barebox/barebox.inc @@ -46,6 +46,9 @@ EXTRA_OEMAKE = " \ BUILDSYSTEM_VERSION=${BAREBOX_BUILDSYSTEM_VERSION} \ " +BAREBOX_FIRMWARE_DIR ?= "" +BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path" + do_configure() { if [ -e ${WORKDIR}/defconfig ]; then cp ${WORKDIR}/defconfig ${B}/.config @@ -60,23 +63,21 @@ do_configure() { find ${WORKDIR} -mindepth 1 -maxdepth 1 -type d -name 'env*' -execdir rsync -av '{}/' ${S}/.defaultenv ';' echo "CONFIG_DEFAULT_ENVIRONMENT_PATH=\"${S}/.defaultenv\"" > ${B}/.defaultenv.cfg + # If ${BAREBOX_FIRMWARE_DIR} is set, use that for CONFIG_EXTRA_FIRMWARE_DIR + touch ${B}/.firmware.cfg + if [ -n "${BAREBOX_FIRMWARE_DIR}" ]; then + echo "CONFIG_EXTRA_FIRMWARE_DIR=\"${BAREBOX_FIRMWARE_DIR}\"" > ${B}/.firmware.cfg + fi + ${S}/scripts/kconfig/merge_config.sh -m ${B}/.config \ ${B}/.defaultenv.cfg \ + ${B}/.firmware.cfg \ ${@" ".join(find_cfgs(d))} cml1_do_configure } -BAREBOX_FIRMWARE_DIR ?= "" -BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path" - do_compile () { - # If ${BAREBOX_FIRMWARE_DIR} is set, use that for CONFIG_EXTRA_FIRMWARE_DIR - if [ -n "${BAREBOX_FIRMWARE_DIR}" ]; then - sed -i -e "s,^\(CONFIG_EXTRA_FIRMWARE_DIR=\"\).*\"$,\1${BAREBOX_FIRMWARE_DIR}\"," \ - ${B}/.config - fi - # Barebox uses pkg-config only for building native tools export PKG_CONFIG_LIBDIR="${STAGING_DIR_NATIVE}${libdir}/pkgconfig:${STAGING_DIR_NATIVE}/usr/share/pkgconfig" export PKG_CONFIG_SYSROOT_DIR=