【嵌入式Linux】内核模块编译出错解决:ERROR: modpost: “xxxx“

编译报错

  MODPOST /home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/Module.symvers
ERROR: modpost: "rockchip_wifi_get_oob_irq" [/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/rtl8723ds.ko] undefined!
ERROR: modpost: "rockchip_wifi_mac_addr" [/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/rtl8723ds.ko] undefined!
ERROR: modpost: "rockchip_wifi_set_carddetect" [/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/rtl8723ds.ko] undefined!
ERROR: modpost: "rockchip_wifi_power" [/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/rtl8723ds.ko] undefined!
scripts/Makefile.modpost:169: recipe for target '/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/Module.symvers' failed
make[5]: *** [/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/Module.symvers] Error 1
make[5]: *** 正在删除文件“/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds/Module.symvers”
Makefile:1819: recipe for target 'modules' failed
make[4]: *** [modules] Error 2
make[4]: Leaving directory '/home/liefyuan/luckfox/luckfox-pico/sysdrv/source/kernel'
Makefile:2363: recipe for target 'modules' failed
make[3]: *** [modules] Error 2
make[3]: Leaving directory '/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi/rtl8723ds'
Makefile:80: recipe for target 'build-sdio' failed
make[2]: *** [build-sdio] Error 2
make[2]: Leaving directory '/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko/wifi'
Makefile:22: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/liefyuan/luckfox/luckfox-pico/sysdrv/drv_ko'
Makefile:513: recipe for target 'drv' failed
make: *** [drv] Error 2
make: Leaving directory '/home/liefyuan/luckfox/luckfox-pico/sysdrv'
[build.sh:error] Running build_driver failed!
[build.sh:error] exit code 2 from line 509:
[build.sh:info]     make -C ${SDK_SYSDRV_DIR} drv

可以初步确认是Linux内核之中有功能没有打开,导致编译这个内核ko模块无法通过。

全局查找

liefyuan@ubuntu:~/luckfox/luckfox-pico/sysdrv/source/kernel$ grep -r "rockchip_wifi_get_oob_irq" ./
./net/rfkill/rfkill-wlan.c:int rockchip_wifi_get_oob_irq(void)
./net/rfkill/rfkill-wlan.c:EXPORT_SYMBOL(rockchip_wifi_get_oob_irq);
./net/rfkill/rfkill-wlan.c:int rockchip_wifi_get_oob_irq_flag(void)
./net/rfkill/rfkill-wlan.c:EXPORT_SYMBOL(rockchip_wifi_get_oob_irq_flag);
./include/linux/rfkill-wlan.h:int rockchip_wifi_get_oob_irq(void);
./include/linux/rfkill-wlan.h:int rockchip_wifi_get_oob_irq_flag(void);
./drivers/net/wireless/rockchip_wlan/rtl8723cs/platform/platform_ops.c:	oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rtl8821cs/platform/platform_ops.c:	oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rtl8189fs/platform/platform_ops.c:	oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rtl8188fu/platform/platform_ops.c:	//oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_gpio.c:	host_oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_gpio.c:	irq_flags = rockchip_wifi_get_oob_irq_flag();
./drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_indep_power/dhd_gpio.c:	host_oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_indep_power/dhd_gpio.c:	irq_flags = rockchip_wifi_get_oob_irq_flag();
./drivers/net/wireless/rockchip_wlan/rtl8723ds/platform/platform_ops.c:	oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/ssv6xxx/platforms/rk3126-generic-wlan.c:extern int rockchip_wifi_get_oob_irq(void);
./drivers/net/wireless/rockchip_wlan/ssv6xxx/platforms/rk3126-generic-wlan.c:    oob_irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_gpio.c:    irq = rockchip_wifi_get_oob_irq();
./drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_gpio.c:	irq_flags = rockchip_wifi_get_oob_irq_flag();

关键信息

./net/rfkill/rfkill-wlan.c:int rockchip_wifi_get_oob_irq(void)
./net/rfkill/rfkill-wlan.c:EXPORT_SYMBOL(rockchip_wifi_get_oob_irq);
./include/linux/rfkill-wlan.h:int rockchip_wifi_get_oob_irq(void);

参考:https://blog.csdn.net/m0_61737429/article/details/129842585

rfkill-wlan.c文件入手

