diff mbox series

[1/2] barebox: add initial support

Message ID 20230203135011.2061939-1-m.felsch@pengutronix.de
State New
Headers show
Series [1/2] barebox: add initial support | expand

Commit Message

Marco Felsch Feb. 3, 2023, 1:50 p.m. UTC
This adds the support for the barebox bootloader to oe-core. The recipe
is based on the recipe found in meta-ptx [1] with a few minor adaptions.

This basic support includes the bootloader and the target tools to
interact with the bootloader. The host tools support is not part of
this commit. This will be added later on as separate recipe.

[1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 meta/conf/documentation.conf                  |   7 +
 meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
 ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
 4 files changed, 175 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
 create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch

Comments

Richard Purdie Feb. 3, 2023, 2:17 p.m. UTC | #1
On Fri, 2023-02-03 at 14:50 +0100, Marco Felsch wrote:
> This adds the support for the barebox bootloader to oe-core. The recipe
> is based on the recipe found in meta-ptx [1] with a few minor adaptions.
> 
> This basic support includes the bootloader and the target tools to
> interact with the bootloader. The host tools support is not part of
> this commit. This will be added later on as separate recipe.
> 
> [1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  meta/conf/documentation.conf                  |   7 +
>  meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
>  meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
>  ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
>  4 files changed, 175 insertions(+)
>  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
>  create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
>  create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch

In order to add something to OE-Core, we need to see it being used by a
reasonable portion of the ecosystem. Is there enough usage of barebox
on common boards that justifies this?

I noticed there is no maintainers entry being added so this will throw
QA errors on the autobuilder.

Also, I'm not sure adding doc varflags for individual recipe variables
to documentation.conf makes sense. We should probably have them in the
recipe or just put entries into the manual?

Cheers,

Richard
Alexandre Belloni Feb. 3, 2023, 9:07 p.m. UTC | #2
This breaks oe-selftest:

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/4760/steps/15/logs/stdio

2023-02-03 17:55:08,025 - oe-selftest - INFO - fitimage.FitImageTests.test_sign_cascaded_uboot_fit_image (subunit.RemotedTestCase)
2023-02-03 17:55:08,026 - oe-selftest - INFO -  ... FAIL
Stderr:
2023-02-03 14:32:52,619 - oe-selftest - INFO - Adding: "include selftest.inc" in /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-35279/conf/local.conf
2023-02-03 14:32:52,620 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
2023-02-03 17:55:08,026 - oe-selftest - INFO - 13: 4/22 399/509 (54.05s) (0 failed) (fitimage.FitImageTests.test_sign_cascaded_uboot_fit_image)
2023-02-03 17:55:08,026 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/selftest/cases/fitimage.py", line 612, in test_sign_cascaded_uboot_fit_image
    bitbake("virtual/bootloader")
  File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/utils/commands.py", line 236, in bitbake
    return runCmd(cmd, ignore_status, timeout, output_log=output_log, **options)
  File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/utils/commands.py", line 214, in runCmd
    raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, exc_output))
AssertionError: Command 'bitbake  virtual/bootloader' returned non-zero exit status 1:

ERROR: barebox-2023.01.0-r0 do_configure: No defconfig given. Either add file 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG
ERROR: barebox-2023.01.0-r0 do_configure: ExecutionError('/home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-35279/tmp/work/qemuarm-poky-linux-gnueabi/barebox/2023.01.0-r0/temp/run.do_configure.3098535', 1, None, None)
ERROR: Logfile of failure stored in: /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-35279/tmp/work/qemuarm-poky-linux-gnueabi/barebox/2023.01.0-r0/temp/log.do_configure.3098535
NOTE: recipe barebox-2023.01.0-r0: task do_configure: Failed
ERROR: Task (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-bsp/barebox/barebox_2023.01.0.bb:do_configure) failed with exit code '1'

And as already reported by Richard:

AssertionError: 
The following recipes do not have a maintainer assigned to them. Please add an entry to meta/conf/distro/include/maintainers.inc file.
barebox-tools (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-bsp/barebox/barebox-tools_2023.01.0.bb)
barebox (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-bsp/barebox/barebox_2023.01.0.bb)

On 03/02/2023 14:50:10+0100, Marco Felsch wrote:
> This adds the support for the barebox bootloader to oe-core. The recipe
> is based on the recipe found in meta-ptx [1] with a few minor adaptions.
> 
> This basic support includes the bootloader and the target tools to
> interact with the bootloader. The host tools support is not part of
> this commit. This will be added later on as separate recipe.
> 
> [1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  meta/conf/documentation.conf                  |   7 +
>  meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
>  meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
>  ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
>  4 files changed, 175 insertions(+)
>  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
>  create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
>  create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
> 
> diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
> index a27d7a53c3..99e8f8e730 100644
> --- a/meta/conf/documentation.conf
> +++ b/meta/conf/documentation.conf
> @@ -77,6 +77,13 @@ AUTOREV[doc] = "When SRCREV is set to the value of this variable, it specifies t
>  
>  B[doc] = "The Build Directory. The OpenEmbedded build system places generated objects into the Build Directory during a recipe's build process."
>  BAD_RECOMMENDATIONS[doc] = "A list of packages not to install despite being recommended by a recipe. Support for this variable exists only when using the IPK or RPM packaging backends."
> +BAREBOX_BUILDSYSTEM_VERSION[doc] = "Build system version to add to the barebox image. By default this is the git description of the containing layer."
> +BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig is added to the SRC_URI."
> +BAREBOX_ENV_DIR[doc] = "Overlay the barebox built-in environment with the environment provided by the BSP if specified."
> +BAREBOX_BINARY[doc] = "Specify the barebox binary to install. If not specified all barebox artifacts are installed."
> +BAREBOX_IMAGE[doc] = "A unique barebox image name. Unused if ${BAREBOX_BINARY} is not set."
> +BAREBOX_SUFFIX[doc] = "Specify the suffix for ${BAREBOX_IMAGE}."
> +BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path, default ${B}/firmware"
>  BB_DANGLINGAPPENDS_WARNONLY[doc] = "Defines how BitBake handles situations where an append file (.bbappend) has no corresponding recipe file (.bb)."
>  BB_DISKMON_DIRS[doc] = "Monitors disk space and available inodes during the build and allows you to control the build based on these parameters."
>  BB_DISKMON_WARNINTERVAL[doc] = "Defines the disk space and free inode warning intervals. To set these intervals, define the variable in the conf/local.conf file in the Build Directory."
> diff --git a/meta/recipes-bsp/barebox/barebox.inc b/meta/recipes-bsp/barebox/barebox.inc
> new file mode 100644
> index 0000000000..896db9739f
> --- /dev/null
> +++ b/meta/recipes-bsp/barebox/barebox.inc
> @@ -0,0 +1,123 @@
> +SUMMARY = "barebox is a bootloader designed for embedded systems. It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."
> +HOMEPAGE = "https://barebox.org/"
> +SECTION = "bootloaders"
> +PROVIDES = "virtual/bootloader"
> +
> +LICENSE = "GPL-2.0-only"
> +LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
> +
> +PACKAGE_ARCH = "${MACHINE_ARCH}"
> +
> +inherit kernel-arch deploy cml1 pkgconfig
> +
> +# libusb1 is only required for usb tools like imx-usb-loader. These tools may
> +# be enabled within the defconfig file so depend on it here to be more user
> +# friendly (do not abort the build). The actual tools are provided by the
> +# barebox-tools package.
> +DEPENDS = "libusb1 bison-native flex-native"
> +
> +export KBUILD_BUILD_USER ?= "oe-user"
> +export KBUILD_BUILD_HOST ?= "oe-host"
> +
> +SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
> +
> +S = "${WORKDIR}/barebox-${PV}"
> +B = "${WORKDIR}/build"
> +
> +def get_layer_rev(path):
> +    try:
> +        rev, _ = bb.process.run("git describe --match='' --always --dirty --broken", cwd=path)
> +    except bb.process.ExecutionError:
> +        rev = ""
> +    return rev.strip()
> +
> +BAREBOX_BUILDSYSTEM_VERSION ??= "${@get_layer_rev(os.path.dirname(d.getVar('FILE')))}"
> +
> +BAREBOX_FIRMWARE_DIR ??= "${B}/firmware"
> +
> +EXTRA_OEMAKE = " \
> +    CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
> +    BUILDSYSTEM_VERSION=${BAREBOX_BUILDSYSTEM_VERSION} \
> +    CONFIG_EXTRA_FIRMWARE_DIR=${BAREBOX_FIRMWARE_DIR} \
> +"
> +
> +BAREBOX_CONFIG ?= ""
> +
> +do_configure() {
> +        if [ -e ${WORKDIR}/defconfig ]; then
> +                cp ${WORKDIR}/defconfig ${B}/.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
> +        fi
> +
> +        ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
> +        cml1_do_configure
> +}
> +
> +BAREBOX_ENV_DIR ??= "${WORKDIR}/env/"
> +
> +do_compile () {
> +        export userccflags="${TARGET_LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
> +        unset LDFLAGS
> +        unset CFLAGS
> +        unset CPPFLAGS
> +        unset CXXFLAGS
> +        unset MACHINE
> +
> +        if [ -d ${BAREBOX_ENV_DIR} ]; then
> +                BAREBOX_DEFAULT_ENV="$(grep ^CONFIG_DEFAULT_ENVIRONMENT_PATH .config | cut -d '=' -f 2 | tr -d '"')"
> +                oe_runmake CONFIG_DEFAULT_ENVIRONMENT_PATH="\"${BAREBOX_DEFAULT_ENV} ${BAREBOX_ENV_DIR}\""
> +        else
> +                oe_runmake
> +        fi
> +}
> +
> +BAREBOX_BINARY ??= ""
> +BAREBOX_SUFFIX ??= "img"
> +BAREBOX_SUFFIX:x86 ??= "efi"
> +BAREBOX_SUFFIX:x86-64 ??= "efi"
> +BAREBOX_IMAGE ?= "${PN}-${MACHINE}-${PV}-${PR}.${BAREBOX_SUFFIX}"
> +
> +do_install () {
> +        if [ -n "${BAREBOX_BINARY}" ]; then
> +
> +                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
> +                if [ ! -f "${BAREBOX_BIN}" ]; then
> +                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
> +                fi
> +                if [ ! -f "${BAREBOX_BIN}" ]; then
> +                        bbfatal "Failed to locate ${BAREBOX_BINARY}"
> +                fi
> +
> +                install -D -m 644 ${BAREBOX_BIN} ${D}/boot/${BAREBOX_IMAGE}
> +                ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
> +        else
> +                install -d ${D}/boot/
> +                for image in $(cat ${B}/barebox-flash-images); do
> +                        install -m 644 ${B}/${image} ${D}/boot/
> +                done
> +        fi
> +}
> +FILES:${PN} = "/boot"
> +
> +do_deploy () {
> +        if [ -n "${BAREBOX_BINARY}" ]; then
> +
> +                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
> +                if [ ! -f "${BAREBOX_BIN}" ]; then
> +                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
> +                fi
> +
> +                install -D -m 644 ${BAREBOX_BIN} ${DEPLOYDIR}/${BAREBOX_IMAGE}
> +                ln -sf ${BAREBOX_IMAGE} ${DEPLOYDIR}/${BAREBOX_BINARY}
> +        else
> +                for image in $(cat ${B}/barebox-flash-images); do
> +                        cp ${B}/${image} ${DEPLOYDIR}
> +                done
> +        fi
> +}
> +addtask deploy after do_compile
> diff --git a/meta/recipes-bsp/barebox/barebox_2023.01.0.bb b/meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> new file mode 100644
> index 0000000000..ca0c1566cf
> --- /dev/null
> +++ b/meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> @@ -0,0 +1,5 @@
> +require barebox.inc
> +
> +SRC_URI[sha256sum] = "20532daff1720fbefa0e02dba0294e6817d29c155f49b9b549db9577435fc7b6"
> +
> +SRC_URI += "file://0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch"
> diff --git a/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
> new file mode 100644
> index 0000000000..f37d608cf6
> --- /dev/null
> +++ b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
> @@ -0,0 +1,40 @@
> +From d8ea183cc1894b04b12f466a8779e61f0c1ac681 Mon Sep 17 00:00:00 2001
> +From: Marco Felsch <m.felsch@pengutronix.de>
> +Date: Tue, 6 Dec 2022 12:26:14 +0100
> +Subject: [PATCH] pbl: set IMAGE_COMPRESSION per default to lz4
> +
> +The LZO compression hasn't been updated since 2017 and embedded build
> +tools like Yocto dropping the support for it [1]. So switch to LZ4 as
> +default since this seems to be the most comparable compression standard
> +according Ahmads measurements [2] and the kernel suggestion [3].
> +
> +[1] https://lore.kernel.org/all/20220524152401.1663317-9-ross.burton@arm.com/
> +[2] https://lore.barebox.org/barebox/20220713100922.1880282-1-a.fatoum@pengutronix.de/
> +[3] https://lkml.org/lkml/2020/7/1/848
> +
> +Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> +Link: https://lore.barebox.org/20221206112614.2612071-1-m.felsch@pengutronix.de
> +Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> +
> +Upstream-Status: Backport
> +[https://git.pengutronix.de/cgit/barebox/commit/?h=next&id=d8ea183cc1894b04b12f466a8779e61f0c1ac681]
> +---
> + pbl/Kconfig | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/pbl/Kconfig b/pbl/Kconfig
> +index ba809af2d5..91970c19bc 100644
> +--- a/pbl/Kconfig
> ++++ b/pbl/Kconfig
> +@@ -63,7 +63,7 @@ if IMAGE_COMPRESSION
> + 
> + choice
> + 	prompt "Compression"
> +-	default IMAGE_COMPRESSION_LZO
> ++	default IMAGE_COMPRESSION_LZ4
> + 
> + config IMAGE_COMPRESSION_LZ4
> + 	bool "lz4"
> +-- 
> +2.30.2
> +
> -- 
> 2.30.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#176716): https://lists.openembedded.org/g/openembedded-core/message/176716
> Mute This Topic: https://lists.openembedded.org/mt/96722579/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Enrico Jörns Feb. 14, 2023, 9:46 a.m. UTC | #3
Hi Richard,

Am Freitag, dem 03.02.2023 um 14:17 +0000 schrieb Richard Purdie:
> On Fri, 2023-02-03 at 14:50 +0100, Marco Felsch wrote:
> > This adds the support for the barebox bootloader to oe-core. The recipe
> > is based on the recipe found in meta-ptx [1] with a few minor adaptions.
> > 
> > This basic support includes the bootloader and the target tools to
> > interact with the bootloader. The host tools support is not part of
> > this commit. This will be added later on as separate recipe.
> > 
> > [1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  meta/conf/documentation.conf                  |   7 +
> >  meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
> >  meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
> >  ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
> >  4 files changed, 175 insertions(+)
> >  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
> >  create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> >  create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-
> > to-lz4.patch
> 
> In order to add something to OE-Core, we need to see it being used by a
> reasonable portion of the ecosystem. Is there enough usage of barebox
> on common boards that justifies this?

I understand that not each and every package can and should be added to OE-core, so let me provide
my view on why adding barebox could be reasonable.

First of all, since it is a bootloader and oe-core's purpose is to provide basic common recipes
required to bring up a device, I found it to be a proper location for the recipe.
It does not add any further dependencies in the oe-core ecosystem so additional maintenance should
be limited in scope.

With over 300 individual contributors and regular monthly releases [1] I would call the barebox
bootloader a common, stable and mature project that is around since ~2009 and provides support for a
wide range of architectures, SoCs and platforms [2] including freely available common boards like
RPI, beaglebone, i.MX eval kits and UEFI in general.

Ever since, barebox has also been used by different hardware vendors (e.g. [4]) and was chosen by
Kalray [5] as their bootloader. Of course, as you know, it is always difficult to have a reliable
overview of the user base of an open source project as barebox.

So far there are already a number of barebox oe recipes around [3] that I find worth to consolidate
with adding one reference recipe to oe-core.


The question if these are sufficient arguments for adding barebox to oe-core probably needs to be
answered by the broader community, but I found it to be a good added value to have a bootloader in
oe-core that adapts many of the well-known schemes of Linux and focuses on being developer-friendly
and framework-driven.
(Let me just drop [6] for those interested in a bit details on what I summed up very roughly here.)

> I noticed there is no maintainers entry being added so this will throw
> QA errors on the autobuilder.

I would take responsibility for the recipe, backed by other barebox developers here.

> Also, I'm not sure adding doc varflags for individual recipe variables
> to documentation.conf makes sense. We should probably have them in the
> recipe or just put entries into the manual?

To be honest, this was inspired by the UBOOT_ variables that are placed in documentation.conf thus
we assumed this could be a proper place. We can simply move them into the recipe to limit intrusion
into the rest of the oe ecosystem.


Many thanks for your initial thoughts! Best regards,

Enrico

> Cheers,
> 
> Richard


[1] https://barebox.org/download/
[2] https://barebox.org/doc/latest/boards.html
[3] http://layers.openembedded.org/layerindex/branch/master/recipes/?q=barebox
[4] https://www.phytec.eu/en/cdocuments/?doc=YQ4RCg
[5] https://en.wikipedia.org/wiki/Kalray
[6] https://www.youtube.com/watch?v=fru1n54s2W4&ab_channel=TheLinuxFoundation
Richard Purdie Feb. 14, 2023, 1:56 p.m. UTC | #4
On Tue, 2023-02-14 at 10:46 +0100, Enrico Jörns wrote:
> Hi Richard,
> 
> Am Freitag, dem 03.02.2023 um 14:17 +0000 schrieb Richard Purdie:
> > On Fri, 2023-02-03 at 14:50 +0100, Marco Felsch wrote:
> > > This adds the support for the barebox bootloader to oe-core. The recipe
> > > is based on the recipe found in meta-ptx [1] with a few minor adaptions.
> > > 
> > > This basic support includes the bootloader and the target tools to
> > > interact with the bootloader. The host tools support is not part of
> > > this commit. This will be added later on as separate recipe.
> > > 
> > > [1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
> > > 
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > >  meta/conf/documentation.conf                  |   7 +
> > >  meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
> > >  meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
> > >  ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
> > >  4 files changed, 175 insertions(+)
> > >  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
> > >  create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> > >  create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-
> > > to-lz4.patch
> > 
> > In order to add something to OE-Core, we need to see it being used by a
> > reasonable portion of the ecosystem. Is there enough usage of barebox
> > on common boards that justifies this?
> 
> I understand that not each and every package can and should be added to OE-core, so let me provide
> my view on why adding barebox could be reasonable.
> 
> First of all, since it is a bootloader and oe-core's purpose is to provide basic common recipes
> required to bring up a device, I found it to be a proper location for the recipe.
> It does not add any further dependencies in the oe-core ecosystem so additional maintenance should
> be limited in scope.
> 
> With over 300 individual contributors and regular monthly releases [1] I would call the barebox
> bootloader a common, stable and mature project that is around since ~2009 and provides support for a
> wide range of architectures, SoCs and platforms [2] including freely available common boards like
> RPI, beaglebone, i.MX eval kits and UEFI in general.
> 
> Ever since, barebox has also been used by different hardware vendors (e.g. [4]) and was chosen by
> Kalray [5] as their bootloader. Of course, as you know, it is always difficult to have a reliable
> overview of the user base of an open source project as barebox.
> 
> So far there are already a number of barebox oe recipes around [3] that I find worth to consolidate
> with adding one reference recipe to oe-core.
> 
> The question if these are sufficient arguments for adding barebox to oe-core probably needs to be
> answered by the broader community, but I found it to be a good added value to have a bootloader in
> oe-core that adapts many of the well-known schemes of Linux and focuses on being developer-friendly
> and framework-driven.
> (Let me just drop [6] for those interested in a bit details on what I summed up very roughly here.)

Fair enough, I'm open to the idea. It would be interesting/useful to
see if anyone else in the community is in favour of this or not. I'm
sure you appreciate why we need to ask the question and why we can't
just add everything! :)

The community usage does appear to be primarily phytec/ptx.

> > I noticed there is no maintainers entry being added so this will throw
> > QA errors on the autobuilder.
> 
> I would take responsibility for the recipe, backed by other barebox developers here.

Ok, that helps. What about testing? I'm a bit worried that in adding
this, we'd be adding something which doesn't really get tested by the
autobuilder and is hence in an unknown state to us...

> > Also, I'm not sure adding doc varflags for individual recipe variables
> > to documentation.conf makes sense. We should probably have them in the
> > recipe or just put entries into the manual?
> 
> To be honest, this was inspired by the UBOOT_ variables that are placed in documentation.conf thus
> we assumed this could be a proper place. We can simply move them into the recipe to limit intrusion
> into the rest of the oe ecosystem.

There are multiple u-boot pieces so there is a slightly different case
there but even then, I think we should likely be rethinking global
variables like that which are so specific. Sadly global content isn't
something which comes for free in bitbake. I'm not keen to add to the
problem if we don't need to.

Cheers,

Richard
Otavio Salvador Feb. 15, 2023, 11:22 a.m. UTC | #5
Hello Richard,

Em ter., 14 de fev. de 2023 às 10:56, Richard Purdie <
richard.purdie@linuxfoundation.org> escreveu:

> Fair enough, I'm open to the idea. It would be interesting/useful to
> see if anyone else in the community is in favour of this or not. I'm
> sure you appreciate why we need to ask the question and why we can't
> just add everything! :)
>
> The community usage does appear to be primarily phytec/ptx.
>

I have used barebox in some projects in the past for multiple customers. It
is a solid and commonly used bootloader. I consider U-Boot the industry
standard, but Barebox is also widely used, and it makes sense to be part of
OE-Core.
Alexander Kanavin Feb. 15, 2023, 1:43 p.m. UTC | #6
On Wed, 15 Feb 2023 at 12:22, Otavio Salvador
<otavio.salvador@ossystems.com.br> wrote:
>> Fair enough, I'm open to the idea. It would be interesting/useful to
>> see if anyone else in the community is in favour of this or not. I'm
>> sure you appreciate why we need to ask the question and why we can't
>> just add everything! :)
>>
>> The community usage does appear to be primarily phytec/ptx.
>
>
> I have used barebox in some projects in the past for multiple customers. It is a solid and commonly used bootloader. I consider U-Boot the industry standard, but Barebox is also widely used, and it makes sense to be part of OE-Core.

I do not quite understand why barebox needs to be specifically in
oe-core. There's a well maintained layer for it:
https://github.com/menschel-d/meta-barebox
so once all those meta-phytec recipes are phased out in favour of
using that layer, there's no fragmentation.

Alex
Enrico Jörns Feb. 15, 2023, 1:49 p.m. UTC | #7
Am Mittwoch, dem 15.02.2023 um 14:43 +0100 schrieb Alexander Kanavin:
> On Wed, 15 Feb 2023 at 12:22, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
> > > Fair enough, I'm open to the idea. It would be interesting/useful to
> > > see if anyone else in the community is in favour of this or not. I'm
> > > sure you appreciate why we need to ask the question and why we can't
> > > just add everything! :)
> > > 
> > > The community usage does appear to be primarily phytec/ptx.
> > 
> > 
> > I have used barebox in some projects in the past for multiple customers. It is a solid and
> > commonly used bootloader. I consider U-Boot the industry standard, but Barebox is also widely
> > used, and it makes sense to be part of OE-Core.
> 
> I do not quite understand why barebox needs to be specifically in
> oe-core. There's a well maintained layer for it:
> https://github.com/menschel-d/meta-barebox
> so once all those meta-phytec recipes are phased out in favour of
> using that layer, there's no fragmentation.
> 

