Jump to content
81 posts in this topic

Recommended Posts

I made a new driver for Realtek card readers, and I would like to invite people to join the beta testing.

Please use this thread for general discussion and test reports.

 

This driver is based on the Linux driver module `rtsx_pci/usb` which is contributed by engineers from Realtek and therefore is more mature than the FreeBSD/OpenBSD driver.

But I wrote this driver from scratch instead of blindly copying the code from Linux to macOS, so there is no compatibility layer (and performance degradation introduced by the compatibility layer) at all.

 

This driver supports SDSC/HC/XC cards and UHS-I SDR12/25/50/104 and DDR50 modes.

I tested my RTS525A with a SDXC card and got about 75MB/s read speed and 60MB/s write speed.

Note that your card may support even higher speed but your card reader may be limited by the OEM.

Always test your card under Windows or Linux to get an estimate on the threshold.

Use the `dd` command to get a precise estimate on the I/O speed under macOS.

 

As a bonus, your card reader will be recognized as a native one and is listed under Card Reader in System Information.

You need to install the companion Lilu plugin `RealtekCardReaderFriend` which is available at https://github.com/0xFireWolf/RealtekCardReaderFriend/.

 

As of v0.9.5, USB-based RTS5129, RTS5139 and RTS5179 are supported.

Please give a try and report any issues, as I don't have these chips thus cannot test them.

 

IOReg.thumb.png.2537f9566d8145a8454b618f3550d83f.png

 

SPCR.thumb.png.5794d1b5b222e74d6013c01b42f8867a.png

 

Feel free to report any issues. Detailed information can be found in the Github repo (https://github.com/0xFireWolf/RealtekCardReader).

 

Downloads:

https://github.com/0xFireWolf/RealtekCardReader/releases

 

Enjoy :)

 

-- FireWolf

  • Like 8
  • Thanks 3

Systematic instantaneous/immediate KP 1s after initiating boot when injecting or caching this kext (whether Debug or Release version) in Big Sur 11.4 (Clover r5133) on my Skylake Dell Latitude E7270 laptop fitted with PCie Realtek RTS525a:

RTS525a.jpg

 

IMG_4149.jpg

 

IMG_4150.jpg

 

No log produced... 😪

 

Had to revert to Cholonam's sinetek-rtsx kext.

1 hour ago, Hervé said:

Systematic instantaneous/immediate KP 1s after initiating boot when injecting or caching this kext (whether Debug or Release version) in Big Sur 11.4 (Clover r5133) on my Skylake Dell Latitude E7270 laptop fitted with PCie Realtek RTS525a:

 

No log produced... 😪

 

Had to revert to Cholonam's sinetek-rtsx kext.

 

I hate my plist editor. It changed the value type of IOProbeScore from interger to real.

That's why you saw the serialization error.

 

v0.9.1 should fix the issue and is working fine on my machine.

Please give a try. Thank you.

  • Like 1
  • Haha 1

Can confirm that the bug is fixed in v0.9.1.

 

Card Reader is indeed natively recognised and reported as such in SysInfo which is ace! :thumbsup_anim:

E7270-SysInfo_CardReader.jpg

 

However, I found that:

  1. not all cards are not readable; I've tried 3 x cards: 2 x older 2GB SanDisk microSD (SC?) and 1 x recent 16GB SanDisk microSD HC that are all RW-able with cholonam's sinetek-rtsx driver.
    1. the older 2GB SanDisk microSD (SC?) cards could not be mounted/read
    2. only the more recent 16GB SanDisk microSD HC card could be mounted RW. 
  2. system crashes abruptly and laptop resets after a few short minutes after unreadable cards are inserted or a few longer minutes after my readable SDHC card was inserted.

Regarding performance, it's complete night and day compared to what I previously achieved with cholonam's driver: ~15-16MB/s Write and ~70-75MB/s Read. That's sooooo much better!

SDHC_Performance.jpg

 

I've taken a couple of logs for your attention:

rtsx.log1.zip

rtsx.log2.zip

  • Like 1
  • Austere.J changed the title to FireWolf - Realtek PCIe Card Reader Driver for macOS
  • Allan pinned this topic

Tested here, but my RTL8411B PCI Express Card Reader (0x10EC5287) is on the Not Yet list 😕

 

I've followed the instruction to use the Debug version btw, if there's anything I can do to help, count with me.

 

I'm waiting 😁

 

 

18 hours ago, Hervé said:
  • not all cards are not readable; I've tried 3 x cards: 2 x older 2GB SanDisk microSD (SC?) and 1 x recent 16GB SanDisk microSD HC that are all RW-able with cholonam's sinetek-rtsx driver.
    1. the older 2GB SanDisk microSD (SC?) cards could not be mounted/read
    2. only the more recent 16GB SanDisk microSD HC card could be mounted RW. 
  • system crashes abruptly and laptop resets after a few short minutes after unreadable cards are inserted or a few longer minutes after my readable SDHC card was inserted.

 

Thanks for your report.

 

According to your kernel log, it seems that you tried the SDHC card before the other two SDSC cards.

Your SDHC card supports the UHS-I SDR104 mode, so the bus clock was switched to 208MHz.

That's why you got a read speed of about 75MB/s.

 

However, when you removed the SDHC card and inserted the SDSC one, the bus was still operating at 208MHz (another bug),

so the driver failed to initialize your SDSC card due to mismatched card clock.

 

Please try the 0.9.1 (v2) kext and see if your SDSC card can be recognized.

Specifically, please try the following steps:

1) Boot your computer with the new kext.

2) Insert the SDSC card and check whether the card is recognized and whether the system crashes.

<Dump the kernel log at this moment and rename it to "1.log".>

3) If the card can be recognized, try to read a file from the card and see if the file is corrupted or not.

<Dump the kernel log at this moment and rename it to "2.log".>

4) Remove the SDSC card and insert your SDHC card. Check whether your SDHC card can be recognized properly.

If somthing is wrong, dump the kernel log and rename it to "3.log".

 

To remove your card from the system, right click the icon on the Desktop and click "Eject".

I could only reproduce the kernel panic when I removed the card without clicking "Eject", but 0.9.1v2 should fix this issue.

 

RealtekPCIeCardReader_0.9.1_v2_DEBUG.zip

Just tested this new debug version:

  • No crashes this time.
  • SDHC card remains RW-able and with same performance as before.
  • SDSC cards remain unrecognised, no changes in that respect.

I attach the log as per your request.

1.log.zip

@Austere.J hello! Just interested if it's possible to add support for Realtek SD card readers with USB-based "system"? (ex. RTS5129)

I had the same USB card-reader which is placed in Xiaomi laptops (here). There is only one way to make it work right now > using VM method

But on Linux and Windows it's working properly. 

 

Edited by b0ltun
add RTS

USB hardware is handled totally differently (nothing to do with PCIe bus & technology) and by macOS's own USB drivers. 

2 hours ago, Hervé said:

SDSC cards remain unrecognised, no changes in that respect.

 

[  117.813682]: RTSX: bool IOSDCard::enable4BitWideBus() DInfo: The host device will use the 4-bit bus for data transfer.
[  117.813694]: RTSX: bool IOSDCard::initHighSpeedMode() DInfo: The 4-bit bus has been enabled.
[  117.813702]: RTSX: bool IOSDCard::initHighSpeedMode() DInfo: The card has been initialized with the high speed mode enabled.
[  117.813770]: RTSX: void IOSDHostDriver::recyclePendingBlockRequest() DInfo: Recycling a pending request...
[  117.813786]: RTSX: bool IOSDHostDriver::attachCard(UInt32) DInfo: The card has been created and initialized.
[  117.813793]: RTSX: void IOSDHostDriver::attachCard() DInfo: The card has been initialized at 400000 Hz.
[  117.813801]: RTSX: bool IOSDHostDriver::publishBlockStorageDevice() DInfo: Publishing the block storage device...
[  117.813831]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: =======================================
[  117.813840]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: Starting the SD block storage device...
[  117.813847]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: =======================================
[  117.813858]: RTSX: bool IOSDBlockStorageDevice::fetchCardCharacteristics() DInfo: Card Vendor = SanDisk; Name = SU02G; Revision = 8.0; Serial Number = 0x902EB808.
[  117.813872]: RTSX: bool IOSDBlockStorageDevice::fetchCardCharacteristics() DInfo: Card Block Size = 1024 Bytes; NumBlocks = 1931264; Capacity = 1977614336 Bytes.
[  117.813934]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: ====================================
[  117.813948]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: The SD block storage device started.
[  117.813960]: RTSX: virtual bool IOSDBlockStorageDevice::start(IOService *) DInfo: ====================================
[  117.813971]: RTSX: bool IOSDHostDriver::publishBlockStorageDevice() DInfo: The block storage device has been published.
[  117.813981]: RTSX: void IOSDHostDriver::attachCard() DInfo: The SD card has been attached.
[  117.813990]: RTSX: virtual bool IOSDCardEventSource::checkForWork() DInfo: The card event has been processed.

// The driver begins the eject the SDSC card.
[  117.814000]: RTSX: virtual bool IOSDCardEventSource::checkForWork() DInfo: The card event source is invoked by the processor work loop.
[  117.814011]: RTSX: virtual bool IOSDCardEventSource::checkForWork() DInfo: Processing the card event...
[  117.814021]: RTSX: void IOSDHostDriver::detachCard() DInfo: Detaching the SD card...
[  117.814029]: RTSX: void IOSDHostDriver::detachCard() DInfo: Stopping the block storage device...
[  117.814306]: RTSX: void IOSDHostDriver::detachCard() DInfo: The block storage device has been stopped.
[  117.814313]: RTSX: void IOSDHostDriver::detachCard() DInfo: Stopping the card device...
[  117.814327]: RTSX: void IOSDHostDriver::detachCard() DInfo: The card device has been stopped.

This time, your SDSC card was properly initialized (1.84GB) but then was ejected by the driver.

Your kernel log is incomplete, so I cannot find why the detach function is triggered.

Please make sure that your dmesg buffer is set to 10MB, i.e. msgbuf=10485760, and try the v3 kext with your SDSC card.

Thank you.

RealtekPCIeCardReader_0.9.1_v3_DEBUG.zip

2 hours ago, b0ltun said:

@Austere.J hello! Just interested if it's possible to add support for Realtek SD card readers with USB-based "system"? (ex. RTS5129)

I had the same USB card-reader which is placed in Xiaomi laptops (here). There is only one way to make it work right now > using VM method

But on Linux and Windows it's working properly.

 

Unfortunately, this driver targets at PCIe-based Realtek SD card readers only.

 

Adding support for USB-based ones (e.g., RTS5129, 5139, 5179, 5170) requires a USB driver and therefore is a different story.

22 hours ago, Allan said:

Tested here, but my RTL8411B PCI Express Card Reader (0x10EC5287) is on the Not Yet list 😕

 

I've followed the instruction to use the Debug version btw, if there's anything I can do to help, count with me.

 

I'm waiting 😁

 

RTS8411B is now supported as of v0.9.2. Give a try. :)

 

Link: https://github.com/0xFireWolf/RealtekPCIeCardReader/releases/tag/v0.9.2

  • Like 1

Renewed my tests with debug version 0.9.1 v3 and this time, my SDSC cards do mount. 👍

Cards mount and eject instantly, all looks pretty good as far as I'm concerned. Bravo! :thumbsup_anim:

 

Here's the log I took after playing with the 1st card.

rtsx.log.zip

 

Here are results of performance tests conducted with BlackMagic's tool on both cards:

SDSC_Performance_Test.jpg

 

SDSC#2_Performance_Test.jpg

 

And it's even slightly better with the SDHC card.

SDHC_Performance_Test.jpg

 

Please note that these results are a little hindered by the debug versions of the driver, the release versions offering better performance as shown below with my SDHC card. :P

SanDisk_16GB_SDHC_test.jpg

I've noticed that, on occasions, the driver kind of fails to initialise something if I boot with an SD card already inserted in the slot. No card can then be mounted, no matter what. So far, it's happened 3 x times so it's repeatable. Here are a couple of logs taken after I experienced this with version v0.9.2.

1_no_init.log.zip

2_no_init.log.zip

 

Hello @Austere.J I did test the new version, but it's not working. 🥲

The card reader isn't showing on System Information neither my cards are mounted.

 

I'm using the Debug version, with the boot-arg recommended.

 

Here's my log: rtsx.log

 

Thank you

3 hours ago, Allan said:

Hello @Austere.J I did test the new version, but it's not working. 🥲

The card reader isn't showing on System Preferences neither my cards are mounted.

 

I'm using the Debug version, with the boot-arg recommended.

 

Here's my log: rtsx.log

 

Thank you

 

[    1.714516]: RTSX: virtual IOReturn RealtekRTS5287Controller::initVendorSpecificParameters() DInfo: Initializing the vendor-specific parameters...
[    1.714523]: RTSX: virtual IOReturn RealtekRTS5287Controller::initVendorSpecificParameters() Error: Vendor settings are invalid.
[    1.714527]: RTSX: bool RealtekPCIeCardReaderController::setupCardReader() Error: Failed to initialize vendor-specific parameters.
[    1.714531]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) Error: Failed to set up the card reader.
[    1.714565]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: ===========================================
[    1.714570]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: Failed to start the card reader controller.
[    1.714574]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: ===========================================

 

It seems that your laptop vendor messes up the vendor-specific parameters.

I change the code to continue the initialization process with the default parameters.

Please give a try.

RealtekPCIeCardReader_0.9.3b1_DEBUG.zip

  • Like 1
7 minutes ago, Austere.J said:

 


[    1.714516]: RTSX: virtual IOReturn RealtekRTS5287Controller::initVendorSpecificParameters() DInfo: Initializing the vendor-specific parameters...
[    1.714523]: RTSX: virtual IOReturn RealtekRTS5287Controller::initVendorSpecificParameters() Error: Vendor settings are invalid.
[    1.714527]: RTSX: bool RealtekPCIeCardReaderController::setupCardReader() Error: Failed to initialize vendor-specific parameters.
[    1.714531]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) Error: Failed to set up the card reader.
[    1.714565]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: ===========================================
[    1.714570]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: Failed to start the card reader controller.
[    1.714574]: RTSX: virtual bool RealtekPCIeCardReaderController::start(IOService *) DInfo: ===========================================

 

It seems that your laptop vendor messes up the vendor-specific parameters.

I change the code to continue the initialization process with the default parameters.

Please give a try.

RealtekPCIeCardReader_0.9.3b1_DEBUG.zip 161.64 kB · 1 download

 

 

Now the card reader it's showing at the System Information:

Screen Shot 2021-06-22 at 18.44.09.png

 

 

But my cards isn't mounted. 😭

 

Another log: rtsx.log

43 minutes ago, Allan said:

 

 

Now the card reader it's showing at the System Information:

Screen Shot 2021-06-22 at 18.44.09.png

 

 

But my cards isn't mounted. 😭

 

Another log: rtsx.log

 

What's the model of your SD card? Brand, type (i.e. SDSC/HC/XC), and capacity?

 

Your card did not respond to the CMD8, which means that it is probably a v1.00/v1.01 SD card. (i.e. an old SDSC card.)

Your card was then timed out when the host driver issued an ACMD41 to request the card to switch to 1.8V.

In this case, I have not implemented any fallback mechanism yet.

 

Do you have other more recent SD cards to test the driver?

Hello! First off, thanks for making an SD card reader driver, as these aren't too common. Unfortunately, it's not working for my 8411B based reader yet. The logs indicate that it seems to start and it does show up in system information, but SD cards aren't mounted and don't show up in Finder or Disk utility. I tried using both 0.9.2 and the 0.9.3b1 that you uploaded here, and 3 different SDHC cards which I know work on other machines (and in Windows on this laptop).

Thanks in advance for any help you can offer.

Screen Shot 2021-06-22 at 6.40.06 PM.png

