Skip to content
Snippets Groups Projects
Commit 88b98432 authored by dex's avatar dex
Browse files

add lkm template

parent 4b8bfe6a
No related branches found
No related tags found
No related merge requests found
KDIR ?= ../kernel/linux-3.xx.y
CROSS ?= arm-linux-gnueabi- # use this if you want to cross-compile the module
PWD := $(shell pwd)
obj-m += mod.o
all:
make ARCH=arm CROSS_COMPILE=$(CROSS) -C $(KDIR) M=$(PWD) modules # cross-compilation
#make -C $(KDIR) M=$(PWD) modules # non-cross-compilation
clean:
make -C $(KDIR) M=$(PWD) clean
Minimal template for loadable kernel module (LKM) compilation.
Change `Makefile` to your needs.
Usage:
```
$ make KDIR=<path_to_kernel_out>
$ make KDIR=<path_to_kernel_out> clean
```
Copy `mod.ko` to target system.
On target:
```
$ insmod mod.ko
$ lsmod # should show LKM
```
#include <linux/module.h>
#include <linux/kernel.h>
static int __init initmodule(void ){
printk("Hello Kernel!\n");
return 0;
}
static void __exit exitmodule(void ){
return;
}
module_init( initmodule );
module_exit( exitmodule );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment