]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/host-tools.git/commitdiff
dfu-boot: Support using RPS instead of phidget master
authorJai Luthra <j-luthra@ti.com>
Wed, 16 Feb 2022 15:01:56 +0000 (20:31 +0530)
committerJai Luthra <j-luthra@ti.com>
Wed, 16 Feb 2022 15:01:56 +0000 (20:31 +0530)
* Update documentation to reflect both phidget and RPS as options
* Add switch_type config to select power toggle mechanism: [phidget, rps]
* Add rps_dev config to select UART device of the rps
* Default to phidget if unspecified, for backcompat with older configs

Signed-off-by: Jai Luthra <j-luthra@ti.com>
k3-bootswitch/README.rst
k3-bootswitch/dfu-boot.sh
k3-bootswitch/k3bootswitch.conf

index fee5328735135d609e5bc3881a47dbf827ddfd78..21d684600beb346ba47d5514b3d8b03e45d553cb 100644 (file)
@@ -14,7 +14,8 @@ Hardware setup
   DFU boot is only supported from this port.
 * UART cable should be connected from the main_uart to Linux PC
 * Default switch settings should be for DFU boot mode
-* Power supply to the board should be connected via phidget USB relay
+* Power supply to the board should be connected via phidget USB relay,
+  or a UART Remote Power Switch.
 
 
 Switch settings for DFU boot mode
@@ -25,10 +26,10 @@ Switch settings for DFU boot mode
 * am65xx-evm settings => SW2 = 0000 0000 00   SW3 = 0001 0000 00   SW4 = 11
 * am64xx-evm settings => SW2 = 1100 1010      SW3 = 0011 0000
 
-Phidget setup
--------------
+Power toggling setup
+--------------------
 
-This script uses phidget to control power for restarting the boards.
+This script uses phidget or RPS to control power for restarting the boards.
 Since everyone has different configuration, the script parses the data from a
 config file. You can copy the template as follows and then customize as required.
 
@@ -59,10 +60,14 @@ differnent mechanism, update the **dfu-boot.sh** script with following:
   for main uart. (The one where all u-boot/SBL/kernel logs appear)
 * Update the **switch** variable to reflect the correct switch number  which
   controls the power via phidget
-* If you have a different mechanism to power the board, write your own implementation
-  for **toggle_power** function instead of the default phidget commands
-
-Limitatinos
+* Update the **switch_type** variable to select the mechanism for toggling
+  power of the board (phidget/rps)
+* If using RPS instead of phidget, also update the **rps_dev** variable with
+  the UART device of RPS.
+* If you have a different mechanism to power the board, write your own
+  implementation and update **toggle_util** variable in the script.
+
+Limitations
 -----------
 
 * Do not use this mechanism to measure any boot time numbers
index 248c5b913ca614b951a8782d015822d62ff9fef1..8614acbe67a81b59107eb8598d8e6d839edf1fea 100755 (executable)
@@ -31,7 +31,7 @@ import configparser;
 import sys;
 config = configparser.ConfigParser();
 config.read('$configfile');
-print (config.get('$section','$param'));
+print (config['$section'].get('$param',''));
 "
 }
 
@@ -46,15 +46,32 @@ board=$1
        switch=`read_config $board switch`
 
        ipaddr=`read_config core ipaddr`
+       switch_type=`read_config core switch_type`
+
+       # Select toggle utility (phidget or rps)
+       case $switch_type in
+               rps)
+                       rps_dev=`read_config core rps_dev`
+                       if [ -z "$rps_dev" ]; then
+                               >&2 echo "    >>>> ERROR: RPS uart device is missing in the config"
+                               >&2 echo "    >>>>        Refer to the readme and set rps_dev = /dev/ttyUSB*"
+                               exit 1
+                       fi
+                       toggle_util="$SCRIPTPATH/rps/rps.sh $rps_dev"
+                       ;;
+               phidget | *)
+                       toggle_util=phidget-switch
+                       ;;
+       esac
 }
 
 toggle_power()
 {
 switch=$1
-       echo "    >>>> Toggling phidget..."
-       (phidget-switch $switch 0 && sleep 1 && phidget-switch $switch 1 && sleep 0.1) >/dev/null 2>&1
+       echo "    >>>> Toggling power..."
+       ($toggle_util $switch 0 && sleep 1 && $toggle_util $switch 1 && sleep 0.1) >/dev/null 2>&1
        if [ $? -ne 0 ]; then
-               echo -n "ERROR: phidget not found, Reboot manually and press enter.. "
+               echo -n "ERROR: toggle utility '$toggle_util' not found, Reboot manually and press enter.. "
                read DUMMY
        fi
 }
index 59f3527deca840361d6ff0f0ce5cbded0db22dd2..5790c75329bb6f93d524f3cf18ac3d2238743674 100644 (file)
@@ -1,5 +1,11 @@
 [core]
        ipaddr = 10.24.xx.xxx
+       # Default switch type is Phidget
+       switch_type = phidget
+       # To use RPS comment the above, and uncomment the following
+       # with correct UART device
+       #switch_type = rps
+       #rps_dev = /dev/ttyUSB4
 
 [j721e-evm]
        switch = 0