Hardware Reference
In-Depth Information
NOTE
The quotes around uname -r are backtick characters. On a United States keyboard, the
backtick key is to the left of the 1 key.
This took a little more than three minutes on my Bone. The uname -r part of the com-
mand looks up what version of the kernel you are running and loads the headers for it.
Next, add the code in Example 7-2 to a file called Makefile .
Example 7-2. Simple Kernel Module (Makefile)
obj - m := hello . o
KDIR := /lib/modules/$(shell uname -r)/build
all :
< TAB > make - C $ ( KDIR ) M = $$PWD
clean :
< TAB > rm hello . mod . c hello . o modules . order hello . mod . o Module . symvers
NOTE
Replace the two instances of <TAB> with a tab character (the key left of the Q key on a Un-
ited States keyboard). The tab characters are very important to makefiles and must appear as
shown.
Now, compile the kernel module by using the make command:
bone# make
make -C /lib/modules/3.8.13-bone67/build \
SUBDIRS=/root/cookbook-atlas/images/kernel/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.8.13-bone67'
CC [M] /root/cookbook-atlas/images/kernel/hello/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/cookbook-atlas/images/kernel/hello/hello.mod.o
LD [M] /root/cookbook-atlas/images/kernel/hello/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.8.13-bone67'
Search WWH ::




Custom Search