# Finished: CALL FOR TESTERS Ralink wireless run(4) usb driver for FreeBSD



## PseudoCylon (Oct 7, 2009)

-- Update on Jan 29, 2010 --

The run(4) driver has been committed to FreeBSD 9-CURRENT.

The driver works with
RT2700U == RT2770 MAC/BBP + RT2720 (1T2R) or RT2750 (dual-band 1T2R) radio
RT2800U == RT2870 MAC/BBP + RT2820 (2T3R) or RT2850 (dual-band 2T3R) radio
RT3000U == RT3070 MAC/BBP + RT3020 (1T1R), RT3021 (1T2R) or RT3022 (2T2R) single-band radio
list of known devices are posted at thread #3


For the 11n support, try following driver. (Due to multiple updates in 80211 stack, 11n support is only available in HEAD or 9 RELEASE)

*for 9-RELEASE* rev 225013 or newer, and 10-CURRENT
11n_rc3


For older version (before being committed to the tree) try followings.

*for 8.2-RELEASE*
The driver is included.

*for 8.1-RELEASE* and 9-CURRENT older than rev 211314
8.1_REL

*for 8.0-RELEASE users*
8.0_REL_eos,
or run-8.0-REL_final.tar.bz2 << You can click this.
Support for this release has been ended. Please upgrade to 8.1 if practical.

*[NB]*
Under heavy traffic, Tx may stall. If you experience this issue, please apply patches for EHCI-hangs.
You need to re-build kernel, but with KERNFAST,`# make buildkernel KERNCONF=[i]YOUR_CONF[/i] KERNFAST=1`
it should take only a few minutes.
Patched files, sys/dev/usb/controller/ehci.h and sys/dev/usb/controller/ehci.c, are included in 8.1_REL version.

If you are setting up AP with 8.2-PRERELEASE, apply this patch, or panic.
http://svn.freebsd.org/viewvc/base?view=revision&revision=217511


*for 7.2 users* View attachment run-7.2_final.tar.bz2 << You can click this.
The final version
I have upgraded all my boxes to 8.0 or CURRENT, so I cannot do anything for 7.2 driver. "Final" means no more update, not complete. But it supports STA mode and h/w encryption. Hope this is good enough until upgrading to 8.

Thank you for testing and reporting problems.

-- Followings are original post. Left it here for log purpose --
Hello every one!

I'm porting run (ru'N' not ru'M') driver View attachment run.tar.bz2, and I've made it work (-encryption). Actually, I'm posting this by using that driver. You can find a list of supported devices here.
http://www.openbsd.org/cgi-bin/man....anpath=OpenBSD+Current&arch=amd64&format=html

It hasn't support encryption yet and has some issues, but I thought it is better than nothing and decided to share. If anyone want to try it out, download tar ball and read README in it.

I'm planning to make encryption work. But, I am an ex-MECHANICAL engineer and I installed very first FreeBSD little over a year ago. So, don't expect too much. It will take several weeks. Or, you can help me out.


-- updated on Nov 10, 2009 --
Now, the driver for CURRENT (and 8 RC) is available at thread #28 (One posted here is for 7.)

-- updated on Nov. 28, 2009 --
-- FIX -- FIX -- FIX -- View attachment run-fix.tar.bz2
Some packet loss/drop and memory leak were identified and fixed. (The perfomance has been improved, too.) Details are on RELEASE_NOTES included.

For those wondering about HOSTAP support, here is the word from the original author. (If you don't know who he is, check how many wireless drivers he has written.)
http://old.nabble.com/Re:-Linksys-WUSB600N-and-Access-Point-p21332878.html
I was looking forward to HOSTAP mode by myself. I might play with it, but don't hope for miracles.


----------



## lme@ (Oct 7, 2009)

Thanks for your work! 
Please also file a PR with the new driver and send a mail to current@freebsd.org so it can be rewviewed by a few developers.


----------



## PseudoCylon (Oct 8, 2009)

Thanks for your comment. I'll do that.

I'm not only new to FreeBSD, but new to whole open source stuff. Applicate for info on right procedure.


----
Following is just for a search optimization.
I thought people most likely search with the product's name.

     The driver should work with following adapters:

           Airlink101 AWLL6090
           ASUS USB-N11
           ASUS WL-160N
           Belkin F5D8051 ver 3000
           Belkin F5D8053
           Belkin F5D8055
           Belkin F6D4050 ver 1
           Buffalo WLI-UC-AG300N
           Buffalo WLI-UC-G300N
           Buffalo WLI-UC-GN
           Corega CG-WLUSB2GNL
           Corega CG-WLUSB2GNR
           Corega CG-WLUSB300AGN
           Corega CG-WLUSB300GNM
           D-Link DWA-130 rev B1
           D-Link DWA-140
           DrayTek Vigor N61
           Edimax EW-7711UAn
           Edimax EW-7711UTn
           Edimax EW-7717Un
           Edimax EW-7718Un
           Gigabyte GN-WB30N
           Gigabyte GN-WB31N
           Gigabyte GN-WB32L
           Hawking HWDN1
           Hawking HWUN1
           Hawking HWUN2
           Hercules HWNU-300
           Linksys WUSB54GC v3
           Linksys WUSB600N v1 and v2
           Mvix Nubbin MS-811N
           Planex GW-USMicroN
           Planex GW-US300MiniS
           Sitecom WL-182
           Sitecom WL-188
           Sitecom WL-301
           Sitecom WL-302
           Sitecom WL-315
           SMC SMCWUSBS-N2
           Sweex LW303
           Sweex LW313
           Unex DNUR-81
           Unex DNUR-82
           ZyXEL NWD210N
           ZyXEL NWD270N

The driver supports following Ralink chipsets.
RT2700U == RT2770 MAC/BBP + RT2720 (1T2R) or RT2750 (dual-band 1T2R) radio
RT2800U == RT2870 MAC/BBP + RT2820 (2T3R) or RT2850 (dual-band 2T3R) radio
RT3000U == RT3070 MAC/BBP + RT3020 (1T1R), RT3021 (1T2R) or RT3022 (2T2R) single-band radio


--update Jan 29, 2010--
An experimental status on WUSB600N v2 bas been lifted. Thank you for every one taking risks for testing the driver.
-- updated on Jan 09, 2010 --
A support for WUSB600N v2 has experimentally been added to current driver. Please see the first post for details.
-- added on Dec 02, 2009 --
*1) For Linksys WUSB600N, they now have ver. 1 (plain rectangular shape) and ver. 2 (wedge like shape). Since they have different driver for each version, if_run most likely won't work with ver.2.


----------



## ivoras@ (Oct 10, 2009)

*Hostap?*

Hi,

I occasionally have the need for an AP-supporting USB WiFi device, and I've had bad experiences with rum. 

Do run devices and the driver properly support the AP mode?


----------



## PseudoCylon (Oct 11, 2009)

Hello ivoras,

Unfortunately, no. The device doesn't support for a hostap mode (no beacon tx by h/w).


--update--
I'll move on to CURRENT since that's where the actions are. Everything might work well fine on 8 as well. Stay tuned.

Happy thanks giving.
(It is a thanks giving weekend in Canada.)


----------



## Eyemaster (Oct 15, 2009)

great to see that this driver is being ported! good work
can't wait to test the driver...

firmare compiles fine but I can not compile the src under 9-current

Have you already made the jump to 9-current? I cannot compile it successful under current release


----------



## NAC (Oct 16, 2009)

finally, I saw the light, Been looking for this driver for Freebsd long time.. hopefully could get it worked on 7-stable.keep waiting it updates

thanks a lot....


----------



## egorenar (Oct 16, 2009)

PseudoCylon said:
			
		

> Hello ivoras,
> 
> Unfortunately, no. The device doesn't support for a hostap mode (no beacon tx by h/w).
> 
> ...



I'm sure that rt2870 chip supports transmition of beacons in h/w
because i know the linux reference driver very good and
it works on linux. I think rt2860 supports sending of beacons
because rt2860 openbsd driver supoorts HOSTAP mode.


----------



## PseudoCylon (Oct 16, 2009)

Hello,

All answers in one post.

cannot compile under current 9
It shouldn't. The driver I posted is for 7.2 release. That's why I'm porting it to current at this moment.

HOSTAP mode
I checked their codes, and I've found out that openbsd's PCI based RT2860 chipset driver does support HOSTAP mode. But, for some reason, it is committed from if_run. Both drivers were written by the same person, so I guess HOSTAP mode doesn't work on usb dongle. But, I will give it a shot and see what's gonna happen.

waiting for updates...
There are big changes in ieee80211 and usb stack between 7 and 8. So, it is a quite job on re-writing a driver for usb wireless adapters. And I haven't made current working. (first compiled current kernel failed to boot.) It will take a while. So, stay tuned.


----------



## egorenar (Oct 16, 2009)

PseudoCylon said:
			
		

> Hello,
> 
> All answers in one post.
> 
> ...



rt2870 supports sending of beacons in h/w because the reference driver from Ralink for linux uses this feature. Furthermore,
beacon sending is also necessary for IBSS mode.


----------



## egorenar (Oct 24, 2009)

cool, WEP is working now with freebsd 7.2


----------



## egorenar (Oct 24, 2009)

I have tested WEP with Linksys WUSB600N.
Now i want to implement WPA and WPA2.


----------



## NAC (Oct 24, 2009)

egorenar said:
			
		

> cool, WEP is working now with freebsd 7.2



oh, that's a good news, what driver did you use? if_run usb driver ? or another one? thanks


----------



## egorenar (Oct 25, 2009)

NAC said:
			
		

> oh, that's a good news, what driver did you use? if_run usb driver ? or another one? thanks



nope, i implemented my own driver.
i'm currently learning on my own how wlan and 802.11 stack works.


----------



## PseudoCylon (Oct 25, 2009)

egorenar said:
			
		

> cool, WEP is working now with freebsd 7.2



Cool! How did you do it?


Update
The if_run driver has been compiled on current. Hunting for bugs.


----------



## egorenar (Oct 25, 2009)

PseudoCylon said:
			
		

> Cool! How did you do it?
> 
> 
> Update
> The if_run driver has been compiled on current. Hunting for bugs.



Where do you have problems with WEP ?

I had also big problems with WEP at the beginning.

The following things are important:

* Install WEP key in both key tables (shared and pairwise),
because if you install it only in pairwise you won't be able
to receive multicast and broadcast packets, and dhclient will not work !!!

* After you received an packet in your rx interrupt that was decrypted by hardware (flag in rx desc), you should set M_WEP flag in the variable m_flags of mbuf, because net80211 will silently drop data packets decrypted by hardware if you do not do it.

I figured it out by myself through reading the net80211 code 
Some documentation will be helpful.

* And you should install new key only after the association was successfull, because if you install a WEP key before an association, you won't have valid WCID !!!

I hope it can help you.

If you have specific questions then don't hesitate ans ask me,
i will try to help you.

I'm currently working on AES-CCMP.


----------



## PseudoCylon (Oct 26, 2009)

Sounds like M_WEP flag was what I needed.


----------



## egorenar (Oct 26, 2009)

I'm currently testing AES-CCMP, i'm able to receive and decrypt multicast and brooadcast packets but it seems that the AP don't
understand my unicast packets to it :-(


----------



## NAC (Oct 27, 2009)

howto document available ? 
I really want to get my Ralink RT2870 worked.
thanks


----------



## egorenar (Oct 27, 2009)

AES-CCMP still doesn't work.
I'm currently developing a driver for rt2860 PCI card (only monitor mode) from Linksys so i can sniff packets coming from rt2870 USV card and analyze it
on freebsd.


----------



## joel@ (Oct 27, 2009)

PseudoCylon / egorenar: Make sure you post patches somewhere, so that users/developers can test your drivers.


----------



## egorenar (Oct 27, 2009)

joel@ said:
			
		

> PseudoCylon / egorenar: Make sure you post patches somewhere, so that users/developers can test your drivers.



I will post my driver as soon as AES-CCMP and/or TKIP will work.
Till now only WEP does work. I will try to make it work till the end of this week.


----------



## PseudoCylon (Oct 28, 2009)

Be patient! FreeBSD newbie + ex-mechanical engineer is working here.

When I get it to work, members of this forums will be the first ones to know it.

Condition of the driver for current is now upgraded from crashing like windows to receiving frame.

Here is my plan
1) make driver for current work
2) fix driver for 7.2 (I bet egorenar will do it before I finish off one for current.) But, things didn't go as I expected. So, I made fix by myself. Please see the first post for update. (added on Jan 09, 2010)
3) port it to 8.0


Sorry NAC, src code is the only thing I have.


			
				NAC said:
			
		

> howto document available ?
> I really want to get my Ralink RT2870 worked.
> thanks


----------



## Eyemaster (Oct 28, 2009)

Indeed, we should be patient.

I get the impression that a lot of progress is being made  and that we can test it soon on our own hardware.

I also get the impression that the development of the driver is turning into a race/competition between PseudoCylon and egorenar. Although competition is not necessarily a bad thing, I think more and faster progress can be made in this case by working together.

Keep u the good work, guys !


----------



## egorenar (Oct 29, 2009)

Good news, guys !!!
AES-CCMP is finally working with wpa_supplicant !!! 
I'm currently surfing with it !!!
TKIP is still not working properly.

I implemented rt2860 driver (only monitor mode) and could
analyze with it packets sent by rt2870 chip. It helped me to find a bug in my driver.
I have 2 NICs, Linksys WUSB600N with rt2870 chip and Linksys WMP600N with rt2860 chip.

Next i will try to make TKIP work and then 802.11n.

:e :e :e


----------



## egorenar (Nov 2, 2009)

TKIP is working now !!!

:e :e :e


----------



## egorenar (Nov 2, 2009)

But i still have problems with WME (QoS).
Trying to fix it.

The driver for rt2860 chip is also working now in monitor mode and very stable.
It helps me a lot to test my rt2870 chip driver.


----------



## PseudoCylon (Nov 8, 2009)

*if_run for CURRENT update*

Hello everyone!

if_run for CURRENT update

Here are good news and bad news.

The bad news is I've been working on h/w encryption for almost a week but I have no idea what's wrong. (I cannot write keys onto h/w; usb kicks me out.) I don't know how long it will take to fix it.

The good news is I added s/w encryption and it works with wep, wpa 1/2.

I haven't installed X on current yet, so I couldn't test too much, only ping and fetch. But, it should work fine under STA mode. Please read README included.

