31

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
0andriy
  • 4,183
  • 1
  • 24
  • 37
user3693586
  • 1,227
  • 5
  • 18
  • 40
  • 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 board – Santosh A Jan 13 '15 at 05:31
  • related: https://superuser.com/questions/439511/how-to-save-or-export-a-custom-linux-kernel-configuration – Ciro Santilli OurBigBook.com Jun 27 '18 at 08:00

2 Answers2

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.

0andriy
  • 4,183
  • 1
  • 24
  • 37
  • 1
    Ha! I use my_kool_ as a meta variable, myself! – Jameson Dec 13 '15 at 08:22
  • 2
    What about linux-savedefconfig? Aren't those discrete defconfigs, one for buildroot and all the accessory packages, one for the linux kernel itself? – Adam Miller Dec 17 '15 at 20:34
  • 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? – Adam Miller Dec 17 '15 at 20:41
  • Please note that after this defconfig generated will be sorted but not sorted in alphabetic order – ashish Nov 03 '17 at 05:58
  • @ashish, why do we need it sorted at all? The order currently is the order of appearance in Kconfig:s. – 0andriy Nov 03 '17 at 09:12
  • 1
    "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. – Jeremy Nov 05 '17 at 23:54
  • @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! – 0andriy Nov 07 '17 at 16:03
  • @0andriy, yes true but sometimes people expect it to be sorted alphabetically – ashish Nov 09 '17 at 06:37
  • @0andriy 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- ) – Chan Kim Oct 21 '21 at 05:06
  • @ChanKim, yes, it works. Nobody will ever break this fundamental feature of Kbuild. – 0andriy Oct 21 '21 at 06:01
  • @0andriy 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. – Chan Kim Oct 21 '21 at 14:08
  • @ChanKim, sad to be you, I have specifically added this: _"Pay attention to the filename template that is used for defconfig"_. – 0andriy Oct 21 '21 at 14:20
  • @0andriy sorry missed that. thanks! – Chan Kim Oct 22 '21 at 02:01
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.

subin
  • 490
  • 3
  • 13