对“cnss_get_platform_cap”的未定义引用

undefined reference to `cnss_get_platform_cap'

我正在编译 Android 内核 3.18。 我收到这个错误

drivers/built-in.o: In function `enable_extldo':
/home/vinay/customKernel/3.18/kernel_yu_msm8937/drivers/bluetooth/bluetooth-power.c:307: undefined reference to `cnss_get_platform_cap'
/home/vinay/customKernel/3.18/kernel_yu_msm8937/drivers/bluetooth/bluetooth-power.c:307:(.text+0x5c45bc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `cnss_get_platform_cap'
Makefile:951: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

这是source code 我正在使用 aarch64-linux-android-4.9 工具链

我在尝试为 MI 设备编译内核时遇到了同样的问题。

首先你可以看到函数 cnss_get_platform_cap 是在 cnss.h 中声明的,它位于 include/net:

然后你打开这个文件你会发现这个函数被声明为一个外部函数:

所以这里只是声明,不是实现。

然后我们挖了一个功能在哪里,我用find命令找到了所有cns相关的驱动文件,我发现这个功能在./net/wireless/cnss/cnss_pci.c

中实现了

我们可以看到,函数在这里,编译后将是一个导出的符号。

并且你可以记录下你的编译过程,你会发现实际上编译成功了bluetooth-power.c

只是makefile link vmlinux 的时候就会出问题。所以我们到了。我查了一下日志,没有发现cnss_pci.c编译过,只有cnss_common.c编译过,我们打开net/wireless/cnss/

中的子makefile

你会发现你需要在你的 defconfig 文件中添加一个项目来编译 cnss_pci.c'CONFIG_CNSS_PCI=y'。我将它添加到 arch/arm64/configs/xxx_defconfig 中的 defconfig 文件中并解决了这个问题。

我刚刚尝试将供应商补丁合并到较新的 CAF 内核中,即使使用自动合并也有很多语法错误。 至于逻辑错误和bug,我就不知道了。需要学习的东西很多。 希望你能找到出路。