# # Module: debrick script # # Description: This program is used to demostrate concatenate binary # images. # # Copyright (C) 2013 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 3 # Name of Image containing all images to be tftp'd from host setenv ImageName flash-image.out #Name of Images to be flashed setenv Image1_Name MLO.byteswap setenv Image2_Name u-boot.img setenv Image3_Name uImage # Image offsets into SPI Flash - these are defined in the linux board file setenv Image1_SPIFLASH_Offset 0x0 setenv Image2_SPIFLASH_Offset 0x80000 setenv Image3_SPIFLASH_Offset 0xE0000 # Image offsets in ddr # This has to be calculated from the load address # this assumes the load address is 0x80200000 # Use the load address and the offset provided from the flash-cat utility to calculate setenv Image1_DDR_ADDR 0x80200000 setenv Image2_DDR_ADDR 0x80218800 setenv Image3_DDR_ADDR 0x80271800 # These numbers come from the flash-cat utility setenv Image1_Length 0x18775 setenv Image2_Length 0x58D2C setenv Image3_Length 0x30BDE0 # 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 SPI-Flash Macro for 8MB chip - full erase. Modify the erase size to suit desired chip. setenv EraseSpiFlash 'echo; echo Erasing entire SPI-Flash, please wait...; if sf probe 0; then if sf erase 0 +800000; then echo SPI-Flash Erased; echo; else echo SPI-Flash Erase Failure Error Exit; run TargetEraseErrorExit; run TargetErrorExit; run DataAbort; fi; else echo Cannot detect SPI-Flash on board, check profile settings!; run TargetEraseErrorExit; run TargetErrorExit; run DataAbort; fi;' # Get Image Macro setenv GetSpiFlashImage 'if run GetImage; then echo; echo Got SPI-Flash Image; else echo Get SPI-Flash Image Failed; run TargetGetFileFailure; run TargetErrorExit; run DataAbort; fi;' # Flash SPI-Image Macro for 8MB chip. setenv FlashSpiImage 'if sf probe 0; then if sf write ${source_addr} ${storage_offset} ${image_length}; then echo; echo ${ImageName} successfully programmed; echo; else echo ${ImageName} Programming Failed... error exit; run TargetProgrammingFailure; run TargetErrorExit;echo; run DataAbort; fi; 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 # # # <<<<<<<<<<<< Start of Image Flashing>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # ------------------------------------------------------------------- # Get the single image containing all the files. # ------------------------------------------------------------------- echo echo Get Image containing all images to be flashed echo run GetSpiFlashImage run EraseSpiFlash # ------------------------------------------------------------------- # 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 1 #-------------------------------------------------------------------- setenv source_addr ${Image1_DDR_ADDR} setenv storage_offset ${Image1_SPIFLASH_Offset} setenv image_length ${Image1_Length} setenv ImageName ${Image1_Name} run FlashSpiImage #-------------------------------------------------------------------- # Flash Image 2 #-------------------------------------------------------------------- setenv source_addr ${Image2_DDR_ADDR} setenv storage_offset ${Image2_SPIFLASH_Offset} setenv image_length ${Image2_Length} setenv ImageName ${Image2_Name} run FlashSpiImage #-------------------------------------------------------------------- # Flash Image 3 #-------------------------------------------------------------------- setenv source_addr ${Image3_DDR_ADDR} setenv storage_offset ${Image3_SPIFLASH_Offset} setenv image_length ${Image3_Length} setenv ImageName ${Image3_Name} run FlashSpiImage #-------------------------------------------------------------------- # # <<<<<<<<<<<<< End of Image Flashing >>>>>>>>>>>>>>>>>>>>>>>>>>>>> # # # ------------------------------------------------------------------- # Indicate to Host successful completion run TargetProgrammingComplete echo echo " Target Flash Complete........" echo