Need to compile a driver for a wifi dongle

Technical issues/questions of an intermediate or advanced nature.
Post Reply
fulalas
Contributor
Contributor
Posts: 578
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Need to compile a driver for a wifi dongle

Post#1 by fulalas » 10 Feb 2017, 05:37

I'm trying to compile a driver for the TP-LINK TL-WN725N: https://github.com/twd2/TL-WN725N-V2-Driver-for-Linux

But first I dmesg -w to see if Porteus detect the new device:

Code: Select all

[ 1676.866830] usb 2-1.5: new high-speed USB device number 4 using ehci-pci
[ 1676.945927] usb 2-1.5: New USB device found, idVendor=0bda, idProduct=8179
[ 1676.945931] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1676.945933] usb 2-1.5: Product: 802.11n NIC
[ 1676.945935] usb 2-1.5: Manufacturer: Realtek
[ 1676.945937] usb 2-1.5: SerialNumber: 00E04C0001
[ 1677.520126] r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
[ 1677.521292] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)
[ 1677.558623] usbcore: registered new interface driver r8188eu
[ 1677.585337] r8188eu 2-1.5:1.0: Direct firmware load for rtlwifi/rtl8188eufw.bin failed with error -2
[ 1677.585343] r8188eu 2-1.5:1.0: Firmware rtlwifi/rtl8188eufw.bin not available
[ 1677.585347] MAC Address = 84:16:f9:07:b0:f2                                                                       
[ 1677.718565] usb 2-1.5: USB disconnect, device number 4
[ 1677.719579] R8188EU: ERROR indicate disassoc
When I try to compile I get this:

Code: Select all

"******************************************"
"NO SKRC,we will use default KSRC"
"******************************************"
make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/4.9.0-porteus/build M=/home/guest/Downloads/Driver  modules
make[1]: *** /lib/modules/4.9.0-porteus/build: No such file or directory.  Stop.
Makefile:1367: recipe for target 'modules' failed
make: *** [modules] Error 2
Then I noticed that /lib/modules/4.9.0-porteus/build is a broken symlink pointing to /usr/src/linux. I decided to create a folder called build inside /lib/modules/4.9.0-porteus/ but then I got another error when trying to compile:

Code: Select all

make ARCH=x86_64 CROSS_COMPILE= -C /lib/modules/4.9.0-porteus/build M=/home/guest/TL-WN725N-V2-Driver-for-Linux  modules
make[1]: Entering directory '/lib/modules/4.9.0-porteus/build'
make[1]: *** No rule to make target 'modules'.  Stop.
make[1]: Leaving directory '/lib/modules/4.9.0-porteus/build'
Makefile:582: recipe for target 'modules' failed
make: *** [modules] Error 2
:(

fulalas
Contributor
Contributor
Posts: 578
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: Need to compile a driver for a wifi dongle

Post#2 by fulalas » 10 Feb 2017, 05:55

Oops, I forgot to activate crippled_sources.xzm :P

One more doubt: after compiling it, how do I make install to a package like Slackbuild does?

jssouza
Samurai
Samurai
Posts: 172
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm
Location: Liechtenstein

Re: Need to compile a driver for a wifi dongle

Post#3 by jssouza » 10 Feb 2017, 06:16

fulalas wrote:after compiling it, how do I make install to a package like Slackbuild does?
This is how I do it:
As root:
1. Copy built kernel_module.ko into /lib/modules/`uname -r`/kernel/extra
2. Run depmod -a
3. Create fake root with <pkgroot>/lib/modules/`uname -r`/kernel/extra/kernel_module.ko structure
4. Copy /mnt/live/memory/changes/lib/modules/`uname -r`/modules* to <pkgroot>/lib/modules/`uname -r`/
5. Create slackpkg specific stuff in fake root (install/slack-desc etc.)
6. Execute makepkg to create the slackware package.

Your first post dmesg log mentions a missing firmware .bin file. Put that in pkgroot/lib/firmware once you have it. You might have to also create a udev rule if your driver does not automatically load upon boot.

fulalas
Contributor
Contributor
Posts: 578
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: Need to compile a driver for a wifi dongle

Post#4 by fulalas » 11 Feb 2017, 00:42

jssouza, thank you a lot!

I've managed to compile it and load it almost successfully. I say almost because although it loads and even can see available wifi networks around, the signal is unbelievably poor and unstable. And what's worst: it's really slow to the point you can't load Google sometimes... The dongle is a Tp-Link WN725N v2. I'll return it to the store and get a real wifi card: Tp-Link WN881ND. AFAIK, this card has a native Linux kernel driver, so I hope I won't have much problems :)

Post Reply