User avatar
ric96
Posts: 1253
Joined: Sun Mar 17, 2013 6:03 am
Location: NOIDA, India

unable to compile kernel module

Fri Jul 01, 2016 7:36 am

i just wanted to compile a simple hello-world kernel module but it ends up in the following error.

Code: Select all

pi:helloworld $ sudo make
make -C /lib/modules/4.4.13-v7+/build M= modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.13-v7+'
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[2]: *** No rule to make target 'arch/arm/tools/gen-mach-types', needed by 'include/generated/mach-types.h'.  Stop.
arch/arm/Makefile:315: recipe for target 'archprepare' failed
make[1]: *** [archprepare] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.13-v7+'
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2
pi:helloworld $ 
My apologies for shameless YouTube Plugs...
youtube.com/sahajsarup
twitter @sahajsarup
skype srics1996
e-mail: [email protected]
Blog: http://www.geektillithertz.com/wordpress
Web: http://www.geektillithertz.com

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6461
Joined: Fri Jul 29, 2011 5:36 pm

Re: unable to compile kernel module

Sat Jul 02, 2016 6:05 am

A bit more information would be good. Where did you get the headers from? What kernel package do you have installed? What does uname -a say? Can you post your example? Why are you running 'make' as root?

User avatar
MartyMacGyver
Posts: 32
Joined: Sat Jan 26, 2013 1:37 am

Re: unable to compile kernel module

Mon Jul 25, 2016 1:10 am

As a followup, those headers are probably from the "raspberrypi-kernel-headers" package:
raspberrypi-kernel-headers (1.20160620-1 Raspberry Pi Foundation:stable [armhf])
which currently populates the /usr/src/linux-headers-4.4.13-v7+ tree.

I learned today that this exists even though it's rather old versus current kernels being installed by rpi-update - handy, but only if you're using that particular kernel it seems. I'm glad to see kernel headers finally being distributed, but I'm not sure why they lag the actual kernel releases, given that these headers are artifacts of the very same build.

(ShiftPlusOne - I see that we spoke a long while back about the kernel header problem - might I presume the presence of these headers now is part of the effort? Again, glad to see them, but not sure why they're not current (or how to get the current ones that align with the kernel rpi-update provides))

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6461
Joined: Fri Jul 29, 2011 5:36 pm

Re: unable to compile kernel module

Mon Jul 25, 2016 11:07 am

MartyMacGyver wrote:As a followup, those headers are probably from the "raspberrypi-kernel-headers" package:
raspberrypi-kernel-headers (1.20160620-1 Raspberry Pi Foundation:stable [armhf])
which currently populates the /usr/src/linux-headers-4.4.13-v7+ tree.

I learned today that this exists even though it's rather old versus current kernels being installed by rpi-update - handy, but only if you're using that particular kernel it seems. I'm glad to see kernel headers finally being distributed, but I'm not sure why they lag the actual kernel releases, given that these headers are artifacts of the very same build.

(ShiftPlusOne - I see that we spoke a long while back about the kernel header problem - might I presume the presence of these headers now is part of the effort? Again, glad to see them, but not sure why they're not current (or how to get the current ones that align with the kernel rpi-update provides))
The headers are indeed there as a response to community requests. They're intended to match the kernel in the raspberrypi-kernel package, not what's the latest on github. rpi-update is used for testing and is not something most users should be using. If you would like it to install headers, that request would need to be filed here: https://github.com/Hexxeh/rpi-update.

User avatar
MartyMacGyver
Posts: 32
Joined: Sat Jan 26, 2013 1:37 am

Re: unable to compile kernel module

Mon Jul 25, 2016 10:10 pm

ShiftPlusOne wrote:The headers are indeed there as a response to community requests. They're intended to match the kernel in the raspberrypi-kernel package, not what's the latest on github. rpi-update is used for testing and is not something most users should be using. If you would like it to install headers, that request would need to be filed here: https://github.com/Hexxeh/rpi-update.
Thanks - good to know!

User avatar
MartyMacGyver
Posts: 32
Joined: Sat Jan 26, 2013 1:37 am

Re: unable to compile kernel module

Mon Jul 25, 2016 10:27 pm

To the original question, if you installed a more recent kernel with rpi-update, see https://github.com/notro/rpi-source/wiki for how to get the corresponding kernel source via the rpi-source script there.

boeboe
Posts: 5
Joined: Wed Aug 24, 2011 7:56 pm

Re: unable to compile kernel module

Sun Oct 23, 2016 11:41 pm

I finally got around my missing Build Includes to this point:
checking for /lib/modules/4.1.19+/build/include... yes
by downloading the correct version from https://www.niksula.hut.fi/~mhiienka/Rp ... eaders-rpi/
and installing it with:

Code: Select all

sudo dpkg -i linux-headers-4.1.19+_4.1.19+-2_armhf.deb
Thanks to ~mhiienka,
My kernel was updated apparently but no headers to be found anywhere (also

Code: Select all

sudo rpi-update
failed on numerous fronts because it does not expect python3)

Boeboe

shahab.kalantar
Posts: 1
Joined: Wed May 31, 2017 4:46 pm

Re: unable to compile kernel module

Sun Jun 04, 2017 5:27 am

Hi,

Did you manage to solve your problem? It seems like the experts here don't know exactly what this error means.
I have the same problem on my raspberry pi zero and I'm stuck.
Question is where can we find someone who actually knows what this "gen-mach-types" is and what makefile is responsible for automatically making "mach-types.h".

People just pass you on to this or that forum.

Return to “General discussion”