iROOT

fwUpdate.sh

Jan 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 25.41 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # $Header: /vobs/cm/route66/software/tools/firmware/firmware_update_components/lk/fwUpdate.sh /main/15 21-Nov-2014.11:28:50 zkoppert $
  4. #
  5. # fwUpdate.sh - Performs a firmware upgrade with files found on the
  6. # specified USB device.
  7. #
  8. # NOTE:
  9. #  If power is cycled or the USB drive is removed while updating the
  10. #  bootloader, the system will need to be sent to the Tek Service
  11. #  Center to be restored.
  12. #
  13.  
  14. KERNEL_FILE="kernel.img"
  15. FILESYSTEM_FILE="filesystem.img"
  16. BOOTLOADER_FILE="bootloader.img"
  17. SPLASH_FILE="splash.img"
  18. LMIA_FILE="lmia.bin"
  19. LMIA2_FILE="lmia2.bin"
  20. FP_UPDATE_FILE="route66_fp.s19"
  21. FP_VERSION_FILE="route66_fp_version.txt"
  22. FE_UPDATE_FILE="laguna_fe.s19"
  23. FE_VERSION_FILE="laguna_fe_version.txt"
  24.  
  25. FW_SETENV="/usr/share/tek/fw_setenv"
  26. FW_PRINTENV="/usr/share/tek/fw_printenv"
  27.  
  28. # fw_printenv doesn't exist in the ramdisk, but it's the same tool as
  29. # fw_setenv with a different name, so we'll just copy it over.
  30. #cp $FW_SETENV $FW_PRINTENV
  31.  
  32. UPDATE_ENV_FILE="fwEnvUpdate.sh"
  33. GEN_SAVEALL_FILE="genSaveAll.sh"
  34.  
  35. UPDATE_COMPLETE_FILE="updatecomplete.txt"
  36. UPDATE_OLDER_FILE="updateolder.txt"
  37. UPDATE_CORRUPT_FILE="updatecorrupt.txt"
  38. UPDATE_INCOMPATIBLE_FILE="updateincompat.txt"
  39.  
  40. MD5SUM_FILE="md5sum.txt"
  41.  
  42. #
  43. # Files related to firmware update version comparisons and forced firmware
  44. # installs
  45. FIRMWARE_VERSION_FILE="usr_1/local/bin/version.txt"
  46. UPDATE_VERSION_FILE="updateVersion.txt"
  47. FORCE_INSTALL_FILE="forceinstall.txt"
  48. FORCE_INSTALL_ALT_FILE="override.txt"
  49.  
  50. #
  51. # Locations of important MTD partitions involved in the firmware
  52. # update process.
  53. #
  54. # This is /usr/local/perm
  55. FS_PARTITION="/dev/mtd3"
  56. FS_BLOCKPARTITION="/dev/mtdblock3"
  57. # This is /usr/local/nv
  58. FS2_PARTITION="/dev/mtd4"
  59. FS2_BLOCKPARTITION="/dev/mtdblock4"
  60. # This is the rest of / and is read-only
  61. FS3_PARTITION="/dev/mtd5"
  62. FS3_BLOCKPARTITION="/dev/mtdblock5"
  63. KERNEL_PARTITION="/dev/mtd2"
  64. KERNEL2_PARTITION="/dev/mtd11"
  65. BOOTLOADER_PARTITION="/dev/mtd0"
  66. SPLASH_PARTITION="/dev/mtd1"
  67. LMIA_PARTITION="/dev/mtd6"
  68. LMIA2_PARTITION="/dev/mtd13"
  69.  
  70. # used to deposit the 'incorrect platform' update in the right place
  71. # (as the location of the filesystem partition for the current platform
  72. #  will be different than the filesystem partition for the intended
  73. #  platform).
  74. # CJS???
  75. FS_BLOCKPARTITION_2K="/dev/mtdblock4"
  76. FS_BLOCKPARTITION_3K="/dev/mtdblock2"
  77. FS_BLOCKPARTITION_4K="/dev/mtdblock7"
  78. FS_BLOCKPARTITION_BK="/dev/mtdblock7"
  79. FS_BLOCKPARTITION_LK="/dev/mtdblock3"
  80.  
  81. kernel_found="no"
  82. filesystem_found="no"
  83. bootloader_found="no"
  84. splash_found="no"
  85. lmia_found="no"
  86. lmia2_found="no"
  87. update_env_found="no"
  88. gen_saveall_found="no"
  89. fp_update_found="no"
  90. fe_update_found="no"
  91. continue_update="no"
  92. do_install="no"
  93. update_partition="/tmp/update"
  94. fwupdate_partition=$1
  95. is_new_kernel="no"
  96. found_uboot_extract="no"
  97.  
  98. # Make mount points if necessary
  99. if ! test -e /mnt/rootfs
  100. then
  101.     mkdir /mnt/rootfs
  102. fi
  103. if ! test -e /mnt/permfs
  104. then
  105.     mkdir /mnt/permfs
  106. fi
  107. if ! test -e /mnt/nvfs
  108. then
  109.     mkdir /mnt/nvfs
  110. fi
  111.  
  112. # Check for the presence of 'getPlatform'.  This tool is used to determine
  113. # from which platform the current firmware update is being run.  If not
  114. # present, then abort the installation, as attempting to install the
  115. # update without knowing the platform is unsafe.
  116. GET_PLATFORM="getPlatform"
  117. if [ ! -e $update_partition/$GET_PLATFORM ]
  118. then
  119.     echo "getPlatform not found (corrupt update?).  Installation aborted."
  120.     mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs >/dev/null 2>&1
  121.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  122.     sync
  123.     sync
  124.     umount /mnt/permfs >/dev/null 2>&1
  125.     exit 1
  126. fi
  127.  
  128. # Get the platform and check to make sure that the return value is '6'
  129. # (Laguna).  Abort otherwise.
  130. $update_partition/$GET_PLATFORM
  131. platform=$?
  132. if test $platform -ne 6
  133. then
  134.     echo "This firmware is meant for lk.  Current platform is ${platform}k. Aborting."
  135.     # Note: one of these platforms will be redundant for each platform.  However,
  136.     # I want to keep the scripts as similar as possible, so each platform is included
  137.     # in every script.
  138.     if test $platform -eq 2
  139.     then
  140.         # 2k - update files are in /
  141.         mount -t jffs2 $FS_BLOCKPARTITION_2K /mnt/rootfs >/dev/null 2>&1
  142.         rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
  143.         rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
  144.         rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
  145.         touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
  146.     fi
  147.     if test $platform -eq 3
  148.     then
  149.         # 3k - update files are in /
  150.         mount -t jffs2 $FS_BLOCKPARTITION_3K /mnt/rootfs >/dev/null 2>&1
  151.         rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
  152.         rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
  153.         rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
  154.         touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
  155.     fi
  156.     if test $platform -eq 4
  157.     then
  158.         # 4k - update files are in /
  159.         mount -t jffs2 $FS_BLOCKPARTITION_4K /mnt/rootfs >/dev/null 2>&1
  160.         rm -f /mnt/rootfs/$UPDATE_COMPLETE_FILE
  161.         rm -f /mnt/rootfs/$UPDATE_OLDER_FILE
  162.         rm -f /mnt/rootfs/$UPDATE_CORRUPT_FILE
  163.         touch /mnt/rootfs/$UPDATE_INCOMPATIBLE_FILE
  164.     fi
  165.     if test $platform -eq 5
  166.     then
  167.         # bk - update files are in /usr/local/perm
  168.         mount -t jffs2 $FS_BLOCKPARTITION_BK /mnt/permfs >/dev/null 2>&1
  169.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
  170.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
  171.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  172.         touch /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
  173.     fi
  174.     if test $platform -eq 6
  175.     then
  176.         # lk - update files are in /usr/local/perm
  177.         mount -t jffs2 $FS_BLOCKPARTITION_LK /mnt/permfs >/dev/null 2>&1
  178.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
  179.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
  180.         rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  181.         touch /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
  182.     fi
  183.     sync
  184.     sync
  185.     umount /mnt/rootfs >/dev/null 2>&1
  186.     umount /mnt/permfs >/dev/null 2>&1
  187.     exit 1
  188. fi
  189.  
  190. # Mount /usr/local/perm filesystem
  191. mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs >/dev/null 2>&1
  192. if test $? -ne 0
  193. then
  194.     echo "Mount of /usr/local/perm failed - erasing"  
  195.     flash_eraseall $FS_PARTITION
  196.     mount -t jffs2 $FS_BLOCKPARTITION /mnt/permfs
  197.     mkdir -p /mnt/permfs/usr/local/perm
  198. fi
  199.  
  200. # Create /usr/local/perm directory if necessary
  201. if ! test -e /mnt/permfs/usr/local/perm
  202. then
  203.     mkdir -p /mnt/permfs/usr/local/perm
  204. fi
  205.  
  206. # Clean up old /usr/local/perm/update* files if present
  207. rm -f /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
  208. rm -f /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  209. rm -f /mnt/permfs/usr/local/perm/$UPDATE_INCOMPATIBLE_FILE
  210.  
  211.  
  212. # Check for the presence of 'getMemTotal'.  This tool is used to determine
  213. # how much RAM is present in order to determine which version of U-Boot to use.  
  214. # If not present, then abort the installation, as attempting to install the
  215. # update without knowing the correct U-Boot is unsafe.
  216. GET_MEM_TOTAL="getMemTotal"
  217. if [ ! -e $update_partition/$GET_MEM_TOTAL ]
  218. then
  219.     echo "getMemTotal not found (corrupt update?).  Installation aborted."
  220.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  221.     sync
  222.     sync
  223.     umount /mnt/permfs >/dev/null 2>&1
  224.     exit 1
  225. fi
  226.  
  227. FAN_RESET="fanReset"
  228. if [ ! -e $update_partition/$FAN_RESET ]
  229. then
  230.     echo "fanReset wasn't found.  Update will continue, but system may"
  231.     echo " overheat if the system isn't power cycled shortly after the"
  232.     echo " update completes."
  233. fi
  234.  
  235. echo "Firmware platform check passed."
  236.  
  237. # Determine which version of U-Boot to use by checking how much RAM is present
  238. $update_partition/$GET_MEM_TOTAL
  239. memory=$?
  240. if test $memory -eq 1
  241. then
  242.     BOOTLOADER_FILE="bootloader.img"
  243.     echo "Using bootloader.img"
  244. else
  245.     BOOTLOADER_FILE="bootloader2.img"
  246.     echo "Using bootloader2.img"
  247. fi
  248.  
  249. DISP_BMP="dispBmp"
  250. if test -e $update_partition/$DISP_BMP
  251. then
  252.     cp $update_partition/$DISP_BMP /usr/share/tek/$DISP_BMP
  253. else
  254.     echo "dispBmp wasn't found. Update will continue"
  255. fi
  256.  
  257. # uBootExtract should be in the update as well.  If not, don't try to update
  258. # the boot loader, since we have no way to check the installed version.
  259. UBOOT_EXTRACT="uBootExtract"
  260. if test -e $update_partition/$UBOOT_EXTRACT
  261. then
  262.     cp $update_partition/$UBOOT_EXTRACT /usr/share/tek/$UBOOT_EXTRACT
  263.     found_uboot_extract="yes"
  264. else
  265.     echo "uBootExtract not found!"
  266. fi
  267.  
  268. loopForever()
  269. {
  270.     while [ 1 ]
  271.     do
  272.         sleep 1
  273.     done
  274. }
  275.  
  276. #
  277. # Check to see if forceinstall.txt (or 'override.txt')
  278. # exists on the memory stick.  If it does, then install no matter what.
  279. #
  280. if test -e /mnt/$fwupdate_partition/$FORCE_INSTALL_FILE
  281. then
  282.     echo "$FORCE_INSTALL_FILE found.  Firmware will be installed."
  283.     do_install="yes"
  284. fi
  285.  
  286. if test -e /mnt/$fwupdate_partition/$FORCE_INSTALL_ALT_FILE
  287. then
  288.     echo "$FORCE_INSTALL_ALT_FILE found.  Firmware will be installed."
  289.     do_install="yes"
  290. fi
  291.  
  292. #
  293. # Mount the root filesystem and check for the firmware version file.  
  294. # If the file doesn't exist, do a full install.  If it does exist, then
  295. # compare versions, and if the update version is later, then do an install.
  296. #
  297. echo "Mounting root filesystem"
  298. mount -t squashfs $FS3_BLOCKPARTITION /mnt/rootfs >/dev/null 2>&1
  299.  
  300. #
  301. # If the update file doesn't contain a version information file, then
  302. # abort the update (no easy way to tell what version of firmware we have)
  303. #
  304. if ! test -e $update_partition/$UPDATE_VERSION_FILE
  305. then
  306.     echo "No update version file found in update, aborting update"
  307.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  308.     sync
  309.     sync
  310.     umount /mnt/permfs >/dev/null 2>&1
  311.     umount /mnt/rootfs >/dev/null 2>&1
  312.     exit 1
  313. fi
  314.  
  315. if ! test -e /mnt/rootfs/$FIRMWARE_VERSION_FILE
  316. then
  317.     echo "No firmware version file found in flash, performing update"
  318.     do_install="yes"  
  319.     umount /mnt/rootfs >/dev/null 2>&1
  320. else      
  321.     str1=`cat /mnt/rootfs/$FIRMWARE_VERSION_FILE`
  322.     str2=`cat $update_partition/$UPDATE_VERSION_FILE`
  323.     /bin/compareVersions $str1 $str2
  324.     if test $? -eq 0
  325.     then
  326.         echo "Update on memory stick is newer, performing update"
  327.         do_install="yes"
  328.     fi
  329.     umount /mnt/rootfs >/dev/null 2>&1
  330. fi
  331.  
  332. if test -e "$update_partition/$KERNEL_FILE"
  333. then
  334.     kernel_found="yes"
  335.     echo "  - $KERNEL_FILE found."
  336.     continue_update="yes"
  337. fi
  338.  
  339. if test -e "$update_partition/$FILESYSTEM_FILE"
  340. then
  341.     filesystem_found="yes"
  342.     echo "  - $FILESYSTEM_FILE found."
  343.     continue_update="yes"
  344. fi  
  345.  
  346. if test -e "$update_partition/$BOOTLOADER_FILE"
  347. then
  348.     #
  349.     # If the uBootExtract tool is not available, the bootloader will not be
  350.     # upgraded.  
  351.     #
  352.     if test $found_uboot_extract = "yes"
  353.     then
  354.         echo "  - $BOOTLOADER_FILE found."
  355.         echo "  - comparing versions..."
  356.         #
  357.         # Extract the two versions and check them.  If we can't extract the
  358.         # version of the copy in the update, don't update.  If we can't extract
  359.         # the version from the scope, then update.  If we can extract both,
  360.         # compare versions.  
  361.         #
  362.         # The reasoning for this is that all new bootloaders have a version in
  363.         # them.  If the version on the update doesn't have one, it's old and we
  364.         # don't want to install it.  If the version on the scope doesn't have
  365.         # one, but the version on the update does, the update is definitely newer.
  366.         #
  367.         extract_from_update="no"
  368.         extract_from_scope="no"
  369.  
  370.         /usr/share/tek/$UBOOT_EXTRACT $update_partition/$BOOTLOADER_FILE
  371.         if test $? -eq 0
  372.         then
  373.             str3=`/usr/share/tek/$UBOOT_EXTRACT $update_partition/$BOOTLOADER_FILE`
  374.             extract_from_update="yes"
  375.         fi
  376.      
  377.         /usr/share/tek/$UBOOT_EXTRACT $BOOTLOADER_PARTITION
  378.         if test $? -eq 0
  379.         then
  380.             str4=`/usr/share/tek/$UBOOT_EXTRACT $BOOTLOADER_PARTITION`
  381.             extract_from_scope="yes"
  382.         fi
  383.  
  384.         if test $extract_from_update = "yes"
  385.         then
  386.             if test $extract_from_scope = "no"
  387.             then
  388.                 echo "bootloader version on update but not on scope.  Updating."
  389.                 bootloader_found="yes"
  390.                 continue_update="yes"
  391.             else
  392.                 # compare versions, str4 is the installed version, str3 is the version on the stick
  393.                 /bin/compareVersions $str4 $str3
  394.                 if test $? -eq 0
  395.                 then
  396.                     echo "Bootloader on memory stick is newer, performing update"
  397.                     bootloader_found="yes"
  398.                     continue_update="yes"
  399.                 else
  400.                     echo "installed bootloader is equal or newer. Skipping."
  401.                     bootloader_found="no"
  402.                 fi
  403.             fi
  404.         else
  405.             echo "No version found in bootloader in update.  Skipping."
  406.             bootloader_found="no"
  407.         fi
  408.     fi
  409. fi  
  410.  
  411. if test -e "$update_partition/$SPLASH_FILE"
  412. then
  413.     splash_found="yes"
  414.     echo "  - $SPLASH_FILE found."
  415.     continue_update="yes"
  416. fi  
  417.  
  418. if test -e "$update_partition/$FP_UPDATE_FILE"
  419. then
  420.     if test -e "$update_partition/$FP_VERSION_FILE"
  421.     then
  422.        fp_update_found="yes"
  423.        echo "  - $FP_UPDATE_FILE found."
  424.        echo "    Front panel version file contents - " `cat $update_partition/$FP_VERSION_FILE`
  425.        continue_update="yes"
  426.     else
  427.        echo "Front panel update found, but update version file not found."
  428.     fi
  429. fi
  430.  
  431. if test -e "$update_partition/$FE_UPDATE_FILE"
  432. then
  433.     if test -e "$update_partition/$FE_VERSION_FILE"
  434.     then
  435.         fe_update_found="yes"
  436.         echo "  - $FE_UPDATE_FILE found."
  437.         echo "    Analog front end version file contents - " `cat $update_partition/$FE_VERSION_FILE`
  438.         continue_update="yes"
  439.     else
  440.         echo "Analog front end update found, but update version file not found."
  441.     fi
  442. fi
  443.  
  444. if test -e "$update_partition/$UPDATE_ENV_FILE"
  445. then
  446.     update_env_found="yes"
  447.     echo "  - $UPDATE_ENV_FILE found."
  448.     continue_update="yes"
  449. fi
  450.  
  451. if test -e "$update_partition/$GEN_SAVEALL_FILE"
  452. then
  453.     gen_saveall_found="yes"
  454.     echo "  - $GEN_SAVEALL_FILE found."
  455.     continue_update="yes"
  456. fi
  457.  
  458. if test -e "$update_partition/$LMIA_FILE"
  459. then
  460.     lmia_found="yes"
  461.     echo "  - $LMIA_FILE found."
  462.     continue_update="yes"
  463. fi  
  464.  
  465. if test -e "$update_partition/$LMIA2_FILE"
  466. then
  467.     lmia2_found="yes"
  468.     echo "  - $LMIA2_FILE found."
  469.     continue_update="yes"
  470. fi  
  471.  
  472. if test $continue_update = "no"
  473. then
  474.     echo "No update files found.  Exiting"
  475.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  476.     sync
  477.     sync
  478.     umount /mnt/permfs >/dev/null 2>&1
  479.     umount /mnt/rootfs >/dev/null 2>&1
  480.     exit 1
  481. fi
  482.  
  483. #
  484. # At this point, update files were found.  If the update is newer, then
  485. # do the install.
  486. #
  487. if test $do_install = "no"
  488. then
  489.     echo "This update is older than the installed version, and a forced install"
  490.     echo "wasn't specified.  Update was not performed."
  491.     #
  492.     # Write a file to the filesystem telling the scope application that firmware
  493.     # was found, but is older than the current version.
  494.     #
  495.     touch /mnt/permfs/usr/local/perm/$UPDATE_OLDER_FILE
  496.     sync
  497.     sync
  498.     umount /mnt/permfs >/dev/null 2>&1
  499.     umount /mnt/rootfs >/dev/null 2>&1
  500.     exit 0
  501. fi
  502.  
  503. echo "Update files were found.  Checking file integrity, please wait..."
  504.  
  505. mkdir /tmp/ram
  506. mount -t ramfs ramfs /tmp/ram
  507.  
  508. cp $update_partition/firmware_update4.bmp /tmp/ram
  509. /usr/share/tek/$DISP_BMP /tmp/ram/firmware_update4.bmp
  510. cp $update_partition/firmware_complete4.bmp /tmp/ram
  511.  
  512. # Perform a basic sanity check on the data here
  513. if ! test -e $update_partition/$MD5SUM_FILE
  514. then
  515.     echo "Checksum file not found.  Stopping."
  516.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  517.     sync
  518.     sync
  519.     umount /mnt/permfs >/dev/null 2>&1
  520.     umount /mnt/rootfs >/dev/null 2>&1
  521.     exit 1
  522. fi
  523.  
  524. # The md5sum.txt file is present
  525. cd $update_partition
  526. echo "Running: /usr/bin/md5sum -c < $MD5SUM_FILE"
  527. /usr/bin/md5sum -c < $MD5SUM_FILE
  528. if test $? -ne 0
  529. then
  530.     echo "Checksum process failed!"
  531.     touch /mnt/permfs/usr/local/perm/$UPDATE_CORRUPT_FILE
  532.     sync
  533.     sync
  534.     umount /mnt/permfs >/dev/null 2>&1
  535.     umount /mnt/rootfs >/dev/null 2>&1
  536.     exit 1
  537. fi
  538.  
  539. # Everything looks good at this point
  540. cd /
  541. echo "md5sum check passed for all files, continuing..."
  542.  
  543. echo "Resetting fan..."
  544. $update_partition/$FAN_RESET
  545.  
  546. # Sleep here for 15 seconds.  This sleep, with combined with the
  547. # amount of time spent calculating md5sums, will allow a small window
  548. # which can allow the user to unplug the update stick without any
  549. # effect to the scope (for example, if a stick with an update was
  550. # left in and unplugged when the mistake was realized).  
  551. echo "Performing update in 15 seconds..."
  552. sleep 15
  553.  
  554. # Notify the user that front panel code will be updated during the
  555. # next system powerup.
  556. if test $fp_update_found = "yes"
  557. then
  558.     echo "(The front panel will be updated during the next powerup.)"  
  559. fi
  560.  
  561. # Notify the user that analog front end code will be updated during the
  562. # next system powerup.
  563. if test $fe_update_found = "yes"
  564. then
  565.     echo "(The analog front end will be updated during the next powerup.)"  
  566. fi
  567.  
  568. # Flash the splash screen bitmap
  569. if test $splash_found = "yes"
  570. then
  571.     echo "Flashing $SPLASH_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
  572.     # Perform a final sanity check before erasing ... if the file isn't
  573.     # found, exit the application
  574.     cp $update_partition/$SPLASH_FILE /dev/null 2>&1 | grep -q "Input/output"
  575.     if test $? -ne 0
  576.     then
  577.         echo "  - Erasing flash; this may take a while..."
  578.         flash_eraseall $SPLASH_PARTITION
  579.         echo "  - Writing to flash; this may take a while..."
  580.         cat $update_partition/$SPLASH_FILE > $SPLASH_PARTITION
  581.         if test $? -ne 0
  582.         then
  583.             echo "An error occured while updating the splash screen!"
  584.             loopForever
  585.         else
  586.             echo "Finished updating splash screen."
  587.         fi
  588.     else
  589.         echo "The splash screen file is missing! Exiting..."
  590.         loopForever
  591.     fi
  592. fi
  593.  
  594. # Flash the LMIA
  595. if test $lmia_found = "yes"
  596. then
  597.     echo "Flashing $LMIA_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
  598.     # Perform a final sanity check before erasing ... if the file isn't
  599.     # found, exit the application
  600.     cp $update_partition/$LMIA_FILE /dev/null 2>&1 | grep -q "Input/output"
  601.     if test $? -ne 0
  602.     then
  603.         echo "  - Erasing flash; this may take a while..."
  604.         flash_eraseall $LMIA_PARTITION
  605.         echo "  - Writing to flash; this may take a while..."
  606.         cat $update_partition/$LMIA_FILE > $LMIA_PARTITION
  607.         if test $? -ne 0
  608.         then
  609.             echo "An error occured while updating the LMIA!"
  610.             loopForever
  611.         else
  612.             echo "Finished updating LMIA."
  613.         fi
  614.     else
  615.         echo "The LMIA file is missing! Exiting..."
  616.         loopForever
  617.     fi
  618. fi
  619.  
  620. # Flash the LMIA2
  621. if test $lmia2_found = "yes"
  622. then
  623.     echo "Flashing $LMIA2_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
  624.     # Perform a final sanity check before erasing ... if the file isn't
  625.     # found, exit the application
  626.     cp $update_partition/$LMIA2_FILE /dev/null 2>&1 | grep -q "Input/output"
  627.     if test $? -ne 0
  628.     then
  629.         echo "  - Erasing flash; this may take a while..."
  630.         flash_eraseall $LMIA2_PARTITION
  631.         echo "  - Writing to flash; this may take a while..."
  632.         cat $update_partition/$LMIA2_FILE > $LMIA2_PARTITION
  633.         if test $? -ne 0
  634.         then
  635.             echo "An error occured while updating the LMIA2!"
  636.             loopForever
  637.         else
  638.             echo "Finished updating LMIA2."
  639.         fi
  640.     else
  641.         echo "The LMIA2 file is missing! Exiting..."
  642.         loopForever
  643.     fi
  644. fi
  645.  
  646. if test $kernel_found = "yes"
  647. then
  648.     echo "Flashing $KERNEL_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
  649.     # Perform one last sanity check before writing
  650.     cp $update_partition/$KERNEL_FILE /dev/null 2>&1 | grep -q  "Input/output"
  651.     if test $? -ne 0
  652.     then
  653.         echo "  - Erasing flash; this may take a while..."
  654.         flash_eraseall $KERNEL_PARTITION
  655.         echo "  - Writing to flash; this may take a while..."
  656.         cat $update_partition/$KERNEL_FILE > $KERNEL_PARTITION
  657.         if test $? -ne 0
  658.         then
  659.             echo "An error occured while updating the kernel!"
  660.             loopForever
  661.         else
  662.             echo "Finished updating kernel."
  663.         fi
  664.     else
  665.         echo "kernel file not found!  Exiting..."
  666.         loopForever
  667.     fi
  668.  
  669.     cp $update_partition/$KERNEL_FILE /dev/null 2>&1 | grep -q "Input/output"
  670.     if test $? -ne 0
  671.     then
  672.         # repeat for partition 2
  673.         echo "Flashing $KERNEL_FILE into backup partition..."
  674.         echo "  - Erasing flash; this may take a while..."
  675.         flash_eraseall $KERNEL2_PARTITION
  676.         echo "  - Writing to flash; this may take a while..."
  677.         cat $update_partition/$KERNEL_FILE > $KERNEL2_PARTITION
  678.         if test $? -ne 0
  679.         then
  680.             echo "An error occured while updating the backup kernel!"
  681.             loopForever
  682.         else
  683.             echo "Finished updating backup kernel."
  684.         fi
  685.     else
  686.         echo "Kernel file not found! Exiting..."
  687.         loopForever
  688.     fi
  689. fi
  690.  
  691. if test $filesystem_found = "yes"
  692. then
  693.     echo "Updating filesystem... DO NOT TURN OFF THE SYSTEM!!!!"
  694.     cp $update_partition/$FILESYSTEM_FILE /dev/null 2>&1 | grep -q "Input/output"
  695.     if test $? -ne 0
  696.     then
  697.         umount $FS3_BLOCKPARTITION >/dev/null 2>&1
  698.         echo "  - Erasing flash; this may take a while..."
  699.         flash_eraseall $FS3_PARTITION
  700.         echo "  - Writing to flash; this may take a while..."
  701.         cat $update_partition/$FILESYSTEM_FILE >$FS3_PARTITION
  702.         if test $? -ne 0
  703.         then
  704.             echo  "An error occured while updating the root filesystem!"
  705.             loopForever
  706.         fi
  707.  
  708.         echo "  - Finishing up; this may take a while..."
  709.         sync
  710.         sync
  711.         echo "Finished updating filesystem."
  712.     else
  713.         echo "Filesystem file not found! Exiting..."
  714.         loopForever
  715.     fi
  716. fi
  717.  
  718. # The bootloader upgrade used to happen at the start of the process,
  719. # but now occurs near the end.  See the comment about the 15-second
  720. # wait above for more information about why this is done.
  721. if test $bootloader_found = "yes"
  722. then
  723.     echo "Flashing $BOOTLOADER_FILE... DO NOT TURN OFF THE SYSTEM!!!!"
  724.     # Perform a final sanity check to make sure the file is available
  725.     # before it is erased
  726.     cp $update_partition/$BOOTLOADER_FILE /dev/null 2>&1 | grep -q "Input/output"
  727.     if test $? -ne 0
  728.     then
  729.         echo "  - Erasing flash; this may take a while..."
  730.         flash_eraseall $BOOTLOADER_PARTITION
  731.         echo "  - Writing to flash; this may take a while..."
  732.         cat $update_partition/$BOOTLOADER_FILE > $BOOTLOADER_PARTITION
  733.         if test $? -ne 0
  734.         then
  735.             echo "An error occured while updating the bootloader!"
  736.             loopForever
  737.         else
  738.             echo "Finished updating bootloader."
  739.         fi
  740.     else
  741.         echo "File is not available! Exiting...."
  742.         loopForever
  743.     fi
  744. fi
  745.  
  746. if test $update_env_found = "yes"
  747. then
  748.     $update_partition/$UPDATE_ENV_FILE
  749. fi
  750.  
  751. # Mount /usr/local/nv filesystem
  752. mount -t jffs2 $FS2_BLOCKPARTITION /mnt/nvfs
  753. if test $? -ne 0
  754. then
  755.     echo "Mount of /usr/local/nv failed - erasing"  
  756.     flash_eraseall $FS2_PARTITION
  757.     mount -t jffs2 $FS2_BLOCKPARTITION /mnt/nvfs
  758.     mkdir -p /mnt/nvfs/usr/local/nv
  759. fi
  760.  
  761. # Create /usr/local/nv directory if necessary
  762. if ! test -e /mnt/nvfs/usr/local/nv
  763. then
  764.     mkdir -p /mnt/nvfs/usr/local/nv
  765. fi
  766.  
  767. #        
  768. # Take all existing setup*.set files (these are user-saved setups)
  769. # found in flash, and assemble them into a single, large userSaves.set
  770. # file.  This file will be run on startup and will load all of these
  771. # setups into the correct internal setup slots.
  772. #
  773. if test $gen_saveall_found = "yes"
  774. then
  775.     $update_partition/$GEN_SAVEALL_FILE
  776. fi
  777.  
  778. #
  779. # Write a file to the filesystem telling the scope application that the
  780. # firmware was updated.  Also, at this time, if a front panel update
  781. # file was found, we'll copy it to the filesystem while we have it
  782. # mounted.
  783. #
  784. echo "Marking update as complete in flash..."
  785. touch /mnt/permfs/usr/local/perm/$UPDATE_COMPLETE_FILE
  786.  
  787. # Delete *all* of the keys in /usr/local/nv (not just nvkey20.dat)
  788. if test -e /mnt/nvfs/usr/local/nv
  789. then
  790.     rm -f /mnt/nvfs/usr/local/nv/nvkey*.dat
  791. fi
  792.  
  793. if test $fp_update_found = "yes"
  794. then
  795.     cp -f $update_partition/$FP_UPDATE_FILE /mnt/permfs/usr/local/perm/$FP_UPDATE_FILE
  796.     cp -f $update_partition/$FP_VERSION_FILE /mnt/permfs/usr/local/perm/$FP_VERSION_FILE
  797. fi
  798.  
  799. if test $fe_update_found = "yes"
  800. then
  801.     cp -f $update_partition/$FE_UPDATE_FILE /mnt/nvfs/usr/local/nv/$FE_UPDATE_FILE
  802.     cp -f $update_partition/$FE_VERSION_FILE /mnt/nvfs/usr/local/nv/$FE_VERSION_FILE
  803. fi
  804.  
  805. sync
  806. sync
  807. umount /mnt/rootfs >/dev/null 2>&1
  808. umount /mnt/permfs >/dev/null 2>&1
  809. umount /mnt/nvfs >/dev/null 2>&1
  810.  
  811. /usr/share/tek/$DISP_BMP /tmp/ram/firmware_complete4.bmp
  812. echo "Update is complete. Please power cycle your instrument now."
  813.  
  814. # Loop forever after displaying the message to power cycle on screen
  815. loopForever
Add Comment
Please, Sign In to add comment