User Tools

Site Tools


linux:kernel:kernel_drivers:hello_world

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:kernel:kernel_drivers:hello_world [2019/12/14 16:57] – created peterlinux:kernel:kernel_drivers:hello_world [2022/10/08 11:41] (current) – [Load the module] peter
Line 75: Line 75:
 endif endif
 </file> </file>
 +
 +----
 +
 +===== Compile the module =====
 +
 +<code bash>
 +make
 +</code>
 +
 +displays:
 +
 +<code bash>
 +make -C /lib/modules/4.15.0-72-generic/build M=/home/peter/prog/kernel/helloworld modules
 +make[1]: Entering directory '/usr/src/linux-headers-4.15.0-72-generic'
 +  Building modules, stage 2.
 +  MODPOST 1 modules
 +make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-72-generic'
 +</code>
 +
 +----
 +
 +===== Check the module =====
 +
 +<code bash>
 +ls hello,ko
 +</code>
 +
 +displays:
 +
 +<code bash>
 +hello.ko
 +</code>
 +
 +----
 +
 +===== Load the module =====
 +
 +<code bash>
 +sudo insmod hello.ko
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This will not display anything.
 +</WRAP>
 +
 +
 +----
 +
 +===== Check if the module is loaded =====
 +
 +<code bash>
 +lsmod
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Module                  Size  Used by
 +hello                  16384  0
 +....
 +</code>
 +
 +
 +
 +----
 +
 +===== 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 /var/log/syslog
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Dec 14 17:05:19 peter-bigmamba kernel: [74429.517770] Hello, world
 +</code>
 +
 +----
 +
 +===== Remove the module =====
 +
 +<code bash>
 +sudo rmmod hello.ko
 +</code>
 +
 +----
 +
linux/kernel/kernel_drivers/hello_world.1576342640.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki