Solved Unable to get USB Wi-FI adapter to work on FreeBSD 11.2

Hi. Many posts on this forum have helped me get started . I am using the TP-Link WN 725N usb adapter on my FreeBSD 11.2 (a standard adapter for which a driver is available).

The adapter is detected, but is not able to connect to my Wi-Fi network. Strangely, it also detects all my neighbouring networks, except mine ! On booting, I get a message: "Failed to start wpa_supplicant".

Executing
Code:
ifconfig | grep -B3 -i wireless
gives:

Code:
    ether 50:3e:aa:75:85:16
    hwaddr 50:3e:aa:75:85:16
    nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
    media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)

Executing
Code:
sysctl net.wlan.devices
gives
Code:
net.wlan.devices: urtwn0

My /etc/rc.conf:

Code:
ifconfig_re0="inet 192.168.1.10 netmask 255.255.255.0"
#ifconfig_em0="DHCP"
wlans_urtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"
defaultrouter="192.168.1.1"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
dbus_enable="YES"
mysql_enable="yes"

My /boot/loader.conf

Code:
if_urtwn_load="YES"
legal.realtek.license_ack=1
if_wi_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"

My wpa_supplicant.conf contains just 1 entry of the ssid and password.

My question is: Are there any additional /different settings needed in case of FreeBSD 11.2 to make the wi-fi USB adapter work ?
 
If it detects all networks but yours, is your network, by an chance, hidden? If so, wpa_supplicant.conf usually needs a line scan_ssid=1 to work with a hidden network.
 
Hi SirDice and Scottro. Contents of my wpa_supplicant.conf
Code:
network={
ssid="mySSID"
psk="myPassword"
scan_ssid=1
}

I cross-checked it with my mobile phone, that connects to the Wi-Fi properly. The values are exactly the same.

Scottro, I added the line scan_ssid=1, as you suggested. Now, when I run the command,
Code:
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

The output is:
Code:
Successfully initialized wpa_supplicant
Line 3: Invalid passphrase length 5 (expected: 8..63)

Is there any way to make it accept a 5-character psk ?
 
Update: Since the Wi-Fi router is WEP, I also tried something like this in my wpa_supplicant.conf:

Code:
key_mgmt=NONE
wep_key0="5_character_Password"
wep_tx_keyidx=0

Now when I execute
Code:
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

It just shows:
Code:
Successfully initialized wpa_supplicant
But it still doesn't connect to the Wi-Fi.
 
I'm slightly confused, are you using WEP security on your network?

http://srobb.net/fbsdquickwireless.html gives a quickstart to various types of wireless connection. If you are using WEP, you would be better off using wpa2.
Remember the scan_ssid=1 is ONLY if you are using a hidden wireless network.

OK now I changed the connection of my router to WEP, and accordingly modified the files on my FreeBSD system. Finally, the error, "Failed to start wpa_supplicant" has gone away now.

As suggested by k.jacker in another thread, I added these lines on my /boot/loader.conf:
Code:
urtwn-rtl8192cfwT_load="YES"
urtwn-rtl8192cfwU_load="YES"
urtwn-rtl8188eufw_load="YES"

/etc/rc.conf now has:
Code:
ifconfig_wlan0="WPA DHCP"
instead of:
Code:
ifconfig_wlan0="WPA SYNCDHCP"

Finally, /etc/wpa_supplicant.conf has the 3 simple entries of ssid, psk and scan_ssid=1.

But when I do this:
Code:
ifconfig wlan0 create wlandevice urtwn0
I get:
Code:
ifconfig: create: bad value

In which file could this "bad" value be ?
 
Does urtwn0 show up if you do sysctl net.wlan.devices
Yes. It shows:
net.wlan.devices: urtwn0

Edit: The following is the output of ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 50:3e:aa:75:85:16
hwaddr 50:3e:aa:75:85:16
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
status: no carrier
ssid "" channel 10 (2457 MHz 11g)
regdomain FCC country US authmode WPA1+WPA2/802.11i privacy MIXED
deftxkey UNDEF txpower 30 bmiss 7 scanvalid 60 protmode CTS wme
roaming MANUAL bintval 0
groups: wlan


