Monday, March 05, 2007

Compiling a New Kernel

I downloaded the latest 2.6-series kernel (version 2.6.20.1) for a long time. Yesterday night I unpacked it as my bed-time reading and went for an initial build.

The first build was not working, the disk couldn't be mounted and kernel was panic. I went back to the config and compiled the SATA driver in. Second boot up was smooth, I could see the standard login prompt silently waiting and blinking.

Suddenly I felt good at myself: After so many hours I have spent all these years to compile the linux kernel, up from the 2.0 series until now. At least now I have an instinct on how to build a kernel and can get it right the second time.

This new 2.6 kernel seems to change quite a lot of stuff, most notable is my RaLink-based D-Link wireless PCI card driver no longer compiles, complaining "error: structure has no member named `get_wireless_stats'". A quick look at linux/netdevice.h reviewed that the function get_wireless_stats is deprecated in the struct net_device and got moved into some other places (to struct iw_handler_def in the 'net' directory actually). As social service to the world, I now fix it.

Steps:
  1. Backup your files
  2. Edit rtmp_info.c, search for the string 'rt61_iw_handler_def'. You will land on the definition of the struct. Remove the word 'const' from the definition
  3. Save and close file
  4. Edit rtmp_main.c, again search for the above string.
  5. You will land on the following line. Remove the 'const'
    extern const struct iw_handler_def rt61_iw_handler_def;

  6. At the same file, go to line 198, as shown below:
    net_dev->get_wireless_stats = RT61_get_wireless_stats;

  7. Change it to:
    rt61_iw_handler_def.get_wireless_stats = RT61_get_wireless_stats;

  8. Save and close file. Your module should compile. If you are bored, you may want to remove all compilation warnings. If you are really really bored, put a -Wall switch in the Makefile and remove all warnings

No comments: