rockus.at: 3c359 Tokenring On Minimised debian

rockus.at / Linux_x86 / 3c359 Tokenring on debian

 

(See below for an update for debian lenny and kernel 2.6.26)

This document describes how to get a 3Com 3c359 Tokenring network adapter card up and running on a debian woody, that was minimalised on installation. It provides a rather step-by-step approach, although since this is only really recommended for experienced users, I refrained from putting too much detail into the description. If there are any questions, feel free to drop me an email.


I tried to keep my main router minimalised with as few packages installed as possible. This resulted in a working system that only used some 200MB of hard disc space, including packet filtering and IP masquerading.

Since there was a Tokenring adapter installed in that system I wanted to use it, but debian does not provide pre-compiled drivers in its stable repository (woody at the time of writing, which uses kernel 2.4.18. The drivers I need are only in the stock Linux kernel from 2.4.19 onwards) for my brand of network card. Therefore I had to download additional packages and sources. Luckily, basic Tokenring support is already compiled into the kernel.

What I did was to get the kernel-source for my installation, patch as necessary and compile the modules. If you are careful enough, you do not even need to reboot the computer. For this, just compile the modules, as described below, but not the kernel. Also do not use the scripts to automatically install a new kernel or new modules, instead copy over the one new module manually.

Below are the packages I had to install additionally:

kernel-source
make
gcc
ncurses
libc6-dev
libncurses5-dev
patch
wget
wget is only needed if you want to use it to download the patch archive with it.

Also, the patch for my network card had to be downloaded as well. I found it there:
http://www.linuxtr.net/download/3c359-2.4.17.patch.gz.

Now the fun starts. You have to patch the kernel. After you unpacked the patch archive and cd'ed into the base directory for the kernel sources, a patch -p 1 -i /path/to/patchfile should do the trick.

The important part now, if you want to avoid recompiling the kernel, installing it and rebooting in the end, is to adapt the version in the main kernel Makefile, so that the module can be insmod'ed afterwards without complaints. For that you need to find out the version for the kernel that#s presently running on your machine with more /proc/version. In my case, that yielded a

Linux version 2.4.18-bf2.4 (root@zombie) (gcc version 2.95.4 20011002
(Debian prerelease)) #1 Son Apr 14 09:53:28 CEST 2002
Now you know that your kernel is (for example) 2.4.18-bf2.4.

You have to adapt the Makefile in your base kernel source directory now. The relevant lines look like this for me:

VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 18
EXTRAVERSION = -bf2.4
Note the extra - for the EXTRAVERSION.

Now all you have left to do is compile the new module. For this, still in your kernel source base directory, issue the usual series of commands when building new kernel modules:

make menuconfig
make dep
make modules
I just happen to be used to menuconfig, since I usually work from remote and do not always have access to X. So, once in the configuration, make sure to select the new network card as a module, which can be found in Network device support, Token Ring devices.

If everything compiles fine, you can now test if your module works by trying a insmod /path/to/kernel-source/drivers/net/tokenring/3c359.o. If that works as well and you can see a tr0 device with ifconfig, all that is left is to copy the module into the directory where the kernel can find it: cp -a drivers/net/tokenring/3c359.o /lib/modules/2.4.18-bf2.4/kernel/drivers/net/tokenring/3c359.o. Obvioulsy, the kernel version has to be adapted here as well. Copying the file manually avoids that you have to reboot or end up with a mess in your modules directory, since the scripts first remove all modules and then install only the selected ones. Usually that makes sense when recompiling new kernels, but here it would be rather dangerous. Only after a thorough scrutiny of which modules you need and making sure you selected them prior to compiling, you should use the scripts for installing the modules at that point. I did not want to go through that procedure at that point, so manually copying the file solves that problem.

Now be happy and use Token Ring with your debian. Oh, one more thing, an entry like alias tr0 3c359 could come in handy in /etc/modules.conf.


Update for debian lenny with kernel 2.6.26:

Basically, the steps are the same. However, a few changes are necessary. A good overview on how to move around inside the kernel build system can be found in Kernel configuration and building in Linux 2.5 by Kai Germaschewski. Also, an introduction to the kernel make file may be of use. The packages to install are now

linux-source-2.6.26
libncurses5-dev.
This will also install the following depending packages:
cpp
cpp-4.3
gcc
gcc-4.3
libc6-dev
libgomp1
libmpfr1ldbl
linux-libc-dev
make.

Files to add to the linux source:

drivers/net/tokenring/3c359.c
drivers/net/tokenring/3c359.h
drivers/net/tokenring/3c359_microcode.h

Files to change in the linux source:

drivers/net/tokenring/Makefile
drivers/net/tokenring/Kconfig
drivers/net/tokenring/3c359.c

With this, you can activate compilation of 3c359.c in menuconfig under Device Drivers -> Network Device Support -> Token Ring driver support -> 3Com 3C359 Token Link Velocity XL adapter support. Mark it as module.

There is currently no patch available for compiling the driver for a current kernel. So this has to stop here for now.