Ver Fonte

Improve detection of 2021 boards and firmware updates in scsi2sd-util

Michael McMaster há 4 anos atrás
pai
commit
0638ac314c

+ 7 - 0
lib/SCSI2SD/src/firmware/hwversion.c

@@ -82,6 +82,13 @@ checkHwSensePins()
 		while (1) {}
 	}
 #endif
+#ifdef REV_2021
+    if ((DBGMCU->IDCODE & 0x00000FFF) != 0x0421)
+    {
+		// Oh dear, wrong cpu. Do not pass go.
+		while (1) {}
+    }
+#endif
 }
 
 void

+ 11 - 6
lib/SCSI2SD/src/scsi2sd-util6/SCSI2SD_HID.cc

@@ -401,11 +401,16 @@ HID::getSerialNumber()
 bool
 HID::isCorrectFirmware(const std::string& path)
 {
+    if (path.rfind(".dfu") != path.size() - 4)
+    {
+        return false;
+    }
+
 	if (myFirmwareVersion < 0x0630)
 	{
 		// Definitely the older hardware.
-		return path.rfind("firmware.V6.revF.dfu") != std::string::npos ||
-			path.rfind("firmware.dfu") != std::string::npos;
+		return path.rfind("firmware.V6.revF") != std::string::npos ||
+			path.rfind("firmware") != std::string::npos;
 	}
 	else if (myFirmwareVersion == 0x0630)
 	{
@@ -426,17 +431,17 @@ HID::isCorrectFirmware(const std::string& path)
 			if (prodStr.find(L"2020") != std::string::npos)
 			{
 				// Definitely the 2020c or newer hardware.
-				return path.rfind("firmware.V6.2020.dfu") != std::string::npos;
+				return path.rfind("firmware.V6.2020") != std::string::npos;
 			}
 			else if (prodStr.find(L"2021") != std::string::npos)
 			{
 				// Definitely the 2020c or newer hardware.
-				return path.rfind("firmware.V6.2021.dfu") != std::string::npos;
+				return path.rfind("firmware.V6.2021") != std::string::npos;
 			}
 			else
 			{
-				return path.rfind("firmware.V6.revF.dfu") != std::string::npos ||
-					path.rfind("firmware.dfu") != std::string::npos;
+				return path.rfind("firmware.V6.revF") != std::string::npos ||
+					path.rfind("firmware") != std::string::npos;
 			}
 		}
 	}

+ 6 - 0
lib/SCSI2SD/src/scsi2sd-util6/scsi2sd-util.cc

@@ -599,6 +599,7 @@ private:
 				wxOK | wxICON_ERROR);
 			return false;
 		}
+        file.Close();
 		wxRemoveFile(tmpFile);
 
 		uint32_t value =
@@ -612,6 +613,11 @@ private:
 			wxLogMessage("OTP Hardware version not set. Ignoring.");
 			return true;
 		}
+		else if (value == 0x06002021)
+		{
+			wxLogMessage("Found V6 2021 hardware marker");
+			return firmware.rfind("firmware.V6.2021.dfu") != std::string::npos;
+		}
 		else if (value == 0x06002020)
 		{
 			wxLogMessage("Found V6 2020 hardware marker");