⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvflasher.cs

📁 TI DM6446 EVM 串口下载程序 使用环境:windows dos环境或者linux 使用前需安装mono
💻 CS
📖 第 1 页 / 共 5 页
字号:
/**************************************************************** *  TI DM644x Serial Boot/Flash Host Program                      *  (C) 2006,2007, Texas Instruments, Inc.                            *                                                               * Author:  Daniel Allred * History: 09/19/2006 - Version 0.1 - Initial Release           *          10/2/2006 - Added UART UBL as embedded resource *          10/19/2006 - Internal release *          1/22/2007 - v1.00 release *          2/01/2007 - v1.10 release *              Revised so that the UBL can be used in CCS flashing *              tool.  Required revising this code so that the first *              256 bytes of the UBL binary was trimmed for the NAND *              and UART UBLs. *                                                               ****************************************************************/using System;using System.Text;using System.IO;using System.IO.Ports;using System.Reflection;using System.Threading;using System.Globalization;namespace DVFlasher{    /// <summary>    /// Enumeration for Magic Flags that the UBL expects to see    /// </summary>    public enum MagicFlags : uint    {        MAGIC_NUMBER_VALID = 0xA1ACED00,        MAGIC_NUMBER_INVALID = 0xFFFFFFFF,        UBL_MAGIC_SAFE = 0xA1ACED00,        UBL_MAGIC_DMA = 0xA1ACED11,	                /* DMA boot mode */        UBL_MAGIC_IC = 0xA1ACED22,	                /* I Cache boot mode */        UBL_MAGIC_FAST = 0xA1ACED33,	            /* Fast EMIF boot mode */        UBL_MAGIC_DMA_IC = 0xA1ACED44,	            /* DMA + ICache boot mode */        UBL_MAGIC_DMA_IC_FAST = 0xA1ACED55,	        /* DMA + ICache + Fast EMIF boot mode */        UBL_MAGIC_BIN_IMG = 0xA1ACED66,             /* Describes the application image in Flash - indicates that it is binary*/        UBL_MAGIC_NOR_RESTORE = 0xA1ACED77,         /* Download via UART & Restore NOR with binary data */        UBL_MAGIC_NOR_SREC_BURN = 0xA1ACED88,       /* Download via UART & Burn NOR with UBL readable header and SREC data*/        UBL_MAGIC_NOR_BIN_BURN = 0xA1ACED99,        /* Download via UART & Burn NOR with UBL readable header and BIN data */        UBL_MAGIC_NOR_GLOBAL_ERASE = 0xA1ACEDAA,    /* Download via UART & Global erase the NOR Flash */        UBL_MAGIC_NAND_SREC_BURN = 0xA1ACEDBB,   /* Download via UART & Burn NAND - Image is S-record */        UBL_MAGIC_NAND_BIN_BURN = 0xA1ACEDCC,   /* Download via UART & Burn NAND - Image is binary */        UBL_MAGIC_NAND_GLOBAL_ERASE = 0xA1ACEDDD	/* Download via UART & Global erase the NAND Flash */    };        /// <summary>    /// Enumeration of flash types    /// </summary>    public enum FlashType : uint    {        NONE,        NOR,        NAND    };    /// <summary>    /// Structure to hold command parameters    /// </summary>    struct ProgramCmdParams    {        /// <summary>        /// Flag to indicate if command line is valid        /// </summary>        public Boolean Valid;        /// <summary>        /// Boolean to control the verbosity of output        /// </summary>        public Boolean Verbose;        /// <summary>        /// Name of serial port used for communications        /// </summary>        public String SerialPortName;        /// <summary>        /// MagicFlag which is the command to of what the UART UBL will do.        /// This should be transmitted alone in response to the BOOTPSP.        /// </summary>        public MagicFlags CMDMagicFlag;        /// <summary>        /// Flag to inidicate whether to use internal (TI) UBL or externally provided one        /// </summary>        public Boolean useEmbeddedUBL;        /// <summary>        /// Address at which UART UBL will begin execution (must be 0x100 or greater)        /// </summary>        public UInt32 UARTUBLExecAddr;        /// <summary>        /// Boolean to indicate whether or not to send UART UBL via RBL interfacing.        /// This is set by the -skipRBL command line option.        /// </summary>        public Boolean UARTUBLUsed;        /// <summary>        /// Type of flash that the application and UBL are targeted to use.  Selects        /// which embedded UBL to use.        /// </summary>        public FlashType UBLFlashType;        /// <summary>        /// Entry point addresses for the NAND and NOR UBL embedded binary images.        /// </summary>        public UInt32 NORUBLExecAddr;        public UInt32 NANDUBLExecAddr;        /// <summary>        /// Global varibale to hold the desired magic flag        /// </summary>        public MagicFlags FLASHUBLMagicFlag;        /// <summary>        /// String containing filename of FLASH UBL file (only needed for flashing)        /// </summary>        public String FLASHUBLFileName;        /// <summary>        /// Address where the flash ubl file should be decoded to and         /// run from (if appropriate).        /// </summary>        public UInt32 FLASHUBLLoadAddr;        /// <summary>        /// Address at which the Flash UBL will begin execution (must be 0x100 or greater)        /// This will either be the same as UARTUBLExecAddr (id embedded UBL is put into flash)        /// or provided on the command line in case a separate flash UBL is provided.        /// </summary>        public UInt32 FLASHUBLExecAddr;        /// <summary>        /// Magic Flag for the application data        /// </summary>        public MagicFlags APPMagicFlag;        /// <summary>        /// String containing filename of Application file        /// </summary>        public String APPFileName;        /// <summary>        /// Address where the app should be decoded to and         /// run from (if appropriate).        /// </summary>        public UInt32 APPLoadAddr;        /// <summary>        /// Address where the app begin execution         /// </summary>        public UInt32 APPEntryPoint;    }        /// <summary>    /// Main program Class    /// </summary>    class Program    {        //**********************************************************************************        #region Class variables and members        /// <summary>        /// Global main Serial Port Object        /// </summary>        public static SerialPort MySP;                        /// <summary>        /// The main thread used to actually execute everything        /// </summary>        public static Thread workerThread;        /// <summary>        /// Global boolean to indicate successful completion of workerThread        /// </summary>        public static Boolean workerThreadSucceeded = false;        /// <summary>        /// Public variable to hold needed command line and program parameters        /// </summary>        public static ProgramCmdParams cmdParams;        /// <summary>        /// String to hold the summary of operation program will attempt.        /// </summary>        public static String cmdString;        #endregion        //**********************************************************************************        //**********************************************************************************        #region Code for Main thread        /// <summary>        /// Help Display Function        /// </summary>        private static void DispHelp()        {            Console.Write("Usage:");            Console.Write("\n\tDVFlasher <Option>");            Console.Write("\n\t\t" + "<Option> can be the following:");            Console.Write("\n\t\t\t" + "-enor\tDo a global erase of the NOR flash.");            Console.Write("\n\t\t\t" + "-enand\tDo a global erase of the NAND flash.");            Console.WriteLine();            Console.Write("\n\tDVFlasher <Option> <Application File>");            Console.Write("\n\t\t" + "<Option> can be any of the following:");            Console.Write("\n\t\t\t" + "-b\tBoot and run application code from the DDR RAM (max 16MB)." );            Console.Write("\n\t\t\t" + "-r\tRestore NOR Flash with bootable application (typically u-boot).");            Console.WriteLine();            Console.Write("\n\tDVFlasher <Option> <Application File>");            Console.Write("\n\tDVFlasher <Option> -useMyUBL <Flash UBL File> <Application File>");            Console.Write("\n\t\t" + "<Option> can be any of the following:" +                          "\n\t\t\t" + "-fnorbin\tFlash the NOR Flash with bootable UBL and binary application image." +                          "\n\t\t\t" + "-fnorsrec\tFlash the NOR Flash with bootable UBL and S-record application image." +                          "\n\t\t\t" + "-fnandbin\tFlash the NAND Flash with bootable UBL and binary application image." +                          "\n\t\t\t" + "-fnandsrec\tFlash the NAND Flash with bootable UBL and S-record application image.\n");            Console.Write("\n\t\t"+"<Flash UBL File> is a maximum 14kB second stage bootloader that" +                          "\n\t\t" + "is specifically tailored to sit in the NAND or NOR flash and load" +                           "\n\t\t" + "the application image stored there.\n");            Console.Write("\n\t\t"+"<Application File> is an S-record or binary executable file that"+                          "\n\t\t"+"is run after boot or programmed into flash for execution there. Often"+                          "\n\t\t"+"this will be a third-stage bootloader like u-boot, which can be used to"+                          "\n\t\t"+"boot linux.\n");            Console.Write("\t" + "NOTE: Make sure switches and jumpers are set appropriately for Flash type.\n");            Console.Write("\n\t" + "Other Options" +                          "\n\t\t"+"-h                \tDisplay this help screen."+                          "\n\t\t"+"-v                \tDisplay more verbose output returned from the DVEVM."+                          "\n\t\t"+"-noRBL            \tUse when system is already running UBL, showing \"BOOTPSP\"." +                          "\n\t\t"+"-useMyUBL         \tUse your own provided Flash UBL file instead of the internal UBL." +                          "\n\t\t"+"                  \tExamples of this usage are shown above." +                          "\n\t\t"+"-p \"<PortName>\" \tUse <PortName> as the serial port (e.g. COM2, /dev/ttyS1)."+                          "\n\t\t"+"-s \"<StartAddr>\"\tUse <StartAddr>(hex) as the point of execution for the system");        }            /// <summary>        /// Parse the command line into the appropriate internal command structure        /// </summary>        /// <param name="args">The array of strings passed to the command line.</param>        public static ProgramCmdParams ParseCmdLine(String[] args)        {            ProgramCmdParams myCmdParams =  new ProgramCmdParams();            Boolean[] argsHandled = new Boolean[args.Length];            Int32 numFiles = -1;            UInt32 numUnhandledArgs,numHandledArgs=0;            String s;            if (args.Length == 0)            {                myCmdParams.Valid = false;                return myCmdParams;            }            // Initialize array of handled argument booleans to false            for (int i = 0; i < argsHandled.Length; i++ )                argsHandled[i] = false;            // Set Defualts for application            myCmdParams.UBLFlashType = FlashType.NONE;                        myCmdParams.CMDMagicFlag = MagicFlags.MAGIC_NUMBER_INVALID;            myCmdParams.Valid = true;            myCmdParams.Verbose = false;            myCmdParams.SerialPortName = null;            myCmdParams.useEmbeddedUBL = true;            myCmdParams.UARTUBLExecAddr = 0x0100;            myCmdParams.UARTUBLUsed = true;                        myCmdParams.NORUBLExecAddr = 0x2a30;            myCmdParams.NANDUBLExecAddr = 0x23ec;            myCmdParams.APPMagicFlag = MagicFlags.UBL_MAGIC_SAFE;            myCmdParams.APPFileName = null;            myCmdParams.APPLoadAddr = 0xFFFFFFFF;            myCmdParams.APPEntryPoint = 0xFFFFFFFF;            myCmdParams.FLASHUBLMagicFlag = MagicFlags.UBL_MAGIC_SAFE;            myCmdParams.FLASHUBLFileName = null;            myCmdParams.FLASHUBLLoadAddr = 0xFFFFFFFF;            myCmdParams.FLASHUBLExecAddr = 0x0100;                        // For loop for all dash options            for(int i = 0; i<args.Length; i++)            {                s = args[i];                if (s.StartsWith("-"))                {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -