[u-boot-test-hooks 1/4] bin/flash.sdwire_common_mount: Switch to sourcing the next writer script

Rather than invoking the script that will write to the mounted directory as a binary, source it as a script so that it has access to more than just two parameters. This will allow us to have the same flexibility in our writers that other flash methods have.
Signed-off-by: Tom Rini trini@konsulko.com --- bin/flash.sdwire_common_mount | 3 ++- bin/writer.rpi3_mount | 19 +++++++------------ bin/writer.zynq_mount | 15 +++++---------- 3 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/bin/flash.sdwire_common_mount b/bin/flash.sdwire_common_mount index 6c763e62f47d..b76add064fb0 100644 --- a/bin/flash.sdwire_common_mount +++ b/bin/flash.sdwire_common_mount @@ -52,7 +52,8 @@ if ! mountpoint -q ${mount_dir}; then exit 1 fi
-writer.${flash_writer} ${mount_dir} ${U_BOOT_BUILD_DIR} +# Perform the write, pass along as much environment as possible +. writer.${flash_writer}
complete=false for i in {0..9}; do diff --git a/bin/writer.rpi3_mount b/bin/writer.rpi3_mount index 97f24a5ac694..a63e7999e57b 100755 --- a/bin/writer.rpi3_mount +++ b/bin/writer.rpi3_mount @@ -20,23 +20,18 @@
# Writes rpi3_b to the board
-# Args: -# $1: Mount point of the sdcard when board is off -# $2: U-Boot build directory - set -ex
-mount=$1 -build=$2 +build=${U_BOOT_BUILD_DIR}
-echo "Writing to ${mount} from build at ${build}" +echo "Writing to ${mount_dir} from build at ${build}"
# First make a copy of the original files if we haven't already -if [[ ! -e ${mount}/config.orig ]]; then - cp ${mount}/config.txt ${mount}/config.orig +if [[ ! -e ${mount_dir}/config.orig ]]; then + cp ${mount_dir}/config.txt ${mount_dir}/config.orig fi -if [[ ! -e ${mount}/rpi3-u-boot.bin.orig ]]; then - cp ${mount}/rpi3-u-boot.bin ${mount}/rpi3-u-boot.bin.orig +if [[ ! -e ${mount_dir}/rpi3-u-boot.bin.orig ]]; then + cp ${mount_dir}/rpi3-u-boot.bin ${mount_dir}/rpi3-u-boot.bin.orig fi
# Enable the UART and fix the GPU frequency so it works correctly @@ -46,4 +41,4 @@ if ! grep -q "^gpu_freq=250" /media/rpi3_b_boot/config.txt; then fi
# Copy U-Boot over from the build directory -cp ${build}/u-boot.bin ${mount}/rpi3-u-boot.bin +cp ${build}/u-boot.bin ${mount_dir}/rpi3-u-boot.bin diff --git a/bin/writer.zynq_mount b/bin/writer.zynq_mount index 9d0958880422..c8395a40680e 100755 --- a/bin/writer.zynq_mount +++ b/bin/writer.zynq_mount @@ -20,22 +20,17 @@
# Writes zynq images to the board
-# Args: -# $1: Mount point of the sdcard when board is off -# $2: U-Boot build directory - set -ex
tmp=$(mktemp -d)
-mount=$1 -build=$2 +build=${U_BOOT_BUILD_DIR}
-echo "Writing to ${mount} from build at ${build}" +echo "Writing to ${mount_dir} from build at ${build}"
# Copy U-Boot over from the build directory -cp ${build}/u-boot.bin ${mount}/rpi3-u-boot.bin +cp ${build}/u-boot.bin ${mount_dir}/rpi3-u-boot.bin zynq-boot-bin.py -o ${tmp}/boot.bin -u ${build}/spl/u-boot-spl-dtb.bin -cp ${tmp}/boot.bin ${mount}/BOOT.bin -cp ${build}/u-boot.img ${mount}/. +cp ${tmp}/boot.bin ${mount_dir}/BOOT.bin +cp ${build}/u-boot.img ${mount_dir}/. rm -rf ${tmp}

Now that we have access to more variables in our "mount" writer scripts, we can have a single one that covers all Pi variants.
Signed-off-by: Tom Rini trini@konsulko.com --- I use this locally to test a Pi 3 in both 32, 64 and "arm64" mode.
Cc: Simon Glass sjg@chromium.org --- bin/kea/conf.rpi_3_32b_sjg-rpi_3b | 2 +- bin/kea/conf.rpi_3_sjg-rpi_3b | 2 +- bin/{writer.rpi3_mount => writer.rpi_mount} | 46 +++++++++++++-------- 3 files changed, 31 insertions(+), 19 deletions(-) rename bin/{writer.rpi3_mount => writer.rpi_mount} (63%)
diff --git a/bin/kea/conf.rpi_3_32b_sjg-rpi_3b b/bin/kea/conf.rpi_3_32b_sjg-rpi_3b index 5fe98687221d..020eca2404d8 100644 --- a/bin/kea/conf.rpi_3_32b_sjg-rpi_3b +++ b/bin/kea/conf.rpi_3_32b_sjg-rpi_3b @@ -23,7 +23,7 @@ reset_impl=ykush flash_impl=sdwire_poweroff_mount power_impl=ykush
-flash_writer=rpi3_mount +flash_writer=rpi_mount
ykush_serial=YK17698 ykush_port=1 diff --git a/bin/kea/conf.rpi_3_sjg-rpi_3b b/bin/kea/conf.rpi_3_sjg-rpi_3b index 64ffff01737f..d8d2a94f036a 100644 --- a/bin/kea/conf.rpi_3_sjg-rpi_3b +++ b/bin/kea/conf.rpi_3_sjg-rpi_3b @@ -23,7 +23,7 @@ reset_impl=ykush flash_impl=sdwire_ykush_mount power_impl=ykush
-flash_writer=rpi3_mount +flash_writer=rpi_mount
ykush_serial=YK17698 ykush_port=1 diff --git a/bin/writer.rpi3_mount b/bin/writer.rpi_mount similarity index 63% rename from bin/writer.rpi3_mount rename to bin/writer.rpi_mount index a63e7999e57b..73fb8bf6af04 100755 --- a/bin/writer.rpi3_mount +++ b/bin/writer.rpi_mount @@ -1,4 +1,5 @@ # Copyright 2019 Google LLC. All rights reserved. +# Copyright 2024 Konsulko Group. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -18,27 +19,38 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE.
-# Writes rpi3_b to the board - -set -ex +set -e
build=${U_BOOT_BUILD_DIR}
echo "Writing to ${mount_dir} from build at ${build}"
-# First make a copy of the original files if we haven't already -if [[ ! -e ${mount_dir}/config.orig ]]; then - cp ${mount_dir}/config.txt ${mount_dir}/config.orig -fi -if [[ ! -e ${mount_dir}/rpi3-u-boot.bin.orig ]]; then - cp ${mount_dir}/rpi3-u-boot.bin ${mount_dir}/rpi3-u-boot.bin.orig -fi +case "${board_type}" in +rpi) + kernel_dst=kernel.img + ;; +rpi_2) + kernel_dst=kernel7.img + ;; +rpi_3|rpi_3b|rpi_3_b_plus|rpi_4|rpi_arm64) + kernel_dst=kernel8.img + ;; +rpi_3_32b|rpi_4_32b) + kernel_dst=kernel8-32.img + ;; +*) + echo Unknown Pi ""${board_type}"" + exit 1 + ;; +esac + +sudo rm -f ${mount_dir}/kernel*img +sudo cp -v ${build}/u-boot.bin ${mount_dir}/${kernel_dst}
-# Enable the UART and fix the GPU frequency so it works correctly -sed -i '/enable_uart/c\enable_uart = 1' /media/rpi3_b_boot/config.txt -if ! grep -q "^gpu_freq=250" /media/rpi3_b_boot/config.txt; then - echo 'gpu_freq=250' >>/media/rpi3_b_boot/config.txt -fi +echo "enable_uart=1" | sudo tee ${mount_dir}/config.txt
-# Copy U-Boot over from the build directory -cp ${build}/u-boot.bin ${mount_dir}/rpi3-u-boot.bin +case "${board_ident}" in +3-32-pl011) + echo "dtoverlay=pi3-miniuart-bt" | sudo tee -a ${mount_dir}/config.txt + ;; +esac

On Tue, 25 Jul 2023 at 15:08, Tom Rini trini@konsulko.com wrote:
Now that we have access to more variables in our "mount" writer scripts, we can have a single one that covers all Pi variants.
Signed-off-by: Tom Rini trini@konsulko.com
I use this locally to test a Pi 3 in both 32, 64 and "arm64" mode.
Cc: Simon Glass sjg@chromium.org
bin/kea/conf.rpi_3_32b_sjg-rpi_3b | 2 +- bin/kea/conf.rpi_3_sjg-rpi_3b | 2 +- bin/{writer.rpi3_mount => writer.rpi_mount} | 46 +++++++++++++-------- 3 files changed, 31 insertions(+), 19 deletions(-) rename bin/{writer.rpi3_mount => writer.rpi_mount} (63%)
Reviewed-by: Simon Glass sjg@chromium.org

