예제 #1
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Input commandline arguments</param>
        /// <returns>Return code</returns>
        static Int32 Main(String[] args)
        {
            // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like,
            // with only 2 numbers specified;  the next two are generated from the date.
            System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            // v.Build is days since Jan. 1, 2000, v.Revision*2 is seconds since local midnight
            Int32 buildYear = new DateTime(v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2).AddYears(1999).Year;

            // Begin main code
            Console.Clear();
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("   TI NOR AIS File Generator for " + devString);
            Console.WriteLine("   (C) " + buildYear + ", Texas Instruments, Inc.");
            Console.WriteLine("   Ver. " + v.Major + "." + v.Minor.ToString("D2"));
            Console.WriteLine("-----------------------------------------------------");
            Console.Write("\n\n");


            // Parse the input command line parameters
            ProgramCmdParams cmdParams = ParseCmdLine(args);

            if (!cmdParams.valid)
            {
                DispHelp();
                return(-1);
            }

            // Now proceed with main program
            FileStream tempAIS_fs = null;

            Byte[] AISData;

            // Create a new C642x AIS generator object
            AISGen_C642x generator = new AISGen_C642x();

            generator.CRCType = CRCCheckType.SECTION_CRC;

            // Do the AIS generation
            try
            {
                AISData    = AISGen.GenAIS(cmdParams.inputfileName, "emifa", generator);
                tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write);
                tempAIS_fs.Write(AISData, 0, (int)AISData.Length);
                tempAIS_fs.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Unhandled Exception!!! Application will now exit.");
                return(-1);
            }

            Console.WriteLine("AIS generation is complete.");
            return(0);
        }
예제 #2
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Input commandline arguments</param>
        /// <returns>Return code</returns>
        static Int32 Main(String[] args)
        {
            // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like,
            // with only 2 numbers specified;  the next two are generated from the date.
            System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            // v.Build is days since Jan. 1, 2000, v.Revision*2 is seconds since local midnight
            Int32 buildYear = new DateTime(v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2).AddYears(1999).Year;

            // Begin main code
            Console.Clear();
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("   TI AIS Hex File Generator for " + devString);
            Console.WriteLine("   (C) " + buildYear + ", Texas Instruments, Inc.");
            Console.WriteLine("   Ver. " + v.Major + "." + v.Minor.ToString("D2"));
            Console.WriteLine("-----------------------------------------------------");
            Console.Write("\n\n");


            // Parse the input command line parameters
            ProgramCmdParams cmdParams = ParseCmdLine(args);

            if (!cmdParams.valid)
            {
                DispHelp();
                return(-1);
            }

            // Now proceed with main program
            FileStream tempAIS_fs = null;

            Byte[] AISData, convertedData;

            AISGen_OMAP_L138 generator = new AISGen_OMAP_L138();

            // Update the default INI file name to the one supplied on the command line
            if (cmdParams.iniFileName == null)
            {
                cmdParams.iniFileName = generator.DeviceNameShort + ".ini";
            }

            // Read the INI data from file
            INISection[] iniSecs = INI.Parse(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read));

            // Force section-by-section CRC checks (may be overridden in INI file)
            generator.CRCType = CRCCheckType.SECTION_CRC;

            // Do the AIS generation
            try
            {
                AISData = AISGen.GenAIS(cmdParams.inputfileName, generator, iniSecs);
            }
            catch (Exception e)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true);

                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Unhandled Exception!!! Application will now exit.");
                return(-1);
            }

            tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write);

            switch (cmdParams.convType)
            {
            case ConvType.Exec2Bin:
                tempAIS_fs.Write(AISData, 0, (int)AISData.Length);
                break;

            case ConvType.Exec2CArray:
                convertedData = CArray.bin2CArray(AISData, 4);
                tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                break;

            case ConvType.Exec2Srec:
                convertedData = SRecord.bin2srec(AISData, 0x60000000, 32);
                tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                break;

            case ConvType.Exec2Text:
                Console.WriteLine("Mode Not supported.");
                //Byte[] val = SRecord.bin2srec(aisData, 0x60000000, 32);
                break;
            }

            tempAIS_fs.Close();

            Console.WriteLine("Conversion is complete.");
            return(0);
        }
예제 #3
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Input commandline arguments</param>
        /// <returns>Return code</returns>
        static Int32 Main(String[] args)
        {
            IniFile myIniFile;

            // From Common/AIS/HexAIS_version.cs
            System.Version v = GetVersion();

            // From Common/AIS/HexAIS_version.cs
            Int32 buildYear = GetBuildYear();

            // Begin main code
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("   TI AIS Hex File Generator for " + devString);
            Console.WriteLine("   (C) " + buildYear + ", Texas Instruments, Inc.");
            Console.WriteLine("   Ver. " + v.Major + "." + v.Minor.ToString("D2"));
            Console.WriteLine("-----------------------------------------------------");
            Console.Write("\n\n");


            // Parse the input command line parameters
            ProgramCmdParams cmdParams = ParseCmdLine(args);

            if (!cmdParams.valid)
            {
                DispHelp();
                return(-1);
            }

            // Now proceed with main program
            FileStream tempAIS_fs = null;

            Byte[] AISData, convertedData;

            AISGen_OMAP_L137 generator = new AISGen_OMAP_L137();

            // Update the default INI file name to the one supplied on the command line
            if (cmdParams.iniFileName == null)
            {
                Console.WriteLine("No ini file provided. Using default, {0}", generator.DeviceNameShort + ".ini");
                cmdParams.iniFileName = generator.DeviceNameShort + ".ini";
            }

            // Read the INI data from file
            if (File.Exists(cmdParams.iniFileName))
            {
                myIniFile = new IniFile(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read), cmdParams.iniFileName);
            }
            else
            {
                Console.WriteLine("File {0} not found.", cmdParams.iniFileName);
                return(-1);
            }

            // Put entryPoint in General Ini section (may be overridden by INI InputFile sections)
            myIniFile.InsertValue("General", "EntryPoint", "0x" + cmdParams.entryPoint.ToString("X8"));

            // Force section-by-section CRC checks (may be overridden in INI file)
            generator.AISCRCType = AisCRCCheckType.SECTION_CRC;

            // Do the AIS generation
            try
            {
                AISData = AISGen.GenAIS(generator, cmdParams.inputFileName, myIniFile);
            }
            catch (Exception e)
            {
                System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true);

                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.Message);
                Console.WriteLine("Unhandled Exception!!! Application will now exit.");
                return(-1);
            }

            // Check if SecureAISGen completed successfully
            if (AISData == null)
            {
                Console.WriteLine("AIS generation failed.");
                return(-1);
            }

            using (tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write))
            {
                // Convert the AIS data to the correct output format
                switch (cmdParams.convType)
                {
                case ConvType.Exec2Bin:
                    tempAIS_fs.Write(AISData, 0, (int)AISData.Length);
                    Console.WriteLine("Wrote {0} bytes to file {1}.", AISData.Length, cmdParams.outFileName);
                    break;

                case ConvType.Exec2CArray:
                    convertedData = CArray.bin2CArray(cmdParams.cArrayName, AISData, 4);
                    tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                    Console.WriteLine("Wrote {0} bytes to file {1}.", convertedData.Length, cmdParams.outFileName);
                    break;

                case ConvType.Exec2Srec:
                    convertedData = SRecord.bin2srec(AISData, (UInt32)cmdParams.srecAddr, 32);
                    tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
                    Console.WriteLine("Wrote {0} bytes to file {1}.", convertedData.Length, cmdParams.outFileName);
                    break;

                case ConvType.Exec2Text:
                    Console.WriteLine("Mode Not supported.");
                    break;
                }
            }

            Console.WriteLine("Conversion is complete.");
            return(0);
        }