Howto compile for 2.4 kernel

Live forum: http://rt2x00.serialmonkey.com/viewtopic.php?t=4553

Musicman

13-01-2008 08:22:38

I am trying to build this on a system with 2.4.21 and gcc 3.3.1

make KERNDIR=/usr/src/linux-2.4.21-99
cc -I. -DAGGREGATION_SUPPORT -DWMM_SUPPORT -DKBUILD_BASENAME=rtmp_main -c -o rtmp_main.
o rtmp_main.c
In file included from rtmp_main.c36
rt_config.h572 Warnung #warning You must compile this file with the correct options!
rt_config.h582 Warnung #warning See the last lines of the source file.
rt_config.h592 #error You must compile this driver with "-O".
In file included from /usr/include/linux/sched.h12,
from /usr/include/linux/module.h9,
from rt_config.h62,
from rtmp_main.c36
/usr/include/linux/jiffies.h16 error parse error before "jiffies_64"
/usr/include/linux/jiffies.h20 error parse error before "get_jiffies_64"
In file included from /usr/include/linux/sched.h20,
from /usr/include/linux/module.h9,
from rt_config.h62,
from rtmp_main.c36
/usr/include/asm/mmu.h13 error field `sem' has incomplete type
In file included from /usr/include/linux/signal.h4,
from /usr/include/linux/sched.h24,
from /usr/include/linux/module.h9,
from rt_config.h62,
from rtmp_main.c36
/usr/include/linux/list.h5632 Warnung #warning "don't include kernel headers in usersp
ace"
In file included from /usr/include/asm/siginfo.h4,
from /usr/include/linux/signal.h7,
from /usr/include/linux/sched.h24,
from /usr/include/linux/module.h9,
from rt_config.h62,

I have tried to add PATCHLEVEL=4, CFLAGS=-I/usr/src/linux-2.4.21-99/include, CFLAGS=-O and combinations without much difference. I have recently built a kernel in this kernel dir.

What am I doing wrong?

Vern

13-01-2008 18:38:05

Hi Musicman,

Does /usr/src/linux-2.4.21-99 have *exactly* the same structure as you would have with a download of 2.4.21 from kernel.org?

Does /lib/modules/`uname -r`/extra exist?

Thanks,

Musicman

14-01-2008 06:06:06

Hi,

this is the layout of the kernel dir
abi/ COPYING fs/ kernel/ mm/ Rules.make
arch/ CREDITS include/ Kerntypes net/ scripts/
Config.in crypto/ init/ lib/ README sound/
config.orig Documentation/ ipc/ MAINTAINERS REPORTING-BUGS System.map
config-suse-deflt drivers/ kdb/ Makefile rmgt/ vmlinux*
It looks pretty standard. Of course things have changed over the years - this is layout for latest 2.4 from kernel.org
arch crypto fs ipc MAINTAINERS net Rules.make
COPYING Documentation include kernel Makefile README scripts
CREDITS drivers init lib mm REPORTING-BUGS

This is the layout of the modules dir, there is no extra
build@ modules.dep modules.parportmap oprofile/
dvb/ modules.generic_string modules.pcimap pcmcia/
kernel/ modules.ieee1394map modules.pnpbiosmap pcmcia-external/
misc/ modules.isapnpmap modules.usbmap v4l2/

I have seen a howto installing the rt24 driver on the same setup, and it did not mention any compile problems

Vern

14-01-2008 17:17:37

You might try going here[/url1u2q8qb3], download and unpack the tarball, point make to it, and see what happens.

Musicman

15-01-2008 06:18:08

unfortunately no real change (
When I compile a kernel, compile options look like
gcc -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -nostdinc

When I try to build the rt73 driver, it does not use these options.
In particular, it reads include files from /usr/include/linux unless I add CFLAGS option, and regardless of -O or -O2 it complains about options
rt_config.h572 Warnung #warning You must compile this file with the correct
options!
rt_config.h582 Warnung #warning See the last lines of the source file.
rt_config.h592 #error You must compile this driver with "-O".
When I use CFLAGS="-D__KERNEL__ -I/home/wolfgang/progs/linux-2.4.21/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686", it gets until
rtmp_init.c In function `LoadFirmware'
rtmp_init.c1530 error structure has no member named `dev'
rtmp_init.c1565 Warnung implicit declaration of function `msleep'
The 'struct usb_device' referred to looks like this
struct usb_device {
int devnum; /* Address on USB bus */
char devpath [16]; /* Use in messages /port/port/... */

enum {
USB_SPEED_UNKNOWN = 0, /* enumerating */
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
USB_SPEED_HIGH /* usb 2.0 */
} speed;

struct usb_tt *tt; /* low/full speed dev, highspeed hub */
int ttport; /* device port on that tt hub */

atomic_t refcnt; /* Reference count */
struct semaphore serialize;

unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
unsigned int halted[2]; /* endpoint halts; one bit per endpoint # & direction; */
/* [0] = IN, [1] = OUT */
int epmaxpacketin[16]; /* INput endpoint specific maximums */
int epmaxpacketout[16]; /* OUTput endpoint specific maximums */

struct usb_device *parent;
struct usb_bus *bus; /* Bus we're part of */

struct usb_device_descriptor descriptor;/* Descriptor */
struct usb_config_descriptor *config; /* All of the configs */
struct usb_config_descriptor *actconfig;/* the active configuration */

char **rawdescriptors; /* Raw descriptors for each config */

int have_langid; /* whether string_langid is valid yet */
int string_langid; /* language ID for strings */

void *hcpriv; /* Host Controller private data */

/* usbdevfs inode list */
struct list_head inodes;
struct list_head filelist;

/*
* Child devices - these can be either new devices
* (if this is a hub device), or different instances
* of this same device.
*
* Each instance needs its own set of data structures.
*/

int maxchild; /* Number of ports if hub */
struct usb_device *children[USB_MAXCHILDREN];
};

