That’s what, you are going to select using the kernel menu configuration. Here, you should do obj-, but you don’t know whether it is m, or y, or n. The next step is to add this obj variable entry into the local makefile.įirst, let’s go back to our command prompt and let’s open the makefile that we created. Here, let’s create a local Makefile, as shown in Figure 8. Adding source “drivers/char/ your folder/Kconfig”Īfter that, the next step is to create a local makefile. Go at the end and add source “drivers/char/ your folder/Kconfig”(as shown in Figure 7). Go to upper level directoryĪnd here, open Kconfig. Let’s go to the upper-level directory do cd. You can see Kconfig(as shown in Figure 5 ). You have to inform that to the upper-level Kconfig. That’s how the kernel build system will detect your local kconfig. Next, you have to add the local Kconfig entry to the upper-level Kconfig. ![]() That’s a small menu entry for our CUSTOM_MODULE. “Īnd after that, mention the default selection for this kernel module. Just give a descriptive name for this CUSTOM_HELLOWORLD module “helloworld module support. That you can give by using the keyword ‘tristate.’ You can give a short description about your custom module. That means each kernel module actually has three states. And if it is selected, it could be a static module or dynamic module. ![]() Call it as CUSTOM_HELLOWORLD.Īfter that, your kernel module can be deselected, or it could be selected. We are adding a helloworld kernel module. You have to give an identifier name for your config entry. Let’s add the first entry config entry, config. It is usually written in capital letters. The kernel identifies your kernel module by using this identifier. In this config item, you have to use a config keyword and an identifier. A config entry should start with the keyword ‘config.’ We have got one, which prints “Hello World.” That’s why this is a config entry or config item for my Hello world kernel module. Add a descriptive name for your menu, your custom, or let me add “fastbit custom modules” After that, end this with the end menu. You can give a short description which describes your menu. ![]() Inside the menu, you can add a couple of config items-one config item for each kernel module. Open Kconfig using command gedit Kconfig and add the entries as shown in Figure 4.Ī menu entry should start with a keyword ‘menu,’ and it should end with a keyword ‘endmenu.’ Copying main.c from 001hello_world to my_c_devĪfter that, create a local Kconfig file (as shown in Figure 3). ![]() Creating my_c_dev directory under linux_4.14/drivers/char pathĪnd there, you copy your main.c (as shown in Figure 2). Under the directory drivers/cha r under this path, create a directory called my c_dev as shown in Figure 1. Add the local level makefile to higher level Makefileįirst, what you have to do is, you have to create a folder in the Linux kernel source tree. Add the local Kconfig entry to upper level KconfigĦ. Create Kconfig file and add the below entriesĤ. Create a folder in drivers/char/my_c_devģ. You can add a small menu for your kernel module, and that what we are going to learn in this article.īelow are the steps we follow to add the in-tree module to the kernel menu configuration.ġ. When you do menuconfig, Linux configuration will come in the form of menus, and from there, you can select or deselect your kernel modules.
0 Comments
Leave a Reply. |