`./scripts/recordmcount: Syntax error:" ("unexpectedly" reported when I compile a driver module on a raspberry Pi

I recompiled my Raspberry Pi Linux kernel to enable some debugging features. The new kernel was compiled on my X86 desktop using the tools provided by https://github.com/raspberrypi/tools . The new kernel works fine until I compile my hello-world module on it and the information below is printed:

 make -C /lib/modules/3.18.10-d0u9/build M=/home/pi/Linux-Device-Driver-3.18/1_Hello-World modules make[1]: Entering directory '/usr/src/linux-source-3.18' CC [M] /home/pi/Linux-Device-Driver-3.18/1_Hello-World/main.o ./scripts/recordmcount: 1: ./scripts/recordmcount: Syntax error: "(" unexpected scripts/Makefile.build:257: recipe for target '/home/pi/Linux-Device-Driver-3.18/1_Hello-World/main.o' failed make[2]: *** [/home/pi/Linux-Device-Driver-3.18/1_Hello-World/main.o] Error 2 Makefile:1398: recipe for target '_module_/home/pi/Linux-Device-Driver-3.18/1_Hello-World' failed make[1]: *** [_module_/home/pi/Linux-Device-Driver-3.18/1_Hello-World] Error 2 make[1]: Leaving directory '/usr/src/linux-source-3.18' Makefile:19: recipe for target 'modules' failed make: *** [modules] Error 2 

The hello-world module is pretty simple and correctly compiled on my X86 PC.

I think that maybe the way to compile the Linux kernel is wrong ...

Does anyone meet this issue?

By the way, how to cross-compile the kernel for Raspberry Pi for driver development?

+6
source share
2 answers

Without knowing more details about the version of the recompiled kernel, which os version, etc. it would be difficult to see exactly what was happening.

Based on personal experience installing Raspbian , this is a much more forgiving way to make things work on pi. This is "Debian enough", which makes working on it somewhat similar to most Linux environments.

Sparkfun has an excellent guide to installing Raspbian , and the Raspbian website has a lot of documentation and seems to be quite an active community. Sorry, I canโ€™t be more useful, but in no more detail about how the kernel was recompiled, what debugging features were enabled, etc. It is difficult to be more specific with respect to the decision.

+1
source

Where do you compile your module? on raspi?

If so, the executable. / scripts / recordmcount created during cross-compilation is built for x86 (since this is where it starts when the kernel is built), but when you build your module on Pi, you try to run its Pi Arm.

Cross compile your x86 kernel module the same way you cross-build your kernel, or just create a mcount entry for Pi and replace the x86 binary created during cross-compilation (but you may run into similar problems with other built-in time tools if you do)

+1
source

All Articles