summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1927c40)
raw | patch | inline | side by side (parent: 1927c40)
author | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Mon, 6 Jul 2020 12:42:48 +0000 (18:12 +0530) | ||
committer | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Thu, 16 Jul 2020 09:15:25 +0000 (14:45 +0530) |
Generalize the script to support multiple boards
Select the prebuilt binaries and boot_select binaries
based on the board.
Move the binaries and patches into board specific directories
Add support for am65xx-evm for dfu booting into mmc, ospi, uart,
emmc and noboot modes.
Update the script to handle different board names.
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Select the prebuilt binaries and boot_select binaries
based on the board.
Move the binaries and patches into board specific directories
Add support for am65xx-evm for dfu booting into mmc, ospi, uart,
emmc and noboot modes.
Update the script to handle different board names.
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
16 files changed:
similarity index 100%
rename from k3-bootswitch/bin/sysfw.itb
rename to k3-bootswitch/bin/j721e-evm/sysfw.itb
rename from k3-bootswitch/bin/sysfw.itb
rename to k3-bootswitch/bin/j721e-evm/sysfw.itb
similarity index 100%
rename from k3-bootswitch/bin/tiboot3.bin
rename to k3-bootswitch/bin/j721e-evm/tiboot3.bin
rename from k3-bootswitch/bin/tiboot3.bin
rename to k3-bootswitch/bin/j721e-evm/tiboot3.bin
similarity index 100%
rename from k3-bootswitch/bin/tispl.bin
rename to k3-bootswitch/bin/j721e-evm/tispl.bin
rename from k3-bootswitch/bin/tispl.bin
rename to k3-bootswitch/bin/j721e-evm/tispl.bin
similarity index 100%
rename from k3-bootswitch/bin/u-boot.img
rename to k3-bootswitch/bin/j721e-evm/u-boot.img
rename from k3-bootswitch/bin/u-boot.img
rename to k3-bootswitch/bin/j721e-evm/u-boot.img
diff --git a/k3-bootswitch/boot_select/am65xx-evm/0001-HACK-Select-bootmode-and-reset.patch b/k3-bootswitch/boot_select/am65xx-evm/0001-HACK-Select-bootmode-and-reset.patch
--- /dev/null
@@ -0,0 +1,55 @@
+From e54793d50f8211af99a5528af1c1dc968fb6ca96 Mon Sep 17 00:00:00 2001
+From: Nikhil Devshatwar <nikhil.nd@ti.com>
+Date: Thu, 16 Jul 2020 13:46:14 +0530
+Subject: [PATCH] HACK: Select bootmode and reset
+
+Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
+---
+ arch/arm/mach-k3/am6_init.c | 31 +++++++++++++++++++++++++++++++
+ 1 file changed, 31 insertions(+)
+
+diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
+index 0ce7b83676..aefdda9ed7 100644
+--- a/arch/arm/mach-k3/am6_init.c
++++ b/arch/arm/mach-k3/am6_init.c
+@@ -141,6 +141,37 @@ void board_init_f(ulong dummy)
+ /* Make all control module registers accessible */
+ ctrl_mmr_unlock();
+
++#define MMC 0xdead0000
++#define EMMC 0xdead0001
++#define OSPI 0xdead0002
++#define UART 0xdead0003
++#define NOBOOT 0xdead0004
++#define BOOTMODE NOBOOT
++
++#if BOOTMODE == MMC
++ /* Set the boot mode to MMC/SD */
++ *((volatile uint32_t *)0x00100030) = 0x1006;
++ *((volatile uint32_t *)0x43000030) = 0x2db;
++#elif BOOTMODE == EMMC
++ /* Set the boot mode to EMMC */
++ *((volatile uint32_t *)0x00100030) = 0x000d;
++ *((volatile uint32_t *)0x43000030) = 0x2db;
++#elif BOOTMODE == OSPI
++ /* Set the boot mode to OSPI */
++ *((volatile uint32_t *)0x00100030) = 0x0001;
++ *((volatile uint32_t *)0x43000030) = 0x2db;
++#elif BOOTMODE == UART
++ /* Set the boot mode to UART */
++ *((volatile uint32_t *)0x00100030) = 0x000a;
++ *((volatile uint32_t *)0x43000030) = 0x2db;
++#elif BOOTMODE == NOBOOT
++ /* Set the boot mode to UART */
++ *((volatile uint32_t *)0x00100030) = 0x0000;
++ *((volatile uint32_t *)0x43000030) = 0x2db;
++#endif
++ /* Issue a system reset */
++ *((volatile uint32_t *)0x4301817C) = 0x0;
++
+ setup_am654_navss_northbridge();
+
+ #ifdef CONFIG_CPU_V7R
+--
+2.17.1
+
diff --git a/k3-bootswitch/boot_select/am65xx-evm/spl.emmc b/k3-bootswitch/boot_select/am65xx-evm/spl.emmc
new file mode 100644 (file)
index 0000000..2ffb183
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.emmc differ
index 0000000..2ffb183
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.emmc differ
diff --git a/k3-bootswitch/boot_select/am65xx-evm/spl.mmc b/k3-bootswitch/boot_select/am65xx-evm/spl.mmc
new file mode 100644 (file)
index 0000000..eafb3f3
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.mmc differ
index 0000000..eafb3f3
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.mmc differ
diff --git a/k3-bootswitch/boot_select/am65xx-evm/spl.noboot b/k3-bootswitch/boot_select/am65xx-evm/spl.noboot
new file mode 100644 (file)
index 0000000..03b0a8d
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.noboot differ
index 0000000..03b0a8d
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.noboot differ
diff --git a/k3-bootswitch/boot_select/am65xx-evm/spl.ospi b/k3-bootswitch/boot_select/am65xx-evm/spl.ospi
new file mode 100644 (file)
index 0000000..361bc74
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.ospi differ
index 0000000..361bc74
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.ospi differ
diff --git a/k3-bootswitch/boot_select/am65xx-evm/spl.uart b/k3-bootswitch/boot_select/am65xx-evm/spl.uart
new file mode 100644 (file)
index 0000000..04fa03d
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.uart differ
index 0000000..04fa03d
Binary files /dev/null and b/k3-bootswitch/boot_select/am65xx-evm/spl.uart differ
diff --git a/k3-bootswitch/boot_select/0001-HACK-Select-bootmode-and-reset.patch b/k3-bootswitch/boot_select/j721e-evm/0001-HACK-Select-bootmode-and-reset.patch
similarity index 100%
rename from k3-bootswitch/boot_select/0001-HACK-Select-bootmode-and-reset.patch
rename to k3-bootswitch/boot_select/j721e-evm/0001-HACK-Select-bootmode-and-reset.patch
rename from k3-bootswitch/boot_select/0001-HACK-Select-bootmode-and-reset.patch
rename to k3-bootswitch/boot_select/j721e-evm/0001-HACK-Select-bootmode-and-reset.patch
similarity index 100%
rename from k3-bootswitch/boot_select/spl.mmc
rename to k3-bootswitch/boot_select/j721e-evm/spl.mmc
rename from k3-bootswitch/boot_select/spl.mmc
rename to k3-bootswitch/boot_select/j721e-evm/spl.mmc
similarity index 100%
rename from k3-bootswitch/boot_select/spl.noboot
rename to k3-bootswitch/boot_select/j721e-evm/spl.noboot
rename from k3-bootswitch/boot_select/spl.noboot
rename to k3-bootswitch/boot_select/j721e-evm/spl.noboot
similarity index 100%
rename from k3-bootswitch/boot_select/spl.ospi
rename to k3-bootswitch/boot_select/j721e-evm/spl.ospi
rename from k3-bootswitch/boot_select/spl.ospi
rename to k3-bootswitch/boot_select/j721e-evm/spl.ospi
similarity index 100%
rename from k3-bootswitch/boot_select/spl.uart
rename to k3-bootswitch/boot_select/j721e-evm/spl.uart
rename from k3-bootswitch/boot_select/spl.uart
rename to k3-bootswitch/boot_select/j721e-evm/spl.uart
index 5e6e6ce4cdf93b2c9e9f10d97e35917c6275c0e8..2106762f71f16d55d8260270966fad74b538e994 100755 (executable)
# Utility script to select the bootmode from command line
# Author: Nikhil Devshatwar
+# No need to change anything below this line
+UMS_part1=/dev/disk/by-id/usb-Linux_UMS_disk*part1
+UMS_part2=/dev/disk/by-id/usb-Linux_UMS_disk*part2
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
-prefix=$SCRIPTPATH/bin
-boot_select=$SCRIPTPATH/boot_select
user=`logname`
-UMS_part1=/dev/disk/by-id/usb-Linux_UMS_disk*part1
-UMS_part2=/dev/disk/by-id/usb-Linux_UMS_disk*part2
-
-# Customize this as required
-uart_dev=/dev/ttyUSB0
-dev=1
-
usage()
{
+ echo
+ echo "dfu-boot.sh => Utility script to select bootmode and mount MMC to PC"
echo "Usage:"
- echo " dfu-boot.sh - Utility script to select bootmode and mount MMC to PC"
- echo " sudo ./dfu-boot.sh --mount DEV"
- echo " DEV: 1 for MMC, 0 for eMMC"
- echo " sudo ./dfu-boot.sh --bootmode MODE"
- echo " MODE: " `ls $boot_select/spl* | awk -F"." 'BEGIN{ORS=" "} { print $2 }'`
+ echo " sudo ./dfu-boot.sh PLATFORM --mount DEV | --bootmode MODE"
+ echo " PLATFORM: Either of --j721e-evm or --am65xx-evm"
+ echo " DEV: specify the device to mount => 1 for MMC, 0 for eMMC"
+ echo " MODE: specify the bootmode to use"
+}
+
+init() {
+board=$1
+ # Customize this as required
+ if [ "$board" = "j721e-evm" ]; then
+ uart_dev=/dev/ttyUSB0
+ switch=0
+ elif [ "$board" = "am65xx-evm" ]; then
+ uart_dev=/dev/ttyUSB4
+ switch=3
+ else
+ echo "Invalid board"
+ usage
+ exit 1
+ fi
+
+ prebuilt=$SCRIPTPATH/bin/$board
+ boot_select=$SCRIPTPATH/boot_select/$board
+}
+
+toggle_power()
+{
+switch=$1
+ echo " >>>> Toggling phidget..."
+ (phidget-switch $switch 0 && sleep 0.5 && phidget-switch $switch 1 && sleep 0.1) >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -n "ERROR: phidget not found, Reboot manually and press enter.. "
+ read DUMMY
+ fi
}
# Bootloader takes time to initialize
-# wait till then
+# wait till PC detects a dfu device
wait_till_ready() {
msg=$1
for i in `seq 30`; do
exit 1
}
-# Use dfu to send all bootloaders till you get to the
-# A72 u-boot prompt
+# Use dfu to send prebuilt binaries till you get to the
+# Cortex-A u-boot prompt
boot_till_uboot() {
wait_till_ready "for tiboot3.bin"
- 2>&1 dfu-util -R -a bootloader -D $prefix/tiboot3.bin
+ 2>&1 dfu-util -R -a bootloader -D $prebuilt/tiboot3.bin
wait_till_ready "for sysfw.itb"
- 2>&1 dfu-util -R -a sysfw.itb -D $prefix/sysfw.itb
+ 2>&1 dfu-util -R -a sysfw.itb -D $prebuilt/sysfw.itb
wait_till_ready "for tispl.bin"
- 2>&1 dfu-util -R -a tispl.bin -D $prefix/tispl.bin
+ 2>&1 dfu-util -R -a tispl.bin -D $prebuilt/tispl.bin
wait_till_ready "for u-boot.img"
- 2>&1 dfu-util -R -a u-boot.img -D $prefix/u-boot.img
+ 2>&1 dfu-util -R -a u-boot.img -D $prebuilt/u-boot.img
}
# Detect and mount the partitions
try_mount() {
+uart_dev=$1
+mdev=$2
for i in `seq 1 100`; do
- echo "ums 0 mmc $1" > $uart_dev
+ echo "ums 0 mmc $mdev" > $uart_dev
sleep 0.1
if [ -b $UMS_part1 ] && [ -b $UMS_part2 ]; then
mkdir -p /media/$user/UMS-boot
exit 1
}
-toggle_power()
-{
- echo " >>>> Toggling phidget..."
- (phidget-switch 0 0 && sleep 0.5 && phidget-switch 0 1 && sleep 0.1) >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo -n "ERROR: phidget not found, Reboot manually and press enter.. "
- read DUMMY
+# Send a boot_select binary
+change_bootmode() {
+bootmode=$1
+ if [ ! -f $boot_select/spl.$bootmode ]; then
+ echo "Invalid bootmode $bootmode"
+ options=`ls $boot_select/spl* | awk -F"." 'BEGIN{ORS=" "} { print $2 }'`
+ echo "Supported bootmodes for $board are: $options"
+ exit 1
+ fi
+
+ wait_till_ready
+ echo " >>>> Selecting bootmode: $bootmode"
+ dfu-util -R -a bootloader -D $boot_select/spl.$bootmode >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo " >>>> SUCCESS"
+ else
+ echo " >>>> FAILED"
fi
}
exit 1
fi
-if [ "$1" = "--mount" ]; then
- if [ ! -z "$2" ]; then
- dev=$2
- fi
- toggle_power
- boot_till_uboot >/dev/null
- try_mount $dev
-elif [ "$1" = "--bootmode" ]; then
- if [ ! -z "$2" ]; then
+while [[ $# -gt 0 ]]
+do
+case $1 in
+ --j7|--j721e|--j721e-evm)
+ init "j721e-evm"
+ shift
+ ;;
+ --am6|--am654|--am65x-evm)
+ init "am65xx-evm"
+ shift
+ ;;
+ -m|--mount)
+ mdev=$2
+ shift
+ shift
+ ;;
+ -b|--bootmode)
bootmode=$2
- fi
- if [ ! -f $boot_select/spl.$bootmode ]; then
- echo "Invalid bootmode $bootmode"
+ shift
+ shift
+ ;;
+ -h|--help)
usage
- exit 2
- fi
+ exit 0
+ ;;
+ *)
+ echo "Invalid argument $1"
+ usage
+ exit 1
+ ;;
+esac
+done
- toggle_power
- wait_till_ready
- echo " >>>> Selecting bootmode: $bootmode"
- dfu-util -R -a bootloader -D $boot_select/spl.$bootmode >/dev/null 2>&1
- if [ $? -eq 0 ]; then
- echo " >>>> SUCCESS"
- else
- echo " >>>> FAILED"
- fi
+init $board
+if [ ! -z $bootmode ]; then
+ # Reboot the board in specified bootmode
+ toggle_power $switch
+ change_bootmode $bootmode
+
+elif [ ! -z $mdev ]; then
+ # Reboot the board and mount the specified device
+ toggle_power $switch
+ boot_till_uboot >/dev/null
+ try_mount $uart_dev $mdev
else
- echo " Invalid usage"
+ echo "Invalid usage!!"
usage
fi