WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Compiling kernel modules --> extensions  (Read 7649 times)

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Compiling kernel modules --> extensions
« on: October 27, 2009, 03:41:01 AM »
Hi there, many thanks to the devs for tiny core... such a fully featured distro in so little space is quite remarkable.

My issue is with compiling kernel modules in a tc environment (with the goal of creating a tcz from it).

I have the compiletc.tcz extension loaded, I download the linux 2.6.29.1 source and place it on a persistent medium. I then mount to /usr/src/linux and try to compile a module with this:

make /net/mac80211/mac08211.ko

It seems to go well but then exits with MODPOST 0 modules.

When looking in /net/mac80211 there is only a mac80211.o file....

I tried compiling it on another system using the same kernel source and got a .ko file out, however when trying to insmod it on the tc system it fails with 'invalid module type'.

I even tried unloading the module that comes with tc and then insmod-ing it back in while in the correct directory... that failed with the same error....

I'm lost... can anyone give me a clue?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14535
Re: Compiling kernel modules --> extensions
« Reply #1 on: October 27, 2009, 03:55:54 AM »
This is probably not all required, but:

load the compiletc "meta-extension"
load the perl5 and bash extensions
download the patched tinycore source and unpack in, say, /usr/src
download the tinycore config and copy to the top level of the unpacked souce as .config
use "make menuconfig" to load the tinycore .config and save
make modules
sudo make modules_install

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #2 on: October 27, 2009, 04:12:54 AM »
Many thanks for the swift reply.

I have perl5 loaded (tried a plain make modules for the hell of it, seems some need it) but did not have any of the bash*.tcz extensions loaded... would this make the difference?

I will try all that you suggested, but may I ask, if this works will it produce *.ko.gz modules in the correct directories (because of the modules_install) which I can fish out and put into a .tcz?

Would be really nice if there was an idiots guide to things like this in the wiki... are you guys open to contributions?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Compiling kernel modules --> extensions
« Reply #3 on: October 27, 2009, 04:22:27 AM »
Would be really nice if there was an idiots guide to things like this in the wiki... are you guys open to contributions?

Wiki is open for anybody, just register.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14535
Re: Compiling kernel modules --> extensions
« Reply #4 on: October 27, 2009, 04:45:49 AM »
I have perl5 loaded (tried a plain make modules for the hell of it, seems some need it) but did not have any of the bash*.tcz extensions loaded... would this make the difference?

I will try all that you suggested, but may I ask, if this works will it produce *.ko.gz modules in the correct directories (because of the modules_install) which I can fish out and put into a .tcz?

Certain parts of the kernel/kernel modules build require bash and perl so you'd need both extensions loaded to make sure everything compiles OK.

This will produce a *.ko module in the "correct" directory (I don't think it matters too much where as it's under /lib or /usr/local/lib and you run depmod). Unless there's a make switch that I'm not aware of, you'll need to manually gzip/advdef the *.ko to *.ko.gz.

Once you have the module under /lib, I'd recommend moving it to a comparable path under /usr/local/lib/modules/2.6.29.1-tinycore/kernel/.. so that it becomes PPI compatible before you make your *.tczm extension out of it.

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #5 on: October 27, 2009, 05:14:47 AM »
Again thanks for the reply.

Another question (forgive me)... once I have the relevant module in /usr/local/lib/modules...etc... how best should I go about using mksquashfs to create the tczm?

I made a .tcz to load the firmware for my wireless card by creating a temp dir with the same dir structure as the place it needed to be and using mksquashfs on that, eg - mkdir temp/lib/firmware/b43 coping the relevant files to the deepest dir and then mksquashfs temp packagename.tcz. Would I have to create this structure (eg /temp/usr/local/lib/modules/2.6.29.1-tinycore/kernel/...) and then mksquashfs that?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14535
Re: Compiling kernel modules --> extensions
« Reply #6 on: October 27, 2009, 05:23:46 AM »
I'm not at a linux machine at the moment to confirm the shortest way to do this, but whilst being a bit long, this should work:
Code: [Select]
$ sudo tar -czvf mymodule.tcem --numeric-owner /usr/local/lib/path-to-file/module_name.ko.gz
$ mkdir /tmp/pkg
$ cp mymodule.tcem /tmp/pkg
$ cd /tmp/pkg
$ sudo tar xzf mymodule.tcem
$ rm mymodule.tcem
$ cd ..
$ sudo mksquashfs pkg/ mymodule.tczm
note: use the gnu tar extension to do this

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #7 on: October 27, 2009, 05:41:49 AM »
I see, so the tar-ing with --numeric-owner /usr/local/lib/path-to-file/module_name.ko.gz preserves the directory structure, which is created again when you untar it, which you then apply mksquashfs to. Thanks for clearing that up.

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #8 on: October 27, 2009, 05:44:08 AM »
Sorry if this is a dumb question by how do you create tcz's that do more than just put files in the right place?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Compiling kernel modules --> extensions
« Reply #9 on: October 27, 2009, 05:45:33 AM »
Sorry if this is a dumb question by how do you create tcz's that do more than just put files in the right place?

What do you mean do more?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14535
Re: Compiling kernel modules --> extensions
« Reply #10 on: October 27, 2009, 05:45:57 AM »
Quote
...preserves the directory structure

..and permissions
« Last Edit: October 27, 2009, 05:49:26 AM by Juanito »

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #11 on: October 27, 2009, 05:52:51 AM »
Sorry if this is a dumb question by how do you create tcz's that do more than just put files in the right place?

What do you mean do more?

Well I thought that some extensions did more than just put files in folders. The wireless-2.6.29.1 extension seems to make new modules (if required) load at boot, and at the very least they have to update bash. Or is this all just clever scripts?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14535
Re: Compiling kernel modules --> extensions
« Reply #12 on: October 27, 2009, 05:57:14 AM »
Well I thought that some extensions did more than just put files in folders. The wireless-2.6.29.1 extension seems to make new modules (if required) load at boot, and at the very least they have to update bash. Or is this all just clever scripts?

This is a combination of the "m" in tczm which tells tce-load to invoke "depmod" and udev which automagically loads available modules for hardware it knows about.

Edit: and you can include a script /usr/local/tce.installed/extension_name in your tcz that will execute when the extension is loaded
« Last Edit: October 27, 2009, 06:01:10 AM by Juanito »

Offline Theo404

  • Newbie
  • *
  • Posts: 9
Re: Compiling kernel modules --> extensions
« Reply #13 on: October 27, 2009, 06:06:47 AM »
Edit: and you can include a script /usr/local/tce.installed/extension_name in your tcz that will execute when the extension is loaded

Ok, but tcz extensions just come as one file (excluding .list .dep etc), where is this script contained?

Edit: and if you can add scripts to them... how?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Compiling kernel modules --> extensions
« Reply #14 on: October 27, 2009, 06:08:52 AM »
You may read this WIKI article Adding Custom Startup Scripts
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."