Ralink USB wifi dongle drivers + problem

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Ralink USB wifi dongle drivers + problem

Postby yobikap » Sun Nov 18, 2012 11:49 pm

I have compiled drivers for Ralink, this device supports up to 150mbps connection.

Image

I can load the driver via insmod without error, with iwconfig command, I can see the ra0 device, I have editted the wpa_supplicant.conf file:

wpa_supplicant.conf
from

Code: Select all

ctrl_interface=wlan0

to

Code: Select all

ctrl_interface=ra0


How do I attach this driver to the on/off switch in WiFi Settings, and how can I set this driver that it gets loaded at boot?

I already tried to edit init.rc file and inserted insmod /system/lib/modules/rt5370sta.ko , but this isn't working, on reboot the init.rc file gets restored, the same happends when I overwrite rkwifi.ko (as suggested in other thread) with rt5370sta.ko.

I hope someone can help me out, thanks.

NWolvie
Posts: 11
Joined: Wed Oct 17, 2012 7:17 pm

Re: Ralink USB wifi dongle drivers + problem

Postby NWolvie » Mon Nov 19, 2012 7:05 pm

yobikap wrote: I hope someone can help me out, thanks.


X2 :grin:

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Mon Nov 19, 2012 8:28 pm

The driver is working, but it is not connecting correctly to my router. Still trying to get this work :)

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Wed Nov 21, 2012 1:51 am

The driver for Ralink RT5370 is working quit well.

See the updated driver and RT2870STA.dat file along with a readme in the attachment.

You have to edit the RT2870STA.dat according with your own wireless connection settings, see readme file for what parameters you have to configure and what options you have to use.

These are my steps that I have done to get this to work:

first we will remount /system with rewrite permission

Code: Select all

$ mount -o remount,rw /system


copy the rt5370sta.ko to the lib folder by using adb

Code: Select all

adb push rt5370sta.ko /system/lib/modules/rt5370sta.ko


copy the RT2870STA.dat to the /system/etc/Wireless/RT2870STA/RT2870STA.dat (you have to create the folder Wireless and RT2870STA, it does not exist by default)

Code: Select all

$ cd /system/etc
$ mkdir Wireless
$ cd Wireless
$ mkdir RT2870STA
$ cd RT2870STA
$ cp /mnt/external_sd/RT2870STA.dat RT2870STA.dat


stop the current wlan interface

Code: Select all

$ ifconfig wlan0 down


after the above we will unload the wlan module

Code: Select all

$ rmmod wlan


connect your wifi device to the MK808

Now we will insert our module

Code: Select all

$ insmod /system/lib/module/rt5370sta.ko


initialize the wlan0 interface by bringing this up

Code: Select all

$ ifconfig wlan0 up


check if wlan0 has been up with netcfg

Code: Select all

$ netcfg


if the wlan0 is up, we will request a ip lease from the router with the following command:

Code: Select all

$ dhcpcd -d wlan0


If everything went okay, you can now use internet browser or youtube.

TODO (I need some help with this):
1. make this driver work with the settings UI
2. automatically load the driver at boot
You do not have the required permissions to view the files attached to this post.

bthoven
Posts: 57
Joined: Tue Oct 02, 2012 2:38 am

Re: Ralink USB wifi dongle drivers + problem

Postby bthoven » Wed Nov 21, 2012 2:43 am

Sorry, I don't know about Linux; but I'm now using an usb wifi 300Mbps with my MK808.

As you already have a working ko file, what I did are:

1. turn off wifi
2. copy rt5370sta,ko to /system/lib/module/
3. rename rkwifi.ko to other name, say, rkwifi.ko.bak
4. rename rt5370ta.ko to rkwifi.ko (also ensure you get the right permissions setting)
5. plug your usb wifi to mk808
6. turn on wifi

The wifi should work and see your access point ready to connect.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Wed Nov 21, 2012 8:35 am

I will try this when I am at home.

Do you know what permissions I have to set on rkwifi.ko after I have replaced this?

bthoven
Posts: 57
Joined: Tue Oct 02, 2012 2:38 am

Re: Ralink USB wifi dongle drivers + problem

Postby bthoven » Wed Nov 21, 2012 8:50 am

Sorry, I can't remember. Just follow what permissions are on the original rkwifi file.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Wed Nov 21, 2012 6:38 pm

I have tried, but could not get the driver work with the interface.

I pushed rt5370sta.ko file to /system/lib/modules/rkwifi.ko and chmod 644 on rkwifi.ko

This is my logcat message:
http://pastebin.com/ifgYEaRx

my dmesg outputs the following:
http://pastebin.com/YWU2QEeJ

I hope if someone could lead me to a direction so that I could get this driver to work with the UI Settings.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Thu Nov 22, 2012 8:05 am

I know what the problem is. The driver module boots succesfully at boot.

WPA_SUPPLICANT communicates with the driver via ioctl, because SIOCSIWPRIV is not in the sourcecode, the driver is not working via the GUI Settings of Android. I will try to get this driver work.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Thu Nov 22, 2012 8:51 am

Found a driver sourcecode with support for SIOCSIWPRIV for android.

https://github.com/Yobikap/rt5572/blob/ ... ta_ioctl.c

Forked from boundrydevices at https://github.com/boundarydevices/rt5572

I will compile this in the evening.

lukesan
Posts: 40
Joined: Fri Nov 09, 2012 5:24 am

Re: Ralink USB wifi dongle drivers + problem

Postby lukesan » Thu Nov 22, 2012 5:54 pm

yobikap wrote:Found a driver sourcecode with support for SIOCSIWPRIV for android.

https://github.com/Yobikap/rt5572/blob/ ... ta_ioctl.c

Forked from boundrydevices at https://github.com/boundarydevices/rt5572

I will compile this in the evening.



Very much interested in it since it seems I bought exactly the same on ebay tonight

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Sat Nov 24, 2012 6:16 pm

Logcat reports the following problem:

Code: Select all

I/ActivityManager(  261): No longer want com.google.android.apps.maps:FriendService (pid 916): hidden #16
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiStateMachine(  261): Failed to setup control channel, restart supplicant
D/CommandListener(   90): Setting iface cfg
D/CommandListener(   90): Trying to bring down wlan0
E/WifiHW  (  261): Unable to open connection to supplicant on "wlan0": No such file or directory
I/wpa_supplicant( 1067): rfkill: Cannot open RFKILL control device
E/wpa_supplicant( 1067): nl80211: Could not configure driver to use managed mode
E/wpa_supplicant( 1067): wlan0: Failed to initialize driver interface
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiHW  (  261): Supplicant not running, cannot connect
E/WifiStateMachine(  261): Failed to setup control channel, restart supplicant
D/CommandListener(   90): Setting iface cfg
D/CommandListener(   90): Trying to bring down wlan0
I/wpa_supplicant( 1071): rfkill: Cannot open RFKILL control device
E/wpa_supplicant( 1071): nl80211: Could not configure driver to use managed mode
E/wpa_supplicant( 1071): wlan0: Failed to initialize driver interface


When i check iwconfig, the wlan0 is active and with commands, I can still connect to the device.

When I compile the driver with CFG80211 option enabled in config.mk, the driver compiles succesfully, but after inserting the device I am getting the following error in dmesg:

Code: Select all

rt5370sta: Unknown symbol malloc_sizes (err 0)


My knowledge stops here. I hope someone could help me to get this driver working with the wpa_supplicant.

The code can be found here:

https://github.com/Yobikap/rta5370sta.git

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Sun Nov 25, 2012 11:54 am

I have modified the boot image (I have to repack it), after the test it will tell me if the ralink rt5370 wifi will work or not.

My hopes are now really high now.

I have changed in init.rk30board.rc

Code: Select all

service wpa_supplicant /system/bin/wpa_supplicant \
    -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf


to

Code: Select all

service wpa_supplicant /system/bin/wpa_supplicant \
    -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf


By using the parameter -Dwext form commandline, wpa_supplicant tries to boot ralink driver, but fails because it gets permission denied on the /etc/Wireless/RT2870STA/RT2870STA.dat file.

Code: Select all

wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Mon Nov 26, 2012 6:43 am

There has been a progress to get this driver working. I made modification to the parameter how wpa_supplicant connects to the driver as mentioned in my previous post.

The Settings GUI connects to the driver, but it is still not showing any networks to connect.
When using from terminal, I am able to find networks:

Code: Select all

iwlist wlan0 scan

lukesan
Posts: 40
Joined: Fri Nov 09, 2012 5:24 am

Re: Ralink USB wifi dongle drivers + problem

Postby lukesan » Mon Nov 26, 2012 11:26 am

Hi yobikap, just received mine in the mailbox.

Let me know on the progress you are making and how we can actually get it up and running. There is a catch 22 here that if we disable the internal wifi we might have to reflash the device to get wifi working again.

So my understanding is that we need to get all the drivers into a temp folder and for the sake of security copy all of the working internal drivers and files to another temp dir on the internal storage space so in case it goes wrong we can copy them back without having to installing the rom again.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Mon Nov 26, 2012 10:02 pm

Thanks for the interrest lukesan.

Today I have flashed the device more than 10 times. I have made changes to init.rc (boot.img), wpa_supplicant.conf and added the module to the system as standard.

Lets cross the fingers and hope that we can get this wifi device working soon.

abid123
Posts: 5
Joined: Mon Oct 08, 2012 7:37 am

Re: Ralink USB wifi dongle drivers + problem

Postby abid123 » Tue Nov 27, 2012 1:13 pm

Hi I would very much appreciate if you can help me get my usb wifi working on my MK808. It uses the Realtek RTL8191SU chipset. Please can you compile a .ko file for me and give me instructions on how to get it working on MK808. I would very much appreciate it. I use Windows 7 so Im not familiar with linux. Please get back to me asap.
Thanks

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Wed Nov 28, 2012 1:06 am

See the attachment for the drivers.

