2004-06-11 15:43:59

by Srinivas G.

[permalink] [raw]
Subject: Problem in module loading automatically at boot time


Hi,

I have written a small driver program called hello.c.

************************************************************************
***************
#include <linux/module.h>

MODULE_LICENSE("GPL");

int init_module(void)
{
printk("<1>" "Hello world\n");
return 0;
}

void cleanup_module(void)
{
printk("<1>good bye\n");
}

************************************************************************
****************

I compiled the above program with cc -DMODULE -D__KERNEL__
-I/usr/src/linux2.4/include -O2 -c hello.c

I am using Red Hat Linux 7.3 with kernel version of 2.4.18-3.
It works fine when I load it with insmod from root prompt.

Now, I want to make it load automatically at boot time.
For that I have used the following steps.

---> I copied the hello.o file in the
/lib/modules/2.4.18-3/kernel/drivers/block

---> I run the depmod command. It included the above path in
/lib/modules/2.4.18-3/modules.dep file.

---> I added "alias hello1 hello" entry into /etc/modules.conf file.

When I reboot the machine after the above changes, my driver is not
loaded and an error message is printed as follows.

---> depmod: *** Unresolved symbols in
/lib/modules/2.4.18-3/kernel/drivers/block/hello.o


Could anyone suggest me, if I am missing anything here?

Srinivas G



2004-06-11 17:03:26

by Richard B. Johnson

[permalink] [raw]
Subject: Re: Problem in module loading automatically at boot time

On Fri, 11 Jun 2004, Srinivas G. wrote:

>
> Hi,
>
> I have written a small driver program called hello.c.
>
> ************************************************************************
> ***************
> #include <linux/module.h>
>
> MODULE_LICENSE("GPL");
>
> int init_module(void)
> {
> printk("<1>" "Hello world\n");
> return 0;
> }
>
> void cleanup_module(void)
> {
> printk("<1>good bye\n");
> }
>
> ************************************************************************
> ****************
>
> I compiled the above program with cc -DMODULE -D__KERNEL__
> -I/usr/src/linux2.4/include -O2 -c hello.c
>
> I am using Red Hat Linux 7.3 with kernel version of 2.4.18-3.
> It works fine when I load it with insmod from root prompt.
>
> Now, I want to make it load automatically at boot time.
> For that I have used the following steps.
>
> ---> I copied the hello.o file in the
> /lib/modules/2.4.18-3/kernel/drivers/block
>
> ---> I run the depmod command. It included the above path in
> /lib/modules/2.4.18-3/modules.dep file.
>
> ---> I added "alias hello1 hello" entry into /etc/modules.conf file.
>
> When I reboot the machine after the above changes, my driver is not
> loaded and an error message is printed as follows.
>
> ---> depmod: *** Unresolved symbols in
> /lib/modules/2.4.18-3/kernel/drivers/block/hello.o
>
>
> Could anyone suggest me, if I am missing anything here?
>
> Srinivas G
>

Maybe `depmod -e ...` would tell you what symbols are missing??

Then, after you observe that, try including <linux/kernel.h>,
and <linux/module.h>, like you are supposed to do.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.


2004-06-12 08:44:40

by Srinivas G.

[permalink] [raw]
Subject: RE: Problem in module loading automatically at boot time

Hi Johnson,

I tried with depmod -e option. It showed that printk is unresolved
symbol. Is it current? Is it(printk) not a kernel symbol? If so, give me
a suggestion.

Note: I included the <linux/kernel.h> and <linux/module.h> also. Please
see the attachments.

Thanks and regards,

Srinivas G

-----Original Message-----
From: Richard B. Johnson [mailto:[email protected]]
Sent: Friday, June 11, 2004 10:29 PM
To: Srinivas G.
Cc: [email protected]; Surendra I.; Subramanyam B
Subject: Re: Problem in module loading automatically at boot time

On Fri, 11 Jun 2004, Srinivas G. wrote:

>
> Hi,
>
> I have written a small driver program called hello.c.
>
>
************************************************************************
> ***************
> #include <linux/module.h>
>
> MODULE_LICENSE("GPL");
>
> int init_module(void)
> {
> printk("<1>" "Hello world\n");
> return 0;
> }
>
> void cleanup_module(void)
> {
> printk("<1>good bye\n");
> }
>
>
************************************************************************
> ****************
>
> I compiled the above program with cc -DMODULE -D__KERNEL__
> -I/usr/src/linux2.4/include -O2 -c hello.c
>
> I am using Red Hat Linux 7.3 with kernel version of 2.4.18-3.
> It works fine when I load it with insmod from root prompt.
>
> Now, I want to make it load automatically at boot time.
> For that I have used the following steps.
>
> ---> I copied the hello.o file in the
> /lib/modules/2.4.18-3/kernel/drivers/block
>
> ---> I run the depmod command. It included the above path in
> /lib/modules/2.4.18-3/modules.dep file.
>
> ---> I added "alias hello1 hello" entry into /etc/modules.conf file.
>
> When I reboot the machine after the above changes, my driver is not
> loaded and an error message is printed as follows.
>
> ---> depmod: *** Unresolved symbols in
> /lib/modules/2.4.18-3/kernel/drivers/block/hello.o
>
>
> Could anyone suggest me, if I am missing anything here?
>
> Srinivas G
>

Maybe `depmod -e ...` would tell you what symbols are missing??

Then, after you observe that, try including <linux/kernel.h>,
and <linux/module.h>, like you are supposed to do.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.



Attachments:
hello.c (644.00 B)
hello.c
Makefile (262.00 B)
Makefile
Download all attachments