Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # $Header: /vobs/cm/route66/software/tools/firmware/firmware_update_components/lk/fwUpdate.sh /main/15 21-Nov-2014.11:28:50 zkoppert $
- #
- # fwUpdate.sh - Performs a firmware upgrade with files found on the
- # specified USB device.
- #
- # NOTE:
- # If power is cycled or the USB drive is removed while updating the
- # bootloader, the system will need to be sent to the Tek Service
- # Center to be restored.
- #
- KERNEL_FILE="kernel.img"
- FILESYSTEM_FILE="filesystem.img"
- BOOTLOADER_FILE="bootloader.img"
- SPLASH_FILE="splash.img"
- LMIA_FILE="lmia.bin"
- LMIA2_FILE="lmia2.bin"
- FP_UPDATE_FILE="route66_fp.s19"
- FP_VERSION_FILE="route66_fp_version.txt"
- FE_UPDATE_FILE="laguna_fe.s19"
- FE_VERSION_FILE="laguna_fe_version.txt"
- FW_SETENV="/usr/share/tek/fw_setenv"
- FW_PRINTENV="/usr/share/tek/fw_printenv"
- # fw_printenv doesn't exist in the ramdisk, but it's the same tool as
- # fw_setenv with a different name, so we'll just copy it over.
- #cp $FW_SETENV $FW_PRINTENV
- UPDATE_ENV_FILE="fwEnvUpdate.sh"
- GEN_SAVEALL_FILE="genSaveAll.sh"
- UPDATE_COMPLETE_FILE="updatecomplete.txt"
- UPDATE_OLDER_FILE="updateolder.txt"
- UPDATE_CORRUPT_FILE="updatecorrupt.txt"
- UPDATE_INCOMPATIBLE_FILE="updateincompat.txt"
- MD5SUM_FILE="md5sum.txt"
- #
- # Files related to firmware update version comparisons and forced firmware
- # installs
- FIRMWARE_VERSION_FILE="usr_1/local/bin/version.txt"
- UPDATE_VERSION_FILE="updateVersion.txt"
- FORCE_INSTALL_FILE="forceinstall.txt"
- FORCE_INSTALL_ALT_FILE="override.txt"
- #
- # Locations of important MTD partitions involved in the firmware
- # update process.
- #
- # This is /usr/local/perm
- FS_PARTITION="/dev/mtd3"
- FS_BLOCKPARTITION="/dev/mtdblock3"
- # This is /usr/local/nv
- FS2_PARTITION="/dev/mtd4"
- FS2_BLOCKPARTITION="/dev/mtdblock4"
- # This is the rest of / and is read-only
- FS3_PARTITION="/dev/mtd5"
- FS3_BLOCKPARTITION="/dev/mtdblock5"
- KERNEL_PARTITION="/dev/mtd2"
- KERNEL2_PARTITION="/dev/mtd11"
- BOOTLOADER_PARTITION="/dev/mtd0"
- SPLASH_PARTITION="/dev/mtd1"
- LMIA_PARTITION="/dev/mtd6"
- LMIA2_PARTITION="/dev/mtd13"
- # used to deposit the 'incorrect platform' update in the right place
- # (as the location of the filesystem partition for the current platform
- # will be different than the filesystem partition for the intended
- # platform).
- # CJS???
- FS_BLOCKPARTITION_2K="/dev/mtdblock4"
- FS_BLOCKPARTITION_3K="/dev/mtdblock2"
- FS_BLOCKPARTITION_4K="/dev/mtdblock7"
- FS_BLOCKPARTITION_BK="/dev/mtdblock7"
- FS_BLOCKPARTITION_LK="/dev/mtdblock3"
- kernel_found="no"
- filesystem_found="no"
- bootloader_found="no"
- splash_found="no"
- lmia_found="no"
- lmia2_found="no"
- update_env_found="no"
- gen_saveall_found="no"
- fp_update_found="no"
- fe_update_found="no"
- continue_update="no"
- do_install="no"
- update_partition="/tmp/update"
- fwupdate_partition=$1
- is_new_kernel="no"
- found_uboot_extract="no"
- # Make mount points if necessary
- if ! test -e /mnt/rootfs
- then
- mkdir /mnt/rootfs
- fi
- if ! test -e /mnt/permfs
- then
- mkdir /mnt/permfs
- fi
- if ! test -e /mnt/nvfs
- then
- mkdir /mnt/nvfs
- fi
- # Check for the presence of 'getPlatform'. This tool is used to determine
- # from which platform the current firmware update is being run. If not
- # present, then abort the installation, as attempting to install the
- # update without knowing the platform is unsafe.
- GET_PLATFORM="getPlatform"
- if [ ! -e $update_partition/$GET_PLATFORM ]
- then
- echo "getPlatform not found (corrupt update?). Installation aborted."
- mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs >/dev/null 2>&1
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- exit 1
- fi
- # Get the platform and check to make sure that the return value is '6'
- # (Laguna). Abort otherwise.
- $update_partition/$GET_PLATFORM
- platform=$?
- if test $platform -ne 6
- then
- echo "This firmware is meant for lk. Current platform is ${platform}k. Aborting."
- # Note: one of these platforms will be redundant for each platform. However,
- # I want to keep the scripts as similar as possible, so each platform is included
- # in every script.
- if test $platform -eq 2
- then
- # 2k - update files are in /
- mount -t jffs2 $FS_BLOCKPARTITION_2K /mnt/rootfs >/dev/null 2>&1
- rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
- rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
- rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
- touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
- fi
- if test $platform -eq 3
- then
- # 3k - update files are in /
- mount -t jffs2 $FS_BLOCKPARTITION_3K /mnt/rootfs >/dev/null 2>&1
- rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
- rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
- rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
- touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
- fi
- if test $platform -eq 4
- then
- # 4k - update files are in /
- mount -t jffs2 $FS_BLOCKPARTITION_4K /mnt/rootfs >/dev/null 2>&1
- rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
- rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
- rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
- touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
- fi
- if test $platform -eq 5
- then
- # bk - update files are in /usr/local/perm
- mount -t jffs2 $FS_BLOCKPARTITION_BK /mnt/permfs >/dev/null 2>&1
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- touch /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
- fi
- if test $platform -eq 6
- then
- # lk - update files are in /usr/local/perm
- mount -t jffs2 $FS_BLOCKPARTITION_LK /mnt/permfs >/dev/null 2>&1
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- touch /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
- fi
- sync
- sync
- umount /mnt/rootfs >/dev/null 2>&1
- umount /mnt/permfs >/dev/null 2>&1
- exit 1
- fi
- # Mount /usr/local/perm filesystem
- mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs >/dev/null 2>&1
- if test $? -ne 0
- then
- echo "Mount of /usr/local/perm failed - erasing"
- flash_eraseall $FS_PARTITION
- mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs
- mkdir -p /mnt/permfs/usr/local/perm
- fi
- # Create /usr/local/perm directory if necessary
- if ! test -e /mnt/permfs/usr/local/perm
- then
- mkdir -p /mnt/permfs/usr/local/perm
- fi
- # Clean up old /usr/local/perm/update* files if present
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- rm -f /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
- # Check for the presence of 'getMemTotal'. This tool is used to determine
- # how much RAM is present in order to determine which version of U-Boot to use.
- # If not present, then abort the installation, as attempting to install the
- # update without knowing the correct U-Boot is unsafe.
- GET_MEM_TOTAL="getMemTotal"
- if [ ! -e $update_partition/$GET_MEM_TOTAL ]
- then
- echo "getMemTotal not found (corrupt update?). Installation aborted."
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- exit 1
- fi
- FAN_RESET="fanReset"
- if [ ! -e $update_partition/$FAN_RESET ]
- then
- echo "fanReset wasn't found. Update will continue, but system may"
- echo " overheat if the system isn't power cycled shortly after the"
- echo " update completes."
- fi
- echo "Firmware platform check passed."
- # Determine which version of U-Boot to use by checking how much RAM is present
- $update_partition/$GET_MEM_TOTAL
- memory=$?
- if test $memory -eq 1
- then
- BOOTLOADER_FILE="bootloader.img"
- echo "Using bootloader.img"
- else
- BOOTLOADER_FILE="bootloader2.img"
- echo "Using bootloader2.img"
- fi
- DISP_BMP="dispBmp"
- if test -e $update_partition/$DISP_BMP
- then
- cp $update_partition/$DISP_BMP /usr/share/tek/$DISP_BMP
- else
- echo "dispBmp wasn't found. Update will continue"
- fi
- # uBootExtract should be in the update as well. If not, don't try to update
- # the boot loader, since we have no way to check the installed version.
- UBOOT_EXTRACT="uBootExtract"
- if test -e $update_partition/$UBOOT_EXTRACT
- then
- cp $update_partition/$UBOOT_EXTRACT /usr/share/tek/$UBOOT_EXTRACT
- found_uboot_extract="yes"
- else
- echo "uBootExtract not found!"
- fi
- loopForever()
- {
- while [ 1 ]
- do
- sleep 1
- done
- }
- #
- # Check to see if forceinstall.txt (or 'override.txt')
- # exists on the memory stick. If it does, then install no matter what.
- #
- if test -e /mnt/$fwupdate_partition/$FORCE_INSTALL_FILE
- then
- echo "$FORCE_INSTALL_FILE found. Firmware will be installed."
- do_install="yes"
- fi
- if test -e /mnt/$fwupdate_partition/$FORCE_INSTALL_ALT_FILE
- then
- echo "$FORCE_INSTALL_ALT_FILE found. Firmware will be installed."
- do_install="yes"
- fi
- #
- # Mount the root filesystem and check for the firmware version file.
- # If the file doesn't exist, do a full install. If it does exist, then
- # compare versions, and if the update version is later, then do an install.
- #
- echo "Mounting root filesystem"
- mount -t squashfs $FS3_BLOCKPARTITION /mnt/rootfs >/dev/null 2>&1
- #
- # If the update file doesn't contain a version information file, then
- # abort the update (no easy way to tell what version of firmware we have)
- #
- if ! test -e $update_partition/$UPDATE_VERSION_FILE
- then
- echo "No update version file found in update, aborting update"
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/rootfs >/dev/null 2>&1
- exit 1
- fi
- if ! test -e /mnt/rootfs/$FIRMWARE_VERSION_FILE
- then
- echo "No firmware version file found in flash, performing update"
- do_install="yes"
- umount /mnt/rootfs >/dev/null 2>&1
- else
- str1=`cat /mnt/rootfs/$FIRMWARE_VERSION_FILE`
- str2=`cat $update_partition/$UPDATE_VERSION_FILE`
- /bin/compareVersions $str1 $str2
- if test $? -eq 0
- then
- echo "Update on memory stick is newer, performing update"
- do_install="yes"
- fi
- umount /mnt/rootfs >/dev/null 2>&1
- fi
- if test -e "$update_partition/$KERNEL_FILE"
- then
- kernel_found="yes"
- echo " - $KERNEL_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$FILESYSTEM_FILE"
- then
- filesystem_found="yes"
- echo " - $FILESYSTEM_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$BOOTLOADER_FILE"
- then
- #
- # If the uBootExtract tool is not available, the bootloader will not be
- # upgraded.
- #
- if test $found_uboot_extract = "yes"
- then
- echo " - $BOOTLOADER_FILE found."
- echo " - comparing versions..."
- #
- # Extract the two versions and check them. If we can't extract the
- # version of the copy in the update, don't update. If we can't extract
- # the version from the scope, then update. If we can extract both,
- # compare versions.
- #
- # The reasoning for this is that all new bootloaders have a version in
- # them. If the version on the update doesn't have one, it's old and we
- # don't want to install it. If the version on the scope doesn't have
- # one, but the version on the update does, the update is definitely newer.
- #
- extract_from_update="no"
- extract_from_scope="no"
- /usr/share/tek/$UBOOT_EXTRACT $update_partition/$BOOTLOADER_FILE
- if test $? -eq 0
- then
- str3=`/usr/share/tek/$UBOOT_EXTRACT $update_partition/$BOOTLOADER_FILE`
- extract_from_update="yes"
- fi
- /usr/share/tek/$UBOOT_EXTRACT $BOOTLOADER_PARTITION
- if test $? -eq 0
- then
- str4=`/usr/share/tek/$UBOOT_EXTRACT $BOOTLOADER_PARTITION`
- extract_from_scope="yes"
- fi
- if test $extract_from_update = "yes"
- then
- if test $extract_from_scope = "no"
- then
- echo "bootloader version on update but not on scope. Updating."
- bootloader_found="yes"
- continue_update="yes"
- else
- # compare versions, str4 is the installed version, str3 is the version on the stick
- /bin/compareVersions $str4 $str3
- if test $? -eq 0
- then
- echo "Bootloader on memory stick is newer, performing update"
- bootloader_found="yes"
- continue_update="yes"
- else
- echo "installed bootloader is equal or newer. Skipping."
- bootloader_found="no"
- fi
- fi
- else
- echo "No version found in bootloader in update. Skipping."
- bootloader_found="no"
- fi
- fi
- fi
- if test -e "$update_partition/$SPLASH_FILE"
- then
- splash_found="yes"
- echo " - $SPLASH_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$FP_UPDATE_FILE"
- then
- if test -e "$update_partition/$FP_VERSION_FILE"
- then
- fp_update_found="yes"
- echo " - $FP_UPDATE_FILE found."
- echo " Front panel version file contents - " `cat $update_partition/$FP_VERSION_FILE`
- continue_update="yes"
- else
- echo "Front panel update found, but update version file not found."
- fi
- fi
- if test -e "$update_partition/$FE_UPDATE_FILE"
- then
- if test -e "$update_partition/$FE_VERSION_FILE"
- then
- fe_update_found="yes"
- echo " - $FE_UPDATE_FILE found."
- echo " Analog front end version file contents - " `cat $update_partition/$FE_VERSION_FILE`
- continue_update="yes"
- else
- echo "Analog front end update found, but update version file not found."
- fi
- fi
- if test -e "$update_partition/$UPDATE_ENV_FILE"
- then
- update_env_found="yes"
- echo " - $UPDATE_ENV_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$GEN_SAVEALL_FILE"
- then
- gen_saveall_found="yes"
- echo " - $GEN_SAVEALL_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$LMIA_FILE"
- then
- lmia_found="yes"
- echo " - $LMIA_FILE found."
- continue_update="yes"
- fi
- if test -e "$update_partition/$LMIA2_FILE"
- then
- lmia2_found="yes"
- echo " - $LMIA2_FILE found."
- continue_update="yes"
- fi
- if test $continue_update = "no"
- then
- echo "No update files found. Exiting"
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/rootfs >/dev/null 2>&1
- exit 1
- fi
- #
- # At this point, update files were found. If the update is newer, then
- # do the install.
- #
- if test $do_install = "no"
- then
- echo "This update is older than the installed version, and a forced install"
- echo "wasn't specified. Update was not performed."
- #
- # Write a file to the filesystem telling the scope application that firmware
- # was found, but is older than the current version.
- #
- touch /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/rootfs >/dev/null 2>&1
- exit 0
- fi
- echo "Update files were found. Checking file integrity, please wait..."
- mkdir /tmp/ram
- mount -t ramfs ramfs /tmp/ram
- cp $update_partition/firmware_update4.bmp /tmp/ram
- /usr/share/tek/$DISP_BMP /tmp/ram/firmware_update4.bmp
- cp $update_partition/firmware_complete4.bmp /tmp/ram
- # Perform a basic sanity check on the data here
- if ! test -e $update_partition/$MD5SUM_FILE
- then
- echo "Checksum file not found. Stopping."
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/rootfs >/dev/null 2>&1
- exit 1
- fi
- # The md5sum.txt file is present
- cd $update_partition
- echo "Running: /usr/bin/md5sum -c < $MD5SUM_FILE"
- /usr/bin/md5sum -c < $MD5SUM_FILE
- if test $? -ne 0
- then
- echo "Checksum process failed!"
- touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
- sync
- sync
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/rootfs >/dev/null 2>&1
- exit 1
- fi
- # Everything looks good at this point
- cd /
- echo "md5sum check passed for all files, continuing..."
- echo "Resetting fan..."
- $update_partition/$FAN_RESET
- # Sleep here for 15 seconds. This sleep, with combined with the
- # amount of time spent calculating md5sums, will allow a small window
- # which can allow the user to unplug the update stick without any
- # effect to the scope (for example, if a stick with an update was
- # left in and unplugged when the mistake was realized).
- echo "Performing update in 15 seconds..."
- sleep 15
- # Notify the user that front panel code will be updated during the
- # next system powerup.
- if test $fp_update_found = "yes"
- then
- echo "(The front panel will be updated during the next powerup.)"
- fi
- # Notify the user that analog front end code will be updated during the
- # next system powerup.
- if test $fe_update_found = "yes"
- then
- echo "(The analog front end will be updated during the next powerup.)"
- fi
- # Flash the splash screen bitmap
- if test $splash_found = "yes"
- then
- echo "Flashing $SPLASH_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
- # Perform a final sanity check before erasing ... if the file isn't
- # found, exit the application
- cp $update_partition/$SPLASH_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $SPLASH_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$SPLASH_FILE > $SPLASH_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the splash screen!"
- loopForever
- else
- echo "Finished updating splash screen."
- fi
- else
- echo "The splash screen file is missing! Exiting..."
- loopForever
- fi
- fi
- # Flash the LMIA
- if test $lmia_found = "yes"
- then
- echo "Flashing $LMIA_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
- # Perform a final sanity check before erasing ... if the file isn't
- # found, exit the application
- cp $update_partition/$LMIA_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $LMIA_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$LMIA_FILE > $LMIA_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the LMIA!"
- loopForever
- else
- echo "Finished updating LMIA."
- fi
- else
- echo "The LMIA file is missing! Exiting..."
- loopForever
- fi
- fi
- # Flash the LMIA2
- if test $lmia2_found = "yes"
- then
- echo "Flashing $LMIA2_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
- # Perform a final sanity check before erasing ... if the file isn't
- # found, exit the application
- cp $update_partition/$LMIA2_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $LMIA2_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$LMIA2_FILE > $LMIA2_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the LMIA2!"
- loopForever
- else
- echo "Finished updating LMIA2."
- fi
- else
- echo "The LMIA2 file is missing! Exiting..."
- loopForever
- fi
- fi
- if test $kernel_found = "yes"
- then
- echo "Flashing $KERNEL_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
- # Perform one last sanity check before writing
- cp $update_partition/$KERNEL_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $KERNEL_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$KERNEL_FILE > $KERNEL_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the kernel!"
- loopForever
- else
- echo "Finished updating kernel."
- fi
- else
- echo "kernel file not found! Exiting..."
- loopForever
- fi
- cp $update_partition/$KERNEL_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- # repeat for partition 2
- echo "Flashing $KERNEL_FILE into backup partition..."
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $KERNEL2_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$KERNEL_FILE > $KERNEL2_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the backup kernel!"
- loopForever
- else
- echo "Finished updating backup kernel."
- fi
- else
- echo "Kernel file not found! Exiting..."
- loopForever
- fi
- fi
- if test $filesystem_found = "yes"
- then
- echo "Updating filesystem... DO NOT TURN OFF THE SYSTEM!!!!"
- cp $update_partition/$FILESYSTEM_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- umount $FS3_BLOCKPARTITION >/dev/null 2>&1
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $FS3_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$FILESYSTEM_FILE >$FS3_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the root filesystem!"
- loopForever
- fi
- echo " - Finishing up; this may take a while..."
- sync
- sync
- echo "Finished updating filesystem."
- else
- echo "Filesystem file not found! Exiting..."
- loopForever
- fi
- fi
- # The bootloader upgrade used to happen at the start of the process,
- # but now occurs near the end. See the comment about the 15-second
- # wait above for more information about why this is done.
- if test $bootloader_found = "yes"
- then
- echo "Flashing $BOOTLOADER_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
- # Perform a final sanity check to make sure the file is available
- # before it is erased
- cp $update_partition/$BOOTLOADER_FILE /dev/null 2>&1 | grep -q "Input/output"
- if test $? -ne 0
- then
- echo " - Erasing flash; this may take a while..."
- flash_eraseall $BOOTLOADER_PARTITION
- echo " - Writing to flash; this may take a while..."
- cat $update_partition/$BOOTLOADER_FILE > $BOOTLOADER_PARTITION
- if test $? -ne 0
- then
- echo "An error occured while updating the bootloader!"
- loopForever
- else
- echo "Finished updating bootloader."
- fi
- else
- echo "File is not available! Exiting...."
- loopForever
- fi
- fi
- if test $update_env_found = "yes"
- then
- $update_partition/$UPDATE_ENV_FILE
- fi
- # Mount /usr/local/nv filesystem
- mount -t jffs2 $FS2_BLOCKPARTITION /mnt/nvfs
- if test $? -ne 0
- then
- echo "Mount of /usr/local/nv failed - erasing"
- flash_eraseall $FS2_PARTITION
- mount -t jffs2 $FS2_BLOCKPARTITION /mnt/nvfs
- mkdir -p /mnt/nvfs/usr/local/nv
- fi
- # Create /usr/local/nv directory if necessary
- if ! test -e /mnt/nvfs/usr/local/nv
- then
- mkdir -p /mnt/nvfs/usr/local/nv
- fi
- #
- # Take all existing setup*.set files (these are user-saved setups)
- # found in flash, and assemble them into a single, large userSaves.set
- # file. This file will be run on startup and will load all of these
- # setups into the correct internal setup slots.
- #
- if test $gen_saveall_found = "yes"
- then
- $update_partition/$GEN_SAVEALL_FILE
- fi
- #
- # Write a file to the filesystem telling the scope application that the
- # firmware was updated. Also, at this time, if a front panel update
- # file was found, we'll copy it to the filesystem while we have it
- # mounted.
- #
- echo "Marking update as complete in flash..."
- touch /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
- # Delete *all* of the keys in /usr/local/nv (not just nvkey20.dat)
- if test -e /mnt/nvfs/usr/local/nv
- then
- rm -f /mnt/nvfs/usr/local/nv/nvkey*.dat
- fi
- if test $fp_update_found = "yes"
- then
- cp -f $update_partition/$FP_UPDATE_FILE /mnt/permfs/usr/local/perm/$FP_UPDATE_FILE
- cp -f $update_partition/$FP_VERSION_FILE /mnt/permfs/usr/local/perm/$FP_VERSION_FILE
- fi
- if test $fe_update_found = "yes"
- then
- cp -f $update_partition/$FE_UPDATE_FILE /mnt/nvfs/usr/local/nv/$FE_UPDATE_FILE
- cp -f $update_partition/$FE_VERSION_FILE /mnt/nvfs/usr/local/nv/$FE_VERSION_FILE
- fi
- sync
- sync
- umount /mnt/rootfs >/dev/null 2>&1
- umount /mnt/permfs >/dev/null 2>&1
- umount /mnt/nvfs >/dev/null 2>&1
- /usr/share/tek/$DISP_BMP /tmp/ram/firmware_complete4.bmp
- echo "Update is complete. Please power cycle your instrument now."
- # Loop forever after displaying the message to power cycle on screen
- loopForever
Add Comment
Please, Sign In to add comment