Enable Realtek USB 2.0 Card Reader On Ubuntu

closeThis post was published 7 years 5 months 8 days ago which may make many or all of its content outdated. Please follow at your own risk.

ubuntu logo In my first and last attempt months ago, I used the keucr module which is a pretty common SD card reader driver to make my laptop’s built-in reader to work. It failed miserably. I half-heartedly searched a few more times on Google but didn’t find a solution. That time I really had no use of the card reader. Eventually I forgot about this, and as I rarely (or never) use the reader, I never bothered to fix it until now. I still rarely use the card reader but I want everything to work on my Ubuntu Natty.

The main reason I failed in my previous attempt is because I did not bother to identify the device on my machine. The thing is, you have to know the name/version of the specific devices you’re trying to make to work.

The device is RTS5139

My laptop manufacturer (MSI) IDs the device as rts5139, and from their website one can download an updated driver. Unfortunately, there is no driver available for Linux. It is only for Windows. At least I now know the specific device version.

Searching on Google again, I found this interesting thread on the Ubuntu forums – http://ubuntuforums.org/archive/index.php/t-1797202.html.

Running `lsusb` I compared the results with my machine against the thread above

Bus 002 Device 005: ID 0bda:0139 Realtek Semiconductor Corp.

BINGO! It is a match and at this point I was pretty sure I was on to something. As luck would have it, one user claimed that he got the source from Realtek by email (Please read the thread above.), and my heart was already pumping hard from all the excitement. Saved me from having to look for it on Realtek’s website. It looks like I may have found the answer after all. And I did.

The source can be downloaded from http://ubuntuone.com/p/153B/ or you may download it directly here. If you want to make it work right away, just extract the package and follow the steps in README.txt. It is that simple.

Note: I am assuming you already have all the compile tools and kernel headers necessary to build from source.

However, that method is kind of lacking. Once you install  (update) another kernel the module will no longer work because it is compiled against a specific kernel. You can re-compile it, or, the solution here is to build the module using DKMS (Dynamic Kernel Support).

Steps to Build With DKMS

1) Download the source package above

2) Extract and copy to /usr/src (This is arbitrary. You can save it anywhere, including in your HOME directory. However, /usr/src is a very likely candidate where you don’t accidentally delete the source code. It is needed in future builds against a new kernel version.)

3) Rename the directory to rts5139-0.0.1 (The 0.0.1 is arbitrary. This is for personal versioning purposes. You will understand why this is important because if you use PACKAGE_VERSION, like below, DKMS will look for a directory with the PACKAGE_NAME +  VERSION to find the source.)

4) Using your favorite text editor, create the dkms.conf file. Copy the contents below, and save it to /usr/src/rts5139-0.0.1

PACKAGE_NAME=”rts5139″
PACKAGE_VERSION=”0.0.1″
CLEAN=”make clean”
BUILT_MODULE_NAME[0]=”rts5139″
DEST_MODULE_NAME[0]=”rts5139″
MAKE[0]=”make KERNELDIR=/lib/modules/${kernelver}/build PWD=$dkms_tree/rts5139/0.0.1/build”
DEST_MODULE_LOCATION[0]=”/kernel/drivers/scsi”
AUTOINSTALL=”yes”

5) Time to build the module. Follow the commands below one at a time:

sudo dkms add -m rts5139 -v 0.0.1
sudo dkms build -m rts5139 -v 0.0.1
sudo dkms install -m rts5139 -v 0.0.1

(OOPS! Almost forgot. Load the module with modprobe. You may need to reboot after.)

sudo modprobe rts5139

Issue the command modinfo rts5139 to see information about the module.

Everything should have worked up to this point, as it did with mine. However, yours could be a different case. Cross your fingers that the build is successful. :P

Try out if your DKMS build is working by installing a kernel. Click on details to see what is happening during the install. See image below.

If you’re the type who updates frequently then chances are you may have updated to the latest kernel version. Don’t worry, you can still use the older kernel versions for testing. These should be readily available from the Ubuntu repositories. I suggest you install the kernel through a terminal so you will see the installation process and if it re-builds the module for that particular version. However the surest way to find out if it is working is to reboot and use that newly installed kernel.

Building with DKMS is one of the best ways to compile from source. This way you are guaranteed that your device will work properly on future kernel updates.

I suggest you read about DKMS at https://help.ubuntu.com/community/DKMS and the manual (man DKMS).

Disclaimer: Source package is not signed. Use at your own risk!

Related Posts:

  • No Related Posts

11 thoughts on “Enable Realtek USB 2.0 Card Reader On Ubuntu

  1. Hello,

    I tried to follow your tutorial to make the internal mic and usb’s work on a Lenovo s205. But when I do sudo dkms add -m rts5139 -v 0.0.1, it gives me this:

    /usr/src/rts5139-0.0.1/dkms.conf: line 3: $’clean\342\200\235′: command not found
    dkms.conf: Error! Directive ‘DEST_MODULE_LOCATION’ does not begin with
    ‘/kernel’, ‘/updates’, or ‘/extra’ in record #0.
    Error! Bad conf file.
    File: /usr/src/rts5139-0.0.1/dkms.conf
    does not represent a valid dkms.conf file.

    Could you please advise me on what to do now? Thank you very much.

    • By the way Irina, this RTS5139 driver is only for the the card reader/writer which is built-in to the laptop but attached via USB bus. I just noticed you mentioned you’re installing it for your internal mic and USB ports to function? That might not work.

      • I have downloaded both the derivrs but when I am running the first step in the terminal this is the result I’m getting..not able to understand why this is happening..could you help?Reading package lists DoneBuilding dependency treeReading state information DoneE: Unable to locate package linux-image-2.6.38-8-genericE: Couldn’t find any package by regex linux-image-2.6.38-8-generic’E: Unable to locate package linux-headers-2.6.38-8E: Couldn’t find any package by regex linux-headers-2.6.38-8

        • It looks like you’re missing a few Linux kernel packages needed for compilation. Are you sure you have it installed on your Ubuntu?

    • Irina,
      I just had the same problem fixed right now.I was banging my head for days,before I realized that there should be no space after ‘=’.
      This does not work:
      DEST_MODULE_LOCATION[0]= “/kernel/drivers/”
      This WORKS:
      DEST_MODULE_LOCATION[0]=”/kernel/drivers/”
      Linux should be way ahead and not bother with spaces anymore,my opinion.

  2. Alright, then that’s why it didn’t work. I actually came to this page from a link on the usb/mic problem topic. Thanks anyway :)

  3. @Irina : in your dkms.conf file, change the all the doble quotes : ” with simple quote : ‘ and it will work. It’s because when you copy/paste from this blog, the quotes are not the standard one, and thus; not recognize by the dkms parser..

    Btw, works for me on the LENOVO s205.
    Thx,

  4. One thing to note is that this card reader/writer module on Kernel 3.x and upwards should no longer be needed from what I have read. It should be compiled-in by default. But do check against this piece of info as I may have gotten it wrong.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>