Skip to contentSkip to conversation

setup-tftp: Also copy boot-monitor and u-boot.gph

PATCH New Jacob Stiffler 1 participant 2 messages Oct 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 setup-tftp: Also copy boot-monitor and u-boot.gph

* This is required for keystone devices

---
 setup-tftp.sh | 60 ++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 35 insertions(+), 25 deletions(-)
setup-tftp.sh +35 -25
index 3428c73..714968f 100644
@@ -55,6 +55,34 @@ disable = no
      echo "$tftpcfg successfully created"
 }
 
+prebuiltimagesdir=`cd $cwd/../board-support/prebuilt-images/ ; echo $PWD`
+copy_to_tftproot() {
+    files="$1"
+    for file in $files
+    do
+	if [ -f $tftproot/$file ]; then
+	    echo
+	    echo "$tftproot/$file already exists. The existing installed file can be renamed and saved under the new name."
+	    echo "(o) overwrite (s) skip copy "
+	    read -p "[o] " exists
+	    case "$exists" in
+	      s) echo "Skipping copy of $file, existing version will be used"
+		 ;;
+	      *) sudo cp "$prebuiltimagesdir/$file" $tftproot
+		 check_status
+		 echo
+		 echo "Successfully overwritten $file in tftp root directory $tftproot"
+		 ;;
+	    esac
+	else
+	    sudo cp "$prebuiltimagesdir/$file" $tftproot
+	    check_status
+	    echo
+	    echo "Successfully copied $file to tftp root directory $tftproot"
+	fi
+    done
+}
+
 echo "--------------------------------------------------------------------------------"
 echo "Which directory do you want to be your tftp root directory?(if this directory does not exist it will be created for you)"
 read -p "[ $tftprootdefault ] " tftproot
@@ -122,32 +150,14 @@ else
     echo "Successfully copied $kernelimage to tftp root directory $tftproot"
 fi
 
-dtbfiles=`cd $cwd/../board-support/prebuilt-images/;ls -1 *.dtb`
-prebuiltimagesdir=`cd $cwd/../board-support/prebuilt-images/ ; echo $PWD`
+dtbfiles=`cd $prebuiltimagesdir;ls -1 *.dtb`
+copy_to_tftproot "$dtbfiles"
 
-for dtbfile in $dtbfiles
-do
-    if [ -f $tftproot/$dtbfile ]; then
-        echo
-        echo "$tftproot/$dtbfile already exists. The existing installed file can be renamed and saved under the new name."
-        echo "(o) overwrite (s) skip copy "
-        read -p "[o] " exists
-        case "$exists" in
-          s) echo "Skipping copy of $dtbfile, existing version will be used"
-             ;;
-          *) sudo cp "$prebuiltimagesdir/$dtbfile" $tftproot
-             check_status
-             echo
-             echo "Successfully overwritten $$dtbfile in tftp root directory $tftproot"
-             ;;
-        esac
-    else
-        sudo cp "$prebuiltimagesdir/$dtbfile" $tftproot
-        check_status
-        echo
-        echo "Successfully copied $dtbfile to tftp root directory $tftproot"
-    fi
-done
+uboot_gph_files=`cd $prebuiltimagesdir;ls -1 u-boot*.gph 2> /dev/null`
+copy_to_tftproot "$uboot_gph_files"
+
+monfiles=`cd $prebuiltimagesdir;ls -1 skern*.bin 2> /dev/null`
+copy_to_tftproot "$monfiles"
 
 echo
 if [ -f $tftpcfg ]; then
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 setup-uboot-env-keystone: Add u-boot env setup for keystone devices

---
 ...nv-am57xx-evm.sh => setup-uboot-env-keystone.sh | 188 ++++++++++++++-------
 1 file changed, 123 insertions(+), 65 deletions(-)
 copy setup-uboot-env-am57xx-evm.sh => setup-uboot-env-keystone.sh (61%)
 mode change 100644 => 100755
