Skip to contentSkip to conversation

Add barebox bootloader support (and testing)

PATCH Superseded Enrico Jörns 2 participants 16 messages Sep 10, 2024

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add barebox bootloader support (and testing)

This adds support for the barebox bootloader (and tools) to oe-core.

In order to have proper testing, this extends oe-selftest to allow basic testing of bootloaders. While at it, cover both u-boot and barebox.

v4:

* bump to barebox 2024.08.0
* change barebox native build deps to PACKAGECONFIGs
* export HOST_EXTRACFLAGS
* set new barebox PKG_CONFIG and CROSS_PKG_CONFIG make options
* remove unnecessary python variables (PN, FILE) from barebox config check
* use new multi_v8_defconfig for qemuarm64
* drop x86 tests and crlf output parsing adaptions for now to avoid potential impact on other tests

Enrico Jorns (5):
barebox: set default BAREBOX_CONFIG for qemu machines oeqa/utils/qemurunner: support ignoring vt100 escape sequences
oeqa: support passing custom boot patterns to runqemu oeqa/selftest/cases: add basic u-boot test oeqa/selftest/cases: add basic barebox tests

Marco Felsch (2):
barebox: add initial support
barebox-tools: add initial barebox tools support

 meta/conf/distro/include/maintainers.inc      |   2 +
 meta/conf/machine/qemuarm.conf                |   1 +
 meta/conf/machine/qemuarm64.conf              |   1 +
 meta/conf/machine/qemux86-64.conf             |   1 +
 meta/lib/oeqa/selftest/cases/barebox.py       |  43 +++++
 meta/lib/oeqa/selftest/cases/uboot.py         |  42 +++++
 meta/lib/oeqa/targetcontrol.py                |   5 +-
 meta/lib/oeqa/utils/commands.py               |   5 +-
 meta/lib/oeqa/utils/qemurunner.py             |   6 +-
 .../barebox/barebox-tools_2024.08.0.bb        |  58 +++++++
 meta/recipes-bsp/barebox/barebox.inc          | 156 ++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2024.08.0.bb |   3 +
 12 files changed, 317 insertions(+), 6 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/cases/barebox.py
 create mode 100644 meta/lib/oeqa/selftest/cases/uboot.py
 create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2024.08.0.bb
Signature · 1 line
2.39.2
#1 lore raw

PATCH v4 1/7 barebox: add initial support

From: Marco Felsch <[email protected]>

This adds the support for the barebox bootloader to oe-core. The recipe is inspired by meta-ptx [1] but is a major rework the one found there.

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

---
 meta/conf/distro/include/maintainers.inc      |   1 +
 meta/recipes-bsp/barebox/barebox.inc          | 151 ++++++++++++++++++
 meta/recipes-bsp/barebox/barebox_2024.08.0.bb |   3 +
 3 files changed, 155 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox.inc
 create mode 100644 meta/recipes-bsp/barebox/barebox_2024.08.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
index 60f36a9449..1b3d485e48 100644
@@ -54,6 +54,7 @@ RECIPE_MAINTAINER:pn-automake = "Robert Yang <[email protected]>"
 RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>"
+RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>"
 RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>"
 RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>"
 RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"
meta/recipes-bsp/barebox/barebox.inc new file +151 -0

151 lines not on this page · raw message

meta/recipes-bsp/barebox/barebox_2024.08.0.bb new file +3 -0
new file mode 100644
index 0000000000..1a7bbbccaa
@@ -0,0 +1,3 @@
+require barebox.inc
+
+SRC_URI[sha256sum] = "b08a762da8d63dd18b4f2d9f5d0a8da001b6e608d1b3eff6dcebc6a2e575d535"
Signature · 1 line
2.39.2
#2 lore raw

Re: [OE-core] [PATCH v4 1/7] barebox: add initial support

meta/recipes-bsp/barebox/barebox.inc line 23

Quoted 3 lines · Enrico Jörns via lists.openembedded.org
meta/recipes-bsp/barebox/barebox.inc new file +3 -0
+PACKAGECONFIG[openssl] = ",,openssl-native"
+PACKAGECONFIG[libusb] = ",,libusb1-native"
+PACKAGECONFIG[fit] = ",,u-boot-tools-native dtc-native"

Does barebox have configuration options for these? The problem with auto-detection is that one can't reliably keep this options disabled, as openssl etc. can show up in native sysroot for other reasons.

