Exemplo n.º 1
0
        public void ValidateFirmware(string FwPath)
        {
            FwInfo fwInfo1 = Validate(FwPath);                     // simple firmware validation
            FwInfo fwInfo2 = Validate(FwPath, new StringWriter()); // save parse log

            // If firmware is invalid, Valid = false. Otherwise Valid = True
            Console.WriteLine(fwInfo1.Valid);
            // Firmware format. TI-TXT, Intel-HEX, ELF or SREC
            Console.WriteLine(fwInfo1.Format);
            // First address in firmware, max 32-bit, usually 16-bit
            Console.WriteLine(fwInfo1.AddrFirst);
            // Last address in firmware, max 32-bit, usually 16-bit
            Console.WriteLine(fwInfo1.AddrLast);
            // Total length of firmware, count of all bytes from first address to last
            Console.WriteLine(fwInfo1.SizeFull);
            // Real count of all bytes in firmware parsed from file
            Console.WriteLine(fwInfo1.SizeCode);
            // CRC-16-CCITT is 16-bit crc value of all data bytes in firmware
            Console.WriteLine(fwInfo1.Crc16);
            // [MSP430 specific] Reset vector is address (value) located usually at
            // 16-bit address 0xFFFE.
            Console.WriteLine(fwInfo1.ResetVector);
            // List<long>. When parsing FW, FillFF can be set, to output code in single
            // piece. Addresses, that dont belong to original FW, are in this list.
            Console.WriteLine(fwInfo1.FilledFFAddr);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Init Firmware with simple data Nodes and new FwInfo class based on valid input data.
 /// </summary>
 public Firmware(List <FwNode> Data,
                 FwFormat Format,
                 int SizeBuffer                  = 0,
                 long ResetVectorAddr            = -1,
                 ICollection <long> FilledFFAddr = null)
 {
     Nodes = Data.OrderBy(o => o.Addr).ToList();
     Info  = new FwInfo(Data, Format, SizeBuffer, ResetVectorAddr, FilledFFAddr);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Init Firmware with raw memory stream bytes and new FwInfo class based on valid input data.
 /// </summary>
 public Firmware(Stream Data,
                 FwFormat Format,
                 long FirstAddress,
                 int SizeBuffer                  = 0,
                 long ResetVectorAddr            = -1,
                 ICollection <long> FilledFFAddr = null)
 {
     byte[] nodes;
     Data.Position = 0;
     using (MemoryStream ms = new MemoryStream())
     {
         Data.CopyTo(ms);
         nodes = ms.ToArray();
     }
     Nodes = nodes.Select(n => new FwNode()
     {
         Data = n, Addr = FirstAddress++
     }).ToList();
     Info = new FwInfo(Nodes, Format, SizeBuffer, ResetVectorAddr, FilledFFAddr);
 }