Fix: Realtek SD card reader not working with Ubuntu

I have a RTS5209 Realtek SD card reader on my laptop, which was not reading any card inserted. The following instructions are likely to work for other versions like RTS5229 or RTS5289 as well.

Turns out I needed to install the driver.

Realtek offers drivers on its website for Ubuntu/Linux. Download the driver and unpack into a temporary directory.

Open a terminal and cd into the directory you unpacked the file.

Then enter one after the other:

make

sudo make install

sudo depmod

You will have to reboot your computer for the driver to load, or you can enter this command:
sudo modprobe rts_pstor

This is for RTS5209. I believe for RTS5229 it is (hint:read folder name):
sudo modprobe rts5229

However, this only works on older kernels and on 3.9+ you get errors like:

vidyut@vidyut-Compaq-435-Notebook-PC:~/tmp/rts_pstor$ make
sed "s/RTSX_MK_TIME/`date +%y.%m.%d.%H.%M`/" timestamp.in > timestamp.h
cp -f ./define.release ./define.h
make -C /lib/modules/3.8.0-26-generic/build/ SUBDIRS=/home/vidyut/tmp/rts_pstor modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.0-26-generic'
CC [M] /home/vidyut/tmp/rts_pstor/rtsx.o
/home/vidyut/tmp/rts_pstor/rtsx.c:916:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rtsx_probe’
/home/vidyut/tmp/rts_pstor/rtsx.c:1080:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rtsx_remove’
/home/vidyut/tmp/rts_pstor/rtsx.c:1106:11: error: ‘rtsx_probe’ undeclared here (not in a function)
/home/vidyut/tmp/rts_pstor/rtsx.c:1107:2: error: implicit declaration of function ‘__devexit_p’ [-Werror=implicit-function-declaration]
/home/vidyut/tmp/rts_pstor/rtsx.c:1107:24: error: ‘rtsx_remove’ undeclared here (not in a function)
/home/vidyut/tmp/rts_pstor/rtsx.c:485:12: warning: ‘rtsx_control_thread’ defined but not used [-Wunused-function]
/home/vidyut/tmp/rts_pstor/rtsx.c:596:12: warning: ‘rtsx_polling_thread’ defined but not used [-Wunused-function]
/home/vidyut/tmp/rts_pstor/rtsx.c:745:13: warning: ‘quiesce_and_remove_host’ defined but not used [-Wunused-function]
/home/vidyut/tmp/rts_pstor/rtsx.c:780:13: warning: ‘release_everything’ defined but not used [-Wunused-function]
/home/vidyut/tmp/rts_pstor/rtsx.c:790:12: warning: ‘rtsx_scan_thread’ defined but not used [-Wunused-function]
/home/vidyut/tmp/rts_pstor/rtsx.c:816:13: warning: ‘rtsx_init_options’ defined but not used [-Wunused-function]
cc1: some warnings being treated as errors
make[2]: *** [/home/vidyut/tmp/rts_pstor/rtsx.o] Error 1
make[1]: *** [_module_/home/vidyut/tmp/rts_pstor] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-26-generic'
make: *** [default] Error 2
vidyut@vidyut-Compaq-435-Notebook-PC:~/tmp/rts_pstor$

The fix for this is to edit the file rtsx.c (that is throwing the errors) and remove “__devinit” “__devexit” and “__devexit_p” from it, leaving the rest of the code (and the rest of the line they occur in) in tact.

Like so:

static int __devinit rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)

Becomes:

static int rtsx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)

static void __devexit rtsx_remove(struct pci_dev *pci)

Becomes:
static void rtsx_remove(struct pci_dev *pci)

.remove = __devexit_p(rtsx_remove),

Becomes:
.remove = rtsx_remove,

Now, when you run make, the process should complete without errors.

If your SD card *still* doesn’t mount, check your dmesg like so:

sudo dmesg

If it shows something like:
[ 694.058432] systemd-hostnamed[2516]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!

Try installing the library.
apt-get install libnss-myhostname

If it still doesn’t work, I don’t know what to do. This SHOULD work.

Comments 11

  • Thank you ! And for 3.10 kernel (and more), there is another patch to apply.
    It is described here : http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-block/rts_pstor/files/?diff_format=s

    • You are awesome, Xubuntu 13.10 here, was having that problem and came here because with 13.04 I solved it with the original post, thank you so much.

  • Hello Hacks! Thank you very much for your post. I have this card reader and I had managed to install the drivers in ubuntu 12.04 but now I am having troubles….

    —— Code——
    I tried the solution you posted and I can not get further than step 2:

    vital@foreshadowing:~/rts_pstor$ sudo make

    [sudo] password for vital:

    sed “s/RTSX_MK_TIME/`date +%y.%m.%d.%H.%M`/” timestamp.in > timestamp.h
    cp -f ./define.release ./define.h
    make -C /lib/modules/3.8.0-31-generic/build/ SUBDIRS= modules
    make[1]: Entering directory `/usr/src/linux-headers-3.8.0-31-generic’
    make[2]: *** No rule to make target `/usr/src/linux-headers-3.8.0-31-generic/arch/x86/syscalls/syscall_32.tbl’, needed by `arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h’. Stop.
    make[1]: *** [archheaders] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-31-generic’
    make: *** [default] Error 2

    vital@foreshadowing:~/rts_pstor$ sudo make install

    cp rts_pstor.ko /lib/modules/3.8.0-31-generic/kernel/drivers/scsi -f
    cp: cannot stat ‘rts_pstor.ko’: No such file or directory
    make: *** [install] Error 1
    —————-

    I would be very grateful for any advice

  • Hi I’m getting problems with Linux Mint 16 after upgrading my kernel to 3.13.

    make seems to fail:

    # make
    sed "s/RTSX_MK_TIME/`date +%y.%m.%d.%H.%M`/" timestamp.in > timestamp.h
    cp -f ./define.release ./define.h
    make -C /lib/modules/3.13.2-031302-generic/build/ SUBDIRS=/home/user/Downloads/rts_pstor modules
    make[1]: Entering directory `/usr/src/linux-headers-3.13.2-031302-generic'
    CC [M] /home/user/Downloads/rts_pstor/rtsx.o
    /home/user/Downloads/rts_pstor/rtsx.c:275:2: error: unknown field ‘proc_info’ specified in initializer
    .proc_info = proc_info,
    ^
    /home/user/Downloads/rts_pstor/rtsx.c:275:2: warning: initialization from incompatible pointer type [enabled by default]
    /home/user/Downloads/rts_pstor/rtsx.c:275:2: warning: (near initialization for ‘rtsx_host_template.proc_dir’) [enabled by default]
    make[2]: *** [/home/user/Downloads/rts_pstor/rtsx.o] Error 1
    make[1]: *** [_module_/home/user/Downloads/rts_pstor] Error 2
    make[1]: Leaving directory `/usr/src/linux-headers-3.13.2-031302-generic'
    make: *** [default] Error 2

    Your advice would be greatly appreciated!!!

    • @evolver you need to comment out that line inn the rtsx.c file. It should look like this:
      struct scsi_host_template rtsx_host_template = {

      .name = CR_DRIVER_NAME,
      .proc_name = CR_DRIVER_NAME,
      // .proc_info = proc_info, <—comment out this line
      .info = host_info,

    • @evolver you need to comment out that line inn the rtsx.c file. It should look like this:
      struct scsi_host_template rtsx_host_template =
      {
      .name = CR_DRIVER_NAME,
      .proc_name = CR_DRIVER_NAME,
      // .proc_info = proc_info, <—comment out this line
      .info = host_info,

      ……rest of the file goes here

      • after commenting it out, I get this error. any idea how to solve this?

        cp -f ./define.release ./define.h
        make -C /lib/modules/4.2.0-42-generic/build/ SUBDIRS=/home/swethmandava/Downloads/rts5229 modules
        make[1]: Entering directory `/usr/src/linux-headers-4.2.0-42-generic’
        CC [M] /home/swethmandava/Downloads/rts5229/rtsx.o
        /home/swethmandava/Downloads/rts5229/rtsx.c: In function ‘rtsx_control_thread’:
        /home/swethmandava/Downloads/rts5229/rtsx.c:522:7: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘u64’ [-Wformat=]
        chip->srb->device->id, chip->srb->device->lun);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx.c:528:7: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘u64’ [-Wformat=]
        chip->srb->device->id, chip->srb->device->lun);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx.c: At top level:
        /home/swethmandava/Downloads/rts5229/rtsx.c:132:12: warning: ‘proc_info’ defined but not used [-Wunused-function]
        static int proc_info (struct Scsi_Host *host, char *buffer,
        ^
        CC [M] /home/swethmandava/Downloads/rts5229/rtsx_chip.o
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c: In function ‘rtsx_write_cfg_seq’:
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c:1131:2: error: implicit declaration of function ‘vmalloc’ [-Werror=implicit-function-declaration]
        data = (u32 *)vmalloc(dw_len * 4);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c:1131:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
        data = (u32 *)vmalloc(dw_len * 4);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c:1137:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
        mask = (u32 *)vmalloc(dw_len * 4);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c:1139:3: error: implicit declaration of function ‘vfree’ [-Werror=implicit-function-declaration]
        vfree(data);
        ^
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c: In function ‘rtsx_read_cfg_seq’:
        /home/swethmandava/Downloads/rts5229/rtsx_chip.c:1189:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
        data = (u32 *)vmalloc(dw_len * 4);
        ^
        cc1: some warnings being treated as errors
        make[2]: *** [/home/swethmandava/Downloads/rts5229/rtsx_chip.o] Error 1
        make[1]: *** [_module_/home/swethmandava/Downloads/rts5229] Error 2
        make[1]: Leaving directory `/usr/src/linux-headers-4.2.0-42-generic’
        make: *** [default] Error 2

  • Yes very old post but after searching and failing for hours I found this, There is a conflict with non-free linux-firmware, and has been removed from apt (found that on another site, said to try and install it idk)
    But with Mint 18 even doing this throws more errors and not found(s)
    Download, Extract, make, make install, reboot, done.
    or:

    Clone this repository into /usr/src/rts_pstor-1.11 and use dkms install to install the module with dkms.
    # switch into /usr/src
    cd /usr/src
    # clone this repository
    git clone https://github.com/chrisnew/rts_pstor.git rts_pstor-1.11
    # compile and install through dkms
    dkms install rts_pstor/1.11
    # load the module
    modprobe rts_pstor
    ———————————————————
    https://github.com/chrisnew/rts_pstor

    Works out of the box.

  • hello guys i had this problem and i found a link to github for a modified rts driver but it’s for rts5209

    Can you please help because i got an rst5229 and it doesn’t work for me
    If there is codes that i can change on files for my driver

Leave a Reply

Your email address will not be published. Required fields are marked *