13

I'm trying to build module.

But here's some issues.

ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it.

WARNING: Symbol version dump ./Module.symvers is missing; modules will have no dependencies and modversions.`

And here's my makefile

ifeq ($(KERNELRELEASE),)


KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

modules:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
    $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules modules_install clean

else
    # called from kernel build system: just declare what our modules are
    obj-m := hello.o hellop.o seq.o jit.o jiq.o sleepy.o complete.o \
             silly.o faulty.o kdatasize.o kdataalign.o
endif

I tried building like this:

export KERNELDIR=/path/to/extern/linux/source
make

How can I solve this problem?

Stephen Newell
  • 7,330
  • 1
  • 24
  • 28
Woo-Hyun
  • 131
  • 1
  • 1
  • 4
  • 1
    What is unclear in phrase "include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it."? The error itself means that kernel source directory, which you point to, isn't ready for build neither kernel itself nor modules for it. – Tsyvarev May 16 '18 at 07:19
  • 1
    @Tsyvarev Thank you for your comment. – Woo-Hyun May 18 '18 at 07:40
  • 1
    @Woo-Hyun, could you solve the problem? – russoue Nov 01 '18 at 19:52
  • 1
    @Tsyvarev well in my case, I get the same error if my custom kernel module is included and get no error if I exclude my kernel module. That means that kernel source directory is ready to build kernel and is valid. – Dr. Andrey Belkin Feb 24 '20 at 13:49
  • @Woo-Hyun if this helped you; please consider clicking the "accept" button ^_^ – William Martens Jan 12 '23 at 19:02

3 Answers3

16

re-install the linux-headers.


prerequisites

  • terminal access(bash presumably)
  • root privileges
    • (or a user who can do 'sudo')

First, we try to re install (using APT) the linux-headers package -but adding your specific kernel version. Which is determined by the following command: $(uname -r)

and to do it all in one line:


sudo apt install --reinstall linux-headers-$(uname -r)

Then, as we talk about the kernel, and making changes to it (quite major too, a reinstall of a kernel that is) we want to reboot as soon as the APT command is done:


sudo reboot

If you get it couldn't find any package, (or similar) (from apt) try apt update and re-try the above.


Logs Do check /var/log/kern.log for any messages that is,

  • cat /var/log/kern.log
William Martens
  • 753
  • 1
  • 8
  • 27
3

I solved this problem with the following commands:

  1. From your built sources take the most recent .config file with kernel configuration. Copy it to kernel-source directory (e.g.: build/tmp/work-shared/lmm-corei7/kernel-source).
  2. Run make prepare.
Dr. Andrey Belkin
  • 795
  • 1
  • 9
  • 28
  • 1
    didn't quite understand from where to copy the file, sorry if it's because of my poor english knowledge or poor linux knowledge haha – Daniel Saito Jun 18 '21 at 01:12
  • @DanielSaito No worries at all, I am a bit unsure myself, where would we try to copy it from and to? copy there .config file is a bit broad :) – William Martens Jun 19 '21 at 10:55
  • 1
    From your built sources take the most recent .config with kernel parameters. Copy it to kernel-source directory (e.g.: build/tmp/work-shared/lmm-corei7/kernel-source). – Dr. Andrey Belkin Jun 19 '21 at 19:49
  • 1
    @Dr.AndreyBelkin Hey - Thanks for the quick explanation - sorry for late reply, (This is to show I have read the comment) – William Martens Jun 22 '21 at 16:54
1

I spent hours on the same problem, having the same error message : ERROR: Kernel configuration is invalid...

The solution was so simple... I was running sudo make and this created the errors. After having done what is suggested by William Martens (reinstall the headers and reboot), I logged as root, and the module built perfectly. To be sure, I did a second test with an admin account and sudo make, and it failed again. So I am sure this is the reason. I noticed also that after a fail, I have to reinstall the headers otherwise, even in root, it fails.

This happened on a Debian 11 with kernel 5.10.0-16-amd64.

Dysmas
  • 152
  • 11