WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to compile a kernel module with source from vendor?  (Read 4573 times)

Offline mikedev

  • Newbie
  • *
  • Posts: 25
How to compile a kernel module with source from vendor?
« on: August 19, 2016, 02:04:35 PM »
I know how to compile programs into tcz from source.
So, how to compile kernel module into .ko from source provided by vendor or git clone?
Any general tutorial or guidelines?

Threads from google of compiling kernel modules in debian/ubuntu mentioned about "dkms", is it necessary in TC/piCore?

More detail is, I have an usb wireless adapter 8192cu, which works flawlessly with piCore8beta1 (4.4.11) but it is NOT working in beta4 (4.4.15).
I would like to try compiling this kernel module from realtek source or some git clone mentioned the "fix".

Thanks.

Online Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: How to compile a kernel module with source from vendor?
« Reply #1 on: August 19, 2016, 02:51:36 PM »
Hi mikedev,

I have been chasing these wifi issues and have found this improves the situation:

Change wifi-wpadrv and add to /opt/.filetool.lst
Code: [Select]
From:
$ cat /etc/sysconfig/wifi-wpadrv
wext
To:
$ cat /etc/sysconfig/wifi-wpadrv
nl80211,wext

I find this wifi adaptor now works 80% to 90% of the time.

(BTW: I didn't test the kernel 4.1.xx setup to verify if it was working 100%, I suspect not. I had been using this wifi adaptor successfully for over a year.)

wifi adaptor details:

Code: [Select]
Report diag_wifi.cgi generated on Sat Aug 20 07:35:49 EST 2016
         _ _____             ___  __
   ___  (_) ___/__  _______ / _ \/ /__ ___ _____ ____
  / _ \/ / /__/ _ \/ __/ -_) ___/ / _ `/ // / -_) __/
 / .__/_/\___/\___/_/  \__/_/  /_/\_,_/\_, /\__/_/
/_/                                   /___/

piCorePlayer = piCore + Squeezelite + Raspberry Pi

The software is provided "as is" without warranty of any kind,
either express or implied, including without limitation any implied
warranties of condition, uninterrupted use, merchantability,
fitness for a particular purpose, or non-infringement.

=========================================================================================
Wifi:        on
SSID:        GEwireless2
Password:    xxxxxxx
Security:    WPA
MAC address: 00:28:01:71:d0:24
Uptime:       4 days 0 hours 18 minutes 30 seconds
=========================================================================================

dmesg
=========================================================================================
[    3.294733] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=8176
[    3.294749] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.294760] usb 1-1.2: Product: 802.11n WLAN Adapter
[    3.294771] usb 1-1.2: Manufacturer: Realtek
[    3.294783] usb 1-1.2: SerialNumber: 00e04c000001
.

lsmod
=========================================================================================
Module                  Size  Used by    Not tainted
8192cu                568110  0
cfg80211              440795  1 8192cu
rfkill                 16702  2 cfg80211
squashfs               29704 21
zram                   21852  1
zsmalloc               12458  1 zram
lz4_compress            3028  1 zram

wifi usb report (lsusb)
=========================================================================================
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

iwconfig
=========================================================================================
wlan0     IEEE 802.11bgn  ESSID:"GEwireless2"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.452 GHz  Access Point: 00:04:ED:C9:57:B8   
          Bit Rate:150 Mb/s   Sensitivity:0/0 
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=89/100  Signal level=71/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0


ifconfig
=========================================================================================
wlan0     Link encap:Ethernet  HWaddr 00:28:01:71:D0:24 
          inet addr:192.168.1.155  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14828603 errors:0 dropped:462364 overruns:0 frame:0
          TX packets:2496518 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1290626924 (1.2 GiB)  TX bytes:251438066 (239.7 MiB)


iwlist
=========================================================================================
wlan0     Scan completed :
          Cell 01 - Address: C4:EA:1D:B3:07:CB
                    ESSID:"TelstraB307CB"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:130 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020c00
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD980050F204104A00011010440001021057000101103B000103104700101519F3997A305259A09F8F92113204591021000B546563686E69636F6C6F721023000E546563686E69636F6C6F7220544710240006373939766163104200093135343853413855531054000800060050F204000110110014546563686E69636F6C6F7220544737393976616310080002268C1049000600372A000120
                    Quality=94/100  Signal level=44/100 
          Cell 02 - Address: C6:EA:1D:B3:07:CD
                    ESSID:"Telstra Air"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=78/100  Signal level=42/100 
          Cell 03 - Address: C6:EA:1D:B3:07:CE
                    ESSID:"Fon WiFi"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=34/100  Signal level=42/100 
          Cell 04 - Address: 00:04:ED:C9:57:B8
                    ESSID:"GEwireless2"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.452 GHz (Channel 9)
                    Encryption key:on
                    Bit Rates:300 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    Quality=89/100  Signal level=71/100 
          Cell 05 - Address: 00:1B:2F:74:C9:D8
                    ESSID:"NETGEAR"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:54 Mb/s
                    Quality=96/100  Signal level=47/100 
          Cell 06 - Address: 30:91:8F:2F:BC:C3
                    ESSID:"Telstra2FBCC3"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:on
                    Bit Rates:130 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020c00
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD9A0050F204104A00011010440001021057000101103B0001031047001056B110A696C559EFBB435E0DB8C4857C1021000B546563686E69636F6C6F721023000E546563686E69636F6C6F72205447102400073739376E207633104200093134333054414144301054000800060050F204000110110015546563686E69636F6C6F722054473739376E20763310080002268C1049000600372A000120
                    Quality=56/100  Signal level=23/100 
          Cell 07 - Address: 32:91:8F:2F:BC:C5
                    ESSID:"Telstra Air"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=44/100  Signal level=19/100 
          Cell 08 - Address: 32:91:8F:2F:BC:C6
                    ESSID:"Fon WiFi"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=41/100  Signal level=15/100 



---------------------------------------------------------------------------------------------
       SSID                 Quality   Level       Channel      Encryption       Address
---------------------------------------------------------------------------------------------
 1. NETGEAR                    96     47/100    11 (2.462GHz)   off NONE   00:1B:2F:74:C9:D8
 2. TelstraB307CB              94     44/100     6 (2.437GHz)   on  WPA2   C4:EA:1D:B3:07:CB
 3. GEwireless2                92     71/100     9 (2.452GHz)   on  WPA2   00:04:ED:C9:57:B8
 4. Telstra Air                78     42/100     6 (2.437GHz)   off NONE   C6:EA:1D:B3:07:CD
 5. Telstra2FBCC3              56     23/100    11 (2.462GHz)   on  WPA2   30:91:8F:2F:BC:C3
 6. Telstra Air                44     19/100    11 (2.462GHz)   off NONE   32:91:8F:2F:BC:C5
 7. Fon WiFi                   41     15/100    11 (2.462GHz)   off NONE   32:91:8F:2F:BC:C6
 8. Fon WiFi                   34     42/100     6 (2.437GHz)   off NONE   C6:EA:1D:B3:07:CE
---------------------------------------------------------------------------------------------

regards
Greg

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
Re: How to compile a kernel module with source from vendor?
« Reply #2 on: August 19, 2016, 03:28:16 PM »
There is a vendor driver in the kernel, it is just disabled in the config.   I'll look it up for you

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
Re: How to compile a kernel module with source from vendor?
« Reply #3 on: August 19, 2016, 07:51:46 PM »
Can you point me to the "FIX" you are referring to?

The realtek vendor drivers are disabled in the current kernel.      The old 8192cu has been getting small patches to make it work with hostapd and modern mac80211/nl80211.   But there are just too many variants of the rtl8188 chipset to make it work reliably.      There is another promising driver coming up, but it's not fully developed.    RTL8xxxu.  But it might work with in 8192cu mode.


The easiest way would be to apply the patch you mentioned to the kernel  or replace the appropriate kernel source with the source you want.   Or enable one of the above drivers and then build in tree.

Download the kernel source/config/System.map/Module.symvers  from http://tinycorelinux.net/8.x/armv7/releases/RPi/src/kernel/    If you have an armv6 board, just change the above link to armv6

Expand the kernel source
expand the .config   Module.symvers  and the System.map and place in the root of the kernel build directory

To enable the rtlwifi vendor drivers
edit the file drivers/net/wireless/Kconfig
     -scroll to the end of the file and uncomment this line    source "drivers/net/wireless/realtek/rtlwifi/Kconfig"
edit the file drivers/net/wireless/realtek/Makefile
     -remove the comment from the line   obj-$(CONFIG_RTLWIFI)       += rtlwifi/
run make menuconfig
       navigate to Device Drivers/Network device support/Wireless Lan/
              make sure "Realtek rtlwifi family of devices" is set to <m>
       You may choose to enable RTL8XXXU as well
Save the config
Exit

To build single modules do this.  (This will build the Realtek vendor driver rtl8192cu.ko)

make modules_prepare
make SUBDIRS=drivers/net/wireless/realtek/rtlwifi modules

Then goto driver/net/wireless/realtek/rtlwifi/rtl8192cu/     and you will find your new module.


Obviously if you have more than one driver on your system for your card, it will confuse the kernel, so either blacklist drivers or load/unload them manually with modprobe
« Last Edit: August 19, 2016, 08:05:30 PM by Paul_123 »

Offline mikedev

  • Newbie
  • *
  • Posts: 25
Re: How to compile a kernel module with source from vendor?
« Reply #4 on: August 22, 2016, 10:40:08 AM »
Hi mikedev,

I have been chasing these wifi issues and have found this improves the situation:

Change wifi-wpadrv and add to /opt/.filetool.lst
Code: [Select]
From:
$ cat /etc/sysconfig/wifi-wpadrv
wext
To:
$ cat /etc/sysconfig/wifi-wpadrv
nl80211,wext

I find this wifi adaptor now works 80% to 90% of the time.

(BTW: I didn't test the kernel 4.1.xx setup to verify if it was working 100%, I suspect not. I had been using this wifi adaptor successfully for over a year.)

wifi adaptor details:

Code: [Select]
Report diag_wifi.cgi generated on Sat Aug 20 07:35:49 EST 2016
         _ _____             ___  __
   ___  (_) ___/__  _______ / _ \/ /__ ___ _____ ____
  / _ \/ / /__/ _ \/ __/ -_) ___/ / _ `/ // / -_) __/
 / .__/_/\___/\___/_/  \__/_/  /_/\_,_/\_, /\__/_/
/_/                                   /___/

piCorePlayer = piCore + Squeezelite + Raspberry Pi

The software is provided "as is" without warranty of any kind,
either express or implied, including without limitation any implied
warranties of condition, uninterrupted use, merchantability,
fitness for a particular purpose, or non-infringement.

=========================================================================================
Wifi:        on
SSID:        GEwireless2
Password:    xxxxxxx
Security:    WPA
MAC address: 00:28:01:71:d0:24
Uptime:       4 days 0 hours 18 minutes 30 seconds
=========================================================================================

dmesg
=========================================================================================
[    3.294733] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=8176
[    3.294749] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.294760] usb 1-1.2: Product: 802.11n WLAN Adapter
[    3.294771] usb 1-1.2: Manufacturer: Realtek
[    3.294783] usb 1-1.2: SerialNumber: 00e04c000001
.

lsmod
=========================================================================================
Module                  Size  Used by    Not tainted
8192cu                568110  0
cfg80211              440795  1 8192cu
rfkill                 16702  2 cfg80211
squashfs               29704 21
zram                   21852  1
zsmalloc               12458  1 zram
lz4_compress            3028  1 zram

wifi usb report (lsusb)
=========================================================================================
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

iwconfig
=========================================================================================
wlan0     IEEE 802.11bgn  ESSID:"GEwireless2"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.452 GHz  Access Point: 00:04:ED:C9:57:B8   
          Bit Rate:150 Mb/s   Sensitivity:0/0 
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=89/100  Signal level=71/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0


