設置 | 登錄 | 註冊

目前共有9篇帖子。

【解決方案】編譯luckfox_rv1106模塊時報找不到include/config/auto.conf文件的錯誤

1樓 巨大八爪鱼 2025-3-11 18:03

編譯luckfox_rv1106模塊時報找不到include/config/auto.conf文件的錯誤:
[oct1158@fed41-bh8f7e0 first]$ make
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
Makefile:672: include/config/auto.conf: No such file or directory
make: *** [Makefile:7: build] Error 2
[oct1158@fed41-bh8f7e0 first]$

 

先編譯內核:
cd /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel
make luckfox_rv1106_linux_defconfig ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
make ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
(這條命令等待時間較長,並且長時間沒有輸出,需要耐心等待)

 

再編譯模塊:
cd /home/oct1158/Documents/Code/C/driver_test/first
make

這下就能編譯成功生成test.ko文件了。

[oct1158@fed41-bh8f7e0 kernel]$ cd /home/oct1158/Documents/Code/C/driver_test/first
[oct1158@fed41-bh8f7e0 first]$ make
make -C /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel M=/home/oct1158/Documents/Code/C/driver_test/first modules ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
[oct1158@fed41-bh8f7e0 first]$ ls -l
total 240
-rwxr--r-- 1 oct1158 oct1158    404 Mar 11 17:44 Makefile
-rw-r--r-- 1 oct1158 oct1158     57 Mar 11 17:47 modules.order
-rw-r--r-- 1 oct1158 oct1158      0 Mar 11 18:01 Module.symvers
-rwxr--r-- 1 oct1158 oct1158    886 Mar  7 17:40 test.c
-rw-r--r-- 1 oct1158 oct1158 109016 Mar 11 18:01 test.ko
-rw-r--r-- 1 oct1158 oct1158     57 Mar 11 17:47 test.mod
-rw-r--r-- 1 oct1158 oct1158    534 Mar 11 17:47 test.mod.c
-rw-r--r-- 1 oct1158 oct1158  39220 Mar 11 17:47 test.mod.o
-rw-r--r-- 1 oct1158 oct1158  70712 Mar 11 17:47 test.o
[oct1158@fed41-bh8f7e0 first]$ file test.ko
test.ko: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), BuildID[sha1]=5f8c00b5d550340d31842a2a861b7bd85c401d9f, with debug_info, not stripped
[oct1158@fed41-bh8f7e0 first]$

2樓 巨大八爪鱼 2025-3-11 18:03

內核模塊的Makefile:

KDIR := /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel
CROSS_COMPILE := /home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-

obj-m := test.o

build:
 $(MAKE) -C $(KDIR) M=$(shell pwd) modules ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE)

clean:
 $(MAKE) -C $(KDIR) M=$(shell pwd) clean

 

3樓 巨大八爪鱼 2025-3-11 18:05

[oct1158@fed41-bh8f7e0 first]$ adb push test.ko /root
test.ko: 1 file pushed, 0 skipped. 456.1 MB/s (109016 bytes in 0.000s)

 

 

[root@luckfox root]# ls -l
total 128
-rwxrwxrwx    1 root     root          7352 Mar 11  2025 test
-rw-rw-rw-    1 root     root        109016 Mar 11  2025 test.ko
-rwxrwxrwx    1 root     root          8480 Mar 11  2025 testcpp
[root@luckfox root]# insmod test.ko
insmod: can't insert 'test.ko': invalid module format
[root@luckfox root]#

 

運行不了。。。。

4樓 巨大八爪鱼 2025-3-11 18:21

dmesg裏面的詳細錯誤信息:

[24818.574437] test: version magic '5.10.160 mod_unload ARMv7 thumb2 p2v8 ' should be '5.10.110 mod_unload ARMv7 thumb2 p2v8 '
[24818.576011] test: version magic '5.10.160 mod_unload ARMv7 thumb2 p2v8 ' should be '5.10.110 mod_unload ARMv7 thumb2 p2v8 '

巨大八爪鱼顯然是ko模塊使用的內核源碼版本5.10.160,和板子運行的linux內核版本5.10.110不相符。
5樓 巨大八爪鱼 2025-3-11 18:34

invalid module format錯誤的解決辦法:

打開內核源碼根目錄下的Makefile文件(/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel/Makefile),第四行SUBLEVEL = 160改成110。
改完需重新編譯內核:
cd /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel
make ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-
然後再重新編譯模塊:
cd /home/oct1158/Documents/Code/C/driver_test/first
make

 

[oct1158@fed41-bh8f7e0 first]$ modinfo test.ko
filename:       /home/oct1158/Documents/Code/C/driver_test/first/test.ko
license:        GPL
author:         Oct1158
depends:
name:           test
vermagic:       5.10.110 mod_unload ARMv7 thumb2 p2v8
這下就可以看到ko的版本變成110了。

 

上傳到板子上:
adb push test.ko /root/test.ko

[root@luckfox ]# cd root
[root@luckfox root]# insmod test.ko
[root@luckfox root]# rmmod test.ko
成功了。

6樓 巨大八爪鱼 2025-3-11 18:48
printk(KERN_ERR(高於控制台打印級別)的消息,adb shell上沒法自動顯示,估計要在串口上才看得到。
7樓 巨大八爪鱼 2025-3-13 14:31
編譯內核時,兩條make指令的ARCH和CROSS_COMPILE參數都不可省略!
執行後是不需要輸入任何信息的。如果要輸入信息(比如Restart config...)那就是操作有問題。
8樓 巨大八爪鱼 2025-3-13 14:45

printk KERN_ERR的消息,adb shell上沒法自動顯示,確實要在串口上才看得到。

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。