Giter Site home page Giter Site logo

nvmetool-win's People

Contributors

ken-yossy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvmetool-win's Issues

Is is possible to complete "Security Receive" Admin Command?

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.

Wrong value in ProtocolDataRequestSubValue for NVMeDataTypeLogPage

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.

Get Log Page option for raw-binary DATA

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?

write, read fail

Hello!

I tried to read(-r), write(-w) to my nvme device using the tool you produced, but it failed. Scsi status comes out as 02h.
But 'get log page' works very well.
Here is snapshot.

  • read
    image
  • write
    image
  • get log page (02h)
    image

Can you tell me what the problem is?

Error while running NVMeTool.exe

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

Here is my attachment photo:
image

Looking forward to your reply, that will be much of help!

Regard,
freeqimmy

Windows does not recognize PhysicalDrive%hs, how to send IOCTL commands to SSD?

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

Example command to run identify controller to get SUBNQN field

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?

Error while running NVMeTool.exe

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.?

ProtocolDataRequestSubValue4 support

Hi Ken,

MS claims to support setting LSP, RAE bits via ProtocolDataRequestSubValue4. I guess you can reflect this in your tool to read telemetry.

How to use IOCTL_STORAGE_FIRMWARE_DOWNLOAD?

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

Issuing Format NVM Fail

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

Here is the attachment picture.
image

Does Window10 not support NVMe1.4b?

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?

no firmware download/commit

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.

Mobile NVME

Why can't I read and recognize the mobile nvme hard disk?

get log page for vu report error 1117

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 

}

Renamed "master" to "main"

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.

Compiler error

VS2019 build this project can't find PDEVICE_INTERNAL_STATUS_DATA struct in #include <ntddstor.h>@NVMeGetTelemetry.c

Get Level 0 Discovery data with "Security Receive" command

(refs #2)

Code for getting Level 0 Discovery data has been merged, based on the report that getting it with the code had successfully done with the same code in #2.

But I have not succeeded in getting it yet.
I'm going to track trial-and-errors for this issue.

C++ support

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.

Some CNS values are not sent to drive

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.

For reading NVMe - how to change Offset from default (0) to required ?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.