First, Environment construction
The simplest way is to:
1. Installing VMware under Windows
2, WMware install Ubuntu (i installed ubuntu-10.04-desktop-i386 (Ubuntu distribution name, 10.04 is April 10, Desktop is the release version, I386 is the model and type of CPU))
3, at this time your environment has been set up, to how simple is more simple, is not yet do what? How can it be? This is because Ubuntu has helped us get it done.
4, just install Ubuntu How to configure screen resolution? System-preferences-monitors
5, verify: Open terminal (shortcut key: ctrl+atl+t) input uname-a or uname-r view kernel version; source directory:/USR/SRC
Second, small trial sledgehammer
1, under your user to create a new directory: study (can be arbitrary, this article takes study as an example)
2. Build two files
First one: hello.c
The code is as follows:
#include <linux/module.h>
#include <linux/init.h>
module_license ("Dual bsd/ GPL ");
static int hello_init (void)
{
PRINTK (kern_alert "Hello world.\n");
return 0;
}
static int hello_exit (void)
{
PRINTK (kern_alert "goodbye.\ n ");
return 0;
}
Module_init (hello_ INIT);
module_exit (hello_exit);
Second file: Makefile (note m uppercase and no suffix prefix, the following all and clean under the line of instructions before the blank type of a tab to build)
The contents are as follows:
Obj-m: = hello.o
Kernel_dir: =/lib/modules/$ (Shell uname-r)/build
PWD: = $ (shell pwd)
All
Make-c $ (Kernel_dir) subdirs=$ (PWD) modules
Clean
RM *.o *.ko
. Phony:clean
3, Execution (note: When prompted operation not permitted please add sudo before the instruction)
First go to directory study
Then execute: Make
Next load module to kernel: Insmod./hello.ko
See if there is a Hello module: lsmod
Last unload module: rmmod Hello
Linux Driver Development (1) Environment construction small test sledgehammer