How to create a defconfig file from a .config?
Asked Answered
N

2

30

I have done make menuconfig for a board defconfig and modified few configurations. When I select save, a new .config was created in the Kernel top directory.

I want to create new defconfig for this .config file created.

Can I copy the .config as a new defconfig and copy to arch/arm/configs/?

$ cp .config arch/arm/configs/board_new_defconfig
Nikolos answered 12/1, 2015 at 9:47 Comment(2)
Yes, copying the file would work. But as defconfig's are know to have minimal configurations of the board it is better to remove few of the CONFIG_XXXXXX that are not arbitrary for you boardMissend
related: superuser.com/questions/439511/…Cohligan
S
58

I think you have to do just one command and use the created file as you want to.

% make savedefconfig 
% cp defconfig arch/arm/configs/my_cool_defconfig

(Pay attention to the filename template that is used for defconfig)

To get all possible targets just run

% make help

As noted by Adam Miller followed by Jeremy, users of Buildroot distribution can use wrappers for that purpose, i.e. (per Buildroot manual, section 8.1):

  • linux-savedefconfig for Linux kernel
  • barebox-savedefconfig for barebox bootloader
  • uboot-savedefconfig for U-Boot bootloader

make savedefconfig minimizes the generated defconfig skipping redundant configs that are implied by others.

Saviour answered 13/1, 2015 at 9:24 Comment(13)
Ha! I use my_kool_<foo> as a meta variable, myself!Cellular
What about linux-savedefconfig? Aren't those discrete defconfigs, one for buildroot and all the accessory packages, one for the linux kernel itself?Certiorari
You can do: make linux-savedefconfig - as per the buildroot manual. I would think that make linux-menuconfig and linux-savedefconfig correspond just as menuconfig and savedefconfig targets do, no?Certiorari
Please note that after this defconfig generated will be sorted but not sorted in alphabetic orderPak
@ashish, why do we need it sorted at all? The order currently is the order of appearance in Kconfig:s.Saviour
"make linux-savedefconfig" is only useful if you are using "buildroot" to build embedded linux, which the OP did not mention. However I added +1 to AdamMiller 's comment because this was just what I was looking for, and other buildroot users may end up here.Whiz
@Jeremy, so, make linux-savedefconfig is a wrapper in Buildroot for Linux kernel's config, correct? Okay, I'm about to update the answer, thanks!Saviour
@0andriy, yes true but sometimes people expect it to be sorted alphabeticallyPak
@Saviour Hi, I ran make defconfig and make menuconfig to remove some configs, and make. Then I did make savedefconfig and copied the new defconfig to arch/arm64/configs/def1config. And I tried make def1config but it says "make[1]: *** No rule to make target 'def1config'. Stop". Can you check if your method still works? (ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- )Charlotte
@ChanKim, yes, it works. Nobody will ever break this fundamental feature of Kbuild.Saviour
@Saviour strange, I tried fresh from linux-5.4.21 code. started with defconfig, and for test, removed PCI, sound driver, SATA driver and built the kernel just to check. and did 'make savedefconfig' and moved the defconfig to arch/arm64/configs/newconfig. When I do 'make newconfig' it gives me the same error.. I can do with saved .config file anyway.Charlotte
@ChanKim, sad to be you, I have specifically added this: "Pay attention to the filename template that is used for defconfig".Saviour
@Saviour sorry missed that. thanks!Charlotte
C
2

For your platform, in a new defconfig file, yes. In fact this is the safest way to create a new defconfig. If you manually remove config entries from an existing config file to create a new one, you are likely to get dependency issues and during build, it might restart the kernel config and give you prompts for selecting individual config options.

Coronal answered 14/1, 2015 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.