ken-yossy / nvmetool-win Goto Github PK
View Code? Open in Web Editor NEWCommunicate with NVMe SSD using Windows' inbox device driver
License: Other
Communicate with NVMe SSD using Windows' inbox device driver
License: Other
Reported value for Maximum Domain Namespace Attachments (MAXDNA) seems to be wrong.
Can you add a function for sending a vendor-specific command to NVME SSD? thanks!
VS2019 build failed.
PDEVICE_INTERNAL_STATUS_DATA not define.
Could you help check it?
Hi Ken, thanks for your great job about developing NVMe tool in Windows, it helps me a lot for understanding how to access Windows's inbox NVMe driver.
However, I'd like to know if it's possible to provide sample code about "Security Receive" command? I think it would be great to get more information about "level 0 discovery data" from this command.
Please let me know how you think about this, many thanks.
According to M$ doc https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddstor/ne-ntddstor-_storage_protocol_nvme_data_type :
for IOCTL_STORAGE_QUERY_PROPERTY with NVMeDataTypeLogPage
, field ProtocolDataRequestSubValue
in STORAGE_PROTOCOL_SPECIFIC_DATA is offset for log page, not NamespaceID. Insert NVME_NAMESPACE_ALL
as log page offset will cause Error 1117 :)
I noticed this problem for NVME_LOG_PAGE_HEALTH_INFO
and NVME_LOG_PAGE_COMMAND_EFFECTS
.
Hi,
Want to read DATA in raw-binary format but as per "PSTORAGE_PROTOCOL_SPECIFIC_DATA" i cant find the parameter to be set for this.
Can you please give me for the same?
Hi ken-yossy;
I am an engineer in china who develop nvme test python lib with boost c++ lib;
can you give me your email or other information, i want to contact with you, thx.
Hi Ken,
First of all, thank you so much for making this amazing tool, it's very helpful for a NVMe beginner like me.
But on the first time I try to run NVMeTool.exe it suggests that there is an I/O device error.
The error message is:
[I] Running on Windows 11 build 22000[E] DeviceIoControl: (error code = 1117) The request could not be performed because of an I/O device error.
[E] Getting controller identify data failed, stop.
Environments are as below:
CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz 2.80 GHz
OS: Windows 11 22000.469
Dependencies: Visual Studio Community 16.8.4 + Windows Driver Kit 10.0.20348.0
Looking forward to your reply, that will be much of help!
Regard,
freeqimmy
Reported value for MEGCAP in Identify Controller data structure seems to be wrong.
Send a command to the SSD, open PhysicalDrive%hs through CreateFile, and then send the IOCTL command to the SSD.
If Windows does not recognize PhysicalDrive%hs (for example, the SSD device does not start normally), is there a way to send an IOCTL command to the SSD? Similar to the character device that can send IOCTL to SSD under Linux
Thanks
The Linux kernel prints an error if the SUBNQN field is invalid or missing. This can be verified with nvme id-ctrl /dev/nvme0n1
on Linux with nvme-cli.
Unfortunately, the Dell support asks for a command to verify this under Microsoft Windows, which I do not have access to. The example outputs in your Wiki contain the SUBNQN field. Can you please tell me how to get those example outputs with your tool, so I can forward it to the Dell support?
Bit new to this, so might be doing some silly mistake.
Have downloaded and compiled nvmetool-win as per your readme and was able to successfully generate NVMETool.exe
But while trying to run (NVMeTool.exe PhysicalDrive0) it am getting below error:-
"[I] Running on Windows 10 build 18363[E] CreateFile: (error code = 2) The system cannot find the file specified."
Not sure if something is wrong with my setup., can you please help me in resolving this issue.?
MS claims to support setting LSP, RAE bits via ProtocolDataRequestSubValue4 in Get Log Page
command in Working with NVMe drives. It seems to be valid from Windows 10 build 22000 (Windows 11?)or later.
As Windows 11 ISO (install) image (build 22000.132) has been released in Windows Insider, re-open #13.
Add support of Supported Log Pages in Get Log Page command introduced from NVMe 2.0
Please let us know when can we have an ARM64 version for Windows on ARM OS.
Hi Ken,
MS claims to support setting LSP, RAE bits via ProtocolDataRequestSubValue4. I guess you can reflect this in your tool to read telemetry.
Update the Windows device through IOCTL_STORAGE_FIRMWARE_DOWNLOAD, the windows computer directly prompts the crash prompt "SYSTEM_SERVICE_EXCEPTION", How to use IOCTL_STORAGE_FIRMWARE_DOWNLOAD?
thanks
Reported value for NVM Capacity (NVMCAP) in Identify Namespace data structure seems to be wrong.
Add support of Endurance Group Event Aggregate log in Get Log Page command introduced in NVMe 1.4
Hi Ken-Yossy,
During usage of the Tool,
I tried the commands and found that I could not issue Format NVM.
And the error message is:
[E] DeviceIOControl : (ErrorCode=1) Incorrect function.
[E] Failed in issuing Format NVM command by DeviceIOControl (IOCTL_STORAGE_REINITIALIZE_MEDIA)
I'm wondering to know if there is some setting or config I should modify or change?
Thanks for your kindly help.
Environments as below:
MB : Gigabyte X570 UD
CPU : AMD Ryzen 3 3100 4-Core Processor
OS: Windows 10 10.0.10586
Does the Windows 10 suppotr the new feature Endurance Group Information (Log Identifier 09h) of NVMe spec 1.4 chapter 5.14.1.9 ?
Follow this page (https://docs.microsoft.com/en-us/windows/win32/fileio/working-with-nvme-devices#example-nvme-get-log-pages-query) , i set ProtocolDataRequestValue to 0x09 and set ProtocolDataRequestSubValue3(CDW11) to 0x010000, but the SSD can not get the CDW11,it's always 0.
But in Linux using NVMe-cli i can get the righe data
So do you know how to add the Endurance Group Information (Log Identifier 09h) to the code?
I see that this application lacks FW processing routines. Is it possible to add them?
One trick - since Win10 2004 only CA=3 is supported.
Why can't I read and recognize the mobile nvme hard disk?
when i get log page (F0, it is a vendor specified ), rerurn erro 1117 ,but when i get log page (DF ,it is also a vendor specified), it work , i am confused , ,both of them are vu LID , why F0 can not support,
below is my code
CPP_API ULONGLONG __cdecl AhciGetLogPageNVMe_F0(UINT str)
{
//str = 23;
//int LID = 2;
int LID = 0xf0;
DWORD log_buffer[32] = { 0 };
//UINT32 log_buffer[1024] = {0};
BYTE SmartReadData[32] = { 0 }; //f0 length
//log_buffer = &SmartReadData;
TCHAR deviceName[MAX_PATH];
//const TCHAR* SamsungTestPath = _T("\\\\.\\PhysicalDrive1");
//DWORD log_length = 512; //smart info 512
DWORD log_length = 32;
PSTORAGE_PROPERTY_QUERY query;
PSTORAGE_PROTOCOL_DATA_DESCRIPTOR protocolDataDescr;
PSTORAGE_PROTOCOL_SPECIFIC_DATA protocolData;
BOOL result;
DWORD returnedLength;
PVOID buffer = NULL;
DWORD bufferLength = FIELD_OFFSET(STORAGE_PROPERTY_QUERY, AdditionalParameters) + sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA) + log_length;
buffer = malloc(bufferLength);
ZeroMemory(buffer, bufferLength);
query = (PSTORAGE_PROPERTY_QUERY)buffer;
protocolDataDescr = (PSTORAGE_PROTOCOL_DATA_DESCRIPTOR)buffer;
protocolData = (PSTORAGE_PROTOCOL_SPECIFIC_DATA)query->AdditionalParameters;
query->PropertyId = StorageDeviceProtocolSpecificProperty;
query->QueryType = PropertyStandardQuery;
protocolData->ProtocolType = ProtocolTypeNvme;
protocolData->DataType = NVMeDataTypeLogPage;
protocolData->ProtocolDataRequestValue = LID;
//protocolData->ProtocolDataRequestSubValue = 1;
protocolData->ProtocolDataRequestSubValue = 0;
protocolData->ProtocolDataOffset = sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA);
//protocolData->ProtocolDataLength = sizeof(NVME_COMMAND_EFFECTS_LOG);
protocolData->ProtocolDataLength = log_length;
printf(("device_path %X.\n"), ((UCHAR)deviceName));
printf(("LID %X.\n"), ((UCHAR)LID));
m_hDisk = device();
if (m_hDisk == INVALID_HANDLE_VALUE) // cannot open the drive
{
printf("invalid device\n", ((UCHAR)("invalid device")));
printf("open error %d\n", GetLastError());
}
result = DeviceIoControl(m_hDisk,
IOCTL_STORAGE_QUERY_PROPERTY,
buffer,
bufferLength,
buffer,
bufferLength,
&returnedLength,
NULL
);
CloseHandle(m_hDisk);
if (!result || (returnedLength == 0)) {
printf(("AhciGetLogPageNVMe: failed. Error Code %d.\n"), GetLastError());
goto exit;
}
//
// Validate the returned data.
//
if ((protocolDataDescr->Version != sizeof(STORAGE_PROTOCOL_DATA_DESCRIPTOR)) ||
(protocolDataDescr->Size != sizeof(STORAGE_PROTOCOL_DATA_DESCRIPTOR))) {
printf(("AhciGetLogPageNVMe: - data descriptor header not valid.\n"));
goto exit;
}
protocolData = &protocolDataDescr->ProtocolSpecificData;
if ((protocolData->ProtocolDataOffset < sizeof(STORAGE_PROTOCOL_SPECIFIC_DATA)) ||
(protocolData->ProtocolDataLength < log_length)) {
//TraceInfo_DiskInfo(_T("AhciGetLogPageNVMe: ProtocolData Offset/Length not valid.\n"));
goto exit;
}
memcpy((void*)log_buffer, (PCHAR)protocolData + protocolData->ProtocolDataOffset, log_length);
exit:
PNVME_HEALTH_INFO_LOG smartInfo = (PNVME_HEALTH_INFO_LOG)((PCHAR)protocolData + protocolData->ProtocolDataOffset);
switch (str)
{
case 23:
tmp = (log_buffer[0]);
printf("com 0 cnt \t%x\n", log_buffer[0]);
printf("com 1 cnt \t%x\n", log_buffer[1]);
printf("com 2 cnt \t%x\n", log_buffer[2]);
printf("com 3 cnt \t%x\n", log_buffer[3]);
printf("com 4 cnt \t%x\n", log_buffer[4]);
printf("com 5 cnt \t%x\n", log_buffer[5]);
printf("com 6 cnt \t%x\n", log_buffer[6]);
break;
case 24:
tmp = (log_buffer[10]);
printf("com cnt \t%x\n", tmp);
printf("available \t%x\n", ((UCHAR)smartInfo->AvailableSpare));
printf("temp1 \t%x\n", ((UCHAR)smartInfo->Temperature[1]));
printf("temp2 \t%x\n", ((UCHAR)smartInfo->Temperature[2]));
break;
}
//printf(("Temperature %d.\n"), ((ULONG)smartInfo->Temperature[1] << 8 | smartInfo->Temperature[0]) - 273);
//printf(("AvailableSpareThreshold %X.\n"), ((UCHAR)smartInfo->AvailableSpareThreshold));
//printf(("AvailableSpare %X.\n"), ((UCHAR)smartInfo->AvailableSpare));
//printf(("PercentageUsed %X.\n"), ((UCHAR)smartInfo->PercentageUsed));
//printf(("WarningCompositeTemperatureTime %X.\n"), ((UCHAR)smartInfo->WarningCompositeTemperatureTime));
//printf(("CriticalCompositeTemperatureTime %X.\n"), ((UCHAR)smartInfo->CriticalCompositeTemperatureTime));
//printf("DataUnitRead\t%x\n", data_get(smartInfo->DataUnitRead, 16));
//printf("DataUnitWritten\t%x\n", data_get(smartInfo->DataUnitWritten, 16));
//printf("HostReadCommands\t%x\n", data_get(smartInfo->HostReadCommands, 16));
//printf("HostWrittenCommands\t%x\n", data_get(smartInfo->HostWrittenCommands, 16));
//printf("ControllerBusyTime\t%x\n", data_get(smartInfo->ControllerBusyTime, 16));
//printf("PowerCycle\t%x\n", data_get(smartInfo->PowerCycle, 16));
//printf("PowerOnHours\t%x\n", data_get(smartInfo->PowerOnHours, 16));
//printf("UnsafeShutdowns\t%x\n", data_get(smartInfo->UnsafeShutdowns, 16));
//printf("MediaErrors\t%x\n", data_get(smartInfo->MediaErrors, 16));
//printf("ErrorInfoLogEntryCount\t%x\n", data_get(smartInfo->ErrorInfoLogEntryCount, 16));
//cout << typeid(smartInfo->AvailableSpare).name() << endl;
printf(("type of output .\n"), tmp);
free(buffer);
return tmp;// very good , based on the help from jinlei ,success
}
This is an notification.
I've just renamed this branch (trunk) to "main."
No other changes are made before this renaming.
I think you can continue tracking this branch by renaming your local one.
Thank you.
VS2019 build this project can't find PDEVICE_INTERNAL_STATUS_DATA struct in #include <ntddstor.h>@NVMeGetTelemetry.c
refs #2
Is there any reason why this project considered as C++ one? I see #include <iostream>
or #include <string>
but they don't seem to be used.
Active Namespace ID list (CNS 02h) and Namespace Identification Descriptor list for the specified NSID (CNS 03h) do not work.
I found that Windows (stornvme.sys) issued Identify command with CNS = 00h (= query for Identify Namespace data) for NSID = 1 with the following code (in NVMeIdentifyActiveNSIDList.c)
query->PropertyId = StorageDeviceProtocolSpecificProperty;
query->QueryType = PropertyStandardQuery;
protocolData->ProtocolType = ProtocolTypeNvme;
protocolData->DataType = NVMeDataTypeIdentify;
protocolData->ProtocolDataRequestValue = NVME_IDENTIFY_CNS_ACTIVE_NAMESPACES;
protocolData->ProtocolDataRequestSubValue = 0; // to retrieve all IDs
I thought PSTORAGE_PROTOCOL_SPECIFIC_DATA::ProtocolDataRequestValue
corresponded to CNS value for Identify command, but it may be my misunderstanding.
Hi,
Am able to read from NVMe Ok, but, with mention params tried changing Offset to configure as reading from particular point (say 12) , but receiving data from beginning part only instead specified Offset, any thoughts about param to change or suggestions would be really appreciated.
..
protocolData->ProtocolDataRequestValue = NVME_LOG_PAGE_..;
protocolData->ProtocolDataRequestSubValue = 12; // lower 32-bit of the offset
protocolData->ProtocolDataRequestSubValue2 = 12; // higher 32-bit of the offset
..
Thanks,
Lokesh
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.