Kernel Configuration and Customization

OpenWrt specifies the kernel configuration for a target. It does allow some customization via the command make menuconfig but for things that are not available in OpenWrt configuration, you need to modify the kernel configuration directly located in the target/linux/<targetarch>/config* file. OpenWrt allows you to do this through the command make kernel_menuconfig.

Note that there are 2 different config files:

  • make menuconfig - main configuration for OpenWrt including all build options and package includes - often modified (.config file)
  • make kernel_menuconfig - configuration for kernel - rarely modified (target/linux/<targetarch>/config*


To modify the kernel, please go to your build directory and type the command:

make kernel_menuconfig

You should then see a screen like this:

So, for example, to turn on PPS support for GPS, please go to the following:

  1. make kernel_menuconfig - gui should come up
  2. In the gui - go down and select Device Drivers
  3. Go down and select PPS support
  4. Enable PPS support (check the checkbox by making it an asterisk by kitting the spacebar)
  5. Select anything else in PPS you may need
  6. Exit and be sure to save
  7. Rebuild everything with a make inside of the trunk directory
    make -j8 V=99
  • NOTE: Do not navigate up a directory and do a make imx6, etc as this will overwrite the config.

CAUTION: Kernel config items can be overwritten by OpenWrt Modules. Use the asterisk [*] when selecting a kernel item. Unless intended, be careful to NOT build the item as a module, represented by the letter [M]. The asterisk will build the item into the kernel as static. See the configuring modules section below for more information.

CAUTION: Kernel config can very easily be wiped out and not saved. Every time a make is ran for OpenWrt this config is overwritten because of its location, as seen below:


rerbstoesser@softdev:/usr/src/rerbstoesser/builds/gateworks-openwrt-trunk$ ls trunk/target/linux/cns3xxx/config-3.3 

Viewing Target Kernel Config

To do this on the target, you must first enable this feature in the make menuconfig while building the BSP.

Then while on the target, you can see what the kernel config is via zcat /proc/config.gz

root@OpenWrt:/# zcat /proc/config.gz 
# Automatically generated make config: don't edit
# Linux/arm Kernel Configuration
# Wed Nov 14 15:37:55 2012

Configuring Target Kernel Modules

Support for features or hardware drivers in the kernel can be built either statically or as kernel modules. Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. The trade off however is that kernel modules are loaded after static code and may result in longer boot time. This section steps for some common kernel module operations on the OpenWrt BSP.

Adding New Modules

If you wish to add a new kernel feature as a module you can do so via the menuconfig tool.

  1. Run a make kernel_menuconfig in your build directory.
  2. Find your kernel feature with the hierarchy or search tool (/ key)
  3. Use Spacebar to build as module (denoted as [M])

After rebuilding and deploying your kernel, you can verify that the new module has been loaded by booting and seeing an entry in the /etc/modules.d/ directory. Modules here are loaded in alphanumeric order.

Understand that building a feature or driver as a kernel module instead of statically built may have unintended consequences. For instance, if the code that sets the system time from the hardware clock is statically built, but the hardware clock driver is built as a module and therefore loaded afterwards, that feature will break.

Unloading and Reloading Modules

For testing and development, or to simply tune your system's overall boot speed, you may wish to unload a particular module on a running target. To maintain the ability to easily reload modules that you remove, use the following approach:

cp -a /etc/modules.d /etc/modules.old                   # Back up original modules list
rm /etc/modules.d/*ipt* ; rm /etc/modules.d/*ebtables*  # Remove unwanted modules
cp /etc/modules.old/* /etc/modules.d                    # Restore modules


Occasionally after using make kernel_menuconfig, the OpenWrt build system may start prompting you for specific kernel configuration items every time you do a 'make'.

This is the result of a kernel config which isn't specified in target/linux/<targetarch>/config or the other places used to generate kernel configuration. To work around this, add the configs you are being prompted for manually to target/linux/<targetarch/config.

For example, if you are working with Ventana (imx6 arch) and find you keep getting prompted with a question regarding GENERIC_CPUFREQ_CPU0 after doing a 'make kernel_menuconfig', simply add a proper default for 'CONFIG_GENERIC_CPUFREQ_CPU0' to the config file manually. If you wish to disable this for example:

echo "#CONFIG_GENERIC_CPUFREQ_CPU0 is not set" >> target/linux/imx6/config-3.14
Last modified 12 months ago Last modified on 08/17/16 16:03:31

Attachments (2)

Download all attachments as: .zip