# Wifi Support for QCA9377 or EW-7811Un V2?



## Osmium (Jun 9, 2021)

Dear community,

I have become interested in installing the operating system FreeBSD on my laptop (Acer Aspire 3).
As with all operating systems, the pain in the a** problem is again the Wifi - without which nothing else will work, since
I need internet in order to install things. 

Now, I have found out that the Atheros QCA9377 card is not yet supported (installed into my laptop). So, I decided to
follow the instructions and suggestions given for the matter that the Wifi card is not supported, and now I have 
an Edimax EW-7811Un (V2). And again, not knowing that this "V2" is of any relevance, it is not working. 

This is really a pity, as both Edimax and Atheros are listed as supported Wifi devices. 
Therefore, I would like to ask whether there is a workaround (I read that OpenBSD now
supports the Edimax V2 card), since getting yet another USB dongle becomes a little silly.

If not, then I would like to ask if any support for at least one of the abovementioned cards is planned in
the next version of FreeBSD? I can imagine that I am not the only one with this problem, since the
QCA9377 now seems quite common, and the "V2" is really hidden...

Thanks for any suggestions and information on this matter 
Cheers


----------



## SirDice (Jun 9, 2021)

Osmium said:


> This is really a pity, as both Edimax and Atheros are listed as supported Wifi devices.


_Some_ Edimax and _some_ Atheros chipsets are supported. Not _all_ Edimax or _all_ Atheros devices.



Osmium said:


> If not, then I would like to ask if any support for at least one of the above mentioned cards is planned in
> the next version of FreeBSD?


What version did you try?


----------



## Osmium (Jun 9, 2021)

Well, as I wrote above:
Qualcomm Atheros QCA9377
Edimax EW-7811Un V2

...and the current version of FreeBSD (13.0)


----------



## T-Daemon (Jun 10, 2021)

Osmium said:


> Edimax EW-7811Un V2



It's likely that specific Edimax model is supported on FreeBSD. The problem seems to be a missing device ID. I found this Linux patch for the Edimax EW-7811UN V2.

RTL8188EU chip support is provided by rtwn(4) on FreeBSD.

To make sure the device ID (0xb811) from the Linux patch is the same with your device please execute `usbconfig | grep WLAN` , look for the `ugenX.Y` unit.address value.

Example output for a Ralink:

```
ugen0.4: <Ralink 802.11 n WLAN> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (450mA)
```

Execute `usbconfig 0.4 dump_all_desc | grep id` (replace`0.4` with the Edimax unit.address value), post output.


----------



## Osmium (Jun 14, 2021)

T-Daemon said:


> It's likely that specific Edimax model is supported on FreeBSD. The problem seems to be a missing device ID. I found this Linux patch for the Edimax EW-7811UN V2.
> 
> RTL8188EU chip support is provided by rtwn(4) on FreeBSD.
> 
> ...



Thank you for the reply!

Interestingly, doing an usbconfig command, I get, among other things,
ugen0.3: <Realtek Edimax N150 Adapter> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)

...but when doing it with | grep WLAN (or grep wlan), then nothing remains.

Doing as you said, the output is:
idVendor = 0x7392
idProduct = 0xb811

Best regards


----------



## T-Daemon (Jun 15, 2021)

Osmium said:


> ugen0.3: <Realtek Edimax N150 Adapter> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)


I expected 'WLAN' here but it looks like that's not always the case I see.



Osmium said:


> idVendor = 0x7392
> idProduct = 0xb811


After the product ID is confirmed you need to build and install a custom kernel to add support for the Edimax. Download and apply attached diff(1) file down below with patch(1) to the source code in /usr/src.

If you are unsure how to build a custom kernel and need a step by step guide please ask. In case you are worried about the procedure to be complicated, building a custom kernel is very easy.


----------



## Osmium (Jun 15, 2021)

T-Daemon said:


> I expected 'WLAN' here but it looks like that's not always the case I see.
> 
> 
> After the product ID is confirmed you need to build and install a custom kernel to add support for the Edimax. Download and apply attached diff(1) file down below with patch(1) to the source code in /usr/src.
> ...


Thank you for the reply.
I do have some questions:
- So, it is necessary to at least have a LAN connection to the internet from my Laptop with FreeBSD, is that correct?
There is no way of doing it any differently (say, by copying the file to a USB stick and from there, copy it to the operating system)?
- Yes, I am unsure of how to build a custom kernel. I have done that before with Gentoo, but it was a pain in the a**, and I needed to recompile
many times, since always, something was missing. It would be great, however, if there was a possibility to compile a kernel, say, just exactly
like the default kernel, but with this driver added. Is that possible?
--> And so, is it then necessary to build this kernel anew each time I want to upgrade the operating system?

Many thanks
Best regards


----------



## T-Daemon (Jun 15, 2021)

Corrected typo.


----------



## Osmium (Jun 18, 2021)

T-Daemon said:


> Corrected typo.


