Version 3 (modified by 6 years ago) ( diff ) | ,
---|
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*
Tutorial
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:
- make kernel_menuconfig - gui should come up
- In the gui - go down and select Device Drivers
- Go down and select PPS support
- Enable PPS support (check the checkbox by making it an asterisk by kitting the spacebar
- Select anything else in PPS you may need
- Exit and be sure to save
- 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. DO NOT turn it into a module, represented by the letter M. The asterisk will build the item into the kernel as static CAUTION: Kernel config can very easily be wiped out and not saved. Everytime a make is ran for open wrt it is overwritten because of the location of it, as seen below:
EXAMPLE:
rerbstoesser@softdev:/usr/src/rerbstoesser/builds/gateworks-openwrt-trunk$ ls trunk/target/linux/cns3xxx/config-3.3
Target Kernel Config
While on the target, you can see what the kernel config is:
root@OpenWrt:/# zcat /proc/config.gz # # Automatically generated make config: don't edit # Linux/arm 2.6.39.2 Kernel Configuration # Wed Nov 14 15:37:55 2012 # CONFIG_ARM=y CONFIG_MIGHT_HAVE_PCI=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y CONFIG_GENERIC_GPIO=y # CONFIG_ARCH_USES_GETTIMEOFFSET is not set CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y CONFIG_KTIME_SCALAR=y CONFIG_HAVE_PROC_CPU=y CONFIG_STACKTRACE_SUPPORT=y CONFIG_LOCKDEP_SUPPORT=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_RWSEM_GENERIC_SPINLOCK=y ........... .............
To do this on the target, you must first enable this feature in the make menuconfig while building the BSP.
Troubleshooting
Occasionally after using 'make kernelmenuconfig', 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
Making Edits to Kernel Files and Rebuilding
Typically this would be done via a patch in OpenWrt.
However, it is possible to edit a kernel .c file in an existing build and then rebuild with the changes.
Example given below for Gateworks OpenWrt 16.02
- Edit kernel file in build dir:
vi build_dir/target-arm_cortex-a9+neon_musl-1.1.12_eabi/linux-imx6/linux-4.4/drivers/net/usb/qmi_wwan.c
- Recompile kernel
make target/linux/compile
- Push artifacts to OpenWrt build system
make target/linux/install
- Recompile OpenWrt .ubi images (for Ventana NAND)
make -C gateworks/ imx6