autoconf.h丢失和恢复
如果你在构建驱动或者一些特殊的内核工具时遇到如下错误:
geduer@ulan:~/gelabs/llaolao2$ make
make -C /lib/modules/5.10.110-rockchip-rk3588/build M=/home/geduer/gelabs/llaolao2 modules
make[1]: Entering directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'
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[1]: *** [Makefile:746: include/config/auto.conf] Error 1
make[1]: Leaving directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'
make: *** [Makefile:16: all] Error 2
那么说明你的autoconf.h被意外删除了。
对于这种情况,通常只要把合适版本的这个头文件恢复到原来位置就行了。
以双剑2为例,从下面链接下载这个版本的头文件:
https://gedu.oss-cn-beijing.aliyuncs.com/yl/aufoconf/sj2/autoconf.h
放到如下目录就可以了:
/usr/src/linux-headers-5.10.110-rockchip-rk3588/include/generated
如果你好奇它的内容到底是什么?其实就是配置内核选项的那些宏。
geduer@ulan:/usr/src/linux-headers-5.10.110-rockchip-rk3588/include/generated$ cat autoconf.h
/*
*
* Automatically generated file; DO NOT EDIT.
* Linux/arm64 5.10.110 Kernel Configuration
*
*/
#define CONFIG_IP6_NF_MATCH_AH_MODULE 1
#define CONFIG_COMMON_CLK_SCMI 1
#define CONFIG_MTD_SPI_NAND 1
#define CONFIG_RING_BUFFER 1
#define CONFIG_HAVE_ARCH_SECCOMP_FILTER 1
#define CONFIG_IP6_NF_SECURITY_MODULE 1
#define CONFIG_SND_PROC_FS 1
#define CONFIG_BOOTPARAM_RCU_STALL_PANIC_VALUE 0
#define CONFIG_SCSI_DMA 1
#define CONFIG_SND_SOC_ROCKCHIP_PDM 1
#define CONFIG_NETFILTER_FAMILY_BRIDGE 1
#define CONFIG_TCP_MD5SIG 1
#define CONFIG_CC_HAS_SANCOV_TRACE_PC 1
#define CONFIG_DEFAULT_INIT ""
#define CONFIG_MT7615_COMMON_MODULE 1
#define CONFIG_ARM64_PAGE_SHIFT 12
#define CONFIG_ROCKCHIP_VOP 1
#define CONFIG_CPU_PX30 1
#define CONFIG_ARCH_HAS_DEBUG_VM_PGTABLE 1
#define CONFIG_BATMAN_ADV_NC 1
#define CONFIG_DW_WATCHDOG 1
#define CONFIG_INPUT_KEYBOARD 1
#define CONFIG_BAREUDP_MODULE 1
#define CONFIG_ROCKCHIP_CLK_PVTM 1
使用ebpf时也需要这个头文件,不然会出现如下错误:
geduer@ulan:~$ sudo ./HelloYourLand.py
[sudo] password for geduer:
In file included from <built-in>:1:
././include/linux/kconfig.h:7:10: fatal error: 'generated/autoconf.h' file not found
#include <generated/autoconf.h>
^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "/home/geduer/./HelloYourLand.py", line 11, in <module>
b = BPF(text=prog)
^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/bcc/__init__.py", line 479, in __init__
raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
作者:Zhang Yinkui 创建时间:2024-10-15 10:53
最后编辑:Zhang Yinkui 更新时间:2024-11-15 17:44
最后编辑:Zhang Yinkui 更新时间:2024-11-15 17:44