I added provable code for h/w beacon. If you are brave, you can try it out. (I haven't tested it by myself yet.)

And here is another bad news. It's 3 o'clock in the morning! Gaaa, I gotta go bed.


-- updated on Nov. 28, 2009 --
Fix has been released and available at the very first thread


----------



## Eyemaster (Nov 9, 2009)

unfortunately, your driver results in kernel trap when I plug in the hercules HWNUm-300 mini  (also when I define SIX in if_runvar.h)

I added product ID 0x031 to usbdevs and compiled your driver.
when I load if_run kernel trap occurs

any idea for a fix?

GUILLEMOT HERCULES <0x06f8>
HWNUm-300 PRODUCT 0xe031
http://www.hercules.com/uk/wifi/bdd/p/104/hercules-wireless-n-usb-mini-hwnum-300-/


----------



## Eyemaster (Nov 9, 2009)

I thought that HWNUm-300 had the RT2870 chipset, but I might be wrong...


----------



## PseudoCylon (Nov 9, 2009)

Eyemaster said:
			
		

> unfortunately, your driver results in kernel trap when I plug in the hercules HWNUm-300 mini  (also when I define SIX in if_runvar.h)
> 
> I added product ID 0x031 to usbdevs and compiled your driver.
> when I load if_run kernel trap occurs
> ...



Hi Eyemaster, Thank you for trying out the driver.

I think HWNU-300 and HWNUm-300 uses different chipset. They have different windows diver for each products.

But, when it panic, you see a messeg;
run0: could not allocate USB transfers, err=USB_ERR_NO_PIPE
try replace lines from 349 to 414 (inclusive) with followings

```
static const struct usb_config run_config[RUN_N_XFER] = {
    [RUN_BULK_TX_BE] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.ep_index = 0,
	.direction = UE_DIR_OUT,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
    [RUN_BULK_TX_BK] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_OUT,
	.ep_index = 1,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
    [RUN_BULK_TX_VI] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_OUT,
	.ep_index = 2,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
    [RUN_BULK_TX_VO] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_OUT,
	.ep_index = 3,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
#ifdef SIX
    [RUN_BULK_TX_HCCA] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_OUT,
	.ep_index = 4,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
    [RUN_BULK_TX_PRIO] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_OUT,
	.ep_index = 5,
	.bufsize = RUN_MAX_TXSZ,
	.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
	.callback = run_bulk_tx_callback,
	.timeout = 5000,
    },
#endif	/* SIX */
    [RUN_BULK_RX] = {
	.type = UE_BULK,
	.endpoint = UE_ADDR_ANY,
	.direction = UE_DIR_IN,
	.bufsize = RUN_MAX_RXSZ,
	.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
	.callback = run_bulk_rx_callback,
    }
};
```

- Warning - Warning - Waring -
Forcing to run a device with wrong driver sounds very bad to me. Please make sure your device has the right chipset, before attempting.

Also, defining SIX causes more trouble. Undef SIX. When everything works, then define SIX and see if it works.


----------



## eMxyzptlk (Nov 9, 2009)

I'm running 8-RC2 (amd64), I just finished installing it actually

I can't kldload if_run


```
# kldload if_run
kldload: can't load if_run: Exec format error
```

but I didn't get any warnings/errors while compiling, any ideas ?


----------



## eMxyzptlk (Nov 9, 2009)

I forgot to tell you what I have in dmesg when the error above occurs


```
link_elf_obj: symbol _mtx_assert undefined
linker_load_file: Unsupported file type
```


----------



## PseudoCylon (Nov 9, 2009)

Hello eMxyzptlk,

It is for CURRENT 9, so might not work on 8 RC.

But try this: change the last line of if_runvar.h,
#define RUN_LOCK_ASSERT(sc, t)	mtx_assert(&(sc)->sc_mtx, t)
to

```
#define RUN_LOCK_ASSERT(sc, t)	(void)0
```

Again it shouldn't work on 8 RC. If it doesn't work wait 'till I port it to 8. If it works, I won't have to port. Lucky me.

If it works, next time compiling custom kernel, adding options "INVARIANTS" AND "INVARIANT_SUPPORT" (or removing both) in kernel config file (and compile kernel) should fix the problem.

Please let me know how it goes.


----------



## eMxyzptlk (Nov 10, 2009)

Hey,

i just tried that patch, it compiled okay, loaded kay, but when I tried to set the country to FR

```
# ifconfig run0 country FR
ifconfig: unable to get regulatory domain info: invalid argument
```
nothing in dmesg..

Next I tried to put the device up, the pc hanged for couple of seconds and it rebooted.

Next I tried to put the device up


----------



## eMxyzptlk (Nov 10, 2009)

I was able to get you a screenshot of the panic

http://twitpic.com/oz0ed


----------



## PseudoCylon (Nov 10, 2009)

Try this.

```
#kldload if_run
#ifconfig wlan create wlandev run0
#ifconfig wlan0 country FR
```
wlan thing is new to 8. Once you create wlan0, use wlan0 instead of run0, i.e ifconfig wlan0 ssid xxxx, ifconfig wlan0 up, etc. You only need to use run0 when creating wlan.
To unload, do

```
#ifconfig wlan0 down
#ifconfig wlan0 destroy
#kldunload if_run
```
or you can just turn off the computer.

And please check if FR is listed in

```
#ifconfig wlan0 list countries
```
after ifconfig wlan create wlandev run0 if you haven't done so.


----------



## eMxyzptlk (Nov 10, 2009)

That actually worked, but the driver is really unstable, I was able to associate with an open ssid, and I tried pinging another PC wired, I got 70% loss..

What next?

P.S: I have the same chip as you (WUSB54GC ver.3)


----------



## eMxyzptlk (Nov 10, 2009)

Forget what I said, I'm actually browsing with it now..

Earlier I tried to connect to the FreeWifi Hotspot (If you don't know what it is, it is an access point broadcasted by every Freebox ( http://www.free.fr ) allowing people with a free connection to browse the Net wherever they go.. Somehow that did not work, but I brought back my stored wifi access point and setup it to broadcast an open wifi with MAC Filtering, it works like a charm this way.

I need to first learn how to use WPA with FreeBSD and I then will try with the main access point currently broadcasting a WPA-PSK protected wifi, I'll tell you what happens next..


----------



## PseudoCylon (Nov 10, 2009)

That's good.

I guess it was an environmental issue. There are bunch of gadget emitting 2.4ghz band these days. I checked other driver and code for 8 and 9 are identical.

Once you write a config file just run
`# wpa_supplicani -B -i wlan0 -c 'your_config_file'`
after setting country code. It should work.

P.S.
At the time of writing, WUSB54GC is not compatible with windows 7. (Lincsys has only released drivers for more expensive devices like WUSB600N.) FreeBSD is truly windows incapable!


----------



## Eyemaster (Nov 11, 2009)

This might be a bit off topic but maybe useful so...

I got a official confirmation about chipset in HWNum-300 from Hercules:
"We inform you that the chipset of the USB N mini key HWNUm-300 is Realtek RTL8192SU."

This means that in contrast to Hercules prod ID 0x0e30 HWNu-300 with the RT2870 chipset, Hercules prod ID 0x0e31 HWNum-300 contains the RTL8192SU chipset.

@PseudoCylon : So, you can now ignore my reports about your driver

Anyone working on a FreeBSD driver for the RTL8192SU chipset, by any chance?

I think there is already a driver for RTL8192SU under linux :
http://www.linuxhq.com/kernel/file/drivers/staging/rtl8192su/index.html


----------



## egorenar (Nov 11, 2009)

Good news, guys.
QoS(WME) is finally working with rt2870 chip.
It was an important step towards 802.11n because
QoS is mandatory in 802.11n !!!


----------



## gnoma (Nov 16, 2009)

> I implemented rt2860 driver (only monitor mode) and could
> analyze with it packets sent by rt2870 chip. It helped me to find a bug in my driver.
> I have 2 NICs, Linksys WUSB600N with rt2870 chip and Linksys WMP600N with rt2860 chip.



egorenar sorry for the question but how did you install WMP600N ???
I am using FreeBSD 7.2  and I still can't install that card. Tryed with this driver but noting happens...
pls it you have a time check this topic http://forums.freebsd.org/showthread.php?t=8391
Thank you


----------



## egorenar (Nov 16, 2009)

gnoma said:
			
		

> egorenar sorry for the question but how did you install WMP600N ???
> I am using FreeBSD 7.2  and I still can't install that card. Tryed with this driver but noting happens...
> pls it you have a time check this topic http://forums.freebsd.org/showthread.php?t=8391
> Thank you



Hi,

if_run driver does not support rt2860 chip, it is an USB driver.
WMP600N is a PCI card !!!

I have implemented my own driver for WMP600N. WMP600N has rt2860 chip. My driver is not complete yet, i use it only in monitor mode, that means it can only receive packets but not send yet, but you can use it for example with wireshark without any problems.
Currently, i' m working on 802.11n mode for rt2870 chip and use
WMP600N to analyze packets which are sent by WUSB600N.

It's not difficult to implement sending packets for WMP600N,
i guess i can make it work in a weekend or so. But currently,
i'm concentrating on WUSB600N. I planned to finish WMP600N
driver later. I will try to implement packet sending for WMP600N
on this weekend if i have time.

I myself find WMP600N better than WUSB600N. It has 2 large antennas and is easier to program than USB driver.

I can provide you with my rt2860 driver for WMP600N if you want. It works only on FreeBSD 7.2.

:e :e :e


----------



## gnoma (Nov 16, 2009)

I'll be very grateful if you provide this driver
I am planing to use this card as AP in my office but I'll not use any encription... hope it works 
thank you.


----------



## egorenar (Nov 16, 2009)

gnoma said:
			
		

> I'll be very grateful if you provide this driver
> I am planing to use this card as AP in my office but I'll not use any encription... hope it works
> thank you.



Here is the driver.
As i said earlier, now only monitor mode is implemented.
Packet sending is not supported yet, but you can sniff WLAN
with wireshark.

How to use:

1. Extract the archive


```
$ tar xvjf rt2860_fbsd72.tar.bz2
```

2. Change into the extracted directory and execute "make"


```
$ cd rt2860_fbsd72
$ make
```

3. Now load the kernel module (as root !!!)


```
# kldload ./rt2860.ko
```

4. Now you should be able to see the NIC rt28600


```
$ ifconfig
```


In case you have problems with my driver, don't hesitate to contact me.


----------



## gnoma (Nov 23, 2009)

Thank you egorenar you are the men!!!
I'll test tomorrow at the work place. And I realy hope u finish the full driver with no problems... Don't meen to rush you if it sounds like that  but I have realy no more options and you bring me a hope!  If it works well you are my personal jesus 
Thank you very much.


----------



## hellevil (Nov 23, 2009)

RT2770F support this driver ?


----------



## egorenar (Nov 25, 2009)

hellevil said:
			
		

> RT2770F support this driver ?



Hi,

please test this driver and provide feedback.

Thanks.


----------



## gnoma (Nov 26, 2009)

```
# ifconfig rt28600 up scan
SSID            BSSID              CHAN RATE   S:N     INT CAPS
D-link          00:19:5b:54:cc:c2    6   54M -88:-95  119 EP   WPA
CHVHOME         00:1a:70:9d:62:0e    9   54M -89:-95  100 EP   WPA
belkin54g       00:17:3f:44:32:30   11   54M -89:-95  100 EP   WPA
BTC-ADSL        00:1e:73:59:5d:bf    3   54M -88:-95  100 E
```

It works great 
Thank you 
YOU ARE THE MAN!!!
I guess I can not connect any network with this driver or make an AP.(AP is the target idea)
So I can't wait for the fill driver  I am sure it will be something great.

Thank you egorenar 
YOU ARE THE MAN!!!


----------



## egorenar (Nov 27, 2009)

gnoma said:
			
		

> ```
> # ifconfig rt28600 up scan
> SSID            BSSID              CHAN RATE   S:N     INT CAPS
> D-link          00:19:5b:54:cc:c2    6   54M -88:-95  119 EP   WPA
> ...



Thanks, but please be patient with me, i have not much time now for this driver but i promise to continue my work.


----------



## gnoma (Nov 27, 2009)

OK dude  sorry I don't meen to rush you.
And... about that driver I don't know is it normal and do I have to make more settings about that, but when I restart my PC and type ifconfig that wi-fi card was not in the list.
Is it a driver bug or I just didn't make some settings I should do?? I don't know I just install the driver and didn't touch nothing else.


----------



## PseudoCylon (Nov 28, 2009)

Hello everyone,

A fix have been released for the driver for 8.0 RELEASE and CURRENT. There were some packet loss/drop and mem leak. (The fix improves some performance too.)

Also, 40 more vender/device IDs have been added.

Get it here




			
				gnoma said:
			
		

> OK dude  sorry I don't meen to rush you.
> And... about that driver I don't know is it normal and do I have to make more settings about that, but when I restart my PC and type ifconfig that wi-fi card was not in the list.
> Is it a driver bug or I just didn't make some settings I should do?? I don't know I just install the driver and didn't touch nothing else.


@gnoma

Since I'm here.
Yes, you need to make more settings. If you want the driver to be loaded automatically at boot time, add

```
[I]module_name[/I]_load="YES"
```
to /boot/loader.conf
you have to install the driver (make install), though.
and if you add

```
ifconfig_[I]interface_name[/I]="WPA DHCP"
```
to /etc/rc.conf you should be on the network automatically.

You can find complete detail at http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-wireless.html


----------



## gnoma (Nov 28, 2009)

OK Thank you.... then I just need to know then ame of the module that I have to add in loader.conf 
May be it is something like 

```
module_rt28600_load="YES"
```
or something?
About that fix


> A fix have been released for the driver for 8.0 RELEASE and CURRENT. There were some packet loss/drop and mem leak. (The fix improves some performance too.)


Rekease 8.0 and CURRENT? That current meens 7.2?


----------



## DutchDaemon (Nov 28, 2009)

CURRENT is bleeding-edge (which is now FreeBSD *9*).


----------



## Reygok (Nov 28, 2009)

Hi!

I'm not an expert in these things and dont understand english very well, so please, could someone just help me with this?

I have the Linksys WUSB54GC, which appears in the list, but I dont have any idea how to install these drivers. Is the "run.tar" the driver? SO what do I have to do with it.

So, great thanks in advance,

Reygok


----------



## GeorgeMitchell (Nov 28, 2009)

*7.2, ad hoc mode?*

Is the run.tar.bz2 file from the first post still the correct version for FreeBSD 7,2?  And is ad hoc mode supported, or do I have to have an access point somewhere?


----------



## PseudoCylon (Nov 29, 2009)

@gnoma
No, based on your post it should be

```
rt2860_load="YES"
```

@Reygok
First, you have to check the version of your device. Look at the back of the device. If the model No says "WUSB54GC" use if_rum. (It is written in very very small font. You have to look hard.) The driver comes with FreeBSD. If it says "WUSB54GC ver. 3" use if_run. Please see the first post for latest update.

@GeorgeMitchell
It is for 7.2, but ad hoc mode isn't supported. Probably the same reason the original author excluded the support.


----------



## Reygok (Nov 29, 2009)

Sorry, but what do you mean by: "The driver comes with FreeBSD"?
My device says WUSB54GC, nothing else.

Thanks, Reygok


----------



## PseudoCylon (Nov 29, 2009)

Sorry, I should have said "The driver is included in FreeBSD." I live in Canada, but I'm not a Canadian. I feel I'm more fluent in C than English, these days.

Anyway, rum(4) should work fine with your device. If you are using GENERIC kernel, it even compiled into the kernel. Just plug in the device and run
`% ifconfig`
You should see "rum0" in the output. If not you need to load the driver manually. It depends which version of FreeBSD you are using. But when you run
`% man rum`
you will see appropriate manual for your version. And the manual tells you how to use the driver as well.


----------



## Reygok (Nov 29, 2009)

Okay, so I need to insall this FreeBSD? I did not know that^^
So, now, before I continue, I want to know if I can go into Wifi with my Nintendo DS when using this driver?, If not, i dont even have to install this BDS thing


----------



## DutchDaemon (Nov 29, 2009)

Reygok, what are you doing on a FreeBSD forum if you *a)* don't run it and *b)* have never heard of it? Everything posted here applies to the FreeBSD operating system, not your game console.


----------



## Reygok (Nov 29, 2009)

Good to know that, thanky^^ So, I'm gone...


----------



## egorenar (Nov 30, 2009)

gnoma said:
			
		

> OK dude  sorry I don't meen to rush you.
> And... about that driver I don't know is it normal and do I have to make more settings about that, but when I restart my PC and type ifconfig that wi-fi card was not in the list.
> Is it a driver bug or I just didn't make some settings I should do?? I don't know I just install the driver and didn't touch nothing else.



I have good news for guys who are impatient to test rt2860 
I have finally implemented sending for rt2860. It's not very stable yet. Please test it and provide feedback. It's the first version of the driver with Tx support.
AP mode doesn't work yet.
And Tx watchdog happens to often for my liking.
The driver supports 802.11abg, QoS, encryption in hardware, WEP, TKIP and AES.

Installation:

Extract archive, run make and load the driver with kldload.
The driver is compiled with debug information on by default, so
i would be grateful if you could provide crash dumps with backtrace to me
should the driver crash  (kgdb backtraces would be nice)

I will try to fix bugs in the next days.
You will not believe me how many crashes i had while testing this driver
before i got more or less stable version 

Writing this post with rt2860 

Thanks.

2.12.2009 Update, Tx DMA scatter added => more efficient sending of frames, avoids mbuf copying

4.12.2009
The driver is now stable. But
you should disable bgscan with "ifconfig rt28600 -bgscan" else
the link goes down after some time, don't know why.
The problem with interrupts is not solved yet.
Added statistic output, try "sysctl dev.rt2860.0.stats=1" and then "dmesg".

:e :e :e


----------



## gnoma (Dec 2, 2009)

I was unable to copy the code becos I don't see it on SSH and on the FreeBSD machine it was for short time and then it reboots.
It was something like...

```
interupt storm detected on "irq10"; trottiling interupt source
interupt storm detected on "irq10"; trottiling interupt source
interupt storm detected on "irq10"; trottiling interupt source
rt28600: Tx watchdog: tx_timer=0
rt28600: Tx watchdog: tx_timer=0
rt28600: Tx watchdog: tx_timer=0
interupt storm detected on "irq10"; trottiling interupt source
rt28600: Tx watchdog: tx_timer=0
```
And so on...
And also I want to ask if the driver is able to support an AP mode? Becos this morning I saw somehere that not every wi-fi driver in freebsd support this mode. Well I am sure at this time it doesn't but when it is complete?


----------



## egorenar (Dec 2, 2009)

gnoma said:
			
		

> I was unable to copy the code becos I don't see it on SSH and on the FreeBSD machine it was for short time and then it reboots.
> It was something like...
> 
> ```
> ...



Thanks for feedback,

yes the interface supports AP mode but driver not yet.
But i intend to implement it


----------



## egorenar (Dec 2, 2009)

gnoma said:
			
		

> I was unable to copy the code becos I don't see it on SSH and on the FreeBSD machine it was for short time and then it reboots.
> It was something like...
> 
> ```
> ...



The problem is that the NIC generates an interrupt for every received or sent packet !!! I could count the interrupts with "vmstat -i" and rt2860 generates as many interrupts as system timer interrupt !!! I guess i need to do interrupt mitigation. How do i do it on FreeBSD, has somebody any ideas ???

The hardware of rt2860 chip is able to do interrupt mitigation in hardware but this feature is not documented. I tried to experiment with it, but the transfer rate becomes too low x(

3.12.2009
I have found a solution to my problem. The e1000 driver implements this.
It uses Fast IRQs and task queues to defer work which my driver does in
interrupt (similar to Linux tasklets). I will implement it soon, test
and report back 

3.12.2009
Implemented interrupt mitigation with task queues.
It didn't solve the problem x(


----------



## egorenar (Dec 4, 2009)

I just learned that FreeBSD 8 was released. Cool :e
It is time to start porting my drivers for rt2870 and rt2860 chips to FreeBSD 8.

:e:e:e


----------



## kvchung (Dec 5, 2009)

I can't wait for your rt2860 chips driver for FreeBSD 8.
I'd like to run it on my EeePC 1000H.


----------



## egorenar (Dec 5, 2009)

I installed FreeBSD 8.0 today and started to port rt2860 device driver. Monitor mode is already working :e
I will try to make STA mode work on this weekend.


----------



## egorenar (Dec 6, 2009)

I have good news, guys.
rt2860 STA mode with hardware encryption is working on FreeBSD 8.
:e :e :e
I ported the first version and writing this post with rt2860 driver on FreeBSD 8.
I will improve it in the next days and then you can test it
by yourself.


----------



## egorenar (Dec 6, 2009)

Here is the first version of rt2860 device driver for FreeBSD 8.
It is stable and works fine on my very old PC with P4 2.5GHz.
Please test it and provide feedback.
You should deactivate bgscan with "ifconfig wlan0 -bgscan"
because it causes some problems.

Installation instruction:

1. Add following lines to rc.conf


```
wlans_rt28600="wlan0"
ifconfig_wlan0="WPA DHCP"
```

2. Restart networking


```
# /etc/rc.d/netif restart
```

3. Compile rt2860.ko KLM


```
$ make
```

4. Load rt2860.ko


```
# kldload ./rt2860.ko
```

AP mode is still work in progress.

6.12.2009
Added PCI IDs for Ralink RT2790 PCIe card.

Disabled BGSCAN because it causes problems.
So you don't have to disable it every time manually
with ifconfig.

:e :e :e


----------



## kvchung (Dec 6, 2009)

I have done # kldload ./rt2860.ko

```
# kldstat
Id Refs Address    Size     Name
 1    9 0xc0400000 760d70   kernel
 2    1 0xc0b61000 52dc     ums.ko
 5    1 0xcb27f000 12000    rt2860.ko
```
but nothing happened
rt28600 has not been found

What else should I do ?


----------



## egorenar (Dec 6, 2009)

kvchung said:
			
		

> I have done # kldload ./rt2860.ko
> 
> ```
> # kldstat
> ...



My driver currently works only for Linksys WMP600N.
I need PCI vendor and product ID of your card so
my driver could identify it and automatically load.

Try lspci -v and provide me with PCI IDs.
And in 5 minutes you can test it again.

:e


----------



## kvchung (Dec 6, 2009)

# lspci -v not work
I try pciconf

```
pciconf -lv
...
none0@pci0:1:0:0:       class=0x028000 card=0x27901814 chip=0x07811814 rev=0x00 hdr=0x00
    vendor     = 'Ralink Technology, Corp'
    device     = 'Wireless (RT2860/RT2890)'
    class      = network
```


----------



## egorenar (Dec 6, 2009)

kvchung said:
			
		

> # lspci -v not work
> I try pciconf
> 
> ```
> ...



OK, you have a PCIe card.
VendorID=0x1814 and ProductID=0x0781
Wait a second and i will update my driver.


----------



## egorenar (Dec 6, 2009)

kvchung said:
			
		

> # lspci -v not work
> I try pciconf
> 
> ```
> ...



OK, i updated the driver, you can try it again
and provide feedback. I could not test my driver with this device
so there is a possibility that some problems can occur.

:e


----------



## kvchung (Dec 6, 2009)

It can find the device now
when I klkload, I get these message in dmesg

```
# kldload ./rt28600.ko

rt28600: <RT2790 PCIe> mem 0xfbef0000-0xfbefffff irq 19 at device 0.0 on pci1
rt28600: attaching
rt28600: EEPROM rev=0x0102
rt28600: EEPROM mac address=00:22:43:42:25:27
rt28600: EEPROM RF rev=0x0003, paths=1T2R
rt28600: EEPROM NIC config: Tx AGC control=0
rt28600: EEPROM country code=1/7
rt28600: EEPROM freq offset=0x1c
rt28600: EEPROM led cntl=0x01, LEDs=0xffff/0x9ad9/0xc8cc
rt28600: EEPROM LNA gains=0x00/0xff
rt28600: invalid EEPROM LNA gain: 2
rt28600: invalid EEPROM LNA gain: 3
rt28600: EEPROM Tx power compensation deltas=0(2MHz), 0(5MHz)
rt28600: EEPROM Tx power compensation #0=0x66663333(20MHz), 0x66663333(40MHz/2GHz), 0x66663333(40MHz/5GHz)
rt28600: EEPROM Tx power compensation #1=0x66666666(20MHz), 0x66666666(40MHz/2GHz), 0x66666666(40MHz/5GHz)
rt28600: EEPROM Tx power compensation #2=0x33333333(20MHz), 0x33333333(40MHz/2GHz), 0x33333333(40MHz/5GHz)
rt28600: EEPROM Tx power compensation #3=0x66663333(20MHz), 0x66663333(40MHz/2GHz), 0x66663333(40MHz/5GHz)
rt28600: EEPROM Tx power compensation #4=0xffff6666(20MHz), 0xffff6666(40MHz/2GHz), 0xffff6666(40MHz/5GHz)
rt28600: EEPROM TSSI 2GHz: 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, step=255
rt28600: EEPROM TSSI 5GHz: 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, step=255
rt28600: MAC/BBP RT2860 (rev 0x28720200), RF RT2720
rt28600: skip channel 10, could not find extension channel
rt28600: skip channel 11, could not find extension channel
rt28600: skip channel 12, could not find extension channel
rt28600: skip channel 13, could not find extension channel
rt28600: skip channel 14, could not find extension channel
rt28600: [ITHREAD]
wlan0: Ethernet address: 00:22:43:42:25:27
rt28600: initializing
rt28600: loading 8051 microcode
rt28600: 8051 microcode was successfully loaded
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
```

and I started to scan
It can list th APs


```
# ifconfig wlan0 up list scan

SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
NCTU-Wireless   00:0b:86:9c:31:80    1   11M -143:-95   60 ES
0               00:02:6f:22:00:ae    1   54M -137:-95  100 ES
NCTU_NOD lab    00:22:b0:94:c8:f7    6   54M -138:-95  100 ES   MESHCONF MESHCON
F WPS HTCAP WME
Kan Cheng T...  00:23:6c:8d:f5:97   11   54M -136:-95  100 E    HTCAP WME
y955188         00:1f:1f:47:c0:64   11   54M -154:-95  100 EP   MESHCONF MESHCON
F HTCAP RSN WME
NCTU-HOT-1-G    00:90:4b:bd:f4:30   11   54M -141:-95  100 ES
NCTU-HOT-1-A    00:90:4b:bd:f4:40   13   54M -142:-95  100 ES
ndlit           00:12:7f:ca:f0:a0    4   54M -138:-95  100 ES
ndl-ap2         00:1f:9e:c0:19:c0    8   54M -138:-95  100 EPS  WME
Personal        00:24:8c:ec:20:dc    1   54M -145:-95  100 EPS  RSN
guest           00:12:7f:ca:f3:a0   10   54M -137:-95  100 ES
NCTU-Wireless   00:0b:86:9c:4b:30   11   11M -138:-95   60 ES
```

but wlan0 still no carrier


```
# ifconfig 

...
rt28600: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:22:43:42:25:27
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
        status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:22:43:42:25:27
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid NCTU-Wireless channel 5 (2432 Mhz 11g)
        country US authmode OPEN privacy OFF txpower 0 bmiss 7 scanvalid 60
        bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5
        protmode CTS wme burst bintval 0
```


Sorry, this is my first time using wireless lan on freebsd...


----------



## egorenar (Dec 6, 2009)

kvchung said:
			
		

> It can find the device now
> when I klkload, I get these message in dmesg
> 
> ```
> ...




Hm, did you modified your rc.conf as i said and of cause you need to configure your wpa_supplicant. Did you do this ?

PS: you can write to my ICQ account and i can help you faster.


----------



## kvchung (Dec 6, 2009)

Not yet configure my wpa_supplicant,
I'm going to try it


----------



## lme@ (Dec 7, 2009)

Just one suggestion:
Could you please re-name the driver?
It is really odd to have device names with more that one digit at the end...


----------



## egorenar (Dec 7, 2009)

I have started to port my rt2870 device driver to FreeBSD 8.
I think in 2 days you can test the first working version.

:e :e :e


----------



## gnoma (Dec 8, 2009)

OK Then I guess I have to upgrade to BSD 8 
But still wondering about the Access point mode of your driver?
Is it supporter or for now you are just makeing it for client modes?


----------



## egorenar (Dec 9, 2009)

gnoma said:
			
		

> OK Then I guess I have to upgrade to BSD 8
> But still wondering about the Access point mode of your driver?
> Is it supporter or for now you are just makeing it for client modes?



Don't worry, i will support both FreeBSD 7.2 and FreeBSD 8.
FreeBSD 8 version of rt2860 device driver is not better than 
FreeBSD 7.2 version of the driver. But FreeBSD 8 supoorts VAPs
and rt2860 chip supports 8 VAPs in hardware, so if you want to
use the newest 802.11 stack features then upgrade to FreeBSD 8.


And yes, i will try to make AP mode working in the next days.



:e:e:e


----------



## dDMC (Dec 10, 2009)

*Questions*

Hi, 

@ egorenar I compiled your driver & can kldload it but i dont get any device in my ifconfig, dmesg shows insertion of ugen device, my usb wifi stick is Edimax EW-7711UTn. Any ideas ?

@ PseudoCylon, I compiled your drivers too, can get them to load & can see run0 device, Are you planning on adding h/w encryption ? as i'm having troubles with wpa_supplicant, i can get it working ok without encryption. I'm using PC-BSD gallileo which is 7.2 based.

The thread is hard to follow at times as it also contains posts relating to other RT chips & drivers.

But all good stuff.


----------



## PseudoCylon (Dec 10, 2009)

Hi dDMC

My driver for 7.2 doesn't support any encryption. (updated on Jan 09, 2010: but, now it supports. Please see the first post for details.) Since I already upgraded to 8.0, there won't be any update on driver for 7.2. Once they upgrade PC-BSD to 8, my driver should work.

I'm still tweaking the driver for 8.0 and current. Update is coming.


----------



## egorenar (Dec 10, 2009)

dDMC said:
			
		

> Hi,
> 
> @ egorenar I compiled your driver & can kldload it but i dont get any device in my ifconfig, dmesg shows insertion of ugen device, my usb wifi stick is Edimax EW-7711UTn. Any ideas ?
> 
> ...



Hi,

i need USB vendor and product IDs of your device.
So i can add them to my driver.

Try "lsusb -vv" and post here the IDs.

If you have the device (0x7392,0x7718) or (0x7392,0x7717) then you are lucky
and my driver should support it. 

7392:7711 means you have rt3070 chip in your device and my driver doesn't support this chip.


:e :e :e


----------



## dDMC (Dec 10, 2009)

*argh !*

yes my chip is 0x7711 & 0x7392, so thats why i dont see anything in ifconfig


----------



## dDMC (Dec 10, 2009)

PseudoCylon, is it still possible to run wpa_supplicant on top of the run0 interface ?

I've been trying WPA-PSK & TKIP but get a IOCTL SIOCS80211 op19 len 60 invalid argument error.


----------



## egorenar (Dec 10, 2009)

Good news guys 
I ported the first version of rt2870 device driver to FreeBSD 8.
It is not very stable yet but hardware encryption works (WEP, TKIP, AES). I will try to make it stable and then upload it here.

:e :e :e


----------



## PseudoCylon (Dec 11, 2009)

dDMC said:
			
		

> PseudoCylon, is it still possible to run wpa_supplicant on top of the run0 interface ?
> 
> I've been trying WPA-PSK & TKIP but get a IOCTL SIOCS80211 op19 len 60 invalid argument error.



That's because the driver doesn't support any encryption.

But, I have fixed the driver. It is just a band-aid fix, but it handles h/w encryption (WEP 1/2 AES/TKIP). So, wpa_supplicant should work with fixed driver, now.

Hope this is good enough while waiting for PC-BSD 8 release. One for 8 and current is solid one. If your device runs on my driver, it will most definitely run on 8's, too. No need for searching the driver.

How to use
just replace the if_run.c then compile and load.
no need to do any thing with firmware (runfw) not even unloading it if it's already loaded.
-- updated on Jan 09, 2010 --
Or go to the first post for the latest update.


----------



## egorenar (Dec 12, 2009)

I promised rt2870 device driver for FreeBSD 8 and here it is.
It is quite stable now. I tested TKIP and AES hardware encryption
and QoS works fine. AP mode is still not working, trying to make it work 
Please send me your bug reports and feedback.
I would appreciate it. Thanks.

Currently surfing with it on FreeBSD 8 

Installation:

1. Extract archive
2. run "make"
3. Load rt2870.ko module with kldload

Have fun.

:e :e :e


----------



## mathuin (Dec 13, 2009)

This worked beautifully!  Thank you so much!  I'm looking forward to testing it over the next few days...


----------



## egorenar (Dec 13, 2009)

mathuin said:
			
		

> This worked beautifully!  Thank you so much!  I'm looking forward to testing it over the next few days...



Yeah, please send me your feedback and bug reports.
Thanks.

:e


----------



## egorenar (Dec 13, 2009)

gnoma said:
			
		

> OK Then I guess I have to upgrade to BSD 8
> But still wondering about the Access point mode of your driver?
> Is it supporter or for now you are just makeing it for client modes?



Hi, i have good news for you. I implemented AP mode for rt2860 and rt2870 chip devices and first tests were successfull. I could associate with AP and AES works :e It is the first working version
with AP mode and i will try to test it more before i upload it here. So be patient 
Association, authentication and WPA handshake works !!! 

:e :e :e


----------



## egorenar (Dec 13, 2009)

Here is the rt2870 device driver with HOSTAP mode :e
Please test it and report back any bugs and problems.
I only tested association and WPA handshake.
DHCPD works also.
First tests were very good 
Thanks for feedback in advance.


19.12.2009
Fixed bug in HOSTAP mode with association id == 0

I tested the driver now and it is quite stable, could download large files in HOSTAP mode 

:e :e :e


----------



## gnoma (Dec 14, 2009)

Thank you about the driver  I realy can't wait to see it, sounds realy good but...

```
# ls
@                       rt2870_eeprom.h         rt2870_rf.h
Makefile                rt2870_io.c             rt2870_rxinfo.h
bus_if.h                rt2870_io.h             rt2870_rxwi.h
device_if.h             rt2870_led.c            rt2870_softc.h
machine                 rt2870_led.h            rt2870_txinfo.h
opt_usb.h               rt2870_read_eeprom.c    rt2870_txwi.h
rt2870.c                rt2870_read_eeprom.h    rt2870_ucode.h
rt2870.sh               rt2870_reg.h            usbdevs.h
rt2870_debug.h          rt2870_rf.c
#
#
# make
Warning: Object directory not changed from original /usr/home/gnoma/New.Folder/rt2870_fbsd8
cc -O2 -fno-strict-aliasing -pipe -DRT2870_DEBUG -D_KERNEL -DKLD_MODULE -std=c99 -nostdinc   -I. -I@ -I@/contrib/altq -finline-limit=8000 
--param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -g -mno-align-long-strings -mpreferred-stack-boundary=2  
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-
prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c rt2870_io.c
In file included from rt2870_io.h:21,
                 from rt2870_io.c:18:
rt2870_softc.h:144: error: field 'vap' has incomplete type
rt2870_io.c: In function 'rt2870_io_vendor_req':
rt2870_io.c:383: error: storage size of 'usb_req' isn't known
rt2870_io.c:384: error: 'usb_error_t' undeclared (first use in this function)
rt2870_io.c:384: error: (Each undeclared identifier is reported only once
rt2870_io.c:384: error: for each function it appears in.)
rt2870_io.c:384: error: expected ';' before 'error'
rt2870_io.c:391: warning: left-hand operand of comma expression has no effect
rt2870_io.c:392: warning: left-hand operand of comma expression has no effect
rt2870_io.c:393: warning: left-hand operand of comma expression has no effect
rt2870_io.c:395: error: 'error' undeclared (first use in this function)
rt2870_io.c:396: warning: passing argument 1 of 'usbd_do_request_flags' from incompatible pointer type
rt2870_io.c:396: warning: passing argument 2 of 'usbd_do_request_flags' from incompatible pointer type
rt2870_io.c:396: warning: passing argument 4 of 'usbd_do_request_flags' makes integer from pointer without a cast
rt2870_io.c:396: warning: passing argument 6 of 'usbd_do_request_flags' makes integer from pointer without a cast
rt2870_io.c:396: error: too many arguments to function 'usbd_do_request_flags'
rt2870_io.c:383: warning: unused variable 'usb_req'
*** Error code 1

Stop in /usr/home/gnoma/New.Folder/rt2870_fbsd8.
#
```

Is this normal???


----------



## egorenar (Dec 14, 2009)

gnoma said:
			
		

> Thank you about the driver  I realy can't wait to see it, sounds realy good but...
> 
> ```
> # ls
> ...



Do you compile on FreeBSD 7.2. Because this version is for FreeBSD 8


----------



## egorenar (Dec 14, 2009)

And here is the rt2860 device driver for FreeBSD 8 with HOSTAP mode
and interrupt mitigation to improve performance 

Please send your feedback to me and bug reports. Thanks.

19.12.2009
Fixed bug in HOSTAP mode with association id == 0

:e :e :e


----------



## gnoma (Dec 14, 2009)

Ops. I realy did it on freebsd 7.2
Sorry I don't have the time to upgrade to fbsd8 right now. May be tomorrow I'll test it.


----------



## rossgohlke (Dec 22, 2009)

I was very excited to find this thread, but I need help getting rt2870 working.

Interface: Cisco (Linksys) WUSB600N, Version 2.0 (wedge-like shape).
 It was first attached to a Windows machine, with hardware encryption enabled.
OS: amd64 FreeBSD-STABLE csup'd on 2009-12-19
System: AMD Opteron 1207

Module compiles without error, but when I load the module, I get this:


```
%tail -f /var/log/messages
Dec 22 12:09:49 putnam root: Unknown USB device: vendor 0x1737 product 0x0079 bus uhub1
```

Any help would be greatly appreciated.


----------



## egorenar (Dec 22, 2009)

rossgohlke said:
			
		

> I was very excited to find this thread, but I need help getting rt2870 working.
> 
> Interface: Cisco (Linksys) WUSB600N, Version 2.0 (wedge-like shape).
> It was first attached to a Windows machine, with hardware encryption enabled.
> ...



Hm, you have new Linksys WUSB600N v2, i have tested my driver only with v1. It is easy to adjust the driver so it will also be loaded for WUSB600N v2, but i don't know if the driver will work.
But you can try it.

Edit rt2870.c and add the following line:


```
static const struct usb_device_id rt2870_usb_devid[] =
{
	{ USB_VP(USB_VENDOR_LINKSYS4, USB_PRODUCT_LINKSYS4_WUSB600N) },		/* Linksys WUSB600N */
+       { USB_VP(USB_VENDOR_LINKSYS4, 0x0079) },		/* Linksys WUSB600N v2 */

	{ USB_VP(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_DWA140) },			/* D-Link DWA-140 */
	{ USB_VP(USB_VENDOR_DLINK2, USB_PRODUCT_DLINK2_DWA160AREVB) },		/* D-Link DWA-160A Rev. B */
	{ USB_VP(USB_VENDOR_ASUS, USB_PRODUCT_ASUS_RT2770F) },				/* Asus RT2770F */
};
```

After that, recompile the driver and post your feeback here please.
Thanks.

UPDATE
Sorry, but my rt2870 driver will not work with your NIC because WUSB600N v2
has another chipset (RT3572) :-(

See this link: http://forums.remote-exploit.org/backtrack-4-non-working-hardware/29502-rt3572-wusb600n-v2.html


----------



## rossgohlke (Dec 22, 2009)

Wow, thanks the for quick response and for the link.
Should I try ndis_wrapper?
Keep up the great work.


----------



## egorenar (Dec 23, 2009)

rossgohlke said:
			
		

> Wow, thanks the for quick response and for the link.
> Should I try ndis_wrapper?
> Keep up the great work.



i don't know about ndis but there is already a Linux driver fot this chipset on Ralink web site. I know the Linux driver for rt2870 very well and it is very similar to rt3572, but EEPROM is quite different :e I guess i could port my rt2870 driver
for rt3572, but i don't have any rt3572 hardware so i could test the driver.


----------



## PseudoCylon (Dec 23, 2009)

I have added support for WUSB600N ver.2. My driver supports some RT30XX chips to begin with.

I don't have the device with that chipset. I cannot test. It may works, or may not work at all. *Try it at your own risk!* Don't blame me if your device get toasted.

-- updated on Jan 09, 2010 --
Please go to the first post for the latest update.


----------



## rossgohlke (Dec 23, 2009)

I'm not able to load the if_run.


```
% make
Warning: Object directory not changed from original /stg/sfw/dld/run-test/sys/modules/usb/run
:> opt_usb.h
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
awk -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -h
cc -O2 -pipe -funroll-loops -DWITNESS -DINVARIANT_SUPPORT -DINVARIANTS -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ 
-I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common  -fno-omit-frame-pointer 
-mcmodel=kernel -mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-sse3 -mno-mmx -mno-3dnow  -msoft-float -fno-asynchronous-unwind-tables 
-ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-
prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c /stg/sfw/dld/run-test/sys/modules/usb/run
/../../../dev/usb/wlan/if_run.c
ld  -d -warn-common -r -d -o if_run.ko if_run.o
:> export_syms
awk -f /sys/conf/kmod_syms.awk if_run.ko  export_syms | xargs -J% objcopy % if_run.ko
objcopy --strip-debug if_run.ko
# make install
install -o root -g wheel -m 555   if_run.ko /boot/kernel
kldxref /boot/kernel
# kldload if_run
kldload: can't load if_run: Exec format error
```

Also, README needs small edit:

```
-        %cd sys/modules/usb/runfw
+        %cd sys/modules/runfw
```

Any ideas? I have a custom kernel installed, as well as ccache. I also tried this make command:
`#env -i make -j8 -DALWAYS_CHECK_MAKE -DNOCCACHE KERNCONF=TUNED`


----------



## rossgohlke (Dec 23, 2009)

A ha! I changed Makefile


```
-CFLAGS += -DWITNESS -DINVARIANT_SUPPORT -DINVARIANTS
+#CFLAGS += -DWITNESS -DINVARIANT_SUPPORT -DINVARIANTS
```

`#kldload if_run`



```
1) After created wlan device, please run
        #ifconfig wlan0 country
   with proper country code, before doing anything.
```

This gives me pause. I'm going to man ifconfig first...


----------



## rossgohlke (Dec 23, 2009)

It loaded!


```
#kldload if_run
#ifconfig
run0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:25:9c:0a:77:90
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier

#ifconfig wlan create wlandev run0
#ifconfig wlan0 list countries
#ifconfig wlan0 country US
#ifconfig
run0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:25:9c:0a:77:90
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
wlan0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:25:9c:0a:77:90
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid "" channel 1 (2412 Mhz 11b)
        regdomain FCC country US authmode OPEN privacy OFF txpower 30 bmiss 7
        scanvalid 60 wme bintval 0
```

README should be updated with first command.
`#ifconfig wlan create wlandev run0`

Now, to configure it...

Thanks for all the help!


----------



## DutchDaemon (Dec 23, 2009)

rossgohike, please use proper posting tags:
http://forums.freebsd.org/showthread.php?t=8816


----------



## PseudoCylon (Dec 24, 2009)

Is it working now? Let me know how the driver doing.

I guess I have to update README file, too.

Thanks for taking risks (oops testing the driver).


----------



## GeorgeMitchell (Dec 26, 2009)

PseudoCylon said:
			
		

> I have added support for WUSB600N ver.2. My driver supports some RT30XX chips to begin with.
> 
> I don't have the device with that chipset. I cannot test. It may works, or may not work at all. *Try it at your own risk!* Don't blame me if your device get toasted.



1. I'm running with a GENERIC kernel, so I had to change the definition of RUN_LOCK_ASSERT to the empty string.

2. After plugging in my Zonet ZEW2500P (04), my log said:

```
Dec 25 19:28:16 milk kernel: ugen2.2: <Ralink> at usbus2
Dec 25 19:28:16 milk kernel: run0: <.0> on usbus2
Dec 25 19:28:16 milk kernel: run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 
1T1R), address 00:a1:b0:c0:25:e8
Dec 25 19:28:16 milk kernel: run0: You are using firmware RT2870.
```

3. When I typed "ifconfig run0 country US", I got:
ifconfig: unable to get regulatory domain info: Invalid argument

4. When I typed "ifconfig run0 up", the system immediately crashed.  The crash summary is at:
http://www.m5p.com/~george/core.txt.0

What do you suggest I do next?  (And thanks for all the work!)


----------



## PseudoCylon (Dec 26, 2009)

You need to create wlan0, first.

After kldload if_run, do
`# ifconfig wlan create wlandev run0`
`# ifconfig [b]wlan0[/b] country US`
`# ifconfig [b]wlan0[/b] up`

Once you create wlan0, use wlan0 instead of run0. This is new for 8.0.

I definitely need to update README, after holidays.

Merry Christmas.


----------



## joel@ (Dec 29, 2009)

Making this one sticky.


----------



## TheBiggestGnome (Dec 30, 2009)

egorenar said:
			
		

> Hm, did you modified your rc.conf as i said and of cause you need to configure your wpa_supplicant. Did you do this ?
> 
> PS: you can write to my ICQ account and i can help you faster.



I am having a similar issue. I have edited rd.conf as you said with:

wlans_rt28600="wlan0"
ifconfig_wlan0="ssid KretNet WPA DHCP"

and have also used your supplied config as well [ifconfig_wlan0="WPA DHCP" with the same results.

when I restart netif, I get the errors:


```
wlan0: Ethernet address: 00:1e:e5:e8:d5:4f
ifconfig: DHCP: bad vaule
rt28600 initializing
/etc/rc.d/wpa_supplicant: Warning: /etc/wpa_supplicant.conf is not readable
/etc/rc.d/wpa_supplicant: Warning:failed precmd routine for wpa_supplicant
Starting Network lo0
lo0 flags=8049(UP,LOOPBACK,RUNNING,MULTICAST) metric 0 mtu 16384
options=3(RXCSUM,TXCSUM)
inet6 fe80::1%1o0 prefixlen 64 scopeid 0x5
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
```


You'll have to excuse any silly errors as I'm still pretty new to FreeBSD


----------



## egorenar (Dec 30, 2009)

TheBiggestGnome said:
			
		

> I am having a similar issue. I have edited rd.conf as you said with:
> 
> wlans_rt28600="wlan0"
> ifconfig_wlan0="ssid KretNet WPA DHCP"
> ...



Hi,

you also have to configure WPA supplicant properly.
What looks your /etc/wpa_supplicant.conf like ?


----------



## lme@ (Dec 30, 2009)

I think you cannot mix "ssid foo" and "WPA". You define the ssid and the wpa key in /etc/wpa_supplicant.conf and the supplicant takes care of connecting to the right network.


----------



## TheBiggestGnome (Dec 30, 2009)

egorenar said:
			
		

> Hi,
> 
> you also have to configure WPA supplicant properly.
> What looks your /etc/wpa_supplicant.conf like ?



because I have to manually type out anything from the other pc, what exactly are you looking for?

I'll provide you with the first few lines:


```
#!/bin/sh
#
# $FreeBSD: src/etc/rc.d/wpa_supplicant,v 1.6.2.2.2.1 2009/10/25 01:10:29 kensmith Exp$
#

# PROVIDE: wpa_supplicant
# REQUIRE: mountcritremote
# KEYWORD: nojail nostart

. /etc/rc.subr
. /etc/network.subr

name="wpa_supplicant"
rcvar=

ifn="$2"
```


----------



## egorenar (Dec 30, 2009)

TheBiggestGnome said:
			
		

> because I have to manually type out anything from the other pc, what exactly are you looking for?
> 
> I'll provide you with the first few lines:
> 
> ...



I assume you want to use WPA or WPA2 with your NIC 

You have to edit /etc/wpa_supplicant.conf.

Here is an example of /etc/wpa_supplicant.conf:


```
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
        ssid="my_network"
        proto=RSN WPA
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk="secret_password"
}
```

Change ssid "my_network" to your network ssid and
psk "secret_password" to your password.
Then restart netif as root with


```
# /etc/rc.d/netif restart
```

See also this link: 
http://www.freebsd.org/doc/en/books/handbook/network-wireless.html


----------



## TheBiggestGnome (Dec 30, 2009)

egorenar said:
			
		

> I assume you want to use WPA or WPA2 with your NIC
> 
> You have to edit /etc/wpa_supplicant.conf.
> 
> ...



and if its just an open network without any kind of security, do i need to add all of the WPA/TKIP stuff?

I'll see what I can find in the handbook, as well


----------



## TheBiggestGnome (Dec 30, 2009)

Apparently, you cen't edit until one has so many posts under their belt.

So, I don't need to configure WPA, because well, I don't use it. I have edited rc.conf to reflect that:


```
ifconfig_wlan0="ssid NETWORK_HERE DHCP"
```

Now the only issue I have is:

```
Status: no carrier
```


----------



## egorenar (Dec 30, 2009)

No security at all, it is not a good idea 
What NIC do you have ?
And what says ifconfig ?


----------



## TheBiggestGnome (Dec 30, 2009)

the WMP600N, with your rt28600 loaded, hopefully correct


```
# ifconfig
.....
rt28600: flags=8843(UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST) metric 0 MTU 2290
ether 00:1E:E5:E8:D5:4F
media: IEEE 802.11 Wireless Ethernet autoselect mode 11a
status: associated

wlan0: flags=8843(UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST) METRIC 0 MTU 1500
ether: 00:1e:e5:e8:d5:4f
media IEEE 802.11 Wireless Ethernet autoselect (autoselect)
status: no carrier
ssid KretNet channel 132 (5660 Mhz 11a)
country US authmode OPEN privacy OFF txpower 0 bmiss 7 mcastrate 6
mgmtrate 6 scanvaild 60 wme burst bintval 0
```


----------



## egorenar (Dec 30, 2009)

You can also use wpa_supplicant with a network without securiry.

Example:


```
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
	ssid="my_network"
	key_mgmt=NONE
}
```

Try this config, it should work. I don't know how to associate with
a network without WPA supplicant.

But it is not a good idea to use no security.
WMP600N supports WPA2-AES in hardware and my driver works well with it.
I have the same NIC and it works fine with WPA2.
But it is of course your decision


----------



## TheBiggestGnome (Dec 30, 2009)

egorenar said:
			
		

> You can also use wpa_supplicant with a network without securiry.
> 
> Example:
> 
> ...



Alright, after /etc/rc.d/netif restart:

```
rt28600: flags=8802<BROADCAST,SIMPLEX,MULTICAST) metric 0 mtu 2290
ether 00:1e:e5:e8:d5:4f
media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
status: no carrier
ifconfig: interface wlan0 does not exist
wlan0: Ethernet address: 00:1e:e5:e8:d5:4f
Starting wpa_supplicant
Starting Network lo0
.....
[root@~/rt2860_fbsd8]# Dec 30 16:05:05  wpa_supplicant[3785]: Failed to initialize control interface '/var/run/wpa_supplicant'. You may have 
another wpa_suplicant process already running or the file left by an unclean termination of wpa_supplicant in which case you will need to 
manually remove this file before starting wpa_supplicant again.
Dec 30 16:05:05 wpa_supplicant[3785] Failed to disable WPA in the driver
rt28600 initializing
```


----------



## egorenar (Dec 30, 2009)

TheBiggestGnome said:
			
		

> Alright, after /etc/rc.d/netif restart:
> 
> ```
> rt28600: flags=8802<BROADCAST,SIMPLEX,MULTICAST) metric 0 mtu 2290
> ...



These log messages are OK, but you didn't post the complete log.
What says ifconfig now ?


----------



## TheBiggestGnome (Dec 30, 2009)

WOOOOOOOOO!

YAY! IT WORKS!

Thank you so much!


Now, this will connect every time the system boots, correct?


----------



## egorenar (Dec 30, 2009)

TheBiggestGnome said:
			
		

> WOOOOOOOOO!
> 
> YAY! IT WORKS!
> 
> ...



You are welcome. Please send me back bug and problem reports.
Thanks.

It should connect at the system boot if you add the following
line to rc.conf:


```
rt2860_wlans="wlan0"
ifconfig_wlan0="WPA DHCP"
```

And you should also copy rt2860.ko module to /boot/kernel/
and add the following line to /boot/loader.conf:


```
rt2860_load="YES"
```


----------



## gnoma (Dec 31, 2009)

So what's up with the WMP600n driver for 7.2?
Any news? 
Thanks and happy new year to all!


----------



## egorenar (Dec 31, 2009)

gnoma said:
			
		

> So what's up with the WMP600n driver for 7.2?
> Any news?
> Thanks and happy new year to all!



Hi,

follow this link and there you will find the driver with AP mode for FreeBSD 7.2:

http://forums.freebsd.org/showthread.php?t=7010&page=3

:e :e :e


----------



## greyulv (Jan 2, 2010)

Hello, egorenar.  Does the 7.2 version of your driver work for 7.2 stable under PC-BSD 7.1.1?

Following the thread [thread=7562]7562[/thread]


----------



## greyulv (Jan 2, 2010)

Now following link for post 129.


----------



## gnoma (Jan 5, 2010)

egorenar
I've just installed rt2860 on freebsd7.2.
It worked good and I did that in /boot/loader.conf

```
rt2860_load="YES"
```
and in /etc/rc.conf

```
ifconfig_rt28600="inet 192.168.1.2 netmask 255.255.255.0 ssid example mode 11g mediaopt hostap"
```
and I copy the rt2860.ko file in /boot/kernel/
and when I reboot...

```
login: rt28600: Tx watchdog timeout: resetting
rt28600: stopping
```
and it stands on pause, no keyboard respons. I can't ivent login.
I reboot 2-3 times and then I removed the card from the PCI slot so I can run the machine. I don't know if I wrong something becos I also have a LAN card on 192.168.1.1(natd enable) could it be a problem?
Thancks and have verry happy and successful 2010 year and keep up the good work


----------



## egorenar (Jan 6, 2010)

gnoma said:
			
		

> egorenar
> I've just installed rt2860 on freebsd7.2.
> It worked good and I did that in /boot/loader.conf
> 
> ...



Thanks for feedback.
I didn't test loading the driver at boot time.
I will see what i can do.

:e :e :e


----------



## egorenar (Jan 6, 2010)

gnoma said:
			
		

> egorenar
> I've just installed rt2860 on freebsd7.2.
> It worked good and I did that in /boot/loader.conf
> 
> ...



I fixed the bug :e
Please test again.

Here is the new version:
http://forums.freebsd.org/showthread.php?p=55365#post55365


----------



## GeorgeMitchell (Jan 7, 2010)

PseudoCylon said:
			
		

> You need to create wlan0, first.
> 
> After kldload if_run, do
> `# ifconfig wlan create wlandev run0`
> ...



Thanks again!  I was delighted to discover that this even works in hostap and station mode, as long as I don't try to encrypt.  Once I enable hostapd and wpa_supplicant, the station no longer associated with the hostap, and the hostap says, "run0: device timeout" about as often (I assume) as the station tries to scan for it.  Any suggestions?  (This is with two rt3070s.)


----------



## PseudoCylon (Jan 7, 2010)

That's because support for hostap mode is still work-in-progress.

When chipset sends beacons it behave badly. Currently, I'm looking into Ralink's source code and trying to find some solutions.

Actually, rt2xxx and rt3xxx chips are very similar but not exactly the same. The driver might work fine with rt2xxx chipset, but hostap mode on rt3xxx looks grim so far. But, see what I can find out. (NB: A FreeBSD newbie is writing a driver without any datasheet. It will take a while.)


----------



## gnoma (Jan 7, 2010)

> egorenar
> I've just installed rt2860 on freebsd7.2.
> It worked good and I did that in /boot/loader.conf
> 
> ...


egorenar 
The same thing keep showing with the new driver 
I am using WMP600N if it matters to you and my MB is a little older so I it works with ACPI disabled. Any ideas?


----------



## egorenar (Jan 7, 2010)

gnoma said:
			
		

> egorenar
> The same thing keep showing with the new driver
> I am using WMP600N if it matters to you and my MB is a little older so I it works with ACPI disabled. Any ideas?



I could reproduce this problem now. I'm trying to find a solution.
Thanks for feedback. It seems i found another bug yesterday :e


----------



## egorenar (Jan 7, 2010)

gnoma said:
			
		

> egorenar
> The same thing keep showing with the new driver
> I am using WMP600N if it matters to you and my MB is a little older so I it works with ACPI disabled. Any ideas?



Please test the driver again. Thanks for feedback, it is important for me.


----------



## gnoma (Jan 7, 2010)

It still does the same thing on system start.
Delete the old archive end unarchived dir, delete the old rtl2860.ko file in /boot/kernel, extract the archive again, run "make" and copy the rt2860.ko in /boot/kernel, (I didn't load it becos the card is removed from the slot so I can start the machine normaly)then shutdown, place the card and start.


```
login: ro rt28600: Tx watchdog timeout: resetting
rt28600: stopping
```

I didn't touch the x.conf files.
May be I miss something, may be the problem is there???
/boot/loader.conf:

```
rt2860_load="YES"and in /etc/rc.conf
```
/etc/rc.conf:

```
ifconfig_rt28600="inet 192.168.1.2 netmask 255.255.255.0 ssid example mode 11g mediaopt hostap"
```


----------



## egorenar (Jan 7, 2010)

gnoma said:
			
		

> It still does the same thing on system start.
> Delete the old archive end unarchived dir, delete the old rel2860.ko file in /boot/kernel, extract the archive again, make and copy the rt2860.ko in /boot/kernel. I didn't touch the x.conf files.
> May be I miss something, may be the problem is there???
> /boot/loader.conf:
> ...



I only tested it manually. I loaded the driver, configured the interface and started hostapd. And it worked.
What system do you have ?


----------



## egorenar (Jan 7, 2010)

gnoma said:
			
		

> It still does the same thing on system start.
> Delete the old archive end unarchived dir, delete the old rtl2860.ko file in /boot/kernel, extract the archive again, run "make" and copy the rt2860.ko in /boot/kernel, (I didn't load it becos the card is removed from the slot so I can start the machine normaly)then shutdown, place the card and start.
> 
> 
> ...



Yes, you are right, the problem is still there. Strange.
If i load the driver manually and configure it then it works fine. But if the driver is autoloaded at boot time then the problem is there. I will try to find a solution for this problem.
Did you try to configure the NIC manually ?


----------



## gnoma (Jan 7, 2010)

I did only with the first driver becos after that I couldn't start the PC with the card in the slot, and it worked fine. If u want I can comment that line in /boot/loader.conf and then start and see if the problem is during setting the interface from /etc/rc.conf or the problem is during boot and driver loading and check if loaded driver on boot works with manual ifconfig-ing.


----------



## egorenar (Jan 7, 2010)

gnoma said:
			
		

> I did only with the first driver becos after that I couldn't start the PC with the card in the slot, and it worked fine. If u want I can comment that line in /boot/loader.conf and then start and see if the problem is during setting the interface from /etc/rc.conf or the problem is during boot and driver loading and check if loaded driver on boot works with manual ifconfig-ing.



I tested the rt2860 driver in AP mode on FreeBSD 8 and it works fine,
it doesn't matter if you configure it manually or the driver
is loaded automatically at boot time. But on FreeBSD 7.2 it only works if you configure it manually. I will try to fix it but i don't know when.

:e :e :e


----------



## gnoma (Jan 7, 2010)

Well okay then it is not a problem to configure it manualy  the driver is still great  thank you


----------



## Dein (Jan 7, 2010)

Thank you Egorenar for your greate WORK.

Which magic words should be used to setup Dlink DWA-140 (rt2870) in 802.11n hostap mode? Now it works perfectly in 11g/11b mode.


```
home/Dein/>uname -a
FreeBSD qbic.home 8.0-RELEASE-p1 FreeBSD 8.0-RELEASE-p1
```


The driver is great.


----------



## egorenar (Jan 7, 2010)

Dein said:
			
		

> Thank you Egorenar for your greate WORK.
> 
> Which magic words should be used to setup Dlink DWA-140 (rt2870) in 802.11n hostap mode? Now it works perfectly in 11g/11b mode.
> 
> ...



Sorry, but 802.11n mode is still work in progress :e
Are you using your NIC in HOSTAP mode ?


----------



## Dein (Jan 7, 2010)

> Sorry, but 802.11n mode is still work in progress
> Are you using your NIC in HOSTAP mode ?



Only in the test zone  In production zone still using h/w access point.


----------



## egorenar (Jan 8, 2010)

Dein said:
			
		

> Only in the test zone  In production zone still using h/w access point.



And please do not forget to send me feedback and bug reports.
It is importnat for me so i could improve the driver.

:e :e :e


----------



## Dein (Jan 8, 2010)

It looks like I found some crash scenario.

1. Config:
HostAP mode 11g
hostap.conf

```
hw_mode=g
interface=wlan0
logger_syslog=-1
logger_syslog_level=0
logger_stdout=-1
logger_stdout_level=0
debug=3
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
#### IEEE 802.11 related config ####
ssid=freebsd
macaddr_acl=0
auth_algs=1
#### IEEE 802.1X related config ####
ieee8021x=0
#### WPA/IEEE 802.11i config #####
wpa=3
wpa_passphrase=11111111
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
```
2. Notebook (asus eee) connected via wifi from Windows Home to freebsd. Signal level fine. Starting [CMD="ping -t -l 1024 qbic"][/CMD] 
3. Go far from AP till signal lost.
4. Returning to coverage...
5. Freebsd crashed with:

```
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
Sleeping thread (tid 100053, pid 0) owns a non-sleepable lock
panic: sleeping thread
cpuid = 0
```

P.S. mmm do you have any bugtracking system like JIRA or bugzilla?


----------



## egorenar (Jan 8, 2010)

Dein said:
			
		

> It looks like I found some crash scenario.
> 
> 1. Config:
> HostAP mode 11g
> ...



Does it happen every time you do it ?
Crash dump would be most useful for me. Did your system save
the crash dump ? Unfortunately, i cannot test this scenario by myself because i have only one PC and a hardware AP :-(

An i don't have any bugtracking system but you can send everything to my email account.


----------



## egorenar (Jan 9, 2010)

Dein said:
			
		

> It looks like I found some crash scenario.
> 
> 1. Config:
> HostAP mode 11g
> ...



I could reproduce this error by simply restarting hostapd daemon.


```
# /etc/rc.d/hostapd restart
```

I'm working now on a solution.

UPDATE
I have found a solution. Whe i'm done implementing it, i will upload the new version
of driver. The problem is LOCKING in 802.11 stack :-(

UPDATE
Bug fixed, new version here http://forums.freebsd.org/showpost.php?p=55365

:e :e :e


----------



## gnoma (Jan 10, 2010)

ergorenar the driver is great, now works just fine. I tryed this scenario to go out of range and I had no problems. After manualy ifconfig ofcorse.
I tryed a heavy download, gaming, all night constant pinging and there was no problem. It works great. I guess I am to lazy do migrate on BSD8 so I can  make it on boot ifconfig-ing but it is still great.
Thank you! You are the man!


----------



## egorenar (Jan 10, 2010)

gnoma said:
			
		

> ergorenar the driver is great, now works just fine. I tryed this scenario to go out of range and I had no problems. After manualy ifconfig ofcorse.
> I tryed a heavy download, gaming, all night constant pinging and there was no problem. It works great. I guess I am to lazy do migrate on BSD8 so I can  make it on boot ifconfig-ing but it is still great.
> Thank you! You are the man!



Thanks for feedback. I appreciate it.

The problem you mentoned appears only with rt2870 device driver.
And you are using rt2860 device driver.

And i'm investigating the problem with autoloading on FreeBSD 7.2

:e :e :e


----------



## joel@ (Jan 29, 2010)

The run(4) driver, ported from OpenBSD by PseudoCylon, has now been committed to FreeBSD 9-CURRENT.


----------



## PseudoCylon (Feb 14, 2010)

There are updates on the driver for 8.0 and CURRENT. (The same driver still works on both.) The driver is posted at [thread=7562]the first thread[/thread].

Most of updates apply to RT3572 chipset. Also, new firmware is required (included in the tarball) by this updates. Please update *both* driver *and* firmware.

And, some patches to RT30XX chipset.

Details are on RELEASE_NOTES included.


----------



## PseudoCylon (Mar 4, 2010)

Supports for HOSTAP mode has been added, and it's been working for 80+ hours straight. Try it out.

As usual, you can get it at [thread=7562] the first thread[/thread].


----------



## freenaswrls (Mar 7, 2010)

does anyone know how to get this driver working with freenas?


----------



## GeorgeMitchell (Mar 7, 2010)

PseudoCylon said:
			
		

> Supports for HOSTAP mode has been added, and it's been working for 80+ hours straight. Try it out.
> 
> As usual, you can get it at [thread=7562] the first thread[/thread] (run-8.0-REL_3.tar.bz2)



HOSTAP mode works great!  Thanks very much!


----------



## PseudoCylon (Mar 8, 2010)

@freenaswrls
Sorry, not from me. I'm quite handful with CURRENT and 8.0. I only know one individual trying to make it work on pfSense. That's about it. You would be luckier if you post questions at their forums/mailing list. They are listed [thread=7290]here[/thread]

@GeorgeMitchell
High Five! Thank you for testing.


----------



## freenaswrls (Mar 8, 2010)

PseudoCylon said:
			
		

> @freenaswrls
> Sorry, not from me. I'm quite handful with CURRENT and 8.0. I only know one individual trying to make it work on pfSense. That's about it. You would be luckier if you post questions at their forums/mailing list. They are listed [thread=7290]here[/thread]



okay, thanks a lot!


----------



## bsdfan (Mar 21, 2010)

thanks for your work.

I got a usb rt2870 and had checked out head kernel code.

I can see run0 interface.
when I try `wpa_supplicant -i run0 -c ./homewireless.conf -ddd`

wpa_supplicant log shows


```
ioctl[SIOCG80211, op 98, len 32]: Invalid argument
wpa_driver_bsd_init: failed to get device capabilities: Invalid argument
Failed to initialize driver interface.
.....
```

should I upgrade wpa_supplicant? Or something else wrong?

homewireless.conf:

```
nework={
ssid="home"
psk="xxxxxx"
}
```

thanks.


----------



## PseudoCylon (Mar 21, 2010)

bsdfan said:
			
		

> when I try `wpa_supplicant -i [b]run0[/b] -c ./homewireless.conf -ddd`



First you need to create wlan with
`# ifconfig wlan create wlandev [b]run0[/b]`
Then,
`# wpa_supplicant -B -i [b]wlan0[/b] -c ./homewireless.conf`

You only need to use run0 when creating wlan. Once wlan is created, use wlan0 instead of run0. i.e ifoncif wlan0 up, ifconfig wlan0 down, e.t.c. This is new to 8.0. Here are more [thread=8784]details[/thread].


----------



## bsdfan (Mar 22, 2010)

thanks!
I figured that out too after I read document.
but with 9.0-CURRENT kernel but 8.0 release userland, not sure why wpa_supplicant got all of scan ssid "", although I can see the mac is from my ap but the ssid is empty and ifconfig can scan correctly.

I will try a full 9.0 -current.

thanks again!


----------



## PseudoCylon (Mar 23, 2010)

bsdfan said:
			
		

> but with 9.0-CURRENT kernel but 8.0 release userland, not sure why wpa_supplicant got all of scan ssid "", although I can see the mac is from my ap but the ssid is empty and ifconfig can scan correctly.



You've might already swiched to CURRENT, but are you saying
`% ifconfig wlan0 list scan`
shows correct SSID on CURRENT, but all empty SSID on 8.0? (Though, you get correct BSSID on both, CURRENT and 8.0.)


----------



## bsdfan (Mar 24, 2010)

No.
Actually I compiled head kernel source on 8.0 release so I had 9.0-current kernel on 8.0 release userland.
"ifconfig wlan0 list scan" does show correct essid but the scan results from wpa_supplicant didn't(many empty ssids) so I thought it must be something changed in 802.11 stack but wpa_supplicant didn't follow yet. 
then I downloaded 9.0-current iso(it was compiled in feb.2010) and install it, update kernel source to head and recompile kernel(it will have your run support), now wpa_supplicant can show ssid correctly.
now it can work with wpa_supplicant on 9.0-current although there are other filesystem bugs with 9.0-current so I have to go back to 8.0 and recompile world!

thank you very much!


----------



## bsdfan (Mar 25, 2010)

It seems that there is a problem with 5G, 2.4G seems ok. When I scan a 5.765G(chan 153), it can't find it and it takes many times to find once but it seems Linux can easily find it.

thanks


----------



## PseudoCylon (Mar 26, 2010)

First, 11n support hasn't been added, yet. But...

You can speed up scanning process on 5G channels with
`# ifconfig wlan0 outdoor`
This will limit scanning on channels 149 and above. Due to regulatory constraints, this might not work, i.e. in US. Then, set mode to 11a
`# ifconfig wlan0 mode 11a`
This will skip scanning on b/g channels. Otherwise, it scans from channel 1. With "outdoor" option, device will scan + assoc (with 11a + chan 153 AP) in a few second.


----------



## bsdfan (Mar 27, 2010)

thanks for reply.
can I know what is necessary for 11n?

>Due to regulatory constraints, this might not work, i.e. in US. Then, set mode to 11a
Is this limited by the hardware? I enabled the debug info from linux driver and I see country code is in eeprom's parameter.

good to know the "mode 11a"


----------



## PseudoCylon (Mar 27, 2010)

bsdfan said:
			
		

> can I know what is necessary for 11n?


To be quick, make list of channels and tell h/w to use it and to behave as 11n device.



			
				bsdfan said:
			
		

> Is this limited by the hardware? I enabled the debug info from linux driver and I see country code is in eeprom's parameter.


No. It is limited by s/w. Those ifconfig options are little cheats to finish scan quicker. So, the device can find chan 153 quicker. (Without any cheat, scanning all available channels (1 to 173) should be finished within 10 sec.)


----------



## bsdfan (Mar 31, 2010)

I found some bugs in registers setting and I will post later after I verified.


----------



## PseudoCylon (Apr 1, 2010)

Thanks. I'm looking forward to having a patch.

I have found some bugs, too. Check the repository, just in case.


----------



## bsdfan (Apr 1, 2010)

PseudoCylon said:
			
		

> Thanks. I'm looking forward to having a patch.
> 
> I have found some bugs, too. Check the repository, just in case.



thanks!

one question is why you change it from 8 to 10? according to Linux 2870 driver, pAd->EEPROMDefaultValue[0-18], first 3 is nic1,2, country region, but in LInux driver code it only read 8 uint16t from eeprom, and the left 8 will be 0.
so what is the real number of bbps setting?


```
/* read vender BBP settings */

1395         for (i = 0; i < 10; i++) {

1396                 run_srom_read(sc, RT2860_EEPROM_BBP_BASE + i, &val);

1397                 sc->bbp[i].val = val & 0xff;

1398                 sc->bbp[i].reg = val >> 8;

1399                 DPRINTF("BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val)
```

thanks,


----------



## PseudoCylon (Apr 2, 2010)

bsdfan said:
			
		

> one question is why you change it from 8 to 10? according to Linux 2870 driver, pAd->EEPROMDefaultValue[0-18], first 3 is nic1,2, country region, but in LInux driver code it only read 8 uint16t from eeprom, and the left 8 will be 0.
> so what is the real number of bbps setting?


Short answer is 19.

There are 19 short values to read.





			
				bsdfan said:
			
		

> pAd->EEPROMDefaultValue*[0-18]*


[0-18] means 19 slots. My driver and linux driver agree with it.

My code reads word at a time, so I need to loop 10 times. (Looping 9Â½ times won't work.)

Linux driver should look like
	
	



```
pAd->EEPROMDefaultValue[0] = nic1;
pAd->EEPROMDefaultValue[1] = nic2;
pAd->EEPROMDefaultValue[2] = country;

for(i = 0; i < 8; i++){
read_eeprom16(aAd, EEPROM_BBP_BASE + i*2, tmp);
pAd->EEPROMDefaultValue[i + 3] = tmp;
}
```
reads first 3 bytes and then loop 8 times to read 4th to 19th byte. (3 + word x 8 = 19 bytes)


----------



## g_willikers (Apr 8, 2010)

PseudoCylon said:
			
		

> -- Update on Jan 29, 2010 --
> 
> The run(4) driver has been committed to FreeBSD 9-CURRENT.
> 
> ...



Greetings,
 I have some questions about procedure in the README file in the run-8.0-REL_3.tar.bz2
archive.
First, I am dual-booting win2k3 enterprise LVE && freebsd-8. I will have no internet access
for FreeBSD until I get my ENCORE ENUWI-N3 dongle to work in FreeBSD.
The software CD that came with it installed rt2870.sys. I tried egorenar's driver
(http://forums.freebsd.org/showthread.php?p=76769). But he advised me to use the "run" driver. So here I am. 

```
[b]# uname -a[/b]
FreeBSD l400.ultimatedns.NET 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009
root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
```


```
[b]#usbconfig dump_device_desc[/b]
ugen0.1: <UHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen0.2: <802.11 n WLAN Ralink> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0000
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x203d
  idProduct = 0x1480
  bcdDevice = 0x0101
  iManufacturer = 0x0001  <Ralink>
  iProduct = 0x0002  <802.11 n WLAN>
  iSerialNumber = 0x0003  <1.0>
  bNumConfigurations = 0x0001
```

I know this may sound stupid. But being as I have to keep bouncing back-and-forth (reboting)
between windows and freebsd. I want to make sure I don't make this more difficult than
it needs to be.
According the the README:

```
How to use
----------
0) read Ralink license at
	sys/contrib/dev/run/LICENSE
1) over write usbdevs
	%cd sys/dev/usb
	#cp usbdevs /usr/src/sys/dev/usb/
	  (or where ever your src files are)
2) make firmware
	%cd sys/modules/runfw
	%make
	#make install
3) make driver
	%cd sys/modules/usb/run
	%make
	#make install
4) load firmware
	#kldload runfw
		(Optional: Driver will load fw for you as long as fw is installed.)
5) load driver
	#kldload if_run
6) create wlan (new to FreeBSD 8.0)
	#ifconfig wlan create wlandev run0
	#ifconfig wlan0 country XX
		substitute "XX" with proper country code. The list of available
		country code can be viewed by running
			%ifconfig wlan0 list countries
		The default country is US. So, if you live in north America region,
		setting country code doesn't matter.
7) configure it for your needs, for example, "ifconfig wlan0 up",
   "wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf", etc.
```
My copy of the archive run-8.0-REL_3.tar.bz2 has no "sys" folder in it. Yet, I _assume_
I need to copy (and overwrite) files located in my "sys" && "src/sys" tree - yes?
When referring to sys && src can you please reference "archive" folder vs "system" folder,
so it is _real_ clear which one is which?

Thank you for all your time and consideration.
Thank you also, for all your hard work on this driver.

--Chris (g_willikers)


----------



## g_willikers (Apr 9, 2010)

Greetings again,
 It worked! 

OK, for anyone else that may have had the same question I did;
If you replace every occurrence of:

```
%cd sys/...
```
with

```
%cd run/...
```
(assuming the root of the archive) it will all work as described.

Given that I was not able to plan for the migration to wireless, but abruptly forced to,
I'll now have to figure out how to make use of it. 
FWIW here's the output from the two commands listed in the README, in case it helps anyone
else with this dongle:

```
[b]kldload runfw[/b]
firmware: 'runfw' version 1: 8192 bytes loaded at 0xc2c9054c
```


```
[b]#kldload if_run[/b]
run0: <1.0> on usbus0
run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 1T1R), address XX:XX:XX:XX:XX:XX
run0: firmware RT2870 loaded
run0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
run0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36M
bps 48Mbps 54Mbps
```
NOTE: XX:XX:... has been masked out

Thank you for all your hard work on this driver, PseudoCylon!


--Chris (g_willikers)


----------



## g_willikers (Apr 9, 2010)

Greetings again,
 Apologies for the repeated (excessive?) posts. But I'm attempting to get as much info as
possible *before* rebooting to freebsd, where I am not able to view these forums and
all the info in them. That said;
According to the README:

```
4) load firmware
   #kldload runfw
       (Optional: Driver will load fw for you as long as fw is installed.)
```
After I rebooted, the driver was not loaded (did not show up in messages during verbose boot)
Do I need to load it via /boot/loader.conf? eg; fw_load="YES"
Or do I need to create /etc/rc.conf indicators that I'm using run/wlan0 etc, where it will
_then_ get loaded?
Speaking if rc.conf entries;
Assuming a WEP setup, would the following get the job done?

```
ifconfig wlan create wlan0 ssid <my_ssid> wepmode on wepkey <my_wepkey> weptxkey 1 up
```
and if so,
 How would I best translate that to rc.conf entr(y|ies)?

Thanks again, and apologies for the niose. I'll happily post a *consolidated* how-to
to help others when I get this sorted out. 

--Chris


----------



## g_willikers (Apr 9, 2010)

OK
I used the following:

```
[b]/boot/loader.conf[/b]
if_run_load="YES"
runfw_load="YES"
```
which loaded the drivers/devices

at the tty0

```
ifconfig wlan create wlandev run0 ssid <my_ssid> wepmode on wepkey <my_wepkey> \
weptxkey 1 up
```
which made my dongle start blinking. But never logged in, or assigned an address.
I'm *sure* I need more information for /etc/rc.conf but don't know how to address
the device. Should it be if_run0?

Sorry, but after reading a great deal of material, I'm still not quite sure of all the
answers.

Thank you for all your time and consideration.

--Chris


----------



## g_willikers (Apr 9, 2010)

*unable to connect...*

Greetings,
 Well, I think I've been able to sort most of it out.
Adding the following to /etc/rc.conf:

```
wlans_run0="wlan0"
wlan_wep_load="YES"
ifconfig_wlan0="ssid <my_net> wepmode on weptxkey 1 wepkey <my_key> DHCP"
```

results in the following:

```
[b]ifconfig[/b]run0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether XX:XX:XX:XX:XX:XX
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
        status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether XX:XX:XX:XX:XX:XX
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid <my_net> channel 11 (2462 Mhz 11g)
        country US authmode OPEN privacy ON deftxkey 1 wepkey 1:40-bit
        txpower 0 bmiss 7 scanvalid 60 protmode CTS wme bintval 0
```
NOTE: XX:XX:... has been used to mask the ether
<my_net> is a mask for my actual network
<my_key> is a mask for my actual WEP key
channel 11 varies, as it polls all the channels. So sending another ifconfig will likely result in a different channel showing.

That said; I'm not able to link up (make a connection) - no carrier

Can anyone suggest something I'm missing?
I know WEP isn't the best choice. But until I can actually connect, WEP should at least
be the simplest (lowest denominator) choice.
FWIW this is an 802.11n dongle

Thank you for all your time and consideration.

--Chris


----------



## PseudoCylon (Apr 9, 2010)

Hello,

Sorry for typo in README. I'll update it.

First, my driver doesn't support N yet. (I need more time to add it.) So, make sure your AP is compatible with G mode.

With RT3070 you need to unplug the device every time the device is brought down. And depend on the computer you are using, rebooting won't help. (shutdown and power on is OK) So, When you reboot, you might need to unplug the device. (This is RT3070 specific problem.)

To eliminate all the variables, when you reboot to FreeBSD, try
`# ifconfig wlan0 destroy`
unplug and re-plug-in the device because /etc/rc.conf will bring it up. Also, /boot/loader.conf should load the driver. I assume the driver is loaded. So, just try,
`# ifconfig wlan create wlandev run0`
`# ifconfig wlan0 ssid <my_net> wepmode on weptxkey 1`
`# ifconfig wlan0 up`
Forget about wepkey for now.
`% ifconfig wlan0`
should say "associated" Might take 10-15 sec.
	
	



```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether XX:XX:XX:XX:XX:XX
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: [B]associated[/B]
        ssid <my_net> channel 11 (2462 Mhz 11g)
        country US authmode OPEN privacy ON deftxkey 1 wepkey 0-bit
        txpower 0 bmiss 7 scanvalid 60 protmode CTS wme bintval 0
```
Encryption kicks in after association. First you want to associate with an AP. When you see "associated"
`# ifconfig wlan0 wepkey [color="Red"]1:0x[/color]<my_hex_key>`
`# dhclient wlan0`
Then should see something like
	
	



```
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.0
bound to 192.168.0.1 -- renewal in 43200 seconds.
```

If you want to automate the loading process, wpa_supplicant with ether wep or wpa would works better. But see if manual load work for now.


----------



## g_willikers (Apr 9, 2010)

Greetings PseudoCylon, and thank you *very much* for your informative reply.
I followed your instructions, but was unable to connect.
FWIW

```
[b]/boot/loader.conf[/b]
runfw_load="YES"
if_run_load="YES"
```
The address in my */etc/rc.conf* file is *defaultrouter*. which is the one assigned
by my upstream (wireless provider) - it's DHCP.

After following your instructions (before sending the *wepkey*), issuing *ifconfig wlan0*
returns:

```
[b]# ifconfig wlan0[/b]
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether XX:XX:XX:XX:XX:XX
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid <my_net> channel 10 (2457 Mhz 11g)
        country US authmode OPEN privacy ON deftxkey 1 wepkey 1:40-bit
        txpower 0 bmiss 7 scanvalid 60 protmode CTS wme bintval 0
```

followed by

```
[b]# dhclient wlan0[/b]
wlan0: no link .............. giving up
```

Here's additional output

```
[b]# ifconfig[/b]
xl0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=9<RXCSUM,VLAN_MTU>
	ether XX:XX:XX:XX:XX:XX
	media: Ethernet autoselect (100baseTX)
	status: active
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=3<RXCSUM,TXCSUM>
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
	inet6 ::1 prefixlen 128 
	inet 127.0.0.1 netmask 0xff000000 
run0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
	ether XX:XX:XX:XX:XX:XX
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11g
	status: associated
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether XX:XX:XX:XX:XX:XX
	media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
	status: no carrier
	ssid <my_net> channel 6 (2437 Mhz 11g)
	country US authmode OPEN privacy ON deftxkey 1 wepkey 1:40-bit
	txpower 0 bmiss 7 scanvalid 60 protmode CTS wme bintval 0
```

I should probably note that this is on a freshly installed FreeBSD-8.0 from the CD.
As I have no access to the internet from FreeBSD, I can't install/update anything.
So if I am required to build anything, I'll need to download a package from Winblows,
and copy it to my USB memstick, then mount that in FreeBSD ... you get the picture. 

Anyway thought that might be worth noting.

Is there anything you (or anyone else) can think of/suggest? I'd *really* hate
to have to make Linux - or worse, Windows, be the gateway for all of the FreeBSD servers
I have had running for _years_ now. *Please* help, I beg you.

Thank you for all your time and consideration.

--Chris


----------



## PseudoCylon (Apr 9, 2010)

g_willikers said:
			
		

> The address in my */etc/rc.conf* file is *defaultrouter*. which is the one assigned
> by my upstream (wireless provider) - it's DHCP.


So, you are trying to connect your wireless internet provider with USB dongle. Are all of setting, ssid and wep, matches what provider supplied? After
`# ifconfig wlan0 up` (forget about all other options)
wait for 15 sec. or so. (Give device time to scan all channels.) Then, can you show me the out put of
`% ifconfig wlan0 list scan`
There must be your provider's ssid on the list, even though you cannot connect.
If I'm misunderstanding, please tell me what you are connecting to.



			
				g_willikers said:
			
		

> Is there anything you (or anyone else) can think of/suggest? I'd really hate to have to make Linux - or worse, Windows, be the gateway for all of the FreeBSD servers I have had running for years now. Please help, I beg you.


Are you trying to set up FreeBSD router? If so, it depends on how much traffic you have. There are lots of options. You don't need to worry. Just focus on make the device work, now.


----------



## g_willikers (Apr 9, 2010)

PseudoCylon said:
			
		

> So, you are trying to connect your wireless internet provider with USB dongle. Are all of setting, ssid and wep, matches what provider supplied? After
> `# ifconfig wlan0 up` (forget about all other options)
> wait for 15 sec. or so. (Give device time to scan all channels.) Then, can you show me the out put of
> `% ifconfig wlan0 list scan`
> ...


Thank you *very* much PseudoCylon, for your reply.
Doing a *ifconfig wlan0 list scan* _does_ show my upstream "hotspot".
I'll run it, and provide it's output for you.



			
				PseudoCylon said:
			
		

> Are you trying to set up FreeBSD router? If so, it depends on how much traffic you have. There are lots of options. You don't need to worry. Just focus on make the device work, now.


No. I'm not trying to mess with anything _except_ to get connected by the wireless
for now. 

I'll report back with what I get from these instructions.

Thank you again for your response, PseudoCylon.

--Chris

PS the *wepkey* I am using while booted to Windows is text _not_ hex.
I use a text wepkey in FreeBSD too. Should I convert the characters to hex?

Thanks again.


----------



## g_willikers (Apr 9, 2010)

Hello again PseudoCylon,
 Here's what I did

```
ifconfig wlan0 destroy
ifconfig wlan create wlandev run0
ifconfig wlan0 ssid <my_net> wepmode on weptxkey 1
ifconfig wlan0 up
[b]waited 2.5 minutes[/b]
ifconfig wlan0 list scan

SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
<my_net>        XX:XX:XX:XX:XX:XX    1   54M -14:-15   50 EP  
Annie's House   00:1f:f3:01:d7:53    6   54M -52:-89  100 EPS  RSN HTCAP WPA WME
SuperG          00:1d:6a:e1:1b:5f    6   54M -48:-85  100 ES   WPS
CraigersPC      00:24:b2:5e:a0:73    3   54M -47:-83  100 EPS  RSN WPA WME HTCAP ATH WPS
```

Does any of this provide clues?

Thanks for all your time and consideration.

--Chris


----------



## g_willikers (Apr 9, 2010)

Hello again, PseudoCylon.
Truth be known, it may be the wepkey that's the issue. While booted to Winblows, the
configuration accepts (and is using) a pure ASCII string for the wepkey.
However, the AP - and presumably the commands I'm passing; _assume_ I'm passing
a 104bit *hex* string. I may be way off here (2 days working on this w/o sleep)
but I translated the ASCII string I use to connect, into the hex counterparts, using
the hex equivalents for example the capital letter *A* would be *41*, the
number *7* would be *37*. So, if my entire wepkey was *A7*, I would
enter *4137* for the wepkey. *However*, I know that the ASCII string needs
to be a minimum of *5* characters (which I use). SO I guess my question is:
Am I converting the ASCII to HEX correctly? It doesn't seem like a long enough HEX
string to amount to 104bits.

Just thought I'd mention it.

Thanks for all your time and consideration.

--Chris


----------



## g_willikers (Apr 9, 2010)

OK I generated 4 64bit keys based on the ASCII string I use as my WEP key.
I fed each of them on the cli as:

```
ifconfig wlan0 wepkey 1:<64bit_key#1>
ifconfig wlan0 wepkey 1:<64bit_key#2>
ifconfig wlan0 wepkey 1:<64bit_key#3>
ifconfig wlan0 wepkey 1:<64bit_key#4>
```
but no joy.
I even setup a */etc/wpa_supplicant.conf* file with the 4 different
*wep_key0=* entries, and tried that, but still no luck.
Everything showed correct in *ifconfig wlan0* output *but* the line that read
*no carrier*. The light on the USB dongle blinks away, but that's all. sigh...


Anyway, if you can think of anything, I'd *love* to hear it. 

Thanks for all your time and consideration.

--Chris


----------



## g_willikers (Apr 9, 2010)

Well, I managed to get an *association* through wpa_supplicant.
But it was only for a short time and it renegotiated because I was
never able to receive an address. So it threw multicast related errors
and when ifconfig wlan0 showed association, it _also_ showed
address 0.0.0.0. 

So I'm still trying to find a cure/lead. But haven't figured where to
find it.

Best wishes.

--Chris


----------



## g_willikers (Apr 9, 2010)

Greetings again,
 Am I missing something here, or is there something in the *ifconfig(8) create command*
that I'm (we're) missing here. For example, you indicated I issue:
*ifconfig wlan create wlandev run0*
For example would it make sense to use something like this in /etc/rc.conf:
*wlans_run0="wep0 sta"*
or would that be better created with the
*ifconfig create wlandev run0 sta* command

Just some thoughts, as I try to make the run driver work...

--Chris


----------



## PseudoCylon (Apr 10, 2010)

I see. My driver won't work on one microsoft wy. You need to move away form it.

OK, first thing first. You might want to comment out/delete lines you added to /etc/rc.conf and forget about it for now. That's step 692. We are at step one.

First, you need to associate with AP. Otherwise, nothing works.





			
				g_willikers said:
			
		

> Well, I managed to get an *association* through wpa_supplicant. But it was only for a short time and it renegotiated because I was never able to receive an address. So it threw multicast related errors and when ifconfig wlan0 showed association, it _also_ showed address 0.0.0.0.


This is a good thing. as long as ifconfig say "associated" it is OK. It most likely a need-to-re-plug-in issue, you couldn't associate before.

Now, wepkey. You don't need to convert ascii to hex. But, ascii key works on windows usually won't work on freebsd. You can try it, but if it won't work, you might need to get hex wep key from your provider. Also, make sure default tx key index agrees with your provider. If not, it won't work. If need to update wpa_supplicant.conf, update first and run wpa_supplicant.

Then
`# dhclient wlan0`
wpa_supplicant won't do dhcp business.

If it won't work, please tell me,
it doesn't associate and nothing in ifconfig wlan0 list scan,
it doesn't associate but your provider is listed on list scan, or
it associates but dhclient doesn't get IP address.
These are all different issues. And what's in wpa_supplicant.conf


----------



## g_willikers (Apr 12, 2010)

PseudoCylon said:
			
		

> I see. My driver won't work on one microsoft wy. You need to move away form it.


OK Update: I took your advice and spent most of the weekend moving to 443 BSD wy.
*Thank you* for the advice, this is a *much* nicer neighborhood. I haven't
seen one Trojan, or Virus in the neighborhood - not one!



			
				PseudoCylon said:
			
		

> OK, first thing first. You might want to comment out/delete lines you added to /etc/rc.conf and forget about it for now. That's step 692. We are at step one.


Done



			
				PseudoCylon said:
			
		

> First, you need to associate with AP. Otherwise, nothing works.This is a good thing. as long as ifconfig say "associated" it is OK. It most likely a need-to-re-plug-in issue, you couldn't associate before.


OK you mentioned an issue about this early in this thread. As I understand it, if there
seems a problem I need to unplug it, then enter [cmd=]ifconfig wan0 destroy[/cmd], then plug
the USB dongle back in - correct?



			
				PseudoCylon said:
			
		

> Now, wepkey. You don't need to convert ascii to hex. But, ascii key works on windows usually won't work on freebsd. You can try it, but if it won't work, you might need to get hex wep key from your provider. Also, make sure default tx key index agrees with your provider. If not, it won't work. If need to update wpa_supplicant.conf, update first and run wpa_supplicant.


I converted my ASCII wepkey via: http://www.wepkey.com/
Which produced 4 64bit keys, and a 128bit key. While I _can_ login to my "hotspot"
(Sierra Wireless w801) and change the encryption type (WEP,WPA,WPA2,etc...) but WEP seems to have the least variables, and therefore the
easiest to use for testing.
So I made 4 entries in wpa_supplicant.conf using all 4 64bit keys, which _should_
equal my ASCII equivalent. Then I issued
[cmd=]# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf[/cmd]
Which at several points indicated an *association* in the *status* field,
otherwise *no carrier*



			
				PseudoCylon said:
			
		

> Then
> `# dhclient wlan0`
> wpa_supplicant won't do dhcp business.
> 
> ...



Thank you for your continued help, and advice PseudoCylon, I *greatly* appreciate it.

I'll try again w/o the /etc/rc.conf entries and report the results.

--Chris


----------



## PseudoCylon (Apr 12, 2010)

g_willikers said:
			
		

> I converted my ASCII wepkey via: http://www.wepkey.com/
> Which produced 4 64bit keys, and a 128bit key. While I _can_ login to my "hotspot"
> (Sierra Wireless w801) and change the encryption type (WEP,WPA,WPA2,etc...) but WEP seems to have the least variables, and therefore the easiest to use for testing. So I made 4 entries in wpa_supplicant.conf using all 4 64bit keys, which _should_ equal my ASCII equivalent. Then I issued *# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf* Which at several points indicated an *association* in the *status* field, otherwise *no carrier*


OK. Here is the problem. You have to type in those 4 64-bit keys into your Sierra Wireless w801. Encryption isn't working because the keys in Sierra Wireless w801 and ones in wpa_supplicant.conf doesn't match. There must be fields you can type in encryption keys somewhere near you can set wep/wpa. I guess ascii key is for login to Sierra Wireless w801 not for encryption. Once both encryption keys, in Sierra Wireless w801 and wpa_supplicant.conf match, the device shall work.

When you unplug the device, wlan destroy first, then unplug and plug it back in. But, it is most likely encryption key problem.


----------



## g_willikers (Apr 13, 2010)

Hello again PseudoCylon,
 Here's a Thanks for your recent post. 
I have to preface the following by stating that I've been "wired" since '75 - yes; I _do_ mean 1975.
You could hand me a crate of BGP's, Switches, Routers, Modems, and cables, and I'd have
everything wired up, and the Networking in full working order in under 10 minutes.
Point being, I've had no need to deal with "wireless" (outside a Cell Phone). So if
it's not already painfully obvious; I'm no "expert" in this department. :r
This is _not_ to say I haven't completely read, and become familiar with the
FreeBSD wireless documentation 

The only interface provided by the W801, is via web browser. I've become quite familiar
with it. And don't recall anything matching your description (as I understand you).
That being said, I'll look though all the possibilities available, and see if I can
find anything interesting, that might shed some light on why I'm unable to get the
desired communication with it through run0/wlan0/wpa_supplicant.

Thanks again for all your time and continued consideration.

--Chris


----------



## PseudoCylon (Apr 13, 2010)

g_willikers said:
			
		

> The only interface provided by the W801, is via web browser.


Yes, that usually is. If you can select ecryption mode, you should be able to set keys. Otherwise, encryption is useless. It might say password, wireless password, wifi password, or something like that.





			
				g_willikers said:
			
		

> that might shed some light on why I'm unable to get the desired communication with it through run0/wlan0/wpa_supplicant


I'm quite sure that W801 and your computer have different keys. As long as they have mismatched keys, it won't work. Or, usually ascii wep key is a problem. It might never work. You might want to select different encryption mode or maybe no encryption for time being.

Once you change the settings, you will lose connection though windows until you re-configure. So, do it at your own discretion.


----------



## g_willikers (Apr 13, 2010)

Hello PseudoCylon, and thanks for the response.
I just finished changing all the settings in the W108 to use WPA/WPA2.
Which entailed dropping the 5 character ASCII password for a 8-63 character
password. I made the new password, and restarted the Winblows networking
to test connectivity with the new setup. It works.
I created a new wpa_supplicant.conf file with all the anticipated fields
required. I created a ASCII field, and one generated with wpa_passphrase(5)
to insure this area will be fully covered. I was just about to reboot to FreeBSD,
but thought I'd check back here before I did, and found your thoughtful reply.

Thanks.

Wish me luck. 

--Chris


----------



## PseudoCylon (Apr 13, 2010)

Hope I'm replying early enough.


			
				g_willikers said:
			
		

> I created a ASCII field, and one generated with wpa_passphrase(5)
> to insure this area will be fully covered.


Try this simple wpa_supplicant.conf

```
network={
  ssid="<my_net>"
  psk="<my_key>"
}
```
<my_key> is exactly the same as you have typed into W801. No need to use wpa_passphrase(8)


----------



## bsdfan (Apr 14, 2010)

PseudoCylon said:
			
		

> Thanks. I'm looking forward to having a patch.
> 
> I have found some bugs, too. Check the repository, just in case.



I have reported these to OpenBSD and it had already been committed by openbsd developer.
I saw you have merge one into FreeBSD, you will find more

thanks!


----------



## PseudoCylon (Apr 15, 2010)

Thanks for reporting bugs. Please report if you find more.

Does your device work better now?


----------



## bsdfan (Apr 20, 2010)

Yes, they work better.

thanks!


----------



## ericbsd (Sep 23, 2010)

I am kind of lost here. I try to have my cisco syslink wusb600n to work on FreeBSD. But I didn't find the driver on all those post. 
and Him new to wireless.


----------



## PseudoCylon (Sep 23, 2010)

The driver is included in 8.1-RELEASE. If you have just done standard installation,
`# kldload if_run`
will load the driver.

If you need 11n support, the driver is posted at the first thread.


----------



## ericbsd (Sep 23, 2010)

PseudoCylon said:
			
		

> The driver is included in 8.1-RELEASE. If you have just done standard installation,
> `# kldload if_run`
> will load the driver.
> 
> If you need 11n support, the driver is posted at the first thread.



Yes but how to configure it to work.

On my rc.conf.


----------



## DutchDaemon (Sep 23, 2010)

PseudoCylon, is there a man page in the works yet? I see that run(4) is not yet available in 8.1-STABLE / 9-CURRENT as of today.


----------



## PseudoCylon (Sep 24, 2010)

*@ericturgeon*


			
				ericturgeon said:
			
		

> Yes but how to configure it to work.


Nothing special. Please see this post and freebsd hand book.


			
				ericturgeon said:
			
		

> On my rc.conf.


It depends how you want to set up. Basically, following 2 lines in /etc/rc.conf would do the trick
	
	



```
wlans_run0="wlan0"
ifconfig_wlan0="DHCP"
```
the freebsd hand book explains well.


*@DutchDaemon, The moderator*


			
				DutchDaemon said:
			
		

> PseudoCylon, is there a man page in the works yet? I see that run(4) is not yet available in 8.1-STABLE / 9-CURRENT as of today.


Actually, there is a man page in head tree
http://www.freebsd.org/cgi/cvsweb.cgi/src/share/man/man4/run.4
I don't why it isn't in 8.1 nor in online man page. Currently, installing 9-CURRENT is the only way to see the man page.

-- update Jan. 12, 2011 --
man pages have been commit to the HEAD
http://svn.freebsd.org/viewvc/base?view=revision&revision=217289


----------



## ericbsd (Sep 24, 2010)

@PseudoCylon

I have already try this in /etc/rc.conf.

```
wlans_run0="wlan0"
ifconfig_wlan0="DHCP"
```

and I have put thi in my /boot/loader.conf.

```
if_run_load="YES"
```
It doesn't  work. That's why I say the Handbook don't cover my case.


----------



## ericbsd (Sep 24, 2010)

I have to put this in my /boot/loader.conf to have my wireless to work.

```
if_run_load="YES"
runfw_load="YES"
```

Problem solve.


----------



## Nollo (Nov 24, 2010)

Does it support RTL8192 ?


----------



## PseudoCylon (Nov 25, 2010)

Nollo said:
			
		

> Does it support RTL8192 ?


Unfortunately no.
The driver supports some of Ralink chips, but RTL8192 is a Realtek chip (as far as I know).


----------



## Nollo (Nov 25, 2010)

PseudoCylon said:
			
		

> Unfortunately no.
> The driver supports some of Ralink chips, but RTL8192 is a Realtek chip (as far as I know).



ah yes sorry, I posted here because someone spoke about this chipset in page 2


----------



## Dein (Nov 28, 2010)

Good day PseudoCylon,

I have several questions:

1. First of all, I want to test 802.11n driver version, but all links on the first page are broken.
2. I have next difficalties with your driver under 8.1-Release and 8.2-Prerelease version when connecting to AP:
   a. On AMD64 machine - "Kernel panic: fatal trap 12" without dump.
   b. On x86 machine - I got connection terminated without reason or case "a".

My hostap.conf

```
hw_mode=g
interface=wlan0
logger_syslog=-1
logger_syslog_level=0
logger_stdout=-1
logger_stdout_level=0
debug=3
#channel=6
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
#### IEEE 802.11 related config ####
ssid=freebsd1
macaddr_acl=0
auth_algs=1
#### IEEE 802.1X related config ####
ieee8021x=0
#### WPA/IEEE 802.11i config #####
wpa=3
wpa_passphrase=11111111
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
```

WBR,
Dein


----------



## PseudoCylon (Dec 1, 2010)

Hi,


			
				Dein said:
			
		

> 1. First of all, I want to test 802.11n driver version, but all links on the first page are broken.


Please try this link instead.
11n beta
It is beta because it might stall during high traffic.





			
				Dein said:
			
		

> 2. I have next difficalties with your driver under 8.1-Release and 8.2-Prerelease version when connecting to AP:
> a. On AMD64 machine - "Kernel panic: fatal trap 12" without dump.
> b. On x86 machine - I got connection terminated without reason or case "a".
> 
> My hostap.conf


Can you give me more deatil what you are doing with what commands you issue? I suppose "connecting to AP" means you are using the driver as client. Then you don't need /etc/hostapd.conf. 

As far as I know, the driver causes panic when try to create the wlan without loading firmware. When failed to load firmware, it will print
	
	



```
run0: could not load 8051 microcode
```
Did you compiled firmware into kernel or loading it as a module?


----------



## okeeblow (Dec 14, 2010)

runfw(4) claims:



> To compile this module into the kernel, place the following line in your
> kernel configuration file:
> 
> "device runfw"
> ...



But this does not seem to be a valid kernel configuration directive.


```
config: Error: device "runfw" is unknown
config: 1 errors
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
```

Unfortunately, the platform I'm building for does not use loader, so I have no other way to load it at boot.


----------



## PseudoCylon (Dec 15, 2010)

okeeblow said:
			
		

> ```
> config: Error: device "runfw" is unknown
> config: 1 errors
> *** Error code 1
> ...



Please add following to src/sys/conf/files

```
runfw.c				optional runfw							\
	compile-with	"${AWK} -f $S/tools/fw_stub.awk runfw:runfw -mrunfw -c${.TARGET}"	\
	no-implicit-rule before-depend local							\
	clean		"runfw.c"
runfw.fwo			optional runfw							\
	dependency	"runfw"									\
	compile-with	"${LD} -b binary -d -warn-common -r -d -o ${.TARGET} runfw"		\
	no-implicit-rule									\
	clean		"runfw.fwo"
runfw				optional runfw							\
	dependency	"$S/contrib/dev/run/rt2870.fw.uu"					\
	compile-with	"uudecode -o ${.TARGET} $S/contrib/dev/run/rt2870.fw.uu"		\
	no-obj no-implicit-rule									\
	clean		"runfw"
```
You can put the code anywhere, but next to the line
	
	



```
dev/usb/wlan/if_run.c		optional run
```
would be easier to remember in the future.

I have re-submitted all the changes. This would be committed soon.

-- update Jan. 12, 2011 --
The change has been commit to the HEAD
http://svn.freebsd.org/viewvc/base?view=revision&revision=217288


----------



## okeeblow (Dec 15, 2010)

That worked, Thanks 


I'm getting panics when I try to connect to my hostap network, though. I'll post this here unsure if it's a problem with the driver or a problem with the freebsd-arm kernel. My adapter is a TP-LINK TL-WN321G. I bought it since it was supposed to be a rum() device, but the one I got is RT3070.


```
pochan# uname -a
FreeBSD pochan 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #9: Wed Dec 15 01:09:57 EST 2010     nicole@Emi.cooltrainer.org:/usr/obj/arm/usr/
src/sys/DOCKSTAR-COOLTRAINER  arm
```


```
ugen0.5: <Ralink> at usbus0
run0: <1.0> on usbus0
run0: MAC/BBP RT3070 (rev 0x0201), RF RT2020 (MIMO 1T1R), address d8:5d:4c:98:3b:7f
run0: firmware RT2870 loaded

pochan# usbconfig -u 0 -a 5 dump_device_desc                      
ugen0.5: <802.11 g WLAN Ralink> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0200 
  bDeviceClass = 0x0000 
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x148f 
  idProduct = 0x2070 
  bcdDevice = 0x0101 
  iManufacturer = 0x0001  <Ralink>
  iProduct = 0x0002  <802.11 g WLAN>
  iSerialNumber = 0x0003  <1.0>
  bNumConfigurations = 0x0001
```


```
pochan# ifconfig wlan0 create wlandev run0 wlanmode hostap
wlan0: Ethernet address: d8:5d:4c:98:3b:7f
pochan# ifconfig wlan0 inet 172.16.0.2 netmask 255.240.0.0 ssid FreeBSD-Kirkwood channel 11

pochan# ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether d8:5d:4c:98:3b:7f
        inet 172.16.0.2 netmask 0xfff00000 broadcast 172.31.255.255
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid FreeBSD-Kirkwood channel 11 (2462 MHz 11g) bssid d8:5d:4c:98:3b:7f
        country US authmode OPEN privacy OFF txpower 0 scanvalid 60
        protmode CTS wme dtimperiod 1 -dfs
```








```
vm_fault(0xc0cc9254, 0, 1, 0) -> 1
Fatal kernel mode data abort: 'Translation Fault (P)'
trapframe: 0xc8413d8c
FSR=00000017, FAR=0000000c, spsr=20000013
r0 =c1bba000, r1 =00000000, r2 =00000000, r3 =00001908
r4 =00000000, r5 =c1bba000, r6 =c1bba000, r7 =c19e7c00
r8 =c19ee778, r9 =c09c97c0, r10=c19db000, r11=00000000
r12=c0ce2100, ssp=c8413dd8, slr=c09c9818, pc =c0ae6cd8

panic: Fatal abort
Uptime: 16m8s
Cannot dump. Device not defined or unavailable.
Automatic reboot in 15 seconds - press a key on the console to abort
```


----------



## PseudoCylon (Dec 23, 2010)

Sorry for taking long.

Can you try these?

If it doesn't work, please show me out put of`% ifconfig`(without _wlan0_), and /etc/rc.conf (if you are using nat), /etc/hostapd.conf (if you are using).


----------



## okeeblow (Jan 5, 2011)

```
vm_fault(0xc0cc93d4, 0, 1, 0) -> 1
Fatal kernel mode data abort: 'Translation Fault (P)'
trapframe: 0xc8413d8c
FSR=00000017, FAR=0000000c, spsr=20000013
r0 =c1adb000, r1 =00000000, r2 =00000000, r3 =00001908
r4 =00000000, r5 =c1adb000, r6 =c1adb000, r7 =c19e7c00
r8 =c19ee778, r9 =c09c9350, r10=c19db000, r11=00000000
r12=c0ce2280, ssp=c8413dd8, slr=c09c93a8, pc =c0ae6ca0

panic: Fatal abort
Uptime: 8m55s
Cannot dump. Device not defined or unavailable.
Automatic reboot in 15 seconds - press a key on the console to abort
```

rc.conf

```
swapfile="/usr/swap0"

hostname="pochan"
gateway_enable="YES"

ifconfig_mge0="up"
ifconfig_ue0="DHCP"
wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="up ssid FreeBSD-Kirkwood channel 11"

ntpd_enable="YES"
ntpd_flags="-g"

sshd_enable="YES"
fsck_y_enable="YES"
background_fsck="NO"
force_fsck="YES"
force_fsck_list="/"

postfix_enable="YES"
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
```

I believe this may be a more general problem on the ARM architecture, since I've received mail from people having the same problem with a rum controller. I filed a PR a while ago.


----------



## PseudoCylon (Jan 8, 2011)

okeeblow said:
			
		

> I believe this may be a more general problem on the ARM architecture, since I've received mail from people having the same problem with a rum controller. I filed a PR a while ago.


Sounds like it if the same problem occurs with rum(4).

Can you show me the output of followings? (assuming everything is compiled into kernel)`% objdump -h [FILE]/where/your_kernel/is/[/FILE]kernel | grep text` (The kernel doesn't have to be on Dockstar to run the command.)`% objdump -S --start-address=0xc8413d88 --stop-address=0xc8413da0 [FILE]/where/your_kernel/is/[/FILE]kernel`(-'S' is uppercase)

I'll try to find a workaround if possible. (Usually it is too far from the driver.)


----------



## okeeblow (Jan 9, 2011)

```
[root@Emi#/root]objdump -h /usr/obj/arm/usr/src/sys/DOCKSTAR-COOLTRAINER/kernel.bin|grep text           
objdump: /usr/obj/arm/usr/src/sys/DOCKSTAR-COOLTRAINER/kernel.bin: File format not recognized
[root@Emi#/root]objdump -S /usr/obj/arm/usr/src/sys/DOCKSTAR-COOLTRAINER/kernel.bin
objdump: /usr/obj/arm/usr/src/sys/DOCKSTAR-COOLTRAINER/kernel.bin: File format not recognized
```


```
pochan# objdump -h kernel.bin 
objdump: kernel.bin: File format not recognized
pochan# objdump -S --start-address=0xc8413d88 --stop-address=0xc8413da0 kernel.bin
objdump: kernel.bin: File format not recognized
```

On both architectures. I uploaded it if you'd like to take a look: http://cooltrainer.org/kernel.bin


----------



## vhapkin (Jan 14, 2011)

PseudoCylon said:
			
		

> -- Update on Jan 29, 2010 --
> 
> The run(4) driver has been committed to FreeBSD 9-CURRENT.
> 
> ...



Could you please add support of rt3090 to driver?


----------



## HighTower (Jan 14, 2011)

Hello, 

I have problems with RAlink RT3070 card...  (LR802UKN2)

tried with driver from FreeBSD 8.2-PRERELEASE #4: Fri Jan 14 20:26:35 sources
also tried http://gitorious.org/run/run/archive-tarball/8.1_REL and http://gitorious.org/run/run/archive-tarball/11n_beta2
results are the same...
I want to create AccessPoint, but can't... also I can't use it as wireless client ((
what I do:

kldload runfs - ok
kldload if_run - ok

```
run0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:0d:f0:8d:54:f4
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
```
`ifconfig wlan0 create wlandev run0 wlanmode hostap`

```
wlan0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:0d:f0:8d:54:f4
        media: IEEE 802.11 Wireless Ethernet autoselect <hostap> (autoselect <hostap>)
        status: no carrier
        ssid "" channel 1 (2412 MHz 11b)
        country US authmode OPEN privacy OFF txpower 0 scanvalid 60 wme
        dtimperiod 1 -dfs bintval 0
```
hostap is supported
`ifconfig wlan0 list caps`

```
drivercaps=d85c501<STA,IBSS,HOSTAP,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,WME,WDS>
cryptocaps=1b<WEP,TKIP,AES_CCM,TKIPMIC>
htcaps=f057e<CHWIDTH40,GREENFIELD,SHORTGI20,SHORTGI40,DELBA>
```
make open accesspoint:
`ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1`

```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:0d:f0:8d:54:f4
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid freebsdap channel 1 (2412 MHz 11g) bssid 00:0d:f0:8d:54:f4
        country US authmode OPEN privacy OFF txpower 0 scanvalid 60
        protmode CTS wme dtimperiod 1 -dfs
```
And now I have wireless led blinking very fast and that's all... No accesspoints can be found by other devices... What I do wrong?


----------



## PseudoCylon (Jan 17, 2011)

*@okeeblow*


			
				okeeblow said:
			
		

> On both architectures. I uploaded it if you'd like to take a look: http://cooltrainer.org/kernel.bin


Is there file named kernel.o?
And just in case, can you check if virsion of src/sys/net80211/ieee80211_amrr.c is
	
	



```
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_amrr.c,v 1.4.2.3 2010/11/20 12:22:02 bschmidt Exp $");
```

*@vhapkin*


			
				vhapkin said:
			
		

> Could you please add support of rt3090 to driver?


Sorry. It is PCIe based chipset. Cannot just add. It would be a separate driver.

*@HighTower*


			
				HighTower said:
			
		

> make open accesspoint:
> `ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1`


Can you issue 'inet' separately?`# ifconfig wlan0 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1`then`# ifconfig wlan0 inet 192.168.0.1`The driver has problem restarting some 3070 chipset, so give 'inet' at the end. Hope this is the case.


----------



## HighTower (Jan 17, 2011)

PseudoCylon said:
			
		

> Can you issue 'inet' separately?`# ifconfig wlan0 netmask 255.255.255.0 ssid freebsdap mode 11g channel 1`then`# ifconfig wlan0 inet 192.168.0.1`The driver has problem restarting some 3070 chipset, so give 'inet' at the end. Hope this is the case.



I've tried as you wrote after reboot, unfortunately result is the same... wireless led on device blinking very fast, but no ap with "freebsdap" name and my mac is seen..

Also now I observe another problem, after rebooting, loafing if_run module and creading wlan I can't recieve list of APs in range!
[CMD=]ifconfig wlan0 up scan[/CMD]
return nothing.. it is in "run" stage for a long with not output...

initally, then I just installed 8.1 with generic kernel on this device I was able to scan and recieve APs list in range...


----------



## okeeblow (Jan 18, 2011)

PseudoCylon said:
			
		

> *@okeeblow*Is there file named kernel.o?



There doesn't appear to be:


```
[root@Emi#src]cp /usr/obj/arm/usr/src/sys/DOCKSTAR-COOLTRAINER/kernel.
kernel.bin*           kernel.gz.tramp*      kernel.gz.tramp.bin*  kernel.tramp*         kernel.tramp.bin*
```



> And just in case, can you check if virsion of src/sys/net80211/ieee80211_amrr.c is
> 
> 
> 
> ...



I have 
	
	



```
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_amrr.c,v 1.4.2.3.2.1 2010/12/21 17:09:25 kensmith Exp $");
```


----------



## JackMiles (Jan 19, 2011)

Hello. I have some problem with my Dlink DWA-140 device.

OS 8.1 release.
Driver is standard from 8.1 release, or from your site http://gitorious.org/run/run/trees/8.1_REL, doesnt matter, happens everywhere.

Device detects as:

```
run0: <Ralink 11n adapter, class 0/0, rev. 2.00/1.01, addr 2> on usbus1
run0: MAC/BBP RT3071 (rev 0x0213), RF RT3022 (MIMO 2T2R), address 1c:af:f7:04:0c:9d
```
Setting up device in HOSTAP mode (auth doesnt matter)
Connecting a client to this hostap.
Starting traffic exchange (i start pings from cl to ap and from ap to cl).
Disconnecting a client.
Core dump...

Debug looks like this (much of megs cropped):


```
.............
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=148 rate=2 qid=0 phy=0
run_bulk_tx_callbackN: sending frame len=128 xferlen=152 @ index 0
run_bulk_tx_callbackN: transfer complete: 152 bytes @ index 0
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=140 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=120 xferlen=144 @ index 0
run_bulk_tx_callbackN: transfer complete: 144 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_drain_fifo: tx stat 0x00000023
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810201a6
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x00000022
run_drain_fifo: tx stat 0x00000022
run_reset_livelock: debug reg 04000001
run_iter_func: ridx=16
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=148 rate=2 qid=0 phy=0
run_bulk_tx_callbackN: sending frame len=128 xferlen=152 @ index 0
run_bulk_tx_callbackN: transfer complete: 152 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_drain_fifo: tx stat 0x00000023
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810201a6
run_update_beacon: cmdq_store=22
run_cmdq_cb: cmdq_exec=22 pending=1
run_updateprot: mode=9 prot=1 useprot=off
run_updateprot: htinfo=2 htprot=2
run_update_beacon_cb: chan=2GHz
run_update_beacon: cmdq_store=23
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=140 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=120 xferlen=144 @ index 0
run_bulk_tx_callbackN: transfer complete: 144 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_cmdq_cb: cmdq_exec=23 pending=1
run_updateprot: mode=9 prot=1 useprot=off
run_updateprot: htinfo=2 htprot=2
run_update_beacon_cb: chan=2GHz
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x00000022
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810401ab
run_drain_fifo: tx stat 0x810201a6
run_update_beacon: cmdq_store=24
run_cmdq_cb: cmdq_exec=24 pending=1
run_updateprot: mode=9 prot=1 useprot=off
run_updateprot: htinfo=2 htprot=2
run_update_beacon_cb: chan=2GHz
run_update_beacon: cmdq_store=25
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=140 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=120 xferlen=144 @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_bulk_tx_callbackN: transfer complete: 144 bytes @ index 0
run_rx_frame: received RT2860_RX_L2PAD frame
run_tx: qos 0	qid 0	tid 0	qflags 4
run_tx: sending data frame len=116 rate=132 qid=0 phy=8104
run_bulk_tx_callbackN: sending frame len=96 xferlen=120 @ index 0
run_bulk_tx_callbackN: transfer complete: 120 bytes @ index 0
run_cmdq_cb: cmdq_exec=25 pending=1
run_updateprot: mode=9 prot=1 useprot=off
run_updateprot: htinfo=2 htprot=2
run_update_beacon: cmdq_store=26
run_update_beacon_cb: chan=2GHz
run_cmdq_cb: cmdq_exec=26 pending=1
run_updateprot: mode=9 prot=1 useprot=off
run_updateprot: htinfo=0 htprot=2
run_update_beacon_cb: chan=2GHz
run_drain_fifo: tx stat 0x810401ab


Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address	= 0xc4bcb908
fault code		= supervisor read, page not present
instruction pointer	= 0x20:0xc4b3ac0a
stack pointer	        = 0x28:0xe68c2c6c
frame pointer	        = 0x28:0xe68c2ca0
code segment		= base 0x0, limit 0xfffff, type 0x1b
			= DPL 0, pres 1, def32 1, gran 1
processor eflags	= interrupt enabled, resume, IOPL = 0
current process		= 0 (run0 taskq)
trap number		= 12
panic: page fault
cpuid = 0
Uptime: 4m40s
Cannot dump. Device not defined or unavailable.
Automatic reboot in 15 seconds - press a key on the console to abort
```

It happens about 99,99% when there's some traffic between client and ap, and client disappears. It happens about 10% when there's no traffic and client disappears.

Sorry for by bad english.


----------



## PseudoCylon (Jan 20, 2011)

*@HighTower*


			
				HighTower said:
			
		

> [CMD=]ifconfig wlan0 up scan[/CMD]
> return nothing.. it is in "run" stage for a long with not output...


'up' and 'scan' cause problem. Just using 'up' also creats the list.


			
				HighTower said:
			
		

> initally, then I just installed 8.1 with generic kernel on this device I was able to scan and recieve APs list in range...


If the driver works on 8.1 this might be caused by some changes in ieee80211 stack. Can you show me the debugging messages? After creating the wlan,
`# wlandebug -i wlan0 debug+dumppkts+input+elemid+node+scan+output+state`Your kernel need to be compiled with IEEE08211_DEBUG option.
Or, try
`# ifconfig wlan0 ssid freebsdap channel 1``# ifconfig wlan0 inet 192.168.0.1`you might get lucky.


*@okeeblow*
Can you try this patch? As you can see, this may fix panic with rum(4) as well.
http://svn.freebsd.org/viewvc/base?view=revision&revision=217511
If it won't work,
- can I get some debug messages? DDB or at least,`# wlandebug -i wlan0 any`last a few lines before panic? 
- can I have kernel.tramp and kernel.tramp.bin?


*@JackMiles*
Can you try this?
http://gitorious.org/run/run/trees/rssi_fix/dev/usb/wlan


----------



## bschmidt (Jan 20, 2011)

PseudoCylon said:
			
		

> *@HighTower*'up' and 'scan' cause problem. Just using 'up' also creats the list.



CFT/CFR, possible fix for ifconfig scan hang


----------



## JackMiles (Jan 20, 2011)

PseudoCylon said:
			
		

> *@JackMiles*
> Can you try this?
> http://gitorious.org/run/run/trees/rssi_fix/dev/usb/wlan



Ok, heres the comparsion:
*Previous driver:*
+11g support
-AES CCMP not working (win client says "AES; key absent", didnt thought that is a driver issue...)
-core dump on client disconnection

*RSSfix driver:*
-no 11g support
+AES CCMP working ok.
+looks like i cant make this driver core dumped
*-Strange TX bug:
packets can only be transmitted, when some packets are received. So, this thing works only if i start on my win client pinging this AP. I'f i wont - many packets lost. Testing: starting pings from AP with run driver to win client, and from client to AP. It works. Disabling pings from client to AP - pings from AP to client freezes, no response.
*

b.t.w. theres some strange thing, happens in all run drivers i tested. starting pings from win client to ap - time almost always <1ms. Start pings from AP to client - time is huge, like

```
64 bytes from 10.0.0.2: icmp_seq=0 ttl=128 time=0.859 ms
64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=0.892 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=128 time=779.953 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=128 time=770.234 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=128 time=759.415 ms
```
Every icmp ping consists of request and reply, 1 tx and 1 rx packet anyway, so this looks very strange to me.


----------



## JackMiles (Jan 20, 2011)

Er, i mean 11n support, not 11g.


----------



## HighTower (Jan 20, 2011)

PseudoCylon said:
			
		

> *@HighTower*'up' and 'scan' cause problem. Just using 'up' also creats the list.
> If the driver works on 8.1 this might be caused by some changes in ieee80211 stack. Can you show me the debugging messages? After creating the wlan,
> `# wlandebug -i wlan0 debug+dumppkts+input+elemid+node+scan+output+state`Your kernel need to be compiled with IEEE08211_DEBUG option.
> Or, try
> `# ifconfig wlan0 ssid freebsdap channel 1``# ifconfig wlan0 inet 192.168.0.1`you might get lucky.



so, not I almost succeeded!!!
what I've done:
`# kldload runfw`
`# kldload if_run`
`# ifconfig wlan0 create wlandev run0 wlanmode hostap`
`# wlandebug -i wlan0 debug+dumppkts+input+elemid+node+scan+output+state`

```
net.wlan.0.debug: 0x0 => 0x6b380000<debug,dumppkts,input,elemid,node,scan,output,state>
```
`# ifconfig wlan0 ssid freebsdap channel 1`
`# ifconfig wlan0 inet 192.168.0.1`

after that ap with name "freebsdap" because available, but then I connected to it, whole device restarted (((

here is wlandebug log:

```
Jan 20 19:31:26 home kernel: run0: <1.0> on usbus3
Jan 20 19:31:26 home kernel: run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO 1T1R), address 00:0d:f0:8d:54:f4
Jan 20 19:31:26 home kernel: run0: firmware RT2870 loaded
Jan 20 19:31:38 home kernel: wlan0: Ethernet address: 00:0d:f0:8d:54:f4
Jan 20 19:32:13 home kernel: wlan0: ieee80211_init
Jan 20 19:32:13 home kernel: wlan0: start running, 0 vaps running
Jan 20 19:32:13 home kernel: wlan0: ieee80211_start_locked: up parent run0
Jan 20 19:32:13 home kernel: wlan0: ieee80211_start: ignore queue, parent run0 not up+running
Jan 20 19:32:14 home kernel: wlan0: start running, 1 vaps running
Jan 20 19:32:14 home kernel: wlan0: ieee80211_new_state_locked: INIT -> SCAN (nrunning 0 nscanning 0)
Jan 20 19:32:14 home kernel: wlan0: ieee80211_newstate_cb: INIT -> INIT arg 0
Jan 20 19:32:14 home kernel: wlan0: hostap_newstate: INIT -> INIT (0)
Jan 20 19:32:14 home kernel: wlan0: ieee80211_newstate_cb: INIT -> SCAN arg 0
Jan 20 19:32:14 home kernel: wlan0: hostap_newstate: INIT -> SCAN (0)
Jan 20 19:32:14 home kernel: wlan0: ieee80211_create_ibss: creating HOSTAP on channel 1
Jan 20 19:32:14 home kernel: wlan0: ieee80211_alloc_node 0xc4dff000<00:0d:f0:8d:54:f4> in station table
Jan 20 19:32:14 home kernel: wlan0: ieee80211_new_state_locked: SCAN -> RUN (nrunning 0 nscanning 0)
Jan 20 19:32:14 home kernel: wlan0: ieee80211_newstate_cb: SCAN -> RUN arg -1
Jan 20 19:32:14 home kernel: wlan0: hostap_newstate: SCAN -> RUN (-1)
Jan 20 19:32:14 home kernel: wlan0: synchronized with 00:0d:f0:8d:54:f4 ssid "freebsdap" channel 1 start 0Mb
Jan 20 19:32:14 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 63
Jan 20 19:32:14 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:14 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:32:14 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:14 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
...
repeated a lot of times, difference in last numbers, 65 or 63 or 67 or 59
...
Jan 20 19:32:19 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 27
Jan 20 19:32:19 home kernel: [40:a6:d9:14:e5:5a] discard probe_req frame, ssid mismatch: "ZyXEL"
Jan 20 19:32:19 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 27
Jan 20 19:32:19 home kernel: [40:a6:d9:14:e5:5a] discard probe_req frame, ssid mismatch: "ZyXEL"
...
ZyXEL - is open AP in ragne
...
text before repeated several times
...
Jan 20 19:32:35 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 67
Jan 20 19:32:35 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:35 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 65
Jan 20 19:32:35 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:32:35 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:32:35 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
Jan 20 19:32:35 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 67
Jan 20 19:32:35 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:35 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:32:35 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
...
again repeated a lot of times
...
Jan 20 19:32:39 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:39 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 65
Jan 20 19:32:39 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:32:39 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:32:39 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
...
Jan 20 19:32:39 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 63
Jan 20 19:32:39 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:39 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 25
Jan 20 19:32:39 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:32:39 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:32:39 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
Jan 20 19:32:39 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 25
Jan 20 19:32:39 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
...
Jan 20 19:32:40 home kernel: [40:a6:d9:14:e5:5a] discard probe_req frame, ssid mismatch: "ZyXEL"
Jan 20 19:32:40 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:32:40 home kernel: wlan0: [00:24:8c:50:c3:95] discard 
Jan 20 19:32:40 home kernel: unhandled information element, 
Jan 20 19:32:40 home kernel: id 47, len 1
Jan 20 19:32:40 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 63
Jan 20 19:32:40 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:32:40 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 63
Jan 20 19:32:40 home kernel: [40:a6:d9:14:e5:5a] discard probe_req frame, ssid mismatch: "ZyXEL"
Jan 20 19:32:40 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
...
Jan 20 19:32:48 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:32:48 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:32:48 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
Jan 20 19:32:48 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 23
Jan 20 19:32:48 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:32:48 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:32:48 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
...
Jan 20 19:33:07 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:33:07 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:33:07 home kernel: wlan0: received probe_req from 40:a6:d9:14:e5:5a rssi 25
Jan 20 19:33:07 home kernel: wlan0: [40:a6:d9:14:e5:5a] recv probe req
Jan 20 19:33:07 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_proberesp:2391) 0xc4dff000<00:0d:f0:8d:54:f4> refcnt 4
Jan 20 19:33:07 home kernel: wlan0: send probe resp on channel 1 to 40:a6:d9:14:e5:5a
Jan 20 19:33:07 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:33:07 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:33:07 home kernel: wlan0: received auth from 40:a6:d9:14:e5:5a rssi 27
Jan 20 19:33:07 home kernel: wlan0: ieee80211_alloc_node 0xc4e67000<40:a6:d9:14:e5:5a> in station table
Jan 20 19:33:07 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_mgmt:1876) 0xc4e67000<40:a6:d9:14:e5:5a> refcnt 2
Jan 20 19:33:07 home kernel: [40:a6:d9:14:e5:5a] send auth on channel 1
Jan 20 19:33:07 home kernel: wlan0: [40:a6:d9:14:e5:5a] station authenticated (open)
Jan 20 19:33:07 home kernel: wlan0: received assoc_req from 40:a6:d9:14:e5:5a rssi 25
Jan 20 19:33:07 home kernel: wlan0: [40:a6:d9:14:e5:5a] station associated at aid 1: short preamble, short slot time, QoS
Jan 20 19:33:07 home kernel: wlan0: ieee80211_ref_node (ieee80211_send_mgmt:1876) 0xc4e67000<40:a6:d9:14:e5:5a> refcnt 3
Jan 20 19:33:07 home kernel: [40:a6:d9:14:e5:5a] send assoc_resp on channel 1
Jan 20 19:33:07 home kernel: wlan0: [40:a6:d9:14:e5:5a] node join
Jan 20 19:33:07 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 63
Jan 20 19:33:07 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:33:07 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:33:07 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
Jan 20 19:33:07 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 63
...
Jan 20 19:33:08 home kernel: wlan0: received beacon from 00:24:8c:50:c3:95 rssi 65
Jan 20 19:33:08 home kernel: wlan0: [00:24:8c:50:c3:95] discard unhandled information element, id 47, len 1
```
after last line - reboot...

but anyway, this is very-very big progress for me!!!


----------



## PseudoCylon (Jan 21, 2011)

*@JackMiles*


			
				JackMiles said:
			
		

> -no 11g support[/CODE]


Patches are for one in HEAD. 11n hasn't supported, yet. I just want to patch codes already committed first. Fixes on 11n beta will follow.



			
				JackMiles said:
			
		

> *-Strange TX bug:*


Most likely caused by power save mode. The support hasn't added, yet. Can you turn off power save mode on client, for now?


*@HighTower*


			
				HighTower said:
			
		

> after that ap with name "freebsdap" because available, but then I connected to it, whole device restarted (((


It seems 8.2-PRERELEASE + AP needs this patch.
http://svn.freebsd.org/viewvc/base?view=revision&revision=217511
And, please use this run(4)
http://gitorious.org/run/run/trees/rssi_fix/dev/usb/wlan
Soon or later, you will encounter the same problem as JackMiles's.

Can you post the debugging messages with 'mode 11g' option?`# wlandebug -i wlan0 debug+dumppkts+input+elemid+node+scan+output+state``# ifconfig wlan0 ssid freebsdap mode 11g channel 1`Not using 'mode 11g' option is OK for workaround, but bug shoud be fixed. Also please give this patch a try.
http://forums.freebsd.org/showpost.php?p=120126&postcount=225


----------



## JackMiles (Jan 21, 2011)

PseudoCylon said:
			
		

> *@JackMiles*Patches are for one in HEAD. 11n hasn't supported, yet. I just want to patch codes already committed first. Fixes on 11n beta will follow.
> 
> Most likely caused by power save mode. The support hasn't added, yet. Can you turn off power save mode on client, for now?


Yes, this helps. Seems like turning off power saving mode fixes Ap-client ping time too. Thank you very much!

b.t.w. , can you recommend some wlan driver source, with comments, or something else to understand how wlan drivers works? I have an experience in writing freebsd kernel modules, but not device drivers, and thinking about porting rtl8192 to freebsd.


----------



## HighTower (Jan 21, 2011)

PseudoCylon said:
			
		

> *@HighTower*It seems 8.2-PRERELEASE + AP needs this patch.
> http://svn.freebsd.org/viewvc/base?view=revision&revision=217511
> And, please use this run(4)
> http://gitorious.org/run/run/trees/rssi_fix/dev/usb/wlan
> ...



I took run sources from http://gitorious.org/run/run/trees/rssi_fix/dev/usb/wlan
later checked changes with http://svn.freebsd.org/viewvc/base?view=revision&revision=217511
the only difference that if_run.c on svn.freebsd.org doesn't have line

```
ieee80211_ratectl_node_init(ni);
```
 at line ~2379, but at gitorious.org has.. I decided not to change sources from gitorious.org, so my copy has this line
patch for ifconfig I also took and recompile every thing.

now AP is created, user can connect and not reboot!!!

debug is attached...

so, AP in opened mode - works, I can use dhcpd to give ip adresses to clients

but then I try to create WPA protected ap - smth goes wrong...
opened AP:

```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:0d:f0:8d:54:f4
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid freebsdap channel 1 (2412 MHz 11g) bssid 00:0d:f0:8d:54:f4
        country US authmode OPEN privacy OFF txpower 0 scanvalid 60
        protmode CTS wme dtimperiod 1 -dfs
```
after I run `# /etc/rc.d/hostapd forcestart`
with following config /etc/hostapd.conf

```
interface=wlan0
driver=bsd
debug=1
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=freebsdap
wpa=1
wpa_passphrase=xxxxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
```
after that AP dissapears in available list (((

```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:0d:f0:8d:54:f4
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid freebsdap channel 1 (2412 MHz 11g) bssid 00:0d:f0:8d:54:f4
        country US authmode WPA privacy MIXED deftxkey 2 TKIP 2:128-bit
        txpower 0 scanvalid 60 protmode CTS wme dtimperiod 1 -dfs
```


----------



## JackMiles (Jan 22, 2011)

PseudoCylon said:
			
		

> *@JackMiles*Patches are for one in HEAD. 11n hasn't supported, yet. I just want to patch codes already committed first. Fixes on 11n beta will follow.
> 
> Most likely caused by power save mode. The support hasn't added, yet. Can you turn off power save mode on client, for now?



Update... i can make this core dump too. But, it was one time, all other times PC freezes, no core dump, no nothing, fully freeze.
Howto: just connect with invalid (not listed in conf) MAC or KEY. When MAC is invalid - PC freezes. When KEY is invalid - sometimes some messages about wrong key from hostapd , then freeze. One time was core dump.
Happends on both TKIP and CCMP.


----------



## PseudoCylon (Jan 24, 2011)

*@HighTower*

```
driver=bsd
```
looks linux-ish
Can you use this http://gitorious.org/run/run/trees/key_fix/dev/usb/wlan and`# sysctl hw.usb.run.debug=1`before`# /etc/rc.d/hostapd forcestart`and post debug messages?





			
				HighTower said:
			
		

> after that AP dissapears in available list (((


means AP with rt3070 is still responding (still taking commands, not freezing), just AP doesn't show up on client?


*@JackMiles*
Does





			
				JackMiles said:
			
		

> When KEY is invalid...


means intentionally giving wrong key or giving the right key but auth mode isn't working?





			
				JackMiles said:
			
		

> PC freezes...


I cannot help windows freezing issue, you have to tell steve ballmer but if FreeBSD Box with run(4) is freezing, please try this http://gitorious.org/run/run/trees/fifo_fix/dev/usb/wlan previous code has LOR issue.





			
				JackMiles said:
			
		

> b.t.w. , can you recommend some wlan driver source, with comments, or something else to understand how wlan drivers works? I have an experience in writing freebsd kernel modules, but not device drivers, and thinking about porting rtl8192 to freebsd.


Not particularly. I used rum(4) just because it is also driver for ralink's chipset. It worked well for me.


----------



## HighTower (Jan 24, 2011)

PseudoCylon said:
			
		

> *@HighTower*
> 
> ```
> driver=bsd
> ...



I removed 
	
	



```
driver=bsd
```
 from /etc/hostapd.conf
sources are taken and run is recompiled

Also I completely shut down system with removing power cable.. if not to do it (make shutdown or reboot) after creating opened AP, it is strange why, but AP is visible, even if not if_run module is loaded!!!



			
				PseudoCylon said:
			
		

> means AP with rt3070 is still responding (still taking commands, not freezing), just AP doesn't show up on client?



yes, with new sources the same situation...
If I have opened AP, it is visible by clients, clients can connect to it and traffic goes..
but then I call
`# /etc/rc.d/hostapd forcestart`
my AP just simply dissapears, clients do not see it and can't connect
but wireless led continue blinking as in normal situation
I've tried commands:
`# ifconfig wlan0 list sta`
`# ifconfig wlan0 list scan`
`# ifconfig wlan0 down`
all of them were executed with no delay and no output ((

new debug is attached...


----------



## PseudoCylon (Jan 26, 2011)

HighTower said:
			
		

> Also I completely shut down system with removing power cable.. if not to do it (make shutdown or reboot) after creating opened AP, it is strange why, but AP is visible, even if not if_run module is loaded!!!


mmm... strange. What OS are clients running?





			
				HighTower said:
			
		

> If I have opened AP, it is visible by clients, clients can connect to it and traffic goes..
> but then I call
> `# /etc/rc.d/hostapd forcestart`
> my AP just simply dissapears, clients do not see it and can't connect
> but wireless led continue blinking as in normal situation


So, what you are doing is
1) set up an open AP,
2) check everything is OK,
3) stat hostapd.
If so, did you switch encryption mode on clients, for FreeBSD boxes, run wpa_supplicant? Debug message shows no client attempted to associate. Even though encryption keys are wrong, clients can associate as long as ssid and encryption mode match. Then, in WPA mode, they will be kicked off.

Anyway, the drive isn't writing the keys properly. Here is fix.
http://gitorious.org/run/run/trees/8.2_PRE/dev/usb/wlan
(If you are lazy, you can use one you have. Just start hostapd right after creating wlan, no extra command between.)

If it doesn't work please post debug message.`# wlandebug -i wlan0 debug+crypto+assoc+auth+wpa``# sysctl hw.usb.run.debug=1`and set up hostap.

If it works, you can turn off annoying debug output with`# sysctl hw.usb.run.debug=0`


----------



## HighTower (Jan 26, 2011)

PseudoCylon said:
			
		

> mmm... strange. What OS are clients running?


agree, strange...
iPhone 4 and smartphones with WinMobile 6 - do it this way
WinXP - no...
I have no spare freebsd pc with wireless to test on it (



			
				PseudoCylon said:
			
		

> So, what you are doing is
> 1) set up an open AP,
> 2) check everything is OK,
> 3) stat hostapd.


wow, now it works!!! really!!! I'm happy :beer



			
				PseudoCylon said:
			
		

> Anyway, the drive isn't writing the keys properly. Here is fix.
> http://gitorious.org/run/run/trees/8.2_PRE/dev/usb/wlan
> (If you are lazy, you can use one you have. Just start hostapd right after creating wlan, no extra command between.)


I'm not lazy and I'm interested in this driver, so I'm ready for tests...

and some questions:
- how to do it in best way to start AP with system start?
- is it possible made autochannel selection for AP? like some box routers do then they change channel number depending on smth (may be availability of open APs on the same channel or signal quality or smth else)?
- is it possible to control transmit power?
now it is written

```
TKIP 2:128-bit TKIP 3:128-bit txpower 0 scanvalid 60 protmode CTS wme
        dtimperiod 1 -dfs
```
what does "txpower 0" mean?

p.s. if you are interested, here is debug log... two clients are connected and work with no problems...


----------



## HighTower (Jan 26, 2011)

forgot to attache debug, here it is.


----------



## HighTower (Jan 27, 2011)

addition... don't know is it driver or hostapd problem... but my iPhone now do not automatically connects to my AP... then I select network manually - it asks for network key each time!.. (((((


----------



## PseudoCylon (Jan 28, 2011)

HighTower said:
			
		

> wow, now it works!!! really!!! I'm happy :beer


2 thumbs up!




			
				HighTower said:
			
		

> and some questions:
> - how to do it in best way to start AP with system start?


 Pretty much stradard, use loader.conf(5) and rc.conf(5).




			
				HighTower said:
			
		

> - is it possible made autochannel selection for AP? like some box routers do then they change channel number depending on smth (may be availability of open APs on the same channel or signal quality or smth else)?


Yes. Just`# ifconfig wlan create wlandev run0 wlanmode ap``# /etc/rc.d/hostapd forcestart`Then it will scan and selects appropriate one like any other routers. I thought you had to use chennel 1.




			
				HighTower said:
			
		

> - is it possible to control transmit power?


It could, but the support hasn't been added.





			
				HighTower said:
			
		

> what does "txpower 0" mean?


It means I'm too lazy to fix it. The driver (supposedly) sets txpower properly, but not telling anyone. I noticed it while ago, but I'm just fixing bugs causing troubles, first.




			
				HighTower said:
			
		

> p.s. if you are interested, here is debug log... two clients are connected and work with no problems...


Thanks for reporting/testing. The debug messages shows the driver behaves as it should be. But, DHCP server is complaining. Check dhcpd.conf.




			
				HighTower said:
			
		

> addition... don't know is it driver or hostapd problem... but my iPhone now do not automatically connects to my AP... then I select network manually - it asks for network key each time!.. (((((


Most likely steve jobs' problem. AP doesn't tell client to join or give out encryption keys.
* For open AP, any client can associate, so as iPhone.
* For WPA AP, iPhone needs a key, so it asks every time it wants. I don't know why iPhone doesn't remember keys. I don't even have a cellphone.


----------



## HighTower (Jan 28, 2011)

PseudoCylon said:
			
		

> Pretty much stradard, use loader.conf(5) and rc.conf(5).


I have:
loader.conf

```
runfw_load="YES"
if_run_load="YES"
```
rc.conf

```
wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap up"

cloned_interfaces="bridge0"
ifconfig_bridge0="addm wlan0 addm re1"    # << re1 is iface for internal wired net

ifconfig_bridge0="inet 172.16.1.1 netmask 255.255.255.0"

hostapd_enable="YES"
```
after restart iface wlan0 is created, hostapd is started, wireless led on device is blinking as usuial, but
- AP is not seen
- wlan0 is not added to bringe0



			
				PseudoCylon said:
			
		

> Then it will scan and selects appropriate one like any other routers. I thought you had to use chennel 1.


I've tried such way, but channel is all the time 1 and not chaning in time... that's why I asked...



			
				PseudoCylon said:
			
		

> It could, but the support hasn't been added.It means I'm too lazy to fix it. The driver (supposedly) sets txpower properly, but not telling anyone. I noticed it while ago, but I'm just fixing bugs causing troubles, first.


hm.. so driver controls power itself?
no way to set it to max? because then I sit near AP (~3m) I have signal quality ~80%, if I go about 7m (with 2 walls between) quality is ~12%...
and command `# ifconfig wlan0 txpower 50` 
replyes with error

```
ifconfig: SIOCS80211: Operation not supported
```



			
				PseudoCylon said:
			
		

> But, DHCP server is complaining. Check dhcpd.conf.


I fixed it.. problem was in wrong place of defining static hosts..



			
				PseudoCylon said:
			
		

> Most likely steve jobs' problem. AP doesn't tell client to join or give out encryption keys.


not sure... because I use iPhone to connect to several WPA2 protected nets with keys (D-Link and TP-Link routers) and I not prompted to enter key each time...
Then I have in my hostapd.conf line

```
wpa=1
```
it connected automatically, but then I change it to 
	
	



```
wpa=2
```
 to have WPA2 instead of WPA, problems started...

another strange thing (may it is related to the fact, that iPhone "forgets" key), the it automatically connects to open AP in range with very-very low signal (~8%)


----------



## HighTower (Jan 28, 2011)

small update: 
- problem with iPhone doesn't exists any more
- AP is started successfully while system start up

what I did - simply shutdown the system and removed power cord for 5 minutes... this is issue I already wrote....
it looks like some info about previous wireless chip configuration is not reset after reboot, because actually power is not removed from it while reboot and shutdown if power cord is connected...


----------



## JackMiles (Jan 29, 2011)

PseudoCylon said:
			
		

> Does means intentionally giving wrong key or giving the right key but auth mode isn't working?


Giving right key works fine. Giving really wrong key myself makes some msg about wrong key and when pc freeze.


			
				PseudoCylon said:
			
		

> I cannot help windows freezing issue, you have to tell steve ballmer but if FreeBSD Box with run(4) is freezing, please try this http://gitorious.org/run/run/trees/fifo_fix/dev/usb/wlan previous code has LOR issue.


FreeBSD Box with run(4) is freezing.
With fifo_fix version all seems ok right now, no freezing.


----------



## JackMiles (Jan 29, 2011)

*PseudoCylon*, btw, why maximum speed is about 11mbit in g mode?


----------



## PseudoCylon (Jan 31, 2011)

@*HighTower*


			
				HighTower said:
			
		

> small update:
> - problem with iPhone doesn't exists any more
> - AP is started successfully while system start up
> what I did - simply shutdown the system and removed power cord for 5 minutes... this is issue I already wrote....
> it looks like some info about previous wireless chip configuration is not reset after reboot, because actually power is not removed from it while reboot and shutdown if power cord is connected...


Thst's good. So, it leaves us channels and tx power issue. (I'll try to fix re-power-up issue some day.)





			
				HighTower said:
			
		

> I've tried such way, but channel is all the time 1 and not chaning in time... that's why I asked...


AP picks the most appropriate channel (least traffic, etc), then stick with it unless you manually change. It seems channel 1 is the one AP picks.





			
				HighTower said:
			
		

> hm.. so driver controls power itself? no way to set it to max?


Yes (supporsted to). I set what they call "auto tx power." And it should crank up to max when appropriate.


			
				HighTower said:
			
		

> I sit near AP (~3m) I have signal quality ~80%, if I go about 7m (with 2 walls between) quality is ~12%...


It kinda low, but it look normal. You cannot get the same quality if you walk away from AP. Noise also affects quality. Does another router give better quality? I get the comparable rssi/snr with linksys G router.





			
				HighTower said:
			
		

> command `# ifconfig wlan0 txpower 50`
> replyes with error
> 
> ```
> ...


That's because the driver doesn't support that command. (someday maybe)


@*JackMiles*


			
				JackMiles said:
			
		

> FreeBSD Box with run(4) is freezing.
> With fifo_fix version all seems ok right now, no freezing.


fifo_fix version fixed the problem, then. I'll submit the patch.





			
				JackMiles said:
			
		

> *PseudoCylon*, btw, why maximum speed is about 11mbit in g mode?


How did you get the number, with`% ifconfig wlan0 list sta`or used some packet sniffer? (Power save mode is still of, isn't it?)


----------



## HighTower (Feb 1, 2011)

*@PseudoCylon*
ok, I can live with current issues about power and channel

but what is really makes me craze is that after reboot AP doesn't work... run0 and wlan0 are created and have "running" status, wireless led is blinking as in normal situation, but AP is not seen and can't be connected to (((
I've tried to play with usconfig + power_off + power_on on wireless device - no result:

`# hostapd forcestop`
`# ifconfig wlan0 destroy`
`# kldunload if_run`
`# kldunload runfw`
`# usbconfig -u 3 -a 1 power_off   (or reset)`
...
`# usbconfig -u 3 -a 1 power_on`
`# kldload runfw`
`# kldload if_run`
but no run0 device is created and NO messages on console (


----------



## PseudoCylon (Feb 2, 2011)

HighTower said:
			
		

> If I have opened AP, it is visible by clients, clients can connect to it and traffic goes..
> but then I call
> `# /etc/rc.d/hostapd forcestart`
> my AP just simply dissapears, clients do not see it and can't connect
> ...





			
				HighTower said:
			
		

> agree, strange...
> iPhone 4 and smartphones with WinMobile 6 - do it this way
> WinXP - no...





			
				HighTower said:
			
		

> but what is really makes me craze is that after reboot AP doesn't work... run0 and wlan0 are created and have "running" status, wireless led is blinking as in normal situation, but AP is not seen and can't be connected to (((


Just recapping what we are on.

Combine all of the above, AP fails only
- on reboot (works on cold start) with hostapd (open ap works),
- fails with cell phones (works OK with XP)
correct?

This debug message was collected when AP wasn't visible, wasn't it?


----------



## HighTower (Feb 3, 2011)

PseudoCylon said:
			
		

> Just recapping what we are on.
> 
> Combine all of the above, AP fails only
> - on reboot (works on cold start) with hostapd (open ap works),
> ...



now exactrly... in my case:
- after cold start (then power cord was removed for several minutes) AP start and work normally in opened mode as well as with hostapd
cell phones see it and can connect with no promles (same as pc and notebooks)

- after reboot or shutdown and start again (if power cord was connected) - run0 and wlan0 devices are created and have "running" status, but AP can't be found by any client (while scan) and clients can't connect to it.. doesn't matter AP is opened or with hostapd

not I'm not sure then was debug messaged made, so lated today I'll post debug after reboot then AP is not visible...


----------



## JackMiles (Feb 3, 2011)

PseudoCylon said:
			
		

> @*JackMiles*fifo_fix version fixed the problem, then. I'll submit the patch.How did you get the number, with`% ifconfig wlan0 list sta`or used some packet sniffer? (Power save mode is still of, isn't it?)



Sniffer trafshow on wlan0. Actual download time of 100mb file looks like trafshow is absolutely right about speed. Power-saving mode is off, of course.

b.t.w, it's not a driver issue, but maybe you can help. I want my FreeBSD AP to stop scanning other devices, so it will look like "no tx packets at all if noone trying to connect directly to my AP, just waiting for rx". Is it possible ?


----------



## HighTower (Feb 3, 2011)

here are debug messages after reboot...
there are only few lines after several minutes...


----------



## PseudoCylon (Feb 9, 2011)

@*HighTower*


			
				HighTower said:
			
		

> - after reboot or shutdown and start again (if power cord was connected) - run0 and wlan0 devices are created and have "running" status, but AP can't be found by any client (while scan) and clients can't connect to it.. doesn't matter AP is opened or with hostapd
> 
> not I'm not sure then was debug messaged made, so lated today I'll post debug after reboot then AP is not visible...


This is a restarting issue I have from the beginning. Some how the device with RF2020 radio chip (one your device has) cannot Rx at all after restarting. 80211 stack thinks no one is around. I spent hours looking into ralink's code and poking different registers, but no luck. Sorry. But some time I suddenly find the solution while working on other issues. When you find some info, let me know.


@*JackMiles*


			
				JackMiles said:
			
		

> Sniffer trafshow on wlan0. Actual download time of 100mb file looks like trafshow is absolutely right about speed. Power-saving mode is off, of course.


At my house, I can get 30mbps including all packet headers if amrr keeps tx rate at the max, 54mpbs. If Tx rate gets lowered, though put gets lowered, too.





			
				JackMiles said:
			
		

> b.t.w, it's not a driver issue, but maybe you can help. I want my FreeBSD AP to stop scanning other devices, so it will look like "no tx packets at all if noone trying to connect directly to my AP, just waiting for rx". Is it possible ?


I'm not sure if it works with AP, but disabling bgscan`# ifconfig wlan0 -bgscan`might do the trick. Or you can add tircky code like
	
	



```
if (ic->ic_flags & IEEE80211_F_SCAN)
        goto skip_tx;
```
If you completely silent AP (i.e. stop beacon), nothing will work. You need to find the way to wake AP up.


----------



## HighTower (Feb 9, 2011)

PseudoCylon said:
			
		

> @*HighTower*This is a restarting issue I have from the beginning. Some how the device with RF2020 radio chip (one your device has) cannot Rx at all after restarting. 80211 stack thinks no one is around. I spent hours looking into ralink's code and poking different registers, but no luck. Sorry. But some time I suddenly find the solution while working on other issues. When you find some info, let me know.



if I understood you correctly - this is hw problem...
I also wonder, why it is not possible to "reset" device by removing power from it using usbsonfig?
I mean, I can make power_off and power_on, but after loading driver - nothing happens...
I think reseting power via usbconfig can be working workaround after reboot (if use own start up script, instead of starting wifi by system)


----------



## HighTower (Feb 9, 2011)

I'm searched internet and found, that people can make AP using this chip under linux without any problems...
there is new FW on official ralink website http://eng.ralinktech.com.tw/support.php?s=2
and for linux drivers http://wireless.kernel.org/download/compat-wireless-2.6/compat-wireless-2011-01-30.tar.bz2


----------



## PseudoCylon (Feb 14, 2011)

tried new fw, but didn't fix the problem. (attached new fw, you can swap with old one)

checked linux code, didn't find anything new regarding to resetting chips.

if power_off by usbconfig actually cuts off the current, power_off->reboot might reset the device and make it work again.


----------



## HighTower (Feb 14, 2011)

With new FW I have completely the same behaviour. And does it mean, that you have same problem as me? Power_off->reboot have no effect actually.


----------



## PseudoCylon (Feb 15, 2011)

I have devices with different chipsets. Only one with rt3070 mac + rt2020 radio shows the problem. Based on bug reports I have received, rt3070 with other radio chip doesn't have the issue. It's hard to find the cause just looking into source code. But, currently I'm working on setting up radio (making 11NA AP work with 11A stations). I might find the solution.


----------



## HighTower (Feb 25, 2011)

Hello again.

I took the latest driver sources from "master" branch, TX bug reported by JackMiles is fixed and connection is stable, BUT, battery consumption of mobile devices are high and battary discharges rapidly.

I've made experiments with my iPhone (similar situation with smartphone HTC)

1) phone is 100% charged, wifi is disabled, battery level drops down for 1-2% for 8 hours
2) phone is 100% charged, wifi is enabled, connected to d-link (or tp-link) access point, phone is used for conversation, sms and mail reading via fi-wi, battery level drops down for ~9% for 8 hours, so ~1% per hour
3) phone is 100% charged, wifi is enabled, connected to my ap based on ralink, no activity at all, phone is in stand by mode, battery level drops down for ~76% for 8 hours, so ~9-10% per hour

I don't know what is happening, but it looks like phone can't put wi-fi module to powersave mode (or something like this) then connected to ralink. There were no such problem with previous version of driver with tx bug...


----------



## PseudoCylon (Feb 27, 2011)

Could be. It wakes up all stations blindly. Every time a station gets waken up, the station sends extra packets. Hence more battery consumption. Turn off power save mode could save battery.

I haven't found how to make power save mode work on AP mode.


----------



## gour (Mar 10, 2011)

Hiya,



			
				PseudoCylon said:
			
		

> Unfortunately no.
> The driver supports some of Ralink chips, but RTL8192 is a Realtek chip (as far as I know).



I installed Free(PC)BCD on my laptop (latest 9.0 snapshot) and before migrating my desktop machine from Archlinux, I need to make my wifi card working..

By looking and this thread and this one, I wonder which driver might be more appropriate for my 
	
	



```
ID 07d1:3c16 D-Link System DWA-125 Wireless N 150 Adapter(rev.A2) [Ralink RT2870]
```
 card?

I use x86_64 (amd64) version and would like working WPA2...


----------



## wani (Jun 2, 2011)

Hello,

I just installed FreeBSD for the first time and I don't have ethernet connection (only wireless). My PCI adapter's model is WMP600N which I believe is supported by egorenar's rt2860 driver. I compiled the code with *make* but when I write 
[cmd=]#./rt2860.sh [/cmd]
I get an error saying the command doesn't exist.

I saw someone using *kldload*, but when I try it I get an error.


```
#kldload ./rt2860.ko
link_elf: symbol ieee80211_amrr_tx_complete undefined
kldload: can't load ./rt2860.ko : no such file or directory
```

I used *chmod +x* on both files in case it was the problem. And in rt2860.sh I changed 
	
	



```
#!/bin/sh
```
 to 
	
	



```
#!/bin/csh
```

I am quite the newbie with UNIX, is there something more I should have done?

Thanks.


----------



## PseudoCylon (Jun 3, 2011)

This [thread=7010]thread[/thread] has more information about rt2860 driver.

As far as I know, the driver should be get loaded with kldload(8). You can forget about rt2860.sh.



			
				wani said:
			
		

> ```
> #kldload ./rt2860.ko
> link_elf: symbol ieee80211_amrr_tx_complete undefined
> ```



Is that correct? Not 
	
	



```
[b]rt2860[/b]_amrr_tx_complete
```
 or something else?

Are you sure you are using the correct version of the driver? One for 8.0 should still run on 8.2 or CURRENT.


----------



## wani (Jun 3, 2011)

Yes, I am pretty sure I took the correct version. I even tried copying rt2860.ko in /boot/modules with a `chmod 555 /boot/modules/rt2860.ko` but when I call it I get an error again. 


```
kldload rt2860.ko
link_elf: symbol ieee80211_amrr_tx_complete undefined
kldload: can't load ./rt2860.ko : no such file or directory
```

Anyways thanks a lot for the fast reply, I'll ask on the other thread.


----------



## adri (Jul 5, 2011)

*11n_rc2 on 8.2 release*

As I wanted to have 11n speeds, I have compiled the last 11n_rc2 version of if_run(4) on FreeBSD 8.2-RELEASE. As mentioned in the README, I updated the /usr/src/sys/net80211 directory with the version from 9-CURRENT and recompiled the kernel.

After rebooting the system, the new if_run loads fine and the wlan0 interface gets created. When doing [cmd=]ifconfig wlan0 list scan[/cmd] I can see my AP and many others, so the driver is functional.

However I never get associated with my AccessPoint using WPA. Wpa_supplicant only reports SCAN EVENT RESULTS about once every minute, but never tries to associate. With the old if_run driver, included in FreeBSD 8.2, everything works fine with the same configuration.

Do I need a new version of wpa_supplicant or does anyone know what is happening?

Thanks.


----------



## PseudoCylon (Jul 6, 2011)

Hi,

There are some updates. I have updated the repository. Please try the new driver. Please note the driver is still in developing phase. It may not perform at 100%. But your effort of testing is appreciated.

If it doesn't work, please post the debug message. After loading the driver,`# sysctl hw.usb.run.debug=1`Then set up the device as usual. You will see the debug message like
	
	



```
run_newstate: SCAN -> AUTH
run_newstate: AUTH -> ASSOC
run_newstate: ASSOC -> RUN
run_newassoc: rate=NN ridx=NN ctl_ridx=NN
run_updateprot_cb:
run_key_set_cb: wcid=NN, keyix=NN, mode=N, type=N, tx=XX, rx=XX
```


----------



## Tarick (Jul 17, 2011)

Either with included in -current or using posted above 11n_rc2 driver I still see stalled connection and messages like:

```
Jul 17 16:54:20 n kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 16:54:20 n kernel: run0: device timeout
```

My device is D-Link DWA-140, from messages:

```
Jul 17 16:15:07 n kernel: ugen0.4: <Ralink> at usbus0
Jul 17 16:15:07 n kernel: run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 4> on usbus0
Jul 17 16:15:07 n kernel: run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 14:d6:4d:49:67:75
Jul 17 16:15:07 n kernel: run0: firmware RT3071 ver. 0.17 loaded
```
I use it as access point on ARM machine and it works fine for ~30 seconds until that USB timeout occurs. If it matters, power safe mode was disabled on client.


----------



## lastuser (Aug 24, 2011)

First of all i want to thank *PseudoCylon* for a great work, after some time with a wired lan now my DWA-140 really works on FreeBSD 9-CURRENT as a client, so i got rid of the wires  . I have two questions:

- in a february you said about txpower configuration. Do you plan to realize this feature? My whistle show txpower about 32mw, but i have two walls between FBSD and AP, so it's will be great to make whistle power some more (;
- when you plan to commit 11n to source tree? At this moment it looks like stable - for a two days i have no see any freezes or kernel panics.


----------



## PseudoCylon (Aug 25, 2011)

lastuser said:
			
		

> - in a february you said about txpower configuration. Do you plan to realize this feature? My whistle show txpower about 32mw, but i have two walls between FBSD and AP, so it's will be great to make whistle power some more (;


With current driver, h/w xmit at 100% power. My linksys wireless router is at 28mw, and you get 32mw. That sounds right. Tx power configuration will let you set lower than max xmit pwr. Though, I'm planning to add that feature.



			
				lastuser said:
			
		

> - when you plan to commit 11n to source tree? At this moment it looks like stable - for a two days i have no see any freezes or kernel panics.


It won't make it to 9.0-REL. But, I found out that something wrong writing on h/w's buffer, yesterday (lots of rx buffer overflow and crc error). I think that's the cause of poor performance (up to 80-90mbps). Once I fix it, it's ready to go (hopefully).


----------



## lastuser (Aug 25, 2011)

PseudoCylon said:
			
		

> With current driver, h/w xmit at 100% power. My linksys wireless router is at 28mw, and you get 32mw. That sounds right. Tx power configuration will let you set lower than max xmit pwr. Though, I'm planning to add that feature.


Ummm! I ask this because dlink like to understate tx power, for example, my dir300 transmit for a 75mw, althought real chip max power is 100mw (or, maybe, more)



			
				PseudoCylon said:
			
		

> It won't make it to 9.0-REL. But, I found out that something wrong writing on h/w's buffer, yesterday (lots of rx buffer overflow and crc error). I think that's the cause of poor performance (up to 80-90mbps). Once I fix it, it's ready to go (hopefully).


when you plan to fix and commit to 11n_rc about? maybe, because of this today i see interesting bug (or, maybe, it's my curved hands) - when i fetch big files, speed up to 4-5 mbit, after 10-15 sec fetching wifi link on freebsd stalled for a ~10sec, then wifi link go up. i think 5mbit is not so heavy traffic ):


----------



## PseudoCylon (Aug 25, 2011)

lastuser said:
			
		

> Ummm! I ask this because dlink like to understate tx power, for example, my dir300 transmit for a 75mw, althought real chip max power is 100mw (or, maybe, more)


I doubt it, unless you have one of these.
http://www.ampedwireless.com/products/ua150c.html

According to the product manual I got from D-Link's website
http://www.dlink.com/products/?tab=3&pid=DWA-140&rev=DWA-140_revB
Transmitter power output: 14dBm
Power consumption: Tx 460mA

14dBm is about 32mW
http://en.wikipedia.org/wiki/DBm
and USB 2.0 specifies power supply as 100mA/unit and may draw max 5 unit/port. So, it is hitting h/w max of USB dangle. (I don't know about your router, though.)



			
				lastuser said:
			
		

> when you plan to fix and commit to 11n_rc about? maybe, because of this today i see interesting bug (or, maybe, it's my curved hands) - when i fetch big files, speed up to 4-5 mbit, after 10-15 sec fetching wifi link on freebsd stalled for a ~10sec, then wifi link go up. i think 5mbit is not so heavy traffic ):


I've fixed this issue. But, please wait until I fix corrupted on-chip buffer issue. Otherwise you will encounter similar problem.


----------



## lastuser (Aug 25, 2011)

No-no, dir 300 is a wifi-router, not a usb wifi-card  I simply know about dlink "features" - dlink router firmware mean 100% as 75mW, third-party firmware dd-wrt give me max 200mW on the same router. Because of this i ask you about power: i have dlink dwa-140 dongle and i have some doubt about it real tx power


----------



## Halberdier (Oct 30, 2011)

Hello,

I installed 8.2-RELEASE (64bit) on a multiboot system, and tried to use a few wifi adapters, namely, a D-link DWL-G122, a Belkin F5D7050 ver. 2000, a D-link DWL-G132 and a D-link DWA-140.

By inserting the devices into the running system, they are detected and for the Belkin and the G132 the ural(4) and uath(4) drivers, respectively are suggested, while for the other no similar indication is provided.

The Belkin works properly, but is unstable, I think due to the age of the device. The G132 has other problems.

My Linux system automatically recognises the other two, detecting the RT2870 chipset, therefore I forced the run(4) driver into /boot/loader.conf, and edited the /etc/rc.conf and /etc/wpa_supplicant.conf according with that driver and my router/AP settings.

There are apparently no error messages, the firmware loads correctly, and both devices accept most ifconfig commands, but the scan never works, and I was able to connect only the G122 to the LAN once and never again, never managed to do it with the DWA-140. Moreover, the DWA detected chipset is surprisingly the RT3022/RT3071 pair, differently from what Linux says.

Shall I replace the run(4) with some of the files posted here?

Thank you.


----------



## PseudoCylon (Oct 31, 2011)

So, DWL-G122 and DWA-140 are supposed to be supported by run(4), but not working. According to the previous posts, at least DWA-140 should work with run(4).

First, comment out all the changes in /boot/loader.conf and /etc/rc.conf until the problem is solved.

Then, do followings one device at a time
1) boot
2) load the driver`# kldload if_run`
3) plug in the device, and show me what it says. It will print out something like
	
	



```
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus2
run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 00:00:00:00:00:00
run0: firmware RT3071 loaded
```
If you see only something like following, do (i)
	
	



```
ugenX.Y: <Ralink> at usbus2
```
4)`# ifconfig wlan create wlandev run0`
5) I assume you are using GENERIC kernel which is compiled with IEEE80211_DEBUG opetion. If not, do (ii) instead.
`# wlandebug -i wlan0 scan+auth+assoc+crypto`
6) `# wpa_supplicant -B -i wlan0 -c /your/wpa_supplicant/conf/file`
7) show me what it says.



(i)`# usbconfig -d X.Y dump_device_desc` *[NB]* X.Y is the same number from ugenX.Y.
Then tell me what it says.

(ii)`# wpa_supplicant -dd -i wlan0 -c /your/wpa_supplicant/conf/file`Hopefully this gives me enough info.


----------



## Halberdier (Oct 31, 2011)

First of all, thank you very much for your fast reply. 
And now, let's see if I manage to report correctly all the important information: I know that it is an overused expression, but "please be patient" 

3a) with the DWA-140 the output is exactly the one you posted (RT3071 and RT3022)
3b) with the DWL-G122, the output is

```
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus2
run0: MAC/BBP RT3070 (rev 0x0201), RF RT2020 (MIMO 1T1R), address 00:00:00:00:00:00
run0: firmware RT2870 loaded
```
4) OK
5) the output of the wlandebug command is

```
net.wlan.0.debug: 0x0 => 0x10e00000<crypto,assoc,auth,scan>
```
6) after 5) above, I was overwhelmed by a mass of messages that I cannot deal with, however I saw that eventually everything worked, so I tried repeating the entire process, but omitting point 5); the result is that both the DWA and the DWL perform correctly, both the connection and the scan

At the end, I assume that with my .conf files I didn't start properly the wpa_supplicant, which instead did by launching it with your options.


----------



## Halberdier (Nov 1, 2011)

A further investigation showed that:
- points 2) and 3) of your list can be switched with no harm (leaving the device plugged during the boot and launching the driver later)
- replacing kldload with re-enabling the commands in /boot/loader.conf, it does not work, but
- it works if the device is extracted and plugged again

Thus, apparently, the commands in /boot/loader.conf, as follows

```
if_run_load="YES"
runfw_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
```
are not sufficient, but if the device is extracted and plugged again, the driver works properly.


----------



## PseudoCylon (Nov 2, 2011)

Halberdier said:
			
		

> - it works if the device is extracted and plugged again


With DWL-G122, it is a known issue. Please boot first, then plugin the device. With DWA-140, it should work. If not, do the followings (no need to do with both device, only with DWA-140 is sufficient.)
1) boot with the device is plugged in
2) while the device is not working,`# wlandebug -i wlan0 scan+auth+assoc+crypto`Even though you will be overwhelmed, I need some debug messages to find out what goes wrong.
3) wait for 10 to 15 sec.
`# wlandebug -i wlan0 0`
4) `% dmesg | grep -e run0 -e wlan0 >> /file/name/you/choose`(A new file, /file/name/you/choose will be created.)
5) attach/post that file, your /boot/loader.conf, and /etc/rc.conf


----------



## Halberdier (Nov 2, 2011)

I didn't specify it, the DWL-G122 is rev. E, but you may have guessed it, as it features RT2870.

I don't know what to say, now it works fully and regularly, and even with the DWL-G122, with no need to unplug and re-plug. The only thing I changed is that I installed and added to the /boot/loader.conf the nvidia driver, but I assume that this is completely unrelated. 

My apologies if I am wasting your time with unreliable data. However, here we have still some new piece of information, which is that the DWL-G122 (rev. E) works.

I will go on monitoring my system, and if it stop working again, I will try the diagnostic you are suggesting.

Thank you again.


----------



## Halberdier (Nov 6, 2011)

So, here we are. Sometimes it works, some other (I would say most), it needs unplug, replug. In the meanwhile, I finished installing KDE 4, so what I'm posting was done from an X terminal with root privileges. Please let me know if you need diagnostics from a console.

So, today I started the system, then in the terminal I launched ifconfig and the interfaces were present, but not connected to the network. So I extracted first the relevant run0 and wlan0 messages from dmesg:

```
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus6
run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 14:d6:4d:48:b1:cf
run0: firmware RT3071 loaded
wlan0: Ethernet address: 14:d6:4d:48:b1:cf
```
Then I launched wlandebug, waited some 20 secs, then stopped (wlandebug -i wlan0 0), as you indicated. The next dmesg grep was:

```
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus6
run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 14:d6:4d:48:b1:cf
run0: firmware RT3071 loaded
wlan0: Ethernet address: 14:d6:4d:48:b1:cf
wlan0: ieee80211_ioctl_scanreq: flags 0x52 duration 0x7fffffff mindwell 0 maxdwell 0 nssid 0
wlan0: start_scan_locked: active scan, duration 2147483647 mindwell 0 maxdwell 0, desired mode auto, append, nojoin, once
wlan0: scan set 1g, 6g, 11g, 7g, 2g, 3g, 4g, 5g, 8g, 9g, 10g dwell min 20ms max 200ms
wlan0: scan_task: chan  10g ->   1g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   1g ->   6g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   6g ->  11g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan  11g ->   7g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   7g ->   2g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   2g ->   3g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   3g ->   4g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   4g ->   5g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   5g ->   8g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   8g ->   9g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   9g ->  10g [active, dwell min 20ms max 200ms]
wlan0: sta_pick_bss: no scan candidate
wlan0: scan_task: done, [ticks 322198, dwell min 20 scanend 2147803412]
wlan0: notify scan done
wlan0: ieee80211_ioctl_scanreq: flags 0x52 duration 0x7fffffff mindwell 0 maxdwell 0 nssid 0
wlan0: start_scan_locked: active scan, duration 2147483647 mindwell 0 maxdwell 0, desired mode auto, append, nojoin, once
wlan0: scan set 1g, 6g, 11g, 7g, 2g, 3g, 4g, 5g, 8g, 9g, 10g dwell min 20ms max 200ms
wlan0: scan_task: chan  10g ->   1g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   1g ->   6g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   6g ->  11g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan  11g ->   7g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   7g ->   2g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   2g ->   3g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   3g ->   4g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   4g ->   5g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   5g ->   8g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   8g ->   9g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   9g ->  10g [active, dwell min 20ms max 200ms]
wlan0: sta_pick_bss: no scan candidate
wlan0: scan_task: done, [ticks 329632, dwell min 20 scanend 2147810846]
wlan0: notify scan done
wlan0: ieee80211_ioctl_scanreq: flags 0x52 duration 0x7fffffff mindwell 0 maxdwell 0 nssid 0
wlan0: start_scan_locked: active scan, duration 2147483647 mindwell 0 maxdwell 0, desired mode auto, append, nojoin, once
wlan0: scan set 1g, 6g, 11g, 7g, 2g, 3g, 4g, 5g, 8g, 9g, 10g dwell min 20ms max 200ms
wlan0: scan_task: chan  10g ->   1g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   1g ->   6g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   6g ->  11g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan  11g ->   7g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   7g ->   2g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   2g ->   3g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   3g ->   4g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   4g ->   5g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   5g ->   8g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   8g ->   9g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   9g ->  10g [active, dwell min 20ms max 200ms]
wlan0: sta_pick_bss: no scan candidate
wlan0: scan_task: done, [ticks 337070, dwell min 20 scanend 2147818280]
wlan0: notify scan done
wlan0: ieee80211_ioctl_scanreq: flags 0x52 duration 0x7fffffff mindwell 0 maxdwell 0 nssid 0
wlan0: start_scan_locked: active scan, duration 2147483647 mindwell 0 maxdwell 0, desired mode auto, append, nojoin, once
wlan0: scan set 1g, 6g, 11g, 7g, 2g, 3g, 4g, 5g, 8g, 9g, 10g dwell min 20ms max 200ms
wlan0: scan_task: chan  10g ->   1g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   1g ->   6g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   6g ->  11g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan  11g ->   7g [active, dwell min 20ms max 200ms]
```
Finally, I unplugged and replugged the device, and did the dmesg grep again, with this result:

```
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus6
run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 14:d6:4d:48:b1:cf
run0: firmware RT3071 loaded
wlan0: Ethernet address: 14:d6:4d:48:b1:cf
wlan0: ieee80211_ioctl_scanreq: flags 0x52 duration 0x7fffffff mindwell 0 maxdwell 0 nssid 0
<... snip, same as before ...>
wlan0: scan_task: chan  10g ->   1g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   1g ->   6g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan   6g ->  11g [active, dwell min 20ms max 200ms]
wlan0: scan_task: chan  11g ->   7g [active, dwell min 20ms max 200ms]
wlan0: ieee80211_new_state_locked: pending SCAN -> AUTH transition lost
wlan0: link state changed to UP
wlan0: link state changed to DOWN
wlan0: link state changed to UP
run0: at uhub6, port 1, addr 2 (disconnected)
wlan0: link state changed to DOWN
run0: <Ralink 11n Adapter, class 0/0, rev 2.00/1.01, addr 2> on usbus6
run0: MAC/BBP RT3071 (rev 0x021C), RF RT3022 (MIMO 2T2R), address 14:d6:4d:48:b1:cf
run0: firmware RT3071 loaded
wlan0: Ethernet address: 14:d6:4d:48:b1:cf
wlan0: link state changed to UP
```

/boot/loader.conf is now:

```
if_run_load="YES"
runfw_load="YES"

wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"

nvidia_load="YES"
snd_hda_load="YES"
```
/etc/rc.conf also follows:

```
# -- sysinstall generated deltas -- # Thu Oct 27 01:04:32 2011
# Created: Thu Oct 27 01:04:32 2011
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="us.international"
moused_enable="NO"

wlans_run0=wlan0
ifconfig_wlan0="WPA DHCP"

hald_enable="YES"
dbus_enable="YES"

kdm4_enable="YES"
```

Everything was done with the DWA 140. Apparently, the DWL G122 behaves similarly, but I didn't collect the same data on it. I hope this gives sufficient information. Please, let me know if I can be more precise.


----------



## PseudoCylon (Nov 8, 2011)

I couldn't reproduce the problem on my laptop. Booted 5 times and worked on every time. Is it like booting works but not re-booting? I cannot re-boot my laptop. It stalls.

First, I forgot one wlandebug flag. When it is not working,`# wlandebug -i wlan0 debug`wait for 10-15 sec.`# wlandebug -i wlan0 0``% dmesg | grep wlan0:\ received\ beacon`(Don't miss ":" after "wlan0".) Confirm (I guess) it doesn't return any thing.

Second, when it is not working (you can continue working, no need to re-boot after the above),`# sysctl hw.usb.run.debug=15`(If the above dmesg(8) returns something, set it to "10" instead of "15".) Wait for 10-15 sec.`# sysctl hw.usb.run.debug=0``% dmesg | grep run_ >> /file/you/choose`(There is "_" after "run".) Post/attach the file.


Actually, this is wired. There should be another "changed to DOWN" before "UP".


			
				Halberdier said:
			
		

> ```
> wlan0: link state changed to UP
> wlan0: link state changed to DOWN
> wlan0: link state changed to UP
> ```


So, when it isn't working (again you can just continue on, no need to re-boot), `% ifconfig wlan0`and confirm "UP" and "RUNNING" flags are set, i.e.
	
	



```
wlan0: flags=8843<[b]UP[/b], BROADCAST, [B]RUNNING[/B], SIMPLEX, MULTICAST> metric 0 mtu 1500
```


This





			
				Halberdier said:
			
		

> ```
> wlans_run0=wlan0
> ```


should be
	
	



```
wlans_run0=[b]"[/b]wlan0[b]"[/b]
```
with quotation marks, just in case.


hint
You can issue all commands in KDE's terminal, and dmesg(8) prints out in it. Also, doing it with DWA-140 is sufficient, since RT2020 (DWL-G122) has a known issue.


----------



## Halberdier (Nov 11, 2011)

It is the opposite, booting does not work, but now it doesn't require unplug/plug, the command

```
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
```
suffices. Then, on reboot, it works.

I did wlandebug ... debug, waited 20 secs, wlandebug ... 0, dmesg | grep wlan0:... and I confirm it didn't return anything, neither from root nor from normal user.

Then sysctl ...=15, wait 20 secs, sysctl ...=0, dmesg | grep... and the output file is this:

```
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_enable_tsf_sync: rvp_id=0 ic_opmode=1
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_enable_tsf_sync: rvp_id=0 ic_opmode=1
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_tx_param: sending raw frame len=42 rate=2
run_bulk_tx_callbackN: sending frame len=42 xferlen=68 @ index 0
run_bulk_tx_callbackN: transfer complete: 68 bytes @ index 0
run_enable_tsf_sync: rvp_id=0 ic_opmode=1
```

wlans_run0=wlan0 : shame on me!!! Consider that I edited the file with emacs, so that it was highlighted in a stunning black among pale green and yellow words .

Until the next time.


----------



## PseudoCylon (Nov 14, 2011)

It seems the driver is fine as long as the codes are properly executed, but something goes wrong during cold boot. As the result, the device will not properly be initiated.

usbd_do_request_flags() tends to fail. So that, it is put in a loop @if_run.c:1062

```
static usb_error_t
run_do_request(struct run_softc *sc,
    struct usb_device_request *req, void *data)
{
	usb_error_t err;
	int ntries = 10;

	RUN_LOCK_ASSERT(sc, MA_OWNED);

	while (ntries--) {
		err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx,
		    req, data, 0, NULL, 250 /* ms */);
		if (err == 0)
			break;
		DPRINTFN(1, "Control request failed, %s (retrying)\n",
		    usbd_errstr(err));
		run_delay(sc, 10);
	}
	return (err);
}
```
You can change that to
	
	



```
static usb_error_t
run_do_request(struct run_softc *sc,
    struct usb_device_request *req, void *data)
{
	usb_error_t err;
	int ntries = 10;

	RUN_LOCK_ASSERT(sc, MA_OWNED);

	while (ntries--) {
		err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx,
		    req, data, 0, NULL, 250 /* ms */);
		if (err == 0)
			[color="YellowGreen"]return (0);[/color]
		run_delay(sc, 10);
	}
	[color="YellowGreen"]device_printf(sc->sc_dev, "Control request failed, %s\n",
	    usbd_errstr(err));[/color]

	return (err);
}
```
If you see the message, that is the cause. Then, you may increase ntries as workaround.

Because I could not reproduce the problem, I am not sure if this fixes the issue. I will also keep eye on bug report might caused the issue. Until then, this is the best bet.


----------



## NicoM (Nov 14, 2011)

Hi,
I've got also a RT3070-based wifi usb, and have the same problem (doesn't work at boot).

I've modified the if_run.c file, but there's no message. How much do think i could increase the ntries variable? (Just for a test)


----------



## PseudoCylon (Nov 16, 2011)

NicoM said:
			
		

> Hi,
> I've got also a RT3070-based wifi usb, and have the same problem (doesn't work at boot).
> 
> I've modified the if_run.c file, but there's no message. How much do think i could increase the ntries variable? (Just for a test)