setup-uboot-env-keystone.sh renamed from setup-uboot-env-am57xx-evm.sh +123 -65
old mode 100644
new mode 100755
similarity index 61%
copy from setup-uboot-env-am57xx-evm.sh
copy to setup-uboot-env-keystone.sh
index ae95368..71e407d
@@ -38,6 +38,7 @@ do_expect() {
     check_status
     echo "    $1" >> $3
     check_status
+    echo "    timeout 600 goto end" >> $3
     echo "}" >> $3
     check_status
     echo $2 >> $3
@@ -45,6 +46,32 @@ do_expect() {
     echo >> $3
 }
 
+copy_to_tftproot() {
+    files="$1"
+    for file in $files
+    do
+	if [ -f $tftproot/$file ]; then
+	    echo
+	    echo "$tftproot/$file already exists. The existing installed file can be renamed and saved under the new name."
+	    echo "(o) overwrite (s) skip copy "
+	    read -p "[o] " exists
+	    case "$exists" in
+	      s) echo "Skipping copy of $file, existing version will be used"
+		 ;;
+	      *) sudo cp "$prebuiltimagesdir/$file" $tftproot
+		 check_status
+		 echo
+		 echo "Successfully overwritten $file in tftp root directory $tftproot"
+		 ;;
+	    esac
+	else
+	    sudo cp "$prebuiltimagesdir/$file" $tftproot
+	    check_status
+	    echo
+	    echo "Successfully copied $file to tftp root directory $tftproot"
+	fi
+    done
+}
 
 echo
 echo "--------------------------------------------------------------------------------"
@@ -54,7 +81,6 @@ echo "--------------------------------------------------------------------------
 ipdefault=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'`
 platform=`grep PLATFORM= $cwd/../Rules.make | cut -d= -f2`
 
-
 echo "Autodetected the following ip address of your host, correct it if necessary"
 read -p "[ $ipdefault ] " ip
 echo
@@ -63,6 +89,18 @@ if [ ! -n "$ip" ]; then
     ip=$ipdefault
 fi
 
+if [ -f $cwd/../.tftproot ]; then
+    tftproot=`cat $cwd/../.tftproot`
+else
+    echo "Where is your tftp root directory?"
+    read -p "[ /tftpboot ]" tftproot
+
+    if [ ! -n "$tftproot" ]; then
+        tftproot="/tftpboot"
+    fi
+    echo
+fi
+
 if [ -f $cwd/../.targetfs ]; then
     rootpath=`cat $cwd/../.targetfs`
 else
@@ -75,38 +113,47 @@ else
     echo
 fi
 
+
 kernelimage="zImage-""$platform"".bin"
 kernelimagesrc=`ls -1 $cwd/../board-support/prebuilt-images/$kernelimage`
 kernelimagedefault=`basename $kernelimagesrc`
 
+ubootimage="u-boot-spi-${platform}.gph"
+
+ubifsimage="tisdk-server-rootfs-image-${platform}.ubi"
+ubifsimagesrc=`ls -1 $cwd/../filesystem/$ubifsimage`
+ubifsimagedefault=`basename $ubifsimagesrc`
 
-echo "Select Linux kernel location:"
-echo " 1: TFTP"
-echo " 2: SD card"
+prebuiltimagesdir=`cd $cwd/../filesystem/ ; echo $PWD`
+ubifsimages=`cd $prebuiltimagesdir;ls -1 *.ubi 2> /dev/null`
+copy_to_tftproot "$ubifsimages"
+
+
+echo "--------------------------------------------------------------------------------"
+echo "Would you like to update U-boot on the board (y/n)?"
+read -p "[ y ] " ubootupdate
 echo
-read -p "[ 1 ] " kernel
 
-if [ ! -n "$kernel" ]; then
-    kernel="1"
+if [ ! -n "$ubootupdate" ]; then
+    ubootupdate="y"
 fi
 
-echo
-echo "Select root file system location:"
+
+echo "Select secondary boot:"
 echo " 1: NFS"
-echo " 2: SD card"
+echo " 2: UBI"
 echo
-read -p "[ 1 ] " fs
+read -p "[ 1 ] " secondary_boot
 
