* Also refuse to proceed if not upgrading update from MCSDK

Signed-off-by: Jacob Stiffler <[email protected]>
---
 setup-uboot-env-keystone.sh | 74 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 60 insertions(+), 14 deletions(-)

diff --git a/setup-uboot-env-keystone.sh b/setup-uboot-env-keystone.sh
index b709cd6..750b8cf 100755
--- a/setup-uboot-env-keystone.sh
+++ b/setup-uboot-env-keystone.sh
@@ -215,26 +215,67 @@ check_for_board() {
 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
-do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
-do_expect "\"U-Boot#\"" "send \"reset\"" $cwd/setupBoard.minicom
+
+if [ "$ubootupdate" != "y" ]; then
+       # If not updating U-Boot, refure to procede if running an old MCSDK 
version.
+       cat >> $cwd/setupBoard.minicom << '__EOF__'
+expect {
+    "U-Boot#"
+    "# " goto uboot_update_required
+    timeout 60 goto end
+}
+send " "
+__EOF__
+fi
+
+# Reset to the default environment
+do_expect "\"# \"" "send \"env default -f -a\"" $cwd/setupBoard.minicom
+do_expect "\"# \"" "send \"saveenv\"" $cwd/setupBoard.minicom
+
+# Reset incase any variables are set when u-boot initializes
+do_expect "\"# \"" "send \"reset\"" $cwd/setupBoard.minicom
 do_expect "\"stop autoboot:\"" "send \" \"" $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
+# Set vars required to flash u-boot
+do_expect "\"# \"" "send \"setenv serverip $ip\"" $cwd/setupBoard.minicom
+do_expect "\"# \"" "send \"setenv tftp_root '$tftproot'\"" 
$cwd/setupBoard.minicom
+do_expect "\"# \"" "send \"setenv name_uboot $ubootimage\"" 
$cwd/setupBoard.minicom
 
 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
+       # Use common "burn_uboot" command
+       do_expect "\"# \"" "send \"if test -n \$burn_uboot_spi; then setenv 
burn_uboot \$burn_uboot_spi; fi\"" $cwd/setupBoard.minicom
+
+       # Create command to print a known message if u-boot update succeeds
+       update_uboot_success="U-Boot successfully updated"
+
+       # Create command to fetch and flash u-boot
+       do_expect "\"# \"" "send \"setenv update_uboot 'if run get_uboot_net 
burn_uboot; then echo $update_uboot_success; else echo U-boot update failed!; 
fi'\"" $cwd/setupBoard.minicom
+       do_expect "\"# \"" "send \"run update_uboot\"" $cwd/setupBoard.minicom
+
+       do_expect "\"$update_uboot_success\"" "send \"reset\"" 
$cwd/setupBoard.minicom
+
+       # Reset once to get new u-boot
+       do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
+
+       # Reset environment to the new U-Boot's defaults
+       do_expect "\"U-Boot#\"" "send \"env default -f -a\"" 
$cwd/setupBoard.minicom
+       do_expect "\"U-Boot#\"" "send \"saveenv\"" $cwd/setupBoard.minicom
+
+       # Reset a second time incase any variables are set when u-boot 
initializes
        do_expect "\"U-Boot#\"" "send \"reset\"" $cwd/setupBoard.minicom
        do_expect "\"stop autoboot:\"" "send \" \"" $cwd/setupBoard.minicom
+
+       # Reinitialize any variables previously set
+       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 name_uboot $ubootimage\"" 
$cwd/setupBoard.minicom
 fi
 
+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 \"saveenv\"" $cwd/setupBoard.minicom
+
 if [ "$secondary_boot" -eq "1" ]; then
        #TFTP and NFS Boot
        do_expect "\"U-Boot#\"" "send \"setenv boot net\"" 
$cwd/setupBoard.minicom
@@ -248,8 +289,13 @@ 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
+cat >> $cwd/setupBoard.minicom << __EOF__
+goto end
+uboot_update_required:
+send echo; echo "*** U-boot is require to be updated before proceding!"; echo 
"*** Please re-run setup.sh and choose to update U-boot."; echo
+end:
+__EOF__
+#echo "! killall -s SIGHUP minicom" >> $cwd/setupBoard.minicom
 
 echo 
"--------------------------------------------------------------------------------"
 echo "Would you like to create a minicom script with the above parameters 
(y/n)?"
-- 
1.9.1

_______________________________________________
meta-arago mailing list
[email protected]
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago

Reply via email to