6

I recompiled my Raspberry Pi's Linux Kernel to enable some debug features. The new kernel is compiled on my X86 desktop PC by the tools that are supplied by https://github.com/raspberrypi/tools. The new kernel seems working fine until that I compile my hello-world driver module on it, and the info 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 fairly simple, and it is compiled correctly on my X86 PC.

I think that maybe the way I compile Linux Kernel is wrong...

Has any one meet this problem?

BTW, how to correctly cross-compile kernel for raspberry Pi for driver development?

Douglas Su
  • 3,214
  • 7
  • 29
  • 58

2 Answers2

1

Without knowing more specifics about the version of the kernel that was recompiled, which os version, etc it would be difficult to be certain what exactly is going on.

Based on personal experience installing Raspbian is a much more forgiving way to get things running on the pi. It is "Debian enough" that making things work on it is somewhat similar to most Linux environments.

Sparkfun has a great guide on installing Raspbian and the Raspbian website has a lot of documentation available and seems to be a pretty active community. Sorry I can't be more helpful but without more details about how the kernel was recompiled, what debug features were enabled, etc it is hard to be more specific about a solution.

Matt
  • 545
  • 3
  • 16
1

Where are you compiling your module? on the RasPi?

If so the ./scripts/recordmcount executable created during cross compilation is built for x86 (since that is where it runs when you build the kernel) but when you are building your module on the Pi you are trying to run it on the Pi Arm.

Either cross compile your kernel module on the x86 just like you cross built your kernel OR build just recordmcount for the Pi and replace the x86 binary created during the cross compile (but you might run into similar issues with other built time tools if you do)

gby
  • 14,900
  • 40
  • 57