altbootcmd=echo "ERROR: Maximum boot count reached!"; tlv errstate; anything_else_needs_flashing=echo "INFO: Starting anything else needs flashing..."; if test ${XLOADER_NEEDS_FLASHING} = yes || test ${ROOTFS_NEEDS_FLASHING} = yes || test ${KERNEL_NEEDS_FLASHING} = yes; then echo "INFO: kernel partition being erased"; run eraseuImage; KERNEL_NEEDS_FLASHING=yes; fi; if test ${XLOADER_NEEDS_FLASHING} = yes; then if tlv chnkhdr ${tlv_load_addr} x-loader; then echo "INFO: xloader in download partition TLV update image"; statusled green blink; nandecc hw 2; echo "INFO: xloader partition being erased"; nand erase ${TLV_CHNK_DEST}; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_CHNK_SIZE=${TLV_DECRYPT_XLOADER_CHNK_SIZE}; fi; echo "INFO: writing xloader to flash..."; if nand write ${TLV_CHNK_DATA} ${TLV_CHNK_DEST} ${TLV_CHNK_SIZE}; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate; fi; nandecc hw 1; XLOADER_VERS=${TLV_CHNK_VERS};fi; fi; if test ${ROOTFS_NEEDS_FLASHING} = yes; then if tlv chnkhdr ${tlv_load_addr} rootfs; then echo "INFO: rootfs in download partition TLV update image"; statusled green blink; nandecc hw 1; echo "INFO: erasing rootfs partition"; run eraseRfs; if ubi part rootfs 2048; then echo "INFO: rootfs is a valid ubi partition"; fi; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_CHNK_SIZE=${TLV_DECRYPT_ROOTFS_CHNK_SIZE}; fi; echo "INFO: need to create ubi nuvo-tesla-rootfs volume first..."; if ubi create nuvo-tesla-rootfs; then echo "INFO: successfully created volume, nuvo-tesla-rootfs..."; echo "INFO: writing ubi rootfs to flash..."; if ubi write ${TLV_CHNK_DATA} nuvo-tesla-rootfs ${TLV_CHNK_SIZE}; then echo "INFO: successfully wrote rootfs to flash after volume, nuvo-tesla-rootfs, was created..."; else echo "ERROR: failed to write rootfs to flash after volume, nuvo-tesla-rootfs, was created"; tlv errstate; fi; else echo "ERROR: failed to create volume, nuvo-tesla-rootfs"; tlv errstate; fi; ROOTFS_VERS=${TLV_CHNK_VERS};else echo "ERROR: rootfs not in download partition TLV update image"; tlv errstate; fi; fi; if test ${KERNEL_NEEDS_FLASHING} = yes; then if tlv chnkhdr ${tlv_load_addr} kernel; then echo "INFO: kernel in download partition TLV update image"; statusled green blink; nandecc hw 1; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_CHNK_SIZE=${TLV_DECRYPT_KERNEL_CHNK_SIZE}; fi; echo "INFO: writing kernel to flash..."; if nand write ${TLV_CHNK_DATA} ${TLV_CHNK_DEST} ${TLV_CHNK_SIZE}; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate; fi; KERNEL_VERS=${TLV_CHNK_VERS};else echo "ERROR: kernel not in download partition TLV update image"; tlv errstate; fi; fi; if test ${XLOADER_NEEDS_FLASHING} = yes; then echo "INFO: setting xloader_vers in environment..."; setenv xloader_vers ${XLOADER_VERS};fi; if test ${ROOTFS_NEEDS_FLASHING} = yes; then echo "INFO: setting rootfs_vers in environment..."; setenv rootfs_vers ${ROOTFS_VERS};fi; if test ${KERNEL_NEEDS_FLASHING} = yes; then echo "INFO: setting kernel_vers in environment..."; setenv kernel_vers ${KERNEL_VERS};fi; if test ${XLOADER_NEEDS_FLASHING} = yes || test ${ROOTFS_NEEDS_FLASHING} = yes || test ${KERNEL_NEEDS_FLASHING} = yes; then echo "INFO: saving environment..."; saveenv;fi; echo "INFO: Completed anything else needs flashing."; baudrate=115200 bootcmd=run legacy_boot bootcount=1 bootdelay=1 bootlimit=6 buildtime_uboot_version=00000001.00000000.00000004.0ab1cffc console=ttyO2,115200n8 does_anything_else_need_flashing=echo "INFO: Start check if anything else needs flashing..."; UPDATE _ROOTFS=no; if tlv chnkhdr ${tlv_load_addr} rootfs; then echo "INFO: rootfs in download partition TL V update image"; if fwup fail || test -z ${rootfs_vers}; then if fwup fail; then echo "INFO: Fail fl ag is set"; fi; if test -z ${rootfs_vers}; then echo "INFO: rootfs_vers is missing"; fi; UPDATE_ROOT FS=yes; elif fwup update && test ${rootfs_vers}_ != ${TLV_CHNK_VERS}_; then echo "INFO: Update flag is set AND rootfs_vers(${rootfs_vers}) not equal TLV_CHNK_VERS(${TLV_CHNK_VERS})"; UPDATE_ROOTFS=yes ; fi; if test ${UPDATE_ROOTFS} = yes; then echo "INFO: rootfs needs flashing..."; run handle_cr32; r un handle_md5_; run handle_sha2; run handle_encm; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_DECR YPT_ROOTFS_CHNK_SIZE=${TLV_CHNK_SIZE}; fi; ROOTFS_NEEDS_FLASHING=yes; fi; else echo "INFO: rootfs no t in download partition TLV update image"; fi; UPDATE_KERNEL=no; if tlv chnkhdr ${tlv_load_addr} ker nel; then echo "INFO: kernel in download partition TLV update image"; if fwup fail || test -z ${kern el_vers}; then if fwup fail; then echo "INFO: Fail flag is set"; fi; if test -z ${kernel_vers}; then echo "INFO: kernel_vers is missing"; fi; UPDATE_KERNEL=yes; elif fwup update && test ${kernel_vers} _ != ${TLV_CHNK_VERS}_; then echo "INFO: Update flag is set AND kernel_vers(${kernel_vers}) not equa l TLV_CHNK_VERS(${TLV_CHNK_VERS})"; UPDATE_KERNEL=yes; fi; if test ${UPDATE_KERNEL} = yes; then echo "INFO: kernel needs flashing..."; run handle_cr32; run handle_md5_; run handle_sha2; run handle_enc m; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_DECRYPT_KERNEL_CHNK_SIZE=${TLV_CHNK_SIZE}; fi; KERN EL_NEEDS_FLASHING=yes; fi; else echo "INFO: kernel not in download partition TLV update image"; fi; echo "INFO: Completed check if anything else needs flashing"; does_uboot_ubootenv_xloader_need_flashing=echo "INFO: Start check if uboot/ubootenv/xloader needs fl ashing..."; if fwup fail || fwup update || test -z ${xloader_vers} || test -z ${uboot_vers} || test -z ${ubootenv_vers} || test -z ${kernel_vers} || test -z ${rootfs_vers}; then if fwup fail; then ech o "INFO: Fail flag is set"; fi; if fwup update; then echo "INFO: Update flag is set"; fi; if test -z ${xloader_vers}; then echo "INFO: xloader_vers is missing"; fi; if test -z ${uboot_vers}; then echo "INFO: uboot_vers is missing"; fi; if test -z ${ubootenv_vers}; then echo "INFO: ubootenv_vers is m issing"; fi; if test -z ${kernel_vers}; then echo "INFO: kernel_vers is missing"; fi; if test -z ${r ootfs_vers}; then echo "INFO: rootfs_vers is missing"; fi; if tlv chnkhdr ${tlv_load_addr} u-boot; t hen echo "INFO: uboot in download partition TLV update image"; if test -z ${uboot_vers} || test ${ub oot_vers}_ != ${TLV_CHNK_VERS}_; then if test ${uboot_vers}_ < 00000001.00000000.00000000.00000000 | | test ${TLV_CHNK_VERS} > 00000000.ffffffff.ffffffff.ffffffff; then if test -z ${uboot_vers}; then e cho "INFO: uboot_vers is missing"; fi; if test ${uboot_vers}_ != ${TLV_CHNK_VERS}_; then echo "INFO: uboot_vers(${uboot_vers}) not equal TLV_CHNK_VERS(${TLV_CHNK_VERS})"; fi; echo "INFO: u-boot needs flashing..."; run handle_cr32; run handle_md5_; run handle_sha2; run handle_encm; if test ${TLV_CHNK _ENCM} = 00000001; then TLV_DECRYPT_UBOOT_CHNK_SIZE=${TLV_CHNK_SIZE}; fi; UBOOT_NEEDS_FLASHING=yes; else echo "INFO: u-boot cannot downgrade to below 00000001.00000000"; fi; fi; else echo "INFO: u-boo t not in download partition TLV update image"; fi; if tlv chnkhdr ${tlv_load_addr} u-boot-env; then echo "INFO: uboot environment in download partition TLV update image"; if test -z ${ubootenv_vers} | | test ${ubootenv_vers}_ != ${TLV_CHNK_VERS}_; then if test ${ubootenv_vers}_ < 00000001.00000000.00 000000.00000000 || test ${TLV_CHNK_VERS} > 00000000.ffffffff.ffffffff.ffffffff; then if test -z ${ub ootenv_vers}; then echo "INFO: ubootenv_vers is missing"; fi; if test ${ubootenv_vers}_ != ${TLV_CHN K_VERS}_; then echo "INFO: ubootenv_vers(${ubootenv_vers}) not equal TLV_CHNK_VERS(${TLV_CHNK_VERS}) "; fi; echo "INFO: u-boot-env needs flashing..."; run handle_cr32; run handle_md5_; run handle_sha2; run handle_encm; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_DECRYPT_UBOOTENV_CHNK_SIZE=${TLV_CHN K_SIZE}; fi; UBOOTENV_NEEDS_FLASHING=yes; else echo "INFO: u-boot environment cannot downgrade to be low 00000001.00000000"; fi; fi; else echo "INFO: u-boot-env not in download partition TLV update ima ge"; fi; if tlv chnkhdr ${tlv_load_addr} x-loader; then echo "INFO: x-loader in download partition T LV update image"; if test -z ${xloader_vers} || test ${xloader_vers}_ != ${TLV_CHNK_VERS}_; then if test ${xloader_vers}_ < 00000001.00000000.00000000.00000000 || test ${TLV_CHNK_VERS} > 00000000.ffff ffff.ffffffff.ffffffff; then if test -z ${xloader_vers}; then echo "INFO: xloader_vers is missing"; fi; if test ${xloader_vers}_ != ${TLV_CHNK_VERS}_; then echo "INFO: xloader_vers(${xloader_vers}) no t equal TLV_CHNK_VERS(${TLV_CHNK_VERS})"; fi; echo "INFO: x-loader needs flashing..."; run handle_cr 32; run handle_md5_; run handle_sha2; run handle_encm; if test ${TLV_CHNK_ENCM} = 00000001; then TLV _DECRYPT_XLOADER_CHNK_SIZE=${TLV_CHNK_SIZE}; fi; XLOADER_NEEDS_FLASHING=yes; else echo "INFO: x-load er cannot downgrade to below 00000001.00000000"; fi; fi; else echo "INFO: x-loader not in download p artition TLV update image"; fi; fi; echo "INFO: Completed check if uboot/ubootenv/xloader needs flas hing"; dumpTlvRamImage=run usbmount; if usb storage; then fatstore usb 0 ${tlv_load_addr} datadump.bin ${pa rtDownloadSize}; fi; eraseConstants=if nand erase constants; then echo "INFO: nand erase successful"; else echo "ERROR: n and erase failed"; tlv errstate; fi; eraseDatabase=if nand erase database; then echo "INFO: nand erase successful"; else echo "ERROR: nan d erase failed"; tlv errstate; fi; eraseDownload=if nand erase download; then echo "INFO: nand erase successful"; else echo "ERROR: nan d erase failed"; tlv errstate; fi; eraseRfs=if nand erase rootfs; then echo "INFO: nand erase successful"; else echo "ERROR: nand erase failed"; tlv errstate; fi; eraseUboot=if nand erase u-boot; then echo "INFO: nand erase successful"; else echo "ERROR: nand era se failed"; tlv errstate; fi; eraseUbootEnv=if nand erase u-boot-env; then echo "INFO: nand erase successful"; else echo "ERROR: n and erase failed"; tlv errstate; fi; eraseXloader=if nand erase x-loader; then echo "INFO: nand erase successful"; else echo "ERROR: nand erase failed"; tlv errstate; fi; eraseuImage=if nand erase kernel; then echo "INFO: nand erase successful"; else echo "ERROR: nand er ase failed"; tlv errstate; fi; etharg=smsc95xx_mac=00:25:ED:1B:08:02 flashConstants=echo "INFO: usb thumbdrive constants check..."; run usbmount; if usb storage; then if fatfind usb 0 / constants.bin; then mw.b ${tlv_load_addr} 0x00 ${partConstantsSize}; if fatload usb 0 ${tlv_load_addr} constants.bin; then nandecc hw 1; echo "INFO: constants partition being erased"; run eraseConstants; echo "INFO: writing constants to flash..."; run writeConstants; else echo "ERRO R: failed to load constants.bin from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device ..."; fi; echo "INFO: usb thumbdrive constants complete"; flashUboot=echo "INFO: usb thumbdrive u-boot check..."; run usbmount; if usb storage; then if fatfin d usb 0 / u-boot.bin; then statusled green blink; mw.b ${tlv_load_addr} 0xff ${partUbootSize}; if fa tload usb 0 ${tlv_load_addr} u-boot.bin; then nandecc hw 2; echo "INFO: u-boot partition being erase d"; run eraseUboot; echo "INFO: writing u-boot to flash..."; run writeUboot; nandecc hw 1; else echo "ERROR: failed to load u-boot.bin from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage dev ice..."; fi; echo "INFO: usb thumbdrive u-boot complete"; flashUbootEnv=echo "INFO: usb thumbdrive u-boot environment check..."; run usbmount; if usb storage; then if fatfind usb 0 / u-boot-env; then mw.b ${tlv_load_addr} 0xff ${partUbootEnvSize}; if fatload usb 0 ${tlv_load_addr} u-boot-env; then nandecc hw 1; echo "INFO: u-boot-env partition being erased "; run eraseUbootEnv; echo "INFO: writing u-boot environment to flash..."; run writeUbootEnv; else e cho "ERROR: failed to load u-boot-env from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: usb thumbdrive u-boot environment complete"; flashXloader=echo "INFO: usb thumbdrive x-loader check..."; run usbmount; if usb storage; then if fa tfind usb 0 / x-load.bin.ift; then statusled green blink; mw.b ${tlv_load_addr} 0xff ${partXloaderSi ze}; if fatload usb 0 ${tlv_load_addr} x-load.bin.ift; then nandecc hw 2; echo "INFO: x-loader parti tion being erased"; run eraseXloader; echo "INFO: writing x-loader to flash..."; run writeXloader; n andecc hw 1; else echo "ERROR: failed to load x-load.bin.ift from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: usb thumbdrive x-loader complete"; flashall=run usbmount; if usb storage; then run flashXloader; run flashUboot; run flashuImage; run f lashrfs; fi; flashrfs=echo "INFO: usb thumbdrive rootfs check..."; run usbmount; if usb storage; then if fatfind usb 0 / ubifs.img; then statusled green blink; nandecc hw 1; echo "INFO: erasing rootfs partition"; run eraseRfs; if ubi part rootfs 2048; then echo "INFO: rootfs is a valid ubi partition"; fi; if fatload usb 0 ${tlv_load_addr} ubifs.img; then echo "INFO: need to create ubi nuvo-tesla-rootfs volume first..."; if ubi create nuvo-tesla-rootfs; then echo "INFO: successfully created volume, nuvo-tesla-rootfs..."; if ubi write ${tlv_load_addr} nuvo-tesla-rootfs ${filesize}; then echo "INFO: successfully wrote rootfs to flash after volume, nuvo-tesla-rootfs, was created..."; else echo "ERROR: failed to write rootfs to flash after volume was created"; fi; else echo "ERROR: failed to create volume, nuvo-tesla-rootfs"; fi; else echo "ERROR: failed to load ubifs.img from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: usb thumbdrive rootfs complete"; setenv flashrfs 'echo "INFO: usb thumbdrive rootfs check..."; run usbmount; if usb storage; then if fatfind usb 0 / ubifs.img; then statusled green blink; nandecc hw 1; echo "INFO: erasing rootfs partition"; run eraseRfs; if ubi part rootfs 2048; then echo "INFO: rootfs is a valid ubi partition"; fi; if fatload usb 0 ${tlv_load_addr} ubifs.img; then echo "INFO: need to create ubi nuvo-tesla-rootfs volume first..."; if ubi create nuvo-tesla-rootfs; then echo "INFO: successfully created volume, nuvo-tesla-rootfs..."; if ubi write ${tlv_load_addr} nuvo-tesla-rootfs ${filesize}; then echo "INFO: successfully wrote rootfs to flash after volume, nuvo-tesla-rootfs, was created..."; else echo "ERROR: failed to write rootfs to flash after volume was created"; fi; else echo "ERROR: failed to create volume, nuvo-tesla-rootfs"; fi; else echo "ERROR: failed to load ubifs.img from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: usb thumbdrive rootfs complete";' flashuImage=echo "INFO: usb thumbdrive kernel check..."; run usbmount; if usb storage; then if fatfind usb 0 / uImage; then statusled green blink; mw.b ${tlv_load_addr} 0xff ${partuImageSize}; if fatload usb 0 ${tlv_load_addr} uImage; then nandecc hw 1; echo "INFO: kernel partition being erased"; run eraseuImage; echo "INFO: writing kernel to flash..."; run writeuImage; else echo "ERROR: failed to load uImage from usb thumbdrive"; fi; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: usb thumbdrive kernel complete"; handle_cr32=if test -n ${TLV_CHNK_CR32}; then if crc32 ${TLV_CHNK_DATA} ${TLV_CHNK_SIZE}; then if te st ${CRC32} = ${TLV_CHNK_CR32}; then echo "INFO: crc32 match"; else echo "ERROR: crc32 mismatch ${CR C32} ${TLV_CHNK_CR32}"; tlv errstate; fi; else echo "ERROR: crc32 failed"; tlv errstate; fi; else ec ho "INFO: no chunk crc32 option"; fi; handle_encm=if test ${TLV_CHNK_ENCM} = 00000001; then if tlv decrypt ${TLV_CHNK_DATA} ${TLV_CHNK_SIZ E}; then echo "INFO: chunk decrypt successful"; else echo "ERROR: chunk decrypt failed"; tlv errstat e; fi; elif test ${TLV_CHNK_ENCM} = 00000000; then echo "INFO: chunk not encrypted"; else echo "ERRO R: encryption method invalid (${TLV_CHNK_ENCM})"; tlv errstate; fi; handle_md5_=if test -n ${TLV_CHNK_MD5_}; then if md5sum ${TLV_CHNK_DATA} ${TLV_CHNK_SIZE}; then if t est ${MD5SUM} = ${TLV_CHNK_MD5_}; then echo "INFO: md5 match"; else echo "ERROR: md5 mismatch ${MD5S UM} ${TLV_CHNK_MD5_}"; tlv errstate; fi; else echo "ERROR: md5sum failed"; tlv errstate; fi; else ec ho "INFO: no chunk md5 option"; fi; handle_sha2=if test -n ${TLV_CHNK_SHA2}; then if sha256sum ${TLV_CHNK_DATA} ${TLV_CHNK_SIZE}; then i f test ${SHA256SUM} = ${TLV_CHNK_SHA2}; then echo "INFO: sha256 match"; else echo "ERROR: sha256 mis match ${SHA256SUM} ${TLV_CHNK_SHA2}"; tlv errstate; fi; else echo "ERROR: sha256sum failed"; tlv err state; fi; else echo "INFO: no chunk sha256 option"; fi; kernel_vers=00000001.00000000.00000013.0c4ca47a legacy_boot=echo "INFO: attempting legacy (dofwupdate) boot..."; run usbmount; if usb storage; then if fatfind usb 0 / dofwupdate; then echo "INFO: dofwupdate found on usb thumbdrive..."; run flashall; statusled white blink; run nandboot; fi; else echo "INFO: no usb storage device..."; fi; echo "INFO: legacy boot not performed...missing dofwupdate or no usb thumbdrive..."; echo "INFO: attempting TLV boot..."; run tlv_boot; loadaddr=0x80200000 mtddevname=x-loader mtddevnum=0 mtdids=nand0=nand mtdpartitions=mtdparts=omap2-nand.0:0x00020000(x-loader),0x00180000(u-boot),0x00080000(u-boot-env),0x00080000(constants),0x03F00000(database),0x00560000(kernel),0x05A00000(rootfs),0x05F00000(download) mtdparts=mtdparts=nand:0x00020000(x-loader),0x00180000(u-boot),0x00080000(u-boot-env),0x00080000(constants),0x03F00000(database),0x00560000(kernel),0x05A00000(rootfs),0x05F00000(download) nandargs=setenv bootargs console=${console} root=${nandroot} rootfstype=${nandrootfstype} ${mtdpartitions} ${etharg} ${otherbootargs} ${panicargs} ${wdtargs} ${smsc95xx_args} nandboot=echo "Booting from nand ..."; run nandargs; nandecc hw 1; echo "INFO: loading kernel image into RAM..."; run readuImage; echo "INFO: booting kernel image..."; bootm ${tlv_load_addr}; echo "INFO: kernel boot failed..."; echo "INFO: resetting..."; reset; nandroot=ubi0:nuvo-tesla-rootfs ubi.mtd=6,2048 rw nandrootfstype=ubifs otherbootargs=db_hwid=2 db_rev=0 panicargs=panic=10 mem=127M partConstantsBase=0x00220000 partConstantsSize=0x00080000 partDatabaseBase=0x002A0000 partDatabaseSize=0x03F00000 partDownloadBase=0x0A100000 partDownloadSize=0x05F00000 partRfsBase=0x04700000 partRfsSize=0x05A00000 partUbootBase=0x00020000 partUbootEnvBase=0x001A0000 partUbootEnvSize=0x00080000 partUbootSize=0x00180000 partXloaderBase=0x00000000 partXloaderSize=0x00020000 partition=nand0,0 partuImageBase=0x041A0000 partuImageSize=0x00560000 readuImage=nand read ${tlv_load_addr} kernel rootfs_vers=54ec3a74.01b0009d.0df3fb19.00808799 smsc95xx_args=smsc95xx.turbo_mode=N stderr=serial stdin=serial stdout=serial tlv_boot=echo "INFO: TLV firmware update process started..."; if fwup fail; then if test ${bootcount } -eq ${bootlimit}; then nandecc hw 1; echo "INFO: bootcount(${bootcount}) equals bootlimit(${bootli mit})"; echo "INFO: erasing database partition"; run eraseDatabase; if ubi part database 2048; then echo "INFO: database is a valid ubi partition"; echo "INFO: creating volume nuvo-tesla-database..."; if ubi create nuvo-tesla-database; then echo "INFO: successfully created volume, nuvo-tesla-databas e..."; else echo "ERROR: failed to create volume, nuvo-tesla-database"; tlv errstate; fi; fi; fi; if test ${bootcount} -gt ${bootlimit}; then echo "INFO: bootcount(${bootcount}) greater than bootlimit (${bootlimit})"; statusled red on; echo "ERROR: Maximum boot count reached!"; tlv errstate; fi; fi; run usbmount; if usb storage; then if test ${bootcount} -eq 1; then echo "INFO: bootcount(${bootcoun t}) equals 1"; if fatfind usb 0 / tlvupdate; then echo "INFO: tlvupdate image found on USB thumbdriv e"; statusled green blink; run update_download; fi; fi; fi; if fwup fail || fwup update || test -z $ {xloader_vers} || test -z ${uboot_vers} || test -z ${ubootenv_vers} || test -z ${kernel_vers} || tes t -z ${rootfs_vers}; then if fwup fail; then echo "INFO: Fail flag is set"; fi; if fwup update; then echo "INFO: Update flag is set"; fi; if test -z ${xloader_vers}; then echo "INFO: xloader_vers is m issing"; fi; if test -z ${uboot_vers}; then echo "INFO: uboot_vers is missing"; fi; if test -z ${ubo otenv_vers}; then echo "INFO: ubootenv_vers is missing"; fi; if test -z ${kernel_vers}; then echo "I NFO: kernel_vers is missing"; fi; if test -z ${rootfs_vers}; then echo "INFO: rootfs_vers is missing "; fi; statusled green blink; echo "INFO: Need to read the tlvupdate from download partition..."; if nand read ${tlv_load_addr} download 0x10; then if tlv magic ${tlv_load_addr}; then echo "INFO: tlvu pdate image total length is ${TLV_TOTAL_LEN}"; if nand read ${tlv_load_addr} download ${TLV_TOTAL_LE N}; then if tlv valid ${tlv_load_addr}; then echo "INFO: TLV image in download partition is valid"; else echo "ERROR: TLV image in download partition is invalid"; if fwup update; then echo "INFO: tryi ng to boot old system"; run tlv_boot_kernel; else tlv errstate; fi; fi; else echo "ERROR: nand read failed"; tlv errstate; fi; else echo "ERROR: TLV image in download partition is invalid"; if fwup up date; then echo "INFO: trying to boot old system"; run tlv_boot_kernel; else tlv errstate; fi; fi; e lse echo "ERROR: nand read failed"; tlv errstate; fi; UBOOT_NEEDS_FLASHING=no; UBOOTENV_NEEDS_FLASHI NG=no; XLOADER_NEEDS_FLASHING=no; ROOTFS_NEEDS_FLASHING=no; KERNEL_NEEDS_FLASHING=no; run does_uboot _ubootenv_xloader_need_flashing; run does_anything_else_need_flashing; run uboot_or_ubootenv_need_fl ashing; run anything_else_needs_flashing; fi; echo "INFO: TLV firmware update process completed"; ru n tlv_boot_kernel; tlv_boot_kernel=echo "INFO: clearing update flag..."; fwup clear update; echo "INFO: setting fail flag..."; fwup set fail; statusled white blink; run nandboot; tlv_load_addr=0x80200000 uboot_or_ubootenv_need_flashing=UBOOT_RESET=no; echo "INFO: Starting u-boot or u-boot-env need flash ing..."; UBOOT_VERS=${uboot_vers}; UBOOTENV_VERS=${ubootenv_vers}; XLOADER_VERS=${xloader_vers}; ROO TFS_VERS=${rootfs_vers}; KERNEL_VERS=${kernel_vers}; if test ${UBOOT_NEEDS_FLASHING} = yes; then if tlv chnkhdr ${tlv_load_addr} u-boot; then echo "INFO: uboot in download partition TLV update image"; nandecc hw 2; statusled green blink; echo "INFO: u-boot partition being erased"; nand erase ${TLV_C HNK_DEST}; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_CHNK_SIZE=${TLV_DECRYPT_UBOOT_CHNK_SIZE}; f i; echo "INFO: writing uboot to flash..."; if nand write ${TLV_CHNK_DATA} ${TLV_CHNK_DEST} ${TLV_CHN K_SIZE}; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate ; fi; nandecc hw 1; UBOOT_VERS=${TLV_CHNK_VERS}; UBOOT_RESET=yes; else echo "ERROR: u-boot not in do wnload partition TLV update image"; tlv errstate; fi; fi; if test ${UBOOTENV_NEEDS_FLASHING} = yes; then if tlv chnkhdr ${tlv_load_addr} u-boot-env; then echo "INFO: uboot environment in download part ition TLV update image"; nandecc hw 1; statusled green blink; echo "INFO: u-boot-env partition being erased"; nand erase ${TLV_CHNK_DEST}; if test ${TLV_CHNK_ENCM} = 00000001; then TLV_CHNK_SIZE=${TLV _DECRYPT_UBOOTENV_CHNK_SIZE}; fi; echo "INFO: writing uboot-env to flash..."; if nand write ${TLV_CH NK_DATA} ${TLV_CHNK_DEST} ${TLV_CHNK_SIZE}; then echo "INFO: nand write successful"; else echo "ERRO R: nand write failed"; tlv errstate; fi; echo "INFO: reloading uboot-env from flash to internal memo ry so new environment is used..."; env reload;UBOOTENV_VERS=${TLV_CHNK_VERS};UBOOT_RESET=yes; else e cho "ERROR: u-boot-env not in download partition TLV update image"; tlv errstate; fi; fi; if test ${ UBOOT_NEEDS_FLASHING} = yes || test ${UBOOTENV_NEEDS_FLASHING} = yes; then echo "INFO: setting uboot _vers in environment..."; setenv uboot_vers ${UBOOT_VERS};fi; if test ${UBOOTENV_NEEDS_FLASHING} = y es; then echo "INFO: setting ubootenv_vers in environment..."; setenv ubootenv_vers ${UBOOTENV_VERS} ;echo "INFO: restoring xloader_vers in environment..."; setenv xloader_vers ${XLOADER_VERS};echo "IN FO: restoring rootfs_vers in environment..."; setenv rootfs_vers ${ROOTFS_VERS};echo "INFO: restorin g kernel_vers in environment..."; setenv kernel_vers ${KERNEL_VERS};fi; if test ${UBOOT_NEEDS_FLASHI NG} = yes || test ${UBOOTENV_NEEDS_FLASHING} = yes; then echo "INFO: saving environment..."; saveenv ;fi; if test ${UBOOT_RESET} = yes; then echo "INFO: Resetting ..."; reset; fi;echo "INFO: Completed u-boot or u-boot-env need flashing."; uboot_vers=00000001.00000000.00000004.0ab1cffc ubootenv_vers=00000001.00000000.00000000.0b506e00 update_download=echo "INFO: usb thumbdrive tlvupdate check..."; if fatload usb 0 ${tlv_load_addr} tl vupdate; then echo "INFO: TLV update image found on usb thumbdrive"; if tlv valid ${tlv_load_addr}; then nandecc hw 1; echo "INFO: TLV image valid"; echo "INFO: download partition being erased"; nand erase download; echo "INFO: writing tlvupdate image to flash..."; if nand write ${tlv_load_addr} dow nload ${filesize}; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tl v errstate; fi; echo "INFO: setting USB update flag..."; fwup set usbupdate; echo "INFO: setting fai l flag..."; fwup set fail; echo "INFO: reseting..."; reset; else echo "INFO: TLV image invalid"; fi; else echo "INFO: TLV image USB load failed"; fi; echo "INFO: usb thumbdrive tlvupdate check complet e"; usbmount=usb reset wdt_timeout=600 wdtargs=omap_wdt.timer_margin=600 omap_wdt.pwrup_disable=0 writeConstants=if nand write ${tlv_load_addr} constants; then echo "INFO: nand write successful"; el se echo "ERROR: nand write failed"; tlv errstate; fi; writeDatabase=if nand write ${tlv_load_addr} database; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate; fi; writeUboot=if nand write ${tlv_load_addr} u-boot; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate; fi; writeUbootEnv=if nand write ${tlv_load_addr} u-boot-env; then echo "INFO: nand write successful"; el se echo "ERROR: nand write failed"; tlv errstate; fi; writeXloader=if nand write ${tlv_load_addr} x-loader; then echo "INFO: nand write successful"; else echo "ERROR: nand write failed"; tlv errstate; fi; writeuImage=if nand write ${tlv_load_addr} kernel; then echo "INFO: nand write successful"; else ech o "ERROR: nand write failed"; tlv errstate; fi; xloader_vers=00000001.00000000.00000002.029b1dd7