# How to develop a wireless driver?



## fernandobsd (Sep 4, 2015)

Hello, I have a wireless card that does not work in FreeBSD but in Gnu/Linux with a proprietary firmware (my wireless card is _Realtek RTL8188CE_), the firmware is *rtl8192cfw.bin*.
My question is: How can I develop a free wireless driver and build it with a custom kernel in FreeBSD?
(I do not want to buy a USB Dongle or anything related).

http://www.realtek.com.tw/downloads...n=4&DownTypeID=3&GetDown=false&Downloads=true

Thanks for your help.


----------



## Juanitou (Sep 4, 2015)

I’d suggest to post the question to the freebsd-wireless mail list too, where it can get more attention from FreeBSD developers.


----------



## hanzer (Sep 4, 2015)

I've also been thinking about tinkering with driver development (see - Thread 10-2-atheros-wireless-ar9227-pci-problem.53070). To get your system up and running, the NDIS wrapper for a WindowsXP driver might work (see -* 11.5.1.1. Using Windows® NDIS Drivers*). I haven't had any success with it but others have.

Some device driver development reference material I've collected so far:

Chapter 9. Writing FreeBSD Device Drivers
FreeBSD Device Drivers
Embedded FreeBSD Cookbook


----------



## fernandobsd (Sep 4, 2015)

Juanitou said:


> I’d suggest to post the question to the freebsd-wireless mail list too, where it can get more attention from FreeBSD developers.


I will do that, thanks.


----------



## scottro (Aug 8, 2016)

Old though this thread is (wow, almost a year) it was one of the first hits I got when searching for FreeBSD 8188ce. 

So, it may be worth mentioning that the card is now working in FreeBSD-11-BETA4 (probably earlier, but I didn't try) if one follows the instructions in the man page for rtwn(4).  (I didn't put it in tags, because that leads to a page saying no man page, and indeed, on my 10.3 box, there isn't.  

Anyway, if running FreeBSD-11.x, the man page instructs you to put the following into /boot/loader.conf.  


```
if_rtwn_load="YES"
legal.realtek.license_ack="1"
rtwn-rtl8192cfwU_load="YES"
rtwn-rtl8192cfwU_B_load="YES"
```

Upon doing this, running `pciconf -vl` shows a driver attached to the card.  Note that in 11.x, running ifconfig won't show wireless cards, you have to run `net.wlan.devices`.

Again, I realize this thread is old, but as I said, it was one of the first that came up when googled the card.  Up till now, I've been using an Edimax USB adapter for my L420 laptop, but FreeBSD-11 gets it working.  Thanks to A. Chadd and whoever else worked on it.


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203105


----------



## Atsuri (Aug 16, 2016)

scottro said:


> Old though this thread is (wow, almost a year) it was one of the first hits I got when searching for FreeBSD 8188ce.
> 
> So, it may be worth mentioning that the card is now working in FreeBSD-11-BETA4 (probably earlier, but I didn't try) if one follows the instructions in the man page for rtwn(4).  (I didn't put it in tags, because that leads to a page saying no man page, and indeed, on my 10.3 box, there isn't.
> 
> ...


I'm not sure about the Realtek 8192ce adapter, but neither 8188eu, nor 8192cu require signing the license in /boot/loader.conf anymore (as of 11.x). Also, `ifconfig` will list wireless adapters (wlan0, wlan1, etc.) in 11.0-RC1. Maybe this option will get deprecated in favor of `net.wlan.devices`, though for now it works.

Sorry for assisting in thread-archeology, though I thought the part about Realtek adapters might be useful, in case someone is considering buying a dongle with one of these. After all, the OP seems to be concerned with compatibility with his wireless adapter, rather than venturing into the realm of driver coding .


----------



## scottro (Aug 16, 2016)

IMLTHO (Less Than Humble) sometimes, it's quite worthwhile resurrecting old threads when they're still relevant, as when, for example, one does a google search and it's one of the first hits.   
And yeah, code it yourself is not an answer for an end user, but as there's lots of developer types on these forums, they don't realize how hard it is for the rest of us. 

As for your other comments.  I removed the license line, and then, when I ran ifconfig to create the wlan device, got an error message, could not load firmware image. I am also still finding that ifconfig (unless I have something in /etc/rc.conf that already defines the wlandev as using the rtwn0 card, in which case, ifconfig will show me wlan0) will not show me rtwn0.  I only see it after running the ifconfig command to create a wlandev.  This is an old Thinkpad L420, and pciconf tells me that it's an 8188CE.  So, maybe it's an 8188CE thing?   This is also 11.0-RC1


----------



## Atsuri (Aug 16, 2016)

My apologies then, sorry! It might indeed be as you say, a special case for 8188ce with the Realtek firmware. 

In respect to `ifconfig`, I wrongly assumed everyone uses the wlan0 link in /etc/rc.conf so that the interface gets created automatically when the netif service is launched. Probably not the best thing to do when multiple wireless devices and interfaces are on-board . Also, running `sysctl -a | grep net.wlan.devices` prints my wireless devices as intended:

```
net.wlan.devices: iwn0
```

Seeing as how much needs to be done in the WiFi department, I would like to get involved with writing wireless device drivers at some point, though way after I figure out how to port & maintain FreeBSD software first .


----------