Well then, run_do_request() isn't the cause of the problem. (Changing ntries won't do anything.) This issue might be outside run(4).

What version are you using, 8.2-RELESE-p1, p2, or p3?


----------



## NicoM (Nov 16, 2011)

Hi,

Thank you for all this work! I'm on 8-2 RELEASE-p3. I'll post my *dmesg* soon. My wireless USB is an Edimax EW-7711UAn (support by run driver). It's weird because when I unplug then plug again it works. When it doesn't work, scanning won't detect any ssid. 

And, when it works, sometimes, my *ping* command just kind of "freezes" (no results, even lost packets), it doesn't show anything, I have then to do Ctrl-C to stop it. Sometimes, doing [cmd=]wpa_supplicant -B -i wlan -c /etc/wpa_supplicant.conf[/cmd] works (without unplugging) but sometimes it doesn't.


----------



## Halberdier (Nov 16, 2011)

Mine, after [cmd=]wpa_supplicant -B -i wlan -c /etc/wpa_supplicant.conf[/cmd] works regularly with no need to unplug, it just takes a bit to complete the dhcp handshake. I don't understand the p1, p2, p3 thing:


```
# uname -aip
FreeBSD  8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64 amd64 GENERIC
```


----------



## StainlessRat (Nov 17, 2011)

Hi,

My wireless USB is an DWA-125 on chip 3070. This device work as "Access point":
/etc/rc.conf

```
wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap ssid FreeBSD_AP channel 11"
ifconfig_wlan0="WPA inet 10.1.0.1 netmask 0xffffff00 up"
hostapd_enable="YES"
```
/etc/hostapd.conf

```
interface=wlan0
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
debug=4
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=FreeBSD_AP
wpa=3
wpa_passphrase=verylongpassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
```
`uname -a`

```
FreeBSD gate.home 9.0-RC1 FreeBSD 9.0-RC1 #0: Mon Nov 14 21:27:57 VOLT 2011     
[email]root@gate.home[/email]:/usr/obj/usr/src/sys/KERNEL0  amd64
```
I plugin wireless USB, after some time, wireless net "freeze" with messages in logs.


```
run0: device timeout 2
run0: device timeout 2
```

I have edited the source code /usr/src/sys/dev/usb/wlan/if_run.c line 2617:

```
if (error == USB_ERR_TIMEOUT)
  device_printf(sc->sc_dev, "device timeout 1\n");
```
line 2817

```
if (error == USB_ERR_TIMEOUT) {
  device_printf(sc->sc_dev, "device timeout 2\n");
```
and built kernel with debug symbols. As the result in logs:

