boot/uboot/uboot.mk: add stripped u-boot.elf support
PATCH v2 1/1 boot/uboot/uboot.mk: add stripped u-boot.elf support
If a user requests a u-boot binary in elf format, they may actually want the stripped u-boot.elf version. This patch provides the stripped u-boot.elf binary.
---V1->V2:
- reduced scope to only 64-bit ARM arch platforms
- non-ARM platforms may not have a u-boot.elf by default
--- boot/uboot/uboot.mk | 3 +++ 1 file changed, 3 insertions(+)
boot/uboot/uboot.mk +3 -0
@@ -54,6 +54,9 @@ endif ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y) UBOOT_BINS += u-boot +ifeq ($(BR2_aarch64),y) +UBOOT_BINS += u-boot.elf +endif # To make elf usable for debuging on ARC use special target ifeq ($(BR2_arc),y) UBOOT_MAKE_TARGET += mdbtrick
Signature · 6 lines
2.17.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Neal,
Quoted 18 lines · On Mon, 21 Nov 2022 22:36:11 -0700 Neal Frager <[email protected]> wrote:
If a user requests a u-boot binary in elf format, they may actually want the stripped u-boot.elf version. This patch provides the stripped u-boot.elf binary.
Signed-off-by Neal Frager <[email protected]>---
V1->V2:
- reduced scope to only 64-bit ARM arch platforms
- non-ARM platforms may not have a u-boot.elf by default--- boot/uboot/uboot.mk | 3 +++ 1 file changed, 3 insertions(+)boot/uboot/uboot.mk +0
-0
boot/uboot/uboot.mk endif · line 59
Quoted 6 lines
boot/uboot/uboot.mk +3
-0@@ -54,6 +54,9 @@ endif ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y) UBOOT_BINS += u-boot +ifeq ($(BR2_aarch64),y) +UBOOT_BINS += u-boot.elf +endif
Is it really assured that all arm64 do build this file? And that u-boot.elf is not useful for other architectures?
Looking at the U-Boot source code, it looks like this file is built if CONFIG_REMAKE_ELF is enabled, which seems independent on the architecture and happens for some non-arm64 defconfigs as well (e.g. netgear_dgnd3700v2_ram_defconfig).
At first glance, it looks like we need (yet) another Kconfig knob in Buildroot to manage this cleanly. Otherwise in UBOOT_INSTALL_IMAGES_CMDS we might just install u-boot.elf if it is present,skip it silently otherwise.
Not sure which solution is less appealing. :(
Signature · 7 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Luca,
Quoted 27 lines
If a user requests a u-boot binary in elf format, they may actually want the stripped u-boot.elf version.
This patch provides the stripped u-boot.elf binary.Signed-off-by Neal Frager <[email protected]>---
V1->V2:
- reduced scope to only 64-bit ARM arch platforms
- non-ARM platforms may not have a u-boot.elf by default--- boot/uboot/uboot.mk | 3 +++ 1 file changed, 3 insertions(+)boot/uboot/uboot.mk index renamed from boot/uboot/uboot.mk +0
-0
0439ec5e4b..61b3074163100644boot/uboot/uboot.mk +3
-0@@ -54,6 +54,9 @@ endif ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y) UBOOT_BINS += u-boot +ifeq ($(BR2_aarch64),y) +UBOOT_BINS += u-boot.elf +endifIs it really assured that all arm64 do build this file? And that u-boot.elf is not useful for other architectures?
Quoted 6 lines
Looking at the U-Boot source code, it looks like this file is built if
CONFIG_REMAKE_ELFis enabled, which seems independent on the architecture and happens for some non-arm64 defconfigs as well (e.g.netgear_dgnd3700v2_ram_defconfig).At first glance, it looks like we need (yet) another
Kconfigknob in Buildroot to manage this cleanly. Otherwise inUBOOT_INSTALL_IMAGES_CMDSwe might just install u-boot.elf if it is present,skip it silently otherwise.Not sure which solution is less appealing. :(
Perhaps just checking every file for existence when running the loop below is the best option like below. The idea is to keep this as simple as possible. What do you think?
define UBOOT_INSTALL_IMAGES_CMDS
$(foreach f,$(UBOOT_BINS), \ $(if test -f $(@D)/$(f), \ cp -dpf $(@D)/$(f) $(BINARIES_DIR))/ )
Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Neal,
Quoted 7 lines · Neal via buildroot
Perhaps just checking every file for existence when running the loop below is the best option like below. The idea is to keep this as simple as possible. What do you think?
define
UBOOT_INSTALL_IMAGES_CMDS$(foreach f,$(UBOOT_BINS), \ $(if test -f $(@D)/$(f), \ cp -dpf $(@D)/$(f) $(BINARIES_DIR))/ )
I think we should change:
config BR2_TARGET_UBOOT_FORMAT_ELF
bool "u-boot.elf"
to:
config BR2_TARGET_UBOOT_FORMAT_ELF
bool "u-boot"
(because this is really what it is doing)
and then introduce:
config BR2_TARGET_UBOOT_FORMAT_ELF_STRIPPED
bool "u-boot.elf"
which installs the stripped u-boot.elf file.
This way, BR2_TARGET_UBOOT_FORMAT_ELF_STRIPPED can be enabled on configurations that need it, without breaking configurations that provide u-boot but not u-boot.elf.
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Thomas,
Quoted 18 lines · On Tue, 22 Nov 2022 17:13:15 +0100 Thomas Petazzoni…
Hello Neal,
Quoted 7 lines · Neal via buildroot
Perhaps just checking every file for existence when running the loop below is the best option like below. The idea is to keep this as simple as possible. What do you think?
define
UBOOT_INSTALL_IMAGES_CMDS$(foreach f,$(UBOOT_BINS), \ $(if test -f $(@D)/$(f), \ cp -dpf $(@D)/$(f) $(BINARIES_DIR))/ )I think we should change:
config
BR2_TARGET_UBOOT_FORMAT_ELF
bool "u-boot.elf"
Quoted 6 lines
to:
config
BR2_TARGET_UBOOT_FORMAT_ELF
bool "u-boot"(because this is really what it is doing)
Right.
Quoted 11 lines
and then introduce:
config
BR2_TARGET_UBOOT_FORMAT_ELF_STRIPPED
bool "u-boot.elf"which installs the stripped u-boot.elf file.
This way,
BR2_TARGET_UBOOT_FORMAT_ELF_STRIPPEDcan be enabled on configurations that need it, without breaking configurations that provide u-boot but not u-boot.elf.
I agree with the principle you are proposing.
However, according to the U-Boot source code, u-boot.elf appears as u-boot.bin repackaged into an ELF file. Is "stripped" a correct word for this?
Signature · 7 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 5 lines · On Tue, 22 Nov 2022 19:07:43 +0100 Luca Ceresoli <[email protected]>…
I agree with the principle you are proposing.
However, according to the U-Boot source code, u-boot.elf appears as u-boot.bin repackaged into an ELF file. Is "stripped" a correct word for this?
I used "stripped" because that's how Neal described this file.
Based on what you say, perhaps a better option name is:
BR2_TARGET_UBOOT_FORMAT_BIN_ELF
bool "u-boot.elf"
Thoughts?
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas, Neal,
Quoted 9 lines · On Tue, 22 Nov 2022 21:47:13 +0100 Thomas Petazzoni…
Quoted 5 lines · On Tue, 22 Nov 2022 19:07:43 +0100 Luca Ceresoli <[email protected]>…
I agree with the principle you are proposing.
However, according to the U-Boot source code, u-boot.elf appears as u-boot.bin repackaged into an ELF file. Is "stripped" a correct word for this?
Quoted 8 lines
I used "stripped" because that's how Neal described this file.
Based on what you say, perhaps a better option name is:
BR2_TARGET_UBOOT_FORMAT_BIN_ELF
bool "u-boot.elf"Thoughts?
Seems better.
Neal, adding a short help text would also be useful IMO, as this "bin elf" Frankenstein creation is really non intuitive.
Signature · 7 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas, Luca,
Quoted 13 lines
Quoted 5 lines · On Tue, 22 Nov 2022 19:07:43 +0100 Luca Ceresoli <[email protected]>…
I agree with the principle you are proposing.
However, according to the U-Boot source code, u-boot.elf appears as u-boot.bin repackaged into an ELF file. Is "stripped" a correct word for this?
I used "stripped" because that's how Neal described this file.
Based on what you say, perhaps a better option name is:
Quoted 8 lines
BR2_TARGET_UBOOT_FORMAT_BIN_ELF
bool "u-boot.elf"Thoughts?
Seems better.
Neal, adding a short help text would also be useful IMO, as this "bin elf" Frankenstein creation is really non intuitive.
I am not sure creating a separate BR2 config is the right solution. Both the u-boot and u-boot.elf file are in fact elf formatted files. One just has all the debug symbols and one does not.
If we create a separate BR2 config, even with help text, I am not sure this would be so clean. I was actually surprised when I used the BR2_TARGET_UBOOT_FORMAT_ELF config and did not get a u-boot.elf file. I imagine many others are surprised too.
What do you think of this solution? Basically, we check that the file exists before copying. It is probably good to have this check anyway.
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
If you want, we could even add an else statement that prints a warning message about the expected u-boot file not being copied, so a user is warned about it at build time.
Thoughts?
Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Neal,
Quoted 3 lines · Neal
I am not sure creating a separate BR2 config is the right solution. Both the u-boot and u-boot.elf file are in fact elf formatted files. One just has all the debug symbols and one does not.
I don't understand why you think having a separate option is a problem. We already have separate options for each file that can be installed by U-Boot. Adding another option for another file is completely logical, and actually much more logical than having a weird option that magically installs 2 files - sometimes.
Quoted 3 lines
What do you think of this solution? Basically, we check that the file exists before copying. It is probably good to have this check anyway.
Checks like this are actually not great, because you expect something to happen, there is no error, but the thing you were expecting did not happen. Clearly confusing for the user.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas,
Quoted 6 lines
I am not sure creating a separate BR2 config is the right solution. Both the u-boot and u-boot.elf file are in fact elf formatted files. One just has all the debug symbols and one does not.
I don't understand why you think having a separate option is a problem.
We already have separate options for each file that can be installed by U-Boot. Adding another option for another file is completely logical, and actually much more logical than having a weird option that magically installs 2 files - sometimes.
If adding another BR2 config for this is ok for you, it is ok for me. I was just thinking it was strange to have two different commands for elf files.
To go along with Luca's point, I will add some helper text in the Config.in file, so it can help clarify which command is which for users.
Quoted 4 lines
What do you think of this solution? Basically, we check that the file exists before copying. It is probably good to have this check anyway.
Checks like this are actually not great, because you expect something to happen, there is no error, but the thing you were expecting did not happen. Clearly confusing for the user.
Ok, no problem. I will remove this for v4.
Thank you for your help and thoughtful review!
Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot