Difference between .config and kconfig - linux-kernel

I am new to the kernel configuration and trying to understand the difference between these two terms:
.config
Kconfig
My understanding about .config is that it contains the information about configuration which is being used while compiling the kernel. What is the role of Kconfig then ?

As I know, The Kconfig files contain text that gets printed out when you ask for help while configuring a kernel. Your configuration choices go in the .config file.
The Kconfig files describe: the configuration symbols supported in the
build system, the logical organization and structure to group the
symbols in menus and sub-menus, and the relationships between the
different configuration symbols that govern the valid configuration
combinations.
The Kconfig File Structure

Related

Can a Linux Kernel defconfig file be sorted?

So I use defconfig files to keep the kernel settings/configuration for an embedded project.
Whenever I do changes to the actual config through means like make menuconfig and then do a make savedefconfig afterwards the resulting defconfig file looks completely different to the preexisting one. The order of contained config options seems random at least or following some order not obviously understandable.
Problem about this for me the defconfig files are not diff-able anymore.
To work around this I want to sort the defconfig file before checking it in.
This way I can perfectly track any changes using any diff-tool.
Question is:
Is there any inherent order necessary in defconfig files for the linux kernel. Will this mess with the kernel build system in any way?

Config format in Go project

The most common formats for config file are json, yaml and etc.
When we use this formats, we need to open the file and parse it into structure.
Can we declare config like a new go package and export necessary data by variables? Are there any problems or pitfalls?
The main disadvantage is that you have to ship the Go compiler and linker as part of your configuration system, because in order to load a configuration file, you have to compile the configuration file and link it into the application.
You also have to make sure that the ABI of the compiled configuration file is compatible with the ABI of the application.

How to find out list of kernel files compiled by a kernel? [duplicate]

I'm working on different Android projects and need to setup project in Source Insight for different kernel source tree.
There are many unused files in kernel, I want to find a method to pick out all .c,.h,.S files that are compiled in kernel. I was nearly crazy when I pick the source files manually.
I'd wrote a script that can pick up the files corresponding to the .o files, but there are some .o files are compiled by multiple .c files, which make it more complicated.
Is there an easier way to know what files are handled in the compiling process?
Any information would be greatly appreciated.
It's my first question in stackoverflow, I love here so much.
Thanks.
I always need to search the kernel source without looking at powerpc, ia86, sparc, alpha, infiniband, etc. Assuming you can compile the kernel, several ways of doing this:
1) $K/scripts/basic/fixdep.c is called from Makefile.build to create a .cmd file for each source which contains information about the compile options, compile source/target and dependency list. Modify this to write a separate file with just the source file or source/dependencies.
2) Hack $K/scripts/Makefile.build to log the currently compiled file. See the cmd_as_o_S and rule_cc_o_c areas.
Option #1 is the best but requires a little coding. Option #2 is easiest but a true hack, and doesn't pick up the dependencies.

Yocto kernel config propagation

In my Yocto system, I have a layer defining a bunch of patches on the linux kernel, as well as a file "defconfig" containing kernel configuration. When I modify this file, changes are reflected in the image I build.
However, a few changes are being overruled and I have a hard time figuring out how or where. I do find a bunch of defconfig files in other layers, but is there any easy way to figure out which ones are applied and in what order?
Thanks
It is not other defconfigs that overrule your configuration (at least not in an even only remotely sane setup), but configuration fragments (creating fragments). You can find out what happens exactly like that:
bitbake -e virtual/kernel | less
(you can of course choose another pager, or redirect to a file for additional processing)
And look for:
KERNEL_FEATURES
--> here you can find a list of kernel configuration fragments in the form of .scc files that are applied to your build
SRC_URI
--> this should mention the path to your defconfig file, and no second one.
Please note that this description only holds entirely true for setups that include a kernel defconfig. If you are working without one, things can be different.

buildroot for arm kernel defconfig

I am trying to build a buildroot with kernel image, and after doing make menuconfig and make, I am getting:
No kernel defconfig name specified, check your BR2_LINUX_KERNEL_DEFCONFIG setting
I can set a string to the defconfig, but I don't know what to put there.
My target system is an AT91SAM9RL board.
edit: I found out there are some pre-made config files to some devices, actually not exactly matching to my target.
You can issue the default configuration process by running make xxx_defconfig and that make target is a file in the folder arch/arm/configs/. These default configurations are not designed to exactly fit your target, but are rather meant to be a superset so you only have to modify them a bit.
The make xxx_defconfig creates your initial .config, which you can now edit through make menuconfig and make your changes. After that, you can run make which will then compile the kernel using your settings.

Resources