[aadk-commits] qwell: uClinux/trunk r339 - /uClinux/trunk/uClinux-dist/vendors/Digium/S800I/...

aadk-commits at lists.digium.com aadk-commits at lists.digium.com
Mon Apr 16 11:25:50 MST 2007


Author: qwell
Date: Mon Apr 16 13:25:50 2007
New Revision: 339

URL: http://svn.digium.com/view/aadk?view=rev&rev=339
Log:
Add local file support to flashupdate.

Combine bootloaderupdate script with flashupdate script.
There isn't much different, so no need for different scripts.

bootloaderupdate is a symlink to flashupdate, but when copied
 to the romfs, it becomes a copy, and not a symlink.
This should be fixed eventually.

Added:
    uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate   (with props)
Modified:
    uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/flashupdate

Added: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate?view=auto&rev=339
==============================================================================
--- uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate (added)
+++ uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate Mon Apr 16 13:25:50 2007
@@ -1,0 +1,1 @@
+link flashupdate

Propchange: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/bootloaderupdate
------------------------------------------------------------------------------
    svn:special = *

Modified: uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/flashupdate
URL: http://svn.digium.com/view/aadk/uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/flashupdate?view=diff&rev=339&r1=338&r2=339
==============================================================================
--- uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/flashupdate (original)
+++ uClinux/trunk/uClinux-dist/vendors/Digium/S800I/scripts/flashupdate Mon Apr 16 13:25:50 2007
@@ -1,60 +1,107 @@
 #!/bin/sh
+# Script for reflashing uClinux or u-boot image to SPI flash
+SCRIPTNAME=`basename $0`
+case ${SCRIPTNAME} in
+	"flashupdate" )
+		DEFAULTFILENAME=uImage
+		MTDPART=/dev/mtd3
+		;;
+	"bootloaderupdate" )
+		DEFAULTFILENAME=app.ldr
+		MTDPART=/dev/mtd1
+		;;
+	* )
+		echo "Could not determine what to update.  Exiting."
+		exit 1
+		;;
+esac
 PID=$$
-# Script for reflashing uCLinux image to SPI FLASH 
+SAVEDFILENAME=/tmp/image-${PID}.bin
+NVRAMFILENAME=/tmp/nvram-${PID}.txt
 if [ "$1" = "" ]; then
-	echo "Usage: flashupdate <imageURL>"
-	echo "       OR flashupdate tftp <hostname> [<filename>]"
+	echo "Usage: ${SCRIPTNAME} <imageURL>"
+	echo "       OR ${SCRIPTNAME} tftp <hostname> [<filename>]"
+	echo "       OR ${SCRIPTNAME} file [</path/to/filename>]"
 	exit 1
 fi
 
 # Get the image from the source
 if [ "$1" = "tftp" ]; then
+	if [ "$2" = "" ]; then
+		echo "Must specify a hostname when downloading firmware via TFTP."
+		exit 1
+	fi
 	HOST=$2
 	if [ "$3" = "" ]; then
-			FILENAME=uImage
+			FILENAME=${DEFAULTFILENAME}
 	else
 			FILENAME=$3
 	fi
-	echo "Downloading $FILENAME from host $HOST"
-	tftp -l /tmp/image-${PID}.bin -r ${FILENAME} -g ${HOST}
+	echo "Downloading ${FILENAME} from host ${HOST} via TFTP"
+	tftp -l ${SAVEDFILENAME} -r ${FILENAME} -g ${HOST}
 	if [ "$?" != "0" ]; then 
-		echo "TFTP Download of firmware failed!"
-		rm -f /tmp/image-${PID}.bin
+		echo "Downloading firmware via TFTP failed!"
+		rm -f ${SAVEDFILENAME}
 		exit 1
 	fi
 else
