[realtek] HOWTO: compile rtl8193.c and pci-scan.c as a module under 2.4.18

msimons@moria.simons-clan.com msimons@moria.simons-clan.com
Thu Jun 27 14:02:30 2002


--MGYHOYXEY6WxJCY8
Content-Type: text/plain; charset=us-ascii

Hello Donald Becker,

[this may bounce going to your realtex list... since I'm not subscribed]


  I recently purchased a D-Link DFE-530TX+ which I think uses the 
rtl8139c chip.  I downloaded "rtl8139.c:v1.17 1/28/2002" and the
associated driver files scyld.com (1).

  I was trying to compile this as a module for a 2.4.18 kernel.

  I saw on your site that I needed to download a number of other
files.  After adding "-I/usr/src/linux/include" I was able to 
get both rtl8139.c and pci-scan.c to compile... the problem was with
"pci-scan.c:v1.08 9/28/2001" not being able to load at runtime.  A sample
compile/load attempt is at the end of this email.

  I scanned over the driver file, read over the website, I looked 
through each of your rtl8139 driver mailing lists archives... where I 
can see a dozen other people have had trouble building working modules.

  The only method I could get this driver loaded (as a module) was 
to put it into the /usr/src/linux/drivers/net directory, then 
fudge up the kernel make scripts to get them to build me rtl8139.o
and pci-scan.o.

  So I figured out out what options that process added...
I found that adding the following to pci-scan compile would produce 
a loadable module:
  "-include /usr/src/linux/include/linux/modversions.h -I/usr/src/linux/include"
Even then when I load it insmod mentions that I've tainted
my kernel.  What a mess... 

  So attached is a small patch that can be applied to the pci-scan.c and
rtl8193.c file so that these files and their instructions will work
for a person trying to get them to build outside a 2.4.18 kernel tree.
Included is a patch to add module_license so that loading pci-scan 
doesn't taint the kernel.

  - Could you please apply this patch, or update your web directions with
    a method that will work for the 2.4.18 kernel?

  Sorry to bother you...
    Mike Simons

1: http://www.scyld.com/network/rtl8139.html


  This is a sample of attempting to load pci-scan by following the 
directions...
=============
root@star:~/alt/1# grep gcc pci-scan.c
 *  compile-command: "gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c pci-scan.c"
root@star:~/alt/1# gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c pci-scan.c
root@star:# insmod ./pci-scan.o
./pci-scan.o: unresolved symbol pci_write_config_byte
./pci-scan.o: unresolved symbol kmalloc
./pci-scan.o: unresolved symbol pci_find_class
./pci-scan.o: unresolved symbol __check_region
./pci-scan.o: unresolved symbol pci_read_config_byte
./pci-scan.o: unresolved symbol pci_read_config_dword
./pci-scan.o: unresolved symbol __ioremap
./pci-scan.o: unresolved symbol pci_read_config_word
./pci-scan.o: unresolved symbol kfree
./pci-scan.o: unresolved symbol pci_set_master
./pci-scan.o: unresolved symbol pci_write_config_dword
./pci-scan.o: unresolved symbol pci_write_config_word
./pci-scan.o: unresolved symbol printk
./pci-scan.o: unresolved symbol ioport_resource
./pci-scan.o:
Hint: You are trying to load a module without a GPL compatible license
      and it has unresolved symbols.  Contact the module supplier for
      assistance, only they can help you.
root@star:~/alt/1# gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c orig.pci-scan.c -include /usr/src/linux/include/linux/modversions.h -I /usr/src/linux/include
In file included from orig.pci-scan.c:65:
/usr/src/linux/include/linux/malloc.h:4: warning: #warning linux/malloc.h is deprecated, use linux/slab.h instead.
root@star:~/alt/1# insmod ./orig.pci-scan.o
Warning: loading ./orig.pci-scan.o will taint the kernel: no license

--MGYHOYXEY6WxJCY8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.1"

--- orig.pci-scan.c	Mon Jun 24 10:31:29 2002
+++ pci-scan.c	Tue Jun 25 14:45:31 2002
@@ -51,8 +51,7 @@
 
 #include <linux/version.h>
 #include <linux/module.h>
-/* Older kernels do not include this automatically. */
-#if LINUX_VERSION_CODE < 0x20300  &&  defined(MODVERSIONS)
+#if defined(MODVERSIONS)
 #include <linux/modversions.h>
 #endif
 
@@ -83,6 +82,9 @@
 void (*unregister_cb_hook)(struct drv_id_info *did);
 
 #if LINUX_VERSION_CODE > 0x20118  &&  defined(MODULE)
+MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
+MODULE_DESCRIPTION("PCI Bus scanning support for Donald Becker");
+MODULE_LICENSE("GPL");
 MODULE_PARM(debug, "i");
 MODULE_PARM(min_pci_latency, "i");
 #if defined(EXPORT_SYMTAB)
@@ -572,7 +574,7 @@
 
 /*
  * Local variables:
- *  compile-command: "gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c pci-scan.c"
+ *  compile-command: "gcc -DMODULE -D__KERNEL__ -DEXPORT_SYMTAB -Wall -Wstrict-prototypes -O6 -c pci-scan.c -I/usr/src/linux/include"
  *  c-indent-level: 4
  *  c-basic-offset: 4
  *  tab-width: 4
--- orig.rtl8139.c	Mon Jun 24 01:48:07 2002
+++ rtl8139.c	Tue Jun 25 14:44:04 2002
@@ -1644,7 +1644,7 @@
 
 /*
  * Local variables:
- *  compile-command: "gcc -DMODULE -Wall -Wstrict-prototypes -O6 -c rtl8139.c"
+ *  compile-command: "gcc -DMODULE -Wall -Wstrict-prototypes -O6 -c rtl8139.c -I/usr/src/linux/include"
  *  cardbus-compile-command: "gcc -DCARDBUS -DMODULE -Wall -Wstrict-prototypes -O6 -c rtl8139.c -o realtek_cb.o -I/usr/src/pcmcia/include/"
  *  c-indent-level: 4
  *  c-basic-offset: 4

--MGYHOYXEY6WxJCY8--