HDD GURU FORUMS
http://forum.hddguru.com/

MiniNVMe and MiniAHCI kernel modules for Linux
http://forum.hddguru.com/viewtopic.php?f=7&t=44694
Page 1 of 4

Author:  aekhv [ September 24th, 2024, 8:07 ]
Post subject:  MiniNVMe and MiniAHCI kernel modules for Linux

Hi. Last months I working on interesting project, actually it's a simple disk clone software under the Linux operating system. The main idea is replacing standard NVMe/AHCI drivers to my custom drivers: MiniNVMe and MiniAHCI. As result attached devices will be isolated from the operating system: no mount attempt, no SMART status reading etc. The only way to get access to device is my application. In simple terms - like PC-3000 works.

Whats is I have at this moment? MiniNVMe driver reads some PCI-E (NVMe) device info: PCI id's, link speed, NVMe subsystem version etc. Also PCI-E hot plug supported. Yes, it's not a joke. As you know maybe, PCI-E hot plug supported by the Linux kernel, but to get it work this feature must be also supported by chipset hardware. Not all of the modern PC motherboards support PCI-E hot plug. To control the device's power supply I use a simple CH340 USB relay.

How it looks now?

Attachment:
2024-09-24 21-06-39.png
2024-09-24 21-06-39.png [ 174.68 KiB | Viewed 64282 times ]

Attachment:
2024-09-24 17-48-45 11.JPG
2024-09-24 17-48-45 11.JPG [ 722.63 KiB | Viewed 64282 times ]

Attachment:
2024-09-24 17-49-48 11.JPG
2024-09-24 17-49-48 11.JPG [ 609.2 KiB | Viewed 64282 times ]

Attachment:
2024-09-24 17-53-00 11.JPG
2024-09-24 17-53-00 11.JPG [ 458.63 KiB | Viewed 64282 times ]


From time to time I plan to post some news about the project. Not too often I guess. So stay tuned and please share your thoughts below.

Author:  Arch Stanton [ September 26th, 2024, 5:57 ]
Post subject:  Re: Another useless data recovery toy?

Oh wow ..

Author:  lcoughey [ September 27th, 2024, 9:59 ]
Post subject:  Re: Another useless data recovery toy?

following.

Author:  aekhv [ October 2nd, 2024, 9:16 ]
Post subject:  Re: Another useless data recovery toy?

Now MiniNVMe driver is able to receive device identification data: model name, firmware revision, serial number, capacity etc. The next step is sectors reading and writing.

Attachment:
2024-10-02 23-08-13.png
2024-10-02 23-08-13.png [ 77.33 KiB | Viewed 63398 times ]

Author:  northwind [ October 4th, 2024, 3:20 ]
Post subject:  Re: Another useless data recovery toy?

Very impressive.
I'm following as well.

Author:  pclab [ October 9th, 2024, 3:37 ]
Post subject:  Re: Another useless data recovery toy?

Maybe not that useless :mrgreen:

Author:  aekhv [ October 17th, 2024, 8:48 ]
Post subject:  Re: Another useless data recovery toy?

Data transfer is working: read & write.
Attachment:
2024-10-17 22-26-30.png
2024-10-17 22-26-30.png [ 203.67 KiB | Viewed 62109 times ]

At this moment my driver does not support software reset sequence. If a patient device does not response (slow responding, firmware background activity, bad block occurred, etc.) the only way to reset it is power replug. I guess in case when mainboard supports PCI-E hot plug it's more than enough.

Author:  aekhv [ October 21st, 2024, 10:32 ]
Post subject:  Re: Another useless data recovery toy?

I got a couple of interesting digits: an average read speed from two different devices.
    1. Totally trimmed drive (no real data, returns zeroes only) - 2235.9 MB/ses
    2. Formatted drive, some files dropped - 364.0 MB/sec

Not bad I guess. Especially for self written NVMe device driver for Linux. What do you think?

Attachment:
2024-10-21 23-38-36.png
2024-10-21 23-38-36.png [ 21.16 KiB | Viewed 61260 times ]

Attachment:
2024-10-21 23-47-31.png
2024-10-21 23-47-31.png [ 22.77 KiB | Viewed 61260 times ]

Author:  aekhv [ October 24th, 2024, 8:17 ]
Post subject:  Re: Another useless data recovery toy?

NVMe error codes description in process...
Attachment:
2024-10-24 22-12-13.png
2024-10-24 22-12-13.png [ 119.64 KiB | Viewed 60900 times ]

Author:  Arch Stanton [ October 24th, 2024, 8:44 ]
Post subject:  Re: Another useless data recovery toy?

aekhv wrote:
NVMe error codes description in process...
Attachment:
2024-10-24 22-12-13.png


Those errors do ring a bell ;)

