Re: [ptxdist] [PATCH v2 0/4] ptxd_make_world_inject: Spring cleanup and optional dest dir
Hello Alexander, On 5/6/24 12:50, Alexander Dahl wrote: > Hello, > > some spring cleaning and a new feature for the firmware inject > mechanism. > > When trying to re-build U-Boot as an oot build for the Karo QSBASE93 > Evalkit (for QS93 Solder-Down System-on-Module) it became apparent > U-Boot wants some of those binary blobs in build folder instead of > source folder. Supporting this usecase is nice to have, because you > won't clutter your source tree, especially when building from external > tree after something like `ptxdist local-src u-boot ~/src/u-boot` … > > Maybe we should add some documentation for this inject mechanism? > > Follow-up patches for u-boot package in preparation already, but let me > know what you think of this first. > > Greets > Alex > > v2: > - rework patch 4 introducing the new inject oot mechanism > (using the new _INJECT_OOT variable now instead of a needlessly > flexible approach in v1) > > v1: > https://lore.ptxdist.org/ptxdist/20240424143109.277373-1-...@thorsis.com/T/#t > - initial patch stack revision (implicit) > > Alexander Dahl (4): > ptxd_make_world_inject: Remove useless test > ptxd_make_world_inject: Use _DIR directly > ptxd_make_world_inject: Escape inject path and files > ptxd_make_world_inject: Introduce new variable _INJECT_OOT > > rules/post/ptxd_make_world_inject.make | 6 +++--- > scripts/lib/ptxd_make_world_inject.sh | 26 ++ > 2 files changed, 25 insertions(+), 7 deletions(-) > > > base-commit: 5a720c419cd1fabde04e8de8d1d1367c76a2666b nice, thanks for your patches! Again, I am not at all an expert here and only had a brief look over them, but they LGTM. FWIW: Acked-by: Michael Riesch Best regards, Michael
[ptxdist] [PATCH 2/3] u-boot: Allow other packages to inject dependencies
Same approach as in barebox packages. Signed-off-by: Alexander Dahl --- platforms/u-boot.in | 5 + 1 file changed, 5 insertions(+) diff --git a/platforms/u-boot.in b/platforms/u-boot.in index 53db146e1..9163a8378 100644 --- a/platforms/u-boot.in +++ b/platforms/u-boot.in @@ -1,6 +1,11 @@ ## SECTION=bootloader +config U_BOOT_DEPENDENCIES + tristate + select VIRTUAL + menuconfig U_BOOT + select U_BOOT_DEPENDENCIES select BOOTLOADER select HOST_SYSTEM_PYTHON3 select HOST_OPENSSL if U_BOOT_NEEDS_HOST_OPENSSL -- 2.39.2
[ptxdist] [PATCH 3/3] u-boot: Add integration of firmware blobs
Almost same approach as done for barebox with commit 6684c552fbd7 ("barebox: add integration of firmware blobs") already. For some boards it is required to inject files to build dir. This is cleaner and not cluttering your source dir. In U-Boot it seems to work in both ways, injecting to source or build dir, so we opt for build dir. Signed-off-by: Alexander Dahl --- platforms/u-boot.firmware.in | 7 +++ platforms/u-boot.in | 8 rules/u-boot.make| 20 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 platforms/u-boot.firmware.in diff --git a/platforms/u-boot.firmware.in b/platforms/u-boot.firmware.in new file mode 100644 index 0..da7f8128f --- /dev/null +++ b/platforms/u-boot.firmware.in @@ -0,0 +1,7 @@ +## SECTION=u_boot_firmware + +# +# This file does only exist to create a defined entry in the "u_boot_firmware" +# section, so that the toplevel Kconfig can include generated/u_boot_firmware.in +# even if no package is in that category. +# diff --git a/platforms/u-boot.in b/platforms/u-boot.in index 9163a8378..5ce7387e4 100644 --- a/platforms/u-boot.in +++ b/platforms/u-boot.in @@ -90,6 +90,14 @@ config U_BOOT_CONFIG endif +menuconfig U_BOOT_FIRMWARE + bool + prompt "integrate firmware blobs " + +if U_BOOT_FIRMWARE +source "generated/u_boot_firmware.in" +endif + config U_BOOT_CUSTOM_MAKE_ENV prompt "Custom (additional) make environment" string diff --git a/rules/u-boot.make b/rules/u-boot.make index e4c963d0c..2a8059170 100644 --- a/rules/u-boot.make +++ b/rules/u-boot.make @@ -36,6 +36,9 @@ endif # Prepare # +U_BOOT_INJECT_PATH := ${PTXDIST_SYSROOT_TARGET}/usr/lib/firmware +U_BOOT_INJECT_OOT := $(call ptx/ifdef, PTXCONF_U_BOOT_BUILD_OOT,YES,NO) + ifdef PTXCONF_U_BOOT_BOOT_SCRIPT U_BOOT_BOOT_SCRIPT_TXT := $(call ptx/in-platformconfigdir, uboot.scr) U_BOOT_BOOT_SCRIPT_BIN := $(call remove_quotes, \ @@ -93,14 +96,23 @@ $(U_BOOT_CONFIG): @exit 1 endif - -ifdef PTXCONF_U_BOOT_CONFIGSYSTEM_LEGACY $(STATEDIR)/u-boot.prepare: @$(call targetinfo) - $(U_BOOT_CONF_ENV) $(MAKE) $(U_BOOT_CONF_OPT) - @$(call touch) + +ifdef PTXCONF_U_BOOT_CONFIGSYSTEM_KCONFIG + @$(call world/prepare, U_BOOT) endif +ifdef PTXCONF_U_BOOT_CONFIGSYSTEM_LEGACY + $(U_BOOT_CONF_ENV) $(MAKE) $(U_BOOT_CONF_OPT) +endif + +ifdef PTXCONF_U_BOOT_FIRMWARE + @$(call world/inject, U_BOOT) +endif + + @$(call touch) + # # Compile # -- 2.39.2
[ptxdist] [PATCH 0/3] u-boot: Extend for using external firmware
Hello everyone, for quite some new boards external firmware blobs are required to build a working bootloader image. This series is the follow-up to the reworked ptxdist inject mechanism and allows to build U-Boot for modern boards with i.MX8 or i.MX9 SoCs (and probably more). Greets Alex Alexander Dahl (3): u-boot: Add option to pass additional make env u-boot: Allow other packages to inject dependencies u-boot: Add integration of firmware blobs platforms/u-boot.firmware.in | 7 +++ platforms/u-boot.in | 22 ++ rules/u-boot.make| 24 +++- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 platforms/u-boot.firmware.in base-commit: 5a720c419cd1fabde04e8de8d1d1367c76a2666b -- 2.39.2
[ptxdist] [PATCH 1/3] u-boot: Add option to pass additional make env
Some things need to be set in environment instead of passing them as additional make opts. Signed-off-by: Alexander Dahl --- platforms/u-boot.in | 9 + rules/u-boot.make | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/platforms/u-boot.in b/platforms/u-boot.in index 000ca491a..53db146e1 100644 --- a/platforms/u-boot.in +++ b/platforms/u-boot.in @@ -85,6 +85,15 @@ config U_BOOT_CONFIG endif +config U_BOOT_CUSTOM_MAKE_ENV + prompt "Custom (additional) make environment" + string + help + List of additional env variables set for make at build time. + Can be used for example to set BINMAN_INDIRS= to a path + containing firmware files (preferably somewhere in + sysroot-target). + config U_BOOT_CUSTOM_MAKE_OPTS prompt "Custom make options" string diff --git a/rules/u-boot.make b/rules/u-boot.make index 4bc7f3f78..e4c963d0c 100644 --- a/rules/u-boot.make +++ b/rules/u-boot.make @@ -63,7 +63,9 @@ U_BOOT_CONF_OPT := \ U_BOOT_MAKE_ENV:= \ CROSS_COMPILE=$(BOOTLOADER_CROSS_COMPILE) \ - HOSTCC=$(HOSTCC) + HOSTCC=$(HOSTCC) \ + $(call remove_quotes,$(PTXCONF_U_BOOT_CUSTOM_MAKE_ENV)) + U_BOOT_MAKE_OPT:= $(U_BOOT_CONF_OPT) U_BOOT_TAGS_OPT:= ctags cscope etags -- 2.39.2
[ptxdist] [PATCH v2 2/4] ptxd_make_world_inject: Use _DIR directly
pkg_source was defined as "$($(1)_DIR)" which is the same as pkg_dir in ptxd_make_world_common. We can use pkg_dir directly. Add a safe-guard to bail out early if that var is empty. Signed-off-by: Alexander Dahl --- Notes: v2: - no change v1: - implicit rules/post/ptxd_make_world_inject.make | 3 +-- scripts/lib/ptxd_make_world_inject.sh | 6 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rules/post/ptxd_make_world_inject.make b/rules/post/ptxd_make_world_inject.make index b7d28e92f..3506ee114 100644 --- a/rules/post/ptxd_make_world_inject.make +++ b/rules/post/ptxd_make_world_inject.make @@ -9,8 +9,7 @@ world/inject/env = \ $(call world/env, $(1)) \ pkg_inject_path="$($(1)_INJECT_PATH)" \ - pkg_inject_files="$($(1)_INJECT_FILES)" \ - pkg_source="$($(1)_DIR)" + pkg_inject_files="$($(1)_INJECT_FILES)" world/inject = \ $(call world/inject/env,$(strip $(1))) \ diff --git a/scripts/lib/ptxd_make_world_inject.sh b/scripts/lib/ptxd_make_world_inject.sh index 5c2d0dc5f..b74e464c6 100644 --- a/scripts/lib/ptxd_make_world_inject.sh +++ b/scripts/lib/ptxd_make_world_inject.sh @@ -10,7 +10,7 @@ ptxd_make_inject() { local source target source="$(echo ${inject_file} | cut -d ":" -f 1)" -target="${pkg_source}/$(echo ${inject_file} | cut -d ":" -f 2)" +target="${pkg_dir}/$(echo ${inject_file} | cut -d ":" -f 2)" if [[ "${source}" =~ ^/.* ]]; then ptxd_bailout "'${source}' must not be an absolute path!" \ @@ -32,6 +32,10 @@ export -f ptxd_make_inject ptxd_make_world_inject() { ptxd_make_world_init || return +if [ -z "${pkg_dir}" ]; then + ptxd_bailout "_DIR empty, no destination to inject to." +fi + for inject_file in ${pkg_inject_files}; do ptxd_make_inject || return done -- 2.39.2
[ptxdist] [PATCH v2 1/4] ptxd_make_world_inject: Remove useless test
One line above $target is set to "${var}/$(subshell)" and even if $var _and_ the result of the subshell call is empty, there's still the slash. Thus target is never empty. Signed-off-by: Alexander Dahl --- Notes: v2: - no change v1: - implicit scripts/lib/ptxd_make_world_inject.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/lib/ptxd_make_world_inject.sh b/scripts/lib/ptxd_make_world_inject.sh index fe4eb8363..5c2d0dc5f 100644 --- a/scripts/lib/ptxd_make_world_inject.sh +++ b/scripts/lib/ptxd_make_world_inject.sh @@ -11,9 +11,6 @@ ptxd_make_inject() { source="$(echo ${inject_file} | cut -d ":" -f 1)" target="${pkg_source}/$(echo ${inject_file} | cut -d ":" -f 2)" -if [ -z "${target}" ]; then - target="${source}" -fi if [[ "${source}" =~ ^/.* ]]; then ptxd_bailout "'${source}' must not be an absolute path!" \ -- 2.39.2
[ptxdist] [PATCH v2 4/4] ptxd_make_world_inject: Introduce new variable _INJECT_OOT
Setting the new variable to 'YES' allows to inject into _BUILD_DIR instead of _DIR as before. When building out-of-tree some bootloaders like U-Boot expect injected files in the build dir, not in the source dir. Backwards compatibility is ensured, the source dir is still the default, the new inject dest is optional and in case set it overwrites the default. For using this in u-boot package, on top of the things already done to use the old inject mechanism in general, add this line to 'rules/u-boot.make' for example: U_BOOT_INJECT_OOT := YES Signed-off-by: Alexander Dahl --- Notes: v2: - dropped the previous approach with the more flexible _INJECT_DEST - reworked the whole logic to use new _INJECT_OOT variable v1: - implicit rules/post/ptxd_make_world_inject.make | 3 ++- scripts/lib/ptxd_make_world_inject.sh | 23 --- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/rules/post/ptxd_make_world_inject.make b/rules/post/ptxd_make_world_inject.make index eabcdd052..1e3979a2f 100644 --- a/rules/post/ptxd_make_world_inject.make +++ b/rules/post/ptxd_make_world_inject.make @@ -9,7 +9,8 @@ world/inject/env = \ $(call world/env, $(1)) \ pkg_inject_path="$(call ptx/escape,$($(1)_INJECT_PATH))" \ - pkg_inject_files="$(call ptx/escape,$($(1)_INJECT_FILES))" + pkg_inject_files="$(call ptx/escape,$($(1)_INJECT_FILES))" \ + pkg_inject_oot="$(call ptx/escape,$($(1)_INJECT_OOT))" world/inject = \ $(call world/inject/env,$(strip $(1))) \ diff --git a/scripts/lib/ptxd_make_world_inject.sh b/scripts/lib/ptxd_make_world_inject.sh index b74e464c6..e8e94fbe6 100644 --- a/scripts/lib/ptxd_make_world_inject.sh +++ b/scripts/lib/ptxd_make_world_inject.sh @@ -10,7 +10,7 @@ ptxd_make_inject() { local source target source="$(echo ${inject_file} | cut -d ":" -f 1)" -target="${pkg_dir}/$(echo ${inject_file} | cut -d ":" -f 2)" +target="${inject_dest}/$(echo ${inject_file} | cut -d ":" -f 2)" if [[ "${source}" =~ ^/.* ]]; then ptxd_bailout "'${source}' must not be an absolute path!" \ @@ -32,8 +32,25 @@ export -f ptxd_make_inject ptxd_make_world_inject() { ptxd_make_world_init || return -if [ -z "${pkg_dir}" ]; then - ptxd_bailout "_DIR empty, no destination to inject to." +if [ -z "${pkg_inject_oot}" ]; then + pkg_inject_oot=NO +fi + +case "${pkg_inject_oot}" in + "YES") inject_dest="${pkg_build_dir}" ;; + "NO") inject_dest="${pkg_dir}" ;; + *) ptxd_bailout "_INJECT_OOT: please set to YES or NO" ;; +esac + +if [ "${pkg_build_oot:-NO}" = 'NO' ] && [ "${pkg_inject_oot}" != 'NO' ]; then + ptxd_warning "_BUILD_OOT and _INJECT_OOT contradict each other." \ + "Using $(ptxd_print_path ${inject_dest}) as inject destination anyways." +fi + +if [ ! -d "${inject_dest}" ]; then + ptxd_bailout " inject destination dir missing." \ + "Correct placement of world/inject depends on _BUILD_OOT and _INJECT_OOT." \ + "Check order of calls in prepare stage!" fi for inject_file in ${pkg_inject_files}; do -- 2.39.2
[ptxdist] [PATCH v2 0/4] ptxd_make_world_inject: Spring cleanup and optional dest dir
Hello, some spring cleaning and a new feature for the firmware inject mechanism. When trying to re-build U-Boot as an oot build for the Karo QSBASE93 Evalkit (for QS93 Solder-Down System-on-Module) it became apparent U-Boot wants some of those binary blobs in build folder instead of source folder. Supporting this usecase is nice to have, because you won't clutter your source tree, especially when building from external tree after something like `ptxdist local-src u-boot ~/src/u-boot` … Maybe we should add some documentation for this inject mechanism? Follow-up patches for u-boot package in preparation already, but let me know what you think of this first. Greets Alex v2: - rework patch 4 introducing the new inject oot mechanism (using the new _INJECT_OOT variable now instead of a needlessly flexible approach in v1) v1: https://lore.ptxdist.org/ptxdist/20240424143109.277373-1-...@thorsis.com/T/#t - initial patch stack revision (implicit) Alexander Dahl (4): ptxd_make_world_inject: Remove useless test ptxd_make_world_inject: Use _DIR directly ptxd_make_world_inject: Escape inject path and files ptxd_make_world_inject: Introduce new variable _INJECT_OOT rules/post/ptxd_make_world_inject.make | 6 +++--- scripts/lib/ptxd_make_world_inject.sh | 26 ++ 2 files changed, 25 insertions(+), 7 deletions(-) base-commit: 5a720c419cd1fabde04e8de8d1d1367c76a2666b -- 2.39.2
[ptxdist] [PATCH v2 3/4] ptxd_make_world_inject: Escape inject path and files
Same as in ptxd_make_world_common for all the other variables set in make and used in shell. Signed-off-by: Alexander Dahl --- Notes: v2: - no change v1: - implicit rules/post/ptxd_make_world_inject.make | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/post/ptxd_make_world_inject.make b/rules/post/ptxd_make_world_inject.make index 3506ee114..eabcdd052 100644 --- a/rules/post/ptxd_make_world_inject.make +++ b/rules/post/ptxd_make_world_inject.make @@ -8,8 +8,8 @@ world/inject/env = \ $(call world/env, $(1)) \ - pkg_inject_path="$($(1)_INJECT_PATH)" \ - pkg_inject_files="$($(1)_INJECT_FILES)" + pkg_inject_path="$(call ptx/escape,$($(1)_INJECT_PATH))" \ + pkg_inject_files="$(call ptx/escape,$($(1)_INJECT_FILES))" world/inject = \ $(call world/inject/env,$(strip $(1))) \ -- 2.39.2