# 8192cu in Gentoo [solved]

## alienjon

My old rt73 usb adapter was dying on me and I decided that it was time to upgrade.  I purchased an Edimax EW7811 card due to several ratings I had seen that it works well in Linux with the rtl8188cu/rtl8198cu driver (That having been said, I would strongly recommend against this device - it's so small that the electronics of the computer mess with the signal and loses strength quickly).  There was also an issue where after about 2 minutes of non-use the card would stop working.  All signs indicated that I was still connected to my router, but it acted as though I wasn't connected at all.

I then purchased an Asus N-13.  Another well rated for linux adapter that apparently also uses the same driver as the Edimax I had also picked up.  This one seemed to work much better, except that it loses connection with my router much faster, after about 30 seconds of idle time.  Now I'm thinking that it may be related to the driver itself so I do some research.  Essentially, I discovered that the kernel driver is essentially trash.  There seems to be something in the power saving code that prevents certain devices with this driver from powering back up when they go idle.  I also discovered that I only needed to hit 'connect' again in the wpa_gui dialog to force a refresh, thus forcing the device out of idle again.

Further research and I discovered that Realtek themselves distributed an open source version of the driver that seemed to work well for people who discussed it in Ubuntu forums (particularly, though others were noted too).  Additionally, forks of this driver were written in the open source community in order to support newer kernels and, in one case that particularly interested me, new options for the driver that will allow disabling of the driver's power saving option (exactly what would fix the problem for me).

I tried all 3 of these latter options.  The Realtek driver won't even build for me (it comes up with a lot of errors that at a quick glance make me think that it needs an older kernel version, especially as the github drivers note specifically being written to support newer kernels).  For both the second and third options, however, the driver builds and seems to load without error:

```
[17246.810483] rtl8192cu driver version=v4.0.2_9000.20130911

[17246.810485] build time: Nov  7 2014 22:57:39

[17246.810508] 

usb_endpoint_descriptor(0):

[17246.810509] bLength=7

[17246.810510] bDescriptorType=5

[17246.810511] bEndpointAddress=81

[17246.810511] wMaxPacketSize=200

[17246.810512] bInterval=0

[17246.810513] RT_usb_endpoint_is_bulk_in = 1

[17246.810513] 

usb_endpoint_descriptor(1):

[17246.810514] bLength=7

[17246.810515] bDescriptorType=5

[17246.810515] bEndpointAddress=2

[17246.810516] wMaxPacketSize=200

[17246.810516] bInterval=0

[17246.810517] RT_usb_endpoint_is_bulk_out = 2

[17246.810518] 

usb_endpoint_descriptor(2):

[17246.810518] bLength=7

[17246.810519] bDescriptorType=5

[17246.810520] bEndpointAddress=3

[17246.810520] wMaxPacketSize=200

[17246.810521] bInterval=0

[17246.810521] RT_usb_endpoint_is_bulk_out = 3

[17246.810522] 

usb_endpoint_descriptor(3):

[17246.810523] bLength=7

[17246.810523] bDescriptorType=5

[17246.810524] bEndpointAddress=84

[17246.810524] wMaxPacketSize=40

[17246.810525] bInterval=1

[17246.810526] RT_usb_endpoint_is_int_in = 4, Interval = 1

[17246.810526] nr_endpoint=4, in_num=2, out_num=2

[17246.810527] USB_SPEED_HIGH

[17246.810535] CHIP TYPE: RTL8188C_8192C

[17246.810539] register rtw_netdev_ops to netdev_ops

[17246.810727] Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C.

[17246.810728] RF_Type is 2!!

[17246.811102] EEPROM type is E-FUSE

[17246.811103] ====> ReadAdapterInfo8192C

[17246.811226] Boot from EFUSE, Autoload OK !

[17246.962711] EEPROMVID = 0x0b05

[17246.962714] EEPROMPID = 0x17ab

[17246.962714] EEPROMCustomerID : 0x00

[17246.962715] EEPROMSubCustomerID: 0x00

[17246.962716] RT_CustomerID: 0x00

[17246.962717] _ReadMACAddress MAC Address from EFUSE = 10:c3:7b:cd:b5:5e

[17246.962718] EEPROMRegulatory = 0x3

[17246.962719] _ReadBoardType(0)

[17246.962720] BT Coexistance = disable

[17246.962721] mlmepriv.ChannelPlan = 0x00

[17246.962722] _ReadPSSetting...bHWPwrPindetect(0)-bHWPowerdown(0) ,bSupportRemoteWakeup(0)

[17246.962722] ### PS params=>  power_mgnt(1),usbss_enable(0) ###

[17246.962723] ### AntDivCfg(0)

[17246.962724] readAdapterInfo_8192CU(): REPLACEMENT = 1

[17246.962725] <==== ReadAdapterInfo8192C in 152 ms

[17246.962831] rtw_macaddr_cfg MAC Address  = 10:c3:7b:cd:b5:5e

[17246.962832] bDriverStopped:1, bSurpriseRemoved:0, bup:0, hw_init_completed:0

[17246.962990] _rtw_drv_register_netdev, MAC Address (if1) = 10:c3:7b:cd:b5:5e

[17246.963011] usbcore: registered new interface driver rtl8192cu

[17246.971332] systemd-udevd[27003]: renamed network interface wlan0 to wifi0

[17283.454345] +rtw_drv_halt

[17283.454348] usbcore: deregistering interface driver rtl8192cu

[17283.454357] +rtw_dev_remove

[17283.459820] rtw_pm_set_ips IPS_NONE

[17283.459824] rtw_pm_set_ips: bDriverStopped=1, bup=0, hw_init_completed=0

[17283.459826] rtw_sta_flush(wifi0)

[17283.459831] <=== rtw_dev_unload

[17283.459832] rtw_usb_if1_deinit, hw_init_completed=0

[17283.459889] free_recv_skb_queue not empty, 8

[17283.459894] =====> rtl8192c_free_hal_data =====

[17283.459895] <===== rtl8192c_free_hal_data =====

[17283.459900] -r871xu_dev_remove, done

[17283.459920] -rtw_drv_halt

[17289.673323] rtl8192cu driver version=v4.0.2_9000.20130911

[17289.673325] build time: Nov  7 2014 22:57:39

[17289.673351] 

usb_endpoint_descriptor(0):

[17289.673352] bLength=7

[17289.673353] bDescriptorType=5

[17289.673353] bEndpointAddress=81

[17289.673354] wMaxPacketSize=200

[17289.673354] bInterval=0

[17289.673355] RT_usb_endpoint_is_bulk_in = 1

[17289.673356] 

usb_endpoint_descriptor(1):

[17289.673357] bLength=7

[17289.673357] bDescriptorType=5

[17289.673358] bEndpointAddress=2

[17289.673358] wMaxPacketSize=200

[17289.673359] bInterval=0

[17289.673360] RT_usb_endpoint_is_bulk_out = 2

[17289.673360] 

usb_endpoint_descriptor(2):

[17289.673361] bLength=7

[17289.673362] bDescriptorType=5

[17289.673362] bEndpointAddress=3

[17289.673363] wMaxPacketSize=200

[17289.673363] bInterval=0

[17289.673364] RT_usb_endpoint_is_bulk_out = 3

[17289.673364] 

usb_endpoint_descriptor(3):

[17289.673365] bLength=7

[17289.673366] bDescriptorType=5

[17289.673366] bEndpointAddress=84

[17289.673367] wMaxPacketSize=40

[17289.673368] bInterval=1

[17289.673368] RT_usb_endpoint_is_int_in = 4, Interval = 1

[17289.673369] nr_endpoint=4, in_num=2, out_num=2

[17289.673370] USB_SPEED_HIGH

[17289.673377] CHIP TYPE: RTL8188C_8192C

[17289.673380] register rtw_netdev_ops to netdev_ops

[17289.673594] Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C.

[17289.673595] RF_Type is 2!!

[17289.673968] EEPROM type is E-FUSE

[17289.673969] ====> ReadAdapterInfo8192C

[17289.674094] Boot from EFUSE, Autoload OK !

[17289.837942] EEPROMVID = 0x0b05

[17289.837945] EEPROMPID = 0x17ab

[17289.837945] EEPROMCustomerID : 0x00

[17289.837946] EEPROMSubCustomerID: 0x00

[17289.837947] RT_CustomerID: 0x00

[17289.837948] _ReadMACAddress MAC Address from EFUSE = 10:c3:7b:cd:b5:5e

[17289.837950] EEPROMRegulatory = 0x3

[17289.837950] _ReadBoardType(0)

[17289.837951] BT Coexistance = disable

[17289.837952] mlmepriv.ChannelPlan = 0x00

[17289.837953] _ReadPSSetting...bHWPwrPindetect(0)-bHWPowerdown(0) ,bSupportRemoteWakeup(0)

[17289.837954] ### PS params=>  power_mgnt(1),usbss_enable(0) ###

[17289.837954] ### AntDivCfg(0)

[17289.837955] readAdapterInfo_8192CU(): REPLACEMENT = 1

[17289.837956] <==== ReadAdapterInfo8192C in 164 ms

[17289.838064] rtw_macaddr_cfg MAC Address  = 10:c3:7b:cd:b5:5e

[17289.838066] bDriverStopped:1, bSurpriseRemoved:0, bup:0, hw_init_completed:0

[17289.838229] _rtw_drv_register_netdev, MAC Address (if1) = 10:c3:7b:cd:b5:5e

[17289.838252] usbcore: registered new interface driver rtl8192cu

[17289.851901] systemd-udevd[27038]: renamed network interface wlan0 to wifi0
```

However, when I try to start my network device, I get:

```
 * Caching service dependencies ...                                                                                                     [ ok ]

 * Bringing up interface wifi0

 *   Starting wpa_supplicant on wifi0 ...

 *   start-stop-daemon: failed to start `/usr/sbin/wpa_supplicant'                                                                      [ !! ]

 * ERROR: net.wifi0 failed to start

```

Here's the wpa_supplicant output:

```
wpa_supplicant v2.2

random: Trying to read entropy from /dev/random

Successfully initialized wpa_supplicant

Initializing interface 'wifi0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A'

Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'

Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'

ctrl_interface='DIR=/var/run/wpa_supplicant GROUP=wheel'

update_config=1

Priority group 0

   id=0 ssid='LJRWireless'

rfkill: initial event: idx=1 type=2 op=0 soft=0 hard=0

nl80211: Driver does not support authentication/association or connect commands

nl80211: Remove monitor interface: refcount=0

netlink: Operstate: ifindex=16 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)

nl80211: Set mode ifindex 16 iftype 2 (STATION)

nl80211: Failed to set interface 16 to mode 2: -19 (No such device)

wifi0: Failed to initialize driver interface

Failed to add interface wifi0

wifi0: Cancelling scan request

wifi0: Cancelling authentication timeout
```

I'm not quite sure how to read this output.  I really don't want to go out and buy another wifi card as I've recently purchased 2 and this driver seems to work for others out there (though they seem to be in other distros).  Also, most of the posts I've seen are at best about a year old.  Anyone have recent luck with this problem?Last edited by alienjon on Sat Nov 08, 2014 11:27 pm; edited 1 time in total

----------

## alienjon

Figured it out.  Buried in the Raspberry Pi forum I found someone mention that for the 8192cu (non-kernel) driver to work you have to use wext and not nl80211.

Here's the rundown of it all.  If you have a device that would use the kernel rtl8192cu driver (and it will not work) with wpa_supplicant you'll need git and dkms installed.  Then do the following.

```
git clone https://github.com/pvaret/rtl8192cu-fixes.git
```

```
dkms add ./rtl8192cu-fixes
```

```
dkms install 8192cu/1.9
```

```
depmod -a
```

```
echo "blacklist rtl8192cu" > /etc/modules.d/8192.conf

