Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            ExtractPacketAddresses("ublox 6mdata.raw", "Addrneo6m.txt", 0x1420, 0x26ddf4);

            ExtractPacketAddresses("6mdata.raw", "Addrneo6m-2.txt", 0x1420, 0x26ddf4);

            ExtractPacketAddresses("datalea6h.raw", "Addrlea6h.txt", 0x3e4c, 0x8546dc);

            ExtractPacketAddresses("datalea6h-nu602.raw", "Addrlea6hnu602.txt", 0x3e4c, 0x8546dc);

            ExtractPacketAddresses("dataneo7n.raw", "Addrneo7n.txt", 0x20001188, 0x862f0c);

            ExtractPacketAddresses("UBX_M8_301_HPG_111_REFERENCE_NEOM8P2.b45d5e63c7aa261bd58dfbcbc22bad68.bin",
                                   "Addrm8p.txt", 0, 0x6df34, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_111_REFERENCE_NEOM8P2.b45d5e63c7aa261bd58dfbcbc22bad68.bin",
                                   "Addrm8p22.txt", 0, 0x6e308, true);

            ExtractPacketAddresses("EXT_G60_LEA-6H.fd1146bafac24b1347701312d42bb698.bin",
                                   "Addrlea6h-2.txt", 0, 0x546dc);

            ExtractPacketAddresses("FW101_EXT_TITLIS.42ec35ce38d201fd723f2c8b49b6a537.bin",
                                   "Addr7.txt", 0, 0x62f0c);

            ExtractPacketAddresses("UBLOX_M8_201.89cc4f1cd4312a0ac1b56c790f7c1622.bin",
                                   "Addr8_201.txt", 0, 0x739e8);

            ExtractPacketAddresses("UBX_M8_301_SPG.911f2b77b649eb90f4be14ce56717b49.bin",
                                   "Addr8_301.txt", 0, 0x7904c, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_100_REFERENCE.dd38fd00c1d64d05d5b458d8a8fa4b41.bin",
                                   "Addrm8p_301_100.txt", 0, 0x6805c, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_100_REFERENCE.dd38fd00c1d64d05d5b458d8a8fa4b41.bin",
                                   "Addrm8p_301_100-2.txt", 0, 0x68394, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_130_REFERENCE_NEOM8P2.59a07babb501ba6a89ff87cac2f2765f.bin",
                                   "Addrm8p_301_130-2.txt", 0, 0x718a8, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_130_REFERENCE_NEOM8P2.59a07babb501ba6a89ff87cac2f2765f.bin",
                                   "Addrm8p_301_130-2a.txt", 0, 0x71ca0, true);

            ExtractPacketAddresses("DO_EXT_301_HPG_140_REFERENCE.ab799cc302b64f28ba73b55dfa945a04.bin",
                                   "Addrm8p_301_140.txt", 0x73980, 0x73980, true);

            //0005bd16
            // 5bd1a   from 20 B1  ==  00 bf

            var fileBytes = File.ReadAllBytes("DO_EXT_301_HPG_140_REFERENCE.ab799cc302b64f28ba73b55dfa945a04.bin");

            var binreader = new BinaryReader(new MemoryStream(fileBytes));

            string[] desc =
            {
                "UBX8",
                "?",
                "-1",  "fwbase ","fwstart", "fwend", "-1", "-1", "0", "-1", "?", "?"
            };

            for (int a = 0; a < 12; a++)
            {
                var item = binreader.ReadInt32();
                Console.WriteLine("{1}\t0x{0:X} = {0}", item, desc[a]);
            }

            /*
             * 0.0   - Verifying image
             *
             * 0.0 Image (file size 502984) for u-blox8 accepted
             *
             * 0.0 Image Ver '3.01 (db0c89)'
             * 0.0   - CRC= 0x90A97896 0xEE9EBE1E
             * 0.0   - Trying to open port STDIO
             *
             * undefined4 __fastcall dochecksum(int *param_1,uint param_2)
             *
             * {
             * int *piVar1;
             * int iVar2;
             * int iVar3;
             * uint uVar4;
             *
             * uVar4 = param_2 >> 2;
             * iVar2 = 0;
             * iVar3 = 0;
             * piVar1 = param_1;
             * while (uVar4 != 0) {
             * iVar2 = iVar2 + *piVar1;
             * piVar1 = piVar1 + 1;
             * iVar3 = iVar3 + iVar2;
             * uVar4 = uVar4 - 1;
             * }
             * if ((iVar2 == *(int *)((int)param_1 + (param_2 & 0xfffffffc))) &&
             * (iVar3 == *(int *)((int)param_1 + (param_2 & 0xfffffffc) + 4))) {
             * return 1;
             * }
             * return 0;
             * }
             *
             */

            // should == 502972 or 502976    000000000007ACBC  000000000001EB2F

            binreader.BaseStream.Seek(4, SeekOrigin.Begin);

            var ivar2 = 0;
            var ivar3 = 0;

            while (binreader.BaseStream.Position < binreader.BaseStream.Length - 8)
            {
                var b = binreader.ReadInt32();
                ivar2 = ivar2 + b;
                ivar3 = ivar3 + ivar2;
            }

            var crc1 = binreader.ReadInt32();
            var crc2 = binreader.ReadInt32();

            if (ivar2 == crc1 && ivar3 == crc2)
            {
                Console.WriteLine("CRC passes");
            }
            else
            {
                Console.WriteLine("CRC fails should be 0x{0:X8} 0x{1:X8} currently {2:X8} {3:X8}", ivar2, ivar3, crc1,
                                  crc2);
            }

            Console.ReadLine();

            return;

            ICommsSerial port;// = /*new TcpSerial();*/ //new SerialPort("com35" ,115200);

            port = new MissionPlanner.Comms.SerialPort();

            port.PortName = "com5";
            port.BaudRate = 115200;

            // mp internal pass
            //port.PortName = "127.0.0.1";
            //port.BaudRate = 500;

            port.ReadBufferSize = 1024 * 1024;

            port.Open();

            /*
             *
             * ?????
             * 0x00800000 0x80000 flash
             * 0x20000000 0x20000 ram
             * 0x20080000 0x20000 ram
             * 0x00200000 0x8000 rom
             *
             * For ublox6 ROM7.03 use:
             *
             * to enable RXM-RAW - addr 000016c8
             * b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
             *
             *
             * to enable RXM-SFRB - addr 0000190c
             * b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
             *
             */

            var rxmraw6m = new downloadreq();

            rxmraw6m.clas      = 0x9;
            rxmraw6m.subclass  = 0x1;
            rxmraw6m.length    = 0x10;
            rxmraw6m.flags     = 0;
            rxmraw6m.startaddr = 0x16c8;
            rxmraw6m.data      = new byte[] { 0x97, 0x69, 0x21, 0x00, 0x00, 0x00, 0x02, 0x10 };

            var rxmsfrb6m = new downloadreq();

            rxmsfrb6m.clas      = 0x9;
            rxmsfrb6m.subclass  = 0x1;
            rxmsfrb6m.length    = 0x10;
            rxmsfrb6m.flags     = 0;
            rxmsfrb6m.startaddr = 0x190c;
            rxmsfrb6m.data      = new byte[] { 0x83, 0x69, 0x21, 0x00, 0x00, 0x00, 0x02, 0x11 };

            var rxmraw6h = new downloadreq();

            rxmraw6h.clas      = 0x9;
            rxmraw6h.subclass  = 0x1;
            rxmraw6h.length    = 0x10;
            rxmraw6h.flags     = 0;
            rxmraw6h.startaddr = 0x40F4;
            rxmraw6h.data      = new byte[] { 0xe7, 0xb9, 0x81, 0x00, 0x00, 0x00, 0x02, 0x10 };

            var rxmsfrb6h = new downloadreq();

            rxmsfrb6h.clas      = 0x9;
            rxmsfrb6h.subclass  = 0x1;
            rxmsfrb6h.length    = 0x10;
            rxmsfrb6h.flags     = 0;
            rxmsfrb6h.startaddr = 0x4360;
            rxmsfrb6h.data      = new byte[] { 0xd3, 0xb9, 0x81, 0x00, 0x00, 0x00, 0x02, 0x11 };

            byte[] turnonbytes = { 0, 1, 0, 0, 0, 0, 0, 0 };

            byte[] header = { 0xb5, 0x62 };

            /*
             * Load FW binary 'C:\Users\hog\Downloads\NL602-patched-fw (1).bin'
             * Binary check success, G60 image valid.
             * Version: 7.03 (45970) Mar 17 2011 16:26:24
             * FLASH Base:          0x800000
             * FW Base:             0x800000
             * FW Start:            0x800048
             * FW End:              0x860AD4
             * FW Size:             0x60ADC
             *
             * Identifying Flash
             * Flash: ManID=0x90, DevID=0x90
             *
             * firmware: 0x200000
             */

            //turnon(port, header, 2, 0x20);
            //turnon(port, header, 2, 0x12);
            //turnon(port, header, 2, 0x23);
            //turnon(port, header, 2, 0x24);
            //turnon(port, header, 2, 0x51);
            //turnon(port, header, 2, 0x52);

            // turnon(port.BaseStream, header, 3, 0xA);
            // turnon(port.BaseStream, header, 3, 0xF);

            //writepacket(port.BaseStream, header, rxmraw);
            //writepacket(port.BaseStream, header, rxmsfrb);

            //writepacket(port.BaseStream, header, rxmraw6h);
            //writepacket(port.BaseStream, header, rxmsfrb6h);

            //writepacket(port.BaseStream, header, rxmraw6m);
            //writepacket(port.BaseStream, header, rxmsfrb6m);

            //return;

            //turnon(port.BaseStream, header, 2, 0x10);
            //turnon(port.BaseStream, header, 2, 0x11);

            //testmsg.startaddr += 8;
            //testmsg.data = turnonbytes;
            //writepacket(port.BaseStream, header, testmsg);


            /*
             * System.Threading.Thread.Sleep(200);
             *
             * while (port.IsOpen)
             * {
             *
             *  while (port.BytesToRead > 0)
             *  {
             *      byte data = (byte)port.ReadByte();
             *
             *      // Console.Write("{0,2:x}",data);
             *
             *      processbyte(data);
             *  }
             *
             * }
             *
             * port.Close();
             *
             * // Console.ReadLine();
             *
             * return;
             */

            // safeboot
            var buf = new byte[] { 0xB5, 0x62, 0x09, 0x07, 0x00, 0x00, 0x10, 0x39 };

            buf = new byte[] { 0xB5, 0x62, 0x09, 0x07, 0x01, 0x00, 0x01, 0x12, 0x4D };

            //port.Write(buf, 0, buf.Length);

            //port.Close();
            //Thread.Sleep(1000);
            //port.Open();

            // dump rom/memory

            req           = new uploadreq();
            req.clas      = 0x9;
            req.subclass  = 0x2;
            req.length    = 12;
            req.startaddr = 0x800001;
            req.datasize  = 128;
            req.flags     = 0;

            var  deadline = DateTime.MinValue;
            uint lastaddr = 0;

            while (port.IsOpen)
            {
                // determine when to send a new/next request
                if (deadline < DateTime.Now || lastaddr != req.startaddr)
                {
                    var datastruct = StaticUtils.StructureToByteArray(req);

                    var checksum = ubx_checksum(datastruct, datastruct.Length);

                    port.Write(header, 0, header.Length);
                    port.Write(datastruct, 0, datastruct.Length);
                    port.Write(checksum, 0, checksum.Length);

                    deadline = DateTime.Now.AddMilliseconds(200);
                    lastaddr = req.startaddr;
                }

                Thread.Sleep(0);

                while (port.BytesToRead > 0)
                {
                    var data = (byte)port.ReadByte();

                    // Console.Write("{0,2:x}",data);

                    processbyte(data);
                }
            }
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            ExtractPacketAddresses("ublox 6mdata.raw", "Addrneo6m.txt", 0x1420, 0x26ddf4);

            ExtractPacketAddresses("6mdata.raw", "Addrneo6m-2.txt", 0x1420, 0x26ddf4);

            ExtractPacketAddresses("datalea6h.raw", "Addrlea6h.txt", 0x3e4c, 0x8546dc);

            ExtractPacketAddresses("datalea6h-nu602.raw", "Addrlea6hnu602.txt", 0x3e4c, 0x8546dc);

            ExtractPacketAddresses("dataneo7n.raw", "Addrneo7n.txt", 0x20001188, 0x862f0c);

            ExtractPacketAddresses("UBX_M8_301_HPG_111_REFERENCE_NEOM8P2.b45d5e63c7aa261bd58dfbcbc22bad68.bin",
                                   "Addrm8p.txt", 0, 0x6df34, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_111_REFERENCE_NEOM8P2.b45d5e63c7aa261bd58dfbcbc22bad68.bin",
                                   "Addrm8p22.txt", 0, 0x6e308, true);

            ExtractPacketAddresses("EXT_G60_LEA-6H.fd1146bafac24b1347701312d42bb698.bin",
                                   "Addrlea6h-2.txt", 0, 0x546dc);

            ExtractPacketAddresses("FW101_EXT_TITLIS.42ec35ce38d201fd723f2c8b49b6a537.bin",
                                   "Addr7.txt", 0, 0x62f0c);

            ExtractPacketAddresses("UBLOX_M8_201.89cc4f1cd4312a0ac1b56c790f7c1622.bin",
                                   "Addr8_201.txt", 0, 0x739e8);

            ExtractPacketAddresses("UBX_M8_301_SPG.911f2b77b649eb90f4be14ce56717b49.bin",
                                   "Addr8_301.txt", 0, 0x7904c, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_100_REFERENCE.dd38fd00c1d64d05d5b458d8a8fa4b41.bin",
                                   "Addrm8p_301_100.txt", 0, 0x6805c, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_100_REFERENCE.dd38fd00c1d64d05d5b458d8a8fa4b41.bin",
                                   "Addrm8p_301_100-2.txt", 0, 0x68394, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_130_REFERENCE_NEOM8P2.59a07babb501ba6a89ff87cac2f2765f.bin",
                                   "Addrm8p_301_130-2.txt", 0, 0x718a8, true);

            ExtractPacketAddresses("UBX_M8_301_HPG_130_REFERENCE_NEOM8P2.59a07babb501ba6a89ff87cac2f2765f.bin",
                                   "Addrm8p_301_130-2a.txt", 0, 0x71ca0, true);

            return;

            ICommsSerial port;// = /*new TcpSerial();*/ //new SerialPort("com35" ,115200);

            port = new MissionPlanner.Comms.SerialPort();

            port.PortName = "com5";
            port.BaudRate = 115200;

            // mp internal pass
            //port.PortName = "127.0.0.1";
            //port.BaudRate = 500;

            port.ReadBufferSize = 1024 * 1024;

            port.Open();

            /*
             *
             * ?????
             * 0x00800000 0x80000 flash
             * 0x20000000 0x20000 ram
             * 0x20080000 0x20000 ram
             * 0x00200000 0x8000 rom
             *
             * For ublox6 ROM7.03 use:
             *
             * to enable RXM-RAW - addr 000016c8
             * b5 62 09 01 10 00 c8 16 00 00 00 00 00 00 97 69 21 00 00 00 02 10 2b 22
             *
             *
             * to enable RXM-SFRB - addr 0000190c
             * b5 62 09 01 10 00 0c 19 00 00 00 00 00 00 83 69 21 00 00 00 02 11 5f f0
             *
             */

            var rxmraw6m = new downloadreq();

            rxmraw6m.clas      = 0x9;
            rxmraw6m.subclass  = 0x1;
            rxmraw6m.length    = 0x10;
            rxmraw6m.flags     = 0;
            rxmraw6m.startaddr = 0x16c8;
            rxmraw6m.data      = new byte[] { 0x97, 0x69, 0x21, 0x00, 0x00, 0x00, 0x02, 0x10 };

            var rxmsfrb6m = new downloadreq();

            rxmsfrb6m.clas      = 0x9;
            rxmsfrb6m.subclass  = 0x1;
            rxmsfrb6m.length    = 0x10;
            rxmsfrb6m.flags     = 0;
            rxmsfrb6m.startaddr = 0x190c;
            rxmsfrb6m.data      = new byte[] { 0x83, 0x69, 0x21, 0x00, 0x00, 0x00, 0x02, 0x11 };

            var rxmraw6h = new downloadreq();

            rxmraw6h.clas      = 0x9;
            rxmraw6h.subclass  = 0x1;
            rxmraw6h.length    = 0x10;
            rxmraw6h.flags     = 0;
            rxmraw6h.startaddr = 0x40F4;
            rxmraw6h.data      = new byte[] { 0xe7, 0xb9, 0x81, 0x00, 0x00, 0x00, 0x02, 0x10 };

            var rxmsfrb6h = new downloadreq();

            rxmsfrb6h.clas      = 0x9;
            rxmsfrb6h.subclass  = 0x1;
            rxmsfrb6h.length    = 0x10;
            rxmsfrb6h.flags     = 0;
            rxmsfrb6h.startaddr = 0x4360;
            rxmsfrb6h.data      = new byte[] { 0xd3, 0xb9, 0x81, 0x00, 0x00, 0x00, 0x02, 0x11 };

            byte[] turnonbytes = { 0, 1, 0, 0, 0, 0, 0, 0 };

            byte[] header = { 0xb5, 0x62 };

            /*
             * Load FW binary 'C:\Users\hog\Downloads\NL602-patched-fw (1).bin'
             * Binary check success, G60 image valid.
             * Version: 7.03 (45970) Mar 17 2011 16:26:24
             * FLASH Base:          0x800000
             * FW Base:             0x800000
             * FW Start:            0x800048
             * FW End:              0x860AD4
             * FW Size:             0x60ADC
             *
             * Identifying Flash
             * Flash: ManID=0x90, DevID=0x90
             *
             * firmware: 0x200000
             */

            //turnon(port, header, 2, 0x20);
            //turnon(port, header, 2, 0x12);
            //turnon(port, header, 2, 0x23);
            //turnon(port, header, 2, 0x24);
            //turnon(port, header, 2, 0x51);
            //turnon(port, header, 2, 0x52);

            // turnon(port.BaseStream, header, 3, 0xA);
            // turnon(port.BaseStream, header, 3, 0xF);

            //writepacket(port.BaseStream, header, rxmraw);
            //writepacket(port.BaseStream, header, rxmsfrb);

            //writepacket(port.BaseStream, header, rxmraw6h);
            //writepacket(port.BaseStream, header, rxmsfrb6h);

            //writepacket(port.BaseStream, header, rxmraw6m);
            //writepacket(port.BaseStream, header, rxmsfrb6m);

            //return;

            //turnon(port.BaseStream, header, 2, 0x10);
            //turnon(port.BaseStream, header, 2, 0x11);

            //testmsg.startaddr += 8;
            //testmsg.data = turnonbytes;
            //writepacket(port.BaseStream, header, testmsg);


            /*
             * System.Threading.Thread.Sleep(200);
             *
             * while (port.IsOpen)
             * {
             *
             *  while (port.BytesToRead > 0)
             *  {
             *      byte data = (byte)port.ReadByte();
             *
             *      // Console.Write("{0,2:x}",data);
             *
             *      processbyte(data);
             *  }
             *
             * }
             *
             * port.Close();
             *
             * // Console.ReadLine();
             *
             * return;
             */

            // safeboot
            var buf = new byte[] { 0xB5, 0x62, 0x09, 0x07, 0x00, 0x00, 0x10, 0x39 };

            buf = new byte[] { 0xB5, 0x62, 0x09, 0x07, 0x01, 0x00, 0x01, 0x12, 0x4D };

            //port.Write(buf, 0, buf.Length);

            //port.Close();
            //Thread.Sleep(1000);
            //port.Open();

            // dump rom/memory

            req           = new uploadreq();
            req.clas      = 0x9;
            req.subclass  = 0x2;
            req.length    = 12;
            req.startaddr = 0x800001;
            req.datasize  = 128;
            req.flags     = 0;

            var  deadline = DateTime.MinValue;
            uint lastaddr = 0;

            while (port.IsOpen)
            {
                // determine when to send a new/next request
                if (deadline < DateTime.Now || lastaddr != req.startaddr)
                {
                    var datastruct = StaticUtils.StructureToByteArray(req);

                    var checksum = ubx_checksum(datastruct, datastruct.Length);

                    port.Write(header, 0, header.Length);
                    port.Write(datastruct, 0, datastruct.Length);
                    port.Write(checksum, 0, checksum.Length);

                    deadline = DateTime.Now.AddMilliseconds(200);
                    lastaddr = req.startaddr;
                }

                Thread.Sleep(0);

                while (port.BytesToRead > 0)
                {
                    var data = (byte)port.ReadByte();

                    // Console.Write("{0,2:x}",data);

                    processbyte(data);
                }
            }
        }