linux:kernel:kernel_drivers:hello_world
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux:kernel:kernel_drivers:hello_world [2019/12/14 16:57] – created peter | linux:kernel:kernel_drivers:hello_world [2022/10/08 11:41] (current) – [Load the module] peter | ||
---|---|---|---|
Line 75: | Line 75: | ||
endif | endif | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Compile the module ===== | ||
+ | |||
+ | <code bash> | ||
+ | make | ||
+ | </ | ||
+ | |||
+ | displays: | ||
+ | |||
+ | <code bash> | ||
+ | make -C / | ||
+ | make[1]: Entering directory '/ | ||
+ | Building modules, stage 2. | ||
+ | MODPOST 1 modules | ||
+ | make[1]: Leaving directory '/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check the module ===== | ||
+ | |||
+ | <code bash> | ||
+ | ls hello,ko | ||
+ | </ | ||
+ | |||
+ | displays: | ||
+ | |||
+ | <code bash> | ||
+ | hello.ko | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Load the module ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo insmod hello.ko | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check if the module is loaded ===== | ||
+ | |||
+ | <code bash> | ||
+ | lsmod | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Module | ||
+ | hello 16384 0 | ||
+ | .... | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Check message from module ===== | ||
+ | |||
+ | As mentioned above when the module was loaded it did not display that "Hello World" message. | ||
+ | |||
+ | This message is actually written to the system log. | ||
+ | |||
+ | <code bash> | ||
+ | tail / | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Dec 14 17:05:19 peter-bigmamba kernel: [74429.517770] Hello, world | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove the module ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo rmmod hello.ko | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ |
linux/kernel/kernel_drivers/hello_world.1576342640.txt.gz · Last modified: 2020/07/15 09:30 (external edit)