You forgot to mention https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox

I did never say that fragmentation is my only motivation.

Regards, Enrico
Otavio Salvador Feb. 15, 2023, 1:53 p.m. UTC | #8
Em qua., 15 de fev. de 2023 às 10:44, Alexander Kanavin
<alex.kanavin@gmail.com> escreveu:
> On Wed, 15 Feb 2023 at 12:22, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
> >> Fair enough, I'm open to the idea. It would be interesting/useful to
> >> see if anyone else in the community is in favour of this or not. I'm
> >> sure you appreciate why we need to ask the question and why we can't
> >> just add everything! :)
> >>
> >> The community usage does appear to be primarily phytec/ptx.
> >
> > I have used barebox in some projects in the past for multiple customers. It is a solid and commonly used bootloader. I consider U-Boot the industry standard, but Barebox is also widely used, and it makes sense to be part of OE-Core.
>
> I do not quite understand why barebox needs to be specifically in
> oe-core. There's a well maintained layer for it:
> https://github.com/menschel-d/meta-barebox
> so once all those meta-phytec recipes are phased out in favour of
> using that layer, there's no fragmentation.

I think the Barebox inside OE-Core allows a bigger integration and
reuse of existing tooling for signing and other classes currently well
integrated with U-Boot. For me, a critical point for decision is if
Pengutronix will commit to support it.
Enrico Jörns Feb. 15, 2023, 2:06 p.m. UTC | #9
Am Mittwoch, dem 15.02.2023 um 10:53 -0300 schrieb Otavio Salvador:
> Em qua., 15 de fev. de 2023 às 10:44, Alexander Kanavin
> <alex.kanavin@gmail.com> escreveu:
> > On Wed, 15 Feb 2023 at 12:22, Otavio Salvador
> > <otavio.salvador@ossystems.com.br> wrote:
> > > > Fair enough, I'm open to the idea. It would be interesting/useful to
> > > > see if anyone else in the community is in favour of this or not. I'm
> > > > sure you appreciate why we need to ask the question and why we can't
> > > > just add everything! :)
> > > > 
> > > > The community usage does appear to be primarily phytec/ptx.
> > > 
> > > I have used barebox in some projects in the past for multiple customers. It is a solid and
> > > commonly used bootloader. I consider U-Boot the industry standard, but Barebox is also widely
> > > used, and it makes sense to be part of OE-Core.
> > 
> > I do not quite understand why barebox needs to be specifically in
> > oe-core. There's a well maintained layer for it:
> > https://github.com/menschel-d/meta-barebox
> > so once all those meta-phytec recipes are phased out in favour of
> > using that layer, there's no fragmentation.
> 
> I think the Barebox inside OE-Core allows a bigger integration and
> reuse of existing tooling for signing and other classes currently well
> integrated with U-Boot.

Yes, this is another valid point. We have already identified that many things in OE are a bit
tailored to u-boot. Having another option (as one has for x86 with grub anyway) could, especially on
ARM platforms, inspire to make things more generic and probably also create community synergy
effects.

What clearly would not be the intention is to tailor things in oe-core for barebox only.

> For me, a critical point for decision is if
> Pengutronix will commit to support it.

Yes, I stated that this is clearly our intention.
So support isn't only a one-man show at all ;)


Thanks and best regards, Enrico
Alexander Kanavin Feb. 15, 2023, 2:11 p.m. UTC | #10
On Wed, 15 Feb 2023 at 14:53, Otavio Salvador
<otavio.salvador@ossystems.com.br> wrote:
> I think the Barebox inside OE-Core allows a bigger integration and
> reuse of existing tooling for signing and other classes currently well
> integrated with U-Boot. For me, a critical point for decision is if
> Pengutronix will commit to support it.

You should be well aware there's a history of people contributing
stuff to core and even assigning themselves as maintainers, then
disappearing. And then it falls (largely) on me to keep things
(barely) going. What happens if ptx withdraws its commitment? Can I
then send a commit that removes barebox from core? Imagine the angry
lynch mob that will show up after my head.

Adding things to core is a decision that cannot be easily reversed, so
I'd rather have barebox in meta-barebox for a while, with any needed
fixing to classes and infra in core.

Alex
Otavio Salvador Feb. 15, 2023, 2:59 p.m. UTC | #11
Em qua., 15 de fev. de 2023 às 11:11, Alexander Kanavin
<alex.kanavin@gmail.com> escreveu:
>
> On Wed, 15 Feb 2023 at 14:53, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
> > I think the Barebox inside OE-Core allows a bigger integration and
> > reuse of existing tooling for signing and other classes currently well
> > integrated with U-Boot. For me, a critical point for decision is if
> > Pengutronix will commit to support it.
>
> You should be well aware there's a history of people contributing
> stuff to core and even assigning themselves as maintainers, then
> disappearing. And then it falls (largely) on me to keep things
> (barely) going. What happens if ptx withdraws its commitment? Can I
> then send a commit that removes barebox from core? Imagine the angry
> lynch mob that will show up after my head.

Yes. If no one maintains, it should be removed. People will get mad
but then we'll see more commitment in future.

> Adding things to core is a decision that cannot be easily reversed, so
> I'd rather have barebox in meta-barebox for a while, with any needed
> fixing to classes and infra in core.

Sure but adding things to the core should still be possible and it is
a place to foster work sharing and contribution.
--
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
Enrico Jörns Feb. 15, 2023, 3:01 p.m. UTC | #12
Am Mittwoch, dem 15.02.2023 um 15:11 +0100 schrieb Alexander Kanavin:
> On Wed, 15 Feb 2023 at 14:53, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
> > I think the Barebox inside OE-Core allows a bigger integration and
> > reuse of existing tooling for signing and other classes currently well
> > integrated with U-Boot. For me, a critical point for decision is if
> > Pengutronix will commit to support it.
> 
> You should be well aware there's a history of people contributing
> stuff to core and even assigning themselves as maintainers, then
> disappearing.

If possible I would add my name with the above-mentioned Mailing list to the maintainers file.
This ensures I am responsible but not the only one reading the mails.

> And then it falls (largely) on me to keep things
> (barely) going. What happens if ptx withdraws its commitment? Can I
> then send a commit that removes barebox from core? Imagine the angry
> lynch mob that will show up after my head.

I am fully ok with removing barebox again if we fail maintaining it properly.

Should I sign this somewhere? ;)

> Adding things to core is a decision that cannot be easily reversed, so
> I'd rather have barebox in meta-barebox for a while, with any needed
> fixing to classes and infra in core.

It has been in meta-ptx since 2015 and in meta-barebox since 2016. I would call that 'a while' :)


Best regards, Enrico
Alexander Kanavin Feb. 15, 2023, 3:12 p.m. UTC | #13
There was a parallel conversation on the irc meanwhile; we've
concluded that Enrico will look into adding qemu based tests for
barebox into oe-selftest like we already have for EFI bootloaders, and
there will be a new patchset then.

Alex

On Wed, 15 Feb 2023 at 16:01, Enrico Jörns <ejo@pengutronix.de> wrote:
>
> Am Mittwoch, dem 15.02.2023 um 15:11 +0100 schrieb Alexander Kanavin:
> > On Wed, 15 Feb 2023 at 14:53, Otavio Salvador
> > <otavio.salvador@ossystems.com.br> wrote:
> > > I think the Barebox inside OE-Core allows a bigger integration and
> > > reuse of existing tooling for signing and other classes currently well
> > > integrated with U-Boot. For me, a critical point for decision is if
> > > Pengutronix will commit to support it.
> >
> > You should be well aware there's a history of people contributing
> > stuff to core and even assigning themselves as maintainers, then
> > disappearing.
>
> If possible I would add my name with the above-mentioned Mailing list to the maintainers file.
> This ensures I am responsible but not the only one reading the mails.
>
> > And then it falls (largely) on me to keep things
> > (barely) going. What happens if ptx withdraws its commitment? Can I
> > then send a commit that removes barebox from core? Imagine the angry
> > lynch mob that will show up after my head.
>
> I am fully ok with removing barebox again if we fail maintaining it properly.
>
> Should I sign this somewhere? ;)
>
> > Adding things to core is a decision that cannot be easily reversed, so
> > I'd rather have barebox in meta-barebox for a while, with any needed
> > fixing to classes and infra in core.
>
> It has been in meta-ptx since 2015 and in meta-barebox since 2016. I would call that 'a while' :)
>
>
> Best regards, Enrico
>
> --
> Pengutronix e.K.                           | Enrico Jörns                |
> Embedded Linux Consulting & Support        | https://www.pengutronix.de/ |
> Steuerwalder Str. 21                       | Phone: +49-5121-206917-180  |
> 31137 Hildesheim, Germany                  | Fax:   +49-5121-206917-9    |
>
Enrico Jörns Feb. 24, 2023, 1:32 p.m. UTC | #14
Hi,

Am Freitag, dem 03.02.2023 um 22:07 +0100 schrieb Alexandre Belloni:
> This breaks oe-selftest:
> 
> https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/4760/steps/15/logs/stdio

thanks for having this thrown on the autobuilder!

> 2023-02-03 17:55:08,025 - oe-selftest - INFO -
> fitimage.FitImageTests.test_sign_cascaded_uboot_fit_image (subunit.RemotedTestCase)
> 2023-02-03 17:55:08,026 - oe-selftest - INFO -  ... FAIL
> Stderr:
> 2023-02-03 14:32:52,619 - oe-selftest - INFO - Adding: "include selftest.inc" in
> /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-st-35279/conf/local.conf
> 2023-02-03 14:32:52,620 - oe-selftest - INFO - Adding: "include bblayers.inc" in bblayers.conf
> 2023-02-03 17:55:08,026 - oe-selftest - INFO - 13: 4/22 399/509 (54.05s) (0 failed)
> (fitimage.FitImageTests.test_sign_cascaded_uboot_fit_image)
> 2023-02-03 17:55:08,026 - oe-selftest - INFO - testtools.testresult.real._StringException:
> Traceback (most recent call last):
>   File "/home/pokybuild/yocto-worker/oe-selftest-
> centos/build/meta/lib/oeqa/selftest/cases/fitimage.py", line 612, in
> test_sign_cascaded_uboot_fit_image
>     bitbake("virtual/bootloader")
>   File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/utils/commands.py",
> line 236, in bitbake
>     return runCmd(cmd, ignore_status, timeout, output_log=output_log, **options)
>   File "/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/lib/oeqa/utils/commands.py",
> line 214, in runCmd
>     raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command,
> result.status, exc_output))
> AssertionError: Command 'bitbake  virtual/bootloader' returned non-zero exit status 1:
> 
> ERROR: barebox-2023.01.0-r0 do_configure: No defconfig given. Either add file
> 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG

This fails since BAREBOX_CONFIG is not set to any default, yet.
This is similar to what the uboot recipes expect to be set from the MACHINE as UBOOT_MACHINE.

To limit the impact of barebox to oe-core, I would set BAREBOX_CONFIG overrides for the default
machines contained in oe-core in the barebox recipe. Then they don't have to be set in the
machine.conf files.

> ERROR: barebox-2023.01.0-r0 do_configure: ExecutionError('/home/pokybuild/yocto-worker/oe-
> selftest-centos/build/build-st-35279/tmp/work/qemuarm-poky-linux-gnueabi/barebox/2023.01.0-
> r0/temp/run.do_configure.3098535', 1, None, None)
> ERROR: Logfile of failure stored in: /home/pokybuild/yocto-worker/oe-selftest-centos/build/build-
> st-35279/tmp/work/qemuarm-poky-linux-gnueabi/barebox/2023.01.0-r0/temp/log.do_configure.3098535
> NOTE: recipe barebox-2023.01.0-r0: task do_configure: Failed
> ERROR: Task (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-
> bsp/barebox/barebox_2023.01.0.bb:do_configure) failed with exit code '1'
> 
> And as already reported by Richard:
> 
> AssertionError: 
> The following recipes do not have a maintainer assigned to them. Please add an entry to
> meta/conf/distro/include/maintainers.inc file.
> barebox-tools (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-
> bsp/barebox/barebox-tools_2023.01.0.bb)
> barebox (/home/pokybuild/yocto-worker/oe-selftest-centos/build/meta/recipes-
> bsp/barebox/barebox_2023.01.0.bb)

Yes. At least for now, that's the easier part and was already fixed in my local patch set by
assigning me. ;)