If it helps, I also have a wired ethernet on the same system connected to the same router. This works fine. As soon as I remove the wire and ping Google, the w-fi adapter fails to connect.
 
From my experience the wireless devices using Realtek chips rtwn(4)/urtwn(4) are slow to connect/reconnect (compared to Atheros and Ralink in my case) so sometimes some patience is neccessary.

Though the reason you can't ping after switching from wireless and wired network is that the route needs to be changed.
I'm not a pro in networking and there might be a better way, but to change the route after you pull the cable:
route flush and route add default 192.168.1.1 should do it.
What that actually does can be checked with netstat -r

Before you do so, you have to get your ssid right, it's empty.
ssid "" channel 10 (2457 MHz 11g)
If you change the line in /etc/rc.conf from
Code:
ifconfig_wlan0="WPA DHCP"
to
Code:
ifconfig_wlan0="WPA SYNCDHCP ssid Yourssid"
it should work.

So in short, when you fixed the ssid, the status should show like
Code:
status: associated
Then change the route and you should be able to ping.
Next useful step could be to set up link aggregation for wired and wireless if you plan on using both.
 
Before you do so, you have to get your ssid right, it's empty.

If you change the line in /etc/rc.conf from
Code:
ifconfig_wlan0="WPA DHCP"
to
Code:
ifconfig_wlan0="WPA SYNCDHCP ssid Yourssid"
it should work.

So in short, when you fixed the ssid, the status should show like
Code:
status: associated
k.jacker, I did that. Now the ssid shows properly under ifconfig wlan0. I also unplugged the wired ethernet cable and
flushed the route and reset the default. But I still get status: no carrier, even though the ssid shows properly.

The /etc/rc.conf now looks like this, after some tinkering around:

hostname="freebsd.rooty"
ifconfig_re0="inet 192.168.1.10 netmask 255.255.255.0"
#ifconfig_em0="DHCP"
dhcpd=YES
dhclient=YES
dhclient_flags="-nw"
wpa_supplicant=YES
wlans_urtwn0="wlan0"
#ifconfig_wlan0="ssid MTNLA303 DHCP"
ifconfig_wlan0="WPA SYNCDHCP ssid MTNLA303"
defaultrouter="192.168.1.1"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
dbus_enable="YES"
mysql_enable="yes"


I also tried bsdconfig netdev, there it shows the entry of wlan0 as <unknown network interface type> as shown in the screenshot below:
2018-09-16-234310_1368x768_scrot.png


But sysctl net.wlan.devices shows net.wlan.devices: urtwn0, which is OK. So, why the conflict ?
 
But when I do this:
Code:
ifconfig wlan0 create wlandevice urtwn0
I get:
Code:
ifconfig: create: bad value
ifconfig wlan0 create wlandev urtwn0

wlandevice is not a valid alias for wlandev.
 
In one of your posts, I see that you do have the wlan0 device, so that step is complete. It shows no carrier, but does have an SSID.

Try this:
Destroy the wlan0 interface:
Code:
ifconfig destroy wlan0
Make sure wpa_supplicant is not running:
Code:
killall wpa_supplicant
unload all the drivers:
Code:
kldunload if_urtwn.ko
kldunload urtwn-rtl8192cfwT.ko
...and also unload any other firmwares you have loaded...
Now unplug the device.

Plug the device back in.

Now, identify the device:
Code:
usbconfig
The first field of the return from that command will be of the form ugenX.Y. Identify the specific line that matches your device.
Now force a device reset:
Code:
usbconfig -d ugenX.Y reset
Now reload your drivers:
Code:
kldload if_urtwn.ko
kldload urtwn-rtl8192cfwT.ko
...also load any other firmwares you need...there are three total I think...
Verify that urtwn0 is present:
Code:
ifconfig
Now, proceed manually, because you want to run wpa_supplicant manually.
Establish the interface:
Code:
ifconfig wlan0 create wlandev urtwn0 up
Verify the existence of wlan0:
Code:
ifconfig
Now run wpa_supplicant:
Code:
wpa_supplicant -B -i wlan0 -c /path/to/wpa_supplicant.conf
And see if it is up:
Code:
ifconfig