View attachment log.txt


----------



## StainlessRat (Nov 17, 2011)

Excuse me, in my previous post


```
run0: device timeout
```

And after change source code
...

```
run0: device timeout 2
run0: device timeout 2
```


----------



## PseudoCylon (Nov 18, 2011)

*@Halberdier* and *@NicoM*
The prime suspect of cold boot problem is variation in hz/tick, but the code looks OK i.e. I'll keep looking for bugs, but it may take for a while.

*@NicoM*
Ping problem is most likely encryption failure. When ping is not working, check if the device is still associated with`% ifconfig wlan0`(see "status"),
debug message with`# wlandebug -i wlan0 crypto+assoc+auth`, and`# sysctl hw.usb.run.debug=1`There should be error message like
	
	



```
run_rx_frame: IVC error
```
(If you are using GENERIC kernel these cmd should work.) I am patching all encryption related glitch as responding usb/150189.

*@StainlessRat*
Try this patch
	
	



```
diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
index 6f8608d..cca73d8 100644
--- a/dev/usb/wlan/if_run.c
+++ b/dev/usb/wlan/if_run.c
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/wlan/if_run.c,v 1.25 2011/11/07 15:43:11 ed Exp $");
+__FBSDID("$FreeBSD$");
 
 /*-
  * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver.
@@ -2718,7 +2718,6 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, unsigned int ind
 	struct run_endpoint_queue *pq = &sc->sc_epq[index];
 	struct mbuf *m;
 	usb_frlength_t size;
-	unsigned int len;
 	int actlen;
 	int sumlen;
 
@@ -2781,13 +2780,10 @@ tr_setup:
 			ieee80211_radiotap_tx(vap, m);
 		}
 
-		/* align end on a 4-bytes boundary */
-		len = (size + IEEE80211_CRC_LEN + m->m_pkthdr.len + 3) & ~3;
+		DPRINTFN(11, "sending frame len=%u  @ index %d\n",
+			m->m_pkthdr.len, index);
 
-		DPRINTFN(11, "sending frame len=%u xferlen=%u @ index %d\n",
-			m->m_pkthdr.len, len, index);
-
-		usbd_xfer_set_frame_len(xfer, 0, len);
+		usbd_xfer_set_frame_len(xfer, 0, size + m->m_pkthdr.len);
 		usbd_xfer_set_priv(xfer, data);
 
 		usbd_transfer_submit(xfer);
@@ -2932,6 +2928,15 @@ run_set_tx_desc(struct run_softc *sc, struct run_tx_data *data)
 
 	if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh))
 		txwi->xflags |= RT2860_TX_NSEQ;
+
+	/*
+	 * Align end on a 4-byte boundary, pad 8 bytes, and
+	 * be sure to zero those trailing bytes.
+	 */
+	uint8_t tail[11];
+	memset(tail, 0, 11);
+	m_append(m, ((m->m_pkthdr.len + 3) & ~3) - m->m_pkthdr.len + 8,
+	    (c_caddr_t)&tail);
 }
 
 /* This function must be called locked */
```