Regards, Enrico

> On 03/02/2023 14:50:10+0100, Marco Felsch wrote:
> > This adds the support for the barebox bootloader to oe-core. The recipe
> > is based on the recipe found in meta-ptx [1] with a few minor adaptions.
> > 
> > This basic support includes the bootloader and the target tools to
> > interact with the bootloader. The host tools support is not part of
> > this commit. This will be added later on as separate recipe.
> > 
> > [1] https://github.com/pengutronix/meta-ptx/tree/master/recipes-bsp/barebox
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  meta/conf/documentation.conf                  |   7 +
> >  meta/recipes-bsp/barebox/barebox.inc          | 123 ++++++++++++++++++
> >  meta/recipes-bsp/barebox/barebox_2023.01.0.bb |   5 +
> >  ...IMAGE_COMPRESSION-per-default-to-lz4.patch |  40 ++++++
> >  4 files changed, 175 insertions(+)
> >  create mode 100644 meta/recipes-bsp/barebox/barebox.inc
> >  create mode 100644 meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> >  create mode 100644 meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-
> > to-lz4.patch
> > 
> > diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
> > index a27d7a53c3..99e8f8e730 100644
> > --- a/meta/conf/documentation.conf
> > +++ b/meta/conf/documentation.conf
> > @@ -77,6 +77,13 @@ AUTOREV[doc] = "When SRCREV is set to the value of this variable, it
> > specifies t
> >  
> >  B[doc] = "The Build Directory. The OpenEmbedded build system places generated objects into the
> > Build Directory during a recipe's build process."
> >  BAD_RECOMMENDATIONS[doc] = "A list of packages not to install despite being recommended by a
> > recipe. Support for this variable exists only when using the IPK or RPM packaging backends."
> > +BAREBOX_BUILDSYSTEM_VERSION[doc] = "Build system version to add to the barebox image. By
> > default this is the git description of the containing layer."
> > +BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig
> > is added to the SRC_URI."
> > +BAREBOX_ENV_DIR[doc] = "Overlay the barebox built-in environment with the environment provided
> > by the BSP if specified."
> > +BAREBOX_BINARY[doc] = "Specify the barebox binary to install. If not specified all barebox
> > artifacts are installed."
> > +BAREBOX_IMAGE[doc] = "A unique barebox image name. Unused if ${BAREBOX_BINARY} is not set."
> > +BAREBOX_SUFFIX[doc] = "Specify the suffix for ${BAREBOX_IMAGE}."
> > +BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory
> > (CONFIG_EXTRA_FIRMWARE_DIR) with this path, default ${B}/firmware"
> >  BB_DANGLINGAPPENDS_WARNONLY[doc] = "Defines how BitBake handles situations where an append file
> > (.bbappend) has no corresponding recipe file (.bb)."
> >  BB_DISKMON_DIRS[doc] = "Monitors disk space and available inodes during the build and allows
> > you to control the build based on these parameters."
> >  BB_DISKMON_WARNINTERVAL[doc] = "Defines the disk space and free inode warning intervals. To set
> > these intervals, define the variable in the conf/local.conf file in the Build Directory."
> > diff --git a/meta/recipes-bsp/barebox/barebox.inc b/meta/recipes-bsp/barebox/barebox.inc
> > new file mode 100644
> > index 0000000000..896db9739f
> > --- /dev/null
> > +++ b/meta/recipes-bsp/barebox/barebox.inc
> > @@ -0,0 +1,123 @@
> > +SUMMARY = "barebox is a bootloader designed for embedded systems. It runs on a variety of
> > architectures including x86, ARM, MIPS, PowerPC and others."
> > +HOMEPAGE = "https://barebox.org/"
> > +SECTION = "bootloaders"
> > +PROVIDES = "virtual/bootloader"
> > +
> > +LICENSE = "GPL-2.0-only"
> > +LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
> > +
> > +PACKAGE_ARCH = "${MACHINE_ARCH}"
> > +
> > +inherit kernel-arch deploy cml1 pkgconfig
> > +
> > +# libusb1 is only required for usb tools like imx-usb-loader. These tools may
> > +# be enabled within the defconfig file so depend on it here to be more user
> > +# friendly (do not abort the build). The actual tools are provided by the
> > +# barebox-tools package.
> > +DEPENDS = "libusb1 bison-native flex-native"
> > +
> > +export KBUILD_BUILD_USER ?= "oe-user"
> > +export KBUILD_BUILD_HOST ?= "oe-host"
> > +
> > +SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
> > +
> > +S = "${WORKDIR}/barebox-${PV}"
> > +B = "${WORKDIR}/build"
> > +
> > +def get_layer_rev(path):
> > +    try:
> > +        rev, _ = bb.process.run("git describe --match='' --always --dirty --broken", cwd=path)
> > +    except bb.process.ExecutionError:
> > +        rev = ""
> > +    return rev.strip()
> > +
> > +BAREBOX_BUILDSYSTEM_VERSION ??= "${@get_layer_rev(os.path.dirname(d.getVar('FILE')))}"
> > +
> > +BAREBOX_FIRMWARE_DIR ??= "${B}/firmware"
> > +
> > +EXTRA_OEMAKE = " \
> > +    CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
> > +    BUILDSYSTEM_VERSION=${BAREBOX_BUILDSYSTEM_VERSION} \
> > +    CONFIG_EXTRA_FIRMWARE_DIR=${BAREBOX_FIRMWARE_DIR} \
> > +"
> > +
> > +BAREBOX_CONFIG ?= ""
> > +
> > +do_configure() {
> > +        if [ -e ${WORKDIR}/defconfig ]; then
> > +                cp ${WORKDIR}/defconfig ${B}/.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
> > +        fi
> > +
> > +        ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
> > +        cml1_do_configure
> > +}
> > +
> > +BAREBOX_ENV_DIR ??= "${WORKDIR}/env/"
> > +
> > +do_compile () {
> > +        export userccflags="${TARGET_LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
> > +        unset LDFLAGS
> > +        unset CFLAGS
> > +        unset CPPFLAGS
> > +        unset CXXFLAGS
> > +        unset MACHINE
> > +
> > +        if [ -d ${BAREBOX_ENV_DIR} ]; then
> > +                BAREBOX_DEFAULT_ENV="$(grep ^CONFIG_DEFAULT_ENVIRONMENT_PATH .config | cut -d
> > '=' -f 2 | tr -d '"')"
> > +                oe_runmake CONFIG_DEFAULT_ENVIRONMENT_PATH="\"${BAREBOX_DEFAULT_ENV}
> > ${BAREBOX_ENV_DIR}\""
> > +        else
> > +                oe_runmake
> > +        fi
> > +}
> > +
> > +BAREBOX_BINARY ??= ""
> > +BAREBOX_SUFFIX ??= "img"
> > +BAREBOX_SUFFIX:x86 ??= "efi"
> > +BAREBOX_SUFFIX:x86-64 ??= "efi"
> > +BAREBOX_IMAGE ?= "${PN}-${MACHINE}-${PV}-${PR}.${BAREBOX_SUFFIX}"
> > +
> > +do_install () {
> > +        if [ -n "${BAREBOX_BINARY}" ]; then
> > +
> > +                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
> > +                if [ ! -f "${BAREBOX_BIN}" ]; then
> > +                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
> > +                fi
> > +                if [ ! -f "${BAREBOX_BIN}" ]; then
> > +                        bbfatal "Failed to locate ${BAREBOX_BINARY}"
> > +                fi
> > +
> > +                install -D -m 644 ${BAREBOX_BIN} ${D}/boot/${BAREBOX_IMAGE}
> > +                ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
> > +        else
> > +                install -d ${D}/boot/
> > +                for image in $(cat ${B}/barebox-flash-images); do
> > +                        install -m 644 ${B}/${image} ${D}/boot/
> > +                done
> > +        fi
> > +}
> > +FILES:${PN} = "/boot"
> > +
> > +do_deploy () {
> > +        if [ -n "${BAREBOX_BINARY}" ]; then
> > +
> > +                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
> > +                if [ ! -f "${BAREBOX_BIN}" ]; then
> > +                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
> > +                fi
> > +
> > +                install -D -m 644 ${BAREBOX_BIN} ${DEPLOYDIR}/${BAREBOX_IMAGE}
> > +                ln -sf ${BAREBOX_IMAGE} ${DEPLOYDIR}/${BAREBOX_BINARY}
> > +        else
> > +                for image in $(cat ${B}/barebox-flash-images); do
> > +                        cp ${B}/${image} ${DEPLOYDIR}
> > +                done
> > +        fi
> > +}
> > +addtask deploy after do_compile
> > diff --git a/meta/recipes-bsp/barebox/barebox_2023.01.0.bb b/meta/recipes-
> > bsp/barebox/barebox_2023.01.0.bb
> > new file mode 100644
> > index 0000000000..ca0c1566cf
> > --- /dev/null
> > +++ b/meta/recipes-bsp/barebox/barebox_2023.01.0.bb
> > @@ -0,0 +1,5 @@
> > +require barebox.inc
> > +
> > +SRC_URI[sha256sum] = "20532daff1720fbefa0e02dba0294e6817d29c155f49b9b549db9577435fc7b6"
> > +
> > +SRC_URI += "file://0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch"
> > diff --git a/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-
> > lz4.patch b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-
> > lz4.patch
> > new file mode 100644
> > index 0000000000..f37d608cf6
> > --- /dev/null
> > +++ b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
> > @@ -0,0 +1,40 @@
> > +From d8ea183cc1894b04b12f466a8779e61f0c1ac681 Mon Sep 17 00:00:00 2001
> > +From: Marco Felsch <m.felsch@pengutronix.de>
> > +Date: Tue, 6 Dec 2022 12:26:14 +0100
> > +Subject: [PATCH] pbl: set IMAGE_COMPRESSION per default to lz4
> > +
> > +The LZO compression hasn't been updated since 2017 and embedded build
> > +tools like Yocto dropping the support for it [1]. So switch to LZ4 as
> > +default since this seems to be the most comparable compression standard
> > +according Ahmads measurements [2] and the kernel suggestion [3].
> > +
> > +[1] https://lore.kernel.org/all/20220524152401.1663317-9-ross.burton@arm.com/
> > +[2] https://lore.barebox.org/barebox/20220713100922.1880282-1-a.fatoum@pengutronix.de/
> > +[3] https://lkml.org/lkml/2020/7/1/848
> > +
> > +Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > +Link: https://lore.barebox.org/20221206112614.2612071-1-m.felsch@pengutronix.de
> > +Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > +
> > +Upstream-Status: Backport
> > +[ 
> > https://git.pengutronix.de/cgit/barebox/commit/?h=next&id=d8ea183cc1894b04b12f466a8779e61f0c1ac681
> > ]
> > +---
> > + pbl/Kconfig | 2 +-
> > + 1 file changed, 1 insertion(+), 1 deletion(-)
> > +
> > +diff --git a/pbl/Kconfig b/pbl/Kconfig
> > +index ba809af2d5..91970c19bc 100644
> > +--- a/pbl/Kconfig
> > ++++ b/pbl/Kconfig
> > +@@ -63,7 +63,7 @@ if IMAGE_COMPRESSION
> > + 
> > + choice
> > +       prompt "Compression"
> > +-      default IMAGE_COMPRESSION_LZO
> > ++      default IMAGE_COMPRESSION_LZ4
> > + 
> > + config IMAGE_COMPRESSION_LZ4
> > +       bool "lz4"
> > +-- 
> > +2.30.2
> > +
> > -- 
> > 2.30.2
> > 
> 
> > 
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#176716): https://lists.openembedded.org/g/openembedded-core/message/176716
> > Mute This Topic: https://lists.openembedded.org/mt/96722579/3617179
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ 
> > alexandre.belloni@bootlin.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> > 
> 
>
diff mbox series

Patch

diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index a27d7a53c3..99e8f8e730 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -77,6 +77,13 @@  AUTOREV[doc] = "When SRCREV is set to the value of this variable, it specifies t
 
 B[doc] = "The Build Directory. The OpenEmbedded build system places generated objects into the Build Directory during a recipe's build process."
 BAD_RECOMMENDATIONS[doc] = "A list of packages not to install despite being recommended by a recipe. Support for this variable exists only when using the IPK or RPM packaging backends."
+BAREBOX_BUILDSYSTEM_VERSION[doc] = "Build system version to add to the barebox image. By default this is the git description of the containing layer."
+BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig is added to the SRC_URI."
+BAREBOX_ENV_DIR[doc] = "Overlay the barebox built-in environment with the environment provided by the BSP if specified."
+BAREBOX_BINARY[doc] = "Specify the barebox binary to install. If not specified all barebox artifacts are installed."
+BAREBOX_IMAGE[doc] = "A unique barebox image name. Unused if ${BAREBOX_BINARY} is not set."
+BAREBOX_SUFFIX[doc] = "Specify the suffix for ${BAREBOX_IMAGE}."
+BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path, default ${B}/firmware"
 BB_DANGLINGAPPENDS_WARNONLY[doc] = "Defines how BitBake handles situations where an append file (.bbappend) has no corresponding recipe file (.bb)."
 BB_DISKMON_DIRS[doc] = "Monitors disk space and available inodes during the build and allows you to control the build based on these parameters."
 BB_DISKMON_WARNINTERVAL[doc] = "Defines the disk space and free inode warning intervals. To set these intervals, define the variable in the conf/local.conf file in the Build Directory."
diff --git a/meta/recipes-bsp/barebox/barebox.inc b/meta/recipes-bsp/barebox/barebox.inc
new file mode 100644
index 0000000000..896db9739f
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox.inc
@@ -0,0 +1,123 @@ 
+SUMMARY = "barebox is a bootloader designed for embedded systems. It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."
+HOMEPAGE = "https://barebox.org/"
+SECTION = "bootloaders"
+PROVIDES = "virtual/bootloader"
+
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit kernel-arch deploy cml1 pkgconfig
+
+# libusb1 is only required for usb tools like imx-usb-loader. These tools may
+# be enabled within the defconfig file so depend on it here to be more user
+# friendly (do not abort the build). The actual tools are provided by the
+# barebox-tools package.
+DEPENDS = "libusb1 bison-native flex-native"
+
+export KBUILD_BUILD_USER ?= "oe-user"
+export KBUILD_BUILD_HOST ?= "oe-host"
+
+SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
+
+S = "${WORKDIR}/barebox-${PV}"
+B = "${WORKDIR}/build"
+
+def get_layer_rev(path):
+    try:
+        rev, _ = bb.process.run("git describe --match='' --always --dirty --broken", cwd=path)
+    except bb.process.ExecutionError:
+        rev = ""
+    return rev.strip()
+
+BAREBOX_BUILDSYSTEM_VERSION ??= "${@get_layer_rev(os.path.dirname(d.getVar('FILE')))}"
+
+BAREBOX_FIRMWARE_DIR ??= "${B}/firmware"
+
+EXTRA_OEMAKE = " \
+    CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
+    BUILDSYSTEM_VERSION=${BAREBOX_BUILDSYSTEM_VERSION} \
+    CONFIG_EXTRA_FIRMWARE_DIR=${BAREBOX_FIRMWARE_DIR} \
+"
+
+BAREBOX_CONFIG ?= ""
+
+do_configure() {
+        if [ -e ${WORKDIR}/defconfig ]; then
+                cp ${WORKDIR}/defconfig ${B}/.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
+        fi
+
+        ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
+        cml1_do_configure
+}
+
+BAREBOX_ENV_DIR ??= "${WORKDIR}/env/"
+
+do_compile () {
+        export userccflags="${TARGET_LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+        unset LDFLAGS
+        unset CFLAGS
+        unset CPPFLAGS
+        unset CXXFLAGS
+        unset MACHINE
+
+        if [ -d ${BAREBOX_ENV_DIR} ]; then
+                BAREBOX_DEFAULT_ENV="$(grep ^CONFIG_DEFAULT_ENVIRONMENT_PATH .config | cut -d '=' -f 2 | tr -d '"')"
+                oe_runmake CONFIG_DEFAULT_ENVIRONMENT_PATH="\"${BAREBOX_DEFAULT_ENV} ${BAREBOX_ENV_DIR}\""
+        else
+                oe_runmake
+        fi
+}
+
+BAREBOX_BINARY ??= ""
+BAREBOX_SUFFIX ??= "img"
+BAREBOX_SUFFIX:x86 ??= "efi"
+BAREBOX_SUFFIX:x86-64 ??= "efi"
+BAREBOX_IMAGE ?= "${PN}-${MACHINE}-${PV}-${PR}.${BAREBOX_SUFFIX}"
+
+do_install () {
+        if [ -n "${BAREBOX_BINARY}" ]; then
+
+                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
+                if [ ! -f "${BAREBOX_BIN}" ]; then
+                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
+                fi
+                if [ ! -f "${BAREBOX_BIN}" ]; then
+                        bbfatal "Failed to locate ${BAREBOX_BINARY}"
+                fi
+
+                install -D -m 644 ${BAREBOX_BIN} ${D}/boot/${BAREBOX_IMAGE}
+                ln -sf ${BAREBOX_IMAGE} ${D}/boot/${BAREBOX_BINARY}
+        else
+                install -d ${D}/boot/
+                for image in $(cat ${B}/barebox-flash-images); do
+                        install -m 644 ${B}/${image} ${D}/boot/
+                done
+        fi
+}
+FILES:${PN} = "/boot"
+
+do_deploy () {
+        if [ -n "${BAREBOX_BINARY}" ]; then
+
+                BAREBOX_BIN=${B}/${BAREBOX_BINARY}
+                if [ ! -f "${BAREBOX_BIN}" ]; then
+                        BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
+                fi
+
+                install -D -m 644 ${BAREBOX_BIN} ${DEPLOYDIR}/${BAREBOX_IMAGE}
+                ln -sf ${BAREBOX_IMAGE} ${DEPLOYDIR}/${BAREBOX_BINARY}
+        else
+                for image in $(cat ${B}/barebox-flash-images); do
+                        cp ${B}/${image} ${DEPLOYDIR}
+                done
+        fi
+}
+addtask deploy after do_compile
diff --git a/meta/recipes-bsp/barebox/barebox_2023.01.0.bb b/meta/recipes-bsp/barebox/barebox_2023.01.0.bb
new file mode 100644
index 0000000000..ca0c1566cf
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox_2023.01.0.bb
@@ -0,0 +1,5 @@ 
+require barebox.inc
+
+SRC_URI[sha256sum] = "20532daff1720fbefa0e02dba0294e6817d29c155f49b9b549db9577435fc7b6"
+
+SRC_URI += "file://0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch"
diff --git a/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
new file mode 100644
index 0000000000..f37d608cf6
--- /dev/null
+++ b/meta/recipes-bsp/barebox/files/0001-pbl-set-IMAGE_COMPRESSION-per-default-to-lz4.patch
@@ -0,0 +1,40 @@ 
+From d8ea183cc1894b04b12f466a8779e61f0c1ac681 Mon Sep 17 00:00:00 2001
+From: Marco Felsch <m.felsch@pengutronix.de>
+Date: Tue, 6 Dec 2022 12:26:14 +0100
+Subject: [PATCH] pbl: set IMAGE_COMPRESSION per default to lz4
+
+The LZO compression hasn't been updated since 2017 and embedded build
+tools like Yocto dropping the support for it [1]. So switch to LZ4 as
+default since this seems to be the most comparable compression standard
+according Ahmads measurements [2] and the kernel suggestion [3].
+
+[1] https://lore.kernel.org/all/20220524152401.1663317-9-ross.burton@arm.com/
+[2] https://lore.barebox.org/barebox/20220713100922.1880282-1-a.fatoum@pengutronix.de/
+[3] https://lkml.org/lkml/2020/7/1/848
+
+Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
+Link: https://lore.barebox.org/20221206112614.2612071-1-m.felsch@pengutronix.de
+Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
+
+Upstream-Status: Backport
+[https://git.pengutronix.de/cgit/barebox/commit/?h=next&id=d8ea183cc1894b04b12f466a8779e61f0c1ac681]
+---
+ pbl/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pbl/Kconfig b/pbl/Kconfig
+index ba809af2d5..91970c19bc 100644
+--- a/pbl/Kconfig
++++ b/pbl/Kconfig
+@@ -63,7 +63,7 @@ if IMAGE_COMPRESSION
+ 
+ choice
+ 	prompt "Compression"
+-	default IMAGE_COMPRESSION_LZO
++	default IMAGE_COMPRESSION_LZ4
+ 
+ config IMAGE_COMPRESSION_LZ4
+ 	bool "lz4"
+-- 
+2.30.2
+