WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to compile kernel module?  (Read 4345 times)

Offline Alatun

  • Newbie
  • *
  • Posts: 41
How to compile kernel module?
« on: May 27, 2015, 11:59:16 AM »
I'd like to use Tinycore with rdesktop as a thin client environment. I remastered and configured Tinycore in a virtual box environment and had no problem so far.

Just did some tests on real hardware and encountered a weird problem. The network IF did not get an IP via DHCP.
The network port is connected to a 1GB network and works correctly with Windows 7. If I boot Tinycore 6.2 from CD without changing any network cables, suddenly the LEDs at the network port switch off. The network IF is shown as UP, but does not get an IP. Assigning an IP manually does not help. It seems the driver switches the network link off.

After some research the suspect fell upon the r8169 driver. Several people using different linux kernel versions were reporting similar problems. Then I found a website that gave a solution for the problem: https://unixblogger.wordpress.com/2011/10/18/the-pain-of-an-realtek-rtl8111rtl8168-ethernet-card/

I just tried to compile the r8168 kernel module from source according to the link above and the README in the src package. But I'm getting an error:
Code: [Select]
/lib/modules/3.16.6-tinycore/build: no such file or directory .

Googling with this error indicates that this error happens, if you don't have the kernel headers installed. I searched the tcz repository and installed: "linux-kernel-sources-env.tcz" "linux-3.16.2_api_headers.tcz". But this did not remove the error.
I was unsure, if the mentioned packages are the missing kernel header files. Could anybody give me a hint?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How to compile kernel module?
« Reply #1 on: May 27, 2015, 12:25:23 PM »
Did you ran the script provided by linux-kernel-sources-env.tcz to actually download and prepare the kernel source?
If so, you might be able to create a symlink to  /lib/modules/3.16.6-tinycore/build . I think the script copies the source to /usr/src/...?
Download a copy and keep it handy: Core book ;)

Offline Alatun

  • Newbie
  • *
  • Posts: 41
Re: How to compile kernel module?
« Reply #2 on: May 28, 2015, 11:42:29 AM »
No, I didn't ran the script provided by linux-kernel-sources-env.tcz.  But this did the trick. Looking at the description of the package would have been helpful. Shame on me.

In the meantime, I successfully compiled the r8168.ko module from the Realtek sources and the first test on my hardware gave me a working network connection. I manually removed the r8169 module, inserted the r8168 module and upped the network IF.

Now I need to remaster Tinycore and blacklist the old driver and include the new one. I saw that all files in the module directory are of type "xx.ko.gz". Is gzipping the new driver and putting it into the corresponding directory sufficient?

Last time I fiddled with kernel drivers happened a long time ago (kernel 1.x). I remember some other files might need an update, too.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How to compile kernel module?
« Reply #3 on: May 28, 2015, 12:49:43 PM »
Quote
Is gzipping the new driver and putting it into the corresponding directory sufficient?
I think compressing modules is not essential - I'd say it saves RAM in case of unused modules. Modules seem just to be needed in the right place. None of the  *module*-KERNEL.tcz  extensions have a startup script as  tce-load  recognizes modules and issues the necessary commands (depmod -a, udevadm trigger, ldconfig).
For firmware,  udevadm trigger  is enough.
If you add modules or firmware to your initrd, not creating an extension, I think nothing is needed for these to be recognized.
Download a copy and keep it handy: Core book ;)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: How to compile kernel module?
« Reply #4 on: May 29, 2015, 04:48:20 AM »
The depmod files need updating after inserting a module, if there is nothing that will run it for you like with Misalf's example.
The only barriers that can stop you are the ones you create yourself.