----------



## SIFE (Nov 20, 2011)

Does it support injection mode?


----------



## NicoM (Nov 20, 2011)

Thanks. The "ping" problem hasn't showed again yet, I'll try to get the messages next time they appear.

A friend lend me a D-Link DWA-140, and it doesn't have any of the issues of the Edimax EW-7711UAn (both with run driver). Cold boot, reboot, it always works (tried like 10 reboots and 10 cold boots). I wonder why the Edimax would have such issues.


----------



## PseudoCylon (Nov 22, 2011)

SIFE said:
			
		

> Does it support injection mode?


There is no such mode. If you just want to shoot raw packets, you can do that though bpf. dhclient(8) sends packets in that way.



			
				NicoM said:
			
		

> A friend lend me a D-Link DWA-140, and it doesn't have any of the issues of the Edimax EW-7711UAn (both with run driver). Cold boot, reboot, it always works (tried like 10 reboots and 10 cold boots). I wonder why the Edimax would have such issues.


There are different routine for different chipsets. Exactly, what chipset EW-7711UAn use? As far as I know, DWA-140 uses mac/rf == 3071/3022.

Actually, One committer is looking into pause/delay part of code. There might soon be a fix.


----------



## StainlessRat (Nov 24, 2011)

Hi
I test patch specified above. The error "run0: device timeout" doesn't appear.
But, wireless connection "freeze" with messages (attachment at the bottom)