ifconfig
=========================================================================================
wlan0     Link encap:Ethernet  HWaddr 00:28:01:71:D0:24 
          inet addr:192.168.1.155  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14828603 errors:0 dropped:462364 overruns:0 frame:0
          TX packets:2496518 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1290626924 (1.2 GiB)  TX bytes:251438066 (239.7 MiB)


iwlist
=========================================================================================
wlan0     Scan completed :
          Cell 01 - Address: C4:EA:1D:B3:07:CB
                    ESSID:"TelstraB307CB"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:130 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020c00
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD980050F204104A00011010440001021057000101103B000103104700101519F3997A305259A09F8F92113204591021000B546563686E69636F6C6F721023000E546563686E69636F6C6F7220544710240006373939766163104200093135343853413855531054000800060050F204000110110014546563686E69636F6C6F7220544737393976616310080002268C1049000600372A000120
                    Quality=94/100  Signal level=44/100 
          Cell 02 - Address: C6:EA:1D:B3:07:CD
                    ESSID:"Telstra Air"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=78/100  Signal level=42/100 
          Cell 03 - Address: C6:EA:1D:B3:07:CE
                    ESSID:"Fon WiFi"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=34/100  Signal level=42/100 
          Cell 04 - Address: 00:04:ED:C9:57:B8
                    ESSID:"GEwireless2"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.452 GHz (Channel 9)
                    Encryption key:on
                    Bit Rates:300 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    Quality=89/100  Signal level=71/100 
          Cell 05 - Address: 00:1B:2F:74:C9:D8
                    ESSID:"NETGEAR"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:54 Mb/s
                    Quality=96/100  Signal level=47/100 
          Cell 06 - Address: 30:91:8F:2F:BC:C3
                    ESSID:"Telstra2FBCC3"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:on
                    Bit Rates:130 Mb/s
                    Extra:rsn_ie=30140100000fac040100000fac040100000fac020c00
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD9A0050F204104A00011010440001021057000101103B0001031047001056B110A696C559EFBB435E0DB8C4857C1021000B546563686E69636F6C6F721023000E546563686E69636F6C6F72205447102400073739376E207633104200093134333054414144301054000800060050F204000110110015546563686E69636F6C6F722054473739376E20763310080002268C1049000600372A000120
                    Quality=56/100  Signal level=23/100 
          Cell 07 - Address: 32:91:8F:2F:BC:C5
                    ESSID:"Telstra Air"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=44/100  Signal level=19/100 
          Cell 08 - Address: 32:91:8F:2F:BC:C6
                    ESSID:"Fon WiFi"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.462 GHz (Channel 11)
                    Encryption key:off
                    Bit Rates:130 Mb/s
                    Quality=41/100  Signal level=15/100 