-if [ ! -n "$fs" ]; then
-    fs="1"
+if [ ! -n "$secondary_boot" ]; then
+    secondary_boot="1"
 fi
 
 
-
-if [ "$kernel" -eq "1" ]; then
+if [ "$secondary_boot" -eq "1" ]; then
     echo
-    echo "Available kernel images in /tftproot:"
-    for file in /tftpboot/*; do
+    echo "Available kernel images in $tftproot:"
+    for file in $tftproot/*; do
 	basefile=`basename $file`
 	echo "    $basefile"
     done
@@ -117,6 +164,21 @@ if [ "$kernel" -eq "1" ]; then
     if [ ! -n "$kernelimage" ]; then
 	kernelimage=$kernelimagedefault
     fi
+else
+    echo
+    echo "Available ubi images in $tftproot:"
+    for file in $tftproot/*-${platform}.ubi; do
+	basefile=`basename $file`
+	echo "    $basefile"
+    done
+    echo
+    echo "Which ubi image do you want to boot?"
+    read -p "[ $ubifsimagedefault ] " ubifsimage
+
+    if [ ! -n "$ubifsimage" ]; then
+	ubifsimage=$ubifsimagedefault
+    fi
+    kernelimage=zImage
 fi
 
 board="unknown"
@@ -127,9 +189,16 @@ check_for_board() {
     then
         board="x15"
     fi
+
+    lsusb -vv -d 0403:6010 > /dev/null 2>&1
+
+    if [ "$?" = "0" ]
+    then
+        board="k2hk"
+    fi
 }
 
-echo "timeout 300" > $cwd/setupBoard.minicom
+echo "timeout 1800" > $cwd/setupBoard.minicom
 echo "verbose on" >> $cwd/setupBoard.minicom
 do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
 do_expect "\"U-Boot#\"" "send \"env default -f -a\"" $cwd/setupBoard.minicom
@@ -137,51 +206,35 @@ do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
 do_expect "\"U-Boot#\"" "send \"reset\"" $cwd/setupBoard.minicom
 do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
 
-if [ "$kernel" -eq "1" ]; then
-	if [ "$fs" -eq "1" ]; then
-		#TFTP and NFS Boot
-		do_expect "\"U-Boot#\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv rootpath '$rootpath'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv bootfile $kernelimage\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv ip_method dhcp\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv nfsopts 'nolock,v3,tcp,rsize=4096,wsize=4096'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv getuenv 'mmc dev \${mmcdev}; if mmc rescan; then if run loadbootenv; then run importbootenv; fi; fi;'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv bootcmd 'run findfdt; run getuenv; setenv autoload no;dhcp ;tftp \${loadaddr} $kernelimage; tftp \${fdtaddr} \${fdtfile}; run netargs; bootz \${loadaddr} - \${fdtaddr}'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"boot\"" $cwd/setupBoard.minicom
-	else
-		#TFTP and SD Boot
-		do_expect "\"U-Boot#\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv bootfile $kernelimage\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv ip_method none\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv getuenv 'mmc dev \${mmcdev}; if mmc rescan; then if run loadbootenv; then run importbootenv; fi; fi;'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv bootcmd 'run findfdt; run getuenv; setenv autoload no; dhcp ; tftp \${loadaddr} $kernelimage; tftp \${fdtaddr} \${fdtfile}; run mmcargs; bootz \${loadaddr} - \${fdtaddr}'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"boot\"" $cwd/setupBoard.minicom
-	fi
-else
-	if [ "$fs" -eq "1" ]; then
-		#SD and NFS Boot
-		do_expect "\"U-Boot#\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv rootpath '$rootpath'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv bootfile zImage\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv ip_method dhcp\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv nfsopts 'nolock,v3,tcp,rsize=4096,wsize=4096'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv getuenv 'mmc dev \${mmcdev}; if mmc rescan; then if run loadbootenv; then run importbootenv; fi; fi;'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv bootcmd 'setenv autoload no; mmc rescan; run findfdt; run getuenv; run loadimage; run loadfdt; run netargs; bootz \${loadaddr} - \${fdtaddr}'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"boot\"" $cwd/setupBoard.minicom
-	    else
-		#SD and SD boot.
-		do_expect "\"U-Boot#\"" "send \"setenv ip_method none\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv bootfile zImage\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"setenv getuenv 'mmc dev \${mmcdev}; if mmc rescan; then if run loadbootenv; then run importbootenv; fi; fi;'\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send setenv bootcmd 'mmc rescan; run findfdt; run getuenv; run loadimage; run loadfdt; run mmcargs; bootz \${loadaddr} - \${fdtaddr}'" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-		do_expect "\"U-Boot#\"" "send \"boot\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send setenv tftp_root '$tftproot'" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send setenv nfs_root '$rootpath'" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"setenv name_ubi $ubifsimage\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"setenv name_kern $kernelimage\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"setenv name_uboot $ubootimage\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
 
-	fi
+if [ "$ubootupdate" = "y" ]; then
+	do_expect "\"U-Boot#\"" "send \"run get_uboot_net\"" $cwd/setupBoard.minicom
+	do_expect "\"U-Boot#\"" "send \"run burn_uboot_spi\"" $cwd/setupBoard.minicom
+	do_expect "\"U-Boot#\"" "send \"reset\"" $cwd/setupBoard.minicom
+	do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
 fi
+
+if [ "$secondary_boot" -eq "1" ]; then
+	#TFTP and NFS Boot
+	do_expect "\"U-Boot#\"" "send \"setenv boot net\"" $cwd/setupBoard.minicom
+else
+	#SD and NFS Boot
+	do_expect "\"U-Boot#\"" "send \"run get_ubi_net\"" $cwd/setupBoard.minicom
+	do_expect "\"U-Boot#\"" "send \"run burn_ubi\"" $cwd/setupBoard.minicom
+	do_expect "\"U-Boot#\"" "send \"setenv boot ubi\"" $cwd/setupBoard.minicom
+fi
+
+do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
+do_expect "\"U-Boot#\"" "send \"boot\"" $cwd/setupBoard.minicom
+
+echo "end:" >> $cwd/setupBoard.minicom
 echo "! killall -s SIGHUP minicom" >> $cwd/setupBoard.minicom
 
 echo "--------------------------------------------------------------------------------"
@@ -202,7 +255,7 @@ if [ "$minicom" = "y" ]; then
     do
         check_for_board
 
-        if [ "$board" = "x15" ]
+        if [ "$board" = "k2hk" ]
         then
             break
         else
@@ -223,21 +276,26 @@ if [ "$minicom" = "y" ]; then
         while [ yes ]
         do
             echo ""
+            echo "--------------------------------------------------------------------------------"
+            echo
             echo -n "Detecting connection to board... "
             loopCount=0
-            port=`dmesg | grep FTDI | grep "tty" | tail -1 | grep "attached" |  awk '{ print $NF }'`
+            usb_id=`dmesg | grep 'idVendor=0403' | grep 'idProduct=6010' | tail -1 | sed -e 's|.*usb \(.*\):.*|\1|'`
+            port=`dmesg  | grep FTDI | grep "$usb_id" | grep "tty" | tail -2 | head -1 | grep "attached" |  awk '{ print $NF }'`
             while [ -z "$port" ] && [ "$loopCount" -ne "10" ]
             do
                 #count to 10 and timeout if no connection is found
                 loopCount=$((loopCount+1))
 
                 sleep 1
-                port=`dmesg  | grep FTDI | grep "tty" | tail -1 | grep "attached" |  awk '{ print $NF }'`
+                usb_id=`dmesg | grep 'idVendor=0403' | grep 'idProduct=6010' | tail -1 | sed -e 's|.*usb \(.*\):.*|\1|'`
+                port=`dmesg  | grep FTDI | grep "$usb_id" | grep "tty" | tail -2 | head -1 | grep "attached" |  awk '{ print $NF }'`
             done
 
             #check to see if we actually found a port
             if [ -n "$port" ]; then
-                echo "/dev/$port"
+                echo "k2hk-evm connected at /dev/$port"
+                echo
                 break;
             fi
 
Signature · 1 line
1.9.1