sagar474
Full Member level 5
- Joined
- Oct 18, 2009
- Messages
- 285
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,318
- Location
- India,kakinada
- Activity points
- 3,123
I'm trying to build my first Linux kernel module.
I'm running ubuntu 12.10
I'm running ubuntu 12.10
Code:
/* Module source file 'crash1.c'. */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
static int hi(void)
{
printk(KERN_INFO "crash1 module being loaded.\n");
return 0;
}
static void bye(void)
{
printk(KERN_INFO "crash1 module being unloaded.\n");
}
module_init(hi);
module_exit(bye);
MODULE_AUTHOR("Robert P. J. Day, http://crashcourse.ca");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("Doing a whole lot of nothing.");
Code:
ifeq ($(KERNELRELEASE),)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
.PHONY: build clean
build:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
else
$(info Building with KERNELRELEASE = ${KERNELRELEASE})
obj-m := crash1.o
endif
Code:
make -C /lib/modules/3.5.0-17-generic/build M=/home/sagar/module1 modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-17-generic'
scripts/Makefile.build:44: /home/sagar/module1/Makefile: No such file or directory
make[2]: *** No rule to make target `/home/sagar/module1/Makefile'. Stop.
make[1]: *** [_module_/home/sagar/module1] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-17-generic'
make: *** [build] Error 2