Any error messages along the way give you something to look at.

I have a lot of experience with these realtek dongles. Much more experience than I would prefer to have, actually. I find that they work OK, but they get twitchy if the box they are connected to has an inadequately filtered USB interface. This proves to be most problematical when booting with the device plugged in; they sometimes lock up in an illegal state and the only recourse is to power cycle the USB bus OR remove/replace the dongle.

The procedure I outline here is what I would call the "baseline" procedure to diagnose the type of problem you are having; you also should look closer at usbconfig because I have often found that entering:
Code:
usbconfig -d ugenX.Y set-config 255
followed by:
Code:
usbconfig -d ugenX.Y set-config 0
will work.

What I have outlined here should certainly point to your particular problem. In fact, if the dongle is not defective (which it most certainly could be...I've seen that many times too...) this SHOULD bring the device up.
 
As a further note about these dongles, I have been most successful with the 8188CU, the 8188CUS, and the 8192CU. I would suggest you stick with a device that contains one of those chips.
 
jiml8, I followed your instructions step-by-step. Just before doing that, I noticed that the light of the USB was stable (and not flashing) and I was indeed getting status: associated upon executing ifconfig wlan0.

I unloaded the drivers, and re-plugged the device. I also successfully reset it and determined the ugenX.Y id using usbconfig -d ugenX.Y reset. Urtn0 is always present when I execute sysctl net.wlan.devices (command has changed in FreeBSD 11 onwards).

But executing ifconfig wlan0 create wlandev urtwn0 up always gives ifconfig: create: bad value.

Anyway, ignoring this I still proceeded to execute the remaining steps. The Urtn0 is recognized, ifconfig shows the wlan0 entry, with status: associated.

But again usbconfig -d ugenX.Y set-config 255 and usbconfig -d ugenX.Y set-config 0 gave an error like (from memory, as I'm in office) set-config: invalid interface or something like that.

Yesterday, once again I tried to follow the instructions from the beginning but the USB device's light kept flashing i.e. it never became stable unlike day before yesterday. Could there be an issue in the device itself ? A few people on FreeBSD forums earlier have reported using the manufacturer, TP-LINK and it works fine for them.
 
I wonder what kind of hardware you're using for the FreeBSD installation? Are you plugged into a hub? Are you using an extension cable?
 
This is all going nowhere...
I would advice you to clean up your configuration, removing all unnecessary stuff.
And please stop playing with usbconfig, it's not neccessary. Pull/replug OR reset the port, doing both is meaningless.

Info: when the lights on the dongle keep flashing, there is from my experience the problem that the firmware won't load,
that's often the case after a suspend/resume event. For me, there was sometimes no other solution that to reboot.
Simply switch to ttyv0 to look for those errors.

The setup is simple, no magic involved. Here is what I use. All other wireless related settings should be removed.
/boot/loader.conf
Code:
# Asus USB-N13
if_urtwn_load="YES"
legal.realtek.lisence_ack=1
urtwn-rtl8188eufw_load="YES"
urtwn-rtl8192cfwU_load="YES"
urtwn-rtl8192cfwT_load="YES"
/etc/rc.conf
Code:
# Asus USB-N13
wlans_urtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP country NO ssid OWRT24"
/etc/wpa_supplicant
Code:
network={
    ssid="OWRT24"
    psk="mypswd"
}

That's all you need.

Please doublecheck your Realtek chip is supported. The 81xxEE devices are not supported for now.
Only the v2 version of your TP-Link device is supported, according to the urtwn(4) manpage,
maybe yours got a different chip.
Just dmesg | grep urtwn and see that it's really got one of the...
Code:
DESCRIPTION
     The urtwn driver supports USB 2.0 wireless network devices based on Realtek RTL8188CUS,
     RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU chipsets.
 
Could there be an issue in the device itself ? A few people on FreeBSD forums earlier have reported using the manufacturer, TP-LINK and it works fine for them.

Yes there could be. These cheap dongles coming from China are sourced...who knows where.

I personally have worked with literally thousands of them (well...me and a couple of technicians...) and we have found all sorts of things involving them, including more than a few counterfeit devices. We eagerly await the day when our company is large enough and powerful enough to force supply contracts on these suppliers, and enforce quality requirements. But, that is for another day...
 
And please stop playing with usbconfig, it's not neccessary. Pull/replug OR reset the port, doing both is meaningless.

Actually, sometimes it is necessary, though it should not be. In any event, in the current situation it helps considerably with debugging.
 
You're trying to use WEP, but your wpa_supplicant.conf has no WEP keys. Most of the respondents (including myself) may have assumed you're using the much safer WPA2 setup. Per the handbook, WEP keys should be like:

network={
ssid="my_net"
key_mgmt=NONE
wep_key3=3BF6789012
wep_tx_keyidx=3
}

More likely your router is using key idx 1 instead of key idx 3 (just check or try them). If you use ASCII, you need to quote it, but you don't need to put quotes around a hex key. You can convert the hex key from ASCII (if that's what's given on the router) by using hexdump. You can also use ifconfig to connect. From handbook:

ifconfig [I]wlan0[/I] create wlandev [I]ath0[/I]
ifconfig wlan0 ssid [I]my_net[/I] wepmode on weptxkey [I]3[/I] wepkey [I]3:0x3BF6789012[/I]
dhclient wlan0
 
I wonder what kind of hardware you're using for the FreeBSD installation? Are you plugged into a hub? Are you using an extension cable?
I'm using a Dell laptop with 4 GB Ram and an AMD 64-bit processor.
You're trying to use WEP, but your wpa_supplicant.conf has no WEP keys. Per the handbook, WEP keys should be like:

network={
ssid="my_net"
key_mgmt=NONE
wep_key3=3456789012
wep_tx_keyidx=3
}

But - more likely your router is using key 1 instead of 3. I think the index is "one based" rather than "zero based". Most of the respondents assume you're using the much safer WPA2 setup - and we almost automatically expect that.
Very sorry, I forgot to mention that I switched back to WPA -- on my router, as well as on wpa_supplicant and /boot/loader.conf (I didn't understand these terms a few days ago). On post#9, my output shows WPA, and on post#11 my /etc/rc.conf shows ifconfig_wlan0="WPA SYNCDHCP. It's been the same ever since. In fact I've now commented the dhclient and dhcpd entries also to no avail.

Currently, my wpa_supplicant.conf has only the 2 entries of ssid and psk.
This is all going nowhere...
I would advice you to clean up your configuration, removing all unnecessary stuff.
Info: when the lights on the dongle keep flashing, there is from my experience the problem that the firmware won't load,
that's often the case after a suspend/resume event. For me, there was sometimes no other solution that to reboot.
Simply switch to ttyv0 to look for those errors.

The setup is simple, no magic involved. Here is what I use. All other wireless related settings should be removed.
/boot/loader.conf
Code:
# Asus USB-N13
if_urtwn_load="YES"
legal.realtek.lisence_ack=1
urtwn-rtl8188eufw_load="YES"
urtwn-rtl8192cfwU_load="YES"
urtwn-rtl8192cfwT_load="YES"
/etc/rc.conf
Code:
# Asus USB-N13
wlans_urtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP country NO ssid OWRT24"
/etc/wpa_supplicant
Code:
network={
    ssid="OWRT24"
    psk="mypswd"
}

That's all you need.

Please doublecheck your Realtek chip is supported. The 81xxEE devices are not supported for now.
Only the v2 version of your TP-Link device is supported, according to the urtwn(4) manpage,
maybe yours got a different chip.
Just dmesg | grep urtwn and see that it's really got one of the...
Code:
DESCRIPTION
     The urtwn driver supports USB 2.0 wireless network devices based on Realtek RTL8188CUS,
     RTL8188CE-VAU, RTL8188EUS, RTL8188RU and RTL8192CU chipsets.
I'll check with these values in my rc.conf, wpa_supplicant and loader.conf. If it works great, otherwise I'll try to test errors with ttyv0.

My chip is RTL8188EU, which is supported in the urtwn(4) manpage. The USB model is TP-Link TL-WN725N. But I checked the box, where it says Ver 3.0, whereas the FreeBSD documentation says it supports Ver 2. Maybe this could be causing the issue.

The ver 2 of this exact same USB is working for other FreeBSD users.

Yes there could be. These cheap dongles coming from China are sourced...who knows where.

I personally have worked with literally thousands of them (well...me and a couple of technicians...) and we have found all sorts of things involving them, including more than a few counterfeit devices. We eagerly await the day when our company is large enough and powerful enough to force supply contracts on these suppliers, and enforce quality requirements. But, that is for another day...
Mine is version 3.0, instead of version 2 that is supported by FreeBSD. I think that may indeed be causing the issue, even though the chip inside i.e. RTL8188EU is said to be supported by FreeBSD.

I'll once again try to make the changes suggested by k.Jacker in all the 3 files, and see. If it works then OK, otherwise I'll have to check using ttyv0 or maybe wait till FreeBSD releases a driver for ver 3.0 of TP-Link WN725N ver 3.0.
 
OK finally the light is stable again, and the status is associated. I followed post#18 by k.jacker.

I think one or more of the entries of dhcp, dhclient, if_wi_load, wlan_wep_load, wlan_ccmp_load, wlan_tkip_load, if_rtwn_pci_load, if_rtwn_usb_load, etc. must've led to the status reading no carrier and the flashing light of the USB. Theoretically they shouldn't have, but.....

Now I'll just have to figure out why ifconfig wlan0 create wlandev urtwn0 outputs ifconfig: create: bad value. Needless to say, pinging google returns Host name lookup failure and running bsdconfig netdev still shows the screenshot in post#11.

Thanks for all your help.
 
Finally, got it to work just now. Posting this using my USB Wi-Fi adapter.

What I did:
  1. Changed my router's settings to Bridge mode from PPpoE mode.
  2. Modified my rc.conf as per post#18.
For any lost soul, using a TP-Link TL-WN725N USB Wi-Fi adapter ver 3 (based on RTL8188EU chip), this should be the /etc/rc.conf:
hostname="freebsd.rooty"
#ifconfig_re0="inet 192.168.1.10 netmask 255.255.255.0"
#ifconfig_em0="SYNCDHCP"
#dhcpd=YES
#dhclient=YES
#dhclient_flags="-nw"
wpa_supplicant=YES
wlans_urtwn0="wlan0"
#ifconfig_wlan0="ssid MTNLA303 DHCP"
ifconfig_wlan0="WPA SYNCDHCP country NO ssid MTNLA303"
defaultrouter="192.168.1.1"
sshd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
dbus_enable="YES"
mysql_enable="yes"


The last 3 entries are optional (last one only if you've installed MySQL). I don't know what sshd_enable does. It was there earlier, so I kept it.

My /boot/loader.conf looks like this:

if_urtwn_load="YES"
legal.realtek.license_ack=1
#if_wi_load="YES"
#wlan_wep_load="YES"
#wlan_ccmp_load="YES"
wlan_tkip_load="YES"
urtwn-rtl8192cfwT_load="YES"
urtwn-rtl8192cfwU_load="YES"
urtwn-rtl8188eufw_load="YES"
#if_rtwn_pci_load="YES"
#if_rtwn_usb_load="YES"


My router uses WPA+PSK encryption (or simply WPA encryption), that's why the entries related to WEP and if_wi_load are disabled. Earlier, the last 2 entries were also enabled, but I disabled them according to advise given on post#18 (it's a Bible).
wlan_tkip_load="YES" is enabled because I found out that my router uses TKIP.

I spent nearly a week with all permutations and combinations of the entries in these 2 files above, till this combination worked. Partly because earlier I was misinformed about WPA and WEP on my router and on my system.

My /etc/wpa_supplicant.conf has the 2 simple entries of ssid, psk. The entry scan_ssid=1 should be there only if the router is not in Visible mode.

Finally, I also had to change my router's settings to Bridge mode from PPpoE. I read about it in some other place and finally my USB Wi-Fi got working.

I hope in the future FreeBSD "automagically" detects every router set-up and makes it's own settings accordingly, and loads the relevant drivers. This is a leaf that can be taken out of commercial OS's like Windows and Macintoshes.
 
Back
Top