NDIS on BSD
Monday, 25. August 2008, 03:35:46
I spent the last day trying to set up an NDIS connection on my PC-BSD install. There are already a few "how-to"s on the Internet, but they are either dated or incomplete. Usually both. What I hope to accomplish here is to add a current manual for those who need an NDIS wrapper for their wireless cards under PC-BSD. Keep in mind that PC-BSD is basically FreeBSD, so read on if you're a FreeBSD user.
What is NDIS?
Some network cards do not have native drivers for BSD, Unix (Solaris/OpenSolaris), or Linux. In order to get these wireless cards to work we can use some software that allows us to use the Windows drivers on a non-Windows operating system.
How difficult is this to set up?
Actually, it's very easy but may require a little trial and error. The reason for this is that not all drivers are the same. I had to try 3 different drivers before I got one that worked on BSD. The OpenSolaris website has a list of drivers that are known to work under Solaris. These drivers appear to work well under BSD as well. I'll give you the link in the next section of this how-to.
Assumptions
I'm assuming you can use a wired connection while you're setting up your wireless. You will need to download some software so an Internet connection of some sorts is necessary.
Requirements
Most of the requirements will already be installed on your system if you're using PC-BSD. I haven't double checked on Free-BSD, but the requirements are:
Set it up
I'm assuming you downloaded a Windows driver. The driver files need to be extracted from your Windows executable. This is where cabextract comes in. Just run: cabextract -l driverName.exe from the command line. Obviously, you'll need to replace driverName.exe with the actual name of the driver that you downloaded. So, it may look something like: cabextract -l sp31463.exe. You'll only need 2 files from the driver. One will end in .inf while the other will end in .sys The name of both should be the same. For simplicity rename these files to ndis.inf and ndis.sys. You don't have to do this, but it's easier to remember the names if you do.
In the command line run the command: ndisgen. This will start a wizard for you which makes life wonderful and simple. Select option 3 which is: Convert Driver. The wizard will ask you for the name of the driver files. If you renamed them as I suggested then you'll just have to type in ndis.sys and ndis.inf. The wizard will take care of the rest for you and will output a driver file which will end with a .ko extension (like ndis_sys.ko).
You can now test your driver using the command: kldload ./driverName.ko (run as root and use the real name of the driver, of course). Some manuals suggest loading several modules such as "kldload ndis" and "kldload if_ndis", but these load automatically when any other module depending on them is loaded. Therefore, this is unnecessary. If you run the command dmesg now you should see an entry starting with ndis0. This means that your driver works. Else, you may see a slew of error messages including something like loading "dummy ndis". In this case your driver doesn't work. Try another Windows driver and start again. It took me 3 tries to get a driver that worked.
To get your driver to start on system boot do the following:
Now you just need to configure your wireless card normally. You can use a graphical tool for this (included with PC-BSD) or do it by hand. The networking tool that comes with PC-BSD is very nice... by the way. =) I'm new to PC-BSD so there may be something that I've overlooked or a helpful tip that I've missed. If so, then please do pass them on to me and I'll add them to my post.
What is NDIS?
Some network cards do not have native drivers for BSD, Unix (Solaris/OpenSolaris), or Linux. In order to get these wireless cards to work we can use some software that allows us to use the Windows drivers on a non-Windows operating system.
How difficult is this to set up?
Actually, it's very easy but may require a little trial and error. The reason for this is that not all drivers are the same. I had to try 3 different drivers before I got one that worked on BSD. The OpenSolaris website has a list of drivers that are known to work under Solaris. These drivers appear to work well under BSD as well. I'll give you the link in the next section of this how-to.
Assumptions
I'm assuming you can use a wired connection while you're setting up your wireless. You will need to download some software so an Internet connection of some sorts is necessary.
Requirements
Most of the requirements will already be installed on your system if you're using PC-BSD. I haven't double checked on Free-BSD, but the requirements are:
- NDIS... this is in the default install of PC-BSD.
- A Windows driver. As I mentioned already, not all drivers will work. You may need to try a few out. I got lucky on my 3rd try. The drivers that are recommended for OpenSolaris seem to work fine under BSD as well. Check out the bottom of this page. If you get confused on the naming scheme then keep this in mind: (14E4,4312) will work for bcm4312 cards. Just match the numbers to your card. If you're not sure what card your using run: scanpci -v and your wireless card should be in the list. (You'll have to do this as root.)
- cabextract, you can always install using pkg_add -r cabextract or use the ports collection.
- Kernel source, it's on CD 2 of the PC-BSD disks.
Set it up
I'm assuming you downloaded a Windows driver. The driver files need to be extracted from your Windows executable. This is where cabextract comes in. Just run: cabextract -l driverName.exe from the command line. Obviously, you'll need to replace driverName.exe with the actual name of the driver that you downloaded. So, it may look something like: cabextract -l sp31463.exe. You'll only need 2 files from the driver. One will end in .inf while the other will end in .sys The name of both should be the same. For simplicity rename these files to ndis.inf and ndis.sys. You don't have to do this, but it's easier to remember the names if you do.
In the command line run the command: ndisgen. This will start a wizard for you which makes life wonderful and simple. Select option 3 which is: Convert Driver. The wizard will ask you for the name of the driver files. If you renamed them as I suggested then you'll just have to type in ndis.sys and ndis.inf. The wizard will take care of the rest for you and will output a driver file which will end with a .ko extension (like ndis_sys.ko).
You can now test your driver using the command: kldload ./driverName.ko (run as root and use the real name of the driver, of course). Some manuals suggest loading several modules such as "kldload ndis" and "kldload if_ndis", but these load automatically when any other module depending on them is loaded. Therefore, this is unnecessary. If you run the command dmesg now you should see an entry starting with ndis0. This means that your driver works. Else, you may see a slew of error messages including something like loading "dummy ndis". In this case your driver doesn't work. Try another Windows driver and start again. It took me 3 tries to get a driver that worked.
To get your driver to start on system boot do the following:
- Copy your driver file to /boot/modules OR /boot/kernel (should work for both locations. In newer manuals it suggests copying to /boot/modules. My install works fine with /boot/kernel.)
- Edit the file: /boot/loader.conf and add an entry driverName_load="YES", so if your driver name was ndis.ko then your entry should be ndis_load="YES".
Now you just need to configure your wireless card normally. You can use a graphical tool for this (included with PC-BSD) or do it by hand. The networking tool that comes with PC-BSD is very nice... by the way. =) I'm new to PC-BSD so there may be something that I've overlooked or a helpful tip that I've missed. If so, then please do pass them on to me and I'll add them to my post.









