From 9c2730657a72f81aa1ac946ebab0d9988db69950 Mon Sep 17 00:00:00 2001
From: chh7872 <105700413+chh7872@users.noreply.github.com>
Date: Tue, 31 Oct 2023 14:59:26 +0800
Subject: [PATCH] (add) hex format firmware check rule (add) allow hex to be
packed
---
ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs | 2 +-
ListenAI.Factory.FirmwareDeploy/MainForm.cs | 2 +-
ListenAI.Factory.FirmwareDeploy/MainForm.resx | 2 +-
ListenAI.Factory.FirmwareDeploy/Utils.cs | 10 +++++++++-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs b/ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs
index 1d07679..b782f57 100644
--- a/ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs
+++ b/ListenAI.Factory.FirmwareDeploy/FirmwarePackingForm.cs
@@ -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;
diff --git a/ListenAI.Factory.FirmwareDeploy/MainForm.cs b/ListenAI.Factory.FirmwareDeploy/MainForm.cs
index 9509284..9e84a33 100644
--- a/ListenAI.Factory.FirmwareDeploy/MainForm.cs
+++ b/ListenAI.Factory.FirmwareDeploy/MainForm.cs
@@ -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);
}
diff --git a/ListenAI.Factory.FirmwareDeploy/MainForm.resx b/ListenAI.Factory.FirmwareDeploy/MainForm.resx
index 5918fd6..7258ec3 100644
--- a/ListenAI.Factory.FirmwareDeploy/MainForm.resx
+++ b/ListenAI.Factory.FirmwareDeploy/MainForm.resx
@@ -18,7 +18,7 @@
System.Resources.ResXResourceReader, System.Windows.Forms, ...
System.Resources.ResXResourceWriter, System.Windows.Forms, ...
this is my long stringthis is a comment
- Blue
+ Blue
[base64 mime encoded serialized .NET Framework object]
diff --git a/ListenAI.Factory.FirmwareDeploy/Utils.cs b/ListenAI.Factory.FirmwareDeploy/Utils.cs
index 1f3a8cb..270abad 100644
--- a/ListenAI.Factory.FirmwareDeploy/Utils.cs
+++ b/ListenAI.Factory.FirmwareDeploy/Utils.cs
@@ -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);