board/zynqmp/post-image.sh: add custom hardware support
PATCH v5 1/3 board/zynqmp/post-image.sh: add custom hardware support
By switching to the LINUX_DTBS variable, the post-image.sh script can now work regardless of whether a user is using BR2_LINUX_KERNEL_INTREE_DTS_NAME or the BR2_LINUX_KERNEL_CUSTOM_DTS_DIR for custom hardware. This simplifies the transition users will make when migrating from a zynqmp evaluation board to a zynqmp custom platform.
To keep the example post-image script as simple as possible, it assumes that the first DTB in the LINUX_DTBS list is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.
---V1->V2:
- removed unnecessary $BINARIES_DIR from symlink source V2->V3:
- ignore anything after the first space char of LINUX_DTBS V3->V4:
- use make print-vars to get LINUX_DTBS variable V4->V5:
- fixed shellcheck issue
--- board/zynqmp/post-image.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
board/zynqmp/post-image.sh +3 -7
@@ -2,13 +2,9 @@ # By default U-Boot loads DTB from a file named "system.dtb", so # let's use a symlink with that name that points to the *first* -# devicetree listed in the config. - -FIRST_DT=$(sed -nr \ - -e 's|^BR2_LINUX_KERNEL_INTREE_DTS_NAME="(xilinx/)?([-_/[:alnum:]\\.]*).*"$|\2|p' \ - "${BR2_CONFIG}") - -[ -z "${FIRST_DT}" ] || ln -fs "${FIRST_DT}.dtb" "${BINARIES_DIR}/system.dtb" +# devicetree in the LINUX_DTBS list. +LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" +ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" BOARD_DIR="$(dirname "$0")"
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v5 2/3 board/versal/post-image.sh: add custom hardware support
By switching to the LINUX_DTBS variable, the post-image.sh script can now work regardless of whether a user is using BR2_LINUX_KERNEL_INTREE_DTS_NAME or the BR2_LINUX_KERNEL_CUSTOM_DTS_DIR for custom hardware. This simplifies the transition users will make when migrating from a versal evaluation board to a versal custom platform.
To keep the example post-image script as simple as possible, it assumes that the first DTB in the LINUX_DTBS list is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.
---V1->V2:
- removed unnecessary $BINARIES_DIR from symlink source V2->V3:
- ignore anything after the first space char of LINUX_DTBS V3->V4:
- use make print-vars to get LINUX_DTBS variable V4->V5:
- fixed shellcheck issue
--- board/versal/post-image.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
board/versal/post-image.sh +3 -7
@@ -2,13 +2,9 @@ # By default U-Boot loads DTB from a file named "system.dtb", so # let's use a symlink with that name that points to the *first* -# devicetree listed in the config. - -FIRST_DT=$(sed -nr \ - -e 's|^BR2_LINUX_KERNEL_INTREE_DTS_NAME="(xilinx/)?([-_/[:alnum:]\\.]*).*"$|\2|p' \ - "${BR2_CONFIG}") - -[ -z "${FIRST_DT}" ] || ln -fs "${FIRST_DT}.dtb" "${BINARIES_DIR}/system.dtb" +# devicetree in the LINUX_DTBS list. +LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" +ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" BOARD_DIR="$(dirname "$0")"
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v5 2/3] board/versal/post-image.sh: add custom hardware support
Quoted 6 lines · Neal Frager
By switching to the
LINUX_DTBSvariable, thepost-image.shscript can now work regardless of whether a user is usingBR2_LINUX_KERNEL_INTREE_DTS_NAMEor theBR2_LINUX_KERNEL_CUSTOM_DTS_DIRfor custom hardware. This simplifies the transition users will make when migrating from a versal evaluation board to a versal custom platform.
Quoted 6 lines
To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.Signed-off-by Neal Frager <[email protected]>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v5 3/3 board/versal2/post-image.sh: add custom hardware support
In reply to Neal Frager via buildrootUsers will ultimately need the BR2_LINUX_KERNEL_CUSTOM_DTS_DIR config to import custom dts files for custom versal2 hardware. Improve the post-image.sh to support either the default device tree which comes from u-boot or a custom device tree for custom hardware.
To keep the example post-image script as simple as possible, it assumes that the first DTB in the LINUX_DTBS list is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs or overlays.
---V1->V2:
- new to patch seriesV2->V5:
- fixed shellcheck issue
- merged with zynqmp and versal patch set
--- board/versal2/post-image.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
board/versal2/post-image.sh +12 -4
@@ -1,9 +1,17 @@ #!/bin/sh -# By default U-Boot loads DTB from a file named "system.dtb", and -# with versal2, the Linux DTB is the same as the U-Boot DTB, so -# let's use a symlink since the DTB is the same. -ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +# By default U-Boot loads DTB from a file named "system.dtb". +# With versal2, there is no default dts in the Linux kernel tree +# because the default is the same as the u-boot.dtb. This means +# it is necessary to cover two cases, a custom dts or the default. +# The BR2_LINUX_KERNEL_DTS_SUPPORT will only be set for custom dts +# files, so it can be used for checking which case is configured. +if grep -Eq "^BR2_LINUX_KERNEL_DTS_SUPPORT=y$" "${BR2_CONFIG}"; then + LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" + ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" +else + ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +fi BOARD_DIR="$(dirname "$0")"
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v5 3/3] board/versal2/post-image.sh: add custom hardware support
Quoted 28 lines · Neal Frager
Users will ultimately need the
BR2_LINUX_KERNEL_CUSTOM_DTS_DIRconfig to import custom dts files for custom versal2 hardware. Improve thepost-image.shto support either the default device tree which comes from u-boot or a custom device tree for custom hardware.To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs or overlays.Signed-off-by Neal Frager <[email protected]>---
V1->V2:
- new to patch seriesV2->V5:
- fixed shellcheck issue
- merged with zynqmp and versal patch set--- board/versal2/post-image.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)board/versal2/post-image.sh +0
-0@@ -1,9 +1,17 @@ #!/bin/sh
board/versal2/post-image.sh line 8
Quoted 10 lines
board/versal2/post-image.sh +6
-4-# By default U-Boot loads DTB from a file named "system.dtb", and -# with versal2, the Linux DTB is the same as the U-Boot DTB, so -# let's use a symlink since the DTB is the same. -ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +# By default U-Boot loads DTB from a file named "system.dtb". +# With versal2, there is no default dts in the Linux kernel tree +# because the default is the same as the u-boot.dtb. This means +# it is necessary to cover two cases, a custom dts or the default. +# The BR2_LINUX_KERNEL_DTS_SUPPORT will only be set for custom dts +# files
Out of my ignorance, is this assumption always correct? What if the main dtb comes from u-boot but the kernel package is used to build some overlays (and no dtb)? This patch would break such configs, because is would link system.dtb to some dtbo instead of u-boot.dtb.
Is this a valid use case in the first place?
board/versal2/post-image.sh line 14
Quoted 7 lines
, so it can be used for checking which case is configured.
board/versal2/post-image.sh +6
-0+if grep -Eq "^BR2_LINUX_KERNEL_DTS_SUPPORT=y$" "${BR2_CONFIG}"; then + LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" + ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" +else + ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +fi
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v5 3/3] board/versal2/post-image.sh: add custom hardware support
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Luca,
Quoted 44 lines
Users will ultimately need the
BR2_LINUX_KERNEL_CUSTOM_DTS_DIRconfig to import custom dts files for custom versal2 hardware. Improve thepost-image.shto support either the default device tree which comes from u-boot or a custom device tree for custom hardware.To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs or overlays.Signed-off-by Neal Frager <[email protected]>---
V1->V2:
- new to patch seriesV2->V5:
- fixed shellcheck issue
- merged with zynqmp and versal patch set--- board/versal2/post-image.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)board/versal2/post-image.sh +6
-4@@ -1,9 +1,17 @@ #!/bin/sh -# By default U-Boot loads DTB from a file named "system.dtb", and -# with versal2, the Linux DTB is the same as the U-Boot DTB, so -# let's use a symlink since the DTB is the same. -ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +# By default U-Boot loads DTB from a file named "system.dtb". +# With versal2, there is no default dts in the Linux kernel tree +# because the default is the same as the u-boot.dtb. This means +# it is necessary to cover two cases, a custom dts or the default. +# The BR2_LINUX_KERNEL_DTS_SUPPORT will only be set for custom dts +# filesOut of my ignorance, is this assumption always correct? What if the main dtb comes from u-boot but the kernel package is used to build some overlays (and no dtb)? This patch would break such configs, because is would link system.dtb to some dtbo instead of u-boot.dtb.
Quoted 1 line
Is this a valid use case in the first place?
Yes, I didn't think of this use case.
My goal was to try to keep the script as simple as possible, so I was only trying to cover the case where someone migrates from the vek385 to a custom versal2 board where the device tree is different, and not just an overlay on top of the vek385 base dtb which is included with u-boot. Or an overlay on top of a custom u-boot.dtb.
In the end, this comes back to the same question for the other patches. Should we improve the script to handle the full list of LINUX_DTBS? In other words, we would assume that we would want to combine any dtbos and create a system.dtb that contains everything in the LINUX_DTBS list, including the original u-boot.dtb in case there are no dtbs in LINUX_DTBS?
It would make the script more complex, so is it worth it?
board/versal2/post-image.sh line 14
Quoted 7 lines
, so it can be used for checking which case is configured.
board/versal2/post-image.sh +6
-0+if grep -Eq "^BR2_LINUX_KERNEL_DTS_SUPPORT=y$" "${BR2_CONFIG}"; then + LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" + ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" +else + ln -fs "u-boot.dtb" "${BINARIES_DIR}/system.dtb" +fi
Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 33 lines · Neal Frager
By switching to the
LINUX_DTBSvariable, thepost-image.shscript can now work regardless of whether a user is usingBR2_LINUX_KERNEL_INTREE_DTS_NAMEor theBR2_LINUX_KERNEL_CUSTOM_DTS_DIRfor custom hardware. This simplifies the transition users will make when migrating from a zynqmp evaluation board to a zynqmp custom platform.To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.Signed-off-by Neal Frager <[email protected]>---
V1->V2:
- removed unnecessary $BINARIES_DIR from symlink sourceV2->V3:
- ignore anything after the first space char ofLINUX_DTBSV3->V4:
- use make print-vars to getLINUX_DTBSvariableV4->V5:
- fixed shellcheck issue--- board/zynqmp/post-image.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)board/zynqmp/post-image.sh +0
-0@@ -2,13 +2,9 @@ # By default U-Boot loads DTB from a file named "system.dtb", so # let's use a symlink with that name that points to the *first*
board/zynqmp/post-image.sh line 7
Quoted 10 lines
board/zynqmp/post-image.sh +3
-7-# devicetree listed in the config. - -FIRST_DT=$(sed -nr \ - -e 's|^BR2_LINUX_KERNEL_INTREE_DTS_NAME="(xilinx/)?([-_/[:alnum:]\\.]*).*"$|\2|p' \ - "${BR2_CONFIG}") - -[ -z "${FIRST_DT}" ] || ln -fs "${FIRST_DT}.dtb" "${BINARIES_DIR}/system.dtb" +# devicetree in the LINUX_DTBS list. +LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" +ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb"
The whitespace-based string mangling still feels a bit fragile to me, but it should be OK in the practice as I don't think we support paths with spaces.
Also there was a concern about what happens in case the first file is a dtbo, but the old code does not support it either so this patch is not breaking anything. dtbo-first-in-the-list support can be added later with more sophisticated scripting if needed.
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines · Neal Frager via buildroot
By switching to the
LINUX_DTBSvariable, thepost-image.shscript can now work regardless of whether a user is usingBR2_LINUX_KERNEL_INTREE_DTS_NAMEor theBR2_LINUX_KERNEL_CUSTOM_DTS_DIRfor custom hardware. This simplifies the transition users will make when migrating from a zynqmp evaluation board to a zynqmp custom platform.
Quoted 6 lines
To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.Signed-off-by Neal Frager <[email protected]>
Applied series to master, thanks!
Even though Luca voiced some concerns, I think this is an improvement over the
current situation. It maybe doesn't work in all cases but it's a good start. Users doing weird stuff are going to have to build their own post-build scripts.
Regarding the spaces: within Buildroot we use things like $(firstword ...)
which does pretty much the same thing, so I think it's fine.
Regards,
Arnout
Quoted 36 lines
---
V1->V2:
- removed unnecessary $BINARIES_DIR from symlink sourceV2->V3:
- ignore anything after the first space char ofLINUX_DTBSV3->V4:
- use make print-vars to getLINUX_DTBSvariableV4->V5:
- fixed shellcheck issue--- board/zynqmp/post-image.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)board/zynqmp/post-image.sh +3
-7@@ -2,13 +2,9 @@ # By default U-Boot loads DTB from a file named "system.dtb", so # let's use a symlink with that name that points to the *first* -# devicetree listed in the config. - -FIRST_DT=$(sed -nr \ - -e 's|^BR2_LINUX_KERNEL_INTREE_DTS_NAME="(xilinx/)?([-_/[:alnum:]\\.]*).*"$|\2|p' \ - "${BR2_CONFIG}") - -[ -z "${FIRST_DT}" ] || ln -fs "${FIRST_DT}.dtb" "${BINARIES_DIR}/system.dtb" +# devicetree in the LINUX_DTBS list. +LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" +ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" BOARD_DIR="$(dirname "$0")"Signature · 1 line
2.25.1
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
AMD General
Hi Arnout,
Quoted 6 lines
By switching to the
LINUX_DTBSvariable, thepost-image.shscript can now work regardless of whether a user is usingBR2_LINUX_KERNEL_INTREE_DTS_NAMEor theBR2_LINUX_KERNEL_CUSTOM_DTS_DIRfor custom hardware. This simplifies the transition users will make when migrating from a zynqmp evaluation board to a zynqmp custom platform.
Quoted 8 lines
To keep the example post-image script as simple as possible, it assumes that the first DTB in the
LINUX_DTBSlist is the one for creating the system.dtb filename that u-boot will use for booting. Users are free to implement their own post-image scripts for use cases with multiple DTBs.Signed-off-by Neal Frager <[email protected]>Applied series to master, thanks!
Thank you!
Quoted 4 lines
Even though Luca voiced some concerns, I think this is an improvement over the current situation. It maybe doesn't work in all cases but it's a good start. Users doing weird stuff are going to have to build their own post-build scripts.
I am aware of Luca's concerns. He is always welcome to submit a solution that works even better!
Quoted 2 lines
Regarding the spaces: within Buildroot we use things like $(firstword ...) which does pretty much the same thing, so I think it's fine.
Thanks for sharing. I am fine with changing it. The only thing that matters to me is that the script works and it is simple.
Quoted 2 lines
Regards,
Arnout
Best regards,
Neal
Quoted 35 lines
---
V1->V2:
- removed unnecessary $BINARIES_DIR from symlink sourceV2->V3:
- ignore anything after the first space char ofLINUX_DTBSV3->V4:
- use make print-vars to getLINUX_DTBSvariableV4->V5:
- fixed shellcheck issue--- board/zynqmp/post-image.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)board/zynqmp/post-image.sh +3
-8@@ -2,13 +2,9 @@ # By default U-Boot loads DTB from a file named "system.dtb", so # let's use a symlink with that name that points to the *first* -# devicetree listed in the config. - -FIRST_DT=$(sed -nr \ - -e 's|^BR2_LINUX_KERNEL_INTREE_DTS_NAME="(xilinx/)?([-_/[:alnum:]\\.]*).*"$|\2|p' \ - "${BR2_CONFIG}") - -[ -z "${FIRST_DT}" ] || ln -fs "${FIRST_DT}.dtb" "${BINARIES_DIR}/system.dtb" +# devicetree in the LINUX_DTBS list. +LINUX_DTBS="$(make --no-print-directory VARS=LINUX_DTBS printvars)" +ln -fs "$(basename "${LINUX_DTBS%% *}")" "${BINARIES_DIR}/system.dtb" BOARD_DIR="$(dirname "$0")" --
Quoted 1 line
2.25.1
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot