/// <summary> /// Function to Transmit the UBL via the device ROM Serial boot /// </summary> private static void TransmitUBL(Byte[] imageData,UARTBOOT_Header ackHeader) { // Local Variables for building up output StringBuilder UBLsb; CRC32 MyCRC; ProgressBar progressBar; Int32 blockCnt; UBLsb = new StringBuilder(imageData.Length * 2); // Read the data from the UBL file into the appropriate structures for (int i=0; i<imageData.Length; i+=sizeof(UInt32)) { UBLsb.AppendFormat("{0:X8}", System.BitConverter.ToUInt32(imageData,i)); } // Create CRC object and use it to calculate the UBL file's CRC // Note that this CRC is not quite the standard CRC-32 algorithm // commonly in use since the final register value is not XOR'd // with 0xFFFFFFFF. As a result the CRC value returned here // will be the bitwise inverse of the standard CRC-32 value. MyCRC = new CRC32(0x04C11DB7, 0xFFFFFFFF, 0x00000000, true, 1, CRCType.ONESHOT, CRCCalcMethod.LUT); ackHeader.crcVal = MyCRC.CalculateCRC(imageData); ackHeader.byteCnt = (UInt32) imageData.Length; try { BOOTMESEQ: Console.WriteLine("\nWaiting for the "+devString+"..."); // Wait for the device to send the ^BOOTME/0 sequence if (SerialIO.waitForSequence(" BOOTME\0", " BOOTME\0", MySP, cmdParams.verbose)) Console.WriteLine("BOOTME commmand received. Returning ACK and header..."); else goto BOOTMESEQ; // Output 28 Bytes for the ACK sequence and header // 8 bytes acknowledge sequence = " ACK\0" //#if (DM35x_REVB || DM36x_REVA) //#if (DM35x_REVB) // MySP.Write(" ACK"); //#else MySP.Write(" ACK\0"); //#endif // 8 bytes of CRC data = ASCII string of 8 hex characters MySP.Write(ackHeader.crcVal.ToString("X8")); // 4 bytes of UBL data size = ASCII string of 4 hex characters (3800h = 14336d) MySP.Write(ackHeader.byteCnt.ToString("X4")); // 4 bytes of start address = ASCII string of 4 hex characters (>=0100h) MySP.Write(ackHeader.startAddr.ToString("X4")); // 4 bytes of constant zeros = "0000" MySP.Write("0000"); Console.WriteLine("ACK command sent. Waiting for BEGIN command... "); // Wait for the BEGIN sequence if (SerialIO.waitForSequence(" BEGIN\0", " BOOTME\0", MySP,true)) Console.WriteLine("BEGIN commmand received. Sending CRC table..."); else goto BOOTMESEQ; // Send the 1024 byte (256 word) CRC table progressBar = new ProgressBar(); progressBar.Update(0.0,"Sending CRC table..."); for (int i = 0; i < MyCRC.Length; i++) { MySP.Write(MyCRC[i].ToString("x8")); progressBar.Percent = (((Double)(i+1))/MyCRC.Length); } progressBar.Update(100.0,"CRC table sent."); Console.WriteLine("Waiting for DONE..."); // Wait for the first DONE sequence if (SerialIO.waitForSequence(" DONE\0", " BOOTME\0", MySP, cmdParams.verbose)) Console.WriteLine("DONE received. Sending the UBL..."); else goto BOOTMESEQ; // Send the contents of the UBL file (as hex text) progressBar = new ProgressBar(); progressBar.Update(0.0,"Sending UBL..."); blockCnt = UBLsb.Length/128; for (int i = 0; i < (blockCnt*128); i+=128) { MySP.Write(UBLsb.ToString(i,128)); progressBar.Percent = (((Double)(i+1))/UBLsb.Length); } // Write last (possibly partial) block MySP.Write(UBLsb.ToString(blockCnt*128,UBLsb.Length - (blockCnt*128) )); progressBar.Update(100.0,"UBL sent."); // Wait for the second DONE sequence if (SerialIO.waitForSequence(" DONE\0", " BOOTME\0", MySP, cmdParams.verbose)) Console.WriteLine("DONE received. UBL was accepted."); else goto BOOTMESEQ; Console.WriteLine("UBL transmitted successfully.\n"); } catch (ObjectDisposedException e) { Console.WriteLine(e.StackTrace); throw e; } }
/// <summary> /// The public constructor for the DM637x device AIS generator. /// The constructor is where the device differentiation is defined. /// </summary> public AISGen_C642x() { // Define the device name - used for default file names devNameShort = "C642x"; devNameLong = "TMS320C642x"; // Define the device caches (they are considered internal memories since // bootrom turns off caching) - two identical sets since the memory map // has the caches at two locations Cache = new CacheInfo[6]; Cache[0].level = CacheLevel.L2; Cache[0].type = CacheType.Program | CacheType.Data; Cache[0].startAddr = 0x00800000; Cache[0].size = 0x20000; Cache[1].level = CacheLevel.L1; Cache[1].type = CacheType.Program; Cache[1].startAddr = 0x00E08000; Cache[1].size = 0x8000; Cache[2].level = CacheLevel.L1; Cache[2].type = CacheType.Data; Cache[2].startAddr = 0x00F10000; Cache[2].size = 0x8000; Cache[3].level = CacheLevel.L2; Cache[3].type = CacheType.Program | CacheType.Data; Cache[3].startAddr = 0x10800000; Cache[3].size = 0x20000; Cache[4].level = CacheLevel.L1; Cache[4].type = CacheType.Program; Cache[4].startAddr = 0x10E08000; Cache[4].size = 0x8000; Cache[5].level = CacheLevel.L1; Cache[5].type = CacheType.Data; Cache[5].startAddr = 0x10F10000; Cache[5].size = 0x8000; // Define the IDMA channels for internal memory transfers IDMA = new IDMARegisters[2]; IDMA[0] = new IDMARegisters(0, 0x01820000); IDMA[1] = new IDMARegisters(1, 0x01820100); // Define C642x ROM boot loader functions ROMFunc = new ROMFunction[4]; ROMFunc[0].funcName = AISGen_C642x.ROMFunctionNames.PLLConfig; ROMFunc[0].iniSectionName = "PLL"; ROMFunc[0].numParams = 3; ROMFunc[0].paramNames = new String[3] { "PLLM", "PLLDIV1", "CLK_SRC" }; ROMFunc[1].funcName = AISGen_C642x.ROMFunctionNames.EMIFConfig; ROMFunc[1].iniSectionName = "EMIF"; ROMFunc[1].numParams = 5; ROMFunc[1].paramNames = new String[5] { "AB1CR", "AB2CR", "AB3CR", "AB4CR", "NANDFCR" }; ROMFunc[2].funcName = AISGen_C642x.ROMFunctionNames.DDRConfig; ROMFunc[2].iniSectionName = "DDR"; ROMFunc[2].numParams = 9; ROMFunc[2].paramNames = new String[9] { "DDRPLLM","DDRCLKDIV","VPFECLKDIV","CLK_SRC","DDRPHYCR", "SDBCR","SDTIMR","SDTIMR2","SDRCR"}; ROMFunc[3].funcName = AISGen_C642x.ROMFunctionNames.PINMUXConfig; ROMFunc[3].iniSectionName = "PINMUX"; ROMFunc[3].numParams = 2; ROMFunc[3].paramNames = new String[2] { "PINMUX0", "PINMUX1" }; // Configuration info for the AISExtras functions (provided in AISExtraFileName COFF file) AISExtraFileName = "AISExtra_"+devNameShort+".out"; AISExtraFunc = new AISExtraFunction[1]; AISExtraFunc[0].funcName = AISGen_C642x.AISExtraFunctionNames.LPSCTransition; AISExtraFunc[0].iniSectionName = "LPSC"; AISExtraFunc[0].numParams = 2; AISExtraFunc[0].paramNames = new String[2] { "MODNUM", "STATE" }; AISExtraFunc[0].isInitFunc = true; // C642x is little endian devEndian = Endian.LittleEndian; // Create a temp binary file for this object devAISFileName = devNameShort +".ais"; devAISFileStream = null; // INI file describes ROM function parameters devINIFileName = devNameShort + ".ini"; // Default settings for UARTSendDONE function UARTSendDONEAddr = 0x0; SendUARTSendDONE = false; // Default boot mode (can be changed from INI file) for this device bootMode = BootModes.NONE; // Create default CRC object for this device devCRC = new CRC32(0x04C11DB7, 0, 0, false, 1); crcType = CRCCheckType.NO_CRC; }