The driver is okay now. it registers itself now as "wlan" module.

You have to place the rt2870.bin into /system/etc/firmware .
You have to create the folder structure: /system/etc/Wireless/RT2870STA/ , and place RT2870STA.dat file in this folder.
Place the rt5370sta.ko in the /system/lib/modules folder as rkwifi.ko

In init.rk30board.rc you have to change the following:

Code: Select all

service wpa_supplicant /system/bin/wpa_supplicant \
    -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16a ++
    #wlf16a -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16 ++
    #wlf16 -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
    #-Dnl80211 -iwlan0 -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin
    #   we will start as root and wpa_supplicant will switch to user wifi
    #   after setting up the capabilities required for WEXT
    # user wifi
    # group wifi inet keystore
    group system wifi inet keystore
    class main
    socket wpa_wlan0 dgram 660 wifi wifi
    disabled
    oneshot


into

Code: Select all

service wpa_supplicant /system/bin/wpa_supplicant \
    -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16a ++
    #wlf16a -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16 ++
    #wlf16 -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
    #-Dnl80211 -iwlan0 -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin
    #   we will start as root and wpa_supplicant will switch to user wifi
    #   after setting up the capabilities required for WEXT
    # user wifi
    # group wifi inet keystore
    class main
    socket wpa_wlan0 dgram 660 wifi wifi
    disabled
    oneshot


There is one issue to be solved, when turning on/off button in the Settings GUI, logcat spits a lot of error messages such as, wpa_supplicant cannot connect etc etc.

when using adb shell with the following command, it successfully connects and the error messages disappears:

Code: Select all

/system/bin/wpa_supplicant -iwlan0 -Dwext -c/data/misc/wifi/wpa_supplicant.conf -d


We can still not use Settings GUI. But we are closer to get this working.
You do not have the required permissions to view the files attached to this post.

AndrewDB
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: Ralink USB wifi dongle drivers + problem

Postby AndrewDB » Wed Nov 28, 2012 9:30 am

yobikap wrote:I have compiled drivers for Ralink, this device supports up to 150mbps connection.

Image

I can load the driver via insmod without error, with iwconfig command, I can see the ra0 device, I have editted the wpa_supplicant.conf file:

wpa_supplicant.conf
from

Code: Select all

ctrl_interface=wlan0

to

Code: Select all

ctrl_interface=ra0


How do I attach this driver to the on/off switch in WiFi Settings, and how can I set this driver that it gets loaded at boot?

I already tried to edit init.rc file and inserted insmod /system/lib/modules/rt5370sta.ko , but this isn't working, on reboot the init.rc file gets restored, the same happends when I overwrite rkwifi.ko (as suggested in other thread) with rt5370sta.ko.

I hope someone can help me out, thanks.


Hi yobikap, I'll try to help here in this thread.
First, let me say that I have exactly the same WiFi dongle working in Linux on the UG802, so it should be possible to make it work in Android too, it's just a matter of compiling/installing/configuring the thing! :)
What stage are you at and what problems do you have?

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: Ralink USB wifi dongle drivers + problem

Postby yobikap » Wed Nov 28, 2012 10:04 am

Hi AndrewDB,

Thanks for helping me out in this.

I have compiled the rt5572 drivers as following:

Code: Select all

make ARCH=arm CHIPSET=5370


Modified Makefile6 in os/linux, and set the MOD_NAME as "wlan", so that the Android framework can trigger this module from settings UI.

I tried to turn on the CFG80211 setting, but the compilation failed, by implicit declaration of function, I will post the message later on.

The driver is working (without CFG80211), from the command line, also whenever I start wpa_supplicant from commandline with the following option:

Code: Select all

/system/bin/wpa_supplicant -iwlan0 -Dwext -c/data/misc/wifi/wpa_supplicant.conf


This command starts succesfully, when I try to run this as a service in init.rk30board.rc , it gives errors in logcat such as: wpa_supplicant_driver_wext_cmd (-1): MACCADDR failed and 4 other error messages (I will upload the logcat message later on).

In init.rk30board.rc I have replaced the -Dnl80211 to -Dwext in the following part:

Code: Select all

service wpa_supplicant /system/bin/wpa_supplicant \
    -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16a ++
    #wlf16a -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf #wlf16 ++
    #wlf16 -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
    #-Dnl80211 -iwlan0 -puse_p2p_group_interface=1 -e/data/misc/wifi/entropy.bin
    #   we will start as root and wpa_supplicant will switch to user wifi
    #   after setting up the capabilities required for WEXT
    # user wifi
    # group wifi inet keystore
    class main
    socket wpa_wlan0 dgram 660 wifi wifi
    disabled
    oneshot


When the device starts, I am getting error that it could not read wlan0, because of no such file or directory.

I think this is a permission issue.

When I turn on the wifi in Settings GUI, the button goes spontanly to on/off and it will loop to try. The module gets unloaded and loaded (it hangs in a loop).


Return to “Development”

Who is online

Users browsing this forum: No registered users and 4 guests