User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 3:53 am

So I was working on getting my IR receiver to work with xbmc when I hit an interesting snag.  Part of what I needed to do, apparently, was to "just recompile the kernel with option x".  Now I must confess that I'm pretty wet behind the ears when it comes to to world of linux so this statement is hardly a "just do" statement to me, but that's neither here nor there

So would someone be kind enough to explain how to compile the kernel for the r-pi so I can do fun little thing like this?
Dear forum: Play nice ;-)


User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 12:47 pm

ah for the want of typing in the right words in the search box!  Thanks Shirro!
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 12:49 pm

Oh and just to be sure, to compile it with "option x" I make that change in the .config file, right?
Dear forum: Play nice ;-)

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 1:09 pm

Either directly in the config file, or use "make menuconfig" and find the option you want in the hierarchy.  If it's one option, and you know what it's called, it's usually faster to do it direct in the config file.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 1:46 pm

Thanks!  I feel like I'm about to partake of some linux right of passage by doing this
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 9:19 pm

Hmm... everything compiled just fine (took a long time on the pi, but it worked), but for reason even after doing my make modules install it hasn't installed the modules that I specified when I compiled the kernel

I added the following to .config

#
# Multimedia drivers
#
CONFIG_VIDEO_SAA7146=m
CONFIG_VIDEO_SAA7146_VV=m
CONFIG_RC_CORE=m
CONFIG_LIRC=m
# CONFIG_RC_MAP is not set
CONFIG_IR_NEC_DECODER=m
CONFIG_IR_RC5_DECODER=m
CONFIG_IR_RC6_DECODER=m
CONFIG_IR_JVC_DECODER=m
CONFIG_IR_SONY_DECODER=m
CONFIG_IR_RC5_SZ_DECODER=m
CONFIG_IR_LIRC_CODEC=m
CONFIG_IR_ENE=m
CONFIG_IR_IMON=m
CONFIG_IR_MCEUSB=m
CONFIG_IR_ITE_CIR=m
CONFIG_IR_NUVOTON=m
CONFIG_IR_STREAMZAP=m
CONFIG_IR_WINBOND_CIR=m
# CONFIG_RC_LOOPBACK is not set

Then I did the make oldconfig then make, then make install, and finally wrapped it up with make modules and make modules install.  made the kernel.img using the script in tools/mkimage and used it to replace the existing kernel.img in /boot.

But I can't find my new modules I just asked it to install!  (specifically mceusb which *should* be in /lib/modules/3.1.9+/kernel/drivers/media/rc/)  I see them in the linux/drivers/media/rc when I make the kernel, but can't find them afterwards   What am I missing?
Dear forum: Play nice ;-)

User avatar
jojopi
Posts: 3233
Joined: Tue Oct 11, 2011 8:38 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 10:30 pm

Abishur said:

make modules install
 

Could just be a typo in your post, but you want "make modules_install".  "make modules install" is two separate targets, both of which you already built...

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Mon May 07, 2012 10:34 pm

lol, yep that's a typo, I tried both the modules_install from the r-pi itself (where I compiled) and then I redid the whole process on a VM doing cross compiling, installed the modules to a specific path and they're still not there!  I am missing something here right?  I should have a lirc_mceusb module.
Dear forum: Play nice ;-)

Pirx-Danford
Posts: 62
Joined: Thu Oct 06, 2011 2:05 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:12 pm

Not all hardware is automagically detected,

sometimes you need to load the module "manually".

Try a modprobe lirc_mceusb

If that does work you might want to put lirc_mceusb into the /etc/modules file

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:17 pm

Pirx Danford said:


Not all hardware is automagically detected,

sometimes you need to load the module "manually".

Try a modprobe lirc_mceusb

If that does work you might want to put lirc_mceusb into the /etc/modules file



That's what I meant by I can't find them.  modprove lirc_mceusb doesn't work, and when I try to find the correct module I can't!  I'd manually put it in, but I can't even find a place to copy it from.  It's very frustrating as you might imagine!
Dear forum: Play nice ;-)

Pirx-Danford
Posts: 62
Joined: Thu Oct 06, 2011 2:05 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:29 pm

Abishur said:


That's what I meant by I can't find them.


Oh I see.

