提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔
文章目錄
- 一、報錯
- 二、解決方法
- 1.先編譯linux內核源碼
- 2.再重新編譯驅動程序
一、報錯
在編譯驅動程序過程中,經常碰到的一個小問題:
make -C /home/lubancat/LubanCat_SDK/kernel M=/home/lubancat/lubancat_rk_code_storage/linux_driver/device_tree modules
make[1]: Entering directory '/home/lubancat/LubanCat_SDK/kernel'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.
Makefile:630: include/config/auto.conf: No such file or directory
make[1]: *** [Makefile:691: include/config/auto.conf] Error 1
make[1]: Leaving directory '/home/lubancat/LubanCat_SDK/kernel'
make: *** [Makefile:10: all] Error 2
二、解決方法
1.先編譯linux內核源碼
步驟1如下:
lubancat@lubancat-vm:~/LubanCat_SDK/kernel$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- lubancat2_defconfigHOSTCC scripts/basic/fixdepHOSTCC scripts/kconfig/conf.oYACC scripts/kconfig/zconf.tab.cLEX scripts/kconfig/zconf.lex.cHOSTCC scripts/kconfig/zconf.tab.oHOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
步驟2如下:
lubancat@lubancat-vm:~/LubanCat_SDK/kernel$ make ARCH=arm64 -j4 CROSS_COMPILE=aarch64-linux-gnu- dtbs
.....等待編譯完成,這里省略中間的編譯過程,最后的輸出結果如下即可
Image Name:
Created: Tue Jul 29 14:27:08 2025
Image Type: AArch64 Linux Script (uncompressed)
Data Size: 1258 Bytes = 1.23 KiB = 0.00 MiB
Load Address: 00000000
Entry Point: 00000000
Contents:Image 0: 1250 Bytes = 1.22 KiB = 0.00 MiB
2.再重新編譯驅動程序
Makefile文件內容如下
#指定linux內核源碼的路徑
KERNEL_DIR=/home/lubancat/LubanCat_SDK/kernelARCH=arm64
CROSS_COMPILE=aarch64-linux-gnu-
export ARCH CROSS_COMPILEobj-m := get_dts_info.o
all:$(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules.PHONE:cleanclean:$(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean
直接make,即可編譯成功