Getting kernel config from defconfig - linux-kernel

The title says it all: I need the .config file that was used for compiling a kernel, but all I have is the defconfig file. I've seen instructions on how to produce the latter from the former, but not the other way around. Is it possible?

If you know the base config against which your defconfig file was generated, you can merge against it. Kernel version doesn't have to be exactly the same - new options will stay on default.
Assuming the base which your defconfig file was generated against was x86_64_defconfig (most likely) and you just have copied it into the linux source tree:
$ make mrproper
$ scripts/kconfig/merge_config.sh defconfig
If there are no errors, the .config file is now ready and you can run make to build the kernel.
For further help run $ scripts/kconfig/merge_config.sh -h or peek into the script.

You can't.
defconfig files are basic and minimalist config for one target architecture, and are just a starting point used to define a real .config.
You can instead retrieve .config used by other ways : look here on super-user

Related

Using our own local linux kernel source code on Yocto Project

We need use our customized linux kernel source code on Yocto Project, is it possible to use our kernel source code with tar file and put it on downloads folder, then use SRC_URI = file://xxx.tar.gz on bb file, let tar file to be the kernel source? if not, how to do this on our own software project development?
BR,
Jack
virtual/kernel recipes in Yocto are just simple recipes like all recipes.
So, you can set your recipe source to whatever Yocto supports as source type (git, file, ...)
For your case, you can:
Host your custom kernel in a local private git server and use git
Use a local kernel compressed source file and use file
SRC_URI = file://xxx.tar.gz is correct.
You should not put files into the download folder, bitbake will do that when it downloads something. Put it to your source if you use file://.
If your file is not found from the default FILESPATH you can add extra directories to search using something like FILESEXTRAPATHS_prepend := "${COREBASE}/../mysrc:".
Use bitbake -e [recipe] if you are unsure where the variables point to.

Buildroot - menuconfig creates config, but won't make

I'm trying to use buildroot to create a cross-compiler toolchain for MIPS64 (little endian).
I have run make menuconfig and have set the target to MIPS64 (little endian). Also I am being told that the config file has been generated and I can run make (as below)
configuration written to /home/blah/Downloads/buildroot-2018.02.6/mipsel64.config
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
So, I then run make and I get the following:
Makefile:864: *** Please configure Buildroot first (e.g. "make menuconfig"). Stop.
Any ideas?
Try to copy your buildroot config file to .config file in your buildroot directory. It may look like:
cp /home/blah/Downloads/buildroot-2018.02.6/mipsel64.config /home/blah/Downloads/buildroot-2018.02.6/.config
assuming that /home/blah/Downloads/buildroot-2018.02.6/ is your buildroot compilation directory.
Then try to do make.
Don't ask menuconfig to save to a file, just exit and answer Yes when asked Do you wish to save your new configuration?. This way it will save a file named .config, which is exactly the file neeeded for building.

Adding only one driver to linux kernel

I know that on the internet I can find same information about "adding one driver to linux kernel" but I can not get it working.
I need to compile an ADV7800driver. It is based on adv7180 driver code.
I put my driver file (adv7800.c) into /linux_source_folder/drivers/media/platform/mxc/capture folder. I also add
adv7800_converter-objs := adv7800.o
obj-$(CONFIG_MXC_ADV7800_CONVERTER)+=adv7800_converter.o
in makefile in the same folder and add information in Kconfigfile.
Then I go back to /linux_source_folder and do sudo make menuconfig and set adv7800 as a module and save config. Then sudo make defconfig, then sudo make -j4 modules (now waiting about 2 hours) and then sudo make modules install.
As a result I can see every module which I configure in menuconfig but I can not see my own module (only .c file exists).
How can I do this correctly and how can I build only this one module without building others (to same much time) ?
I do not remember exactly what happens in terms of instructions executed, but the idea of defconfig is to set a default configuration for a given architecture/platform.
If, as you said, you run sudo make defconfig after you configure your module to be compiled, most likely you loose your configuration. The defconfig should be executed first (once) and then you customize the configuration.
Regarding the compilation of a single module, I point you to an old answer
How to "make" existing Linux kernel module driver after modifying the driver source code.
One note: you should not use sudo to compile

Build kernel module for existing binary kernel

How can one build a kernel module that loads into an exiting binary kernel?
It seems that loading depends on the BuildID stored inside the module, but what is needed to match those? I expect the binary kernel to be the result of some git revision, using a default .config (copied from arch/.../configs). How can I decide which revision and .config is needed to build module that would be accepted by the existing kernel?
It seems that matching the of the ARCH and KERNELRELEASE properties as shown by uname -a is not enough.
You will need the source code for the current kernel you are running. These are usually packaged separately (you don't mention your distro). However once done you should be able to build the external module against that kernel following the instructions: Documentation/kbuild/modules.txt

Installing Linux Kernel Modules

I usually only work on the FreeBSD kernel and it is a bit different. I get up to the stage of making and installing the modules, but how do you actually boot the kernel that you just built?
Take a look here. Essentially it's something along the lines of make menuconfig, make all, make install, make install_modules, make install_firmware, and then tweaks in grub or lilo config.
Depends on how your system is configured, but you want to copy the bzImage file somewhere your boot loader can see it, then update configs (if necessary). On my gentoo box:
#pwd is /usr/src/linux
cp arch/i386/boot/bzImage /boot/default-kernel

Resources