Post

linux driver Johannes4Linux lesson 1 - Hello World

Follow the post 1 to setup environment.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Download repository "Linux Driver Tutorial"
$ cd ~
$ git clone https://github.com/Johannes4Linux/Linux_Driver_Tutorial.git
$ cd Linux_Driver_Tutorial/

# Compile hello module
$ cd 01_hello/
$ make

# install module
$ sudo insmod hello.ko

# remove module
$ sudo rmmod hello.ko

hello.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <linux/module.h>
#include <linux/init.h>

int my_init(void)
{
	printk("hello - Hello, Kernel!\n");
	return 0;
}

void my_exit(void)
{
	printk("hello - Goodbye, Kernel!\n");
}

module_init(my_init);
module_exit(my_exit);

MODULE_LICENSE("GPL");

The below video demo the hello.ko behavior.


This post is licensed under CC BY 4.0 by the author.