Alex

#3 lore raw

Re: [OE-core] [PATCH v4 1/7] barebox: add initial support

Hi Alex,

Am Dienstag, dem 10.09.2024 um 10:33 +0200 schrieb Alexander Kanavin:

Quoted 9 lines

meta/recipes-bsp/barebox/barebox.inc line 23

Quoted 3 lines · Enrico Jörns via lists.openembedded.org
meta/recipes-bsp/barebox/barebox.inc new file +3 -0
+PACKAGECONFIG[openssl] = ",,openssl-native"
+PACKAGECONFIG[libusb] = ",,libusb1-native"
+PACKAGECONFIG[fit] = ",,u-boot-tools-native dtc-native"

Does barebox have configuration options for these? The problem with auto-detection is that one can't reliably keep this options disabled, as openssl etc. can show up in native sysroot for other reasons.

this should not be a problem since dependencies are only required for some SoC-specific tooling. And this would just fail to compile if the option is accidentally disabled.

I chose to use packageconfig here to reflect that these are not a hard dependencies for all cases and to aligned with what the u-boot recipe does for similar reasons.

Regards, Enrico

Quoted 2 lines

Alex

Signature · 4 lines
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    |
#4 lore raw

PATCH v4 2/7 barebox-tools: add initial barebox tools support

In reply to Enrico Jörns

From: Marco Felsch <[email protected]>

Add initial support to build the barebox tools for the host and the target.

---
 meta/conf/distro/include/maintainers.inc      |  1 +
 .../barebox/barebox-tools_2024.08.0.bb        | 58 +++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
index 1b3d485e48..067c4af096 100644
@@ -55,6 +55,7 @@ RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>"
+RECIPE_MAINTAINER:pn-barebox-tools = "Enrico Jörns <[email protected]>"
 RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>"
 RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>"
 RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"
meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.39.2
#5 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Can this be merged into the main barebox recipe? Does it need a separate recipe?

Alex

Quoted 102 lines · Enrico Jörns via lists.openembedded.org

From: Marco Felsch <[email protected]>

Add initial support to build the barebox tools for the host and the target.

---
 meta/conf/distro/include/maintainers.inc      |  1 +
 .../barebox/barebox-tools_2024.08.0.bb        | 58 +++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb
meta/conf/distro/include/maintainers.inc +1 -0
index 1b3d485e48..067c4af096 100644
@@ -55,6 +55,7 @@ RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>"
+RECIPE_MAINTAINER:pn-barebox-tools = "Enrico Jörns <[email protected]>"
 RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>"
 RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>"
 RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"
meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb new file +58 -1
new file mode 100644
index 0000000000..25f4998d4a
@@ -0,0 +1,58 @@
+SUMMARY = "barebox bootloader tools"
+HOMEPAGE = "https://barebox.org/"
+
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
+
+DEPENDS = "libusb1 bison-native flex-native"
+
+SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
+SRC_URI[sha256sum] = "b08a762da8d63dd18b4f2d9f5d0a8da001b6e608d1b3eff6dcebc6a2e575d535"
+
+S = "${WORKDIR}/barebox-${PV}"
+B = "${WORKDIR}/build"
+
+inherit pkgconfig
+
+EXTRA_OEMAKE = " \
+  ARCH=sandbox \
+  CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
+  CROSS_PKG_CONFIG=pkg-config \
+  CC='${CC}' \
+  LD='${LD}' \
+  "
+
+do_compile:class-target () {
+    export userccflags="${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+    export userldflags="${TARGET_LDFLAGS}${TOOLCHAIN_OPTIONS}"
+    oe_runmake targettools_defconfig
+    oe_runmake scripts
+}
+
+do_compile:class-native () {
+    oe_runmake hosttools_defconfig
+    oe_runmake scripts
+}
+
+BAREBOX_TOOLS = " \
+         bareboxenv \
+         bareboxcrc32 \
+         kernel-install \
+         bareboximd \
+         omap3-usb-loader \
+         omap4_usbboot \
+         imx/imx-usb-loader \
+         "
+
+BAREBOX_TOOLS_SUFFIX = ""
+BAREBOX_TOOLS_SUFFIX:class-target = "-target"
+
+do_install () {
+       install -d ${D}${bindir}
+
+       for tool in ${BAREBOX_TOOLS}; do
+               install -m 0755 scripts/${tool}${BAREBOX_TOOLS_SUFFIX} ${D}${bindir}/${tool##*/}
+       done
+}
+
+BBCLASSEXTEND = "native nativesdk"
--

2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#204337): https://lists.openembedded.org/g/openembedded-core/message/204337
Mute This Topic: https://lists.openembedded.org/mt/108370664/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Hi Alex,

Am Dienstag, dem 10.09.2024 um 10:37 +0200 schrieb Alexander Kanavin:

Quoted 1 line

Can this be merged into the main barebox recipe? Does it need a separate recipe?

not only that it would complicate the main recipe (we had tried this before), but I really see no point in doing and supporting barebox native builds (in contrast to barebox-tools).

And some of these tools might also be useful without using barebox.

I guess u-boot-tools is separate for similar reasons.

Regards, Enrico

Quoted 108 lines

Alex

Quoted 103 lines · Enrico Jörns via lists.openembedded.org

From: Marco Felsch <[email protected]>

Add initial support to build the barebox tools for the host and the target.

---
 meta/conf/distro/include/maintainers.inc      |  1 + .../barebox/barebox-tools_2024.08.0.bb        | 58 +++++++++++++++++++

 2 files changed, 59 insertions(+)

 create mode 100644 meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb

meta/conf/distro/include/maintainers.inc +0 -0
index 1b3d485e48..067c4af096 100644
@@ -55,6 +55,7 @@ RECIPE_MAINTAINER:pn-avahi = "Yi Zhao <[email protected]>"

 RECIPE_MAINTAINER:pn-babeltrace = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-babeltrace2 = "Alexander Kanavin <[email protected]>" RECIPE_MAINTAINER:pn-barebox = "Enrico Jörns <[email protected]>" +RECIPE_MAINTAINER:pn-barebox-tools = "Enrico Jörns <[email protected]>" RECIPE_MAINTAINER:pn-baremetal-helloworld = "Alejandro Hernandez <[email protected]>" RECIPE_MAINTAINER:pn-base-files = "Anuj Mittal <[email protected]>" RECIPE_MAINTAINER:pn-base-passwd = "Anuj Mittal <[email protected]>"

meta/recipes- renamed from meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb +0 -0

bsp/barebox/barebox-tools_2024.08.0.bb
new file mode 100644
index 0000000000..25f4998d4a

meta/recipes-bsp/barebox/barebox-tools_2024.08.0.bb new file +58 -1
@@ -0,0 +1,58 @@
+SUMMARY = "barebox bootloader tools"
+HOMEPAGE = "https://barebox.org/"
+
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
+
+DEPENDS = "libusb1 bison-native flex-native"
+
+SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
+SRC_URI[sha256sum] = "b08a762da8d63dd18b4f2d9f5d0a8da001b6e608d1b3eff6dcebc6a2e575d535"
+
+S = "${WORKDIR}/barebox-${PV}"
+B = "${WORKDIR}/build"
+
+inherit pkgconfig
+
+EXTRA_OEMAKE = " \
+  ARCH=sandbox \
+  CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
+  CROSS_PKG_CONFIG=pkg-config \
+  CC='${CC}' \
+  LD='${LD}' \
+  "
+
+do_compile:class-target () {
+    export userccflags="${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+    export userldflags="${TARGET_LDFLAGS}${TOOLCHAIN_OPTIONS}"
+    oe_runmake targettools_defconfig
+    oe_runmake scripts
+}
+
+do_compile:class-native () {
+    oe_runmake hosttools_defconfig
+    oe_runmake scripts
+}
+
+BAREBOX_TOOLS = " \
+         bareboxenv \
+         bareboxcrc32 \
+         kernel-install \
+         bareboximd \
+         omap3-usb-loader \
+         omap4_usbboot \
+         imx/imx-usb-loader \
+         "
+
+BAREBOX_TOOLS_SUFFIX = ""
+BAREBOX_TOOLS_SUFFIX:class-target = "-target"
+
+do_install () {
+       install -d ${D}${bindir}
+
+       for tool in ${BAREBOX_TOOLS}; do
+               install -m 0755 scripts/${tool}${BAREBOX_TOOLS_SUFFIX} ${D}${bindir}/${tool##*/}
+       done
+}
+
+BBCLASSEXTEND = "native nativesdk"
--

2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#204337): https://lists.openembedded.org/g/openembedded-core/message/204337
Mute This Topic: https://lists.openembedded.org/mt/108370664/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 4 lines
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    |
#7 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Quoted 8 lines · Enrico Jörns
Quoted 1 line

Can this be merged into the main barebox recipe? Does it need a separate recipe?

not only that it would complicate the main recipe (we had tried this before), but I really see no point in doing and supporting barebox native builds (in contrast to barebox-tools).

And some of these tools might also be useful without using barebox.

I guess u-boot-tools is separate for similar reasons.

Then you should put the common bits into barebox-common.inc, same as u-boot does. Also there should be a good DESCRIPTION in there. Why barebox, and not u-boot, for example?

Alex

#8 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Am Dienstag, dem 10.09.2024 um 10:49 +0200 schrieb Alexander Kanavin:

Quoted 7 lines · Enrico Jörns
Quoted 6 lines
Quoted 1 line

Can this be merged into the main barebox recipe? Does it need a separate recipe?

not only that it would complicate the main recipe (we had tried this before), but I really see no
point in doing and supporting barebox native builds (in contrast to barebox-tools).

Quoted 6 lines
Quoted 3 lines

And some of these tools might also be useful without using barebox.

I guess u-boot-tools is separate for similar reasons.

Then you should put the common bits into barebox-common.inc, same as u-boot does.

My impression was that the actual amount of things to share would not justify another file. It is mainly license information, SRC_URI and a bit of metadata where I found it more obvious to have them in the respective recipe.

If having shared parts in a barebox-common.inc is actually preferable, I could rework this of course.

Quoted 2 lines

Also there should be a good DESCRIPTION in there. Why barebox, and not u-boot, for example?

Trying to outdo other projects was not my intention. So I would like to omit such comparisons from the description.

My current summary:

"barebox is a bootloader designed for embedded systems.
It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."

does not yet get the point of a bootloader?
I also thought that adding too much information would make the summary too long. But in case something important is missing, I am open to further suggestions.

Thanks in advance an best regards

Enrico

Quoted 2 lines

Alex

Signature · 4 lines
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    |
#9 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Quoted 6 lines · Enrico Jörns

My impression was that the actual amount of things to share would not justify another file. It is mainly license information, SRC_URI and a bit of metadata where I found it more obvious to have them in the respective recipe.

If having shared parts in a barebox-common.inc is actually preferable, I could rework this of course.

It is yes. They are the same between recipes, and so should be specified once.

Quoted 6 lines
Quoted 2 lines

Also there should be a good DESCRIPTION in there. Why barebox, and not u-boot, for example?

Trying to outdo other projects was not my intention. So I would like to omit such comparisons from the description.

Quoted 8 lines

My current summary:

"barebox is a bootloader designed for embedded systems.
It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."

does not yet get the point of a bootloader?
I also thought that adding too much information would make the summary too long. But in case something important is missing, I am open to further suggestions.

There's a SUMMARY (which is ok), but there's no DESCRIPTION, and they are two different texts. We do require a DESCRIPTION that contains a paragraph or two, with multiple sentences that properly introduce the project. You don't have to directly compare to u-boot, but you do need to highlight the best features and advantages of the component. Being terse or generic in DESCRIPTION is not a good thing, and no DESCRIPTION at all is even worse.

Alex

#10 lore raw

Re: [OE-core] [PATCH v4 2/7] barebox-tools: add initial barebox tools support

Am Dienstag, dem 10.09.2024 um 11:22 +0200 schrieb Alexander Kanavin:

Quoted 5 lines · Enrico Jörns
Quoted 4 lines

My impression was that the actual amount of things to share would not justify another file. It is mainly license information, SRC_URI and a bit of metadata where I found it more obvious to have them in the respective recipe.

Quoted 10 lines
Quoted 2 lines

If having shared parts in a barebox-common.inc is actually preferable, I could rework this of course.

It is yes. They are the same between recipes, and so should be specified once.

Quoted 5 lines
Quoted 2 lines

Also there should be a good DESCRIPTION in there. Why barebox, and not u-boot, for example?

Trying to outdo other projects was not my intention. So I would like to omit such comparisons from the description.

ok, will do.

Quoted 9 lines
Quoted 8 lines

My current summary:

  "barebox is a bootloader designed for embedded systems.
  It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."

does not yet get the point of a bootloader?
I also thought that adding too much information would make the summary too long. But in case something important is missing, I am open to further suggestions.

Quoted 7 lines

There's a SUMMARY (which is ok), but there's no DESCRIPTION, and they are two different texts. We do require a DESCRIPTION that contains a paragraph or two, with multiple sentences that properly introduce the project. You don't have to directly compare to u-boot, but you do need to highlight the best features and advantages of the component. Being terse or generic in DESCRIPTION is not a good thing, and no DESCRIPTION at all is even worse.

Sorry, maybe I got confused since the SUMMARY I had is as long as other recipes DESCRIPTION. But you're right, it's not the same and the DESCRIPTION is missing.
My understanding so far was that SUMMARY is mandatory while DESCRIPTION isn't. However having one is better than not having one.

I'll attempt to provide a more comprehensive DESCRIPTION.

Regards, Enrico

Quoted 2 lines

Alex

Signature · 4 lines
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    |
#11 lore raw

PATCH v4 3/7 barebox: set default BAREBOX_CONFIG for qemu machines

In reply to Enrico Jörns

From: Enrico Jorns <[email protected]>

These are set in the barebox recipe rather in the corresponding machines (where they would belong otherwise) to keep the impact of barebox to oe-core minimal for now.

"multi_v7_defconfig" is used for qemuarm since this is the default barebox armv7 config that just enables all supported platforms.

"multi_v8_defconfig" is used for qemuarm64 sine this is the default barebox armv8 config that just enables all supported platforms.

"efi_defconfig" is used for qemux86-64 which is the primary platform where barebox will not be the first stage bootloader but an EFI payload.

Since these changes make barebox a provider for virtual/bootloader, explicitly default to u-boot in the corresponding MACHINE configs to not unnecessarily surprise users.

---
 meta/conf/machine/qemuarm.conf       | 1 +
 meta/conf/machine/qemuarm64.conf     | 1 +
 meta/conf/machine/qemux86-64.conf    | 1 +
 meta/recipes-bsp/barebox/barebox.inc | 5 +++++
 4 files changed, 8 insertions(+)
meta/conf/machine/qemuarm.conf +1 -0
index 943ce7c16a..af76a53b8e 100644
@@ -7,6 +7,7 @@ require conf/machine/include/qemu.inc
 
 KERNEL_IMAGETYPE = "zImage"
 
+PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
 UBOOT_MACHINE ?= "qemu_arm_defconfig"
 
 SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;hvc0"
meta/conf/machine/qemuarm64.conf +1 -0
index a096d964db..d310445a34 100644
@@ -7,6 +7,7 @@ require conf/machine/include/qemu.inc
 
 KERNEL_IMAGETYPE = "Image"
 
+PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
 UBOOT_MACHINE ?= "qemu_arm64_defconfig"
 
 SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;hvc0"
meta/conf/machine/qemux86-64.conf +1 -0
index 14873a3b4f..4a9c6d364b 100644
@@ -13,6 +13,7 @@ DEFAULTTUNE ?= "core2-64"
 require conf/machine/include/x86/tune-x86-64-v3.inc
 require conf/machine/include/x86/qemuboot-x86.inc
 
+PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
 UBOOT_MACHINE ?= "qemu-x86_64_defconfig"
 
 KERNEL_IMAGETYPE = "bzImage"
meta/recipes-bsp/barebox/barebox.inc +5 -0
index 4883f4cb32..42a1d86b34 100644
@@ -57,6 +57,11 @@ EXTRA_OEMAKE = " \
 BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig is added to the SRC_URI."
 BAREBOX_CONFIG ?= ""
 
+# set sensible default configs for some of oe-core's QEMU MACHINEs
+BAREBOX_CONFIG:qemuarm = "multi_v7_defconfig"
+BAREBOX_CONFIG:qemuarm64 = "multi_v8_defconfig"
+BAREBOX_CONFIG:qemux86-64 = "efi_defconfig"
+
 # prevent from acting as non-buildable provider
 python () {
     bareboxconfig = d.getVar('BAREBOX_CONFIG')
Signature · 1 line
2.39.2
#12 lore raw

PATCH v4 4/7 oeqa/utils/qemurunner: support ignoring vt100 escape sequences

In reply to Enrico Jörns

From: Enrico Jorns <[email protected]>

If we talk to terminals that like colors, we need to ignore the vt100 escape sequences when matching strings.

An unprocessed barebox console prompt would e.g. look like:

ESC[1;32mbarebox@ESC[1;36mARM QEMU virt64:/ESC[0m

where we cannot match for something like "barebox@ARM QEMU virt64:/". The same applies to colored Linux terminal output of course.

The "\x1b\[" from the regex catches the standard start of ANSI escape sequence while the rest catches the actual command code executed.

---
 meta/lib/oeqa/utils/qemurunner.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +3 -1
index cda43aad8c..63fc6f6b53 100644
@@ -30,6 +30,8 @@ control_range = list(range(0,32))+list(range(127,160))
 control_chars = [chr(x) for x in control_range
                 if chr(x) not in string.printable]
 re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
+# Regex to remove the ANSI (color) control codes from console strings in order to match the text only
+re_vt100 = re.compile(r'(\x1b\[|\x9b)[^@-_a-z]*[@-_a-z]|\x1b[@-_a-z]')
 
 def getOutput(o):
     import fcntl
@@ -681,7 +683,7 @@ class QemuRunner:
                     time.sleep(0.1)
                     answer = self.server_socket.recv(1024)
                     if answer:
-                        data += answer.decode('utf-8')
+                        data += re_vt100.sub("", answer.decode('utf-8'))
                         # Search the prompt to stop
                         if re.search(self.boot_patterns['search_cmd_finished'], data):
                             break
Signature · 1 line
2.39.2
#13 lore raw

PATCH v4 5/7 oeqa: support passing custom boot patterns to runqemu

In reply to Enrico Jörns

From: Enrico Jorns <[email protected]>

This allows defining non-standard patterns from QEMU tests just as they are already supported by the testimage.bbclass.

Will allow testing non-Linux shells in QEMU, too (e.g. a U-Boot shell or another bootloader shell).

---
 meta/lib/oeqa/targetcontrol.py    | 5 +++--
 meta/lib/oeqa/utils/commands.py   | 5 +++--
 meta/lib/oeqa/utils/qemurunner.py | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)
meta/lib/oeqa/targetcontrol.py +3 -2
index 6e8b781973..cdf382ee21 100644
@@ -88,7 +88,7 @@ class QemuTarget(BaseTarget):
 
     supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
 
-    def __init__(self, d, logger, image_fstype=None):
+    def __init__(self, d, logger, image_fstype=None, boot_patterns=None):
 
         import oe.types
 
@@ -141,7 +141,8 @@ class QemuTarget(BaseTarget):
                             dump_dir = dump_dir,
                             logger = logger,
                             tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"),
-                            serial_ports = len(d.getVar("SERIAL_CONSOLES").split()))
+                            serial_ports = len(d.getVar("SERIAL_CONSOLES").split()),
+                            boot_patterns = boot_patterns)
 
         self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner)
         if (self.monitor_dumper):
meta/lib/oeqa/utils/commands.py +3 -2
index bf2f49d0c0..ca22d69f29 100644
@@ -312,7 +312,7 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
         f.write('LAYERSERIES_COMPAT_%s = "%s"\n' % (templayername, corenames))
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, discard_writes=True):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, boot_patterns = {}, discard_writes=True):
     """
     Starts a context manager for a 'oeqa.targetcontrol.QemuTarget' resource.
     The underlying Qemu will be booted into a shell when the generator yields
@@ -330,6 +330,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
         image_fstype (str): IMAGE_FSTYPE to use
         launch_cmd (str): directly run this command and bypass automatic runqemu parameter generation
         overrides (dict): dict of "'<bitbake-variable>': value" pairs that allows overriding bitbake variables
+        boot_patterns (dict): dict of "'<pattern-name>': value" pairs to override default boot patterns, e.g. when not booting Linux
         discard_writes (boolean): enables qemu -snapshot feature to prevent modifying original image
     """
 
@@ -361,7 +362,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
 
         logdir = recipedata.getVar("TEST_LOG_DIR")
 
-        qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype)
+        qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, image_fstype, boot_patterns=boot_patterns)
     finally:
         # We need to shut down tinfoil early here in case we actually want
         # to run tinfoil-using utilities with the running QEMU instance.
meta/lib/oeqa/utils/qemurunner.py +1 -1
index 63fc6f6b53..5c3a8e5999 100644
@@ -103,7 +103,7 @@ class QemuRunner:
 
         # Only override patterns that were set e.g. login user TESTIMAGE_BOOT_PATTERNS[send_login_user] = "webserver\n"
         for pattern in accepted_patterns:
-            if not self.boot_patterns[pattern]:
+            if pattern not in self.boot_patterns or not self.boot_patterns[pattern]:
                 self.boot_patterns[pattern] = default_boot_patterns[pattern]
 
     def create_socket(self):
Signature · 1 line
2.39.2
#14 lore raw

PATCH v4 6/7 oeqa/selftest/cases: add basic u-boot test

In reply to Enrico Jörns

From: Enrico Jorns <[email protected]>

This adds basic tests for qemuarm and qemuarm64.

---
 meta/lib/oeqa/selftest/cases/uboot.py | 42 +++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/uboot.py
meta/lib/oeqa/selftest/cases/uboot.py new file +42 -0
new file mode 100644
index 0000000000..936dfa655f
@@ -0,0 +1,42 @@
+# Qemu-based u-boot bootloader integration testing
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runqemu
+from oeqa.core.decorator.data import skipIfNotArch
+from oeqa.core.decorator import OETestTag
+
+uboot_boot_patterns = {
+        'search_reached_prompt': "stop autoboot",
+        'search_login_succeeded': "=>",
+        'search_cmd_finished': "=>"
+        }
+
+
+class UBootTest(OESelftestTestCase):
+
+    @skipIfNotArch(['arm', 'aarch64'])
+    @OETestTag("runqemu")
+    def test_boot_uboot(self):
+        """
+        Tests building u-boot and booting it with QEMU
+        """
+
+        self.write_config("""
+QB_DEFAULT_BIOS = "u-boot.bin"
+PREFERRED_PROVIDER_virtual/bootloader = "u-boot"
+""")
+        bitbake("virtual/bootloader core-image-minimal")
+
+        with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic',
+                     boot_patterns=uboot_boot_patterns) as qemu:
+
+            # test if u-boot console works
+            cmd = "version"
+            status, output = qemu.run_serial(cmd)
+            self.assertEqual(status, 1, msg=output)
+            self.assertTrue("U-Boot" in output, msg=output)
Signature · 1 line
2.39.2
#15 lore raw