echo "options 8192cu rtw_power_mgnt=0 rtw_enusbss=0" >> /etc/modules.d/8192cu
```

```
vi /etc/conf.d/net

Find the wpa_supplicant_wlan0 line and change it to: wpa_supplicant_wlan0="-Dwext"
```

```
/etc/init.d/net.wlan0 stop
```

```
rmmod rtl8192cu rtl_usb rtlwifi rtl8192c_common

modprobe 8192cu
```

```
/etc/init.d/net.wlan0 start
```

This seems to have worked for me so far.  I'll try to keep an eye on the connection over the next few days and if I get any hiccups I'll post here too, but this all seemed to solve the problem.

(Note, most of the steps above are taken from the module readme or compiled from documentation elsewhere)

----------

## ferrelas

I'm grappling with getting this driver to work myself, I tried to follow the instructions here (with some modifications as I'm currently on a live cd), but I get stuck at 3.

this is what I do and what happens:

```
ubuntu ~ # dkms install -k 3.18.11-gentoo 8192cu/1.10

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:

cleaning build area....

make KERNELRELEASE=3.18.11-gentoo -C /lib/modules/3.18.11-gentoo/build M=/var/lib/dkms/8192cu/1.10/build....

Error!  Build of 8192cu.ko failed for: 3.18.11-gentoo (x86_64)

Consult the make.log in the build directory

/var/lib/dkms/8192cu/1.10/build/ for more information.
```

It might not be obvious, but of course I am chrooted to do this.

The file referenced isn't of very much help

make.log:

```
DKMS make.log for 8192cu-1.10 for kernel 3.18.11-gentoo (x86_64)

Mon 27 Apr 18:25:33 CEST 2015

make: Entering directory '/usr/src/linux-3.18.11-gentoo'

  LD      /var/lib/dkms/8192cu/1.10/build/built-in.o

  Building modules, stage 2.

  MODPOST 0 modules

make: Leaving directory '/usr/src/linux-3.18.11-gentoo'
```

----------

## mlyszczek

Sorry for digging out this topic from graveyard, but I have some informations for someone that struggles with this realtek chipset as well.

So, after you install (following alienjon instructions) patched 8192cu (NOT rtl8192cu from kernel - it is broken as we know) you might see something like this:

```
kurwik rtl8192cu-fixes # iwconfig

eth       no wireless extensions.

lo        no wireless extensions.

wifi      no wireless extensions.

```

Turns out you just need to compile also ipw2200 (Devices Drivers -> Network Device Support -> Wireless Lan -> Intel PRO/Wireless 2200bg). This compiles some additional functions that 8192cu needs. After that, wifi card started to work.

Tested against:

gentoo-sources-4.3.0;

8192cu version: 1.10

----------

