k3-bootswitch: Add config file for personalization
authorNikhil Devshatwar <nikhil.nd@ti.com>
Fri, 21 Aug 2020 10:18:49 +0000 (15:48 +0530)
committerNikhil Devshatwar <nikhil.nd@ti.com>
Wed, 26 Aug 2020 07:12:57 +0000 (12:42 +0530)
Copy this file to your own $HOME/config/k3bootswitch.conf
and customize as required.
The script will use the variables from the config file.
Customize the tty device, power switch and other parameters
for every board

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
k3-bootswitch/dfu-boot.sh
k3-bootswitch/k3bootswitch.conf [new file with mode: 0644]

index 20ecffc8f3cadc258f50c22776c51098fcfa782e..48c32171288aaa86e9d4915c067e97449f3158b0 100755 (executable)
@@ -21,29 +21,31 @@ usage()
        echo "    ADDRESS: specify the IP address for tftp/NFS boot"
 }
 
+read_config() {
+configfile=$HOME/.config/k3bootswitch.conf
+section=$1
+param=$2
+
+       python3 -c "
+import configparser;
+import sys;
+config = configparser.ConfigParser();
+config.read('$configfile');
+print (config.get('$section','$param'));
+"
+}
+
 init() {
 board=$1
-       # Customize this as required
-       if [ "$board" = "j721e-evm" ]; then
-               uart_dev=/dev/ttyUSB12
-               nfspath=$HOME/targetfs/coresdk70
-               switch=0
-       elif [ "$board" = "j7200-evm" ]; then
-               uart_dev=/dev/ttyUSB4
-               nfspath=$HOME/targetfs/coresdk70
-               switch=2
-       elif [ "$board" = "am65xx-evm" ]; then
-               uart_dev=/dev/ttyUSB8
-               nfspath=$HOME/targetfs/coresdk70
-               switch=3
-       else
-               echo "Invalid board"
-               usage
-               exit 1
-       fi
 
        prebuilt=$SCRIPTPATH/bin/$board
        boot_select=$SCRIPTPATH/boot_select/$board
+
+       uart_dev=`read_config $board uart_dev`
+       nfspath=`read_config $board nfspath`
+       switch=`read_config $board switch`
+
+       ipaddr=`read_config core ipaddr`
 }
 
 toggle_power()
diff --git a/k3-bootswitch/k3bootswitch.conf b/k3-bootswitch/k3bootswitch.conf
new file mode 100644 (file)
index 0000000..584ba20
--- /dev/null
@@ -0,0 +1,17 @@
+[core]
+ipaddr = 10.24.xx.xxx
+
+[j721e-evm]
+       switch = 0
+       uart_dev = /dev/ttyUSB0
+       nfspath = ~/targetfs/coresdk70
+
+[j7200-evm]
+       switch = 1
+       uart_dev = /dev/ttyUSB6
+       nfspath = ~/targetfs/coresdk70
+
+[am65xx-evm]
+       switch = 2
+       uart_dev = /dev/ttyUSB12
+       nfspath = ~/targetfs/coresdk70