簡體   English   中英

< insmod:錯誤:無法插入模塊 GSM.ko:模塊中的未知符號。 > 如何解決?

[英]< insmod: ERROR: could not insert module GSM.ko: Unknown symbol in module. > How to fix it?

我編寫了一個簡單的可加載 kernel 模塊。 在 /dev/ 和相關的 class 目錄中創建字符設備文件。 我在項目中添加了以下幾行。

MODULE_DESCRIPTION("GSM driver");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Guruprasad");
MODULE_DESCRIPTION("A simple driver");
MODULE_VERSION("0.1");

在構建時,我收到以下警告

WARNING: modpost: missing MODULE_LICENSE() in /home/.../char_dev_gsm/GSM.o

插入時出現以下錯誤:

insmod: ERROR: could not insert module GSM.ko: Unknown symbol in module

請幫我解決一下這個。

該項目有一個主文件 (GSM.c) 和一個包含文件 (device.c 和 device.h)

請從以下鏈接獲取文件。 https://github.com/guruprasad-92/Device-Driver

我嘗試添加MODULE_LICENSE("Dual BSD/GPL"); 在文件 device.c 中,這不會導致警告消息和錯誤消息,但是在插入模塊時,它既不會創建設備文件/dev/gsm0 ,也不會使用printk()相關消息更新$dmesg

我還嘗試在文件 GSM.c 中編寫函數register_dev()unregister_dev() ,但沒有產生任何警告,並在 /sys/class/ 中創建了設備/dev/gsm0和 class 目錄

但我想知道為什么文件包含在構建時會發出警告。

The main problem is that the module is GSM.ko is built from multiple.c files (GSM.c and device.c), and the basename of the module is the same as the basename of one of the.c files (which is僅當模塊從單個.c 文件構建時才允許)。

要修復它,您可以將 GSM.c 重命名為(例如)gsm.c 並更改 ZB67911656EF5D18C4AE36CB6741B7 中的GSM-objs objs 行

obj-m := GSM.o
GSM-objs = gsm.o device.o

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM