{"id":7359,"date":"2022-02-12T08:27:30","date_gmt":"2022-02-12T08:27:30","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=7359"},"modified":"2022-11-26T17:16:24","modified_gmt":"2022-11-26T11:46:24","slug":"building-in-tree-module","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/","title":{"rendered":"Linux Device Driver Programming Lecture 25- Building In tree module"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; line-height: 50px;\"><span style=\"color: #000080;\"><b>Building In tree module<\/b><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, let&#8217;s understand In-tree building. We are going to build our kernel module by adding our kernel module inside the Linux kernel source tree.&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">You have to add the Linux kernel module inside the Linux kernel source tree and let the Linux build system builds that.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">If you want to list your kernel module selection in kernel menuconfig, then you have to create and use a Kconfig file.<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">When you do menuconfig, Linux configuration will come in the form of menus, and from there, you can select or deselect your kernel modules. You can add a small menu for your kernel module, and that what&nbsp;<\/span><span style=\"font-weight: 400;\">we are going to learn in this article.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Below are the steps we follow to add the in-tree module to the kernel menu configuration.<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">1. Create a folder in drivers\/char\/my_c_dev<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">2. Copy main.c<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">3. Create Kconfig file and add the below entries<\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>menu &#8220;my custom modules&#8221;<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>config CUSTOM_HELLOWORLD<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>tristate &#8220;hello world module support&#8221;<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>default m<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 60px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>endmenu<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">&nbsp;4. Add the local Kconfig entry to upper level Kconfig<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">&nbsp;5. Create a local Makefile<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">&nbsp;6. Add obj-$(config_item) += &lt;module&gt;.o in to local Makefile<\/span><\/p>\n<p class=\"\" style=\"padding-left: 30px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">&nbsp;7. Add the local level makefile to higher level Makefile<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400;\"><span style=\"color: #000000;\">(Ref:-<\/span><span style=\"color: #3366ff;\"><a style=\"color: #3366ff;\" href=\"https:\/\/www.kernel.org\/doc\/Documentation\/kbuild\/kconfig-language.txt\" target=\"_blank\" rel=\"noopener\">https:\/\/www.kernel.org\/doc\/Documentation\/kbuild\/kconfig-language.txt<\/a><\/span><span style=\"color: #000000;\">)<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">First, what you have to do is, you have to create a folder in the Linux kernel source tree. Under the directory <\/span><b>drivers\/cha<\/b><span style=\"font-weight: 400;\">r under this path, create a directory called <\/span><b>my c_dev<\/b><span style=\"font-weight: 400;\"> as shown in Figure 1.&nbsp;<\/span><\/span><\/p>\n<figure id=\"attachment_7362\" aria-describedby=\"caption-attachment-7362\" style=\"width: 798px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"size-full wp-image-7362\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-1-10.png\" alt=\" Creating my_c_dev directory under linux_4.14\/drivers\/char path\" width=\"798\" height=\"371\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10.png 798w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-300x139.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-768x357.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-600x279.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-120x56.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-500x232.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-200x93.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-1-10-400x186.png 400w\" sizes=\"(max-width: 798px) 100vw, 798px\" \/><figcaption id=\"caption-attachment-7362\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Creating my_c_dev directory under linux_4.14\/drivers\/char path<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And there, you copy your <\/span><b>main.c&nbsp;<\/b><span style=\"font-weight: 400;\">(as shown in Figure 2).<\/span><\/span><\/p>\n<figure id=\"attachment_7363\" aria-describedby=\"caption-attachment-7363\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-7363 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-2-12.png\" alt=\"Figure 2. Copying main.c from 001hello_world to my_c_dev\" width=\"804\" height=\"365\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12.png 804w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-300x136.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-768x349.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-600x272.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-120x54.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-500x227.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-200x91.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-400x182.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-2-12-800x363.png 800w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><figcaption id=\"caption-attachment-7363\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Copying main.c from 001hello_world to my_c_dev<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">After that, create a local <\/span><b>Kconfig<\/b><span style=\"font-weight: 400;\"> file (as shown in Figure 3).<\/span><\/span><\/p>\n<figure id=\"attachment_7364\" aria-describedby=\"caption-attachment-7364\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-7364\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-3-12.png\" alt=\" Creating Kconfig file\" width=\"804\" height=\"390\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12.png 804w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-300x146.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-768x373.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-600x291.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-120x58.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-500x243.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-200x97.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-400x194.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-3-12-800x388.png 800w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><figcaption id=\"caption-attachment-7364\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Creating Kconfig file<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Open Kconfig using command <\/span><b>gedit Kconfig <\/b><span style=\"font-weight: 400;\">and add the entries as shown in Figure 4.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>Text<\/b><span style=\"font-weight: 400;\">: <\/span><b>menu \u201cfastbit custom_modules\u201d<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;config CUSTOM_HELLOWORLD<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tristate \u201chelloworld module support\u201d<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default n<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endmenu<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">A menu entry should start with a keyword &#8216;menu,&#8217; and it should end with a keyword &#8216;endmenu.&#8217;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Inside the menu, you can add a couple of config items\u2014one config item for each kernel module. You can give a short description which describes your menu.<\/span><\/p>\n<figure id=\"attachment_7365\" aria-describedby=\"caption-attachment-7365\" style=\"width: 1040px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7365\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-4-10.png\" alt=\"Kconfig entries\" width=\"1040\" height=\"511\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png 1040w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-300x147.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-768x377.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-1024x503.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-600x295.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-500x246.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-200x98.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-400x197.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10-800x393.png 800w\" sizes=\"(max-width: 1040px) 100vw, 1040px\" \/><figcaption id=\"caption-attachment-7365\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Kconfig entries<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s open the Kconfig file. Here, add menu. Add a descriptive name for your menu, your custom, or let me add &#8220;fastbit custom&nbsp; modules&#8221; After that, end this with the end menu.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We have got one, which prints &#8220;Hello World.&#8221; That&#8217;s why this is a config entry or config item for my Hello world kernel module. A config entry should start with the keyword &#8216;config.&#8217;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">In this config item, you have to use a config keyword and an identifier. This is an identifier string.&nbsp;<\/span><span style=\"font-weight: 400;\">The kernel identifies your kernel module by using this identifier. It is usually written in capital letters.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s add the first entry config entry, config. You have to give an identifier name for your config entry.&nbsp;<\/span><span style=\"font-weight: 400;\">We are adding a helloworld kernel module. Call it as CUSTOM_HELLOWORLD.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, your kernel module can be deselected, or it could be selected. And if it is selected, it could be a static module or dynamic module. That means each kernel module actually has three states.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">That is y, m, or n. That you can give by using the keyword &#8216;tristate.&#8217; You can give a short description about your custom module. Mention tristate keyword. Just give a descriptive name for this CUSTOM_HELLOWORLD module &#8220;helloworld module support. &#8220;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And after that, mention the default selection for this kernel module. M, or y, or n.&nbsp;<\/span><span style=\"font-weight: 400;\">Let me mention n. It is deselected by default m. That&#8217;s a small menu entry for our CUSTOM_MODULE.&nbsp;<\/span><span style=\"font-weight: 400;\">Let&#8217;s save this and close this.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Next, you have to add the local Kconfig entry to the upper-level Kconfig. That&#8217;s how the kernel build system will detect your local kconfig. You have to inform that to the upper-level Kconfig.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s do<\/span><b> ls.<\/b><span style=\"font-weight: 400;\"> You can see Kconfig(as shown in Figure 5 ).<\/span><\/span><\/p>\n<figure id=\"attachment_7366\" aria-describedby=\"caption-attachment-7366\" style=\"width: 802px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7366\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-5-8.png\" alt=\"Execute ls command\" width=\"802\" height=\"381\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8.png 802w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-768x365.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-600x285.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-120x57.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-500x238.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-400x190.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-5-8-800x380.png 800w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><figcaption id=\"caption-attachment-7366\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Execute ls command<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s go to the upper-level directory do <\/span><b>cd ..<\/b><span style=\"font-weight: 400;\"> , and this is an upper-level directory. Here it is <\/span><b>char<\/b><span style=\"font-weight: 400;\">, as shown in Figure 6.<\/span><\/span><\/p>\n<figure id=\"attachment_7367\" aria-describedby=\"caption-attachment-7367\" style=\"width: 656px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7367\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-6-7.png\" alt=\"Go to upper level directory\" width=\"656\" height=\"315\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7.png 656w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-300x144.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-600x288.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-120x58.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-500x240.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-200x96.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-6-7-400x192.png 400w\" sizes=\"(max-width: 656px) 100vw, 656px\" \/><figcaption id=\"caption-attachment-7367\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Go to upper level directory<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And here, open Kconfig. Go at the end and add source &#8220;drivers\/char\/ your folder\/Kconfig&#8221;(as shown in Figure 7). Save and exit.<\/span><\/p>\n<figure id=\"attachment_7368\" aria-describedby=\"caption-attachment-7368\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7368\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-7-4.png\" alt=\"Adding source &quot;drivers\/char\/ your folder\/Kconfig&quot; \" width=\"610\" height=\"500\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4.png 610w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-300x246.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-600x492.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-120x98.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-500x410.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-200x164.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-7-4-400x328.png 400w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><figcaption id=\"caption-attachment-7368\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Adding source &#8220;drivers\/char\/ your folder\/Kconfig&#8221;<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">After that, the next step is to create a local makefile. Now let&#8217;s get into our folder <\/span><b>my_c_dev.<\/b><span style=\"font-weight: 400;\"> Here, let&#8217;s create a local <\/span><b>Makefile<\/b><span style=\"font-weight: 400;\">, as shown in Figure 8.<\/span><\/span><\/p>\n<figure id=\"attachment_7369\" aria-describedby=\"caption-attachment-7369\" style=\"width: 802px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7369\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-8-3.png\" alt=\"Create a Makefile in my_c_dev directory\" width=\"802\" height=\"442\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3.png 802w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-300x165.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-768x423.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-600x331.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-120x66.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-500x276.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-200x110.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-400x220.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-8-3-800x441.png 800w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><figcaption id=\"caption-attachment-7369\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Create a Makefile in my_c_dev directory<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The next step is to add this obj variable entry into the local makefile.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">First, let&#8217;s go back to our command prompt and let&#8217;s open the makefile that we created.<\/span><\/p>\n<figure id=\"attachment_7370\" aria-describedby=\"caption-attachment-7370\" style=\"width: 735px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7370\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-9-3.png\" alt=\"Adding obj variable entry to Makefile \" width=\"735\" height=\"500\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3.png 735w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-300x204.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-600x408.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-120x82.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-500x340.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-200x136.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-9-3-400x272.png 400w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><figcaption id=\"caption-attachment-7370\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Adding obj variable entry to Makefile<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Here, you should do<\/span> <span style=\"font-weight: 400;\">obj-, but you don&#8217;t know whether it is m, or y, or n. That\u2019s what, you are going to select using the kernel menu configuration. That&#8217;s why you have to mention the config identifier what you have given in the Kconfig. This is how you should write. $ sign open the parenthesis. Inside the parenthesis, give the config identifier for your custom module, that is, we have given the name CUSTOM_HELLOWORLD. This identifier has to be preceded with the keyword CONFIG_<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">If the identifier name is CUSTOM_HELLOWORLD, you should mention it as CONFIG_CUSTOM_<\/span><span style=\"font-weight: 400;\">HELLOWORLD. Now, this identifier later will be replaced by the menu configuration selection.&nbsp;<\/span><span style=\"font-weight: 400;\">It will be replaced by either n, or y, or m, as you select in the kernel menu configuration.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to give the target. You can use = or +=, and here you have to mention module name.o. The module name is main.o the object file. Let&#8217;s save this and exit(as shown in Figure 9).<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The final step is to add the local level makefile to a higher level makefile. We have to establish the link.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go back to the command prompt. Go to the upper level and open the Makefile. And you have to go to the end here you have to add your entry as shown in Figure 10.<\/span><\/p>\n<figure id=\"attachment_7371\" aria-describedby=\"caption-attachment-7371\" style=\"width: 732px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7371\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-10-3.png\" alt=\"Adding local level Makefile to higher level Makefile\" width=\"732\" height=\"492\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3.png 732w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-300x202.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-600x403.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-120x81.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-500x336.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-200x134.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-10-3-400x269.png 400w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><figcaption id=\"caption-attachment-7371\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Adding local level Makefile to higher level Makefile<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">In char, you have created your directory, which is <\/span><b>my_c_dev.<\/b><span style=\"font-weight: 400;\"> You have to add that the way they have added here. Add obj-y because that folder is always selected. That&#8217;s why use <\/span><b>obj-y<\/b><span style=\"font-weight: 400;\">. To select that folder, we don&#8217;t have any config item remember that. <\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">To select a kernel module under that menu, we have config item. But, select our folder we don&#8217;t have any config item, that&#8217;s why, directly using <\/span><b>obj-y +=<\/b><span style=\"font-weight: 400;\"> your folder, <\/span><b>my_c_dev.<\/b><span style=\"font-weight: 400;\"> The kernel build system will come to drivers \/char, and it will read this makefile, and it will go inside our <\/span><b>my_c_dev,<\/b><span style=\"font-weight: 400;\"> that it finds another local makefile and it will use that a Kbuild variable <\/span><b>obj-<\/b><span style=\"font-weight: 400;\"> whatever the config item we have given. Let&#8217;s save and exit.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">We have completed all the steps. Let&#8217;s try the Linux menu configuration.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\"> Come back to the top-level directory of the Linux kernel tree and here execute <\/span><b>make ARCH=arm menuconfig<\/b><span style=\"font-weight: 400;\"> as shown in Figure 11.<\/span><\/span><\/p>\n<figure id=\"attachment_7372\" aria-describedby=\"caption-attachment-7372\" style=\"width: 803px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7372 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-11-3.png\" alt=\"Building In tree module\" width=\"803\" height=\"401\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3.png 803w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-300x150.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-768x384.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-600x300.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-120x60.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-500x250.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-200x100.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-400x200.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-11-3-800x400.png 800w\" sizes=\"(max-width: 803px) 100vw, 803px\" \/><figcaption id=\"caption-attachment-7372\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. make ARCH=arm menuconfig<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Go to device drivers(1). And here go to character devices(2). And here go at the end. Here you see our menu entry fastbit custom modules(3). Go inside that. This is the main menu, and here we have to list our custom modules. We have got one custom module helloworld module support(4).<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And you can see that by default, it is not selected(Figure 12).<\/span><\/p>\n<figure id=\"attachment_7373\" aria-describedby=\"caption-attachment-7373\" style=\"width: 737px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7373 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-12-3.png\" alt=\"Building In tree module\" width=\"737\" height=\"505\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3.png 737w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-300x206.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-600x411.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-120x82.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-500x343.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-200x137.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-12-3-400x274.png 400w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><figcaption id=\"caption-attachment-7373\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. Module selection in menuconfig<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">If you go to the help as shown in Figure 13, it will show you what is a symbol or identifier of that module.&nbsp;<\/span><span style=\"font-weight: 400;\">By default, it is equal to <\/span><b>n<\/b><span style=\"font-weight: 400;\">. Exit.<\/span><\/span><\/p>\n<figure id=\"attachment_7374\" aria-describedby=\"caption-attachment-7374\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7374 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-13-3.png\" alt=\"Building In tree module\" width=\"804\" height=\"412\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3.png 804w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-300x154.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-768x394.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-600x307.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-120x61.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-500x256.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-200x102.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-400x205.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-13-3-800x410.png 800w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><figcaption id=\"caption-attachment-7374\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 13. Help menu<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_7375\" aria-describedby=\"caption-attachment-7375\" style=\"width: 802px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7375 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-14-1.png\" alt=\"Building In tree module\" width=\"802\" height=\"415\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1.png 802w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-300x155.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-768x397.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-600x310.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-120x62.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-500x259.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-200x103.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-400x207.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-14-1-800x414.png 800w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><figcaption id=\"caption-attachment-7375\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 14. Selecting module as dynamic<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And you can use the space key of your computer to select between multiple options here. It would be&nbsp;<\/span><b>M<\/b><span style=\"font-weight: 400;\"> or *. Star(*) means this will be statically linked to the kernel. If it is <\/span><b>M<\/b><span style=\"font-weight: 400;\"> means, it will be built as a dynamically loadable module. I would select <\/span><b>M<\/b><span style=\"font-weight: 400;\"> here, as shown in Figure 14. and after that exit. <\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">It will ask, Do you wish to save your new configuration? You have to press &#8216;Yes&#8217; here, as shown in Figure 15.<\/span><\/span><\/p>\n<figure id=\"attachment_7376\" aria-describedby=\"caption-attachment-7376\" style=\"width: 807px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7376 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-15.png\" alt=\"Building In tree module\" width=\"807\" height=\"402\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15.png 807w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-300x149.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-768x383.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-600x299.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-120x60.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-500x249.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-200x100.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-400x199.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-15-800x399.png 800w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><figcaption id=\"caption-attachment-7376\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 15. Save configuration<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And now open the .config file which is created. Just search for your helloworld(shown in Figure 16). Let&#8217;s quit this. Don&#8217;t edit .config.<\/span><\/p>\n<figure id=\"attachment_7377\" aria-describedby=\"caption-attachment-7377\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7377 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-16.png\" alt=\"Building In tree module\" width=\"580\" height=\"471\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16.png 580w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16-300x244.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16-120x97.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16-500x406.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16-200x162.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-16-400x325.png 400w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><figcaption id=\"caption-attachment-7377\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 16. Created .config file<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s invoke the module building command again, as shown in Figure 17.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf modules -j4<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is a command we used to build the loadable modules. Here you can see that the module that we added is built. You can see that the .ko file is generated.<\/span><\/p>\n<figure id=\"attachment_7378\" aria-describedby=\"caption-attachment-7378\" style=\"width: 808px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7378 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-17.png\" alt=\"Building In tree module\" width=\"808\" height=\"405\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17.png 808w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-300x150.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-768x385.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-600x301.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-120x60.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-500x251.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-540x272.png 540w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-200x100.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-400x200.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-17-800x401.png 800w\" sizes=\"(max-width: 808px) 100vw, 808px\" \/><figcaption id=\"caption-attachment-7378\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 17. Building the module<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s get into that location <\/span><b>drivers\/char\/ my_c_dev <\/b><span style=\"font-weight: 400;\">as shown in Figure 18.<\/span><\/span><\/p>\n<figure id=\"attachment_7379\" aria-describedby=\"caption-attachment-7379\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7379 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-18.png\" alt=\"Building In tree module\" width=\"800\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-300x148.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-768x378.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-600x296.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-500x246.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-200x99.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-18-400x197.png 400w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption id=\"caption-attachment-7379\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 18. Getting into my_c_dev directory<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And here, just run modinfo (as shown in Figure 19) on that kernel module, and here you can see that it shows now in-tree is Y. That means this module is now an in-tree module. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">When you load this module into the kernel, Kernel won&#8217;t throw that warning message saying &#8216;out of tree module taints the kernel.&#8217;<\/span><\/p>\n<figure id=\"attachment_7380\" aria-describedby=\"caption-attachment-7380\" style=\"width: 804px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7380 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/02\/Figure-19.png\" alt=\"Building In tree module\" width=\"804\" height=\"397\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19.png 804w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-300x148.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-768x379.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-600x296.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-500x247.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-200x99.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-400x198.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-19-800x395.png 800w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><figcaption id=\"caption-attachment-7380\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 19. modinfo command<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">That&#8217;s about the in-tree building of kernel modules and let me know if you face any issues. Try to reproduce at your desk, I will see you in the <a href=\"http:\/\/fastbitlab.com\/linux-device-driver-programming-lecture-26-debugging-with-printk\/\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #0000ff;\">&nbsp;following article<\/span><\/a>.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 25px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\">lick here: <\/span><\/span><span style=\"color: #3366ff;\"><a style=\"color: #3366ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #0000ff;\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span>&nbsp;<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Building In tree module &nbsp; &nbsp; In this article, let&#8217;s understand In-tree building. We are going to build our kernel module by adding our kernel module inside the Linux kernel source tree.&nbsp; You have to add the Linux kernel module inside the Linux kernel source tree and let the Linux build system builds that.&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7365,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[18],"class_list":["post-7359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-linux-device-driver-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Building In tree module | Linux Device Driver Programming<\/title>\n<meta name=\"description\" content=\"Building In tree module. In this article, let&#039;s understand In-tree building. We are going to build our kernel module by adding our kernel\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building In tree module | Linux Device Driver Programming\" \/>\n<meta property=\"og:description\" content=\"Building In tree module. In this article, let&#039;s understand In-tree building. We are going to build our kernel module by adding our kernel\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-12T08:27:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-26T11:46:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1040\" \/>\n\t<meta property=\"og:image:height\" content=\"511\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Linux Device Driver Programming Lecture 25- Building In tree module\",\"datePublished\":\"2022-02-12T08:27:30+00:00\",\"dateModified\":\"2022-11-26T11:46:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/\"},\"wordCount\":1867,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Figure-4-10.png\",\"keywords\":[\"Linux Device Driver Programming Tutorial\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/\",\"name\":\"Building In tree module | Linux Device Driver Programming\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Figure-4-10.png\",\"datePublished\":\"2022-02-12T08:27:30+00:00\",\"dateModified\":\"2022-11-26T11:46:24+00:00\",\"description\":\"Building In tree module. In this article, let's understand In-tree building. We are going to build our kernel module by adding our kernel\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Figure-4-10.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/Figure-4-10.png\",\"width\":1040,\"height\":511,\"caption\":\"Figure 4. Kconfig entries\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/building-in-tree-module\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux Device Driver Programming Lecture 25- Building In tree module\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building In tree module | Linux Device Driver Programming","description":"Building In tree module. In this article, let's understand In-tree building. We are going to build our kernel module by adding our kernel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/","og_locale":"en_US","og_type":"article","og_title":"Building In tree module | Linux Device Driver Programming","og_description":"Building In tree module. In this article, let's understand In-tree building. We are going to build our kernel module by adding our kernel","og_url":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-02-12T08:27:30+00:00","article_modified_time":"2022-11-26T11:46:24+00:00","og_image":[{"width":1040,"height":511,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Linux Device Driver Programming Lecture 25- Building In tree module","datePublished":"2022-02-12T08:27:30+00:00","dateModified":"2022-11-26T11:46:24+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/"},"wordCount":1867,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png","keywords":["Linux Device Driver Programming Tutorial"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/","url":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/","name":"Building In tree module | Linux Device Driver Programming","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png","datePublished":"2022-02-12T08:27:30+00:00","dateModified":"2022-11-26T11:46:24+00:00","description":"Building In tree module. In this article, let's understand In-tree building. We are going to build our kernel module by adding our kernel","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/02\/Figure-4-10.png","width":1040,"height":511,"caption":"Figure 4. Kconfig entries"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/building-in-tree-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Linux Device Driver Programming Lecture 25- Building In tree module"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=7359"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7359\/revisions"}],"predecessor-version":[{"id":12768,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/7359\/revisions\/12768"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/7365"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=7359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=7359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=7359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}