"13:08:10" the network stoped
"13:08:26" i connect to server and run tcpdump ("13:09:09")
"13:09:14" has tried to lay out a tunnel to 10.1.0.2:5900
"13:09:26" break tcpdump.
No "ping"

```
PING 10.1.0.2 (10.1.0.2): 56 data bytes
ping: sendto: Host is down
ping: sendto: Host is down
```


```
arp -a
? (10.1.0.2) at (incomplete) on wlan0 expired [ethernet]
? (10.1.0.1) at f0:7d:68:62:ae:13 on wlan0 permanent [ethernet]
? (10.0.0.1) at 00:1c:f0:8b:4e:9e on vr0 permanent [ethernet]
? (192.168.1.2) at 70:71:bc:94:a5:ee on re0 permanent [ethernet]
```


----------



## PseudoCylon (Nov 26, 2011)

Oops! There is an extra ampersand. Sorry. Here is a patch to the previous patch.
	
	



```
diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
index cca73d8..a2c795d 100644
--- a/dev/usb/wlan/if_run.c
+++ b/dev/usb/wlan/if_run.c
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
 #include "usbdevs.h"
 
 #define USB_DEBUG_VAR run_debug
+#define USB_DEBUG
 #include <dev/usb/usb_debug.h>
 
 #include <dev/usb/wlan/if_runreg.h>
@@ -2936,7 +2937,7 @@ run_set_tx_desc(struct run_softc *sc, struct run_tx_data *data)
 	uint8_t tail[11];
 	memset(tail, 0, 11);
 	m_append(m, ((m->m_pkthdr.len + 3) & ~3) - m->m_pkthdr.len + 8,
-	    (c_caddr_t)&tail);
+	    (c_caddr_t)tail);
 }
 
 /* This function must be called locked */
```
or a patch to the stock driver (v. 1.25)
	
	



```
diff --git a/dev/usb/wlan/if_run.c b/dev/usb/wlan/if_run.c
index 6f8608d..a2c795d 100644
--- a/dev/usb/wlan/if_run.c
+++ b/dev/usb/wlan/if_run.c
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/usb/wlan/if_run.c,v 1.25 2011/11/07 15:43:11 ed Exp $");
+__FBSDID("$FreeBSD$");
 
 /*-
  * Ralink Technology RT2700U/RT2800U/RT3000U chipset driver.
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD: src/sys/dev/usb/wlan/if_run.c,v 1.25 2011/11/07 15:43:11 ed
 #include "usbdevs.h"
 
 #define USB_DEBUG_VAR run_debug
+#define USB_DEBUG
 #include <dev/usb/usb_debug.h>
 
 #include <dev/usb/wlan/if_runreg.h>
@@ -2718,7 +2719,6 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, unsigned int ind
 	struct run_endpoint_queue *pq = &sc->sc_epq[index];
 	struct mbuf *m;
 	usb_frlength_t size;
-	unsigned int len;
 	int actlen;
 	int sumlen;
 
@@ -2781,13 +2781,10 @@ tr_setup:
 			ieee80211_radiotap_tx(vap, m);
 		}
 
-		/* align end on a 4-bytes boundary */
-		len = (size + IEEE80211_CRC_LEN + m->m_pkthdr.len + 3) & ~3;
+		DPRINTFN(11, "sending frame len=%u  @ index %d\n",
+			m->m_pkthdr.len, index);
 
-		DPRINTFN(11, "sending frame len=%u xferlen=%u @ index %d\n",
-			m->m_pkthdr.len, len, index);
-
-		usbd_xfer_set_frame_len(xfer, 0, len);
+		usbd_xfer_set_frame_len(xfer, 0, size + m->m_pkthdr.len);
 		usbd_xfer_set_priv(xfer, data);
 
 		usbd_transfer_submit(xfer);
@@ -2932,6 +2929,15 @@ run_set_tx_desc(struct run_softc *sc, struct run_tx_data *data)
 
 	if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh))
 		txwi->xflags |= RT2860_TX_NSEQ;
+
+	/*
+	 * Align end on a 4-byte boundary, pad 8 bytes, and
+	 * be sure to zero those trailing bytes.
+	 */
+	uint8_t tail[11];
+	memset(tail, 0, 11);
+	m_append(m, ((m->m_pkthdr.len + 3) & ~3) - m->m_pkthdr.len + 8,
+	    (c_caddr_t)tail);
 }
 
 /* This function must be called locked */
```
I also defined USB_DEBUG. You can set debug level on the fly even when you compile the driver separately from kernel with`# sysctl hw.usb.run.debug=N`(N = 1 is suficient for debugging this issue and won't make too much noise. N = 0 to turn it off.)


----------



## StainlessRat (Dec 5, 2011)

Hi.
My machine online 8-12 hours, 7 days on week, no more errors.
This a patch result for 1.23 version

```
diff -u b/if_run.c a/if_run.c
--- b/if_run.c  2011-12-05 15:16:37.410924305 +0400
+++ a/if_run.c  2011-12-05 15:37:34.959926722 +0400
@@ -2718,7 +2718,6 @@
        struct run_endpoint_queue *pq = &sc->sc_epq[index];
        struct mbuf *m;
        usb_frlength_t size;
-       unsigned int len;
        int actlen;
        int sumlen;

@@ -2781,13 +2780,10 @@
                        ieee80211_radiotap_tx(vap, m);
                }

-               /* align end on a 4-bytes boundary */
-               len = (size + IEEE80211_CRC_LEN + m->m_pkthdr.len + 3) & ~3;
+               DPRINTFN(11, "sending frame len=%u  @ index %d\n",
+                       m->m_pkthdr.len, index);

-               DPRINTFN(11, "sending frame len=%u xferlen=%u @ index %d\n",
-                       m->m_pkthdr.len, len, index);
-
-               usbd_xfer_set_frame_len(xfer, 0, len);
+               usbd_xfer_set_frame_len(xfer, 0, size + m->m_pkthdr.len);
                usbd_xfer_set_priv(xfer, data);

                usbd_transfer_submit(xfer);
@@ -2932,6 +2928,15 @@

        if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh))
                txwi->xflags |= RT2860_TX_NSEQ;
+
+       /*
+        * Align end on a 4-byte boundary, pad 8 bytes, and
+        * be sure to zero those trailing bytes.
+        */
+       uint8_t tail[11];
+       memset(tail, 0, 11);
+       m_append(m, ((m->m_pkthdr.len + 3) & ~3) - m->m_pkthdr.len + 8,
+           (c_caddr_t)tail);
 }

 /* This function must be called locked */
```
Thank you very much


----------



## PseudoCylon (Dec 18, 2011)

Committed to HEAD
http://svnweb.freebsd.org/base?view=revision&revision=228508

Thank you for reporting.


----------



## Denzelii (Jul 17, 2012)

Hi!

A have an usb wireless adapter:

ugen4.2: <802.11 g WLAN Ralink> at usbus4, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
run0: MAC/BBP RT3070 (rev 0x0201), RF RT2020 (MIMO 1T1R), address 54:e6:fc:8e:39:2f

I'm trying to use as access point with hostapd, but it's sending some packets and freeze. If I reconnect, working a bit and freeze again with these message:
run0: device timeout
run0: device timeout

I applied the patch above (if_run.c, recompiled), but the error is still apear.

Any suggestion?


----------



## PseudoCylon (Jul 17, 2012)

I need more info. Please do followings and let me know what it says.

1) Add a line to /usr/src/sys/modules/usb/run/Makefile as below.
	
	



```
SRCS=   opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
        if_run.c

[color="Green"]+CFLAGS+= -DUSB_DEBUG
+[/color]
.include <bsd.kmod.mk>
```
2) recompile

3) set`# sysctl hw.usb.run.debug=1`

I'm wondering what this part is doing. How log does device work for before the timeout occurs?

If you are using a USB extension code, make sure to put it away from a power code or other higher voltage lines.


----------



## Denzelii (Jul 17, 2012)

Here's the log:

```
Jul 17 23:28:54 rozi kernel: run_newstate: INIT -> INIT
Jul 17 23:28:54 rozi kernel: run_newstate: INIT -> SCAN
Jul 17 23:28:54 rozi kernel: run_update_promisc_locked: entering promiscuous mode
Jul 17 23:28:57 rozi kernel: run_enable_tsf_sync: rvp_id=0 ic_opmode=4
Jul 17 23:28:57 rozi kernel: run_updateslot: cmdq_store=0
Jul 17 23:28:57 rozi kernel: run_wme_update: cmdq_store=1
Jul 17 23:28:57 rozi kernel: run_update_promisc_locked: leaving promiscuous mode
Jul 17 23:28:57 rozi kernel: run_newstate: SCAN -> RUN
Jul 17 23:28:57 rozi kernel: run_updateslot: cmdq_store=2
Jul 17 23:28:57 rozi kernel: run_enable_tsf_sync: rvp_id=0 ic_opmode=4
Jul 17 23:29:04 rozi kernel: run_newassoc: cmdq_store=3
Jul 17 23:29:04 rozi kernel: run_newassoc: new assoc isnew=1 associd=c001 addr=00:26:37:66:d2:8e
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x82 ridx=0 ctl_ridx=0
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x84 ridx=1 ctl_ridx=1
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x8b ridx=2 ctl_ridx=2
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x0c ridx=4 ctl_ridx=4
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x12 ridx=5 ctl_ridx=4
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x96 ridx=3 ctl_ridx=3
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x18 ridx=6 ctl_ridx=6
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x24 ridx=7 ctl_ridx=6
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x30 ridx=8 ctl_ridx=8
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x48 ridx=9 ctl_ridx=8
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x60 ridx=10 ctl_ridx=8
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=0x6c ridx=11 ctl_ridx=8
Jul 17 23:29:04 rozi kernel: run_newassoc: rate=2, mgmt_ridx=0
Jul 17 23:29:04 rozi kernel: run_update_beacon: cmdq_store=4
Jul 17 23:29:04 rozi kernel: run_wme_update: cmdq_store=5
Jul 17 23:29:04 rozi kernel: run_update_beacon: cmdq_store=6
Jul 17 23:29:04 rozi kernel: run_update_beacon: cmdq_store=7
Jul 17 23:29:04 rozi kernel: run_update_beacon: cmdq_store=8
Jul 17 23:29:04 rozi kernel: run_update_beacon: cmdq_store=9
Jul 17 23:29:12 rozi kernel: run_update_beacon: cmdq_store=10
Jul 17 23:29:12 rozi kernel: run_update_beacon: cmdq_store=11
Jul 17 23:29:14 rozi kernel: run_update_beacon: cmdq_store=12
Jul 17 23:29:14 rozi kernel: run_update_beacon: cmdq_store=13
Jul 17 23:29:52 rozi kernel: run_update_beacon: cmdq_store=1
Jul 17 23:29:52 rozi kernel: run_update_beacon: cmdq_store=2
Jul 17 23:30:03 rozi kernel: run_update_beacon: cmdq_store=6
Jul 17 23:30:03 rozi kernel: run_update_beacon: cmdq_store=7
Jul 17 23:30:04 rozi kernel: run_update_beacon: cmdq_store=8
Jul 17 23:30:04 rozi kernel: run_update_beacon: cmdq_store=9
Jul 17 23:30:05 rozi kernel: run_update_beacon: cmdq_store=10
Jul 17 23:30:05 rozi kernel: run_update_beacon: cmdq_store=11
Jul 17 23:30:05 rozi kernel: run_update_beacon: cmdq_store=12
Jul 17 23:30:05 rozi kernel: run_update_beacon: cmdq_store=13
Jul 17 23:30:11 rozi kernel: run_update_beacon: cmdq_store=2
Jul 17 23:30:11 rozi kernel: run_update_beacon: cmdq_store=3
Jul 17 23:30:16 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:16 rozi kernel: run0: device timeout
Jul 17 23:30:16 rozi kernel: run_bulk_tx_callbackN: cmdq_store=4
Jul 17 23:30:18 rozi kernel: run_update_beacon: cmdq_store=5
Jul 17 23:30:18 rozi kernel: run_update_beacon: cmdq_store=6
Jul 17 23:30:18 rozi kernel: run_update_beacon: cmdq_store=7
Jul 17 23:30:18 rozi kernel: run_update_beacon: cmdq_store=8
Jul 17 23:30:34 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:34 rozi kernel: run0: device timeout
Jul 17 23:30:34 rozi kernel: run_bulk_tx_callbackN: cmdq_store=9
Jul 17 23:30:39 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:39 rozi kernel: run0: device timeout
Jul 17 23:30:39 rozi kernel: run_bulk_tx_callbackN: cmdq_store=10
Jul 17 23:30:43 rozi kernel: run_update_beacon: cmdq_store=11
Jul 17 23:30:44 rozi kernel: run_update_beacon: cmdq_store=12
Jul 17 23:30:48 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:48 rozi kernel: run0: device timeout
Jul 17 23:30:48 rozi kernel: run_bulk_tx_callbackN: cmdq_store=13
Jul 17 23:30:49 rozi kernel: run_update_beacon: cmdq_store=14
Jul 17 23:30:49 rozi kernel: run_update_beacon: cmdq_store=15
Jul 17 23:30:53 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:53 rozi kernel: run0: device timeout
Jul 17 23:30:53 rozi kernel: run_bulk_tx_callbackN: cmdq_store=0
Jul 17 23:30:58 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:30:58 rozi kernel: run0: device timeout
Jul 17 23:30:58 rozi kernel: run_bulk_tx_callbackN: cmdq_store=1
Jul 17 23:31:01 rozi kernel: run_update_beacon: cmdq_store=2
Jul 17 23:31:01 rozi kernel: run_update_beacon: cmdq_store=3
Jul 17 23:31:03 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:31:03 rozi kernel: run0: device timeout
Jul 17 23:31:03 rozi kernel: run_bulk_tx_callbackN: cmdq_store=4
Jul 17 23:31:07 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:31:07 rozi kernel: run0: device timeout
Jul 17 23:31:07 rozi kernel: run_bulk_tx_callbackN: cmdq_store=5
Jul 17 23:31:17 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:31:17 rozi kernel: run0: device timeout
Jul 17 23:31:17 rozi kernel: run_bulk_tx_callbackN: cmdq_store=6
Jul 17 23:31:22 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:31:22 rozi kernel: run0: device timeout
Jul 17 23:31:22 rozi kernel: run_bulk_tx_callbackN: cmdq_store=7
Jul 17 23:31:26 rozi kernel: run_update_beacon: cmdq_store=8
Jul 17 23:31:26 rozi kernel: run_update_beacon: cmdq_store=9
Jul 17 23:31:31 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:31:31 rozi kernel: run0: device timeout
Jul 17 23:31:31 rozi kernel: run_bulk_tx_callbackN: cmdq_store=10
Jul 17 23:32:07 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:32:07 rozi kernel: run0: device timeout
Jul 17 23:32:07 rozi kernel: run_bulk_tx_callbackN: cmdq_store=11
Jul 17 23:32:14 rozi kernel: run_update_beacon: cmdq_store=12
Jul 17 23:32:14 rozi kernel: run_update_beacon: cmdq_store=13
Jul 17 23:32:42 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:32:42 rozi kernel: run0: device timeout
Jul 17 23:32:42 rozi kernel: run_bulk_tx_callbackN: cmdq_store=14
Jul 17 23:32:47 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:32:47 rozi kernel: run0: device timeout
Jul 17 23:32:47 rozi kernel: run_bulk_tx_callbackN: cmdq_store=15
Jul 17 23:32:52 rozi kernel: run_bulk_tx_callbackN: USB transfer error, USB_ERR_TIMEOUT
Jul 17 23:32:52 rozi kernel: run0: device timeout
Jul 17 23:32:52 rozi kernel: run_bulk_tx_callbackN: cmdq_store=0
```

Between 23:29:04 - 23:30:11 worked fine. I searched in a google, and start downloading the first result. The most part of the data was received (about 80%), but after it (23:30:16 rozi kernel: run0: device timeout) the browser stopped to download the rest.


----------



## PseudoCylon (Jul 18, 2012)

Can you check if the device is still sending beacons after timeout occurs, i.e
1) a station can still see the ap,
2) a LED on the USB device is still blinking at the same rate as beacon tx (default is 10 times/sec.), or
3) capture a beacon.

Because there are multiple beacon update per second, the hardware might read beacon buffer area while driver is writing on it. When the hardware gets one corrupted descriptor, tx could stuck.


----------



## Denzelii (Jul 18, 2012)

I will check the blinking speed at night.

I connecting to the ap with my cellphone. After the freeze, the phone can reconnect later (it's need 2 minutes for hostapd releasing the sid, but if I restarting the hostapd the phone can connect immediatly). The LED is still blinking, but I never tested the rate.

How can I capture the beacon?


----------



## Denzelii (Jul 18, 2012)

These are missing from the previous post:

FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:15:25 UTC 2012

Jul 18 23:20:38 rozi kernel: run0: MAC/BBP RT3070 (rev 0x0201), RF RT2020 (MIMO 1T1R), address 54:e6:fc:8e:39:2f
Jul 18 23:20:38 rozi kernel: run0: firmware RT2870 loaded

A new log's file attached.


When timeout happens:
 - another device can see the ap, but can't connect (ap is not responding)
 - the wifi's led is blinking with the same speed


----------



## PseudoCylon (Jul 19, 2012)

Thanks for the more log.

So, this is what happening. When timeout happens,
* stations can still see the AP, but cannot connect;
* without touching the AP (no power down or no command issued on the AP) just waiting for several minutes, station can reconnect. (mmm... This puzzles me more.)

Then, attached workaround might work. All patches have been applied, just replace if_run.c and recompile.


----------



## Denzelii (Jul 19, 2012)

The new log was attached.

It was the same.

Small description:

at Jul 19 22:22:24 - I'm trying to reconnect with my cellphone
(the led is blinking with the same speed, cellphone can see the ap, but can't connect to it)
at Jul 19 22:25:13 - hostapd restarted
at Jul 19 22:26:** - speedtest runned
Jul 19 22:22:27:** - a trying to run the test again, but freezed
(the led is blinking with the same speed, cellphone can see the ap, but can't connect to it)

10 minutes later: cellphone can see the ap, but can't connect to it

Last night the phone can reconnect after a few minutes, but now, after 14 minutes can't estabilish a connection.


----------



## Denzelii (Jul 19, 2012)

35 minutes later, the cellphone still can't connect without hostapd restart.

I think when hostapd restarting, the buffer is reinitializing.

Thanks you help!


----------



## PseudoCylon (Jul 20, 2012)

I was hoping the workaround would buy me sometime for digging in the problem, but I guess it didn't.

Since I don't have any documentation, it will take while to figure out. In the meantime, you can try 11n version. Your device is a b/g only one, but Tx OP related bits are also enabled. It might help shooting the packet into the air.

Also, here is Ralink's code. I will be more than happy if you find the problem.


----------



## Denzelii (Jul 23, 2012)

Sorry, I was away.

I downloaded, compiled and tried the 11n version, but producing the same behavior.
(run0: device time out after for a short time).

What should I check in the Ralink's code? I know programing in C, so I hope I can help, but I don't understand the if_run.c, so I don't have any idea, where should I start debugging or modifying the code. I never wrote driver. I just wrote some other programs.

As I think, I can't use the Ralink driver directly. What functions should I check?


----------



## Denzelii (Jul 23, 2012)

I tried the Egorenkov driver (http://forums.freebsd.org/showthread.php?t=7010): it is not working.


----------



## PseudoCylon (Jul 24, 2012)

Denzelii said:
			
		

> What should I check in the Ralink's code? I know programing in C, so I hope I can help, but I don't understand the if_run.c, so I don't have any idea, where should I start debugging or modifying the code. I never wrote driver. I just wrote some other programs.


Cool!

In this case, the device doesn't like the data received, and the data is stuck in the device (nothing is transmitted). Maybe, there is something not right in Tx pass, run_raw_xmit() or run_start(). The last time it was just zeroing trailing bytes. You may compare with Ralink's, i.e. this.

The log shows run_update_beacon() is called far too often. At my place, it is only called once every 15 min. or so. I guess tx bulk transfer and run_do_request() are called at wrong time or order. usbd_do_request_flags() can sleep, so calling it first doesn't guarantee completed first. Though APs don't bgscan, in sta mode, bgscan causes device timeout (That's why the driver doesn't support it.) Because, during the scan, registers are also read/written often, I guess that does something with the device timeout. I'm checking these functions to see if there is anything I need to do. But this is my guess. If you have other guess, you are more than welcome to dig into it. I don't have any documentation; you can find everything I know on the internet.

If it isn't a big problem, try using the AP in low wireless traffic area and see if the timeout still occurs. Also, it would be helpful if you find out what is updating the becaon by adding an extra debug message, like
	
	



```
run_update_beacon(struct ieee80211vap *vap, int item)
{
...
        KASSERT(vap != NULL, ("no beacon"));
[color="Green"]+
+       DPRINTF("item=%d\n", item);
+[/color]
        switch (item) {
```


----------



## Denzelii (Jul 24, 2012)

Ok, I will try something.

But, I know programing in C doesn't means I understand this code, or I know what that function doing, or what that structure represent.


----------



## PseudoCylon (Jul 25, 2012)

Denzelii said:
			
		

> But, I know programing in C doesn't means I understand this code, or I know what that function doing, or what that structure represent.


That's true. But, to read and understand someone's code is also part of porting software, even though it is time consuming. Checking with linux code might be easier, because it is cross referenced, i.e. rt2800.c or rt2800lib.c.

I guess switching slot time during active Tx might be the cause.

Anyway, I'm happy with you have understood how much time I have to spend to fix this bug, at least.


----------



## Denzelii (Aug 27, 2012)

I understand. 
But I realized cheaper and faster to buy a supported hardware than to fix this.

Problem solved, I bought an asus stick.

Thanks for your helping.


----------



## PseudoCylon (Aug 28, 2012)

So, this is a device specific (RT3070/RF2020) problem then. That helps digging the problem further. Though, since you have got a new device, I'll finish adding 11n support.


----------



## wbedard (Sep 30, 2013)

Hi PseudoCyclon,

Although it has been some time since this thread was last active, I would like to touch base with you to see if you would be interested in working with me to more or less pick up where this thread last left off.  I am working with a new hardware setup running pfSense 2.1 (FreeBSD 8.3) and a couple of the following USB WiFi adapters:

Alfa Networks AWUS051NH

This adapter uses the Ralink RT2770 chipset and Alfa makes a lot of driver resources available over on their SourceForge page, here:

Alfa Networks on SourceForge

As for my ability to assist you in this effort, while I am not a developer, I am comfortable reading code and can certainly build patched versions of operating systems such as Android and FreeBSD.  My pfSense hardware is my initial exposure to FreeBSD so I am still learning a lot but I am a pretty quick study in this area.

I have been following your progress on the "run" driver over at Gitorius and would be more than happy to assist you in testing it, especially the new 802.11n functionality.  My principal focus, at the moment though, is to get past the "device timeout" issues that you previously discussed in this thread.  Please let me know if your current situation allows you to spend some time working with me to make some progress here.  Thanks in advance!

R/
wbedard


----------



## PseudoCylon (Oct 2, 2013)

wbedard said:
			
		

> My principal focus, at the moment though, is to get past the "device timeout" issues that you previously discussed in this thread.


That fix didn't go into 8.* You need to manually patch the code because you are running 8.3 RELEASE.
	
	



```
[B]diff --git a/if_run.c b/if_run.c
--- a/if_run.c
+++ b/if_run.c[/B]
[color="Blue"]@@ -2747,6 +2747,9 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, unsigned int index)[/color]
        size = sizeof(data->desc);
        usbd_copy_in(pc, 0, &data->desc, size);
        usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len);
[color="Green"]+       size += m->m_pkthdr.len;
+       usbd_frame_zero(pc, size, ((-size) & 3) + 8);
+       size += ((-size) & 3) + 8;[/color]

        vap = data->ni->ni_vap;
        if (ieee80211_radiotap_active_vap(vap)) {
```



			
				wbedard said:
			
		

> especially the new 802.11n functionality.


Actually, 8.* + 11n isn't a good combination because there are number of changes in 80211 stack. I remember it was a big pain in the neck, and I dumped 8.2 as soon as 9.0 was released. You need an extra hardware to run CURRENT (or 9.2 at least) to test 11n support.


----------



## wbedard (Oct 3, 2013)

PseudoCylon said:
			
		

> That fix didn't go into 8.* You need to manually patch the code because you are running 8.3 RELEASE
> ....


That little patch looks surprisingly easy to apply.  I'm looking forward to trying that out!  Can you point out any posts/threads where others have had positive results using your patch, perhaps even using similar USB adapters?



			
				PseudoCylon said:
			
		

> Actually, 8.* + 11n isn't a good combination because there are number of changes in 80211 stack. I remember it was a big pain in the neck, and I dumped 8.2 as soon as 9.0 was released. You need an extra hardware to run CURRENT (or 9.2 at least) to test 11n support.


Yes, I apologize for not being more clear on that point.  I was aware that 11n couldn't be used in my "production" hardware running pfsense.  What I was imagining doing was connecting one of my Alfa USB devices to my laptop and binding it to a VM running whatever version of FreeBSD you wanted tested.  I haven't actually verified that it would work though, since I was uncertain just how compatible my adapters were with FreeBSD.  Your patch has greatly encouraged me, though.  Let me know if you would be interested in me going down this route and providing you with my test results.

R/
wbedard


----------



## PseudoCylon (Oct 4, 2013)

wbedard said:
			
		

> Can you point out any posts/threads where others have had positive results using your patch, perhaps even using similar USB adapters?


Here is the original post, but his device uses different chipset.
http://forums.freebsd.org/showthread.php?p=156885#post156885



			
				wbedard said:
			
		

> What I was imagining doing was connecting one of my Alfa USB devices to my laptop and binding it to a VM running whatever version of FreeBSD you wanted tested.


9.2-RELEASE should do the job. Whether using CURRENT or the latest RELEASE, you will be end up checking-out the latest source and re-compile when there are important changes in 80211 stack.

Exactly what chipset does your device have? When you plug-in the device, there will be a debug message like this
	
	



```
run0: MAC/BBP RT3572 (rev 0x0221), RF RT3052 (MIMO 2T2R), address ...
```


----------



## gnoma (Oct 4, 2013)

Hello,

I have linksys WMP600N:


```
ral0@pci0:2:2:0:	class=0x028000 card=0x00671737 chip=0x06011814 rev=0x00 hdr=0x00
    vendor     = 'Ralink corp.'
    device     = 'RT2800 802.11n PCI'
    class      = network
```
I was using FreeBSD 7.2 for long time and I was working with if_run driver in 11g mode.

However I reinstalled to FreeBSD 9.0. Now I didn't have to install a driver, it was already included in the kernerl. 
I want now to use it in 11n mode, but I wasn't able to configure it:

```
root@sentinel:/ # ifconfig wlan0 mode 11n
ifconfig: SIOCSIFMEDIA (media): Device not configured
```
No encryption, no hostapd or some other stuff. I guess that the driver just doesn't support it. Now I saw that there is 11n support for this driver here. I hope it will still work so good now as it worked on FreeBSD 7.2 in 11g mode. My problem is that I don't know how to unload/remove the existing driver, as it is included in the kernel, so I can load the new one. Do I have to recompile the kernel? Is it possible to do it without recompile?

Thank you.


----------



## wbedard (Oct 4, 2013)

PseudoCylon said:
			
		

> Here is the original post, but his device uses different chipset.
> http://forums.freebsd.org/showthread.php?p=156885#post156885


Thanks for the reference.  I'll definitely check it out!


			
				PseudoCylon said:
			
		

> Exactly what chipset does your device have? When you plug-in the device, there will be a debug message like this...


My device looks like the following on pfSense 2.1 (FreeBSD 8.3):

```
run0: <1.0> on usbus1
run0: MAC/BBP RT2872 (rev 0x0202), RF RT2750 (MIMO 1T2R), address ....
run0: firmware RT2870 loaded
```


----------



## PseudoCylon (Oct 5, 2013)

@gnoma,


			
				gnoma said:
			
		

> ```
> ral0@pci0:2:2:0:	class=0x028000 card=0x00671737 chip=0x06011814 rev=0x00 hdr=0x00
> vendor     = 'Ralink corp.'
> device     = 'RT2800 802.11n PCI'
> ...


Your device uses ral(4), totally different driver. As far as I know, no one is working on adding 11n support at this moment.

@wbedard,


			
				wbedard said:
			
		

> My device looks like the following on pfSense 2.1 (FreeBSD 8.3):
> 
> ```
> run0: <1.0> on usbus1
> ...


I do not have any device with this chipset, but the driver on gitorious should (or hopefully) work. But, patch and see if device time out disappears before trying 11n.


----------



## wbedard (Oct 7, 2013)

PseudoCylon said:
			
		

> @wbedard,
> I do not have any device with this chipset, but the driver on gitorious should (or hopefully) work. But, patch and see if device time out disappears before trying 11n.



Well, that is pretty neat!  After getting through a few hurdles including:
    1. Familiarizing myself with the pfSense build process so that I could properly inject your patch,
    2. Debugging the pfSense build process to actually get a LiveCD ISO created,
    3. Figuring out an appropriate virtual networking configuration in VirtualBox to configure the VM,
it appears that your patch works like a charm!  Thanks for getting back into this thread to help me out.

BTW, I was a bit embarrassed to find out that the link you provided me previously was only one page back in this thread.  I actually did read this entire thread before posting but I think I was a bit intimidated by the details to leverage your previous discussions on my own.  Thanks for holding my hand a bit on this one.

Also, now that I am pretty familiar with all the aspects of this puzzle, my offer still stands if you would like some assistance debugging the 11n features of your driver, perhaps against some specific configuration cases.  You know a bit about my hardware setup but I don't mind compiling FreeBSD alpha/beta builds with non-standard configurations if you need the input.  It's not going to be for my regular use though as I don't plan on migrating my operational hardware to FreeBSD 9.x/10.x until the next release of pfSense.

R/
wbedard


----------



## wbedard (Oct 7, 2013)

wbedard said:
			
		

> Well, that is pretty neat!  After getting through a few hurdles including
> ...
> it appears that your patch works like a charm!  Thanks for getting back into this thread to help me out.
> ...



Just a quick follow-up to confirm that an A-B comparison using VirtualBox VMs from both the release and patched pfSense ISOs show that your patch does correct the device timeout issue for my device/chipset.  My next step is to verify the upgrade procedures within the "release" VM work as expected before upgrading my production hardware.

R/
wbedard


----------



## PseudoCylon (Oct 8, 2013)

wbedard said:
			
		

> Just a quick follow-up to confirm that an A-B comparison using VirtualBox VMs from both the release and patched pfSense ISOs show that your patch does correct the device timeout issue for my device/chipset.


That's good to know.

For 11n support, you are more than welcome to try the driver at gitorious and report any problem. So far, I have figured out what registers to poke, but BBPs. There are 3 different versions (Linux, Ralink, and OpenBSD) of drivers, and they are slightly different each other. I do not know which one is correct. If you know anything about BBPs, please let me know.


----------



## wbedard (Oct 12, 2013)

wbedard said:
			
		

> Just a quick follow-up to confirm that an A-B comparison using VirtualBox VMs from both the release and patched pfSense ISOs show that your patch does correct the device timeout issue for my device/chipset.  My next step is to verify the upgrade procedures within the "release" VM work as expected before upgrading my production hardware.



As much as I hate to say it, I'd like to backup and re-visit the effectiveness of the patch you provided earlier in this thread.  In spite of my earlier testing, once I upgraded the kernel on my production hardware, I saw device timeouts on the Alfa devices almost immediately.  Assuming that I had simply copied over the wrong kernel, I went back to my stock and patched ISO virtual machines to confirm not only their configuration but also the results I previously, if optimistically and perhaps hastily, posted.

After conducted some more extended testing, it does appear that the patch you specified earlier doesn't eliminate the device timeout issue.  While my earlier testing did not show any timeouts, subsequent testing using the same procedures did.  Would you be willing to follow-up on this issue by providing me some troubleshooting or debugging steps that I could use to help you understand what might be different about this device/chipset from the ones you have previously worked with?

As always, I do greatly appreciate your time and effort in supporting your users!

R/
wbedard


----------



## PseudoCylon (Oct 13, 2013)

If you have compiled the kernel or the driver with USB_DEBUG option, the following will print out some debug information.`# sysctil hw.usb.run.debug=1`

You could try un-comment the following line at or around line 683 in if_run.c, though it might cause LOR. (The LOR was fixed in 9.0-RELEASE.)
	
	



```
ic->ic_updateslot = run_updateslot;
```

Also, background scan tends to cause the timeout. Make sure turn it off (default is off). And, put the USB cable away from the power line or other higher voltage cables, just in case.


----------



## wbedard (Oct 13, 2013)

wbedard said:
			
		

> As much as I hate to say it, I'd like to backup and re-visit the effectiveness of the patch you provided earlier in this thread.  In spite of my earlier testing, ...



While going back through my procedures, I think that I may have never actually applied your patch properly and my earlier success was more a case of good luck/timing.  I'm currently rebuilding my patched pfSense ISO, this time having confirmed that the patch was applied during the build process, and I hope to have additional test results tomorrow.  Thank for your patience as I continue to learn some of the "best practices" surrounding building FreeBSD.

R/
wbedard


----------



## wbedard (Oct 27, 2013)

PseudoCylon said:
			
		

> If you have compiled the kernel or the driver with USB_DEBUG option, the following will print out some debug information.`# sysctil hw.usb.run.debug=1`
> 
> You could try un-comment the following line at or around line 683 in if_run.c, though it might cause LOR. (The LOR was fixed in 9.0-RELEASE.)
> 
> ...



Sorry for the delay in following up on your suggestions...life got a bit busy for a couple of weeks. However, I am back on the case and have some feedback for you. First, I have confirmed at multiple points in the FreeBSD build process that your patch is now being applied and making it into the LiveCD ISO that I am running under VirtualBox. Unfortunately, I can also confirm this since I have been unable to successfully connect to this patched VM. However, I did enable the debugging and have posted the output at various stages to Pastebin, as follows:


 dmesg output after attaching device to VM (Dmesg_Attach_Device_w_Debugging_On)
 dmesg output after creating the interface (Dmesg_Create_Interface_w_Debugging_On)
 ifconfig verbose output for created run0 interface (Ifconfig_Verbose_run0_Interface)
 dmesg output while attempting to connect from client (Dmesg_Attempt_Connection_w_Debugging_On)
While I have attempted to collect and provide all information available, please do not hesitate to ask if there's anything else you would like to see. In item "4" above, only the last line appears when I attempt a connection (run_do_request...) and the other line are only provided as context up to the connection attempt. Additionally, please note that on line 28 in item "3" above, background scanning does appear to be off.

Thanks again for your assistance in helping me troubleshoot this issue. Again, my apologies for dropping out of the thread previously without warning.

R/
wbedard


----------



## PseudoCylon (Nov 2, 2013)

Actually,
	
	



```
run0: device timeout
```
and
	
	



```
run_do_request: Control request failed, USB_ERR_TIMEOUT (retrying)
```
 are 2 different error.

I could not see any run0: device timeout in the attached output. In other words, the deceive should have been working when you got the output, I believe. The device needs to be kept running until run0: device timeout shows up.

I think the device attached to pfSense runs in HOSTAP mode. Does one with VirtualBox also run in HOSTAP mode? There is a tricky part in HOSTAP mode.


----------



## wbedard (Nov 3, 2013)

PseudoCylon said:
			
		

> Actually,
> 
> 
> 
> ...



I'm sorry as it looks like I was away for too long, indeed!  My initial post in this thread was in regards to a "device timeout" error message.  You provided a patch to correct that error.  Indeed, once I properly integrated your patch into my pfSense/FreeBSD build process, that error no longer appears.

My latest post, in which you noted the new error,  relates to a new behavior while running a build with your patch applied.  In this patched build, I am unable to connect to the device with it configured in HOSTAP mode.  I was posting all the diagnostic output in hopes that you could further assist/advise me with the new error.

Historically, all the testing I have performed within VirtualBox has yielded the same results as when tested on "native" hardware.  I can say this since I initially noticed this latest problem when I installed the patched kernel on my primary router.  I was anticipating normal behavior aside from correcting the prior "device timeout" issue.  Once I discovered the new issue though, that was replicated in a VirtualBox environment, also.

As always, any assistance you could provide would be greatly appreciated!

R/
wbedard


----------



## PseudoCylon (Nov 4, 2013)

Just recapping,
1) The AP was working until device timeout error message appears.
2) After applied the patch, the device timeout disappears, but no station can associate with the AP.

Then, I guess I screwed creating the patch. The patch should be
	
	



```
[B]diff --git a/if_run.c b/if_run.c
--- a/if_run.c
+++ b/if_run.c[/B]
[color="Blue"]@@ -2705,6 +2705,5 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, unsigned int index)[/color]
         struct run_endpoint_queue *pq = &sc->sc_epq[index];
         struct mbuf *m;
         usb_frlength_t size;
[color="Red"]-        unsigned int len;[/color]
         int actlen;
         int sumlen;
[color="Blue"]@@ -2751,6 +2750,9 @@ tr_setup:[/color]
                 size = sizeof(data->desc);
                 usbd_copy_in(pc, 0, &data->desc, size);
                 usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len);
[color="Green"]+                size += m->m_pkthdr.len;
+                usbd_frame_zero(pc, size, ((-size) & 3) + 8);
+                size += ((-size) & 3) + 8;[/color]

                 vap = data->ni->ni_vap;
                 if (ieee80211_radiotap_active_vap(vap)) {
[color="Blue"]@@ -2771,10 +2770,7 @@ tr_setup:[/color]

[color="Red"]-                /* align end on a 4-bytes boundary */
-                len = (size + IEEE80211_CRC_LEN + m->m_pkthdr.len + 3) & ~3;
-[/color]
                 DPRINTFN(11, "sending frame len=%u xferlen=%u @ index %d\n",
                     m->m_pkthdr.len, len, index);

[color="Red"]-                usbd_xfer_set_frame_len(xfer, 0, len);[/color]
[color="Green"]+                usbd_xfer_set_frame_len(xfer, 0, size);[/color]
                 usbd_xfer_set_priv(xfer, data);

                 usbd_transfer_submit(xfer);
```
The second hunk is the same as before.

Sorry, my bad.


----------



## wbedard (Nov 5, 2013)

PseudoCylon said:
			
		

> Just recapping,
> 1) The AP was working until device timeout error message appears.
> 2) After applied the patch, the device timeout disappears, but no station can associate with the AP.
> ...
> Sorry, my bad.



