dannyman.toldme.com


FreeBSD, Technical

HOWTO: NDISulate Windows Drivers on FreeBSD

This is the second time I am going to use NDIS to allow FreeBSD to load the Windows drivers for a Dell laptop to access the built-in wireless. As this is my second time, it is good to make my own crib sheet of what I have to do, so I can do it even quicker next time, and because you, the reader, might find yourself here thanks to Google.

In both cases that I have done this I have been starting with FreeBSD 5.3. According to this crib sheet, you need to be fairly current with 5.x to do this. That crib sheet is also my main source of reference.

If you have already done this to your system and find yourself having to re-do NDIS after an upgrade, you may find my “rendis” script handy.

If you have already done this to your system, and are tracking -STABLE I have read that you no longer have to follow these steps, but merely run:
ndisgen

Step 1: Install NDIS code

cd /sys/modules/ndis && make && make install

Step 2: Figure out what hardware you have to support

This can be annoying . . . vendors ship different components in their machines, along with driver disks with all the possible variants of drivers, so you have to find the right driver. Unless you’re a big hardware weenie, you’re not sure, and pulling the right driver from the vendor can be hard.

If yours is a PCI device, you can ask pciconf to list what is on the system, and collate it with a vendor/device information database:

pciconf -lv

And here I see:

none6@pci2:4:0: class=0x028000 card=0x00031028 chip=0x432014e4 rev=0x03 hdr=0x00
    vendor   = 'Broadcom Corporation'
    device   = 'BCM4306 802.11b/g Wireless LAN Controller'
    class    = network

Step 3: Go Get the Win2K/XP Driver

You have to pull this off the CDROM or a web site yourself. Bonus points when the driver is packaged in a self-extracting archive, then you have to borrow a Windows machine to get the .sys and .inf files. Joy!

In this case, Dell re-brands the Broadcom driver as a Dell driver, so I download the “Dell _Wireless (US) WLAN Network Adapter Card” from their web site, extract the files on my Windows box, and select the bcmwl5.inf and bcmwl5.sys

Step 4: Copy those Drivers to /sys/modules/if_ndis

# ls *.inf *.sys
bcmwl5.inf      bcmwl5.sys      bcmwl5a.inf     bcmwlntp.sys
# cp bcmwl5.* /sys/modules/if_ndis
# ls /sys/modules/if_ndis
Makefile        bcmwl5.inf      bcmwl5.sys
# cd /sys/modules/if_ndis

Step 5: Magic

Take a deep breath, stretch your arms, think a happy though, and:

# ndiscvt -i bcmwl5.inf -s bcmwl5.sys -o ndis_driver_data.h
ndiscvt: line 13: e: syntax error.
ÿþ[#

Okay, don’t panic! I have seen this before. The ndiscvt works on ASCII files, but many a crafty driver has been distributing stuff in Unicode. If I look at bcmwl5.inf, I see:

# hd bcmwl5.inf | head -3
00000000  ff fe 3b 00 3b 00 0d 00  0a 00 3b 00 3b 00 20 00  |..;.;.....;.;. .|
00000010  62 00 63 00 6d 00 77 00  6c 00 35 00 2e 00 69 00  |b.c.m.w.l.5...i.|
00000020  6e 00 66 00 0d 00 0a 00  3b 00 3b 00 0d 00 0a 00  |n.f.....;.;.....|

For your edification, if a file looks like null-padded ASCII characters, then it is probably UTF-16.

# iconv -c -f utf-16 -t ascii bcmwl5.inf > bcmwl5.inf.ascii
# head -3 bcmwl5.inf.ascii
;;
;; bcmwl5.inf
;;
# ndiscvt -i bcmwl5.inf.ascii  -s bcmwl5.sys -o ndis_driver_data.h

Well, that was easy.

Step 6: Compile, Install

Basically:

make && make install

Load the module:

kldload ndis
kldload if_ndis

And, see if you have an Ethernet device:

# ifconfig ndis0
ndis0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        ether ff:ff:ff:ff:ff:ff
        media: IEEE 802.11 Wireless Ethernet autoselect
        status: no carrier
        ssid ""
        channel -1 authmode OPEN powersavemode OFF powersavesleep 100
        rtsthreshold 2312 protmode CTS
        wepmode OFF weptxkey 1

(You shouldn’t ever have that as a MAC address, unless you’re blogging sensitive data to the Internet. ;)

Loading NDIS at Boot

Once you are happy with your NDIS, add a line like this to /boot/loader.conf, which will cause the kernel to load your new module at boot time:

if_ndis_load="YES"

At this point, you’re ready to get back to your FreeBSD Handbook if you need further information.

Read More

Next:
Previous:
Categories: FreeBSD, Technical

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading