Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] boot/barebox: add renaming functionality to barebox image copy
@ 2019-02-18 13:59 Steinhilber, Markus
  2019-02-18 22:10 ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Steinhilber, Markus @ 2019-02-18 13:59 UTC (permalink / raw)
  To: buildroot

Until now barebox images are copied to the output/images directory with their default name. This is a problem if the barebox and barebox-aux images have the same name. Also, you need to rename the images in a post-build script if you need certain file names.

With this patch there is a new option in the barebox and barebox-aux config, which allows you to copy the image files with target names of your choice. See the help text of the option for a more detailed explanation.

Signed-off-by: Markus Steinhilber <markus.steinhilber@erbe-med.com>
---
 boot/barebox/barebox-aux/Config.in | 18 ++++++++++++++++++
 boot/barebox/barebox.mk            | 23 ++++++++++++++++++++---
 boot/barebox/barebox/Config.in     | 18 ++++++++++++++++++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/boot/barebox/barebox-aux/Config.in b/boot/barebox/barebox-aux/Config.in
index d39d24f763..11e595241a 100644
--- a/boot/barebox/barebox-aux/Config.in
+++ b/boot/barebox/barebox-aux/Config.in
@@ -39,6 +39,24 @@ config BR2_TARGET_BAREBOX_AUX_IMAGE_FILE
          - barebox.bin for barebox versions older than 2012.10.
          - barebox-flash-image for later versions.

+config BR2_TARGET_BAREBOX_AUX_IMAGE_FILE_TARGETS
+       string "Image file copy target names"
+       help
+         Space-separated list of target file names used when copying
+         the image files from BR2_TARGET_BAREBOX_IMAGE_FILE to the
+         images directory.
+
+         The target names are applied in their order in the list. So the
+         first file in BR2_TARGET_BAREBOX_IMAGE_FILE is named after the
+         first entry in this list and so on.
+
+         If left empty or the number of names is smaller than the number
+         of files in BR2_TARGET_BAREBOX_IMAGE_FILE the original file
+         name is kept.
+
+         If BR2_TARGET_BAREBOX_IMAGE_FILE is left empty, the default file
+         is named after the first entry in this list.
+
 config BR2_TARGET_BAREBOX_AUX_CUSTOM_ENV
        bool "Generate an environment image"
        help
diff --git a/boot/barebox/barebox.mk b/boot/barebox/barebox.mk index 9e8a9f67b5..2fb547c58d 100644
--- a/boot/barebox/barebox.mk
+++ b/boot/barebox/barebox.mk
@@ -110,14 +110,31 @@ define $(1)_BUILD_CMDS  endef

 $(1)_IMAGE_FILES = $$(call qstrip,$$(BR2_TARGET_$(1)_IMAGE_FILE))
+$(1)_IMAGE_FILES_TARGETS = $$(call
+qstrip,$$(BR2_TARGET_$(1)_IMAGE_FILE_TARGETS))

 define $(1)_INSTALL_IMAGES_CMDS
+       image_files_array=($$($(1)_IMAGE_FILES)); \
+       image_targets_array=($$($(1)_IMAGE_FILES_TARGETS)); \
        if test -n "$$($(1)_IMAGE_FILES)"; then \
-               cp -L $$(foreach image,$$($(1)_IMAGE_FILES),$$(@D)/$$(image)) $$(BINARIES_DIR) ; \
+               if test -n "$$($(1)_IMAGE_FILES_TARGETS)"; then \
+                       for index in $$$${!image_files_array[*]}; do \
+                               cp -L $$(@D)/$$$${image_files_array[$$$$index]} $$(BINARIES_DIR)/$$$${image_targets_array[$$$$index]}; \
+                       done; \
+               else \
+                       cp -L $$(foreach image,$$($(1)_IMAGE_FILES),$$(@D)/$$(image)) $$(BINARIES_DIR) ; \
+               fi \
        elif test -h $$(@D)/barebox-flash-image ; then \
-               cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \
+               if test -n "$$($(1)_IMAGE_FILES_TARGETS)"; then \
+                       cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/$$$${image_targets_array[0]} ; \
+               else \
+                       cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \
+               fi \
        else \
-               cp $$(@D)/barebox.bin $$(BINARIES_DIR);\
+               if test -n "$$($(1)_IMAGE_FILES_TARGETS)"; then \
+                       cp $$(@D)/barebox.bin $$(BINARIES_DIR)/$$$${image_targets_array[0]};\
+               else \
+                       cp $$(@D)/barebox.bin $$(BINARIES_DIR);\
+               fi \
        fi
        $$($(1)_INSTALL_CUSTOM_ENV)
 endef
diff --git a/boot/barebox/barebox/Config.in b/boot/barebox/barebox/Config.in index 958e294e40..0096695ea5 100644
--- a/boot/barebox/barebox/Config.in
+++ b/boot/barebox/barebox/Config.in
@@ -39,6 +39,24 @@ config BR2_TARGET_BAREBOX_IMAGE_FILE
          - barebox.bin for barebox versions older than 2012.10.
          - barebox-flash-image for later versions.

+config BR2_TARGET_BAREBOX_IMAGE_FILE_TARGETS
+       string "Image file copy target names"
+       help
+         Space-separated list of target file names used when copying
+         the image files from BR2_TARGET_BAREBOX_IMAGE_FILE to the
+         images directory.
+
+         The target names are applied in their order in the list. So the
+         first file in BR2_TARGET_BAREBOX_IMAGE_FILE is named after the
+         first entry in this list and so on.
+
+         If left empty or the number of names is smaller than the number
+         of files in BR2_TARGET_BAREBOX_IMAGE_FILE the original file
+         name is kept.
+
+         If BR2_TARGET_BAREBOX_IMAGE_FILE is left empty, the default file
+         is named after the first entry in this list.
+
 config BR2_TARGET_BAREBOX_BAREBOXENV
        bool "bareboxenv tool in target"
        help
--
2.11.0

________________________________

Erbe Elektromedizin GmbH Firmensitz: 72072 Tuebingen Geschaeftsfuehrer: Christian O. Erbe, Reiner Thede Registergericht: Stuttgart HRB 380137

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [Buildroot] [PATCH 1/1] boot/barebox: add renaming functionality to barebox image copy
@ 2019-02-19 11:03 Steinhilber, Markus
  2019-02-22  8:40 ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Steinhilber, Markus @ 2019-02-19 11:03 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

>> Until now barebox images are copied to the output/images directory
>> with their default name. This is a problem if the barebox and
>> barebox-aux images have the same name.
> Could you describe a specific case/situation where this would happen ?
> The main reason we have barebox vs. barebox-aux is because you sometimes need to build a full-blown Barebox, and a smaller Barebox that serves a first stage bootloader. From what I remember the generated images had different names, don't they ?

In our case it's happening, because we are building a barebox to be used with the device normally and use the barebox-aux to build a barebox which we use with the serial downloader mode of our board to do initial setup and programming. Those images have the same name and the second file overwrites the first without this patch. I understand that the usual case for barebox-aux may be to build a first stage bootloader, but I think it should not be limited to that case. The description of the barebox-aux package is " Build barebox with an auxiliary configuration" and for this, you can't be sure that the image files have different names. As soon as you are building 2 barebox images of the same type(SPL/TPL), but different config (which I think is quite useful) you will have this problem. I don't know if you may also have it in some cases when the type is different. Also, you can leave the setting empty and it will work just like before.

>> Also, you need to rename the images in a post-build script if you need
>> certain file names.
> That is a pretty normal thing in Buildroot. We just install things as they are installed by the upstream build system, and leave it up to custom post-build script to further rename/move/adjust to match the specific requirements of the project/user.

I understand. In this case I see it as some kind of nice-to-have function you can achieve. The main reason is the one above.

Thanks,
Markus
________________________________

Erbe Elektromedizin GmbH Firmensitz: 72072 Tuebingen Geschaeftsfuehrer: Christian O. Erbe, Reiner Thede Registergericht: Stuttgart HRB 380137

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-25 10:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-18 13:59 [Buildroot] [PATCH 1/1] boot/barebox: add renaming functionality to barebox image copy Steinhilber, Markus
2019-02-18 22:10 ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2019-02-19 11:03 Steinhilber, Markus
2019-02-22  8:40 ` Thomas Petazzoni
2019-02-22  8:53   ` Arnout Vandecappelle
2019-02-22 10:19     ` Thomas Petazzoni
2019-02-25 10:00       ` Steinhilber, Markus
2019-02-25 10:20         ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox