Difference between revisions of "Embedded-Linux-Device-Driver/C2/Simple-Loadable-Module/English"
Nancyvarkey (Talk | contribs) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 22: | Line 22: | ||
* Implement a simple '''loadable module'''. | * Implement a simple '''loadable module'''. | ||
* Create a '''Makefile.''' | * Create a '''Makefile.''' | ||
− | * Compile a '''module.''' | + | * '''Compile''' a '''module.''' |
|- | |- | ||
Line 32: | Line 32: | ||
* '''Ubuntu Linux 18.04 LTS''' operating system. | * '''Ubuntu Linux 18.04 LTS''' operating system. | ||
* '''Linux kernel '''version''' 5.0.0-31 generic.''' | * '''Linux kernel '''version''' 5.0.0-31 generic.''' | ||
− | * '''gedit | + | * '''gedit Text Editor'''. |
| style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial, I am using, | | style="border:1pt solid #000000;padding:0.176cm;"| To record this tutorial, I am using, | ||
Line 38: | Line 38: | ||
* '''Ubuntu Linux 18.04 LTS''' operating system. | * '''Ubuntu Linux 18.04 LTS''' operating system. | ||
* '''Linux kernel '''version''' 5.0.0-31 generic ''' | * '''Linux kernel '''version''' 5.0.0-31 generic ''' | ||
− | * '''gedit | + | * '''gedit Text Editor'''. |
|- | |- | ||
Line 65: | Line 65: | ||
* If not, to do the installation, follow the instructions in '''gedit''' series on this [http://spoken-tutorial.org/ https://spoken-tutorial.org] | * If not, to do the installation, follow the instructions in '''gedit''' series on this [http://spoken-tutorial.org/ https://spoken-tutorial.org] | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| * To proceed further, make sure that '''Gedit''' is installed on your system. | + | | style="border:1pt solid #000000;padding:0.176cm;"| |
− | * If not, to do the installation, follow the instructions in ''' | + | * To proceed further, make sure that '''Gedit''' is installed on your system. |
+ | * If not, to do the installation, follow the instructions in '''Gedit''' series on this website. | ||
|- | |- | ||
Line 72: | Line 73: | ||
What is a''' kernel module'''? | What is a''' kernel module'''? | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| * Code that is added to the''' kernel '''at runtime is called a '''module.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| |
− | * It extends the functionality of the '''kernel '''without the need to reboot the system. | + | * Code that is added to the''' kernel '''at '''runtime''' is called a '''module.''' |
+ | * It extends the '''functionality''' of the '''kernel '''without the need to '''reboot''' the '''system'''. | ||
− | * It communicates with the | + | * It communicates with the '''base kernel''' to complete their '''functions'''. |
|- | |- | ||
Line 90: | Line 92: | ||
Code file - sample_module.c | Code file - sample_module.c | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Please download '''simple_module dot c''' from the | + | | style="border:1pt solid #000000;padding:0.176cm;"| Please download '''simple_module dot c''' from the '''Code files''' link of this tutorial. |
+ | |||
Make use of this file while practising. | Make use of this file while practising. | ||
− | Remember the file path. | + | Remember the '''file path'''. |
|- | |- | ||
Line 101: | Line 104: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Let us open this '''file.''' | | style="border:1pt solid #000000;padding:0.176cm;"| Let us open this '''file.''' | ||
− | Open the''' terminal''' by pressing '''Ctrl+Alt+T''' | + | Open the''' terminal''' by pressing '''Ctrl+Alt+T''' keys simultaneously. |
− | + | ||
− | keys simultaneously. | + | |
− | Press the '''Enter''' key after every command. | + | Press the '''Enter''' key after every '''command'''. |
Go to the folder where '''simple_module dot c''' is saved. | Go to the folder where '''simple_module dot c''' is saved. | ||
Line 117: | Line 118: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Show the '''program''' | | style="border:1pt solid #000000;padding:0.176cm;"| Show the '''program''' | ||
+ | |||
+ | |||
Highlight'''<nowiki> <linux/init.h> </nowiki>''' | Highlight'''<nowiki> <linux/init.h> </nowiki>''' | ||
+ | |||
Highlight'''<nowiki> <linux/module.h></nowiki>''' | Highlight'''<nowiki> <linux/module.h></nowiki>''' | ||
+ | |||
Highlight'''<nowiki> <linux/kernel.h></nowiki>''' | Highlight'''<nowiki> <linux/kernel.h></nowiki>''' | ||
+ | |||
| style="border:1pt solid #000000;padding:0.176cm;"| At the start of the '''program''', there are some '''header files'''. | | style="border:1pt solid #000000;padding:0.176cm;"| At the start of the '''program''', there are some '''header files'''. | ||
Line 129: | Line 135: | ||
The''' module dot h file''' contains '''functions '''related to the '''modules'''. | The''' module dot h file''' contains '''functions '''related to the '''modules'''. | ||
− | The''' kernel dot h file''' contains functions such as '''printk.''' | + | The''' kernel dot h file''' contains '''functions''' such as '''printk.''' |
|- | |- | ||
Line 139: | Line 145: | ||
'''GPL''' means '''GNU Public License.''' | '''GPL''' means '''GNU Public License.''' | ||
− | It is otherwise called as '''GNU, '''which | + | It is otherwise called as '''GNU, '''which is a free and open-source license. |
|- | |- | ||
Line 148: | Line 154: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''MODULE_DESCRIPTION''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''MODULE_DESCRIPTION''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| You can simply describe your '''module '''using this macro . | + | | style="border:1pt solid #000000;padding:0.176cm;"| You can simply describe your '''module '''using this '''macro'''. |
+ | |||
+ | I have given the description as “'''First Linux kernel module”.''' | ||
+ | |||
+ | |- . | ||
I have given the description as “'''First Linux kernel module”.''' | I have given the description as “'''First Linux kernel module”.''' | ||
Line 162: | Line 172: | ||
So it is called as an '''initialization''' '''function''' of a '''module'''. | So it is called as an '''initialization''' '''function''' of a '''module'''. | ||
− | If this '''function''' fails then the '''error '''will be returned. | + | If this '''function''' fails then the '''error '''will be '''returned'''. |
− | It will return 0 to the '''kernel''' on successful execution. | + | It will '''return''' 0 to the '''kernel''' on successful '''execution'''. |
− | Initialization function prints a simple message and | + | '''Initialization function''' prints a simple message and '''returns''' zero. |
− | The '''module init | + | The '''module init macro''' is used to register the '''init function.''' |
|- | |- | ||
Line 180: | Line 190: | ||
The''' exit function''' will undo whatever the''' init function '''did. | The''' exit function''' will undo whatever the''' init function '''did. | ||
− | The '''module underscore exit macro | + | The '''module underscore exit macro''' is used to register the '''exit function. ''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''printk''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''printk''' | ||
Line 191: | Line 201: | ||
Click on '''close''' option. | Click on '''close''' option. | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| In '''kernel '''programming, '''printk '''is used as a | + | | style="border:1pt solid #000000;padding:0.176cm;"| In '''kernel '''programming, '''printk '''is used as a '''printing function.''' |
− | It is similar to '''printf function '''in '''C ''' | + | It is similar to '''printf function '''in '''C programming'''. |
− | Using this '''function,''' | + | Using this '''function, string data''' will get loaded in the '''kernel log buffer'''. |
− | '''printk''' has an optional | + | '''printk''' has an optional '''prefix string, Loglevel '''such as''' KERN_INFO.''' |
− | '''Loglevel '''specifies the type of message being sent to the kernel message log. | + | '''Loglevel '''specifies the type of message being sent to the '''kernel message log'''. |
'''KERN underscore INFO''' is used for informational messages. | '''KERN underscore INFO''' is used for informational messages. | ||
− | For more log levels, go through the '''Additional reading material''' link of this tutorial. | + | For more '''log levels''', go through the '''Additional reading material''' link of this tutorial. |
Press '''Ctrl + S''' keys to save the '''program '''. | Press '''Ctrl + S''' keys to save the '''program '''. | ||
Line 214: | Line 224: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| | | style="border:1pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Let us compile the code. | + | | style="border:1pt solid #000000;padding:0.176cm;"| Let us '''compile''' the code. |
|- | |- | ||
Line 226: | Line 236: | ||
Type '''gedit Makefile ''' | Type '''gedit Makefile ''' | ||
− | The '''Makefile''' is a special file containing '''shell ''' | + | The '''Makefile''' is a special file containing '''shell commands'''. |
Press '''Enter.''' | Press '''Enter.''' | ||
Line 245: | Line 255: | ||
Highlight '''clean:''' | Highlight '''clean:''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The''' obj hyphen m''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| The''' obj hyphen m variable''' tells the '''kernel Makefile '''that this '''module '''needs to be '''compiled'''. |
− | When you | + | When you '''run''' the '''make all command''', then '''commands''' under '''all''' section will be '''executed'''. |
− | If you run the '''make clean ''' | + | If you '''run''' the '''make clean command''', it executes '''commands''' under the '''clean '''section. |
|- | |- | ||
Line 258: | Line 268: | ||
Highlight '''M=$(PWD)''' | Highlight '''M=$(PWD)''' | ||
Highlight''' modules''' | Highlight''' modules''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Using '''hyphen C''', we are | + | | style="border:1pt solid #000000;padding:0.176cm;"| Using '''hyphen C''', we are '''running make command''' inside the''' kernel source directory.''' |
As you know,''' uname hyphen r''' finds the current '''Linux kernel''' version of a '''system.''' | As you know,''' uname hyphen r''' finds the current '''Linux kernel''' version of a '''system.''' | ||
Line 264: | Line 274: | ||
'''PWD '''means the '''present working directory.''' | '''PWD '''means the '''present working directory.''' | ||
− | This option tells the '''kernel | + | This option tells the '''kernel makefile''' that the '''source code '''for the '''driver''' is in '''PWD'''. |
The word '''modules''' tell the '''kernel makefile''' to build the '''modules'''. | The word '''modules''' tell the '''kernel makefile''' to build the '''modules'''. | ||
− | But it will not build the complete''' kernel source code.''' | + | But it will not '''build''' the complete '''kernel source code.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''clean''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''clean''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The word '''clean''' tells the '''kernel makefile '''to clean the generated '''object files.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| The word '''clean''' tells the '''kernel makefile''' to clean the generated '''object files.''' |
|- | |- | ||
Line 288: | Line 298: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Switch back to the '''terminal'''. | | style="border:1pt solid #000000;padding:0.176cm;"| Switch back to the '''terminal'''. | ||
− | Let us compile the '''program''' | + | Let us '''compile''' the '''program'''. |
Type '''make space all.''' | Type '''make space all.''' | ||
|- | |- | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Type''' ls '''and | + | | style="border:1pt solid #000000;padding:0.176cm;"| Type''' ls '''and press''' Enter''' |
Highlight''' ls ''' | Highlight''' ls ''' | ||
Line 299: | Line 309: | ||
Show the output | Show the output | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Now type''' ls.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| Now type '''ls.''' |
− | This command lists the '''files''' in the current '''directory.''' | + | This '''command''' lists the '''files''' in the current '''directory.''' |
− | Here, you can see the number of '''files '''created in this '''directory'''. | + | Here, you can see the number of '''files''' created in this '''directory'''. |
|- | |- | ||
Line 309: | Line 319: | ||
Highlight''' mod.c ''' | Highlight''' mod.c ''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The''' module.symvers''' file contains a list of all '''symbols''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| The '''module.symvers''' file contains a list of all '''symbols''' |
− | These '''symbols '''are exported from the '''kernel ''' | + | These '''symbols '''are exported from the '''kernel build'''. |
The '''mod.c file '''contains information about the '''module'''. | The '''mod.c file '''contains information about the '''module'''. | ||
Line 317: | Line 327: | ||
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' mod.o''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' mod.o''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| '''Mod.o''' file is '''object file''' resulting from the compilation of the '''mod.c file.''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| '''Mod.o''' file is '''object file''' resulting from the '''compilation''' of the '''mod.c file.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' .o''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' .o''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| This''' object file''' is created from the compilation of the '''module source file'''. | + | | style="border:1pt solid #000000;padding:0.176cm;"| This '''object file''' is created from the '''compilation''' of the '''module source file'''. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' modules.order''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' modules.order''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| It will list out the order in which the compilation and creation of the '''.ko file '''takes place. | + | | style="border:1pt solid #000000;padding:0.176cm;"| It will list out the order in which the compilation and creation of the '''.ko file''' takes place. |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' .ko''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight''' .ko''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| This is the final '''kernel module''' | + | | style="border:1pt solid #000000;padding:0.176cm;"| This is the final '''kernel module binary''' that is loaded into the '''kernel.''' |
|- | |- | ||
Line 335: | Line 345: | ||
Press''' Enter''' | Press''' Enter''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| Clear the screen | + | | style="border:1pt solid #000000;padding:0.176cm;"| Clear the '''screen'''. |
|- | |- | ||
Line 341: | Line 351: | ||
Press '''Enter''' | Press '''Enter''' | ||
+ | |||
+ | |||
Highlight '''modinfo''' | Highlight '''modinfo''' | ||
+ | |||
Highlight '''filename''' | Highlight '''filename''' | ||
+ | |||
Highlight '''description''' | Highlight '''description''' | ||
+ | |||
Highlight '''author, license''' | Highlight '''author, license''' | ||
+ | |||
| style="border:1pt solid #000000;padding:0.176cm;"| Let us see the details of a '''module'''. | | style="border:1pt solid #000000;padding:0.176cm;"| Let us see the details of a '''module'''. | ||
Type''' modinfo space simple_module dot ko.''' | Type''' modinfo space simple_module dot ko.''' | ||
− | This command displays information about the '''Linux kernel module. ''' | + | This '''command''' displays information about the '''Linux kernel module. ''' |
− | The '''filename''' field contains an | + | The '''filename''' field contains an '''absolute path''' to the '''.ko kernel object file.''' |
This field displays a short description of a '''module.''' | This field displays a short description of a '''module.''' | ||
− | Author field shows author and ''' | + | '''Author''' field shows author and '''License''' field shows the '''license''' of the '''module.''' |
|- | |- | ||
Line 372: | Line 388: | ||
| style="border:1pt solid #000000;padding:0.176cm;"| The''' depends''' field contains all '''modules''' on which this '''module '''depends. | | style="border:1pt solid #000000;padding:0.176cm;"| The''' depends''' field contains all '''modules''' on which this '''module '''depends. | ||
− | It is shown empty here as this '''module '''does not depend on any other '''module.''' | + | It is shown empty here as this '''module''' does not depend on any other '''module.''' |
|- | |- | ||
| style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''retpoline''' | | style="border:1pt solid #000000;padding:0.176cm;"| Highlight '''retpoline''' | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| '''Retpoline''' field indicates that the '''module '''is compiled with '''retpoline '''method. | + | | style="border:1pt solid #000000;padding:0.176cm;"| '''Retpoline''' field indicates that the '''module '''is '''compiled''' with '''retpoline '''method. |
'''Modules''' must also be compiled with a '''retpoline-aware compiler.''' | '''Modules''' must also be compiled with a '''retpoline-aware compiler.''' | ||
Line 405: | Line 421: | ||
This '''command''' removes all '''object files''' that are created after the '''compilation.''' | This '''command''' removes all '''object files''' that are created after the '''compilation.''' | ||
− | ''' | + | Type '''ls.''' |
Now there are no '''object files.''' | Now there are no '''object files.''' | ||
Line 421: | Line 437: | ||
* Implement a '''simple loadable module.''' | * Implement a '''simple loadable module.''' | ||
* Create a '''Makefile'''. | * Create a '''Makefile'''. | ||
− | * Compile a '''module.''' | + | * '''Compile''' a '''module.''' |
|- | |- | ||
Line 432: | Line 448: | ||
# Open the''' simple_module.c file''' | # Open the''' simple_module.c file''' | ||
# Change the module description''' '''using''' MODULE_DESCRIPTION macro ''' | # Change the module description''' '''using''' MODULE_DESCRIPTION macro ''' | ||
− | # Run the '''modinfo''' | + | # '''Run''' the '''modinfo command''' |
# See the output of description. | # See the output of description. | ||
Line 447: | Line 463: | ||
Spoken Tutorial workshops: | Spoken Tutorial workshops: | ||
− | | style="border:1pt solid #000000;padding:0.176cm;"| The''' Spoken Tutorial Project''' Team | + | | style="border:1pt solid #000000;padding:0.176cm;"| The''' Spoken Tutorial Project''' Team conducts workshops and gives certificates. |
− | + | ||
− | + | ||
− | + | ||
For more details, please write to us. | For more details, please write to us. |
Latest revision as of 13:19, 10 July 2020
Visual cue | Narration |
Slide 1:
Welcome slide: |
Welcome to the spoken tutorial on Simple Loadable Module. |
Slide 2:
Learning objectives:
|
In this tutorial, we will learn how to,
|
Slide 3:
System Requirements:
|
To record this tutorial, I am using,
|
Slide 4:
Prerequisites: To follow this tutorial, you should be familiar with:
|
To follow this tutorial, you should be familiar with:
If not, then go through the C/C++ and Linux spoken tutorials on this website |
Slide 5:
Gedit Installation:
|
|
Slide 6:
What is a kernel module? |
|
Narration only | I’ll start with a simple example to explain how to create a module. |
Point to the folder and file in desktop | I have saved a file simple_module dot c in a folder DeviceDriver in Desktop. |
Slide:
Code file - sample_module.c |
Please download simple_module dot c from the Code files link of this tutorial.
Make use of this file while practising. Remember the file path. |
Type gedit simple_module dot c and press Enter.
Text box |
Let us open this file.
Open the terminal by pressing Ctrl+Alt+T keys simultaneously. Press the Enter key after every command. Go to the folder where simple_module dot c is saved. Type gedit simple_module dot c |
Let us understand the code now. | |
Show the program
Highlight <linux/init.h>
|
At the start of the program, there are some header files.
Init dot h file is used to start the init process. The module dot h file contains functions related to the modules. The kernel dot h file contains functions such as printk. |
Highlight MODULE_LICENSE(“GPL”)
Highlight GPL |
Next line of code is about GPL.
GPL means GNU Public License. It is otherwise called as GNU, which is a free and open-source license. |
Highlight MODULE_AUTHOR | You can give the author name for your module using this macro as shown here. |
Highlight MODULE_DESCRIPTION | You can simply describe your module using this macro.
I have given the description as “First Linux kernel module”. |
Highlight static int init_func(void)
Highlight return(0) Highlight module_init() |
The init function will execute when a module is loaded into the kernel.
So it is called as an initialization function of a module. If this function fails then the error will be returned. It will return 0 to the kernel on successful execution. Initialization function prints a simple message and returns zero. The module init macro is used to register the init function. |
Highlight void exit_func (void)
Highlight module_exit() |
The exit function will execute when the module is unloaded from the kernel.
It is mostly used to cleanup the resources acquired by the module The exit function will undo whatever the init function did. The module underscore exit macro is used to register the exit function. |
Highlight printk
Highlight KERN_INFO Press >> Ctrl + S Press Enter Click on close option. |
In kernel programming, printk is used as a printing function.
It is similar to printf function in C programming. Using this function, string data will get loaded in the kernel log buffer. printk has an optional prefix string, Loglevel such as KERN_INFO. Loglevel specifies the type of message being sent to the kernel message log. KERN underscore INFO is used for informational messages. For more log levels, go through the Additional reading material link of this tutorial. Press Ctrl + S keys to save the program . Close the file. |
Switch back to the terminal. | Switch back to the terminal. |
Let us compile the code. | |
Type >> gedit Makefile
Highlight the makefile Press Enter |
For that, we have to create a Makefile.
Type gedit Makefile The Makefile is a special file containing shell commands. Press Enter. Create a Makefile where you have saved the simple_module dot c . |
Copy paste the makefile content | Type the code as shown. |
Highlight obj-m
Highlight simple_module.o Highlight all: Highlight clean: |
The obj hyphen m variable tells the kernel Makefile that this module needs to be compiled.
When you run the make all command, then commands under all section will be executed. If you run the make clean command, it executes commands under the clean section. |
Highlight -C
Highlight uname -r Highlight (PWD) Highlight M=$(PWD) Highlight modules |
Using hyphen C, we are running make command inside the kernel source directory.
As you know, uname hyphen r finds the current Linux kernel version of a system. PWD means the present working directory. This option tells the kernel makefile that the source code for the driver is in PWD. The word modules tell the kernel makefile to build the modules. But it will not build the complete kernel source code. |
Highlight clean | The word clean tells the kernel makefile to clean the generated object files. |
Press >> Ctrl + S
Click on the close. |
Save the file and close the editor. |
Open the terminal
Type >> make all Press Enter |
Switch back to the terminal.
Let us compile the program. Type make space all. |
Type ls and press Enter
Highlight ls Show the output |
Now type ls.
This command lists the files in the current directory. Here, you can see the number of files created in this directory. |
Highlight module.symvers
Highlight mod.c |
The module.symvers file contains a list of all symbols
These symbols are exported from the kernel build. The mod.c file contains information about the module. |
Highlight mod.o | Mod.o file is object file resulting from the compilation of the mod.c file. |
Highlight .o | This object file is created from the compilation of the module source file. |
Highlight modules.order | It will list out the order in which the compilation and creation of the .ko file takes place. |
Highlight .ko | This is the final kernel module binary that is loaded into the kernel. |
Type >> clear
Press Enter |
Clear the screen. |
Type >> modinfo simple_module.ko
Press Enter
Highlight modinfo
|
Let us see the details of a module.
Type modinfo space simple_module dot ko. This command displays information about the Linux kernel module. The filename field contains an absolute path to the .ko kernel object file. This field displays a short description of a module. Author field shows author and License field shows the license of the module. |
Highlight srcversion | The srcversion field contains the source code version used to compile a module.
It is calculated automatically at build time. |
Highlight depends | The depends field contains all modules on which this module depends.
It is shown empty here as this module does not depend on any other module. |
Highlight retpoline | Retpoline field indicates that the module is compiled with retpoline method.
Modules must also be compiled with a retpoline-aware compiler. Otherwise the kernel can be vulnerable. Retpoline technique protects the kernel from the hacker’s attacks. |
Highlight name | The name field contains the name of a module. |
Highlight vermagic | This field shows the version magic number of a module.
This version magic number is used while loading the kernel module. The version magic number of module and current kernel version should be the same. Otherwise it will fail to load in the current kernel. |
Type >> make clean
Press Enter |
Type make space clean.
This command removes all object files that are created after the compilation. Type ls. Now there are no object files. |
With this, we come to the end of this tutorial. Let us summarize. | |
Slide 6:
Summary: |
In this tutorial, we learned how to
|
Slide 7:
Assignment: |
As an assignment,
|
Slide 8:
About Spoken Tutorial Project: |
The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it. |
Slide 9:
Spoken Tutorial workshops: |
The Spoken Tutorial Project Team conducts workshops and gives certificates.
For more details, please write to us. |
Slide 10:
Forum questions: |
* Do you have questions in THIS Spoken Tutorial?
|
Slide 11:
Forum for specific questions: |
* The Spoken Tutorial forum is for specific questions on this tutorial.
|
Slide 12:
Forum for specific questions: |
* Do you have general or technical questions on Embedded Linux Device Driver?
|
Slide 13:
Acknowledgment: |
Spoken Tutorial project is funded by MHRD, Government of India. |
Slide 14:
Thank you slide: |
This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
This is Mayuri Panchakshari signing off. Thanks for watching. |