# Building driver for mt7630e WiFi card



## Atsuri (Feb 10, 2016)

Hello fellow BSD users!

I've been using FreeBSD for some months now and I think it is a great operating system (maturity + _the UNIX way_), however support for WiFi adapters may sometimes prove problematic. Therefore, I would like to return something back to the community by producing a kernel module/driver for the Mediatek mt7630e WiFi adapter.

The adapter in question is used in HP Probook 4xx, the Asus S301 ultrabook (my device) and some other Asus laptops from the ROG gaming series. Sadly, it is quite notorious for frequent disconnections and low transfer speeds. The most likely culprit is the driver (be it on Linux or Windows).

The adapter itself is a re-branded/re-worked version of the older Ralink 2800 adapter (Mediatek bought Ralink).

Currently, an enthusiastic group of Linux coders is working on the Linux driver for this device (https://github.com/neurobin/MT7630E). The original driver was built for Ubuntu 14.04 LTS (old news) and is at the moment available as an Arch Linux AUR package or directly from the GitHub repo. Still, there are many issues with it, such as overall instability or erratic CPU usage spikes.

As FreeBSD is more conservative when implementing kernel-wide changes (as far as I observed), it might be worth building this driver for FreeBSD (not to mention expanding compatible hardware!).

The route I will most likely pursue is as follows:
- learn how to build NIC drivers and kernel modules for FreeBSD
- compare the 2.x.x branch of the Linux driver from GitHub (mostly non-GPL licensed) with the FreeBSD ral() Ralink 2x00 code
- fork and expand the ral() code to include features used by the Mediatek NIC
- build and test the new driver on my Asus S301 ultrabook

I would be very grateful for any and all feedback from interested parties .

*Notice: Project is temporarily suspended due to time shortage. Will announce once it's resumed.*


----------



## SirDice (Feb 10, 2016)

If it's a reworked version of an existing adapter you may be able to modify the driver for that to also support this one. That's probably the easiest route. If you do need to write a new driver keep in mind that FreeBSD does not allow GPL code in the kernel and/or base OS. I couldn't find a license for the Linux driver but it's safe to assume it's GPL. This would mean you can't use any of that code.


----------



## Atsuri (Feb 10, 2016)

SirDice said:


> If it's a reworked version of an existing adapter you may be able to modify the driver for that to also support this one. That's probably the easiest route. If you do need to write a new driver keep in mind that FreeBSD does not allow GPL code in the kernel and/or base OS. I couldn't find a license for the Linux driver but it's safe to assume it's GPL. This would mean you can't use any of that code.



I forgot to consider the licensing restrictions, my bad! The original driver had an attached license, but its url is missing from the Mediatek website (error 404). I read through the FreeBSD and OpenBSD documentation and there was the ralink 2500 driver (ral()) in the past. Maybe I can use it as a staple for writing the new driver.

EDIT: License is GPL. Incorporated changes into first post.

EDIT2: Current information (details + progress) will appear in the first post to keep everything clean.


----------



## zodias (Mar 5, 2016)

Hi Atsuri,

You may find https://wiki.freebsd.org/WiFi useful. At least you can contact dev team and proceed with their guidance.


----------



## ondra_knezour (Mar 5, 2016)

I would also introduce your intention to the freebsd-wireless@ list. At first, somebody may be already working on it and you can merge your efforts and even if it is not the case, there is a couple of smart guys who may have tip or two regarding porting and device drivers.


----------



## Atsuri (Mar 5, 2016)

zodias said:


> Hi Atsuri,
> 
> You may find https://wiki.freebsd.org/WiFi useful. At least you can contact dev team and proceed with their guidance.



Very useful link, thank you . I will make sure to read through it properly when the time comes.



ondra_knezour said:


> I would also introduce your intention to the freebsd-wireless@ list. At first, somebody may be already working on it and you can merge your efforts and even if it is not the case, there is a couple of smart guys who may have tip or two regarding porting and device drivers.



Thank you, I will check the mailing list, though it's not very likely that someone else is already working on this Mediatek/Ralink driver, as it's rather unpopular in laptops.

Finally, I am sorry to inform, but the project will be temporarily suspended. I now switched back to GNU/Linux as part of my work duties (we're using CentOS). I will resume it once I have more time on my hands.


----------



## ondra_knezour (Mar 5, 2016)

Atsuri said:


> [...]it's not very likely that someone else is already working on this Mediatek/Ralink driver, as it's rather unpopular in laptops.


However MTK SoCs are more and more widespread in the routers realm and I have seen some discussions about them in the lists. But it is unknown to me if those SoCs' wireless parts have anything common with given chipset you are aiming at.


----------

