[GUIDE] Using external USB wifi

Search This thread

infernix

Senior Member
Oct 7, 2007
116
64
I got fed up with crappy wireless reception in a hotel and decided to use my RTL8187 based Alfa USB wireless adapter with my Prime. Here's how it works, pretty rough and open to improvement but it works.

  1. Set up a chroot (ubuntu/debian will work); everything is done within that chroot
  2. Compile and install the drivers for your usb adapter (see the Kernel modules thread for instructions)
  3. apt-get install wicd-curses (or wicd-cli if you prefer), wpasupplicant and dbus plus any of its dependancies
  4. Turn off the broadcom wifi that's controlled by android
  5. insmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)
  6. start dbus and wicd (/etc/init.d/dbus start; /etc/init.d/wicd start)
  7. run wicd-curses (or wicd-cli), refresh the network list and connect to your network
  8. configure dns for android to your dns or to googles (setprop net.dns1 8.8.8.8)
  9. ???
  10. Profit

To stop using external usb wifi, reverse the steps; basically:

  1. stop wicd and dbus (/etc/init.d/wicd stop; /etc/init.d/dbus stop)
  2. kill any running dhcp clients (killall dhclient)
  3. rmmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)

To be able to insert mac80211 without it complaining about missing symbols for ewma_init and ewma_add, I had to add lib/average.c to the mac80211 module; it's pretty simple, here's how i did that:

  1. Go to your prime kernel source tree (e.g. /usr/src/linux)
  2. cp lib/average.c net/mac80211/
  3. Edit net/mac80211/Makefile and add average.o to the list of objects for mac80211-y (don't miss the trailing backslash if you add it halfway)

For simplicity sake I've added the modules for an rtl8187 based usb nic to this post. These are built against the 9.4.2.7 kernel source, and work fine for the 9.4.2.11 release (current ICS release as of Feb 07 2012).

Oh and I don't recommend doing this with androids wifi turned on, it kind of breaks it until you reboot your tab. So if you're smart you'll script the above and spit out a nice warning that your broadcom module is still loaded and then exit. I had no problems switching between external USB wifi and built-in wifi as long as I only turned one of them on exclusively.

Enjoy solid wifi on your prime :)
 

Attachments

  • rtl8187mods.zip
    2.3 MB · Views: 10,992

demandarin

Senior Member
Apr 7, 2010
7,021
2,038
Alexandria, Va
,can you show screenshots of how much of an improvement it was using a USB wifi device vs. Stock wifi. You should relay this info in the kernel modules thread n SaturnDe can probably clean it up or simplify more or make it easier to implement. He could add it to his driver packs and make a new ATP tweaks version. For quick app enabling of this USB wifi method. This is very cool. I really would like to see how much of an improvement in reception thisngives.
 
  • Like
Reactions: PRichardson

infernix

Senior Member
Oct 7, 2007
116
64
You can't use the external wifi together with the android wifi control, it isn't compatible. So screenshots make no sense. This is why you need the chroot and wicd-curses; that's where you configure your wifi connection, not in android.

As for the increase in reception, it depends on your usb adapter. If you have one with an external antenna that is 6 feet long, you can figure out how much of an improvement that would be. Nothing is stopping you from connecting an even bigger wifi antenna if you want. So, reception increase could be anywhere from a few dB up to long range 5km wifi using powerful long range antennas.
 
  • Like
Reactions: demandarin

buxtahuda

Senior Member
Feb 4, 2011
1,379
162
Cleveland, MS
You can't use the external wifi together with the android wifi control, it isn't compatible. So screenshots make no sense. This is why you need the chroot and wicd-curses; that's where you configure your wifi connection, not in android.

As for the increase in reception, it depends on your usb adapter. If you have one with an external antenna that is 6 feet long, you can figure out how much of an improvement that would be. Nothing is stopping you from connecting an even bigger wifi antenna if you want. So, reception increase could be anywhere from a few dB up to long range 5km wifi using powerful long range antennas.