在这里插入图片描述
里面的Makefile文件

# SPDX-License-Identifier: GPL-2.0-only
#
# Makefile for the RF switch subsystem.
#

rfkill-y			+= core.o
rfkill-$(CONFIG_RFKILL_INPUT)	+= input.o
obj-$(CONFIG_RFKILL)		+= rfkill.o
obj-$(CONFIG_RFKILL_GPIO)	+= rfkill-gpio.o
rfkill-rk-y			+= rfkill-wlan.o rfkill-bt.o
obj-$(CONFIG_RFKILL_RK)		+= rfkill-rk.o

Kconfig

# SPDX-License-Identifier: GPL-2.0-only
#
# RF switch subsystem configuration
#
menuconfig RFKILL
	tristate "RF switch subsystem support"
	help
	  Say Y here if you want to have control over RF switches
	  found on many WiFi and Bluetooth cards.

	  To compile this driver as a module, choose M here: the
	  module will be called rfkill.

# LED trigger support
config RFKILL_LEDS
	bool
	depends on RFKILL
	depends on LEDS_TRIGGERS = y || RFKILL = LEDS_TRIGGERS
	default y

config RFKILL_INPUT
	bool "RF switch input support" if EXPERT
	depends on RFKILL
	depends on INPUT = y || RFKILL = INPUT
	default y if !EXPERT

config RFKILL_GPIO
	tristate "GPIO RFKILL driver"
	depends on RFKILL
	depends on GPIOLIB || COMPILE_TEST
	default n
	help
	  If you say yes here you get support of a generic gpio RFKILL
	  driver.

config RFKILL_RK
	tristate "Rockchip RFKILL driver"
	depends on RFKILL
	depends on MMC
	depends on ARCH_ROCKCHIP
	default n
	help
	  Rockchip rfkill driver for rk29/rk3X

结果确认

到这里,就基本上就确定了,需要打开内核的RFKILL
在这里插入图片描述
在这里插入图片描述OK!模块编译通过!

Linux设备驱动程序学习(0)-Hello, world!模块 Linux设备驱动程序学习(0) -Hello, world!模块 一个学习Linux设备驱动程序都会碰到的第一个例程: #include #include MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, Tekkaman Ninja !\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, Tekkaman Ninja !\n Love Linux !Love ARM ! Love KeKe !\n"); } module_init(hello_init); module_exit(hello_exit); 我将其复制到我的工作目录,并编写了一个简单的Makefile文件: KERNELDIR = /home/tekkaman/working/SBC2440/linux-2.6.22.2 # The current directory is passed to sub-makes as argument PWD := $(shell pwd) INSTALLDIR = /home/tekkaman/working/rootfs/lib/modules CROSS_COMPILE =/home/tekkaman/working/crosstool-gcc410-k26222/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu- CC = $(CROSS_COMPILE)gcc obj-m := hello.o modules: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules modules_install: cp hello.ko $(INSTALLDIR) clean: rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions .PHONY: modules modules_install clean 说实话,以上是我参考了《Linux设备驱动程序(第3版)》的Makefile源码修改得来的。我对Makefile不是很了解,是该好好学习学习了! 然后就是make modules 、 make modules_install 。 [root@Tekkaman-Ninja Helloworld]# make modules make -C /home/tekkaman/working/SBC2440/linux-2.6.22.2 M=/home/tekkaman/working/Linuxdriver/Helloworld modules make[1]: Entering directory `/home/tekkaman/working/SBC2440/linux-2.6.22.2' CC [M] /home/tekkaman/working/Linuxdriver/Helloworld/hello.o Building modules, stage 2. MODPOST 1 modules CC /home/tekkaman/working/Linuxdriver/Helloworld/hello.mod.o LD [M] /home/tekkaman/working/Linuxdriver/Helloworld/hello.ko make[1]: Leaving directory `/home/tekkaman/working/SBC2440/linux-2.6.22.2' [root@Tekkaman-Ninja Helloworld]# make modules_install cp hello.ko /home/tekkaman/working/rootfs/lib/modules [root@Tekkaman-Ninja Helloworld]# 在我的开发板上的操作: [Tekkaman2440@SBC2440V4]#cd /lib/modules/ [Tekkaman2440@SBC2440V4]#ls cs89x0.ko hello.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值