test.log

On 6/22/2021 at 2:47 PM, Allan said:

Now the card reader it's showing at the System Information:

But my cards isn't mounted. 😭

Another log: rtsx.log

 

On 6/22/2021 at 3:44 PM, b105 said:

Hello! First off, thanks for making an SD card reader driver, as these aren't too common. Unfortunately, it's not working for my 8411B based reader yet. The logs indicate that it seems to start and it does show up in system information, but SD cards aren't mounted and don't show up in Finder or Disk utility. I tried using both 0.9.2 and the 0.9.3b1 that you uploaded here, and 3 different SDHC cards which I know work on other machines (and in Windows on this laptop).

Thanks in advance for any help you can offer.

test.log 3.4 MB · 1 download

 

Both of you have the RTS8411B (0x10EC5287) card reader, and the card initialization routine failed because your card did not respond to ACMD41 and the timeout handler was triggered.

 

I updated the code to retry up to 10 times if the response to an ACMD is timed out. Please try v0.9.3b2 and see if it solves the problem.

 

RealtekPCIeCardReader_0.9.3v2_DEBUG.zip

  • Like 1

Sorry for my late reply 😬

 

On 6/22/2021 at 7:42 PM, Austere.J said:

What's the model of your SD card? Brand, type (i.e. SDSC/HC/XC), and capacity?

Using the app HWiNFO64, I got this result, it helps?

 

Spoiler

image.png

 

On 6/22/2021 at 7:42 PM, Austere.J said:

Do you have other more recent SD cards to test the driver?

Hmm, no. The current SD Cards that I have to test are these:

 

Spoiler

WhatsApp Image 2021-06-24 at 4.55.57 PM.jpeg

 

11 hours ago, Austere.J said:

I updated the code to retry up to 10 times if the response to an ACMD is timed out. Please try v0.9.3b2 and see if it solves the problem

I've test this version too, I got the same results.

 

But I need to extract the .log for you.

Hi, thank you for your work on this kext, however it's not working and when loaded I experience a KP.

No bootlog is generated

Device is RTS525a

HP Zbook G5

 

I also wonder if it would be possible to make it compatible with Mojave

 

Spoiler

Anonymous UUID:       C623883A-25DF-825B-5813-A9DB33A66A3E

Thu Jun 24 22:00:38 2021

*** Panic Report ***
panic(cpu 4 caller 0xffffff80102449ea): Kernel trap at 0xffffff80106890e0, type 14=page fault, registers:
CR0: 0x0000000080010033, CR2: 0xffffff7f9316d568, CR3: 0x0000000017eec000, CR4: 0x00000000003626e0
RAX: 0xffffff8010a676b8, RBX: 0xffffff7f91637838, RCX: 0x000000000000008b, RDX: 0xffffff7f9316d558
RSP: 0xffffff83aadebbb0, RBP: 0xffffff83aadebbd0, RSI: 0x000000000000008b, RDI: 0x0000000000000000
R8:  0x0000000100000201, R9:  0xffffff80174fb033, R10: 0x0000000000000003, R11: 0x0000000000000000
R12: 0xffffff804f067140, R13: 0xffffff7f915c3200, R14: 0xffffff7f91637838, R15: 0xffffff8010c1d230
RFL: 0x0000000000010282, RIP: 0xffffff80106890e0, CS:  0x0000000000000008, SS:  0x0000000000000000
Fault CR2: 0xffffff7f9316d568, Error code: 0x0000000000000000, Fault CPU: 0x4, PL: 0, VF: 1

