Menuconfig changes result in error

Dear All,

What is the proper way to edit options with menuconfig and then build the kernel? I have followed the kernel guide, which doesn’t mention menuconfig. Each time I change settings via menuconfig, and try to build, I get this:

$ make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j28
make[1]: Entering directory '/home/someone/Documents/archive/project/jetson_build/kernelout'
  CHK     include/config/kernel.release
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  Using /home/someone/Documents/archive/project/jetson_build/Linux_for_Tegra/sources/kernel/kernel-4.9 as source for kernel
  /home/someone/Documents/archive/project/jetson_build/Linux_for_Tegra/sources/kernel/kernel-4.9 is not clean, please run 'make mrproper'
  in the '/home/someone/Documents/archive/project/jetson_build/Linux_for_Tegra/sources/kernel/kernel-4.9' directory.
make[1]: *** [/home/someone/Documents/archive/project/jetson_build/Linux_for_Tegra/sources/kernel/kernel-4.9/Makefile:1147: prepare3] Error 1
make[1]: Leaving directory '/home/someone/Documents/archive/project/jetson_build/kernelout'
make: *** [Makefile:171: sub-make] Error 2

When I make mrproper, it blows away my changes by deleting .config…

Any suggestions welcome!

Thank you.

This isn’t specific here at the start, but you might find this as a “good practice”:

  • Keep your kernel source and the output of build in separate directories. This is what the “O=...” location is…the separate output. Within the kernel source (which should be owned by root and not writable by anyone else, but is readable by all) run “sudo make mrproper”, and then never use sudo again during a build to ensure the original source does not get modified. If you follow this, then everyone will have valid source at all times when using the “O=...somewhere...” alternate output location. You could have five different output locations being built by five different people, and each would be guaranteed valid source without one configuration interfering with another.
  • There is an exception to the above, but you should probably avoid it unless you know why you are doing it: After the mrproper one might config the actual source to the currently running system (usually for package based software looking for an official kernel source to configure against).
  • When you use “O=...somewhere...” to specify the output directory, you have to always use this on all commands (other than the previously mentioned “sudo make mrproper”. This means any variant of “make tegra_defconfig” or “make menuconfig” or just “make Image” or “make modules_prepare”, so on, will always require “O=...somewhere...”.
  • You should start with any general config, e.g., “make O=...somewhere... tegra_defconfig”, and then use “make O=...somewhere... menuconfig” (or other editors…I recommend “nconfig” because it has symbol search). Note that these config editors might require “sudo apt-get install libncurses5-dev” installed.
  • Or use the currently running Jetson’s “/proc/config.gz” and put it in the “O=...somewhere...” location after using gunzip on it and renaming to “.config”. Then use the menu editor.

This script is a “helper” you can just read instead of executing, and is designed for native compile, not cross compile. (2.3 KB)

If you cross compile, then you’d also need to edit this with the correct:

export ARCH=arm64
export SRC=/where/ever/pristine/source/is/kernel-4.9
# Locations writable by your user, and not root owned:
export TEGRA_KERNEL_OUT=/some/temp/output/location/which/has/the_dot-config
export TEGRA_MODULES_OUT=/some/other/temp/location/modules
export TEGRA_FIRMWARE_OUT=/some/other/temp/location/firmware

Most people won’t build or use the firmware target. If you are building modules and not the kernel, then don’t forget build target “modules_prepare”. However, I recommend, as a sanity check, always building Image (the integrated kernel) prior to building modules.

Also, don’t forget that your “.config” in the “TEGRA_KERNEL_OUT” location should also have the “CONFIG_LOCALVERSION” set, most likely to:
…but there is more than one way to add that, so you might see different instructions which do the same thing, e.g., via an environment variable export instead of as part of the “.config”.

Thanks for the information @linuxdev, very good stuff for future builds (mine and others here).

I figured out what my exact problem was:

  1. My .config was landing in my kernel source dir, which your notes above helped sort out - thanks.

  2. When I was editing my config via: make menuconfig, I really needed to be calling: make ARCH=arm64 menuconfig, which would have been automatic if the ARCH env variable were set.