Actually, cross-compiling the kernel module is very easy (or so we think!). Just ensure that you set the "special" ARCH and CROSS_COMPILE environment variables appropriately. Follow along with the following steps:
- Let's re-build our very first Hello, world kernel module for the Raspberry Pi target. Here's how to build it:
To do so without corrupting the original code, we make a new folder called cross with a copy of the (helloworld_lkm) code from Chapter 4, Writing your First Kernel Module - LKMs Part 1, to begin with.
cd <dest-dir>/ch5/cross
Here, <dest-dir> is the root of the book's GitHub source tree.
- Now, run the following command:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
But it doesn't work (or it may work; please see the following info box) straight off the bat. We get compile failures, as...