Results 1 to 2 of 2
I have been wanting to work on developing Linux, and one of the problems I have is that most of the documentation out there for developing Linux modules is outdated ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-02-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 67
How do I make a simple hello world module in Linux?
I have been wanting to work on developing Linux, and one of the problems I have is that most of the documentation out there for developing Linux modules is outdated (or atleast all the documentation I have found). I read in a book called "Linux device drivers" that it got all of its information about kernel development from the documentation that comes with the kernel source code.
However I haven't been able to find the documentation on how to write a simple module. I am using Linux version 2.6.32-32-generic.
- 08-09-2011 #2Just Joined!
- Join Date
- Jul 2011
- Posts
- 12
Here is a example code
And a makefileCode:#include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/syscalls.h> // **************************************************************************** // Inicializacion del modulo // Funcion de registracion para el evento // **************************************************************************** static int __init hello(void) { printk(KERN_EMERG "Hello!!.\n"); return 0; } // **************************************************************************** // Desinicializacion del modulo // Funcion para desregistracion del el evento // **************************************************************************** static void __exit bye(void) { printk(KERN_EMERG "Bye!!.\n"); } module_init(hello); module_exit(bye); MODULE_DESCRIPTION("Hello"); MODULE_AUTHOR("Me"); MODULE_LICENSE("GPL"); MODULE_VERSION("1.00");
then run make.Code:# Makefile for the hello # Modify the path to the kernel sources ifneq ($(KERNELRELEASE),) obj-m := drvhello.o else # Path to the kernel sources # Adapt the path to your system setup KDIR :=$(HOME)/dev/linux-2.6.27.5 # Current directory PWD := $(shell pwd) all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules endif
then insmod drvhello.ko


Reply With Quote