Lol, I believe you're being told to do it yourself 'darin. I have a nice little wifi usb adapter, I'll give this all a whirl later on after work.

Certainly not a solution for myself, but a simple workaround for those uncomfortable with modding and who don't mind annoying sticks coming from their tablets/laptops. Not saying anything against this, I just always hated using older laptops with usb adapters and don't see me liking it more on a smaller, more stream-lined device.
 

infernix

Senior Member
Oct 7, 2007
116
64
Certainly not a solution for myself, but a simple workaround for those uncomfortable with modding and who don't mind annoying sticks coming from their tablets/laptops. Not saying anything against this, I just always hated using older laptops with usb adapters and don't see me liking it more on a smaller, more stream-lined device.


FWIW, this can also be used to run aircrack or other wifi security analysis tools with, which aren't able to ever run with the builtin broadcom adapter. So it has other uses too :)
 

foboi1122

Senior Member
Dec 6, 2011
99
32
FWIW, this can also be used to run aircrack or other wifi security analysis tools with, which aren't able to ever run with the builtin broadcom adapter. So it has other uses too :)

Has anyone tried doing so with their ATP? I'd be very interested to know. I've had a bunch of problems with the build-in card in terms of using the bt5 pentest suite so this might potentially solve some of those problems
 

BiboTheClown

Member
Oct 31, 2007
23
4
Yeap, done with BT5 for arm and ALFA AWUS036H (Rtl8187), apt-get the aircrack tool and bang! : monitoring mode enables

:)

Thanks a lot to the OP for the modules !
 
  • Like
Reactions: PRichardson

foboi1122

Senior Member
Dec 6, 2011
99
32
what version of linux are you guys using? I was trying to install wicd-cli and wicd-curses through my bt5 and had no success. wicd-curses just can't install on arm bt5 for some reason stating that some dependant libraries are incompatible. wicd-cli gives me an fopen error during install and then craps out when I try to run it.
 
  • Like
Reactions: PRichardson

ryun33

Senior Member
Jun 19, 2010
59
37
Thanks for the info, one question tho.
Did you have to do anything special to get the wicd client to run, I get the error 'cannot connect to dbus socket' or something to that effect..

I have tried wicd-cli, -curses, and -gtk

Any help would be appreciated.
 
  • Like
Reactions: PRichardson

michaelmotes

Senior Member
Feb 5, 2012
120
73
Dear Sirs,

This may be newbish, but where can I get the source for the kernel modules the op mentioned. I have obtained my kernel source for my phone, but can't seem to find the source I actually need to compile, rtl8187, etc.

Update:
Alright, I found them, they are part of the compat-wireless package. http://www.aircrack-ng.org/doku.php?id=compat-wireless

I still can get it to compile, but I guess I need to learn a little about cross compiling.

I did find a kernel for my device with the modules already built in, used and voila. Cracked a wep key in about 5-10 minutes. I was happy, happy, happy. Then, a ruinous moment occurred. Almost the very second aircrack-ng finished cracking the key, my phone came up with a low battery warning, I was using a awus036h wifi adapter and it was draining my battery fast, I had about 50% to begin and had the 14% warning hit me about 10 minutes in, funny thing is the warning is usually 14%, but this time was 13%, go figure? Anyway seconds after the warning my phone just blanks, turns off. I plug it in and reboot and the battery is at 0% and stuck there, so a word of warning:

An external wifi adapter my require more usb host juice then the battery can safely supply. I have seen people using powered hubs to circumvent draining the phone battery, I would defintiely recommend the practice.
 
Last edited:

pileot

Senior Member
Oct 16, 2010
750
208
Ok, if the last poster was noobish then i dont even know where i would be because i need help just deciphering wtf OP said.

I realize the drivers for each wireless adapter are going to be a little different... because each wireless adapter is different, but can someone translate this into non geek? I dont even know where to begin.

Can this work using the ubuntu/backtrack/linux installers from the market? Ive muddled my way through that and got linux working that way, or is this completely different?
 

SpyFi

