0

I have written a simple loadable kernel module. To create a character device file in /dev/ and a related class directory. The following lines I have added in the project.

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

While building I got the following warning

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

While inserting I got the following error :

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

Please help me with this.

The project has one main file (GSM.c) and an include file (device.c and device.h)

Please get the files from the following link. https://github.com/guruprasad-92/Device-Driver

I've tried with adding the line MODULE_LICENSE("Dual BSD/GPL"); in file device.c which results no warning messages and no error messages as well, but while inserting the module it neither creates the device file /dev/gsm0 nor updating the $dmesg with printk() related messages.

I have also tried with writing the functions register_dev() and unregister_dev() in the file GSM.c which did not results any warning, and created the the device /dev/gsm0 and class directory in /sys/class/

But I want to know why the file inclusion is giving warning while building.

Kevin
  • 16,549
  • 8
  • 60
  • 74
  • 2
    Running `dmesg` after attempting to load the module should show which symbol was unknown. – Ian Abbott Oct 21 '19 at 12:07
  • Possible duplicate of [Building a kernel module from several source files which one of them has the same name as the module](https://stackoverflow.com/questions/13606075/building-a-kernel-module-from-several-source-files-which-one-of-them-has-the-sam) – Tsyvarev Oct 21 '19 at 22:29

1 Answers1

0

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 only allowed when the module is built from a single .c file).

To fix it, you can rename GSM.c to (for example) gsm.c and change the GSM-objs line in the Makefile:

obj-m := GSM.o
GSM-objs = gsm.o device.o
Ian Abbott
  • 15,083
  • 19
  • 33