Thanks for the link. I had some questions above - about building a custom kernel, and whether I can insert the file from USB or need internet. 
Thanks in advance
Best regards


----------



## T-Daemon (Jun 19, 2021)

Osmium said:


> I had some questions above


When I posted last, your post #7 wasn't there. It must have appeared after Forums administrator approval. The Forums software doesn't notice about those between posts unless the user has the thread on the watch list. I hadn't this thread on the watch list, sorry, I had no knowledge you posted.



Osmium said:


> - So, it is necessary to at least have a LAN connection to the internet from my Laptop with FreeBSD, is that correct?
> There is no way of doing it any differently (say, by copying the file to a USB stick and from there, copy it to the operating system)?


Sure, you can copy it on USB stick, it's not a necessity to have a internet connection from FreeBSD. The patch file (eventually also the system source code package) can be downloaded from a different operating system, put on the USB stick and carried over to FreeBSD. It would be best if the USB stick is formatted with a MS-DOS file system. It would make the device graft to the FreeBSD system easy by using the mount_msdosfs(8) utility from system base.



Osmium said:


> - Yes, I am unsure of how to build a custom kernel. I have done that before with Gentoo, but it was a pain in the a**, and I needed to recompile
> many times, since always, something was missing. It would be great, however, if there was a possibility to compile a kernel, say, just exactly
> like the default kernel,


Building a kernel on FreeBSD, just exactly like the default kernel, is very easy, not comparable with Gentoo, just follow the steps below.



Osmium said:


> ... but with this driver added.


A driver doesn't need to be added to the kernel, it's already there but it doesn't recognize the Edimax model. The patch adds the devices unique identification number to the drivers USB module so the driver can recognize and attach to it.

Steps to build the kernel:

1 - Download patch file.

2 - In case you need to build the kernel again, to reduce the build time for future builds, create file /etc/src-env.conf and set the environment variable:

```
WITH_META_MODE=yes
```

Execute

```
# sysrc kld_list+=filemon    # This will set kernel module 'filemon' (needed for Meta_Mode)
                             # in  /etc/rc.conf to persist reboots
# kldload filemon            # load module imediate
```

3 - If not installed already, install source code from the FreeBSD installer image (/usr/freebsd-dist/src.txz) or if absent, download from link. I assume your system is 13.0-RELEASE, amd64 architecture (AMD, Intel 64 bit):

http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/13.0-RELEASE/src.txz (~150MB)

4 - From USB stick extract source package (omit this step if /usr/src is populated) :

```
# tar xf src.txz -C /
```

5 - Patch the source code:

```
# patch -p0 < patch-edimax-ew-7811unv2.txt
```
Make sure there are no error messages. Don't continue when there are, report back.

6 - Build, install kernel:

```
# cd /usr/src
# make buildkernel
# make installkernel
```

7 - Agree Realtek license:

/boot/loader.conf

```
legal.realtek.license_ack=1
```

8 - Reboot system:

```
# shutdown -r now
```

9 - Check if the device is detected, execute

```
# sysctl net.wlan.devices
```
The output should show

```
net.wlan.devices: rtwn0
```
Also, please post

```
dmesg | grep rtwn0
```
for eventual problem report (see below).

10 - Continue with handbook 32.3. Wireless Networking.



Osmium said:


> --> And so, is it then necessary to build this kernel anew each time I want to upgrade the operating system?


At the moment yes. If all goes well, meaning your device is recognized and functional, I will open a problem report at FreeBSD bugzilla, submit the patch and  ask to be committed. When the patch is approved it goes first into main (CURRENT), then after a few weeks merged into stable/13. From there into releng/13.x (13.x-RELEASE). A future update of your system will make a custom build kernel obsolete.


----------



## Osmium (Jun 28, 2021)

Thanks very much for your answer! I will try it and give feedback whether it works or not.


----------



## swag (Apr 3, 2022)

T-Daemon said:


> Corrected typo.


I just got the Edimax N150 (EW-7811Un V2) working on FreeBSD 13.0 thanks to this thread.  There was however a missing ')' in your patch.  The line you add to /usr/src/sys/dev/rtwn/usb/rtwn_usb_attach.h:

RTWN_RTL8188EU_DEV(EDIMAX,        EW7811UN_2,

should be

RTWN_RTL8188EU_DEV(EDIMAX,        EW7811UN_2*)*,

Without the ')' before the comma, the kernel fails to build.


----------



## T-Daemon (Apr 4, 2022)

swag said:


> RTWN_RTL8188EU_DEV(EDIMAX, EW7811UN_2,
> 
> should be
> 
> RTWN_RTL8188EU_DEV(EDIMAX, EW7811UN_2*)*,


Thanks. Patch corrected.

Support for EDIMAX N150 Wi-Fi 4 Nano USB Adapter EW-7811Un V2 is included since 2022-01-07 in -CURRENT and MFC to 13.0-STABLE and ultimately in  13.1-* .


----------