In the case of TI OMAP (and similar) platforms, the SD card needs MLO and u-boot.img to boot, always. Copy these files over.
Signed-off-by: Tom Rini trini@konsulko.com --- bin/writer.ti-omap_mount | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/writer.ti-omap_mount
diff --git a/bin/writer.ti-omap_mount b/bin/writer.ti-omap_mount new file mode 100755 index 000000000000..7d1dbee8f65f --- /dev/null +++ b/bin/writer.ti-omap_mount @@ -0,0 +1,29 @@ +# Copyright 2022 Konsulko Group. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Copies MLO to the filesystem + +set -e + +build=${U_BOOT_BUILD_DIR} + +echo "Writing to ${mount_dir} from build at ${build}" + +sudo cp ${build}/MLO ${build}/u-boot.img ${mount_dir}/

On Tue, 25 Jul 2023 at 15:09, Tom Rini trini@konsulko.com wrote:
In the case of TI OMAP (and similar) platforms, the SD card needs MLO and u-boot.img to boot, always. Copy these files over.
Signed-off-by: Tom Rini trini@konsulko.com
bin/writer.ti-omap_mount | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bin/writer.ti-omap_mount
Reviewed-by: Simon Glass sjg@chromium.org

The TI K3 platforms require a number of things in order to boot. We must have built both the Cortex-R and Cortex-A configurations (following their board documents and requirements as these need additional tooling and binaries). Further, depending on the specific SoC and variant we need three or four files to be copied to the mount point, with specific names. The least fragile way to handle this is that each board conf file must define the name of the input files to copy (the outputs have static names).
Signed-off-by: Tom Rini trini@konsulko.com --- bin/writer.ti-k3_mount | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/writer.ti-k3_mount
diff --git a/bin/writer.ti-k3_mount b/bin/writer.ti-k3_mount new file mode 100755 index 000000000000..e22a2a50de78 --- /dev/null +++ b/bin/writer.ti-k3_mount @@ -0,0 +1,36 @@ +# Copyright 2022 Konsulko Group. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Copies MLO to the filesystem + +set -e + +build=${U_BOOT_BUILD_DIR} + +if [ -z "${tispl}" -o -z "${uboot}" -o -z "${tiboot3}" ]; then + echo "Must configure tispl, uboot, tiboot3 and optionally sysfw" + echo "per the board documentation." + exit 1 +fi +echo "Writing to ${mount_dir} from build at ${build}" +sudo cp -v ${build}/${tispl} ${mount_dir}/tispl.bin +sudo cp -v ${build}/${uboot} ${mount_dir}/u-boot.img.bin +sudo cp -v ${build/_a??/_r5}/${tiboot3} ${mount_dir}/tiboot3.bin +[ ! -z "${sysfw}" ] && sudo cp -v ${build/_a??/_r5}/${sysfw} ${mount_dir}/sysfw.itb

On Tue, 25 Jul 2023 at 15:09, Tom Rini trini@konsulko.com wrote:
The TI K3 platforms require a number of things in order to boot. We must have built both the Cortex-R and Cortex-A configurations (following their board documents and requirements as these need additional tooling and binaries). Further, depending on the specific SoC and variant we need three or four files to be copied to the mount point, with specific names. The least fragile way to handle this is that each board conf file must define the name of the input files to copy (the outputs have static names).
Signed-off-by: Tom Rini trini@konsulko.com
bin/writer.ti-k3_mount | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/writer.ti-k3_mount
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, 25 Jul 2023 at 15:09, Tom Rini trini@konsulko.com wrote:
Rather than invoking the script that will write to the mounted directory as a binary, source it as a script so that it has access to more than just two parameters. This will allow us to have the same flexibility in our writers that other flash methods have.
Signed-off-by: Tom Rini trini@konsulko.com
bin/flash.sdwire_common_mount | 3 ++- bin/writer.rpi3_mount | 19 +++++++------------ bin/writer.zynq_mount | 15 +++++---------- 3 files changed, 14 insertions(+), 23 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, 25 Jul 2023 17:08:44 -0400, Tom Rini wrote:
Rather than invoking the script that will write to the mounted directory as a binary, source it as a script so that it has access to more than just two parameters. This will allow us to have the same flexibility in our writers that other flash methods have.
Applied, thanks!
[1/4] bin/flash.sdwire_common_mount: Switch to sourcing the next writer script commit: 6fcab91ee4cc7d25ccc6452ab8e0b6c64e326e16 [2/4] bin/writer.rpi*mount: Rework to support all current Pi platforms commit: 0242dc8b81dc5bb7d86dfeaf8a0ebc02f7cc0f71 [3/4] bin/writer.ti-omap_mount: Add support for TI OMAP-style platforms via mount commit: 0c0184ee0e5cecc08a9e60d39d0664f41e41af6e [4/4] bin/writer.ti-k3_mount: Add support for TI K3 platforms via mount commit: bbe462eb91981e266b2980e217fd5a0349acba63
Best regards,
participants (3)
-
Simon Glass
-
Simon Glass
-
Tom Rini