PATCH v4 7/7 oeqa/selftest/cases: add basic barebox tests

In reply to Enrico Jörns

From: Enrico Jorns <[email protected]>

This adds basic tests for qemuarm and qemuarm64.

---
 meta/lib/oeqa/selftest/cases/barebox.py | 43 +++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/barebox.py
meta/lib/oeqa/selftest/cases/barebox.py new file +43 -0
new file mode 100644
index 0000000000..773cf6a1c8
@@ -0,0 +1,43 @@
+# Qemu-based barebox bootloader integration testing
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runqemu
+from oeqa.core.decorator.data import skipIfNotArch
+from oeqa.core.decorator import OETestTag
+
+barebox_boot_patterns = {
+        'search_reached_prompt': r"stop autoboot",
+        'search_login_succeeded': r"barebox@[^:]+:[^ ]+ ",
+        'search_cmd_finished': r"barebox@[a-zA-Z0-9\-\s]+:/"
+        }
+
+
+class BareboxTest(OESelftestTestCase):
+
+    @skipIfNotArch(['arm', 'aarch64'])
+    @OETestTag("runqemu")
+    def test_boot_barebox(self):
+        """
+        Tests building barebox and booting it with QEMU
+        """
+
+        self.write_config("""
+QB_DEFAULT_KERNEL = "barebox-dt-2nd.img"
+PREFERRED_PROVIDER_virtual/bootloader = "barebox"
+""")
+
+        bitbake("virtual/bootloader core-image-minimal")
+
+        with runqemu('core-image-minimal', ssh=False, runqemuparams='nographic',
+                     boot_patterns=barebox_boot_patterns) as qemu:
+
+            # test if barebox console works
+            cmd = "version"
+            status, output = qemu.run_serial(cmd)
+            self.assertEqual(status, 1, msg=output)
+            self.assertTrue("barebox" in output, msg=output)
Signature · 1 line
2.39.2