0% found this document useful (0 votes)
108 views11 pages

Department of Computer Science & Engineering: - + 'KLE Society's KLE Technological University HUBLI-31

This document describes creating a Linux kernel module. It provides background on kernel modules and how they allow extending kernel functionality without recompilation. It then outlines the steps to create a sample "hello world" kernel module: 1) Install linux headers, 2) Write C source code for the module, 3) Create a Makefile to compile it, 4) Use insmod to load the module and rmmod to unload it, 5) Use modinfo to view module details. The module simply prints a message via the kernel at load and unload times.

Uploaded by

kishor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views11 pages

Department of Computer Science & Engineering: - + 'KLE Society's KLE Technological University HUBLI-31

This document describes creating a Linux kernel module. It provides background on kernel modules and how they allow extending kernel functionality without recompilation. It then outlines the steps to create a sample "hello world" kernel module: 1) Install linux headers, 2) Write C source code for the module, 3) Create a Makefile to compile it, 4) Use insmod to load the module and rmmod to unload it, 5) Use modinfo to view module details. The module simply prints a message via the kernel at load and unload times.

Uploaded by

kishor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

-+

`KLE Society's
KLE Technological University
HUBLI-31

DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Report on

1. Creating a Linux Kernel module

Submitted By:

Mr.Karan Virupakshar 01FE15BCS082

Mr.Manjunath Asundi 01FE15BCS098

Mr.Krishna Kudapali 01FE15BCS088

Mr.Kishor Channal 01FE15BCS087

Under The Guidance of:

Prof.Shantala.G
Contents

S.No. Title Pno.

1. Introduction to Tiny Core 1

2. Linux Kernel Module 6

5. Stepwise Implementation 7

6. Results and Snapshots 9


Abstract

Kernel modules are pieces of code that can be loaded and unloaded into the
kernel upon demand. They extend the functionality of the kernel without the
need to reboot the system.
Custom codes can be added to Linux kernels via two methods.

The basic way is to add the code to the kernel source tree and
recompile the kernel.
A more efficient way is to do this is by adding code to the kernel
while it is running. This process is called loading the module, where
module refers to the code that we want to add to the kernel.
Introduction to Tiny Core OS:
Tiny Core Linux (TCL) is a minimal Linux operating system focusing on
providing a base system using BusyBox and FLTK, developed by Robert
Shingledecker.[3] The distribution is notable for its small size (11 to 16 MB) and
minimalism; additional functions are provided by extensions. Tiny Core Linux
is free and open source software and is licensed under the GNU General Public
License version 2. TinyCore becomes simply an example of what the core
project can produce an 16MB FLTK desktop. It is not a complete desktop nor is
all hardware completely supported. It represents only the core needed to boot
into a very minimal X desktop typically with wired internet access. The user has
complete control over which applications and/or additional hardware to have
supported, be it for a desktop, a netbook, an appliance, or server, selectable by
the user by installing additional applications from online repositories, or easily
compiling most anything you desire using tools provided.

Types of Cores:

Core : a smaller variant of Tiny Core without a graphical desktop..


Dcore : a smaller variant of Tiny Core without a graphical desktop
Core64 : a notable port of "Core" to the x86_64 architecture
CorePlus : It is composed of Tiny Core with additional functionality.
piCore : Raspberry Pi port of Core Raspberry Pi port of Core.

System Requirements:
RAM: (min) 46MB.
CPU: i486DX
Linux Kernel Module
Kernel modules are piece of code that can be loaded and unloaded from kernel
on demand.
Kernel modules offers an easy way to extend the functionality of the base kernel
without having to rebuild or recompile the kernel again. Most of the drivers are
implemented as a Linux kernel modules. When those drivers are not needed, we
can unload only that specific driver, which will reduce the kernel image size.

The kernel modules will have a .ko extension. On a normal linux system, the
kernel modules will reside inside /lib/modules/<kernel_version>/kernel/
directory.

Utilities to Manipulate Kernel Modules

1. lsmod List Modules that Loaded Already


lsmod command will list modules that are already loaded in the kernel as
shown below

2. insmod Insert Module into Kernel


insmod command will insert a new module into the kernel as shown
below...
3. modinfo Display Module Info
modinfo command will display information about a kernel module
as shown below

4. rmmod Remove Module from Kernel


rmmod command will remove a module from the kernel. You cannot
remove a module which is already used by any program.
1. Installing the linux headers

2.Summary Module Source Code


3.Create Makefile to Compile Kernel Module
The following makefile can be used to compile the above basic Source
code kernel module.

Use the make command to compile hello world kernel module as shown below.
4. Insert or Remove the Sample Kernel Module
Now that we have our hello.ko file, we can insert this module to the kernel by

using insmod command as shown below.

When a module is inserted into the kernel, the module_init macro will be

invoked, which will call the function summary_init. Similarly, when the module

is removed with rmmod, module_exit macro will be invoked, which will call the

summary_exit. Using dmesg command, we can see the output from the sample

Kernel module.
4.Modinfo to display Kernel Module
The information of the module can be displayed by using the command
modinfo as shown below.

5.rmmod to remove kernel module


The information of the module can be removed by using the command rmmod
as shown below

You might also like