Support building a 2nd Barebox config
v5 cover Support building a 2nd Barebox config
This patch-set adds support for building barebox with up to 2 configurations. It can be used to build the barebox x-loader or MLO (also called Secondary Program Loader) in addition to the standard barebox build (Tertiary Program Loader). This implements the design proposed in
http://elinux.org/Buildroot#Todo_list, with minor adjustments:
1. Have boot/barebox/barebox.mk contain the common stuff.
2. Add a second package boot/barebox/barebox-2.
3. There is only one version selection, but each package allows to define the configuration to be used.
4. Design is a little bit like package/gcc, where we have multiple gcc builds, but share a lot of common definitions between the packages.
To demonstrate that it works as advertized, the last patch adds a defconfig for the beaglebone that makes use of the added functionality.
Revision history:
v5: Review rework based on feedback from Arnout Vandecappelle, Yegor Yefremov
and Thomas Petazzoni:
- Dropped support to rename output/images (same can be achieved with genimage)
- Simplified barebox INSTALL_IMAGE_CMDS
- Simplified KConfig option naming
- Appends test defconfig to last commit message
Improvements to the BBB barebox test config:
- Latest kernel and headers
- Tunes barebox.env to boot from eMMC/SD
- Use genimage to generate a full sdcard.img
v4: Introduces barebox-package function to reduce duplication and maintenance
Simplifies built image selection
Ease review with smaller patches
Review re-work: Special thanks to Arnout Vandecappelle and Yegor Yefremov
v3: Updated for master at 544e2c5871f223facd1ab3c2853cd07ad70dd9d1
v2: Dropped x-loader build specialization in favor of 2 generic barebox builds
v1: Initial posting
Pieter Smith (5):
barebox: support multi-image-build image selection
barebox: introduce barebox-package function
barebox: extract package name argument
barebox: support 2nd config build
beaglebone: adds barebox bootloader defconfig
board/beaglebone/barebox/barebox.env/boot/sd | 11 ++ board/beaglebone/barebox/barebox.env/config-board | 4 + board/beaglebone/barebox/genimage.cfg | 32 ++++ board/beaglebone/barebox/post-image.sh | 17 +++ boot/barebox/Config.in | 12 ++ boot/barebox/barebox-2/Config.in | 72 +++++++++ boot/barebox/barebox-2/barebox-2.hash | 1 + boot/barebox/barebox-2/barebox-2.mk | 9 ++ boot/barebox/barebox.mk | 169 +++++++++++++--------- configs/beaglebone_barebox_defconfig | 43 ++++++ 10 files changed, 300 insertions(+), 70 deletions(-) create mode 100644 board/beaglebone/barebox/barebox.env/boot/sd create mode 100644 board/beaglebone/barebox/barebox.env/config-board create mode 100644 board/beaglebone/barebox/genimage.cfg create mode 100755 board/beaglebone/barebox/post-image.sh create mode 100644 boot/barebox/barebox-2/Config.in create mode 120000 boot/barebox/barebox-2/barebox-2.hash create mode 100644 boot/barebox/barebox-2/barebox-2.mk create mode 100644 configs/beaglebone_barebox_defconfig
Signature · 1 line
2.5.0
PATCH v5 1/5 barebox: support multi-image-build image selection
Support optional selection of the built image filename in a multi-image barebox build. This makes it possible to specify which image to pick in a multi-image barebox config such as the am335x_defconfig.
--- boot/barebox/Config.in | 10 ++++++++++ boot/barebox/barebox.mk | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-)
boot/barebox/Config.in +10 -0
@@ -97,6 +97,16 @@ config BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES A space-separated list of configuration fragment files, that will be merged to the main Barebox configuration file. +config BR2_TARGET_BAREBOX_IMAGE_FILE + string "Barebox image filename" + default "" + help + Name of the built barebox image filename + + If left empty, defaults to: + - barebox.bin for barebox versions older than 2012.10. + - barebox-flash-image for later versions. + config BR2_TARGET_BAREBOX_BAREBOXENV bool "bareboxenv tool in target" help
boot/barebox/barebox.mk +5 -1
@@ -91,8 +91,12 @@ define BAREBOX_BUILD_CMDS $(BAREBOX_BUILD_CUSTOM_ENV) endef +BAREBOX_IMAGE_FILE = $(call qstrip,$(BR2_TARGET_BAREBOX_IMAGE_FILE)) + define BAREBOX_INSTALL_IMAGES_CMDS - if test -h $(@D)/barebox-flash-image ; then \ + if test -n "$(BAREBOX_IMAGE_FILE)"; then \ + cp -L $(@D)/$(BAREBOX_IMAGE_FILE) $(BINARIES_DIR) ; \ + elif test -h $(@D)/barebox-flash-image ; then \ cp -L $(@D)/barebox-flash-image $(BINARIES_DIR)/barebox.bin ; \ else \ cp $(@D)/barebox.bin $(BINARIES_DIR);\
Signature · 1 line
2.5.0
PATCH v5 2/5 barebox: introduce barebox-package function
In reply to Pieter SmithNo functional changes: Introduces a barebox-package function towards re-use by a 2nd config build.
Because the function is meant to be called from within a $(eval), all instances of '$' has to be escaped. I.e. rename '$' -> '$$'.
--- boot/barebox/barebox.mk | 125 ++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 53 deletions(-)
boot/barebox/barebox.mk +72 -53
@@ -4,23 +4,31 @@ # ################################################################################ -BAREBOX_VERSION = $(call qstrip,$(BR2_TARGET_BAREBOX_VERSION)) +################################################################################ +# inner-barebox-package -- generates the KConfig logic and make targets needed +# to support a barebox package. All barebox packages are built from the same +# source (origin, version and patches). +################################################################################ + +define inner-barebox-package -ifeq ($(BAREBOX_VERSION),custom) +BAREBOX_VERSION = $$(call qstrip,$$(BR2_TARGET_BAREBOX_VERSION)) + +ifeq ($$(BAREBOX_VERSION),custom) # Handle custom Barebox tarballs as specified by the configuration -BAREBOX_TARBALL = $(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION)) -BAREBOX_SITE = $(patsubst %/,%,$(dir $(BAREBOX_TARBALL))) -BAREBOX_SOURCE = $(notdir $(BAREBOX_TARBALL)) -BR_NO_CHECK_HASH_FOR += $(BAREBOX_SOURCE) -else ifeq ($(BR2_TARGET_BAREBOX_CUSTOM_GIT),y) -BAREBOX_SITE = $(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL)) +BAREBOX_TARBALL = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION)) +BAREBOX_SITE = $$(patsubst %/,%,$$(dir $$(BAREBOX_TARBALL))) +BAREBOX_SOURCE = $$(notdir $$(BAREBOX_TARBALL)) +BR_NO_CHECK_HASH_FOR += $$(BAREBOX_SOURCE) +else ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_GIT),y) +BAREBOX_SITE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL)) BAREBOX_SITE_METHOD = git else # Handle stable official Barebox versions -BAREBOX_SOURCE = barebox-$(BAREBOX_VERSION).tar.bz2 +BAREBOX_SOURCE = barebox-$$(BAREBOX_VERSION).tar.bz2 BAREBOX_SITE = http://www.barebox.org/download -ifeq ($(BR2_TARGET_BAREBOX_CUSTOM_VERSION),y) -BR_NO_CHECK_HASH_FOR += $(BAREBOX_SOURCE) +ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_VERSION),y) +BR_NO_CHECK_HASH_FOR += $$(BAREBOX_SOURCE) endif endif
@@ -28,97 +36,108 @@ BAREBOX_DEPENDENCIES = host-lzop BAREBOX_LICENSE = GPLv2 with exceptions BAREBOX_LICENSE_FILES = COPYING -ifneq ($(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),) +ifneq ($$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),) define BAREBOX_APPLY_CUSTOM_PATCHES - $(APPLY_PATCHES) $(@D) \ - $(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \*.patch + $$(APPLY_PATCHES) $$(@D) \ + $$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \*.patch endef BAREBOX_POST_PATCH_HOOKS += BAREBOX_APPLY_CUSTOM_PATCHES endif BAREBOX_INSTALL_IMAGES = YES -ifneq ($(BR2_TARGET_BAREBOX_BAREBOXENV),y) +ifneq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) BAREBOX_INSTALL_TARGET = NO endif -ifeq ($(KERNEL_ARCH),i386) +ifeq ($$(KERNEL_ARCH),i386) BAREBOX_ARCH = x86 -else ifeq ($(KERNEL_ARCH),x86_64) +else ifeq ($$(KERNEL_ARCH),x86_64) BAREBOX_ARCH = x86 -else ifeq ($(KERNEL_ARCH),powerpc) +else ifeq ($$(KERNEL_ARCH),powerpc) BAREBOX_ARCH = ppc else -BAREBOX_ARCH = $(KERNEL_ARCH) +BAREBOX_ARCH = $$(KERNEL_ARCH) endif -BAREBOX_MAKE_FLAGS = ARCH=$(BAREBOX_ARCH) CROSS_COMPILE="$(TARGET_CROSS)" -BAREBOX_MAKE_ENV = $(TARGET_MAKE_ENV) +BAREBOX_MAKE_FLAGS = ARCH=$$(BAREBOX_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)" +BAREBOX_MAKE_ENV = $$(TARGET_MAKE_ENV) -ifeq ($(BR2_TARGET_BAREBOX_USE_DEFCONFIG),y) -BAREBOX_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))_defconfig -else ifeq ($(BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG),y) -BAREBOX_KCONFIG_FILE = $(call qstrip,$(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)) +ifeq ($$(BR2_TARGET_BAREBOX_USE_DEFCONFIG),y) +BAREBOX_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))_defconfig +else ifeq ($$(BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG),y) +BAREBOX_KCONFIG_FILE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)) endif -BAREBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES)) +BAREBOX_KCONFIG_FRAGMENT_FILES = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES)) BAREBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig -BAREBOX_KCONFIG_OPTS = $(BAREBOX_MAKE_FLAGS) +BAREBOX_KCONFIG_OPTS = $$(BAREBOX_MAKE_FLAGS) -ifeq ($(BR2_TARGET_BAREBOX_BAREBOXENV),y) +ifeq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) define BAREBOX_BUILD_BAREBOXENV_CMDS - $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) -o $(@D)/bareboxenv \ - $(@D)/scripts/bareboxenv.c + $$(TARGET_CC) $$(TARGET_CFLAGS) $$(TARGET_LDFLAGS) -o $$(@D)/bareboxenv \ + $$(@D)/scripts/bareboxenv.c endef endif -ifeq ($(BR2_TARGET_BAREBOX_CUSTOM_ENV),y) -BAREBOX_ENV_NAME = $(notdir $(call qstrip,\ - $(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH))) +ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_ENV),y) +BAREBOX_ENV_NAME = $$(notdir $$(call qstrip,\ + $$(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH))) define BAREBOX_BUILD_CUSTOM_ENV - $(@D)/scripts/bareboxenv -s \ - $(call qstrip, $(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH)) \ - $(@D)/$(BAREBOX_ENV_NAME) + $$(@D)/scripts/bareboxenv -s \ + $$(call qstrip, $$(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH)) \ + $$(@D)/$$(BAREBOX_ENV_NAME) endef define BAREBOX_INSTALL_CUSTOM_ENV - cp $(@D)/$(BAREBOX_ENV_NAME) $(BINARIES_DIR) + cp $$(@D)/$$(BAREBOX_ENV_NAME) $$(BINARIES_DIR) endef endif define BAREBOX_BUILD_CMDS - $(BAREBOX_BUILD_BAREBOXENV_CMDS) - $(TARGET_MAKE_ENV) $(MAKE) $(BAREBOX_MAKE_FLAGS) -C $(@D) - $(BAREBOX_BUILD_CUSTOM_ENV) + $$(BAREBOX_BUILD_BAREBOXENV_CMDS) + $$(TARGET_MAKE_ENV) $$(MAKE) $$(BAREBOX_MAKE_FLAGS) -C $$(@D) + $$(BAREBOX_BUILD_CUSTOM_ENV) endef -BAREBOX_IMAGE_FILE = $(call qstrip,$(BR2_TARGET_BAREBOX_IMAGE_FILE)) +BAREBOX_IMAGE_FILE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_IMAGE_FILE)) define BAREBOX_INSTALL_IMAGES_CMDS - if test -n "$(BAREBOX_IMAGE_FILE)"; then \ - cp -L $(@D)/$(BAREBOX_IMAGE_FILE) $(BINARIES_DIR) ; \ - elif test -h $(@D)/barebox-flash-image ; then \ - cp -L $(@D)/barebox-flash-image $(BINARIES_DIR)/barebox.bin ; \ + if test -n "$$(BAREBOX_IMAGE_FILE)"; then \ + cp -L $$(@D)/$$(BAREBOX_IMAGE_FILE) $$(BINARIES_DIR) ; \ + elif test -h $$(@D)/barebox-flash-image ; then \ + cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \ else \ - cp $(@D)/barebox.bin $(BINARIES_DIR);\ + cp $$(@D)/barebox.bin $$(BINARIES_DIR);\ fi - $(BAREBOX_INSTALL_CUSTOM_ENV) + $$(BAREBOX_INSTALL_CUSTOM_ENV) endef -ifeq ($(BR2_TARGET_BAREBOX_BAREBOXENV),y) +ifeq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) define BAREBOX_INSTALL_TARGET_CMDS - cp $(@D)/bareboxenv $(TARGET_DIR)/usr/bin + cp $$(@D)/bareboxenv $$(TARGET_DIR)/usr/bin endef endif # Checks to give errors that the user can understand # Must be before we call to kconfig-package -ifeq ($(BR2_TARGET_BAREBOX)$(BR_BUILDING),yy) +ifeq ($$(BR2_TARGET_BAREBOX)$$(BR_BUILDING),yy) # We must use the user-supplied kconfig value, because # BAREBOX_KCONFIG_DEFCONFIG will at least contain the # trailing _defconfig -ifeq ($(or $(BAREBOX_KCONFIG_FILE),$(call qstrip,$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))),) -$(error No Barebox config. Check your BR2_TARGET_BAREBOX_BOARD_DEFCONFIG or BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE settings) +ifeq ($$(or $$(BAREBOX_KCONFIG_FILE),$$(call qstrip,$$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))),) +$$(error No Barebox config. Check your BR2_TARGET_BAREBOX_BOARD_DEFCONFIG or BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE settings) endif endif -$(eval $(kconfig-package)) +$$(eval $$(kconfig-package)) + +endef + +################################################################################ +# barebox-package -- the target generator macro for barebox packages +################################################################################ + +barebox-package=$(call inner-barebox-package) + +# instantiate this barebox package +$(eval $(barebox-package))
Signature · 1 line
2.5.0
PATCH v5 3/5 barebox: extract package name argument
In reply to Pieter SmithNo functional changes: Extracts an argument to the inner-barebox-package function to automatically determine the uppercase package name. This is needed to support a 2nd config build. This results in the following renaming:
'BAREBOX' -> '$(1)'
All barebox packages are meant to be built from the same sources, so related KConfig variables (origin, version and patch directory) are not extracted.
--- boot/barebox/barebox.mk | 121 +++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 59 deletions(-)
boot/barebox/barebox.mk +62 -59
@@ -7,125 +7,128 @@ ################################################################################ # inner-barebox-package -- generates the KConfig logic and make targets needed # to support a barebox package. All barebox packages are built from the same -# source (origin, version and patches). +# source (origin, version and patches). The remainder of the package +# configuration is unique to each barebox package. +# +# argument 1 is the uppercase package name (used for variable name-space) ################################################################################ define inner-barebox-package -BAREBOX_VERSION = $$(call qstrip,$$(BR2_TARGET_BAREBOX_VERSION)) +$(1)_VERSION = $$(call qstrip,$$(BR2_TARGET_BAREBOX_VERSION)) -ifeq ($$(BAREBOX_VERSION),custom) +ifeq ($$($(1)_VERSION),custom) # Handle custom Barebox tarballs as specified by the configuration -BAREBOX_TARBALL = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION)) -BAREBOX_SITE = $$(patsubst %/,%,$$(dir $$(BAREBOX_TARBALL))) -BAREBOX_SOURCE = $$(notdir $$(BAREBOX_TARBALL)) -BR_NO_CHECK_HASH_FOR += $$(BAREBOX_SOURCE) +$(1)_TARBALL = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION)) +$(1)_SITE = $$(patsubst %/,%,$$(dir $$($(1)_TARBALL))) +$(1)_SOURCE = $$(notdir $$($(1)_TARBALL)) +BR_NO_CHECK_HASH_FOR += $$($(1)_SOURCE) else ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_GIT),y) -BAREBOX_SITE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL)) -BAREBOX_SITE_METHOD = git +$(1)_SITE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL)) +$(1)_SITE_METHOD = git else # Handle stable official Barebox versions -BAREBOX_SOURCE = barebox-$$(BAREBOX_VERSION).tar.bz2 -BAREBOX_SITE = http://www.barebox.org/download +$(1)_SOURCE = barebox-$$($(1)_VERSION).tar.bz2 +$(1)_SITE = http://www.barebox.org/download ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_VERSION),y) -BR_NO_CHECK_HASH_FOR += $$(BAREBOX_SOURCE) +BR_NO_CHECK_HASH_FOR += $$($(1)_SOURCE) endif endif -BAREBOX_DEPENDENCIES = host-lzop -BAREBOX_LICENSE = GPLv2 with exceptions -BAREBOX_LICENSE_FILES = COPYING +$(1)_DEPENDENCIES = host-lzop +$(1)_LICENSE = GPLv2 with exceptions +$(1)_LICENSE_FILES = COPYING ifneq ($$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),) -define BAREBOX_APPLY_CUSTOM_PATCHES +define $(1)_APPLY_CUSTOM_PATCHES $$(APPLY_PATCHES) $$(@D) \ $$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \*.patch endef -BAREBOX_POST_PATCH_HOOKS += BAREBOX_APPLY_CUSTOM_PATCHES +$(1)_POST_PATCH_HOOKS += $(1)_APPLY_CUSTOM_PATCHES endif -BAREBOX_INSTALL_IMAGES = YES -ifneq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) -BAREBOX_INSTALL_TARGET = NO +$(1)_INSTALL_IMAGES = YES +ifneq ($$(BR2_TARGET_$(1)_BAREBOXENV),y) +$(1)_INSTALL_TARGET = NO endif ifeq ($$(KERNEL_ARCH),i386) -BAREBOX_ARCH = x86 +$(1)_ARCH = x86 else ifeq ($$(KERNEL_ARCH),x86_64) -BAREBOX_ARCH = x86 +$(1)_ARCH = x86 else ifeq ($$(KERNEL_ARCH),powerpc) -BAREBOX_ARCH = ppc +$(1)_ARCH = ppc else -BAREBOX_ARCH = $$(KERNEL_ARCH) +$(1)_ARCH = $$(KERNEL_ARCH) endif -BAREBOX_MAKE_FLAGS = ARCH=$$(BAREBOX_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)" -BAREBOX_MAKE_ENV = $$(TARGET_MAKE_ENV) +$(1)_MAKE_FLAGS = ARCH=$$($(1)_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)" +$(1)_MAKE_ENV = $$(TARGET_MAKE_ENV) -ifeq ($$(BR2_TARGET_BAREBOX_USE_DEFCONFIG),y) -BAREBOX_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))_defconfig -else ifeq ($$(BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG),y) -BAREBOX_KCONFIG_FILE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)) +ifeq ($$(BR2_TARGET_$(1)_USE_DEFCONFIG),y) +$(1)_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))_defconfig +else ifeq ($$(BR2_TARGET_$(1)_USE_CUSTOM_CONFIG),y) +$(1)_KCONFIG_FILE = $$(call qstrip,$$(BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE)) endif -BAREBOX_KCONFIG_FRAGMENT_FILES = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CONFIG_FRAGMENT_FILES)) -BAREBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig -BAREBOX_KCONFIG_OPTS = $$(BAREBOX_MAKE_FLAGS) +$(1)_KCONFIG_FRAGMENT_FILES = $$(call qstrip,$$(BR2_TARGET_$(1)_CONFIG_FRAGMENT_FILES)) +$(1)_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig +$(1)_KCONFIG_OPTS = $$($(1)_MAKE_FLAGS) -ifeq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) -define BAREBOX_BUILD_BAREBOXENV_CMDS +ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y) +define $(1)_BUILD_BAREBOXENV_CMDS $$(TARGET_CC) $$(TARGET_CFLAGS) $$(TARGET_LDFLAGS) -o $$(@D)/bareboxenv \ $$(@D)/scripts/bareboxenv.c endef endif -ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_ENV),y) -BAREBOX_ENV_NAME = $$(notdir $$(call qstrip,\ - $$(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH))) -define BAREBOX_BUILD_CUSTOM_ENV +ifeq ($$(BR2_TARGET_$(1)_CUSTOM_ENV),y) +$(1)_ENV_NAME = $$(notdir $$(call qstrip,\ + $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH))) +define $(1)_BUILD_CUSTOM_ENV $$(@D)/scripts/bareboxenv -s \ - $$(call qstrip, $$(BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH)) \ - $$(@D)/$$(BAREBOX_ENV_NAME) + $$(call qstrip, $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH)) \ + $$(@D)/$$($(1)_ENV_NAME) endef -define BAREBOX_INSTALL_CUSTOM_ENV - cp $$(@D)/$$(BAREBOX_ENV_NAME) $$(BINARIES_DIR) +define $(1)_INSTALL_CUSTOM_ENV + cp $$(@D)/$$($(1)_ENV_NAME) $$(BINARIES_DIR) endef endif -define BAREBOX_BUILD_CMDS - $$(BAREBOX_BUILD_BAREBOXENV_CMDS) - $$(TARGET_MAKE_ENV) $$(MAKE) $$(BAREBOX_MAKE_FLAGS) -C $$(@D) - $$(BAREBOX_BUILD_CUSTOM_ENV) +define $(1)_BUILD_CMDS + $$($(1)_BUILD_BAREBOXENV_CMDS) + $$(TARGET_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D) + $$($(1)_BUILD_CUSTOM_ENV) endef -BAREBOX_IMAGE_FILE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_IMAGE_FILE)) +$(1)_IMAGE_FILE = $$(call qstrip,$$(BR2_TARGET_$(1)_IMAGE_FILE)) -define BAREBOX_INSTALL_IMAGES_CMDS - if test -n "$$(BAREBOX_IMAGE_FILE)"; then \ - cp -L $$(@D)/$$(BAREBOX_IMAGE_FILE) $$(BINARIES_DIR) ; \ +define $(1)_INSTALL_IMAGES_CMDS + if test -n "$$($(1)_IMAGE_FILE)"; then \ + cp -L $$(@D)/$$($(1)_IMAGE_FILE) $$(BINARIES_DIR) ; \ elif test -h $$(@D)/barebox-flash-image ; then \ cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \ else \ cp $$(@D)/barebox.bin $$(BINARIES_DIR);\ fi - $$(BAREBOX_INSTALL_CUSTOM_ENV) + $$($(1)_INSTALL_CUSTOM_ENV) endef -ifeq ($$(BR2_TARGET_BAREBOX_BAREBOXENV),y) -define BAREBOX_INSTALL_TARGET_CMDS +ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y) +define $(1)_INSTALL_TARGET_CMDS cp $$(@D)/bareboxenv $$(TARGET_DIR)/usr/bin endef endif # Checks to give errors that the user can understand # Must be before we call to kconfig-package -ifeq ($$(BR2_TARGET_BAREBOX)$$(BR_BUILDING),yy) +ifeq ($$(BR2_TARGET_$(1))$$(BR_BUILDING),yy) # We must use the user-supplied kconfig value, because -# BAREBOX_KCONFIG_DEFCONFIG will at least contain the +# $(1)_KCONFIG_DEFCONFIG will at least contain the # trailing _defconfig -ifeq ($$(or $$(BAREBOX_KCONFIG_FILE),$$(call qstrip,$$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))),) -$$(error No Barebox config. Check your BR2_TARGET_BAREBOX_BOARD_DEFCONFIG or BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE settings) +ifeq ($$(or $$($(1)_KCONFIG_FILE),$$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))),) +$$(error No Barebox config. Check your BR2_TARGET_$(1)_BOARD_DEFCONFIG or BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE settings) endif endif
@@ -137,7 +140,7 @@ endef # barebox-package -- the target generator macro for barebox packages ################################################################################ -barebox-package=$(call inner-barebox-package) +barebox-package=$(call inner-barebox-package,$(call UPPERCASE,$(pkgname))) # instantiate this barebox package $(eval $(barebox-package))
Signature · 1 line
2.5.0
PATCH v5 4/5 barebox: support 2nd config build
In reply to Pieter SmithAdds support to build barebox with a 2nd config.
This is useful for building an SPL (Secondary Program Loader) in addition to the traditional TPL (Tertiary Program Loader). The Beaglebone Black for example has two barebox configurations:
- am335x_defconfig builds the full barebox bootloader with device tree, and
- am335x_mlo_defconfig builds the smaller MLO bootloader that loads the full barebox bootloader from the eMMC or SD card.
Tested with the following defconfig:
# architecture BR2_arm=y BR2_cortex_a8=y BR2_ARM_EABIHF=y
# system BR2_TARGET_GENERIC_HOSTNAME="beaglebone" BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_DEVTMPFS=y BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW=y
# filesystem BR2_PACKAGE_AM33X_CM3=y BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y
# bootloader BR2_TARGET_BAREBOX=y BR2_TARGET_BAREBOX_BOARD_DEFCONFIG="am335x" BR2_TARGET_BAREBOX_IMAGE_FILE="images/barebox-am33xx-beaglebone.img" BR2_TARGET_BAREBOX_CUSTOM_ENV=y BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH="board/beaglebone/barebox/barebox.env" BR2_TARGET_BAREBOX_2=y BR2_TARGET_BAREBOX_2_BOARD_DEFCONFIG="am335x_mlo" BR2_TARGET_BAREBOX_2_IMAGE_FILE="images/barebox-am33xx-beaglebone-mlo.img"
# kernel BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_USE_DEFCONFIG=y BR2_LINUX_KERNEL_DEFCONFIG="omap2plus" BR2_LINUX_KERNEL_ZIMAGE=y
# use the barebox built-in dtb # BR2_LINUX_KERNEL_DTS_SUPPORT is not set
--- boot/barebox/Config.in | 2 + boot/barebox/barebox-2/Config.in | 72 +++++++++++++++++++++++++++++++++++ boot/barebox/barebox-2/barebox-2.hash | 1 + boot/barebox/barebox-2/barebox-2.mk | 9 +++++ boot/barebox/barebox.mk | 3 ++ 5 files changed, 87 insertions(+) create mode 100644 boot/barebox/barebox-2/Config.in create mode 120000 boot/barebox/barebox-2/barebox-2.hash create mode 100644 boot/barebox/barebox-2/barebox-2.mk
boot/barebox/Config.in +2 -0
@@ -131,4 +131,6 @@ config BR2_TARGET_BAREBOX_CUSTOM_ENV_PATH barebox devfs format, stored in the images directory, with the same name as the directory name given here. +source boot/barebox/barebox-2/Config.in + endif
boot/barebox/barebox-2/Config.in new file +72 -0
72 lines not on this page · raw message
boot/barebox/barebox-2/barebox-2.hash new file +1 -0
@@ -0,0 +1 @@ +../barebox.hash
boot/barebox/barebox-2/barebox-2.mk new file +9 -0
@@ -0,0 +1,9 @@ +################################################################################ +# +# barebox-2 +# +################################################################################ + +# Instantiate a 2nd barebox package, built from the same sources as the 1st, +# but with it's own configuration: +$(eval $(barebox-package))
boot/barebox/barebox.mk +3 -0
@@ -144,3 +144,6 @@ barebox-package=$(call inner-barebox-package,$(call UPPERCASE,$(pkgname))) # instantiate this barebox package $(eval $(barebox-package)) + +# add the 2nd barebox package build +include boot/barebox/barebox-2/barebox-2.mk
Signature · 1 line
2.5.0
PATCH v5 5/5 beaglebone: adds barebox bootloader defconfig
In reply to Pieter Smith* Builds the barebox MLO and bootloader.
* Generates a bootable SD card image with boot and rootfs partitions.
* Barebox integrates a perfectly good device-tree for the bbb, so no dtb is being generated with the kernel.
--- board/beaglebone/barebox/barebox.env/boot/sd | 11 ++++++ board/beaglebone/barebox/barebox.env/config-board | 4 +++ board/beaglebone/barebox/genimage.cfg | 32 +++++++++++++++++ board/beaglebone/barebox/post-image.sh | 17 +++++++++ configs/beaglebone_barebox_defconfig | 43 +++++++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 board/beaglebone/barebox/barebox.env/boot/sd create mode 100644 board/beaglebone/barebox/barebox.env/config-board create mode 100644 board/beaglebone/barebox/genimage.cfg create mode 100755 board/beaglebone/barebox/post-image.sh create mode 100644 configs/beaglebone_barebox_defconfig
board/beaglebone/barebox/barebox.env/boot/sd new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/sh + +global.bootm.image=/boot/zImage + +# Default to using the barebox built-in dtb +# global.bootm.oftree=/boot/oftree + +# No initrd +# global.bootm.initrd=<path to initrd> + +global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
board/beaglebone/barebox/barebox.env/config-board new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/sh + +global.boot.default=sd +
board/beaglebone/barebox/genimage.cfg new file +32 -0
@@ -0,0 +1,32 @@ +image boot.vfat { + vfat { + file MLO { + image = "barebox-am33xx-beaglebone-mlo.img" + } + file barebox.bin { + image = "barebox-am33xx-beaglebone.img" + } + files = { + "barebox.env", + "zImage" + } + } + size = 32M +} + +image sdcard.img { + hdimage { + } + + partition boot { + partition-type = 0xC + in-partition-table = "yes" + bootable = "true" + image = "boot.vfat" + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext4" + } +}
board/beaglebone/barebox/post-image.sh new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/sh + +BOARD_DIR="$(dirname $0)" +GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg" +GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" + +rm -rf "${GENIMAGE_TMP}" + +genimage \ + --rootpath "${TARGET_DIR}" \ + --tmppath "${GENIMAGE_TMP}" \ + --inputpath "${BINARIES_DIR}" \ + --outputpath "${BINARIES_DIR}" \ + --config "${GENIMAGE_CFG}" + +exit $? +
configs/beaglebone_barebox_defconfig new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.5.0
Thomas Petazzoni
AppliedPATCH v5 1/5 barebox: support multi-image-build image selection
In reply to Pieter SmithHello,
Quoted 9 lines · Pieter Smith
Support optional selection of the built image filename in a multi-image barebox build. This makes it possible to specify which image to pick in a multi-image barebox config such as the
am335x_defconfig.Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/Config.in | 10 ++++++++++ boot/barebox/barebox.mk | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-)
Applied to master, after doing a few minor changes:
[Thomas:
- remove default "", since this is the default for string options
- rename the prompt from "Barebox image filename" to "Image filename"
- slightly improve the Config.in help text.]
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Thomas Petazzoni
AppliedPATCH v5 2/5 barebox: introduce barebox-package function
In reply to Pieter SmithHello,
Quoted 10 lines · Pieter Smith
No functional changes: Introduces a barebox-package function towards re-use by a 2nd config build.
Because the function is meant to be called from within a $(eval), all instances of '$' has to be escaped. I.e. rename '$' -> '$$'.
Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/barebox.mk | 125 ++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 53 deletions(-)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Thomas Petazzoni
AppliedPATCH v5 3/5 barebox: extract package name argument
In reply to Pieter SmithHello,
Quoted 5 lines · Pieter Smith
No functional changes: Extracts an argument to the inner-barebox-package function to automatically determine the uppercase package name. This is needed to support a 2nd config build. This results in the following renaming:
'BAREBOX' -> '$(1)'
Quoted 7 lines
All barebox packages are meant to be built from the same sources, so related KConfig variables (origin, version and patch directory) are not extracted.
Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/barebox.mk | 121 +++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 59 deletions(-)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v5 4/5 barebox: support 2nd config build
In reply to Pieter SmithHello,
Quoted 5 lines · Pieter Smith
boot/barebox/Config.in | 2 + boot/barebox/barebox-2/Config.in | 72 +++++++++++++++++++++++++++++++++++ boot/barebox/barebox-2/barebox-2.hash | 1 + boot/barebox/barebox-2/barebox-2.mk | 9 +++++ boot/barebox/barebox.mk | 3 ++
Regarding this one, I am not sure, there are two things that bother me a bit:
- The name "barebox-2", which I find a bit weird. What about "barebox-aux" or something like that, as opposed to "barebox-main" ?
- The organization of the folders. Having the barebox "infra" + the main barebox package both defined in boot/barebox/barebox.mk seems weird. Ideally, I would have preferred something like:
boot/barebox/barebox.mk <-- common infrastructure boot/barebox/barebox-main/ <-- the main Barebox boot/barebox/barebox-aux/ <-- the auxiliary Barebox
Of course, some tricks will be needed to make the barebox-main/ package behave properly when its options will still be named BR2_TARGET_BAREBOX_<foo> and not BR2_TARGET_BAREBOX_MAIN_<foo>. Alternatively, if that really doesn't work, what about:
boot/barebox/barebox.mk <-- common infrastructure boot/barebox/barebox/ <-- the main Barebox boot/barebox/barebox-aux/ <-- the auxiliary Barebox
I've applied the first three patches of the series to ease your work, but I'd like to see if we can get something a bit better for this patch. I know Arnout has done a lot of review, so don't hesitate to let me know if all this has already been discussed and why the current organization has been chosen compared to something more similar to my proposal.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v5 4/5 barebox: support 2nd config build
Hi Thomas,
Quoted 16 lines · Thomas Petazzoni
Hello,
Quoted 5 lines · Pieter Smith
boot/barebox/Config.in | 2 + boot/barebox/barebox-2/Config.in | 72 +++++++++++++++++++++++++++++++++++ boot/barebox/barebox-2/barebox-2.hash | 1 + boot/barebox/barebox-2/barebox-2.mk | 9 +++++ boot/barebox/barebox.mk | 3 ++Regarding this one, I am not sure, there are two things that bother me a bit:
- The name "barebox-2", which I find a bit weird. What about "barebox-aux" or something like that, as opposed to "barebox-main" ?
Quoted 7 lines
- The organization of the folders. Having the barebox "infra" + the main barebox package both defined in
boot/barebox/barebox.mkseems weird. Ideally, I would have preferred something like:
boot/barebox/barebox.mk<-- common infrastructure boot/barebox/barebox-main/ <-- the main Barebox boot/barebox/barebox-aux/ <-- the auxiliary Barebox
I had it set up this way, but changed it due to some of the review feedback that Arnout provided.
Quoted 8 lines
Of course, some tricks will be needed to make the barebox-main/ package behave properly when its options will still be named BR2_TARGET_BAREBOX_<foo> and not BR2_TARGET_BAREBOX_MAIN_<foo>. Alternatively, if that really doesn't work, what about:
boot/barebox/barebox.mk<-- common infrastructure boot/barebox/barebox/ <-- the main Barebox boot/barebox/barebox-aux/ <-- the auxiliary Barebox
This approach seems reasonable. I will set it up this way. I will also rename all BAREBOX_2 KConfig options to BAREBOX_AUX. Is this acceptable?
Quoted 6 lines
I've applied the first three patches of the series to ease your work, but I'd like to see if we can get something a bit better for this patch. I know Arnout has done a lot of review, so don't hesitate to let me know if all this has already been discussed and why the current organization has been chosen compared to something more similar to my proposal.
I don't think the organization was changed based on concrete arguments. Arnout just liked it more this way. I do however like your 2nd proposed organization more.
[snip]
- Pieter
PATCH v5 1/5 barebox: support multi-image-build image selection
In reply to Thomas PetazzoniHi Thomas,
Quoted 13 lines · Thomas Petazzoni
Hello,
Quoted 9 lines · Pieter Smith
Support optional selection of the built image filename in a multi-image barebox build. This makes it possible to specify which image to pick in a multi-image barebox config such as the
am335x_defconfig.Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/Config.in | 10 ++++++++++ boot/barebox/barebox.mk | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-)
Quoted 8 lines
Applied to master, after doing a few minor changes:
[Thomas:
- remove default "", since this is the default for string options
- rename the prompt from "Barebox image filename" to "Image filename"
- slightly improve the Config.in help text.]Thanks!
A pleasure!
[snip]
- Pieter
PATCH v5 2/5 barebox: introduce barebox-package function
In reply to Thomas PetazzoniHi Thomas,
Quoted 9 lines · Thomas Petazzoni
Hello,
Quoted 6 lines · Pieter Smith
No functional changes: Introduces a barebox-package function towards re-use by a 2nd config build.
Because the function is meant to be called from within a $(eval), all instances of '$' has to be escaped. I.e. rename '$' -> '$$'.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/barebox.mk | 125 ++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 53 deletions(-)Applied to master, thanks.
A pleasure!
[snip]
- Pieter
PATCH v5 3/5 barebox: extract package name argument
In reply to Thomas PetazzoniHi Thomas,
Quoted 11 lines · Thomas Petazzoni
Hello,
Quoted 8 lines · Pieter Smith
No functional changes: Extracts an argument to the inner-barebox-package function to automatically determine the uppercase package name. This is needed to support a 2nd config build. This results in the following renaming:
'BAREBOX' -> '$(1)'All barebox packages are meant to be built from the same sources, so related KConfig variables (origin, version and patch directory) are not extracted.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Pieter Smith <[email protected]>--- boot/barebox/barebox.mk | 121 +++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 59 deletions(-)Applied to master, thanks.
A pleasure!
[snip]
- Pieter