I have installed Xubuntu 7.04, i guess. It has 2.6.20.16 kernel. Then I got 2.6.22.1 kernel source code and compiled it( after lots of issues though). It compiled and I am able to boot into it as well. Now , my next venture is to compile the simple Hello World sample from "Linux Device Drivers" by Jonathan Corbett et. all.

When I compile the helloworld.c, I am getting the following errors:

-desktop:~/mysamples/sample1$ make
gcc -D__KERNEL__ -I~/linux-2.6.22.1/include -c helloworld.c -o hello.o
In file included from ~/linux-2.6.22.1/include/asm/thread_info.h:16,
from ~/linux-2.6.22.1/include/linux/thread_info.h:21,
from ~/linux-2.6.22.1/include/linux/preempt.h:9,
from ~/linux-2.6.22.1/include/linux/spinlock.h:49,
from ~/linux-2.6.22.1/include/linux/module.h:9,
from helloworld.c:2:
~/linux-2.6.22.1/include/asm/processor.h:83: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
~/linux-2.6.22.1/include/asm/processor.h:83: error: requested alignment is not a constant
In file included from ~/linux-2.6.22.1/include/linux/module.h:21,
from helloworld.c:2:
~/linux-2.6.22.1/include/asm/module.h:64:2: error: #error unknown processor family
make: *** [hello.o] Error 1

I googled aa lot on this and got some kind of insight into it. Most posts suggested that it's some kind of mismatch of header files. I tried different things none of them seems to work...it's like shooting in the dark.
Can someone please point me in the right direction?

Thanks in advance,
rabantu

12-25-2007

Tsarevich

It would be ideal if you could paste a link from where you want to compile the Device Drivers. I can't figure out what Hello World has to do with Linux Device Drivers. Also attach the module.h along with the other post. There's a bug in the code.

12-25-2007

Tsarevich

And listen there's one more important point. If its a C Program and module.h is in the same directory as the C file, not in your OS's default includes, then you should define the module.h header the following way in each files:

Code:

#include "module.h"

and not like this:

Code:

#include <module.h>

12-25-2007

rabantu

here is the link...

Quote:

Originally Posted by usamamuneeb

It would be ideal if you could paste a link from where you want to compile the Device Drivers. I can't figure out what Hello World has to do with Linux Device Drivers. Also attach the module.h along with the other post. There's a bug in the code.

Install the libmodule* packages if you haven't already. If you were the impatient reader, go through the "Setting Up Your Test System" section first. Also, thanks for introducing me this page. I am learning C language from a book right now. So it might help later.

12-25-2007

Tsarevich

How long did it take you to compile your kernel?

12-25-2007

rabantu

it took me a while to compile the kernel..

Quote:

Originally Posted by usamamuneeb

How long did it take you to compile your kernel?

Hi,

I did go through that section and followed.
I compiled my kernel sometime back in august or so. Then I got buys with my work. Now I started over with this as I am in vacation.

I had lots of issues with my kernel compilation. Mostly the config part. However, with lots of help from the users of this website, I completed my kernel compilation.
Now I am stuck here::(((

12-25-2007

rabantu

Errors compiling hello world module...please help

Hi All,

I have installed Xubuntu 7.04, i guess. It has 2.6.20.16 kernel. Then I got 2.6.22.1 kernel source code and compiled it( after lots of issues though). It compiled and I am able to boot into it as well. Now , my next venture is to compile the simple Hello World sample from "Linux Device Drivers" by Jonathan Corbett et. all.

When I compile the helloworld.c, I am getting the following errors:

-desktop:~/mysamples/sample1$ make
gcc -D__KERNEL__ -I~/linux-2.6.22.1/include -c helloworld.c -o hello.o
In file included from ~/linux-2.6.22.1/include/asm/thread_info.h:16,
from ~/linux-2.6.22.1/include/linux/thread_info.h:21,
from ~/linux-2.6.22.1/include/linux/preempt.h:9,
from ~/linux-2.6.22.1/include/linux/spinlock.h:49,
from ~/linux-2.6.22.1/include/linux/module.h:9,
from helloworld.c:2:
~/linux-2.6.22.1/include/asm/processor.h:83: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
~/linux-2.6.22.1/include/asm/processor.h:83: error: requested alignment is not a constant
In file included from ~/linux-2.6.22.1/include/linux/module.h:21,
from helloworld.c:2:
~/linux-2.6.22.1/include/asm/module.h:64:2: error: #error unknown processor family
make: *** [hello.o] Error 1

I googled aa lot on this and got some kind of insight into it. Most posts suggested that it's some kind of mismatch of header files. I tried different things none of them seems to work...it's like shooting in the dark.
Can someone please point me in the right direction?