https://www.disktuna.com/decoding-statu ... mart-logs/

Author:  Setlec [ October 26th, 2024, 17:37 ]
Post subject:  Re: Another useless data recovery toy?

Wow this is truly becoming a very interesting tool. Following too.

Author:  aekhv [ November 21st, 2024, 6:51 ]
Post subject:  Re: Another useless data recovery toy?

Now health info looks like you know what... Ehe-he-he... 8)
Attachment:
2024-11-21 20-46-04.png
2024-11-21 20-46-04.png [ 218.6 KiB | Viewed 59907 times ]


Code:
    QNvmeBlockDevice nvme;

    if (!nvme.open("/dev/mininvme0")) {
        ui->plainTextEdit->appendPlainText("Device opening error!");
        return;
    }

    ui->plainTextEdit->appendPlainText("Device /dev/mininvme0 opened...\n");

    QNvmeControllerInfo info = nvme.controllerInfo();
    ui->plainTextEdit->appendPlainText("Model: " + info.modelName());
    ui->plainTextEdit->appendPlainText("Firmware: " + info.firmwareRevision());
    ui->plainTextEdit->appendPlainText("Serial number: " + info.serialNumber());
    ui->plainTextEdit->appendPlainText(QString("Capacity: %1 GB")
                                       .arg(info.totalCapacity() / (1000.0 * 1000.0 * 1000.0), 0, 'f', 1));

    QNvmeLogPageHealthInfo health = nvme.logPageHealthInfo();
    if (!nvme.lastError().success()) {
        ui->plainTextEdit->appendPlainText("Health reading errror!");
        return;
    }

    ui->plainTextEdit->appendPlainText("\n*** HEALTH INFO ***\n");
    ui->plainTextEdit->appendPlainText(QString("Composite temperature: %1 °C")
                                       .arg(health.compositeTemperature() - 273));
    ui->plainTextEdit->appendPlainText(QString("Available spare: %1 %")
                                       .arg(health.availableSpare()));
    ui->plainTextEdit->appendPlainText(QString("Available spare threshold: %1 %")
                                       .arg(health.availableSpareThreshold()));
    ui->plainTextEdit->appendPlainText(QString("Percentage used: %1 %")
                                       .arg(health.percentageUsed()));
    ui->plainTextEdit->appendPlainText(QString("Data units read: %1 (%2 GiB)")
                                       .arg(health.dataUnitsRead()).arg(health.dataUnitsRead() * 512 / (1024 * 1024)));
    ui->plainTextEdit->appendPlainText(QString("Data units written: %1 (%2 GiB)")
                                       .arg(health.dataUnitsWritten()).arg(health.dataUnitsWritten() * 512 / (1024 * 1024)));
    ui->plainTextEdit->appendPlainText(QString("Host read commands: %1")
                                       .arg(health.hostReadCommands()));
    ui->plainTextEdit->appendPlainText(QString("Host write commands: %1")
                                       .arg(health.hostWriteCommands()));
    ui->plainTextEdit->appendPlainText(QString("Controller busy time: %1 m")
                                       .arg(health.controllerBusyTime()));
    ui->plainTextEdit->appendPlainText(QString("Power cycles: %1")
                                       .arg(health.powerCycles()));
    ui->plainTextEdit->appendPlainText(QString("Power on hours: %1")
                                       .arg(health.powerOnHours()));
    ui->plainTextEdit->appendPlainText(QString("Unsafe shutdowns: %1")
                                       .arg(health.unsafeShutdowns()));
    ui->plainTextEdit->appendPlainText(QString("Media and data integrity errors: %1")
                                       .arg(health.mediaAndDataIntegrityErrors()));
    ui->plainTextEdit->appendPlainText(QString("Number of error information log entries: %1")
                                       .arg(health.numberOfErrorInformationLogEntries()));
    ui->plainTextEdit->appendPlainText(QString("Warning composite temperature time: %1 m")
                                       .arg(health.warningCompositeTemperatureTime()));
    ui->plainTextEdit->appendPlainText(QString("Critical composite temperature time: %1 m")
                                       .arg(health.criticalCompositeTemperatureTime()));
    int n = 0;
    foreach (int t, health.temperatureSensors()) {
        n++;
        if (t != 0)
            ui->plainTextEdit->appendPlainText(QString("Temperature sensor #%1: %2 °C").arg(n).arg(t - 273));
        else
            ui->plainTextEdit->appendPlainText(QString("Temperature sensor #%1: no sensor").arg(n));
    }
    ui->plainTextEdit->appendPlainText(QString("Thermal management temperature 1 transition count: %1")
                                       .arg(health.TMT1TransitionCount()));
    ui->plainTextEdit->appendPlainText(QString("Thermal management temperature 2 transition count: %1")
                                       .arg(health.TMT2TransitionCount()));
    ui->plainTextEdit->appendPlainText(QString("Total time for thermal management temperature 1: %1 s")
                                       .arg(health.totalTimeForTMT1()));
    ui->plainTextEdit->appendPlainText(QString("Total time for thermal management temperature 2: %1 s")
                                       .arg(health.totalTimeForTMT2()));

