== Driver for RTL818x based WLAN adapters

=== Installing the r818x Linux kernel driver

Released under the terms of GNU General Public License (GPL) Copyright(c)
2004, Andrea Merello, Install instructions by Rick Bronson; updated by Dr
Balwinder Singh Dheeman

NOTE: These instructions were written for a Knoppix 3.6 (using Linux 2.6.7
kernel, and have been tested to compile for kernel versions 2.6.12 and
2.6.14)

==== Hardware prerequisites

One of the following devices:

1. Realtek card, ManID = 0x10ec, DevID = 0x8180 (make sure it mount sa2400 radio. Many cards do, many don't)
2. Belkin F5D6001 PCI card, ManID = 0x1799, DevID = 0x6001 (Version 3)
3. Belkin F5D6020 Version 3 (3000) Cardbus card, ManID = 0x1799, DevID = 0x6020  NOTE: version 1 and 2 will not work
4. DLINK card, ManID = 0x1799, 0x1186, DevID = 0x3300 (A DWL-610 is working here, but I'm not sure all these cards have rtl8180 & sa2400)
5. Realtel card, ManID = 0x10ec, DevID = 0x8185, (Both the PCI and CaudBus versions are working fine here, these have 8225 radios)
	
==== Software prerequisites

Linux 2.6.0 or greater, 2.4 might work but you'll have to do some hacking.

==== Instructions

Get latest driver from, hopefully you already have done that!
http://sourceforge.net/projects/rtl818x (in this example we'll use
rtl818x-1.0.0-rc1) and build:

    tar xzf rtl8180-1.0.0-rc1.tar.gz
    cd rtl8180-1.0.0-rc1
    make

(naturally, needed to substitute version 1.0.0-rc1 with a current one)

You can ignore any "no CRC" and, or other warnings seen during compilation.

Module loading (order is important)

for users, testers and, or developers convenience scripts
./ifup-wlan0 and ./ifdown-wlan0 are provided, but for these you must
edit your /etc/network/interfaces on a Knoppix and, or Debian systems.
    
    man interfaces	# could be your best friend
    sodo vim /etc/network/interfaces

Anyway if you want to do testing and, or verification manually:

    # you may or may not have to do this following step
    sudo insmod /usr/src/linux/lib/crc32.ko
    # the following is required by ieee80211-rtl
    sudo insmod ieee80211_crypt-rtl.ko
    # you may load any and, or all of the following
    sudo insmod ieee80211_crypt_wep-rtl.ko
    sudo insmod ieee80211_crypt_tkip-rtl.ko
    sudo insmod ieee80211_crypt_ccmp-rtl.ko
    # the following is required by rtl818x
    sudo insmod ieee80211-rtl.ko
    # you will also need ARC4 support in kernel or by loading module
    sudo insmod rtl818x.ko

Once the above is done, you can do some checks to verify if all the things
went well?

Doing 

    cat /proc/modules

Gives something like:

    -------------------------
    rtl818x 104588 0 - Live 0xd0acd000
    ieee80211_rtl 61700 1 rtl818x, Live 0xd0c6c000
    ieee80211_crypt_ccmp_rtl 9344 0 - Live 0xd09df000
    ieee80211_crypt_tkip_rtl 11520 0 - Live 0xd09c3000
    ieee80211_crypt_wep_rtl 7808 0 - Live 0xd09d8000
    ieee80211_crypt_rtl 7940 4 ieee80211_rtl,ieee80211_crypt_ccmp_rtl, ...
    crc32 8064 3 ieee80211_crypt_tkip_rtl,ieee80211_crypt_wep_rtl,pcmcia, ...
    -------------------------

If you do:

    dmesg

You should see something like:

    -------------------------
    rtl818x: Memory mapped space @ 0xf6000000 
    rtl818x: MAC/BBP controller is a RTL8185 b/g (D)
    rtl818x: This is a CardBus NIC
    rtl818x: Reported EEPROM chip is a 93c46 (1Kbit)
    rtl818x: Card MAC address is 00:02:44:b1:b9:37
    rtl818x: EEPROM version 105
    ...
    rtl818x: Probe completed
    --------------------------

In this output you should see also other details, like if you have a digital
or analog PHY. Support for the latter is experimental as yet, please report
...

If you do:

    ifconfig -a

You should see

    --------------------------
    wlan0     Link encap:Ethernet  HWaddr 00:02:44:B1:B9:37  
	      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    	      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    	      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    	      collisions:0 txqueuelen:1000 
    	      RX bytes:0 (0.0 KiB)  TX bytes:0 (0.0 KiB)
    	      Interrupt:11 Memory:d09ca000-d09ca100 
    --------------------------

Doing:

    cat /proc/interrupts |grep wlan

You should see something like:

    --------------------------
    11:          0          ..... , wlan0
    --------------------------

Where '11' could be any number

If you have a CardBus card, doing "cardctl ident" should say something like:

    --------------------------
    Socket 1:
      product info: "Realtek", "Rtl8180"
      manfid: 0x0000, 0x024c
      function: 6 (network)
    --------------------------

Don't panic, the above info also depends on CIS data files, if you have
these and, or the same are not up-to-date, you may not get anything from
this step.

Doing:

    iwconfig

Shows:

    --------------------------
    wlan0     802.11b/g  Mode:Managed  Access Point: 00:00:00:00:00:00   
	      Bit Rate=11 Mb/s   
              Retry:on   Fragment thr:2432 B   
	      Encryption key:off
              Power Management:off
	      Link Quality:0  Signal level:0  Noise level:0
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
	      Tx excessive retries:0  Invalid misc:0   Missed beacon:0
    --------------------------

For now not all parameters are meaningful (like Sensitivity).


==== Setup

Type in the following:

    sudo ifconfig wlan0 up

At this point, if you are near an AP or wireless router you should start
getting interrupts:

    cat /proc/interrupts

    --------------------------
    11:        500          ...., wlan0
    --------------------------

The second number increments. Note that this happens also if you have other
peripherals on the same interrupt line and you use them.

Doing:

    ifconfig

Shows (note RX bytes):

    --------------------------
    wlan0     Link encap:Ethernet  HWaddr 00:02:44:B1:B9:37  
              inet6 addr: fe80::202:44ff:feb1:b937/64 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:1 errors:6 dropped:0 overruns:0 frame:0
              TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:263 (263.0 b)  TX bytes:2604 (2.5 KiB)
              Interrupt:11 Memory:d09c4000-d09c4100 
    --------------------------

If you do:

    iwlist scan

If you are in range of an AP or wireless router, you should see something
like:

    --------------------------
    wlan0     Scan completed :
	      Cell 01 - Address: 36:0C:5E:F9:64:FC
    	        	ESSID:"solar"
                        Protocol:IEEE 802.11g
                        Mode:Master
                        Channel:3
                        Encryption key:off
                        Bit Rate:54 Mb/s
                        Extra: Rates (Mb/s): 1 2 5.5 6 9 11 12 18 24 36 48 54 
                        Quality:0  Signal level:0  Noise level:158
                        Extra: Last beacon: 1294ms ago
    --------------------------

==== Test

Now set your SSID:

    sudo iwconfig wlan0 essid solar

Substitute 'solar' (my essid) with your essid.

Set your address (you may want to use different numbers here):

    sudo ifconfig wlan0 192.168.0.100 netmask 255.255.255.0

Add a route, if you need it:

    sudo route add default gw 192.168.0.1 dev wlan0

Try pinging another host (like the wireless router itself):

    ping 192.168.0.1

For further usage hint (es. setting WEP key or monitor mode see README file)
  
==== Installing permanently (so the driver is loaded when you reboot).

On Debian machines, the interesting files are:

    /etc/modprobe.d/		# man modprobe; quite helpful :)
    /etc/pcmcia/wireless.opts	# Knoppix provides/edits with wlcardconfig
    /etc/network/interfaces		# man interfaces; best friend ;)

You may also install your wireless interface automation scripts in the
following directories:
    
    /etc/network/if-down.d/
    /etc/network/if-post-down.d/
    /etc/network/if-pre-up.d/
    /etc/network/if-up.d/ 

A wrieless-tools and, or a few other packages like airsnort, kismet,
linux-wlan-ng and bridge-utils may also help here.
    
Sorry, Redhatian! I have not looked back Redhat and, or Fedora since I
switched over to Debian based Linux distributions; I otherwise, do not hate
anyone! Indeed, don't have a Redhat/Fedora machine near or around :(

==== Diagnostics

Some commands you can use to try to figure out what's gone wrong:

    lsmod |grep rtl
    dmesg |grep ^rtl818x
    dmesg |grep ^ieee80211
    ifconfig wlan0
    iwconfig wlan0
    cat /proc/iomem
    cat /proc/interrupts |grep wlan
    cardctl ident
    iwlist wlan0 scan

In particular dmesg output is very useful and, or shall highly be
appreciated in feedback.

==== Debug System

You need to have installed kernel sources for this to work; please let me
know if it works with only kernel headers installed...

To debug IEEE 802.11 network stack and, or modules just enable
IEEE80211_DEBUG option while runnig 
    
    sudo make xconfig	# or menuconfig 
	
from kernel source directory /usr/src/linux

This option will enable debug tracing output for the ieee80211 network
stack.

This will result in the kernel module being ~70k larger.  You can control
which debug output is sent to the kernel log by setting the value in

    /proc/net/ieee80211/debug_level

For example:

    % echo 0x00000FFO > /proc/net/ieee80211/debug_level

For a list of values you can assign to debug_level, you can look at the bit
mask values in <net/ieee80211.h>

To debug RTL818X driver, just un-comment a line in the Makefile in
./rtl818x-1.0.0-rc1 directory, find:
    
    #EXTRA_CFLAGS += -DCONFIG_RTL818X_DEBUG=y

Un-commeting the above said line will enable debug tracing output for
rtl818x driver; you can control whatever info you need is sent to the kernel
log by setting the value in
    
    /proc/net/rtl818x/debug_level

For example:

    % echo 0x00000FFO > /proc/net/rtl818x/debug_level

For a list of values you can assign to debug_level, you can look at the bit
mask values in <rtl818x.h>

NOTE: This will make your rtl818x module ~16k or more larger; so better
avoid debug system for production environments.

$Id: INSTALL,v 1.2 2006/06/29 18:55:31 bsd3 Exp $
