Skip to content

Commit

Permalink
Merge pull request #41 from LISTENAI/feature/allow_hex_format_firmware
Browse files Browse the repository at this point in the history
Feature: Allow hex format firmware
  • Loading branch information
chh7872 authored Oct 31, 2023
2 parents 5dcbdc6 + 9c27306 commit ae7a902
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private void FirmwarePackingForm_Load(object sender, EventArgs e) {

private void btnCskFwPathSelect_Click(object sender, EventArgs e) {
using var ofd = new OpenFileDialog();
ofd.Filter = "CSK6固件(*.img)|*.img";
ofd.Filter = "CSK6固件(*.img,*.hex)|*.img;*.hex";
ofd.Multiselect = false;
ofd.Title = "选择CSK6固件";
ofd.CheckPathExists = true;
Expand Down
2 changes: 1 addition & 1 deletion ListenAI.Factory.FirmwareDeploy/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void btnFwSelect_Click(object sender, EventArgs e) {

tsslCurrentFirmware.Text = $"CSK6固件: {fwCskInfo.Name} ({fwCskInfo.Version}) " +
$"WIFI固件: {fwWifiInfo.Name} ({fwWifiInfo.Version}) " +
$"固件包路径: {fwCfg.FullPath}";
$"固件包路径: {ofd.FileName}";
Global.SelectedFirmware = fwCfg;
EnableFirmwareButton(true, false);
}
Expand Down
2 changes: 1 addition & 1 deletion ListenAI.Factory.FirmwareDeploy/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
Expand Down
10 changes: 9 additions & 1 deletion ListenAI.Factory.FirmwareDeploy/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,17 @@ public static bool IsValidFirmware(string path, Constants.FirmwareType type) {

try {
var fw = File.ReadAllBytes(path);
var ext = Path.GetExtension(path);
switch (type) {
case Constants.FirmwareType.Csk:
return fw[0] == 0x0;
switch (ext.ToLower()) {
case ".img":
return fw[0] == 0x0;
case ".hex":
return fw[0] == ':';
default:
return false;
}
case Constants.FirmwareType.Asr:
var header = fw.Take(8).ToArray();
return header.SequenceEqual(Constants.ValidAsrFirmwareHeader);
Expand Down

0 comments on commit ae7a902

Please sign in to comment.