You recapped it correctly and no worries about the erroneous patch.  I look it that as "good news" since it's easier to move forward toward a solution.  Much better than the prospect of having to play detective with a new device.

I'll start a new build this afternoon and let you know as soon as I some results.  Thanks again!

R/
wbedard


----------



## wbedard (Nov 6, 2013)

PseudoCylon said:
			
		

> ```
> [B]diff --git a/if_run.c b/if_run.c
> [/B][color=Blue]...[/color]
> [color=Red]-                /* align end on a 4-bytes boundary */
> ...



Currently, I'm getting a build failure using the patch above.  Looking over the code and previous patches presented in this thread, did you also intend to remove the `DPRINTFN` line, as well?  The error I'm getting is an undeclared variable for "len" (iirc), first used in that line.

R/
wbedard


----------



## PseudoCylon (Nov 6, 2013)

Please change len to size. (Leave m_pkthdr.len as is.)
	
	



```
DPRINTFN(11, "sending frame len=%u xferlen=%u @ index %d\n",
[color="Red"]-                    m->m_pkthdr.len, len, index);[/color]
[color="Green"]+                    m->m_pkthdr.len, size, index);[/color]
```


----------



## wbedard (Nov 10, 2013)

PseudoCylon said:
			
		

> Please change len to size. (Leave m_pkthdr.len as is.)
> 
> 
> 
> ...



Hmmm, even with the newest patch, I am still unable to establish a connection.

By way of background, I did a hard re-think to make sure I wasn't missing something.  In the process, I did discover something that made me concerned that I had wasted a bit of your time.  After testing that possibility, I don't believe that's the case but I'd like to keep you informed as to my testing procedures, if nothing else for posterity.  In VirtualBox, I have a couple of ways to test builds, either by booting a LiveCD directly or by installing it to a virtual drive where I get the benefit of persistent settings across boots.  For my reference VM (stock pfSense 2.1/FreeBSD 8.3), I have installed it to a virtual drive.  For my patch builds, I have been simply booting the LiveCD, running the connectivity tests and copying the kernel over, if desired.  Recently, I decided to remove the virtual drive from my reference VM and boot that also from the LiveCD.  Soon thereafter though, I realized that I could no longer connect to my USB NIC access point even under this reference VM, which has historically provided me with the standard "device timeout" behavior.  After some additional testing, it appears to be simply a side-effect of the pfSense LiveCD which I am not about to ask you to help me troubleshoot.  However, that got me concerned that my recent testing of your patched builds might have been invalid.  So, I installed builds using both versions of your patch to separate virtual disks and conducted my connectivity tests again...with the same "unable to connect" results. Additionally, I built the "reference/release" ISO for pfSense 2.1 using the same build process and conducted my connectivity tests again, installed to a virtual drive, of course...with the same "able to connect but with eventual device timeout" results. Previously, I had been using the reference ISO downloaded from the pfSense website.

At this point, I feel much more comfortable that neither my testing process nor my build procedures are "handicapping" your driver patch.  So, I reluctantly have to hand the ball back to you in the hope that you can further revise your patch for this device.  As always, I am mostly focused on "helping you help me" so there's no rush on this.  I will endeavor to assist you with any add'l testing possible on my end.  Thanks again for all your help so far!

R/
wbedard


----------



## PseudoCylon (Nov 12, 2013)

Can you run the stock driver with debug level of 1 until the problem occurs?
`# sysctl hw.usb.run.debug=1`


----------



## wbedard (Nov 13, 2013)

PseudoCylon said:
			
		

> Can you run the stock driver with debug level of 1 until the problem occurs?
> `# sysctl hw.usb.run.debug=1`



Per your request...http://pastebin.com/XnDXc1Rb

That's the soup-to-nuts output from system boot to detaching the interface.  Basically, I attached the interface, setup the access point, made the connection and started streaming from Youtube until the stream stalled.  At that time, the device still showed that it was connected and the debug output was still going.  So, I then downed the interface in order to capture the output.

Looking it over briefly, I know it probably looks like a "horror show".  Please let me know if you need anything add'l.  Thanks!

R/
wbedard


----------



## sanders (Jan 5, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Apologies if I post this in the wrong place, but since there was already a thread about testers for this chipset I thought this might be a good place. Also I'm rather new to freebsd FreeBSD so my terminology might not be 100% correct.

I got a D-Link DWA-140 Rev D1 and I think it's using RT5372. The USB ID is 3c20.

I've got 10.0-RC3 installed and this did not contain RT5372 but I noticed that it was committed here:  http://svnweb.freebsd.org/base?view=rev ... ion=257955

I copied those files to /usr/src/ owerwriting the existing ones.

Then I added this to usbdevs:

```
product DLINK DWA140D1         0x3c20  DWA-140 rev D1
```
and this to if_run.c:

```
RUN_DEV(DLINK,             DWA140D1),
```
I compiled both runfw and if_run and loaded them with 
`kldload ./runfw.ko
kldload ./if_run.ko`

This caused the following kernel messages:

```
ugen1.3: <Ralink> at usbus1
run0: <1.0> on usbus1
run0: MAC/BBP RT5392 (rev 0x0222), RF RT5372 (MIMO 2T2R), address d8:fe:e3:d7:ab:e5
```

Then running `ifconfig wlan0 create wlandev run0` worked ok. Running `ifconfig wlan0 up scan` caused the kernel to print this

```
run0: firmware RT3071 ver. 0.236 loaded
```
But no wireless networks were displayed, the command just returned without any output whatsoever and subsequent calls to `ifconfig wlan0 scan` returns immediately with no output or kernel messages. So I got stuck here.

I know I'm mixing version 10 and what I assume is the current development head and that can't be ideal. I unfortunately don't have a machine to install -CURRENT on and I tried this just in case it would work.

If anyone want me to check anything else I can, if not I'll acquire another supported USB WiFi dongle.

Thanks in advance for any help.


----------



## wblock@ (Jan 5, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Use `ifconfig wlan0 up list scan`.


----------



## sanders (Jan 7, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*



			
				wblock@ said:
			
		

> Use `ifconfig wlan0 up list scan`.



Apologies for not coming back to this earlier. Unfortunately that didn't produce any output either.


----------



## acheron (Jan 7, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

What is the output (in /var/log/messages) of this command*:* `wlandebug +scan +auth +assoc +debug`

You should also try to update the firmware to v0.33 (see http://svnweb.freebsd.org/base/head/sys ... b/dev/run/).


----------



## sanders (Feb 1, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*



			
				acheron said:
			
		

> You should also try to update the firmware to v0.33 (see http://svnweb.freebsd.org/base/head/sys ... b/dev/run/).




Thanks so much for your help, I really appreciate it. Using the new firmware worked, I am now successfully connected to my AP.


----------



## bryon (Jun 7, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

I'm having troubles setting up a Linksys WUSB54GC v3 usb stick as an access point.

#wlandebug +scan +auth +assoc +debug

```
net.wlan.0.debug: 0x0 => 0x40e00000<debug,assoc,auth,scan>
```

I'm not sure how to check the firmware version of the stick or upgrade it if it needs to be.

Here is what I have so far:

#ifconfig

```
run0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
	ether 00:23:69:e4:52:48
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
	status: running
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 00:23:69:e4:52:48
	inet 172.16.0.1 netmask 0xffffff00 broadcast 172.16.0.255 
	inet6 fe80::223:69ff:fee4:5248%wlan0 prefixlen 64 scopeid 0x5 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
	status: running
	ssid nsabsd channel 1 (2412 MHz 11g) bssid 00:23:69:e4:52:48
	country US authmode WPA privacy MIXED deftxkey 3 TKIP 2:128-bit
	TKIP 3:128-bit txpower 0 scanvalid 60 protmode CTS wme dtimperiod 1
	-dfs
```

/boot/loader.conf

```
#Wireless
if_run_load="YES"
runfw_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
```

/etc/rc.conf

```
ifconfig_re0="DHCP"
network_interfaces="re0"
sshd_enable="NO"
moused_enable="YES"
ntpd_enable="YES"
static_routes="net1"
route_net1="-net 172.16.0.0/12 172.16.0.1"

#Wireless
gateway_enable="YES"
hostapd_enable="YES"
wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 172.16.0.1 netmask 255.255.255.0 ssid nsabsd mode 11g channel 1"
```

/etc/hostapd.conf

```
interface=wlan0
debug=1
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=nsabsd
wpa=1
wpa_passphrase=passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
```

/etc/hosts

```
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain
172.16.0.1              nsabsd
```

/etc/pf.conf

```
scrub in all
set skip on lo0
antispoof quick for lo0 inet
ext_if = "re0"
int_if = "wlan0"
localnet = "$int_if:network"
tcp_services = "{ ssh, smtp, domain, www, pop3, auth, pop3s }"
udp_services = "{ domain, ntp }"

# Keeping the inside IN and the outside OUT
NoRouteIPs = "{ 127.0.0.0/8, 192.168.0.0/16, 10.0.0.0/8 }"

pass in on $int_if to any keep state
pass out on $int_if to any keep state
pass out on $ext_if from $int_if keep state

block in from no-route to any
block in  quick on $ext_if from $NoRouteIPs to any
block out quick on $ext_if from any to $NoRouteIPs

# Block all other incoming
block in log

# Allow all outgoing traffic
pass out keep state

# trying for udp / ntp
pass quick inet proto udp to any port $udp_services keep state

# Block blacklist
table <blacklist> persist file "/etc/blacklist"
block from <blacklist> to any

# Brute Force
table <bruteforce> persist
block quick from <bruteforce>
pass inet proto tcp from any to (re0) port $tcp_services \
    flags S/SA keep state \
    (max-src-conn 100, max-src-conn-rate 10/5, \
    overload <bruteforce> flush global)

# Enable ICMP for IPv4 IPv6
pass proto icmp all

# Nic Specific Rules
pass in quick on {$ext_if $int_if} proto {tcp,udp} from any to any port 49152:65535 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 123 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 137 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 138 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 111 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 1110 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 2049 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 4045 keep state
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 5353 keep state
pass in quick on {$ext_if $int_if} proto udp from any to 224.0.0.251/32 port 5353 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 445 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 137 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 139 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 111 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 1110 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 4045 keep state
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 5353 keep state
```

Everything looks like it's up and running (as far as I can tell)... my phone detects the AP, attempts to sign in but the connection is not established. This is my first time dealing with WiFi so...

Any ideas, tips, pointers, critiques?


----------



## acheron (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

How is your phone configured (static IP, DHCP)?


----------



## bryon (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

I have no idea. It's wp8 on a Nokia icon http://www.nokia.com/us-en/phones/phone/lumia-icon/specifications/
I've had no troubles connecting to any public AP's.


----------



## acheron (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Maybe you just need a dhcp server on your AP.


----------



## bryon (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Ok, not sure how to do that. I have tried many combinations of:

/etc/rc.conf

```
ifconfig_wlan0="mode 11g channel 1 ssid nsabsd bssid 00:23:69:e4:52:48 DHCP"
vs...
ifconfig_wlan0="mode 11g channel 1 ssid nsabsd DHCP"
```

with and without 
/etc/rc.conf

```
static_routes="net1"
route_net1="192.168.0.0/24 192.168.0.1" #switched to 192***** from 172******
```

...and had no luck. When using the bssid with DHCP gnome's network tools devices shows a correct IPv6 but IPv4 of 0.0.0.0, transmitted and received packets increase but nothing else, hardware address n/a, multicast enabled, MTU n/a, link speed n/a, state active. The phone finds the AP nearly instantly Ideas?


----------



## acheron (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Sorry I was not clear, probably you just need to install and configure net/isc-dhcp42-server on your access point.


----------



## bryon (Jun 8, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Ok, got that. I installed bind910 and isc-dhcp43-server and followed instructions as directed in ports messages.
Now, I can access the AP and reach the net with identical ifconfig_run0 and ifconfig_wlan0 's in /etc/rc.conf but the dhcpd (for wlan0) messes up the DHCP of re0. Without the ifconfig_run0 it all works fine... except for re0 which gets totally borked then pf gets confused, calls me an idiot and refuses to load :/

Is there a way to bind wlan0 to  run0 (or run0 to wlan0) without dhcpd messing up the DHCP for re0?


----------



## bryon (Jun 9, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Correct me if I am wrong but run0 (a driver) should *not* be showing up in the ifconfig listings correct?


----------



## kpa (Jun 9, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*



			
				bryon said:
			
		

> Correct me if I am wrong but run0 (a driver) should *not* be showing up in the ifconfig listings correct?



Yes it should show up in ifconfig(8) listing, the run0 interface gets cloned as wlan0 and all the configuration is then done on wlan0.


----------



## bryon (Jun 9, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

So why do I only get connected from wlan0 to re0 (to the net) when an ifconfig_run0 is set in /etc/rc.conf with identical info as the ifconfig_wlan0? The run0 device shows 0.0.0.0 as it's IP. The only time it had an IP (with ifconfig_run0 set) is the only time I was able to connect through the machine.


----------



## bryon (Jun 9, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*


```
# Network config
ifconfig_re0="DHCP"

#Wireless
gateway_enable="YES"
defaultrouter="192.168.1.1" #tried with and without
ipv6_activate_all_interfaces="YES"
ipv6_gateway_enable="YES"
ipv6_ipv4mapping="YES"
hostapd_enable="YES"
named_enable="YES"
named_auto_forward_only="YES"
dhcpd_enable="YES"

wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 192.168.1.1 netmask 255.255.255.0 ssid nsabsd mode 11g chan
#ifconfig_wlan0="mode 11g channel 1 ssid nsabsd bssid 00:23:69:e4:52:48"
#ifconfig_wlan0="mode 11g channel 1 ssid nsabsd DHCP"

network_interfaces="re0 wlan0"
sshd_enable="YES"
moused_enable="YES"
ntpd_enable="YES"
static_routes="lan_net wifi_net"
route_lan_net="192.168.0.0/8 192.168.0.1"
route_wifi_net="192.168.1.0/24 192.168.1.1"
routed_enable="YES"             # Set to YES to enable a routing daemon.
routed_program="/sbin/routed"   # Name of routing daemon to use if enabled.
```

netstat -r

```
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            71-81-64-1.dhcp.st UGS         0     1231    re0
71.81.64.0/20      link#1             U           0        0    re0
71-81-68-64.dhcp.s link#1             UHS         0        0    lo0
localhost          link#3             UH          0        0    lo0
192.168.1.0        link#5             U           0       18  wlan0
nsabsd             link#5             UHS         0        0    lo0
```

/etc/pf.conf

```
ext_if = "re0"
int_if = " wlan0 run0 "
lan_net = "192.168.0.0/8"
wifi_net = "192.168.1.0/24"
nat on $ext_if from $wifi_net to any -> ($ext_if) #tried with from wifi_net and int_if

pass in inet proto icmp all icmp-type $icmp_types keep state
pass in on $ext_if proto {tcp, udp} to $wifi_net keep state #tried with from wifi_net and int_if
pass out on $ext_if proto {tcp, udp} from $wifi_net keep state #tried with from wifi_net and int_if

pass in quick on {$ext_if $int_if} proto {tcp,udp} from any to any port 49152:65
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 123 keep sta
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 137 keep sta
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 138 keep sta
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 111 keep sta
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 1110 keep st
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 2049 keep st
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 4045 keep st
pass in quick on {$ext_if $int_if} proto udp from any to (re0) port 5353 keep st
pass in quick on {$ext_if $int_if} proto udp from any to 224.0.0.251/32 port 535
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 445 keep sta
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 137 keep sta
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 139 keep sta
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 111 keep sta
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 1110 keep st
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 4045 keep st
pass in quick on {$ext_if $int_if} proto tcp from any to (re0) port 5353 keep st

pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 123 keep s
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 137 keep s
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 138 keep s
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 111 keep s
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 1110 keep
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 2049 keep
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 4045 keep
pass in quick on {$ext_if $int_if} proto udp from any to (wlan0) port 5353 keep

pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 445 keep s
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 137 keep s
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 139 keep s
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 111 keep s
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 1110 keep
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 4045 keep
pass in quick on {$ext_if $int_if} proto tcp from any to (wlan0) port 5353 keep
```

I've even tried with /etc/pf.conf

```
pass in  quick all
pass out quick all
```

/etc/hostapd.conf

```
interface=wlan0
debug=1
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=nsabsd
wpa=1
wpa_passphrase=passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
```

/etc/wpa_supplicant.conf

```
network={
          ssid="nsabsd"
          scan_ssid=1
          mode=1
          key_mgmt=WPA-PSK
          wpa_pairwise=CCMP TKIP
          psk="passphrase"
}
```

/usr/local/etc/namedb/named.conf

```
include "/etc/namedb/auto_forward.conf";
```

/usr/local/etc/dhcpd.conf

```
ddns-update-style none;
always-broadcast on;
default-lease-time 7200;
max-lease-time 7200;
authoritative;
option domain-name-servers 192.168.1.1;
option domain-name "nsabsd";
option netbios-name-servers 192.168.1.1;

### WIRELESS NETWORK
###
subnet 192.168.1.0 netmask 255.255.255.0 {
        # NOTE: See: wired->range.notes
        range 192.168.1.100 192.168.1.199;
        option broadcast-address 192.168.1.255;
        option subnet-mask 255.255.255.0;
        option routers 192.168.1.1;
}
```

/etc/hosts

```
192.168.1.1             nsabsd
```

Any ideas? After 36 full hours configuring and reconfiguring everything I can think of or find suggested here, in the handbook and across the net... I am stumped. I can connect/log-in to the AP fine and gnome's Devices > Network Tools shows packets sent/received / bytes sent/received going up web pages don't load, phone can not connect through the machine.


----------



## acheron (Jun 10, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

bind is not needed in your setup, your phone can use the name servers of your ISP.
wpa_supplicant is not needed in your setup, it is only used if you want your WLAN interface to connect to an existing access point with WPA/WPA2 security.
I have a working AP at home, I will post my configuration files later today.


----------



## acheron (Jun 10, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

This is my configuration:
/etc/rc.conf

```
ifconfig_em0="inet 192.168.0.1 netmask 255.255.255.0"

wlans_run0=wlan0
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 192.168.2.1 netmask 255.255.255.0 ssid mik mode 11g channel 11"

gateway_enable="YES"
hostapd_enable="YES"
```

/etc/pf.conf

```
ext_if="em0"
int_if="wlan0"

set block-policy return
set skip on lo

# nat
nat on $ext_if from !($ext_if) -> ($ext_if:0)
pass keep state
```

/usr/local/etc/dhcpd.conf

```
option domain-name "example.org";
# opendns
option domain-name-servers 208.67.222.222, 208.67.220.220;

default-lease-time 600;
max-lease-time 7200;

log-facility local7;

subnet 192.168.2.0 netmask 255.255.255.0 {
        range 192.168.2.10 192.168.2.100;
        option routers 192.168.2.1;
}
```

/etc/hostapd.conf

```
interface=wlan0
debug=1
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid=mik
wpa=1
wpa_passphrase=passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
```


----------



## bryon (Jun 11, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

I disabled named (BIND), set everything as closely as possible to what you have and have tried several combinations of NAT in pf, and nothing has changed at all. I can connect to the AP but the phone does not connect through the machine.


----------



## acheron (Jun 11, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Have you tried to use tcpdump or wireshark on your re0 interface to see where the connection fail?


----------



## bryon (Jun 11, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

I will give it a shot later this evening (maybe 16 hours from now). Do you have any suggested method(s)?


----------



## acheron (Jun 11, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*



			
				bryon said:
			
		

> I will give it a shot later this evening (maybe 16 hours from now). Do you have any suggested method(s)?


Just run `tcpdump -i re0 -w re0.pcap` or `wireshark` on your AP, try to load a web page on your phone and stop capturing the traffic. You can send me your re0.pcap in private if you have a roblem to understand it.


----------



## bryon (Jun 12, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

`tcpdump -i re0 -w re0.pcap`

```
2014-06-11 19:14:44.075105 IP 96-35-30-17.dhcp.stls.mo.charter.com.57949 > vip01olvemo.stls.mo.charter.com.domain: 32869+ A? duckduckgo.com. (32)
2014-06-11 19:14:44.087984 IP vip01olvemo.stls.mo.charter.com.domain > 96-35-30-17.dhcp.stls.mo.charter.com.57949: 32869 2/0/0 A 50.18.192.251, A 50.18.192.250 (64)
```

So DNS requests appear to be processed on re0 but there is no follow up or fetch attempt sent by wlan0 for *A 50.18.192.251, A 50.18.192.250 *

/usr/local/etc/dhcpd.conf

```
#ddns-update-style none;
#always-broadcast on;
default-lease-time 7200;
max-lease-time 7200;
#authoritative;
option domain-name-servers 24.217.0.5, 24.178.162.3;
#option domain-name-servers 192.168.1.1;
option domain-name "nsabsd";
#option netbios-name-servers 24.217.0.5, 24.178.162.3;

### WIRELESS NETWORK
###
subnet 192.168.1.0 netmask 255.255.255.0 {
        # NOTE: See: wired->range.notes
        range 192.168.1.10 192.168.1.100;
#        option broadcast-address 192.168.1.255;
#        option subnet-mask 255.255.255.0;
        option routers 192.168.1.1;
}
```

Could I be missing something in /etc/rc.conf? Possibly a static route or should I enable named?


----------



## bryon (Jun 14, 2014)

*Re: Finished: CALL FOR TESTERS Ralink wireless run(4) usb dr*

Got it! What was messing me up was that the phone translates `option domain-name` to `DNS suffix` and, if the given domain-name matches any /etc/hosts declaration, dhcpd then becomes confused and warns that wlan0 is not available. So unless you have a dedicated dns server leave the `domain-name` option commented! Also, note that `subnet-mask`, `broadcast-address`, `domain-name-servers` and `netbios-name-servers` can all be declared in individual subnet statements; these carry over from ifconfig_wlan0 declarations and /etc/hostap.conf statements respectively.


```
ddns-update-style none;
always-broadcast on;
default-lease-time 7200;
max-lease-time 86400;
authoritative;
#option domain-name "nsabsd";
#option subnet-mask 255.255.255.0;
#option broadcast-address 192.168.1.255;
#option routers 192.168.1.1;
option domain-name-servers 24.217.0.5, 24.178.162.3;
#option domain-name-servers 192.168.1.12;
#option domain-name "nsabsd";
#option netbios-name-servers 192.168.1.1;
log-facility local7;

### WIRELESS NETWORK
###
subnet 192.168.1.0 netmask 255.255.255.0 {
        # NOTE: See: wired->range.notes
        range 192.168.1.10 192.168.1.100;
#        option broadcast-address 192.168.1.255;
#        option subnet-mask 255.255.255.0;
        option routers 192.168.1.1;
}
```

Thank you @acheron! The tcpdump tip came in handy!

For those in a similar situation to what I was in use the following commands as you are exhausting combinations of settings:

`#tcpdump -i re0 -w re0.pcap` (to capture tcp transactions on external nic to your current work directory)
`#tcpdump -tttt -r /usr/home/bryon/re0.pcap` (to read those transactions inside of a terminal)
`#rm /usr/home/bryon/re0.pcap` (to get rid of the previously saved tcp dump before trying again)


----------



## StainlessRat (Apr 13, 2015)

Hi ! I have a problem's with this chip in FreeBSD 10.1 
https://forums.freebsd.org/threads/kernel-panic.51192/
FreeBSD 9.1 - No problem.
Who can help me ?


----------



## StainlessRat (Oct 18, 2015)

https://forums.freebsd.org/threads/kernel-panic.51192/


----------