Backtrace (CPU 4), Frame : Return Address
0xffffff83aadeb610 : 0xffffff801011868d
0xffffff83aadeb660 : 0xffffff8010252ab5
0xffffff83aadeb6a0 : 0xffffff801024463e
0xffffff83aadeb6f0 : 0xffffff80100bea40
0xffffff83aadeb710 : 0xffffff8010117d57
0xffffff83aadeb810 : 0xffffff8010118147
0xffffff83aadeb860 : 0xffffff80108bf2bc
0xffffff83aadeb8d0 : 0xffffff80102449ea
0xffffff83aadeba50 : 0xffffff80102446e8
0xffffff83aadebaa0 : 0xffffff80100bea40
0xffffff83aadebac0 : 0xffffff80106890e0
0xffffff83aadebbd0 : 0xffffff7f915cfb83
0xffffff83aadebbf0 : 0xffffff7f915d86b2
0xffffff83aadebc00 : 0xffffff80107b21a6
0xffffff83aadebc70 : 0xffffff80107b1c57
0xffffff83aadebce0 : 0xffffff801079e402
0xffffff83aadebd30 : 0xffffff801079b503
0xffffff83aadebda0 : 0xffffff80107a9a69
0xffffff83aadebdf0 : 0xffffff80108229de
0xffffff83aadebe40 : 0xffffff80108041b5
0xffffff83aadebef0 : 0xffffff8010803c9e
0xffffff83aadebf50 : 0xffffff8010806456
0xffffff83aadebfa0 : 0xffffff80100be13e
      Kernel Extensions in backtrace:
         com.apple.iokit.IOUSBFamily(900.4.2)[15879BD6-8025-376B-9085-F56C7C002FB1]@0xffffff7f915c3000->0xffffff7f9165bfff
            dependency: com.apple.iokit.IOPCIFamily(2.9)[2F37AE58-E6B9-3B18-9092-3B80D34C334B]@0xffffff7f90b31000
            dependency: com.apple.iokit.IOUSBHostFamily(1.2)[80AD6206-0EDB-39B5-A7B9-8FEAFD6407F3]@0xffffff7f91426000
            dependency: com.apple.driver.usb.AppleUSBCommon(1.0)[B5515CE4-E548-3AEE-9980-1967FB191C23]@0xffffff7f91414000

BSD process name corresponding to current thread: Unknown
Boot args: kext-dev-mode=1 -igfxblr msgbuf=10485760 -v

Mac OS version:
Not yet set

Kernel version:
Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64
Kernel UUID: 9B5A7191-5B84-3990-8710-D9BD9273A8E5
Kernel slide:     0x000000000fe00000
Kernel text base: 0xffffff8010000000
__HIB  text base: 0xffffff800ff00000
System model name: MacBookPro15,1 (Mac-937A206F2EE63C01)
System shutdown begun: NO
Panic diags file unavailable, panic occurred prior to initialization

System uptime in nanoseconds: 15696366490

 

When loaded directly:

Realtek.png.f0e37e9e2d168ef24ac0763c3409b04c.png

 

 

Edited by theroadw
more info
Posted (edited)

@theroadw

 

1) Add the boot argument `keepsyms=1` so that you can see which function triggers the kernel panic.

2) Remove the SD card while your system is booting.

3) Use your bootloader to inject the kernel extension.

4) Once your system boots, insert your card and check whether the same kernel panic occurs.

If so, please attach the full kernel panic report as well as your kernel log.

It is hard to see the log and debug the issue by watching the recording.

 

Note that I don't have macOS Mojave installed on my machine, so I have not checked the compatibility and tested the driver yet.

Edited by Austere.J

@theroadw Afaik, the current kext(s) can on load/run on Catalina and Big Sur (and presumably later). It certainly does not load under Mojave. Not surprisingly given the information available in the Info.plist file which is indicative of the way it was compiled:

    <key>LSMinimumSystemVersion</key>
    <string>10.15</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2021 FireWolf. All rights reserved.</string>
    <key>OSBundleLibraries</key>
    <dict>
        <key>com.apple.iokit.IOPCIFamily</key>
        <string>2.9</string>
        <key>com.apple.iokit.IOStorageFamily</key>
        <string>2.1</string>
        <key>com.apple.kpi.iokit</key>
        <string>16.4</string>
        <key>com.apple.kpi.libkern</key>
        <string>16.4</string>
    </dict>

You could try to edit this to match Mojave's versions but would most likely need to try and recompile the code under Mojave directly. Xcode 10.x required...

  • Slice changed the title to Realtek PCIe Card Reader Driver for macOS
×
×
  • Create New...