Skip to contentSkip to conversation

bin/flash.sdwire_common_mount: Switch to sourcing the next writer script

PATCH Applied Tom Rini 3 participants 9 messages Jul 25, 2023 – Aug 9, 2023 Arm/Zynq architecture

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 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.

---
 bin/flash.sdwire_common_mount |  3 ++-
 bin/writer.rpi3_mount         | 19 +++++++------------
 bin/writer.zynq_mount         | 15 +++++----------
 3 files changed, 14 insertions(+), 23 deletions(-)
bin/flash.sdwire_common_mount +2 -1
index 6c763e62f47d..b76add064fb0 100644
@@ -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
bin/writer.rpi3_mount +7 -12
index 97f24a5ac694..a63e7999e57b 100755
@@ -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
bin/writer.zynq_mount +5 -10
index 9d0958880422..c8395a40680e 100755
@@ -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}
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/4 bin/writer.rpi*mount: Rework to support all current Pi platforms

Now that we have access to more variables in our "mount" writer scripts, we can have a single one that covers all Pi variants.

---
I use this locally to test a Pi 3 in both 32, 64 and "arm64" mode.

Cc Simon Glass <[email protected]>
---
 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%)
bin/kea/conf.rpi_3_32b_sjg-rpi_3b +1 -1
index 5fe98687221d..020eca2404d8 100644
@@ -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
bin/kea/conf.rpi_3_sjg-rpi_3b +1 -1
index 64ffff01737f..d8d2a94f036a 100644
@@ -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
bin/writer.rpi_mount renamed from bin/writer.rpi3_mount +29 -17

60 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 2/4
#2 lore raw

Re: [u-boot-test-hooks 2/4] bin/writer.rpi*mount: Rework to support all current Pi platforms

Quoted 8 lines · Tom Rini

Now that we have access to more variables in our "mount" writer scripts, we can have a single one that covers all Pi variants.

---
I use this locally to test a Pi 3 in both 32, 64 and "arm64" mode.

Quoted 7 lines
Cc Simon Glass <[email protected]>
---
 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%)
author
#3 lore raw

PATCH 3/4 bin/writer.ti-omap_mount: Add support for TI OMAP-style platforms via mount

In reply to Tom Rini

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.

---
 bin/writer.ti-omap_mount | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 bin/writer.ti-omap_mount
bin/writer.ti-omap_mount new file +29 -0
new file mode 100755
index 000000000000..7d1dbee8f65f
@@ -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}/
Signature · 1 line
2.34.1
Reviewed-by on v1 3/4
#4 lore raw

Re: [u-boot-test-hooks 3/4] bin/writer.ti-omap_mount: Add support for TI OMAP-style platforms via mount

Quoted 9 lines · Tom Rini

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.

---
 bin/writer.ti-omap_mount | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 bin/writer.ti-omap_mount
author
#5 lore raw

PATCH 4/4 bin/writer.ti-k3_mount: Add support for TI K3 platforms via mount

In reply to Tom Rini

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).

---
 bin/writer.ti-k3_mount | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 bin/writer.ti-k3_mount
bin/writer.ti-k3_mount new file +36 -0
new file mode 100755
index 000000000000..e22a2a50de78
@@ -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
Signature · 1 line
2.34.1
Reviewed-by on v1 4/4
#6 lore raw

Re: [u-boot-test-hooks 4/4] bin/writer.ti-k3_mount: Add support for TI K3 platforms via mount

Quoted 10 lines · Tom Rini

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).

Quoted 5 lines
---
 bin/writer.ti-k3_mount | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 bin/writer.ti-k3_mount
Reviewed-by on v1 1/4
#7 lore raw
In reply to Tom Rini
Quoted 6 lines · Tom Rini

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.

Quoted 6 lines
---
 bin/flash.sdwire_common_mount |  3 ++-
 bin/writer.rpi3_mount         | 19 +++++++------------
 bin/writer.zynq_mount         | 15 +++++----------
 3 files changed, 14 insertions(+), 23 deletions(-)
author Applied
#8 lore raw
In reply to Tom Rini
Quoted 6 lines · Tom Rini

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,

Signature · 1 line
Tom