I have some problems with compiling & building a simple gpio driver that I wrote( after THIS documentation). I have a Raspberry Pi Model B+ ( not sure if it's relevant to the question) with a fresh install of Raspbian and kernel 3.12.28+.
On Raspberry Pi, when I try to build the driver, I have the following error:
make[1]: *** /lib/modules/3.12.28+/build: No such file or directory. Stop.
and the message is correct because the output of ls /lib/modules/3.12.28+ is:
kernel modules.builtin modules.dep.bin modules.softdep
modules.alias modules.builtin.bin modules.devname modules.symbols
modules.alias.bin modules.dep modules.order modules.symbols.bin
So no build directory. I've tried some answer but none of them, after upgrading the kernel, didn't create a build directory.
Another thing that I've tried was to build the driver on my PC and after that to move it on Raspberry and install it. So I followed the documentation from Cross Compiling I built the kernel on my PC, and I changed the Makefile to execute this line:
make -C /home/arm_kernel/linux M=`pwd` modules
I executed the command make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all
and the build finished successfully. But when I tried to install the driver on my Raspberry Pi after I run sudo insmod ./gpio_driver.ko
I have the next error:
Error: could not insert module ./gpio_driver.ko: Invalid module format
The outup from dmesg is:
[ 1381.829484] gpio_driver: disagrees about version of symbol module_layout
What should I do to build a driver for Raspberry? I ran out of ideas...