Author:  Lardman [ November 21st, 2024, 7:13 ]
Post subject:  Re: Another useless data recovery toy?

Looking good so far.

Would love to see the drive itself on a fly lead outside the case though and positioned so we can get at both sides whilst it's running.

Author:  fzabkar [ November 21st, 2024, 15:06 ]
Post subject:  Re: Another useless data recovery toy?

Where is the health.criticalWarning attribute?

This is wrong:

Code:
    ui->plainTextEdit->appendPlainText(QString("Data units read: %1 (%2 GiB)")
                                       .arg(health.dataUnitsRead()).arg(health.dataUnitsRead() * 512 / (1024 * 1024)));
    ui->plainTextEdit->appendPlainText(QString("Data units written: %1 (%2 GiB)")
                                       .arg(health.dataUnitsWritten()).arg(health.dataUnitsWritten() * 512 / (1024 * 1024)));

It should be ...

Code:
    ui->plainTextEdit->appendPlainText(QString("Data units read: %1 (%2 GiB)")
                                       .arg(health.dataUnitsRead()).arg(health.dataUnitsRead() * 512 * 1000 / (1024 * 1024 * 1024)));
    ui->plainTextEdit->appendPlainText(QString("Data units written: %1 (%2 GiB)")
                                       .arg(health.dataUnitsWritten()).arg(health.dataUnitsWritten() * 512 * 1000 / (1024 * 1024 * 1024)));

Quote:
Data Units Read: Contains the number of 512 byte data units the host has read from the controller; this value does not include metadata. This value is reported in thousands (i.e., a value of 1 corresponds to 1,000 units of 512 bytes read) and is rounded up (e.g., one indicates the that number of 512 byte data units read is from 1 to 1,000, three indicates that the number of 512 byte data units read is from 2,001 to 3,000). When the LBA size is a value other than 512 bytes, the controller shall convert the amount of data read to 512 byte units.

Author:  fzabkar [ November 21st, 2024, 16:23 ]
Post subject:  Re: Another useless data recovery toy?

Lardman wrote:
Would love to see the drive itself on a fly lead outside the case though and positioned so we can get at both sides whilst it's running.

Something like this?

https://forum.hddguru.com/viewtopic.php?p=264481#p264481

Author:  aekhv [ November 21st, 2024, 23:27 ]
Post subject:  Re: Another useless data recovery toy?

fzabkar wrote:
Where is the health.criticalWarning attribute?

Oops, forgot to add...

fzabkar wrote:
This is wrong

Yes, I know. I was just curious why the PC-3000 also shows these attributes incorrectly. Obviously this is a mistake.

Author:  fzabkar [ November 22nd, 2024, 1:18 ]
Post subject:  Re: Another useless data recovery toy?

aekhv wrote:
fzabkar wrote:
This is wrong

Yes, I know. I was just curious why the PC-3000 also shows these attributes incorrectly. Obviously this is a mistake.

PC3000 is correct. You are wrong.

https://www.google.com/search?q=0x0a333b+x+512+x+1000+bytes+in+GiB

    0x0a333b x 512 x 1000 bytes = 318.753719 gibibytes

https://www.google.com/search?q=0x09510f+x+512+x+1000+bytes+in+GiB

    0x09510f x 512 x 1000 bytes = 291.144848 gibibytes

Author:  aekhv [ November 22nd, 2024, 4:29 ]
Post subject:  Re: Another useless data recovery toy?

fzabkar wrote:
PC3000 is correct. You are wrong.

Yeah, it's true. Thanks a lot!

Author:  Lardman [ November 22nd, 2024, 5:40 ]
Post subject:  Re: Another useless data recovery toy?

fzabkar wrote:
More like this https://www.aliexpress.com/item/1005006584734868.html but with the rest of the m2 mounting pcb snapped right back or the the m2 mounted vertically.

We need something that has the drive pcb clear so we can get to both sides and that we can put on an external heater or cooler.

Author:  fzabkar [ November 22nd, 2024, 14:43 ]
Post subject:  Re: Another useless data recovery toy?

Lardman wrote:
fzabkar wrote:
More like this https://www.aliexpress.com/item/1005006584734868.html but with the rest of the m2 mounting pcb snapped right back or the the m2 mounted vertically.

We need something that has the drive pcb clear so we can get to both sides and that we can put on an external heater or cooler.

I'd be wondering about the impedance of the ribbon cable. Mismatches in the impedance would degrade the signal.

Page 1 of 4 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/