# Finally detected wireless card but can't connect to Wifi



## Gurvan (May 19, 2021)

I hope  I'm in the right forum, I thought about Networking but I feel like it's part of the install to get the computer connected so I put it here, feel free to move it if needed 

So I have an ASUS A409M on which I want to try FreeBSD (I'm a Linux user, not very familiar with FreeBSD yet, and only on servers so I never had to mess with networking/Wifi), the wireless card is supported since FreeBSD 13.0 (https://bsd-hardware.info/?id=pci:8086-31dc) so I decided to try it, but had some issues :

- first I installed two or three times to work out some kinks : the USB installer doesn't format the partition(s) you chose so I had to get into the shell to format it manually after failed installs with `newfs -U -S 4096 /dev/ada0pX`, but the issue I found really strange was that the wireless card was detected during the install (and detected some Wifi networks if I set regdomain to FCC or AIPAC2 -I'm currently in Malaysia-) but not after the install : `sysctl net.wlan.devices` returned nothing.

- so I installed after a clean formatting and leaving the wireless card unconfigured and it worked better : when booting into my new system `sysctl net.wlan.devices` returned iwm0. I have to create wlan0 at every boot with `ifconfig wlan0 create wlandev iwm0` though, but I know I can automate it somewhere like rc.conf. Then I could issue 
	
	



```
ifconfig wlan0 up
ifconfig wlan0 scan/list scan
```
 But it works only once per boot for some reason, after the output is empty.

- I have set the /etc/wpa_supplicant.conf with `wpa_passphrase "SSID" "WPA2key"" >> /etc/wpa_supplicant.conf` and I seem to be able to connect with `ifconfig wlan0 ssid "The Network"` but subsequent`ping 8.8.8.8` says no route and `dhclient wlan0` fails saying there is no link.

- another odd thing is that `ifconfig wlan0 scan` misses entirely the two closest Wifi networks available (the router is litterally sitting in a box near the ceiling 4-5 m away from me). The same laptop detects and uses those two networks under Linux, so it's not some weird hardware incompatibility, and the SSIDs are not hidden, but are fairly long as SSIDs go (~31characters).

Could you kindly point me to what I'm missing? (I have read many different pages yesterday and the proper way to get it to work looks scrambled in my brain now^^)


----------



## SirDice (May 19, 2021)

Gurvan said:


> I thought about Networking but I feel like it's part of the install to get the computer connected so I put it here, feel free to move it if needed


Networking is more appropriate. The issue isn't about the installation (installing from memory stick, CD, DVD, etc) but configuration, specifically network configuration. 



Gurvan said:


> I have to create wlan0 at every boot with `ifconfig wlan0 create wlandev iwm0` though, but I know I can automate it somewhere like rc.conf. Then I could issue




```
wlans_iwm0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"
```
As instructed in the handbook: https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-wireless



Gurvan said:


> I have set the /etc/wpa_supplicant.conf with `wpa_passphrase "SSID" "WPA2key"" >> /etc/wpa_supplicant.conf`


Please see the handbook on how to set up /etc/wpa_supplicant.conf correctly.


----------



## Gurvan (May 19, 2021)

Wow, that was a fast reply, thanks  I read the handbook section but it didn't work, there seems to be another problem :

When trying various things, from the handbook or not, I very quickly get a ton of

```
iwm0: device timeout
iwm0: dumping device error log
iwm0: errlog not found, skipping
```
popping up in the terminal continuously once it starts. From what I read on some forum pages it could be a driver problem? (I also got some kernel panic type messages yesterday but didn't think of writing them down)

It would not surprise me as when I add `if_iwm_load="YES"` to /boot/loader.conf then the interface is not even detected anymore after booting `sysctl net.wlan.devices` returns nothing.

I set up my phone as a portable hotspot with no authentication to see if the most basic section (32.3.4.1.2.1 Selecting an access point) would work, but even that fails : the ssid field remains empty, and `dhclient wlan0` fails with "no link", even after I tried to associate manually with `ifconfig wlan0 ssid XXXX`

And when I try to associate manually with a WPA-PSK network I know to work on both my computers with `wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf.NAME`
I get 
`ioctl[SIOCS802111, op-20, val=0, arg_len=7]: Invalid argument`
and then
`wlan0 : CTRL-EVENT-DISCONNECTED bssid=XXXXX reason3 locally_generated=1`
and then the timeout/error log thing above starts


----------



## SirDice (May 19, 2021)

Gurvan said:


> From what I read on some forum pages it could be a driver problem?


Drivers often support different variations of the same or similar chipset. It's possible your wireless chipset has a slightly different variant, manufactures sometimes change the designs a little bit without changing the chip's ID. Which could then lead to the driver not setting the correct registers or some other small incompatibility.


----------



## Gurvan (May 19, 2021)

ok, isn't there anything more I can try besides what's in the handbook? (I mean like tailing logs, using truss and things like that, that is what I would try under Linux to understand the error better I suppose)


----------



## George (May 19, 2021)

According to iwm(4) you also need to load a firmware for your device (or iwmfw).


----------



## Gurvan (May 19, 2021)

Thank you! I didn't even know those man pages existed.

There is progress : now `sysctl net.wlan.devices` doesn't fail, it returns iwm0 even with lines in /boot/loader.conf . The association to an open access point still fails, but I guess I'll have to start from scratch again tomorrow to see the differences


----------



## SirDice (May 19, 2021)

Gurvan said:


> I didn't even know those man pages existed.


FreeBSD has lots and lots of man pages for just about everything.


----------