---------------------------------------------------------------------------------------------
       SSID                 Quality   Level       Channel      Encryption       Address
---------------------------------------------------------------------------------------------
 1. NETGEAR                    96     47/100    11 (2.462GHz)   off NONE   00:1B:2F:74:C9:D8
 2. TelstraB307CB              94     44/100     6 (2.437GHz)   on  WPA2   C4:EA:1D:B3:07:CB
 3. GEwireless2                92     71/100     9 (2.452GHz)   on  WPA2   00:04:ED:C9:57:B8
 4. Telstra Air                78     42/100     6 (2.437GHz)   off NONE   C6:EA:1D:B3:07:CD
 5. Telstra2FBCC3              56     23/100    11 (2.462GHz)   on  WPA2   30:91:8F:2F:BC:C3
 6. Telstra Air                44     19/100    11 (2.462GHz)   off NONE   32:91:8F:2F:BC:C5
 7. Fon WiFi                   41     15/100    11 (2.462GHz)   off NONE   32:91:8F:2F:BC:C6
 8. Fon WiFi                   34     42/100     6 (2.437GHz)   off NONE   C6:EA:1D:B3:07:CE
---------------------------------------------------------------------------------------------

regards
Greg

Thanks Greg, I have tried yours but it doesn't work on my case.
My wlan interface can be brought up, that's it, unable to connect to ap with wpa_supplicant nor serve as ap with hostapd, under 8beta4.
However, it works very fine under 8beta1, can connect to ap, can serve as ap with hostapd.  Haven't tried 8beta2 or beta3.
Strange...

