目前共有9篇帖子。 字体大小:较小 - 100% (默认)▼  内容转换:港澳繁體▼
 
点击 回复
175 8
【解決方案】編譯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不相符。
  2025-3-11 18:30 回复
一派掌门 二十级
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上沒法自動顯示,確實要在串口上才看得到。

 

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
(快捷键:Ctrl+Enter)
 

本帖信息

点击数:175 回复数:8
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2025-3-13 14:45
 
©2010-2025 Purasbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。