Compiling kernel module results in ERROR: Difference between revisions

From AcrodusWiki
(Created page with "This issue was present when compiling a linux device driver using make on a raspberry pi zero w 2. The below log was printed: make -C /lib/modules/6.6.31+rpt-rpi-v8/build M=/home/alex/Linux_I2C_LCD_driver2.0 modules make[1]: Entering directory '/usr/src/linux-headers-6.6.31+rpt-rpi-v8' 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 fi...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
make[1]: Entering directory '/usr/src/linux-headers-6.6.31+rpt-rpi-v8'
make[1]: Entering directory '/usr/src/linux-headers-6.6.31+rpt-rpi-v8'


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


make[2]: *** [/usr/src/linux-headers-6.6.31+rpt-common-rpi/Makefile:817: include/config/auto.conf] Error 1
make[2]: *** [/usr/src/linux-headers-6.6.31+rpt-common-rpi/Makefile:817: include/config/auto.conf] Error 1
Line 24: Line 24:


all: module dt
all: module dt
        echo Builded Device Tree Overlay and kernel module
:      echo Builded Device Tree Overlay and kernel module


module:
module:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
:      make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
dt: overlay.dts
dt: overlay.dts
        dtc -@ -I dts -O dtb -o overlay.dtbo overlay.dts
:      dtc -@ -I dts -O dtb -o overlay.dtbo overlay.dts
clean:
clean:
        make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
:      make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
        rm -rf overlay.dtbo
:      rm -rf overlay.dtbo

Latest revision as of 14:16, 30 September 2024

This issue was present when compiling a linux device driver using make on a raspberry pi zero w 2. The below log was printed:

make -C /lib/modules/6.6.31+rpt-rpi-v8/build M=/home/alex/Linux_I2C_LCD_driver2.0 modules make[1]: Entering directory '/usr/src/linux-headers-6.6.31+rpt-rpi-v8'

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.

make[2]: *** [/usr/src/linux-headers-6.6.31+rpt-common-rpi/Makefile:817: include/config/auto.conf] Error 1 make[1]: *** [/usr/src/linux-headers-6.6.31+rpt-common-rpi/Makefile:246: __sub-make] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.6.31+rpt-rpi-v8' make: *** [Makefile:9: module] Error 2

To correct this re-install the linux-headers using the command:

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

Below is a copy of the Makefile used:

obj-m = waveshare_lcd_driver.o

KVERSION = $(shell uname -r)

all: module dt

echo Builded Device Tree Overlay and kernel module

module:

make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules

dt: overlay.dts

dtc -@ -I dts -O dtb -o overlay.dtbo overlay.dts

clean:

make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
rm -rf overlay.dtbo