Thanks your suggestion!

Offline mikedev

  • Newbie
  • *
  • Posts: 25
Re: How to compile a kernel module with source from vendor?
« Reply #5 on: August 22, 2016, 10:49:53 AM »
Can you point me to the "FIX" you are referring to?

The realtek vendor drivers are disabled in the current kernel.      The old 8192cu has been getting small patches to make it work with hostapd and modern mac80211/nl80211.   But there are just too many variants of the rtl8188 chipset to make it work reliably.      There is another promising driver coming up, but it's not fully developed.    RTL8xxxu.  But it might work with in 8192cu mode.


The easiest way would be to apply the patch you mentioned to the kernel  or replace the appropriate kernel source with the source you want.   Or enable one of the above drivers and then build in tree.

Download the kernel source/config/System.map/Module.symvers  from http://tinycorelinux.net/8.x/armv7/releases/RPi/src/kernel/    If you have an armv6 board, just change the above link to armv6

Expand the kernel source
expand the .config   Module.symvers  and the System.map and place in the root of the kernel build directory

To enable the rtlwifi vendor drivers
edit the file drivers/net/wireless/Kconfig
     -scroll to the end of the file and uncomment this line    source "drivers/net/wireless/realtek/rtlwifi/Kconfig"
edit the file drivers/net/wireless/realtek/Makefile
     -remove the comment from the line   obj-$(CONFIG_RTLWIFI)       += rtlwifi/
run make menuconfig
       navigate to Device Drivers/Network device support/Wireless Lan/
              make sure "Realtek rtlwifi family of devices" is set to <m>
       You may choose to enable RTL8XXXU as well
Save the config
Exit

To build single modules do this.  (This will build the Realtek vendor driver rtl8192cu.ko)

make modules_prepare
make SUBDIRS=drivers/net/wireless/realtek/rtlwifi modules

Then goto driver/net/wireless/realtek/rtlwifi/rtl8192cu/     and you will find your new module.


Obviously if you have more than one driver on your system for your card, it will confuse the kernel, so either blacklist drivers or load/unload them manually with modprobe

This is one of those "fix" links that I would like to try...
http://askubuntu.com/questions/246236/compile-and-install-rtl8192cu-driver
Most other searches from google also utilize the git of "https://github.com/pvaret/rtl8192cu-fixes.git"

Thanks Paul, I would try your solution when I have time.
That's weird to me that the wireless adapter works perfectly under 8beta1 as client or master but not under 8beta4.

I basically have trimmed 2 memory cards (1 for beta1, 1 for beta4) for troubleshooting that each only contain the partition 1, and the partition 2 with wifi.tcz and its dependency.  The issue is repeatable by swapping memory card on the same pi.
Issue must be either from wireless-4.4.15-piCore+ or kernel since this is the only difference.

I doubt on the driver that's why I would like to try (re)compile the driver part...

Thanks.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
Re: How to compile a kernel module with source from vendor?
« Reply #6 on: August 22, 2016, 01:03:34 PM »

This is one of those "fix" links that I would like to try...
http://askubuntu.com/questions/246236/compile-and-install-rtl8192cu-driver
Most other searches from google also utilize the git of "https://github.com/pvaret/rtl8192cu-fixes.git"

Thanks Paul, I would try your solution when I have time.
That's weird to me that the wireless adapter works perfectly under 8beta1 as client or master but not under 8beta4.