Vern

15-01-2008 19:39:40

Hi Musicman,

First, if you have non-miniscule amounts of supporting info, please attach it as a file to a posting, rather than inline. It makes your problem description easier to find.

The line numbers on your driver compilation errors indicate you're using outdated driver source. You can click on the download tab at the top of the page before you log in, or after you log out, select the rt73 legacy code, download the latest CVS tarball, and build from that.

You don't explicitly state that your downloaded kernel builds without errors (not just warnings, errors). Does it? The driver may or may not build with gcc 3.x, but it's preferable to use gcc 4 to build. To do so, you need to apply this patch[/url8mrx2zuk] to your 2.4 kernel source first so that it will build using gcc 4.x.

Could you try those steps? Then we can take a look at any errors that remain. If indeed it turns out that the driver uses structure members that are not defined as of 2.4.21, it may not be feasible to fix the problem, depending on how extensive the needed mods are.

Thanks,

Musicman

17-01-2008 05:34:39

Hi,

I have tried the new version. The makefile now works well, i.e. it compiles with the same options as the kernel make would. However, the compile stumbles over SET_NETDEV_DEV which is not in 2.4.2; it is defined in 2.4.36 as
/* 2.6 compatibility */
#define SET_NETDEV_DEV(net, pdev) do { } while (0)
The error in compiling rtmp_init seems to correlate with a comment found in 2.4.* firmware.h that the args for request_firmware change in 2.5
So it seems that every newer version gets a few 2.6isms added, and I would need to look at the past. Do you have cvs online for viewing?

Musicman

Vern

17-01-2008 18:13:46

Hi Musicman,

Try the attached patch (2.6compat1.patch).

You can get CVS source by clicking on the download tab at the top of the page after you log out, selecting the rt73 legacy driver, and downloading it.

Thanks,

Musicman

18-01-2008 04:44:18

Hi thanks,

I made a little progress
changing the make target from "module" to "modules" caused adding the MODVERSIONS stuff to the compile.
Further it seems that msleep() was called wait_ms() before, I added a #define.
Now I can at least modprobe the driver.
Next I have to find out how firmware loading was meant to work
I compiled the module with debug, and also enabled hotplug debugging. Loading the module writes
Jan 18 090208 laptop kernel rtusb init ====>
Jan 18 090208 laptop kernel usb.c registered new driver rt73
Jan 18 090208 laptop kernel idVendor = 0x14b2, idProduct = 0x3c22
Jan 18 090208 laptop kernel **RT2573**<7>usb device name wlan0
Jan 18 090208 laptop kernel **RT2573**<7>BulkOutMaxPacketSize 64
Jan 18 090208 laptop kernel **RT2573**<7>rt73_get_ether_stats --->
to the system log, then talks about registering an interface. There is no mention of firmware at all


Musicman

Vern

18-01-2008 21:07:42

Hi Musicman,

You should not need to modify the make file to get a clean build. If entering "make" - preferably "make clean all" for "production" code - or "make clean debug" for debugging doesn't do so, please do something like "make clean debug 2>errs" and attach a copy of the error file to a posting here.

It looks like the source you're using is a little old. The lastest CVS has the patch I provided, so could you download a tarball of the latest CVS for the driver, build and run with debug enabled, and post a gzipped copy of /var/log/debug here?

Thanks,

Musicman

20-01-2008 07:24:42

Hi,

I got it working now with the new code. There was one minor thing - on my system there is a
#define HZ get_hz()
so I had to comment themsec/jiffies code in rt_config.h
I wonder how the kernel does that - the code in include/linux/delay.h is pretty much the same.
Next I ran into something that looks like a problem with the driver the version of hotplug I use does a
hwscan --usb --fast
right after loading the driver. (It is probably there only to show success in the system log) If the firmware cannot be loaded (I had to fix the hotplug first) this (as well as running usbmodules) produces a kernel oops.
Now looking for a wlan to actually test things....

Musicman

Vern

20-01-2008 17:03:59

Hi Musicman,
[code2nf7lhsc]#define HZ get_hz()[/code2nf7lhsc]
doesn't sound like a standard kernel construct as supplied by kernel.org. What does "uname -r" say?

You can go to this thread[/url2nf7lhsc] and download a patch that restores the load firmware function as found in Ralink's version of the driver.

Musicman

20-01-2008 19:48:16

Hi,

uname -r says 2.4.21-99 (or maybe 2.4.21-99-default)
This is a SuSe kernel with some stuff backported, in particular the kernel firmwareloader did not exist in plain 2.4.21
I sort of believe that there must be a better way to get at kernel HZ, simply because the code that complains is much the same as in that delay.h
If I can find whether/how a kernel module gets around this problem, I will post it here.
I am quite happy with firmware loading now - I essentially copied a script like the one you mentioned in the other thread to /etc/hotplug/firmware.agent and adjusted filenames - it is /proc/$DEVPATH rather than /sys/$DEVPATH or /sysfs/$DEVPATH (as it is written in the local kernel docs).
I still believe that there is a problem if firmware loading fails (which should not, once everything is in place) and subsequent hwscan or usbmodules causes the system to oops.

Musicman