Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Kernel: update config from command line for specific modules

To build the linux kernel from source, I would normally do something like:

make mrproper
make menuconfig
make

In the menuconfig step, I enable some modules I want to have built into the kernel that aren't part of the default config file (defconfig).

Now suppose I know in advance what modules I want to enable in menuconfig, but want to automate the build process from a script (i.e. non-interactively). I don't want to edit the .config file manually before issuing make as I may not correctly resolve the dependencies of the modules I want to install.

Is there some way of replacing the menuconfig step with something like

make updateconfig module_name

?

PS I don't want to do menuconfig the first time and then save the updated .config as a new default config.

like image 668
user12066 Avatar asked Jun 13 '16 09:06

user12066


People also ask

How do I change kernel config?

To configure the kernel, change to /usr/src/linux and enter the command make config. Choose the features you want supported by the kernel. Usually, There are two or three options: y, n, or m. m means that this device will not be compiled directly into the kernel, but loaded as a module.

How do I change the kernel parameters in Linux?

Enter the command /sbin/sysctl -a to confirm that the values are set correctly. After updating the values of the kernel parameters in the /etc/sysctl. conf file, either restart the computer, or run the command sysctl -p to make the changes in the /etc/sysctl. conf file available in the active kernel memory.

Where is .config file in Linux kernel?

config file in the root directory of the kernel tree. The configuration file itself can be generated by issuing the make menuconfig command.

What does Rmmod command do in Linux?

The rmmod command is used to remove a module from the kernel. Most of the users use modprobe with the -r option instead of using rmmod.


3 Answers

I was looking for the answer to Adding an entry to the Linux Kernel .config file

i.e. you can do:

make CONFIG_XILINX_FIXED_DEVTREE_ADDR=y

and the specified module option will be compiled in. Presumably this also takes care of the module dependencies; I've tried it on a module with some dependencies and it seems to work ok.

like image 118
user12066 Avatar answered Sep 27 '22 21:09

user12066


make menuconfig is one of five similar tools that can configure the Linux kernel source, a necessary early step needed to compile the source code. make menuconfig, with a menu-driven user interface, allows the user to choose the features of the Linux kernel (and other options) that will be compiled.

make menuconfig is tool which will load all attribute which define in Kconfig and create new .config. First you will have to add your attribute to Kconfig then it'll show in menuconfig.

 Example :
 I want to add new backlight driver in kernel.
 1. open Kconfig 'drivers/video/backlight/Kconfig' and add below line---

    config BACKLIGHT_LOCOMO
    tristate "Sharp LOCOMO LCD/Backlight Driver"
    depends on SHARP_LOCOMO
    default y
    help
      If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to
      enable the LCD/backlight driver.

    2. Add CONFIG_BACKLIGHT_LOCOMO to make file.
        obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o

Now run make mrproper and make menuconfig. It'll show in menu.


Otherwise you can manually add to .config 'CONFIG_BACKLIGHT_LOCOMO=y'.

like image 23
Arvind Yadav Avatar answered Sep 27 '22 21:09

Arvind Yadav


There is a config script in the tree that allows callers to enable and disable options in .config from the shell. It doesn't look like it does any dependency resolution, though, so perhaps it makes sense to run make olddefconfig after using it, as other comments mention.

like image 26
Simon Ruggier Avatar answered Sep 27 '22 20:09

Simon Ruggier