Senior Member
Jun 6, 2011
174
48
I just wanted to say THANKS! I now have my Alpha card working in Monitor mode on my TF300T Transformer PAD and man it feels good! I have never been able to get this to work and have been trying to use an external card in backtrack for a loooong time! Thank you 1 million times!
 

kudryashovda

New member
Apr 27, 2009
2
0
Hi! Thanks for instructions. I got compile and install driver for my G-Sky (rtl8187) on AllWinner A10 (Ainol Aurora II) with android 4.0.4 and 3.0.8 kernel. All network settings were done with tablet's terminal (without PC). Only one problem remains - I can't undestant connecting to wpa networks - it's too difficult. Here: http_://nuzhen-sovet.ru/content/podklyuchenie-vneshnego-wi-fi-adaptera-k-planshetu-na-android-4 you can read my manual with connection to nonWPA networks on russian (read with google translate).
 

whycali

Senior Member
Apr 21, 2010
1,262
290
I am wondering if something like this could be used for the folks concerned with bt\wifi fallout. There are plenty of bluetooth dongles out there that are small enough to leave in the dock full time. I have the fallout I just dont use bluetooth enough to care.
 

yousefs

Senior Member
Jan 12, 2014
103
12
plus.google.com
I got fed up with crappy wireless reception in a hotel and decided to use my RTL8187 based Alfa USB wireless adapter with my Prime. Here's how it works, pretty rough and open to improvement but it works.

  1. Set up a chroot (ubuntu/debian will work); everything is done within that chroot
  2. Compile and install the drivers for your usb adapter (see the Kernel modules thread for instructions)
  3. apt-get install wicd-curses (or wicd-cli if you prefer), wpasupplicant and dbus plus any of its dependancies
  4. Turn off the broadcom wifi that's controlled by android
  5. insmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)
  6. start dbus and wicd (/etc/init.d/dbus start; /etc/init.d/wicd start)
  7. run wicd-curses (or wicd-cli), refresh the network list and connect to your network
  8. configure dns for android to your dns or to googles (setprop net.dns1 8.8.8.8)
  9. ???
  10. Profit

To stop using external usb wifi, reverse the steps; basically:

  1. stop wicd and dbus (/etc/init.d/wicd stop; /etc/init.d/dbus stop)
  2. kill any running dhcp clients (killall dhclient)
  3. rmmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)

To be able to insert mac80211 without it complaining about missing symbols for ewma_init and ewma_add, I had to add lib/average.c to the mac80211 module; it's pretty simple, here's how i did that:

  1. Go to your prime kernel source tree (e.g. /usr/src/linux)
  2. cp lib/average.c net/mac80211/
  3. Edit net/mac80211/Makefile and add average.o to the list of objects for mac80211-y (don't miss the trailing backslash if you add it halfway)

For simplicity sake I've added the modules for an rtl8187 based usb nic to this post. These are built against the 9.4.2.7 kernel source, and work fine for the 9.4.2.11 release (current ICS release as of Feb 07 2012).

Oh and I don't recommend doing this with androids wifi turned on, it kind of breaks it until you reboot your tab. So if you're smart you'll script the above and spit out a nice warning that your broadcom module is still loaded and then exit. I had no problems switching between external USB wifi and built-in wifi as long as I only turned one of them on exclusively.

Enjoy solid wifi on your prime :)

Well, after i read most replies, most don't understand how to get things set up, please describe it a bit more, organize things, like section for requirements, etc.
 
Last edited:
  • Like
Reactions: ghostlee618

yousefs

Senior Member
Jan 12, 2014
103
12
plus.google.com
Explain to Kernel and Kernel Modules and how to build them

For everyone who didn't Understand Step 2, I Will explain and tell you how to do that, Please read it all to Understand:highfive::

What is Kernel?
A Kernel is Simply a Bridge Between Software and Hardware.

So The Drivers are Inside the Kernel itself?
For Short, Yes. In Linux Overall (Android, Ubuntu, etc.), Drivers are Included Inside the Kernel it self, Some say for Performance Improvements.
Your Phone's Android Kernel Include all the Drivers required for your phone to function, And for the Devices that Support USB-OTG there are a Plenty of Drivers Included, However, Drivers like the one's for the RTL8187 Most likely won't be included.


What are Kernel Modules?
Kernel Modules are Files that have *KO Extension That can be loaded Through insmod and Unloaded through rmmod Command-Line Commands, These files is to Extend the Functionality of the Kernel Without Touching/Editing it at all,It Just does some effect Until the Modules are Unloaded/Device Rebooted, Kernel Modules useful Either by Adding a Driver or by adding other things..[/B]

What are the Disadvantages of Kernel Modules?
Well, There's no Difference Expect you need to reload the Kernel Modules after a Reboot or Module Unload, Some Tutorials Show you how can you add a command to load these Modules after each boot up

So A Kernel Module is the Solution for adding a driver without modifying the kernel?
Yes, Kernel Modules is the Solution here, Each USB Device needs it's own Kernel Modules, so you can't Download a Module and Use it, You need to Compile yours.

What is the Requirements to build a Kernel Modules?
1.You need Linux Environment, Use either the Chrooted Linux On you phone, or, better use Ubuntu or any linux Distro on a Computer, Build the Module, and load it on the Chrooted Linux on your phone,

2.You need an Internet Connection in the Linux Environment.

3.You need the Driver Source code for your USB Device. Get them from the Manufacturer if he offer them, if he doesn't, You need to Look in the internet until you find one, if you were unable to find the Source code for you Device but found similar Devices Driver source code, see if the Other Device Driver is Compatible with yours usually a Single Driver work on many Devices, you need to look by your own way

4.You Also need some Programs to install in Order to be able to Compile the Kernel Module, Enter these Commands in a Terminal, Pressing Enter after each Line, and make sure you have the Internet Connection:
HTML:
sudo apt-get install fakeroot
sudo apt-get install build-essential
sudo apt-get install dpkg-dev
sudo apt-get install linux-headers-$(uname -r)

For the most Important Part, make the Kernel Module?
1.Unpack the Kernel source code, if it's Extension is bz2 then use:
HTML:
tar jxvf <package-name>
Where <package-name> is the Compressed File name, and make sure you put it in the Home Folder, if it's Extension is gz or tgz the Unpack it with:
HTML:
tar zxvf <package-name>

2. Second, Find config.mk and Open it with gedit or whatever Text editor you like, at first, there is two lines about WPA Support, make sure they end with y rather than n, Save and close.

3.Third, and last, is to Compile the Kernel Module, Open Terminal and use cd command to get inside the folder that contains the Source code, and Simply Execute:
HTML:
sudo make
And now you own the Kernel module, Now copy the Kernel Module to the root of your Internal Storage, Open up a Terminal and Type:
HTML:
cd /mnt/sdcard
insmod <kernel-module-name>.ko
And make sure Internal Wi-Fi is OFF and now your Kernel Module works, Follow the Guys steps to get it working on Chrooted distro



Troubleshooting:
If you find a similar Device Driver Source Code and after Compiling it doesn't work plug the Device in, Open a Terminal and type:
HTML:
sudo lsusb
and Find your Device in the Output and you should find Numbers for it Looks Like 0x148F,0x2070 or whatever, Write them down.
After Step 2 Follow These Steps:
Find usb_main_dev.c and Under #ifdef Section add the Following Line:
HTML:
{USB_DEVICE(0x148F,0x2070)}, /* Your Device name, this is just a Comment. */
Where You should replace 0x148F,0x2070 with the String you just wrote down.
And then Continue Other Steps and it should work.


Please Click "Thanks" Button if i Helped you
Also, if you had any Problems and fixed them Just tell me so i can add them to Troubleshooting Section.
 

iliass01

