Archive

Monthly Archives: January 2014


It’s been a long time since I had/did something worth writing for the blog; never got around to hacking more on the Cubieboards. However, this morning I got a chance to get working on a Cubieboard 2! So got an SD card and was all prepared to get an OS up and running on it. But as luck would have had it, the SD card refused to do anything. Tried checking the dmesg log, and got this:

mmc0: error -110 whilst initializing SD card 

Seemed more or less like a driver issue of some sort, so the first thing that I tried was running lspci and getting what the hardware actually is. This was my lspci output:

abhinav@AsusK55V:/~ lspci
00:00.0 Host bridge: Intel Corporation Ivy Bridge DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Ivy Bridge PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 2 (rev c4)
00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation Panther Point 6 port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation Panther Point SMBus Controller (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1058 (rev ff)
03:00.0 Network controller: Atheros Communications Inc. AR9485 Wireless Network Adapter (rev 01)
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5289 (rev 01)
04:00.2 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 0a)

The device 04:00.0 seems to be unrecognised by the OS, so my guess was it was the SD card reader, and on googling the part number, turns out it was! And also that these drivers were not on the mainline kernel. The issue is faced by a lot of other brands of laptops as well, HP, Dell what not! On checking the Realtek’s driver download page here. However, they do not have a driver for 5289, the very device that my Asus has (But I still did not lose it on Realtek, I mean they have amazing WiFi drivers/hardware support). So I decided to look around, and luckily found a mirror where they still have the driver for 5289.  In case you are going through the same issue, you can follow the steps here:

abhinav@AsusK55V:/~ wget https://bugs.launchpad.net/bugs/971876/+attachment/2991730/+files/rts_bpp.tar.bz2
abhinav@AsusK55V:/~ tar jxf rts_bpp.tar.bz2
abhinav@AsusK55V:/~ cd rts_bpp
abhinav@AsusK55V:/~ make
abhinav@AsusK55V:/~ su -c 'make install ; modprobe rts_bpp ; depmod -a' 

All hell broke loose after this, I start getting these compilation errors while running make:

/home/abhinav/tmp/rts_pstor/rtsx.c:916:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rtsx_probe’
/home/abhinav/tmp/rts_pstor/rtsx.c:1080:23: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rtsx_remove’
/home/abhinav/tmp/rts_pstor/rtsx.c:1106:11: error: ‘rtsx_probe’ undeclared here (not in a function)
/home/abhinav/tmp/rts_pstor/rtsx.c:1107:2: error: implicit declaration of function ‘__devexit_p’ [-Werror=implicit-function-declaration]
/home/abhinav/tmp/rts_pstor/rtsx.c:1107:24: error: ‘rtsx_remove’ undeclared here (not in a function)
/home/abhinav/tmp/rts_pstor/rtsx.c:485:12: warning: ‘rtsx_control_thread’ defined but not used [-Wunused-function]
/home/abhinav/tmp/rts_pstor/rtsx.c:596:12: warning: ‘rtsx_polling_thread’ defined but not used [-Wunused-function]
/home/abhinav/tmp/rts_pstor/rtsx.c:745:13: warning: ‘quiesce_and_remove_host’ defined but not used [-Wunused-function]
/home/abhinav/tmp/rts_pstor/rtsx.c:780:13: warning: ‘release_everything’ defined but not used [-Wunused-function]
/home/abhinav/tmp/rts_pstor/rtsx.c:790:12: warning: ‘rtsx_scan_thread’ defined but not used [-Wunused-function]
/home/abhinav/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/abhinav/tmp/rts_pstor/rtsx.o] Error 1
make[1]: *** [_module_/home/abhinav/tmp/rts_pstor] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-26-generic'
make: *** [default] Error 2

After a bit of googling I realized that this error exists for kernel versions above 3.6.x only. Below that, it works like a charm (After this point I had completely lost it on Realtek, I mean write proper drivers for crying out loud!). So the solution as it turns out is to edit the driver file “rtsx.c” and remove all instances of the string  “__devinit” “__devexit” and “__devexit_p” from it, leaving the rest of the code (and the rest of the line they occur in) intact. Meaning a line in the code which looked like :

 static void __devinit rtsx_remove(struct pci_dev *pci) 

Becomes:

 static void rtsx_remove(struct pci_dev *pci) *pci_id) 

After editing the file, I ran make again, the code compiled, and the kernel file was now ready. After this, I had to load the driver file onto the kernel using modprobe :

abhinav@AsusK55V:/~ sudo modprobe rts_bpp
abhinav@AsusK55V:/~ sudo depmod -a 

Now, in an ideal world, my SD card would be running fine and we’d have light sabers and death stars. However, my card reader still gave the same error, but apparently following the above method worked for most people. So I was pretty sure that the driver file wasn’t wrong. On running lspci again, it was clear what the problem was:

 abhinav@AsusK55V:/~ lspci -v -s 04:00.0
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd.
Device 5289 (rev 01)
Subsystem: ASUSTeK Computer Inc. Device 1457
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at f7800000 (32-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: rtsx_pci
Kernel modules: rts_bpp, rtsx_pci

So as you can see, although our newly compiled driver for the SD card, “rts_bpp” is available for the OS to use, it still continues to use the old buggy “rtsx_pci”. So the obvious steps would be ideally to unload this module and use our rts_bpp module. So I run:

abhinav@AsusK55V:/~ sudo modprobe -r rtsx_pci
 

Only to get this error:

FATAL: Module still in use
 

Turns out that there are certain other hidden modules which use the rtsx_pci module, so you had to unload them first and then unload this godforesaken module:

abhinav@AsusK55V:/~ lsmod|grep rtsx_pci
rtsx_pci            62705  2  rtsx_pci_sdmmc, rtsx_pci_ms
 

So as we see, the rtsx_pci module cannot be unloaded unless we unload the two modules that uses it, like this:

abhinav@AsusK55V:/~ sudo modprobe -r rtsx_pci_sdmmc
abhinav@AsusK55V:/~ sudo modprobe -r rtsx_pci_ms
abhinav@AsusK55V:/~ sudo modprobe -r rtsx_pci
abhinav@AsusK55V:/~ sudo modprobe -r rts_bpp
abhinav@AsusK55V:/~ sudo depmod -a
abhinav@AsusK55V:/~ sudo modprobe rts_bpp
abhinav@AsusK55V:/~ sudo depmod -a
 

So essentially, I unloaded all the kernel modules, including the one I compiled, ran a depmod, loaded just the rts_bpp and ran a depmod again. After a few seconds, my SD card finally mounted!

However rebooting the laptop reconfigured the settings again, and I was stuck with the rtsx_pci module again. So after running the steps above again, I blacklisted the rtsx_pci module:

abhinav@AsusK55V:/~ sudo nano /etc/modprobe.d/blacklist.conf 

by appending the file above with “blacklist rtsx_pci” in the end. After this you need to update the appropriate init files so that the setting sticks everytime you boot your system. You can do that by running:

abhinav@AsusK55V:/~ sudo updateinitramfs -u 

Its annoying how an error like this takes the whole day, when I could have just gone on Windows and done it. But there is something about fixing a problem that makes you feel happy. Now, I shall get back to getting arch on my SD card for the new Cubieboard 2! Hopefully I get to write some posts about GPIO interrupts, something that I have wanted to experiment with for so long now!

Advertisements