Results 1 to 3 of 3
Hello, i am new to linux, C, and this forum, but i was hoping to get some help. Im trying to learn how to create kernel modules, its for a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-04-2011 #1Just Joined!
- Join Date
- Dec 2011
- Posts
- 1
problems compiling module
Hello, i am new to linux, C, and this forum, but i was hoping to get some help. Im trying to learn how to create kernel modules, its for a school project as well. I got the simple hello world module working, so i tried to make one that took parameters from terminal. It looks like this
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
static char name[] = "name";
module_param(name, char, 0);
MODULE_PARM_DESC(name, "The name of the person being greeted);
int init_module(void)
{
printk(KERN_INFO "Hello %s\n", name);
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye %s\n", name);
}
the Makefile looks like this
bj -m += hello3.o
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
when i run the make command i get no errors, but when i ls the dir afterwards i only see modules.order and Module.symvers. This is my problem, where is the .ko file? What did i do wrong?
- 12-04-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,160
Check out these links to books that document how to build kernel modules for Linux: Linux.Kernel.Development.3rd.Edition.pdf
http://lwn.net/images/pdf/LDD3/ldd3_pdf.tar.bz2Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 12-05-2011 #3Just Joined!
- Join Date
- Jul 2011
- Posts
- 16
I can see three problems here. In the Make file there should be obj-m += hello3.o. In hello3.c module_param should be declared like this:
static char *name = "name";
module_param(name, charp, 0);
And in the MODULE_PARM_DESC() there should be double quote the end


Reply With Quote
