# # Module: debrick script # # Description: This program is used to demostrate concatenate binary # images. # # Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ # # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. # # Neither the name of Texas Instruments Incorporated nor the names of # its contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # expect the following parameters to be set outside this script # serverip which should happen as part of the dhcp process # setenv READY_RETRY_DELAY 5 setenv IMAGE_CNT 8 # Name of Image containing all images to be tftp'd from host setenv ImageName flash-image.out #Name of Images to be flashed, MLO image will have 3 backups setenv Image1_Name MLO-am335x-evm setenv Image2_Name device-tree-am335x-evm.dtb setenv Image3_Name u-boot-am335x-evm.img setenv Image4_Name zImage-am335x-evm.bin setenv Image5_Name ubi.img # Image offsets into NAND - these are defined in the EVM configuration header # and should align with the Linux kernel. setenv Image1_NAND_Offset NAND.SPL setenv Image2_NAND_Offset NAND.SPL.backup1 setenv Image3_NAND_Offset NAND.SPL.backup2 setenv Image4_NAND_Offset NAND.SPL.backup3 setenv Image5_NAND_Offset NAND.u-boot-spl-os setenv Image6_NAND_Offset NAND.u-boot setenv Image7_NAND_Offset NAND.kernel setenv Image8_NAND_Offset NAND.file-system # Image offsets in ddr # This has to be calculated from the load address # this assumes the load address is 0x82000000 # Use the load address and the offset provided from the flash-cat utility to calculate setenv Image1_DDR_ADDR 0x82000000 setenv Image2_DDR_ADDR 0x82011000 setenv Image3_DDR_ADDR 0x8201B000 setenv Image4_DDR_ADDR 0x82076800 setenv Image5_DDR_ADDR 0x8238C000 # These numbers come from the flash-cat utility setenv Image1_Length 0x10F18 setenv Image2_Length 0x9BAB setenv Image3_Length 0x5B3B8 setenv Image4_Length 0x3152F0 setenv Image5_Length 0x2EE0000 # Set File Names to indicate progress setenv DebrickTargetReady DebrickTargetReady:${ethaddr} setenv TargetProgrammingComplete TargetProgrammingComplete:${ethaddr} setenv TargetErrorExit TargetErrorExit:${ethaddr} setenv TargetEraseError TargetEraseError:${ethaddr} setenv TargetProgrammingError TargetProgrammingError:${ethaddr} setenv TargetGetFileError TargetGetFileError:${ethaddr} #Need to halt processor due to a processing error in the script setenv DataAbort 'echo Halting processor.....; go 0x2001c;' # Define addresses where the messages will be sourced for the TFTP puts setenv image_msg1_addr 0x80008100 # Define System status messages of flashing #setenv GetReadyFileFromHost "tftp 0x80001000 ${serverip}:${HostReadyFile}" setenv DebrickStartingToHost "tftp 0x80001000 ${serverip}:${DebrickTargetReady}" setenv TargetProgrammingComplete "tftp 0x80001000 ${serverip}:${TargetProgrammingComplete}" setenv TargetProgrammingFailure "tftp 0x80001000 ${serverip}:${TargetProgrammingError}" setenv TargetErrorExit "tftp 0x80001000 ${serverip}:${TargetErrorExit}" setenv TargetEraseErrorExit "tftp 0x80001000 ${serverip}:${TargetEraseError}" setenv TargetGetFileFailure "tftp 0x80001000 ${serverip}:${TargetGetFileError}" # Define Image get command setenv GetImage 'tftpboot ${loadaddr} ${serverip}:${ImageName}' # Define Image succesful Complete get commands, these requests are detected # the gets will fail as the files don't exist, that ok. Using this as a # feedback feedback mechanism to indicate statusi # setenv DoneWithImage "tftp ${image_msg1_addr} ${serverip}:${ImageName}_Complete" # Erase NAND Macro # setenv EraseNand 'echo Erasing NAND; if nand erase.chip; then echo NAND Erased; echo; else echo NAND Erase Failure Error Exit; run TargetEraseErrorExit; run TargetErrorExit; run DataAbort; fi;' # Get Image Macro setenv GetFlashImage 'if run GetImage; then echo; echo Got Flash Image; else echo Get Flash Image Failed;run TargetGetFileFailure;run TargetErrorExit; run DataAbort; fi;' # Flash Image Macro setenv FlashImage 'if nand write ${source_addr} ${storage_offset} ${image_length}; then echo; echo ${ImageName} succesfully programmed;echo; else echo ${ImageName} Programming Failed... error exit;run TargetProgrammingFailure;run TargetErrorExit;echo; run DataAbort; fi;' # ------------------------------------------------------------------- # --- Execution Starts Here # ------------------------------------------------------------------- # --- Start The Process of Flashing # echo echo "Indicates to the host the Debrick script is running" echo run DebrickStartingToHost # #run EraseChip run EraseNand # # <<<<<<<<<<<< Start of Image Flashing>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # ------------------------------------------------------------------- # Get the single image containing all the files. # ------------------------------------------------------------------- echo echo Get Image containing all images to be flashed echo run GetFlashImage # ------------------------------------------------------------------- # Add a section for each Image to be flashed # For each Image to be flashed you will need to set the # following environments: # - Source Address in the Single Image # - Storage Offset into the Storage device # - Length of the image # - Image Name # ------------------------------------------------------------------- # Flash Image MLO #-------------------------------------------------------------------- setenv source_addr ${Image1_DDR_ADDR} setenv storage_offset ${Image1_NAND_Offset} setenv image_length ${Image1_Length} setenv ImageName ${Image1_Name} run FlashImage #-------------------------------------------------------------------- # Flash Image MLO backup 1 #-------------------------------------------------------------------- setenv source_addr ${Image1_DDR_ADDR} setenv storage_offset ${Image2_NAND_Offset} setenv image_length ${Image1_Length} setenv ImageName ${Image1_Name} run FlashImage #-------------------------------------------------------------------- # Flash Image MLO backup 2 #-------------------------------------------------------------------- setenv source_addr ${Image1_DDR_ADDR} setenv storage_offset ${Image3_NAND_Offset} setenv image_length ${Image1_Length} setenv ImageName ${Image1_Name} run FlashImage #-------------------------------------------------------------------- # Flash image MLO backup 3 #-------------------------------------------------------------------- setenv source_addr ${Image1_DDR_ADDR} setenv storage_offset ${Image4_NAND_Offset} setenv image_length ${Image1_Length} setenv ImageName ${Image1_Name} run FlashImage #-------------------------------------------------------------------- # Flash image Device Tree #-------------------------------------------------------------------- setenv source_addr ${Image2_DDR_ADDR} setenv storage_offset ${Image5_NAND_Offset} setenv image_length ${Image2_Length} setenv ImageName ${Image2_Name} run FlashImage #-------------------------------------------------------------------- # Flash image U-Boot #-------------------------------------------------------------------- setenv source_addr ${Image3_DDR_ADDR} setenv storage_offset ${Image6_NAND_Offset} setenv image_length ${Image3_Length} setenv ImageName ${Image3_Name} run FlashImage #-------------------------------------------------------------------- # Flash image Linux Kernel #-------------------------------------------------------------------- setenv source_addr ${Image4_DDR_ADDR} setenv storage_offset ${Image7_NAND_Offset} setenv image_length ${Image4_Length} setenv ImageName ${Image4_Name} run FlashImage #-------------------------------------------------------------------- # Flash image Filesystem #-------------------------------------------------------------------- setenv source_addr ${Image5_DDR_ADDR} setenv storage_offset ${Image8_NAND_Offset} setenv image_length ${Image5_Length} setenv ImageName ${Image5_Name} run FlashImage #-------------------------------------------------------------------- # # <<<<<<<<<<<<< End of Image Flashing >>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # # ------------------------------------------------------------------- # Indicate to Host successful completion run TargetProgrammingComplete echo echo " Target Flash Complete........" echo