Senior Member
Feb 19, 2014
157
34
Hi! Im going on vacation in 2 weeks and I want this to work on my Nexus 5. I run CM12. I think I can manage the kernel part myself (there are a lot of nexus 5 kernels which include the driver of my wifi dongle: TP-Link WN722N). but I don't know how to do the next steps (for example step 4 and 5). Can someone give me a detailed tutorial with command lines? I am familiar with terminal.

My step again:
Nexus 5 running CM12
Wifi dongle: TP-Link WN722N

thanks in advance!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    I got fed up with crappy wireless reception in a hotel and decided to use my RTL8187 based Alfa USB wireless adapter with my Prime. Here's how it works, pretty rough and open to improvement but it works.

    1. Set up a chroot (ubuntu/debian will work); everything is done within that chroot
    2. Compile and install the drivers for your usb adapter (see the Kernel modules thread for instructions)
    3. apt-get install wicd-curses (or wicd-cli if you prefer), wpasupplicant and dbus plus any of its dependancies
    4. Turn off the broadcom wifi that's controlled by android
    5. insmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)
    6. start dbus and wicd (/etc/init.d/dbus start; /etc/init.d/wicd start)
    7. run wicd-curses (or wicd-cli), refresh the network list and connect to your network
    8. configure dns for android to your dns or to googles (setprop net.dns1 8.8.8.8)
    9. ???
    10. Profit

    To stop using external usb wifi, reverse the steps; basically:

    1. stop wicd and dbus (/etc/init.d/wicd stop; /etc/init.d/dbus stop)
    2. kill any running dhcp clients (killall dhclient)
    3. rmmod your modules (in my case eeprom_93cx6.ko, mac80211.ko, rtl8187)

    To be able to insert mac80211 without it complaining about missing symbols for ewma_init and ewma_add, I had to add lib/average.c to the mac80211 module; it's pretty simple, here's how i did that:

    1. Go to your prime kernel source tree (e.g. /usr/src/linux)
    2. cp lib/average.c net/mac80211/
    3. Edit net/mac80211/Makefile and add average.o to the list of objects for mac80211-y (don't miss the trailing backslash if you add it halfway)

    For simplicity sake I've added the modules for an rtl8187 based usb nic to this post. These are built against the 9.4.2.7 kernel source, and work fine for the 9.4.2.11 release (current ICS release as of Feb 07 2012).

    Oh and I don't recommend doing this with androids wifi turned on, it kind of breaks it until you reboot your tab. So if you're smart you'll script the above and spit out a nice warning that your broadcom module is still loaded and then exit. I had no problems switching between external USB wifi and built-in wifi as long as I only turned one of them on exclusively.

    Enjoy solid wifi on your prime :)
    4
    Explain to Kernel and Kernel Modules and how to build them

    For everyone who didn't Understand Step 2, I Will explain and tell you how to do that, Please read it all to Understand:highfive::

    What is Kernel?
    A Kernel is Simply a Bridge Between Software and Hardware.

    So The Drivers are Inside the Kernel itself?
    For Short, Yes. In Linux Overall (Android, Ubuntu, etc.), Drivers are Included Inside the Kernel it self, Some say for Performance Improvements.
    Your Phone's Android Kernel Include all the Drivers required for your phone to function, And for the Devices that Support USB-OTG there are a Plenty of Drivers Included, However, Drivers like the one's for the RTL8187 Most likely won't be included.


    What are Kernel Modules?
    Kernel Modules are Files that have *KO Extension That can be loaded Through insmod and Unloaded through rmmod Command-Line Commands, These files is to Extend the Functionality of the Kernel Without Touching/Editing it at all,It Just does some effect Until the Modules are Unloaded/Device Rebooted, Kernel Modules useful Either by Adding a Driver or by adding other things..[/B]

    What are the Disadvantages of Kernel Modules?
    Well, There's no Difference Expect you need to reload the Kernel Modules after a Reboot or Module Unload, Some Tutorials Show you how can you add a command to load these Modules after each boot up

    So A Kernel Module is the Solution for adding a driver without modifying the kernel?
    Yes, Kernel Modules is the Solution here, Each USB Device needs it's own Kernel Modules, so you can't Download a Module and Use it, You need to Compile yours.

    What is the Requirements to build a Kernel Modules?
    1.You need Linux Environment, Use either the Chrooted Linux On you phone, or, better use Ubuntu or any linux Distro on a Computer, Build the Module, and load it on the Chrooted Linux on your phone,

    2.You need an Internet Connection in the Linux Environment.

    3.You need the Driver Source code for your USB Device. Get them from the Manufacturer if he offer them, if he doesn't, You need to Look in the internet until you find one, if you were unable to find the Source code for you Device but found similar Devices Driver source code, see if the Other Device Driver is Compatible with yours usually a Single Driver work on many Devices, you need to look by your own way

    4.You Also need some Programs to install in Order to be able to Compile the Kernel Module, Enter these Commands in a Terminal, Pressing Enter after each Line, and make sure you have the Internet Connection:
    HTML:
    sudo apt-get install fakeroot
    sudo apt-get install build-essential
    sudo apt-get install dpkg-dev
    sudo apt-get install linux-headers-$(uname -r)

    For the most Important Part, make the Kernel Module?
    1.Unpack the Kernel source code, if it's Extension is bz2 then use:
    HTML:
    tar jxvf <package-name>
    Where <package-name> is the Compressed File name, and make sure you put it in the Home Folder, if it's Extension is gz or tgz the Unpack it with:
    HTML:
    tar zxvf <package-name>

    2. Second, Find config.mk and Open it with gedit or whatever Text editor you like, at first, there is two lines about WPA Support, make sure they end with y rather than n, Save and close.

    3.Third, and last, is to Compile the Kernel Module, Open Terminal and use cd command to get inside the folder that contains the Source code, and Simply Execute:
    HTML:
    sudo make
    And now you own the Kernel module, Now copy the Kernel Module to the root of your Internal Storage, Open up a Terminal and Type:
    HTML:
    cd /mnt/sdcard
    insmod <kernel-module-name>.ko
    And make sure Internal Wi-Fi is OFF and now your Kernel Module works, Follow the Guys steps to get it working on Chrooted distro



    Troubleshooting:
    If you find a similar Device Driver Source Code and after Compiling it doesn't work plug the Device in, Open a Terminal and type:
    HTML:
    sudo lsusb
    and Find your Device in the Output and you should find Numbers for it Looks Like 0x148F,0x2070 or whatever, Write them down.
    After Step 2 Follow These Steps:
    Find usb_main_dev.c and Under #ifdef Section add the Following Line:
    HTML:
    {USB_DEVICE(0x148F,0x2070)}, /* Your Device name, this is just a Comment. */
    Where You should replace 0x148F,0x2070 with the String you just wrote down.
    And then Continue Other Steps and it should work.


    Please Click "Thanks" Button if i Helped you
    Also, if you had any Problems and fixed them Just tell me so i can add them to Troubleshooting Section.
    2
    I just wanted to say THANKS! I now have my Alpha card working in Monitor mode on my TF300T Transformer PAD and man it feels good! I have never been able to get this to work and have been trying to use an external card in backtrack for a loooong time! Thank you 1 million times!
    1
    ,can you show screenshots of how much of an improvement it was using a USB wifi device vs. Stock wifi. You should relay this info in the kernel modules thread n SaturnDe can probably clean it up or simplify more or make it easier to implement. He could add it to his driver packs and make a new ATP tweaks version. For quick app enabling of this USB wifi method. This is very cool. I really would like to see how much of an improvement in reception thisngives.
    1
    You can't use the external wifi together with the android wifi control, it isn't compatible. So screenshots make no sense. This is why you need the chroot and wicd-curses; that's where you configure your wifi connection, not in android.

    As for the increase in reception, it depends on your usb adapter. If you have one with an external antenna that is 6 feet long, you can figure out how much of an improvement that would be. Nothing is stopping you from connecting an even bigger wifi antenna if you want. So, reception increase could be anywhere from a few dB up to long range 5km wifi using powerful long range antennas.