Skip to content

Commit fe7b45b

Browse files
committed
Firmware: add chip and chip_des
1 parent 27321d3 commit fe7b45b

File tree

10 files changed

+3284
-3660
lines changed

10 files changed

+3284
-3660
lines changed

ExtLibs/Xamarin/Xamarin/GCSViews/Firmware.xaml.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ public async Task<bool> UploadPX4(string filename)
349349
{
350350
up.identify();
351351
updateProgress(-1, "Identify");
352-
log.InfoFormat("Found board type {0} boardrev {1} bl rev {2} fwmax {3} on {4}", up.board_type,
353-
up.board_rev, up.bl_rev, up.fw_maxsize, port);
352+
log.InfoFormat("Found board type {0} brdrev {1} blrev {2} fwmax {3} chip {5:X} chipdes {6} on {4}", up.board_type,
353+
up.board_rev, up.bl_rev, up.fw_maxsize, port, up.chip, up.chip_desc);
354354

355355
up.ProgressEvent += new Uploader.ProgressEventHandler(up_ProgressEvent);
356356
up.LogEvent += new Uploader.LogEventHandler(up_LogEvent);
@@ -550,9 +550,8 @@ public void DeviceAttached(object USBDevice, object usbdevice)
550550
try
551551
{
552552
up.identify();
553-
var msg = String.Format("Found board type {0} boardrev {1} bl rev {2} fwmax {3} on {4}",
554-
up.board_type,
555-
up.board_rev, up.bl_rev, up.fw_maxsize, port);
553+
var msg = String.Format("Found board type {0} brdrev {1} blrev {2} fwmax {3} chip {5:X} chipdes {6} on {4}", up.board_type,
554+
up.board_rev, up.bl_rev, up.fw_maxsize, port, up.chip, up.chip_desc);
556555
log.Info(msg);
557556

558557
up.close();

ExtLibs/px4uploader/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public static bool Uploader(string fn)
8080
try
8181
{
8282
up.identify();
83-
Console.WriteLine("Found board type {0} boardrev {1} bl rev {2} fwmax {3} on {4}", up.board_type, up.board_rev,up.bl_rev,up.fw_maxsize, port);
83+
Console.WriteLine("Found board type {0} brdrev {1} blrev {2} fwmax {3} chip {5:X} chipdes {6} on {4}", up.board_type,
84+
up.board_rev, up.bl_rev, up.fw_maxsize, port, up.chip, up.chip_desc);
8485
}
8586
catch ( Exception)
8687
{

ExtLibs/px4uploader/Uploader.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class Uploader: IDisposable
3131
public int board_type;
3232
public int board_rev;
3333
public int fw_maxsize;
34+
public int chip;
35+
public string chip_desc;
3436
public int bl_rev;
3537
public bool libre = false;
3638

@@ -43,6 +45,8 @@ public enum Code : byte
4345
INSYNC = 0x12,
4446
INVALID = 0x13,// # rev3+
4547

48+
BAD_SILICON_REV = 0x14,
49+
4650
// protocol commands
4751
EOC = 0x20,
4852
GET_SYNC = 0x21,
@@ -55,8 +59,11 @@ public enum Code : byte
5559
GET_OTP = 0x2a, // read a byte from OTP at the given address
5660
GET_SN = 0x2b, // read a word from UDID area ( Serial) at the given address
5761
GET_CHIP = 0x2c, // read chip version (MCU IDCODE)
58-
PROTO_SET_DELAY = 0x2d, // set minimum boot delay
62+
SET_DELAY = 0x2d, // set minimum boot delay
63+
GET_CHIP_DES = 0x2e,
5964
REBOOT = 0x30,
65+
PROTO_DEBUG = 0x31,
66+
PROTO_SET_BAUD = 0x33
6067
}
6168

6269
public enum Info {
@@ -69,8 +76,8 @@ public enum Info {
6976

7077
public const byte BL_REV_MIN = 2;// # minimum supported bootloader protocol
7178
public const byte BL_REV_MAX = 10;// # maximum supported bootloader protocol
72-
public const byte PROG_MULTI_MAX = 60;// # protocol max is 255, must be multiple of 4
73-
public const byte READ_MULTI_MAX = 60;// # protocol max is 255, something overflows with >= 64
79+
public const byte PROG_MULTI_MAX = 64;// # protocol max is 255, must be multiple of 4
80+
public const byte READ_MULTI_MAX = 255;// # protocol max is 255, something overflows with >= 64
7481

7582

7683
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -385,6 +392,22 @@ public int __getCHIP()
385392
return info;
386393
}
387394

395+
public string __getCHIPDES()
396+
{
397+
__send(new byte[] { (byte)Code.GET_CHIP_DES, (byte)Code.EOC });
398+
int len = __recv_int();
399+
if (len > 0)
400+
{
401+
var bytes = __recv(len);
402+
__getSync();
403+
return ASCIIEncoding.ASCII.GetString(bytes);
404+
} else
405+
{
406+
__getSync();
407+
return "";
408+
}
409+
}
410+
388411
public void __send(byte c)
389412
{
390413
port.Write(new byte[] { c }, 0, 1);
@@ -560,13 +583,12 @@ public void __program(Firmware fw)
560583
{
561584
byte[] code = fw.imagebyte;
562585
List<byte[]> groups = self.__split_len(code, PROG_MULTI_MAX);
563-
Console.WriteLine("Programing packet total: "+groups.Count);
564586
int a = 1;
565587
foreach (Byte[] bytes in groups)
566588
{
567589
self.__program_multi(bytes);
568590

569-
Console.WriteLine("Program {0}/{1}",a, groups.Count);
591+
System.Diagnostics.Debug.WriteLine("Program {0}/{1}", a, groups.Count);
570592

571593
a++;
572594
if (ProgressEvent != null)
@@ -589,7 +611,7 @@ public void __verify_v2(Firmware fw)
589611
throw new Exception("Verification failed");
590612
}
591613

592-
Console.WriteLine("Verify {0}/{1}", a, groups.Count);
614+
System.Diagnostics.Debug.WriteLine("Verify {0}/{1}", a, groups.Count);
593615

594616
a++;
595617
if (ProgressEvent != null)
@@ -668,6 +690,9 @@ public void identify()
668690
self.board_type = self.__getInfo(Info.BOARD_ID);
669691
self.board_rev = self.__getInfo(Info.BOARD_REV);
670692
self.fw_maxsize = self.__getInfo(Info.FLASH_SIZE);
693+
694+
self.chip = self.__getCHIP();
695+
self.chip_desc = self.__getCHIPDES();
671696
}
672697

673698
public void upload(Firmware fw)

GCSViews/ConfigurationView/ConfigFirmware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ private void Instance_DeviceChanged(MainV2.WM_DEVICECHANGE_enum cause)
8686
try
8787
{
8888
up.identify();
89-
log.InfoFormat("Found board type {0} boardrev {1} bl rev {2} fwmax {3} on {4}", up.board_type,
90-
up.board_rev, up.bl_rev, up.fw_maxsize, port);
89+
log.InfoFormat("Found board type {0} brdrev {1} blrev {2} fwmax {3} chip {5:X} chipdes {6} on {4}", up.board_type,
90+
up.board_rev, up.bl_rev, up.fw_maxsize, port, up.chip, up.chip_desc);
9191

9292
detectedport = port;
9393

GCSViews/ConfigurationView/ConfigFirmwareManifest.Designer.cs

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GCSViews/ConfigurationView/ConfigFirmwareManifest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ private void Instance_DeviceChanged(MainV2.WM_DEVICECHANGE_enum cause)
128128
try
129129
{
130130
up.identify();
131-
var msg = String.Format("Found board type {0} boardrev {1} bl rev {2} fwmax {3} on {4}",
132-
up.board_type,
133-
up.board_rev, up.bl_rev, up.fw_maxsize, port);
131+
var msg = String.Format("Found board type {0} brdrev {1} blrev {2} fwmax {3} chip {5:X} chipdes {6} on {4}", up.board_type,
132+
up.board_rev, up.bl_rev, up.fw_maxsize, port, up.chip, up.chip_desc);
134133
log.Info(msg);
135134

136135
up.close();

0 commit comments

Comments
 (0)