-	FILEURL=$1
-	echo "Downloading URL ${FILEURL}"
-	wget ${FILEURL} -O /tmp/image-${PID}.bin
-	if [ "$?" != "0" ]; then 
-		echo "wget Download of firmware failed!"
-		rm -f /tmp/image-${PID}.bin
-		exit 1
+	if [ "$1" = "file" ]; then
+		if [ "$2" = "" ]; then
+				FILENAME=${DEFAULTFILENAME}
+		else
+				FILENAME=$2
+		fi
+		SAVEDFILENAME=${FILENAME}
+	else
+		if [ "$1" = "" ]; then
+			echo "Must specify a URL when downloading firmware via wget."
+			exit 1
+		fi
+		FILEURL=$1
+		echo "Downloading URL ${FILEURL}"
+		wget ${FILEURL} -O ${SAVEDFILENAME}
+		if [ "$?" != "0" ]; then 
+			echo "Downloading firmware via wget failed!"
+			rm -f ${SAVEDFILENAME}
+			exit 1
+		fi
 	fi
 fi
 
+if [ ! -f "${SAVEDFILENAME}" ]; then
+	echo "File ${SAVEDFILENAME} does not exist."
+	exit 1
+fi
+
 # Commit the image to FLASH 
-FILESIZE=`ls -l /tmp/image-${PID}.bin | cut -c 30-42 | xargs basename`
-echo "Downloaded firmware /tmp/image-${PID} is size ${FILESIZE}"
-#	echo "Stopping Asterisk..."
-#	asterisk -rx "stop now"
-#	echo "Unloading driver..."
-#	rmmod sx00i
+FILESIZE=`ls -l ${SAVEDFILENAME} | cut -c 30-42 | xargs basename`
+echo "Downloaded firmware ${SAVEDFILENAME} is size ${FILESIZE}"
+
+# Save a copy of the environment
+nvram dump ${NVRAMFILENAME}
+
 echo "Writing firmware to FLASH -- DO NOT REBOOT!!!!..."
-dd bs=65536 if=/tmp/image-${PID}.bin of=/dev/mtd3 conv=sync 2>/dev/null
+dd bs=65536 if=${SAVEDFILENAME} of=${MTDPART} conv=sync 2>/dev/null
 echo -n "Verifying FLASH..."
-if cmp /tmp/image-${PID}.bin /dev/mtd3 2>&1 | grep -q -i EOF; then
+if cmp ${SAVEDFILENAME} ${MTDPART} 2>&1 | grep -q -i EOF; then
 	echo "PASSED"
 else
 	echo "FAILED"
-	cmp /tmp/image-${PID}.bin /dev/mtd3
+	cmp ${SAVEDFILENAME} ${MTDPART}
 fi
-echo "Finished writing firmware to FLASH -- Updating NVRAM..."
-rm -f /tmp/image-${PID}.bin
-# Place the size of image into u-boot environment so it knows # bytes to load 
-nvram dump /tmp/nvram-${PID}.txt
-cat /tmp/nvram-${PID}.txt | grep -v "readsize=" > /tmp/nvram-${PID}.new
-printf "readsize=%x\\n" ${FILESIZE} >> /tmp/nvram-${PID}.new
-nvram store /tmp/nvram-${PID}.new
-rm -f /tmp/nvram-${PID}.new
-rm -f /tmp/nvram-${PID}.txt
+rm -f ${SAVEDFILENAME}
+echo "Finished writing firmware to FLASH..."
+echo "Updating environment..."
+case ${SCRIPTNAME} in
+	"flashupdate" )
+		# Place the size of image into u-boot environment so it knows # bytes to load 
+		cat ${NVRAMFILENAME} | grep -v "readsize=" > ${NVRAMFILENAME}.new
+		printf "readsize=%x\\n" ${FILESIZE} >> ${NVRAMFILENAME}.new
+		mv ${NVRAMFILENAME}.new ${NVRAMFILENAME}
+		;;
+	* )
+		# Don't need to do anything special for the rest.
+		;;
+esac
+nvram store ${NVRAMFILENAME}
+rm -f ${NVRAMFILENAME}



More information about the aadk-commits mailing list