在增加校验进度
This commit is contained in:
@@ -1715,145 +1715,159 @@ namespace WinISP
|
||||
private bool ValidateMonitorVsBin(out string errMsg)
|
||||
{
|
||||
errMsg = String.Empty;
|
||||
bool isAmdOrIntel = IsAmdOrIntelPath();
|
||||
|
||||
prbProgress.Style = ProgressBarStyle.Marquee;
|
||||
prbProgress.MarqueeAnimationSpeed = 30;
|
||||
SetStatusMsg("Verifying monitor firmware information, please wait...");
|
||||
|
||||
try
|
||||
{
|
||||
bool isAmdOrIntel = IsAmdOrIntelPath();
|
||||
|
||||
QueryConnectedMonitorInfo();
|
||||
QueryConnectedMonitorInfo();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_fwVersionFromDDC))
|
||||
{
|
||||
_fwVersionFromDDC = DDC_GetMonitorName(MS_GET_FW_VERSION);
|
||||
frmISP.WriteLog($"DDC_GetMonitorName:_fwVersionFromDDC{_fwVersionFromDDC}", "debug");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(_fwVersionFromDDC))
|
||||
{
|
||||
_fwVersionFromDDC = DDC_GetMonitorName(MS_GET_FW_VERSION);
|
||||
frmISP.WriteLog($"DDC_GetMonitorName:_fwVersionFromDDC{_fwVersionFromDDC}", "debug");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Legacy-batch fallback: old monitors shipped before DDC identity commands
|
||||
// were implemented do not respond to MS_GET_MODEL_NAME / CHIP / PANEL / BOARD.
|
||||
// When no reply is received, substitute the known identifiers from the legacy
|
||||
// batch BIN file: MAG 321UPD E14_V8-MM802MS-G01V033_20260429_8ECF.bin
|
||||
//
|
||||
// Also treat firmware that returns the placeholder "MST9U6_PanelCMIM236HGJ_L21"
|
||||
// as legacy: the tool_model_panel_name macro was never updated to the real product
|
||||
// name in early firmware versions, so use the same hardcoded identifiers.
|
||||
// -----------------------------------------------------------------------
|
||||
const string LegacyModel = "MAG 321UPD E14";
|
||||
const string LegacyChip = "MST9U";
|
||||
const string LegacyPanel = "Panel_SG315GD01_2_eDP";
|
||||
const string LegacyFWVer = "FW.033"; // from MAG 321UPD E14_V8-MM802MS-G01V033_20260429_8ECF.bin
|
||||
const string PlaceholderModelName = "MST9U6_PanelCM";
|
||||
// -----------------------------------------------------------------------
|
||||
// Legacy-batch fallback: old monitors shipped before DDC identity commands
|
||||
// were implemented do not respond to MS_GET_MODEL_NAME / CHIP / PANEL / BOARD.
|
||||
// When no reply is received, substitute the known identifiers from the legacy
|
||||
// batch BIN file: MAG 321UPD E14_V8-MM802MS-G01V033_20260429_8ECF.bin
|
||||
//
|
||||
// Also treat firmware that returns the placeholder "MST9U6_PanelCMIM236HGJ_L21"
|
||||
// as legacy: the tool_model_panel_name macro was never updated to the real product
|
||||
// name in early firmware versions, so use the same hardcoded identifiers.
|
||||
// -----------------------------------------------------------------------
|
||||
const string LegacyModel = "MAG 321UPD E14";
|
||||
const string LegacyChip = "MST9U";
|
||||
const string LegacyPanel = "Panel_SG315GD01_2_eDP";
|
||||
const string LegacyFWVer = "FW.033"; // from MAG 321UPD E14_V8-MM802MS-G01V033_20260429_8ECF.bin
|
||||
const string PlaceholderModelName = "MST9U6_PanelCM";
|
||||
|
||||
// Placeholder detection: match exact string or any valid prefix of it (DDC reads may be truncated).
|
||||
string _fwModelTrim = (_monitorModelName ?? string.Empty).Trim();
|
||||
bool fwModelIsPlaceholder =
|
||||
(_fwModelTrim.Length >= 8 && PlaceholderModelName.StartsWith(_fwModelTrim, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(_fwModelTrim, PlaceholderModelName, StringComparison.OrdinalIgnoreCase);
|
||||
if (fwModelIsPlaceholder)
|
||||
frmISP.WriteLog("Monitor firmware返回占位符model名 '" + _monitorModelName + "',使用LegacyFallback进行四项校验", "debug");
|
||||
// Placeholder detection: match exact string or any valid prefix of it (DDC reads may be truncated).
|
||||
string _fwModelTrim = (_monitorModelName ?? string.Empty).Trim();
|
||||
bool fwModelIsPlaceholder =
|
||||
(_fwModelTrim.Length >= 8 && PlaceholderModelName.StartsWith(_fwModelTrim, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(_fwModelTrim, PlaceholderModelName, StringComparison.OrdinalIgnoreCase);
|
||||
if (fwModelIsPlaceholder)
|
||||
frmISP.WriteLog("Monitor firmware返回占位符model名 '" + _monitorModelName + "',使用LegacyFallback进行四项校验", "debug");
|
||||
|
||||
bool usingLegacyFallback = string.IsNullOrWhiteSpace(_monitorModelName) || fwModelIsPlaceholder;
|
||||
bool usingLegacyFallback = string.IsNullOrWhiteSpace(_monitorModelName) || fwModelIsPlaceholder;
|
||||
|
||||
string effModel = usingLegacyFallback ? LegacyModel : _monitorModelName;
|
||||
string effChip = !string.IsNullOrWhiteSpace(_monitorChipName) ? _monitorChipName
|
||||
: (usingLegacyFallback ? LegacyChip : string.Empty);
|
||||
string effPanel = !string.IsNullOrWhiteSpace(_monitorPanelName) ? _monitorPanelName
|
||||
: (usingLegacyFallback ? LegacyPanel : string.Empty);
|
||||
string effModel = usingLegacyFallback ? LegacyModel : _monitorModelName;
|
||||
string effChip = !string.IsNullOrWhiteSpace(_monitorChipName) ? _monitorChipName
|
||||
: (usingLegacyFallback ? LegacyChip : string.Empty);
|
||||
string effPanel = !string.IsNullOrWhiteSpace(_monitorPanelName) ? _monitorPanelName
|
||||
: (usingLegacyFallback ? LegacyPanel : string.Empty);
|
||||
|
||||
// effVer: prefer actual DDC read; fall back to LegacyFWVer when in legacy-fallback mode
|
||||
// (covers AMD/Intel path where DDC identity commands are not supported).
|
||||
string effVer = !string.IsNullOrWhiteSpace(_fwVersionFromDDC) ? _fwVersionFromDDC
|
||||
: (usingLegacyFallback ? LegacyFWVer : string.Empty);
|
||||
// effVer: prefer actual DDC read; fall back to LegacyFWVer when in legacy-fallback mode
|
||||
// (covers AMD/Intel path where DDC identity commands are not supported).
|
||||
string effVer = !string.IsNullOrWhiteSpace(_fwVersionFromDDC) ? _fwVersionFromDDC
|
||||
: (usingLegacyFallback ? LegacyFWVer : string.Empty);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_u8ModelName))
|
||||
{
|
||||
errMsg = "无法解析bin中的Model信息,请重新选择bin文件。";
|
||||
return false;
|
||||
}
|
||||
|
||||
string src = usingLegacyFallback ? "LegacyFallback" : "FW";
|
||||
|
||||
if (!IsFieldMatch(_u8ModelName, effModel))
|
||||
{
|
||||
// Fallback: accept fw model as prefix of bin model name.
|
||||
// NVIDIA DP AUX can truncate DDC reads, so the fw name may be a prefix of the full name.
|
||||
string fwTrim = (effModel ?? string.Empty).Trim();
|
||||
string binTrim = (_u8ModelName ?? string.Empty).Trim();
|
||||
if (fwTrim.Length < 6 || !binTrim.Equals(fwTrim, StringComparison.Ordinal))
|
||||
if (string.IsNullOrWhiteSpace(_u8ModelName))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{fwTrim},Bin:{binTrim}","debug");
|
||||
errMsg = "Model not match.";
|
||||
errMsg = "无法解析bin中的Model信息,请重新选择bin文件。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Only validate chip/panel when both sides have the value.
|
||||
if (!string.IsNullOrWhiteSpace(effChip) && !string.IsNullOrWhiteSpace(_u8ChipName)
|
||||
&& !IsFieldMatch(_u8ChipName, effChip))
|
||||
{
|
||||
// Prefix-match fallback: BIN chip "MST9U6" should pass against legacy effChip "MST9U".
|
||||
string fwChipTrim = (effChip ?? string.Empty).Trim();
|
||||
string binChipTrim = (_u8ChipName ?? string.Empty).Trim();
|
||||
if (!binChipTrim.Equals(fwChipTrim, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{fwChipTrim},Bin:{binChipTrim}", "debug");
|
||||
errMsg = "Chip not match.";
|
||||
return false;
|
||||
}
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: Chip prefix-match accepted: FW=" + effChip + " BIN=" + _u8ChipName, "debug");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(effPanel))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_u8PanelName))
|
||||
string src = usingLegacyFallback ? "LegacyFallback" : "FW";
|
||||
|
||||
if (!IsFieldMatch(_u8ModelName, effModel))
|
||||
{
|
||||
// BIN has no panel info but monitor expects a specific panel – block upgrade.
|
||||
errMsg = "Panel not match. (BIN has no panel info)";
|
||||
return false;
|
||||
}
|
||||
if (!IsFieldMatch(_u8PanelName, effPanel))
|
||||
{
|
||||
// Same prefix-match fallback as Model: DDC truncation may deliver only a prefix.
|
||||
string fwPanelTrim = (effPanel ?? string.Empty).Trim();
|
||||
string binPanelTrim = (_u8PanelName ?? string.Empty).Trim();
|
||||
if (fwPanelTrim.Length < 6 || !binPanelTrim.Equals(fwPanelTrim, StringComparison.Ordinal))
|
||||
// Fallback: accept fw model as prefix of bin model name.
|
||||
// NVIDIA DP AUX can truncate DDC reads, so the fw name may be a prefix of the full name.
|
||||
string fwTrim = (effModel ?? string.Empty).Trim();
|
||||
string binTrim = (_u8ModelName ?? string.Empty).Trim();
|
||||
if (fwTrim.Length < 6 || !binTrim.Equals(fwTrim, StringComparison.Ordinal))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{fwPanelTrim},Bin:{binPanelTrim}", "debug");
|
||||
errMsg = "Panel not match.";
|
||||
frmISP.WriteLog($"FW:{fwTrim},Bin:{binTrim}","debug");
|
||||
errMsg = "Model not match.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Board name is NOT stored in the BIN ISP info struct (field 4 is u8FWversion);
|
||||
// board validation is therefore skipped.
|
||||
|
||||
// Validate FW version prefix (first 4 chars, e.g. "FW.0").
|
||||
// FW.033 vs FW.034 => same prefix => allowed.
|
||||
// FG.034 vs FW.034 => different prefix => rejected.
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: monVer(DDC)=" + (string.IsNullOrWhiteSpace(effVer) ? "(empty)" : effVer)
|
||||
+ " binVer=" + (string.IsNullOrWhiteSpace(_u8FWVersion) ? "(empty)" : _u8FWVersion), "debug");
|
||||
if (!string.IsNullOrWhiteSpace(_u8FWVersion))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(effVer))
|
||||
// Only validate chip/panel when both sides have the value.
|
||||
if (!string.IsNullOrWhiteSpace(effChip) && !string.IsNullOrWhiteSpace(_u8ChipName)
|
||||
&& !IsFieldMatch(_u8ChipName, effChip))
|
||||
{
|
||||
// BIN has a version but monitor version is unreadable – treat as mismatch.
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: effVer is empty, cannot verify FW version.", "debug");
|
||||
errMsg = "FW Version not match." ;
|
||||
return false;
|
||||
// Prefix-match fallback: BIN chip "MST9U6" should pass against legacy effChip "MST9U".
|
||||
string fwChipTrim = (effChip ?? string.Empty).Trim();
|
||||
string binChipTrim = (_u8ChipName ?? string.Empty).Trim();
|
||||
if (!binChipTrim.Equals(fwChipTrim, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{fwChipTrim},Bin:{binChipTrim}", "debug");
|
||||
errMsg = "Chip not match.";
|
||||
return false;
|
||||
}
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: Chip prefix-match accepted: FW=" + effChip + " BIN=" + _u8ChipName, "debug");
|
||||
}
|
||||
|
||||
string normalizedMonVer = NormalizeFwVersionForCompare(effVer);
|
||||
string normalizedBinVer = NormalizeFwVersionForCompare(_u8FWVersion);
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: normalizedMonVer=" + normalizedMonVer + " normalizedBinVer=" + normalizedBinVer, "debug");
|
||||
if (!string.Equals(normalizedMonVer, normalizedBinVer, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(effPanel))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{normalizedMonVer},Bin:{normalizedBinVer}", "debug");
|
||||
errMsg = "FW Version not match.";
|
||||
return false;
|
||||
if (string.IsNullOrWhiteSpace(_u8PanelName))
|
||||
{
|
||||
// BIN has no panel info but monitor expects a specific panel – block upgrade.
|
||||
errMsg = "Panel not match. (BIN has no panel info)";
|
||||
return false;
|
||||
}
|
||||
if (!IsFieldMatch(_u8PanelName, effPanel))
|
||||
{
|
||||
// Same prefix-match fallback as Model: DDC truncation may deliver only a prefix.
|
||||
string fwPanelTrim = (effPanel ?? string.Empty).Trim();
|
||||
string binPanelTrim = (_u8PanelName ?? string.Empty).Trim();
|
||||
if (fwPanelTrim.Length < 6 || !binPanelTrim.Equals(fwPanelTrim, StringComparison.Ordinal))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{fwPanelTrim},Bin:{binPanelTrim}", "debug");
|
||||
errMsg = "Panel not match.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: FW version check skipped (_u8FWVersion is empty).", "debug");
|
||||
}
|
||||
// Board name is NOT stored in the BIN ISP info struct (field 4 is u8FWversion);
|
||||
// board validation is therefore skipped.
|
||||
|
||||
return true;
|
||||
// Validate FW version prefix (first 4 chars, e.g. "FW.0").
|
||||
// FW.033 vs FW.034 => same prefix => allowed.
|
||||
// FG.034 vs FW.034 => different prefix => rejected.
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: monVer(DDC)=" + (string.IsNullOrWhiteSpace(effVer) ? "(empty)" : effVer)
|
||||
+ " binVer=" + (string.IsNullOrWhiteSpace(_u8FWVersion) ? "(empty)" : _u8FWVersion), "debug");
|
||||
if (!string.IsNullOrWhiteSpace(_u8FWVersion))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(effVer))
|
||||
{
|
||||
// BIN has a version but monitor version is unreadable – treat as mismatch.
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: effVer is empty, cannot verify FW version.", "debug");
|
||||
errMsg = "FW Version not match." ;
|
||||
return false;
|
||||
}
|
||||
|
||||
string normalizedMonVer = NormalizeFwVersionForCompare(effVer);
|
||||
string normalizedBinVer = NormalizeFwVersionForCompare(_u8FWVersion);
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: normalizedMonVer=" + normalizedMonVer + " normalizedBinVer=" + normalizedBinVer, "debug");
|
||||
if (!string.Equals(normalizedMonVer, normalizedBinVer, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
frmISP.WriteLog($"FW:{normalizedMonVer},Bin:{normalizedBinVer}", "debug");
|
||||
errMsg = "FW Version not match.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frmISP.WriteLog("ValidateMonitorVsBin: FW version check skipped (_u8FWVersion is empty).", "debug");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
prbProgress.MarqueeAnimationSpeed = 0;
|
||||
prbProgress.Style = ProgressBarStyle.Blocks;
|
||||
prbProgress.Value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
List<FlashSectorInfo> flashSectorInfo = new List<FlashSectorInfo>();
|
||||
|
||||
Reference in New Issue
Block a user