I basically have trimmed 2 memory cards (1 for beta1, 1 for beta4) for troubleshooting that each only contain the partition 1, and the partition 2 with wifi.tcz and its dependency.  The issue is repeatable by swapping memory card on the same pi.
Issue must be either from wireless-4.4.15-piCore+ or kernel since this is the only difference.

I doubt on the driver that's why I would like to try (re)compile the driver part...

Thanks.

There was a change to the kernel source for this driver after 8.0Beta1.     Here is the pull request that was merged into the RPI kernel
https://github.com/raspberrypi/linux/pull/1488.   You will notice it includes a port of the pvaret driver fixes.

I don't think I ever tested beta 1.   If the beta 1 drivers worked, that is the source I would grab.   If you clone the RPI kernel github, you should be able to revert that commit and grab that code.

For me I'm really considering to drop all of my RTL8188 based sticks.

Offline mikedev

  • Newbie
  • *
  • Posts: 25
Re: How to compile a kernel module with source from vendor?
« Reply #7 on: August 26, 2016, 02:43:17 PM »
Can you point me to the "FIX" you are referring to?

The realtek vendor drivers are disabled in the current kernel.      The old 8192cu has been getting small patches to make it work with hostapd and modern mac80211/nl80211.   But there are just too many variants of the rtl8188 chipset to make it work reliably.      There is another promising driver coming up, but it's not fully developed.    RTL8xxxu.  But it might work with in 8192cu mode.


The easiest way would be to apply the patch you mentioned to the kernel  or replace the appropriate kernel source with the source you want.   Or enable one of the above drivers and then build in tree.

Download the kernel source/config/System.map/Module.symvers  from http://tinycorelinux.net/8.x/armv7/releases/RPi/src/kernel/    If you have an armv6 board, just change the above link to armv6

Expand the kernel source
expand the .config   Module.symvers  and the System.map and place in the root of the kernel build directory

To enable the rtlwifi vendor drivers
edit the file drivers/net/wireless/Kconfig
     -scroll to the end of the file and uncomment this line    source "drivers/net/wireless/realtek/rtlwifi/Kconfig"
edit the file drivers/net/wireless/realtek/Makefile
     -remove the comment from the line   obj-$(CONFIG_RTLWIFI)       += rtlwifi/
run make menuconfig
       navigate to Device Drivers/Network device support/Wireless Lan/
              make sure "Realtek rtlwifi family of devices" is set to <m>
       You may choose to enable RTL8XXXU as well
Save the config
Exit

To build single modules do this.  (This will build the Realtek vendor driver rtl8192cu.ko)

make modules_prepare
make SUBDIRS=drivers/net/wireless/realtek/rtlwifi modules

Then goto driver/net/wireless/realtek/rtlwifi/rtl8192cu/     and you will find your new module.


Obviously if you have more than one driver on your system for your card, it will confuse the kernel, so either blacklist drivers or load/unload them manually with modprobe

Paul, first, thank you very much again!  Your detail steps of instruction are very useful.  I learned new stuffs from your instruction in compiling an additional vendor's driver as module from the source.  Very cool!  BTW, would you share where I can learn more about these kernel/module compilation tutorial or documentation?

The compilation works perfectly, however, ran into another problem:
under 4.4.15/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/, there is rtl8192cu.ko, I copied this file into /usr/local/lib/modules/4.4.15-piCore+/kernel/drivers/net/wireless/realtek/rtl8192cu, and then
Quote
sudo depmod -a
sudo modprobe rtl8192cu
modprobe: can't load module rtl8192cu (kernel.tclocal/drivers/net/wireless/realtek/rtl8192cu/rtl8192cu.ko): invalid module format

Any idea why the module format is invalid???

This is the line from syslog:
Quote
[363086.698396] rtl8192cu: no symbol version for module_layout

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1082
Re: How to compile a kernel module with source from vendor?
« Reply #8 on: August 26, 2016, 07:40:57 PM »
Make sure you grabbed the right source files for armv6 or armv7

Otherwise, there may be other updates not done to that driver to be compatible with 4.4.x kernels.


I've just been doing this a while.  Google for info, and save notes.  No particular sites