Simple Hello World error
- From: elliotng.ee@xxxxxxxxx
- Date: 17 Aug 2006 09:16:20 -0700
Hey everyone,
I am running Linux kernel 2.6.17.8 with ubuntu.
I wrote a simple HelloWorld program, and it is not displaying the init
call on /var/log/kern.log
Here's the hello.c file:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_LICENSE("Dual BSD/GPL");
static int __init hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Here's the Makefile:
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language
ifneq ($(KERNELRELEASE),)
obj-m := HelloWorld.o
# Otherwise we were called directly from the command
# line , invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
----
sudo insmod ./hello.ko will not display anything in the log
sudo rmmod hello will display the exit statement
.
- Follow-Ups:
- Re: Simple Hello World error
- From: miline
- Re: Simple Hello World error
- Prev by Date: I2C support - 'built-in' VS modules
- Next by Date: About serial communication
- Previous by thread: I2C support - 'built-in' VS modules
- Next by thread: Re: Simple Hello World error
- Index(es):
Relevant Pages
|