All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/2] uboot: add support for generating U-Boot boot scripts
Date: Wed, 21 Jun 2017 23:41:42 +0200	[thread overview]
Message-ID: <20170621214143.7184-1-thomas.petazzoni@free-electrons.com> (raw)

More and more of our defconfigs need to generate a U-Boot boot
script. It's a simple call to mkimage, but we already have 12
instances of this logic in board/, and there are patch series waiting
in patchwork adding 3 more boards that need this.

So let's add an option in the U-Boot package to generate such a boot
script image easily.

Note that we assume a single script needs to be generated, and the
output file name is boot.scr. The only platform for which it seems to
not be the case are the Boundary Devices platforms: they generate two
boot scripts, 6x_bootscript and 6x_upgrade, but they are anyway
installed inside TARGET_DIR, not BINARIES_DIR.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
We could have chosen to create a helper script that can be used as a
post-build or post-image script, ala
support/scripts/genimage.sh. However, I find rather messy how we are
passing arguments to such scripts: we have a single
BR2_ROOTFS_POST_SCRIPT_ARGS, passed to all scripts. Proposals such as
https://patchwork.ozlabs.org/patch/777463/ with:

  BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/bananapi/bananapi-m64/genimage.cfg board/bananapi/bananapi-m64/boot.cmd"

where support/scripts/genimage.sh parses the first two arguments, and
the post-build script generating the U-Boot boot script parses the
last argument, look really really ugly to me.

Retrospectively, I believe the choice of adding such a helper script
for genimage was wrong. Having a proper option would be much
cleaner/nicer IMO.
---
 boot/uboot/Config.in | 16 ++++++++++++++++
 boot/uboot/uboot.mk  | 13 +++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/boot/uboot/Config.in b/boot/uboot/Config.in
index 547822d..52f3a32 100644
--- a/boot/uboot/Config.in
+++ b/boot/uboot/Config.in
@@ -407,6 +407,22 @@ config BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT
 
 endif # BR2_TARGET_UBOOT_ENVIMAGE
 
+config BR2_TARGET_UBOOT_BOOT_SCRIPT
+	bool "Generate a U-Boot boot script"
+	help
+	  Generate a U-Boot boot script, given a file listing U-Boot
+	  commands to be executed at boot time. The generated boot
+	  script will be called 'boot.scr'.
+
+if BR2_TARGET_UBOOT_BOOT_SCRIPT
+
+config BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE
+	string "U-Boot boot script source"
+	help
+	  Source file to generate the U-Boot boot script.
+
+endif
+
 if BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG
 
 config BR2_TARGET_UBOOT_CUSTOM_DTS_PATH
diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index 904d45a..0f423a8 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -235,6 +235,10 @@ define UBOOT_INSTALL_IMAGES_CMDS
 			$(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
 			$(if $(filter BIG,$(BR2_ENDIAN)),-b) \
 			-o $(BINARIES_DIR)/uboot-env.bin -)
+	$(if $(BR2_TARGET_UBOOT_BOOT_SCRIPT),
+		$(HOST_DIR)/usr/bin/mkimage -C none -A $(MKIMAGE_ARCH) -T script \
+			-d $(call qstrip,$(BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE)) \
+			$(BINARIES_DIR)/boot.scr)
 endef
 
 define UBOOT_INSTALL_OMAP_IFT_IMAGE
@@ -298,6 +302,15 @@ endif
 UBOOT_DEPENDENCIES += host-uboot-tools
 endif
 
+ifeq ($(BR2_TARGET_UBOOT_BOOT_SCRIPT),y)
+ifeq ($(BR_BUILDING),y)
+ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE)),)
+$(error Please define a source file for Uboot boot script (BR2_TARGET_UBOOT_BOOT_SCRIPT_SOURCE setting))
+endif
+endif
+UBOOT_DEPENDENCIES += host-uboot-tools
+endif
+
 ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
 
 #
-- 
2.9.4

             reply	other threads:[~2017-06-21 21:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 21:41 Thomas Petazzoni [this message]
2017-06-21 21:41 ` [Buildroot] [PATCH 2/2] configs/cubieboard2_defconfig: use U-Boot boot script generation logic Thomas Petazzoni
2017-06-22 11:06   ` Peter Korsgaard
2017-06-22 11:06 ` [Buildroot] [PATCH 1/2] uboot: add support for generating U-Boot boot scripts Peter Korsgaard
2017-06-22 11:31   ` Thomas Petazzoni
2017-06-22 14:18     ` Peter Korsgaard
2017-06-22 14:44       ` Thomas Petazzoni
2017-06-22 16:00         ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170621214143.7184-1-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.