Skip to contentSkip to conversation

boot/barebox: add renaming functionality to barebox image copy

PATCH New Steinhilber 3 participants 6 messages Feb 19, 2019 – Feb 25, 2019

lore
Share & tools
lore

Steinhilber

#0 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Hello Thomas,

Quoted 5 lines
Quoted 3 lines

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.

Quoted 3 lines
Quoted 2 lines

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

#1 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Hello Markus,

Quoted 11 lines · Markus
Quoted 5 lines
Quoted 3 lines

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.

OK. It kind of works "by luck", because if you had been using U-Boot as a bootloader, we don't support building two different U-Boot configurations, and you would have had to use two separate Buildroot configurations.

Quoted 12 lines

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.

Quoted 2 lines
Quoted 2 lines

Also, you need to rename the images in a post-build script if you need certain file names.

Quoted 7 lines
Quoted 4 lines

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.

Then perhaps the more Buildroot-ish way of doing things would be to install the images build by the barebox package in a different location than the one installed by the barebox-aux package, like $(BINARIES_DIR)/barebox/ and $(BINARIES_DIR)/barebox-aux/. The downsides of this are:

- We don't do this for other packages

- It breaks backward compatibility.

Arnout, Peter, what do you think ? (See Markus original patch for the start of the discussion)

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Quoted 4 lines · Thomas Petazzoni

Hello Markus,

On Tue, 19 Feb 2019 11:03:52 +0000
"Steinhilber, Markus" <[email protected]> wrote:

[snip]

Quoted 16 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

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.

Then perhaps the more Buildroot-ish way of doing things would be to install the images build by the barebox package in a different location than the one installed by the barebox-aux package, like $(BINARIES_DIR)/barebox/ and $(BINARIES_DIR)/barebox-aux/. The downsides of this are:

Quoted 6 lines

- We don't do this for other packages

- It breaks backward compatibility.

Arnout, Peter, what do you think ? (See Markus original patch for the start of the discussion)

I feel that the original patch is way too complicated for such a corner case.

Indeed, this use case happens to (almost) work by chance because barebox and
barebox-aux are two different packages rather than one like for U-Boot. But if you anyway have the luck of having such an option, I don't mind adding a little bit extra to be able to make better use of it.

Perhaps a possibility is to add a config option that prefixes the output name
with something? You'd still need to rename it in the post-build script (or, more likely, handle that in the genimage.cfg file). But it does solve the identical-name problem, it looks pretty simple, and it doesn't break anything.

Regards,
Arnout

#3 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Hello,

Quoted 9 lines · On Fri, 22 Feb 2019 09:53:18 +0100 Arnout Vandecappelle <[email protected]> wrote:

Indeed, this use case happens to (almost) work by chance because barebox and
barebox-aux are two different packages rather than one like for U-Boot. But if you anyway have the luck of having such an option, I don't mind adding a little bit extra to be able to make better use of it.

Perhaps a possibility is to add a config option that prefixes the output name
with something? You'd still need to rename it in the post-build script (or, more likely, handle that in the genimage.cfg file). But it does solve the identical-name problem, it looks pretty simple, and it doesn't break anything.

Good idea! It is simple (just one string option), and it preserves backward compatibility (the default value of the option would be empty).

Markus, could you look at implementing this instead ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Hi,

Quoted 12 lines

-----Original Message-----
From: Thomas Petazzoni [mailto:thomas.petazzoni at bootlin.com] Hello,

Quoted 5 lines · On Fri, 22 Feb 2019 09:53:18 +0100 Arnout Vandecappelle <[email protected]> wrote:

Indeed, this use case happens to (almost) work by chance because
barebox and barebox-aux are two different packages rather than one like for U-Boot. But if you anyway have the luck of having such an option, I don't mind adding a little bit extra to be able to make better use of it.

Quoted 7 lines
Quoted 4 lines

Perhaps a possibility is to add a config option that prefixes the
output name with something? You'd still need to rename it in the
post-build script (or, more likely, handle that in the genimage.cfg
file). But it does solve the identical-name problem, it looks pretty simple, and it doesn't break anything.

Good idea! It is simple (just one string option), and it preserves backward compatibility (the default value of the option would be empty).

I have to say that I don't see a benefit in the proposed behavior over my patch. My patch adds also a single string option (ok, it can be a string list to be fair) and also doesn't break backward compatibility. Additionally it can be used as a rename option. With a default value of empty it behaves exactly as without the patch.

I also don't see it as too complex. It practically the original if-structure with an added if for each case to check if the value is set and use it or do the 'backward compatibility' way.

Quoted 1 line

Markus, could you look at implementing this instead ?

I think I could, but not right now as I'm busy with some other things.

Regards,
Markus
________________________________

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

#5 lore raw

PATCH 1/1 boot/barebox: add renaming functionality to barebox image copy

Hello Markus,

Quoted 10 lines · Markus
Quoted 3 lines

Good idea! It is simple (just one string option), and it preserves backward compatibility (the default value of the option would be empty).

I have to say that I don't see a benefit in the proposed behavior over my patch. My patch adds also a single string option (ok, it can be a string list to be fair) and also doesn't break backward compatibility. Additionally it can be used as a rename option. With a default value of empty it behaves exactly as without the patch.

Quoted 3 lines

I also don't see it as too complex. It practically the original if-structure with an added if for each case to check if the value is set and use it or do the 'backward compatibility' way.

It's purely a matter of "design principle", i.e how Buildroot normally does/implements/designs things. We try to be consistent and have the same basic design principles applied across Buildroot, so that the way package A does things is similar to how package B does things.

And nowhere in Buildroot we have this idea of two string options, where the Nth entry of the first list "maps" to the Nth entry of the second list. While it works, it's a bit of an awkward/strange semantic for Config.in string options, hence our preference for a single option that allows to specify a prefix or path where the Barebox binaries should be installed.

So, there is nothing wrong per-se with your initial approach: it functionally works. It is just that we (Arnout, me, as long-time Buildroot developers/contributors) find that it doesn't fit very well in the usual BR design principles, and there is a simple alternate solution that works *and* fits better with the usual BR design principles. It's as simple as that :-)

Hopefully this clarifies our suggestion on your contribution.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com