Well in cases like that the locate utilities are quite helpful (http://wiki.ubuntuusers.de/locate).
First do "updatedb", to get all files into the search database, then do a "locate lirc_mceusb".

But maybe you just need to do a "depmod -a", which will do an update to the module dependencies. After a fresh module compile this is needed to get new modules working.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:30 pm

do you have write permissions for /boot and /usr/lib/modules (or wherever it's supposed to install the damn things to)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:41 pm

tufty said:


do you have write permissions for /boot and /usr/lib/modules (or wherever it's supposed to install the damn things to)



you mean when I do the make modules_install?  Yeah, I've tried it both using sudo and as root (which I know is the same thing, but I wanted to be 100% that there wasn't something keeping this from working)

Pirx Danford said:


Abishur said:


That's what I meant by I can't find them.


Oh I see.

Well in cases like that the locate utilities are quite helpful (http://wiki.ubuntuusers.de/locate).
First do "updatedb", to get all files into the search database, then do a "locate lirc_mceusb".

But maybe you just need to do a "depmod -a", which will do an update to the module dependencies. After a fresh module compile this is needed to get new modules working.


I'll give it a shot when I get back home today.  I did try the sudo find / -name lirc_* to no avail.

Just to reiterate, I see the mceusb.c file in the /linux/drivers/media/rc/ directory when I build my kernel.  The steps I go through are (and this is all on the pi itself):

1. make oldconfig (using the .config file I modified to have the code I listed above)

2. make,

3. make install,

4. make modules

5. and make modules_install.

6. mkimage tool script thing

7. Remove existing kernel.img from /boot

8. Copy the new kernel.img to /boot

9. Reboot

(I've also tried redoing the make modules and make modules_install at this point just in case I was supposed to do it after the new kernel was in use)

Thinking out loud for a minute.  I know we need the kernel.img to boot, but is any part of my issue that I need to copy a non .img version of my kernel to some folder on the pi?
Dear forum: Play nice ;-)

Pirx-Danford
Posts: 62
Joined: Thu Oct 06, 2011 2:05 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 2:55 pm

Abishur said:


Thinking out loud for a minute.  I know we need the kernel.img to boot, but is any part of my issue that I need to copy a non .img version of my kernel to some folder on the pi?


Nah thats irrelevant...

The important thing for modules to work is that they match the kernel you boot.
So do a "cat  /proc/version" and make sure the compiled modules match the kernel.
Usually all compiled modules are found in their respective kernelversion as subfolders of the folder "/lib/modules"

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 6:56 pm

Pirx Danford said:


Abishur said:


Thinking out loud for a minute.  I know we need the kernel.img to boot, but is any part of my issue that I need to copy a non .img version of my kernel to some folder on the pi?


Nah thats irrelevant...

The important thing for modules to work is that they match the kernel you boot.
So do a "cat  /proc/version" and make sure the compiled modules match the kernel.
Usually all compiled modules are found in their respective kernelversion as subfolders of the folder "/lib/modules"



yep they match.

The depmod -a didn't help
Dear forum: Play nice ;-)

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 7:11 pm

Are you sure the modules are actually being compiled?

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 7:13 pm

tufty said:


Are you sure the modules are actually being compiled?



I am not.  I was actually researching how to manually compile a .ko off the .c but if there's a way to track in down on this end that would be nice too
Dear forum: Play nice ;-)

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 7:22 pm

Abishur said:


tufty said:


Are you sure the modules are actually being compiled?


I am not.  I was actually researching how to manually compile a .ko off the .c but if there's a way to track in down on this end that would be nice too


IIRC, the object files reside alongside the source files.  Which would mean that if you go to where the source for the module lives and there's no .o files, it's not being compiled and it's probably a configuration error.  If you look somewhere you're *sure* has been compiled, you can double-check my first assumption, of course.

Otherwise - the hell if I know.

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 7:24 pm

You are correct, there is no .o file.  Well, that's one more mystery to track down I guess.
Dear forum: Play nice ;-)

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 7:32 pm

Eh it's not worth it.  There are tons of problems apparently with my setup and LIRC.  I bought "flirc" and we'll see how that goes.  At least the compile in general seems to have worked
Dear forum: Play nice ;-)

Steady_Bear
Posts: 110
Joined: Sat Jan 14, 2012 12:06 pm

Re: How to Compile Kernel for R-pi? [SOLVED]

Tue May 08, 2012 9:21 pm

In case you wish to come back to this in the future (or for other folk).

From what you've said you altered the file called .config so the modules you wanted went from XXX=n to XXX=m (or =y), then you ran 'make oldconfig'.

I've just given this a quick try on my system - about time I update the kernel it's a few months old now .

1) Creating a .config file* (either through make [menu|old|x]config).

2) Editing an option manually using nano (or editor of choice).

3) Running 'make oldconfig'

Step 3 effectively undoes step 2, as it looks at the oldconfig file and resets everything to that. Only options that weren't available to the old kernel should be spared.

You should run 'make oldconfig', then edit the file with 'make menuconfig', then 'make' etc. Don't run oldconfig after customisation.

Hope this helps.
* Not sure about you, but they expect me to supply my own .config (does Debian/'whoever produced the Pi port' provide a default .config with the source?).

User avatar
eshatohhin
Posts: 11
Joined: Tue May 15, 2012 12:27 pm
Location: Estonia

Re: How to Compile Kernel for R-pi? [SOLVED]

Thu May 17, 2012 3:39 pm

eeh, it took me almost 6 hours to compile the kernel on the board.

Return to “Beginners”