diff --git a/RAMSPDToolkit/SPD/DDR4Accessor.cs b/RAMSPDToolkit/SPD/DDR4Accessor.cs
index 732e51b..6b5938f 100644
--- a/RAMSPDToolkit/SPD/DDR4Accessor.cs
+++ b/RAMSPDToolkit/SPD/DDR4Accessor.cs
@@ -88,6 +88,13 @@ public DDR4Accessor(SMBusInterface bus, byte address)
/// True if DDR4 is available at specified address; false otherwise.
public static bool IsAvailable(SMBusInterface bus, byte address)
{
+ //On DDR5 hubs offset 0x02 is the device revision, not the memory type.
+ //Its value can overlap the DDR4 memory type codes.
+ if (DDR5Accessor.HasHubDeviceType(bus, address))
+ {
+ return false;
+ }
+
int value;
//Select first page
diff --git a/RAMSPDToolkit/SPD/DDR5Accessor.cs b/RAMSPDToolkit/SPD/DDR5Accessor.cs
index f256273..cdac788 100644
--- a/RAMSPDToolkit/SPD/DDR5Accessor.cs
+++ b/RAMSPDToolkit/SPD/DDR5Accessor.cs
@@ -86,6 +86,12 @@ public DDR5Accessor(SMBusInterface bus, byte address)
/// True if DDR5 is available at specified address; false otherwise.
public static bool IsAvailable(SMBusInterface bus, byte address)
{
+ //Check device type before changing the page
+ if (!HasHubDeviceType(bus, address))
+ {
+ return false;
+ }
+
//Read current page
int status = RetryReadByteData(bus, address, DDR5Constants.SPD_DDR5_MREG_VIRTUAL_PAGE, SPDConstants.SPD_DATA_RETRIES, out byte page);
@@ -129,13 +135,28 @@ public static bool IsAvailable(SMBusInterface bus, byte address)
}
}
+ return true;
+ }
+
+ #endregion
+
+ #region Internal
+
+ ///
+ /// Detects if a DDR5 SPD Hub is available at specified address without changing the page.
+ ///
+ /// SMBus to check for RAM.
+ /// Address to check.
+ /// True if a DDR5 SPD Hub is available at specified address; false otherwise.
+ internal static bool HasHubDeviceType(SMBusInterface bus, byte address)
+ {
//Try read most significant byte
//Result should be 0x51
var result = RetryReadByteData(bus, address, DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST, SPDConstants.SPD_DATA_RETRIES, out byte ddr5Magic);
if (result < 0)
{
- LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(IsAvailable)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST)} due to error {result}.");
+ LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(HasHubDeviceType)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_MOST)} due to error {result}.");
}
//Try read least significant byte
@@ -144,7 +165,7 @@ public static bool IsAvailable(SMBusInterface bus, byte address)
if (result < 0)
{
- LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(IsAvailable)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_LEAST)} due to error {result}.");
+ LogSimple.LogTrace($"{nameof(DDR5Accessor)}.{nameof(HasHubDeviceType)} failed to read {nameof(DDR5Constants.SPD_DDR5_DEVICE_TYPE_LEAST)} due to error {result}.");
}
//Is it a DDR5 module ?