kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* My simple kernel module wont compile
@ 2014-09-11 11:12 testlaster
  2014-09-11 13:49 ` Gustavo Bittencourt
  0 siblings, 1 reply; 7+ messages in thread
From: testlaster @ 2014-09-11 11:12 UTC (permalink / raw)
  To: kernelnewbies

Hey Guys

All im trying to do here is learn about make files and how to link linux 
header files stored in /usr/src/linux-headers-3.13.0-35-generic to my 
program that im writing.
So far ive been getting the simplest of Kernel Modules to compile and 
load in Linux but nothing useful . The moment I delve deeper I seem to 
get missing header file errors when using "make".
All I want to do is write from Kernel space into user space and visa 
verse. I will be dumping allocated PCI memory blocks into files.
I will also have to edit registers of the PCI to be able to make 
triggers go off by setting bits high etc.
But this is just an introduction to it all and im already having trouble 
compiling.

Now im not 100% sure if its missing header files but the errors is quite 
large.

  This is my Pastebin of the C MODULE Code :

  pastebin.com/lWPBR8DJ

  And here it the PASTEBIN of my MAKEFILE and its errors:

  pastebin.com/ffT1F26N

ALSO...Does anybody know of a good tutorial on how to write a PCI driver 
in Kernel space using kernel modules...also how to send data from and to 
the module from UserSpace?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140911/b9bfc4d9/attachment.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* My simple kernel module wont compile
  2014-09-11 11:12 My simple kernel module wont compile testlaster
@ 2014-09-11 13:49 ` Gustavo Bittencourt
  2014-09-11 14:13   ` testlaster
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo Bittencourt @ 2014-09-11 13:49 UTC (permalink / raw)
  To: kernelnewbies

Maybe you should replace the KERNEL_DIR definition in MAKEFILE. My
suggestions:

KERNEL_DIR:=/usr/src/linux-headers-$(shell uname -r)/build
or
KERNEL_DIR:=/lib/modules/$(shell uname -r)/build

On Thu, Sep 11, 2014 at 8:12 AM, testlaster <testlaster@gmail.com> wrote:

>  Hey Guys
>
> All im trying to do here is learn about make files and how to link linux
> header files stored in /usr/src/linux-headers-3.13.0-35-generic to my
> program that im writing.
> So far ive been getting the simplest of Kernel Modules to compile and load
> in Linux but nothing useful . The moment I delve deeper I seem to get
> missing header file errors when using "make".
> All I want to do is write from Kernel space into user space and visa
> verse. I will be dumping allocated PCI memory blocks into files.
> I will also have to edit registers of the PCI to be able to make triggers
> go off by setting bits high etc.
> But this is just an introduction to it all and im already having trouble
> compiling.
>
> Now im not 100% sure if its missing header files but the errors is quite
> large.
>
>  This is my Pastebin of the C MODULE Code :
>
>  pastebin.com/lWPBR8DJ
>
>  And here it the PASTEBIN of my MAKEFILE and its errors:
>
>  pastebin.com/ffT1F26N
>
> ALSO...Does anybody know of a good tutorial on how to write a PCI driver
> in Kernel space using kernel modules...also how to send data from and to
> the module from UserSpace?
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140911/85bd7e9e/attachment-0001.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* My simple kernel module wont compile
  2014-09-11 13:49 ` Gustavo Bittencourt
@ 2014-09-11 14:13   ` testlaster
  2014-09-11 15:06     ` Fwd: " Gustavo Bittencourt
  2014-09-11 15:11     ` Valdis.Kletnieks at vt.edu
  0 siblings, 2 replies; 7+ messages in thread
From: testlaster @ 2014-09-11 14:13 UTC (permalink / raw)
  To: kernelnewbies

Hi Gustavo

I tried your suggestions.

The first line didn't work because I seem to not have a build directory 
there.
And the second one did exactly the same as mine did.

On 9/11/2014 3:49 PM, Gustavo Bittencourt wrote:
> Maybe you should replace the KERNEL_DIR definition in MAKEFILE. My 
> suggestions:
>
> KERNEL_DIR:=/usr/src/linux-headers-$(shell uname -r)/build
> or
> KERNEL_DIR:=/lib/modules/$(shell uname -r)/build
>
> On Thu, Sep 11, 2014 at 8:12 AM, testlaster <testlaster@gmail.com 
> <mailto:testlaster@gmail.com>> wrote:
>
>     Hey Guys
>
>     All im trying to do here is learn about make files and how to link
>     linux header files stored in
>     /usr/src/linux-headers-3.13.0-35-generic to my program that im
>     writing.
>     So far ive been getting the simplest of Kernel Modules to compile
>     and load in Linux but nothing useful . The moment I delve deeper I
>     seem to get missing header file errors when using "make".
>     All I want to do is write from Kernel space into user space and
>     visa verse. I will be dumping allocated PCI memory blocks into files.
>     I will also have to edit registers of the PCI to be able to make
>     triggers go off by setting bits high etc.
>     But this is just an introduction to it all and im already having
>     trouble compiling.
>
>     Now im not 100% sure if its missing header files but the errors is
>     quite large.
>
>      This is my Pastebin of the C MODULE Code :
>
>     pastebin.com/lWPBR8DJ <http://pastebin.com/lWPBR8DJ>
>
>      And here it the PASTEBIN of my MAKEFILE and its errors:
>
>     pastebin.com/ffT1F26N <http://pastebin.com/ffT1F26N>
>
>     ALSO...Does anybody know of a good tutorial on how to write a PCI
>     driver in Kernel space using kernel modules...also how to send
>     data from and to the module from UserSpace?
>
>     _______________________________________________
>     Kernelnewbies mailing list
>     Kernelnewbies at kernelnewbies.org
>     <mailto:Kernelnewbies@kernelnewbies.org>
>     http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140911/4364f8d6/attachment.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Fwd: My simple kernel module wont compile
  2014-09-11 14:13   ` testlaster
@ 2014-09-11 15:06     ` Gustavo Bittencourt
  2014-09-12  8:11       ` testlaster
  2014-09-11 15:11     ` Valdis.Kletnieks at vt.edu
  1 sibling, 1 reply; 7+ messages in thread
From: Gustavo Bittencourt @ 2014-09-11 15:06 UTC (permalink / raw)
  To: kernelnewbies

Did you install the kernel source or at least the kernel headers?


---------- Forwarded message ----------
From: testlaster <testlaster@gmail.com>
Date: Thu, Sep 11, 2014 at 11:13 AM
Subject: Re: My simple kernel module wont compile
To: kernelnewbies at kernelnewbies.org


 Hi Gustavo

I tried your suggestions.

The first line didn't work because I seem to not have a build directory
there.
And the second one did exactly the same as mine did.


On 9/11/2014 3:49 PM, Gustavo Bittencourt wrote:

 Maybe you should replace the KERNEL_DIR definition in MAKEFILE. My
suggestions:

 KERNEL_DIR:=/usr/src/linux-headers-$(shell uname -r)/build
 or
KERNEL_DIR:=/lib/modules/$(shell uname -r)/build

On Thu, Sep 11, 2014 at 8:12 AM, testlaster <testlaster@gmail.com> wrote:

>  Hey Guys
>
> All im trying to do here is learn about make files and how to link linux
> header files stored in /usr/src/linux-headers-3.13.0-35-generic to my
> program that im writing.
> So far ive been getting the simplest of Kernel Modules to compile and load
> in Linux but nothing useful . The moment I delve deeper I seem to get
> missing header file errors when using "make".
> All I want to do is write from Kernel space into user space and visa
> verse. I will be dumping allocated PCI memory blocks into files.
> I will also have to edit registers of the PCI to be able to make triggers
> go off by setting bits high etc.
> But this is just an introduction to it all and im already having trouble
> compiling.
>
> Now im not 100% sure if its missing header files but the errors is quite
> large.
>
>  This is my Pastebin of the C MODULE Code :
>
>  pastebin.com/lWPBR8DJ
>
>  And here it the PASTEBIN of my MAKEFILE and its errors:
>
>  pastebin.com/ffT1F26N
>
> ALSO...Does anybody know of a good tutorial on how to write a PCI driver
> in Kernel space using kernel modules...also how to send data from and to
> the module from UserSpace?
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


_______________________________________________
Kernelnewbies mailing
listKernelnewbies at kernelnewbies.orghttp://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140911/b9ba75a2/attachment-0001.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* My simple kernel module wont compile
  2014-09-11 14:13   ` testlaster
  2014-09-11 15:06     ` Fwd: " Gustavo Bittencourt
@ 2014-09-11 15:11     ` Valdis.Kletnieks at vt.edu
  1 sibling, 0 replies; 7+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2014-09-11 15:11 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 11 Sep 2014 16:13:58 +0200, testlaster said:

> The first line didn't work because I seem to not have a build directory
> there.

Hopefully, that /usr/src/linux-headers directory is an exact match for
the kernel you're planning to use the module in.

make[2]: *** No rule to make target `/usr/src/linux-headers-3.13.0-35-generic/arch/x86/syscalls/syscall_32.tbl', needed by `arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h'.  Stop.

That's sounding suspiciously like it's not a properly set up directory
tree suitable for building modules against....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140911/fa548238/attachment.bin 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Fwd: My simple kernel module wont compile
  2014-09-11 15:06     ` Fwd: " Gustavo Bittencourt
@ 2014-09-12  8:11       ` testlaster
  2014-09-12 18:29         ` Bruno Guedes Souto
  0 siblings, 1 reply; 7+ messages in thread
From: testlaster @ 2014-09-12  8:11 UTC (permalink / raw)
  To: kernelnewbies

Yes I did run sudo apt-get install build-essential linux-headers-$(uname 
-r) to download the necessary headers. I also ran an apt-get for source 
files and it did install a whole bunch of them but Im not under the 
impression that you actually need the source files as well since they 
suppose to come with the OS?

The thing its complaining about... unistd_32.h appears to really be 
missing. Could this be because of a 64Bit version of the OS? Maybes just 
doesnt install it because its not necessary. But that wouldnt make sense 
because in unistd.h the only include there is will be the unistd_32.h 
and nowhere inside stands anything of #include<unistd_64.h>



On 9/11/2014 5:06 PM, Gustavo Bittencourt wrote:
> Did you install the kernel source or at least the kernel headers?
>
> ---------- Forwarded message ----------
> From: *testlaster* <testlaster at gmail.com <mailto:testlaster@gmail.com>>
> Date: Thu, Sep 11, 2014 at 11:13 AM
> Subject: Re: My simple kernel module wont compile
> To: kernelnewbies at kernelnewbies.org 
> <mailto:kernelnewbies@kernelnewbies.org>
>
>
> Hi Gustavo
>
> I tried your suggestions.
>
> The first line didn't work because I seem to not have a build 
> directory there.
> And the second one did exactly the same as mine did.
>
>
> On 9/11/2014 3:49 PM, Gustavo Bittencourt wrote:
>> Maybe you should replace the KERNEL_DIR definition in MAKEFILE. My 
>> suggestions:
>>
>> KERNEL_DIR:=/usr/src/linux-headers-$(shell uname -r)/build
>> or
>> KERNEL_DIR:=/lib/modules/$(shell uname -r)/build
>>
>> On Thu, Sep 11, 2014 at 8:12 AM, testlaster <testlaster@gmail.com 
>> <mailto:testlaster@gmail.com>> wrote:
>>
>>     Hey Guys
>>
>>     All im trying to do here is learn about make files and how to
>>     link linux header files stored in
>>     /usr/src/linux-headers-3.13.0-35-generic to my program that im
>>     writing.
>>     So far ive been getting the simplest of Kernel Modules to compile
>>     and load in Linux but nothing useful . The moment I delve deeper
>>     I seem to get missing header file errors when using "make".
>>     All I want to do is write from Kernel space into user space and
>>     visa verse. I will be dumping allocated PCI memory blocks into files.
>>     I will also have to edit registers of the PCI to be able to make
>>     triggers go off by setting bits high etc.
>>     But this is just an introduction to it all and im already having
>>     trouble compiling.
>>
>>     Now im not 100% sure if its missing header files but the errors
>>     is quite large.
>>
>>      This is my Pastebin of the C MODULE Code :
>>
>>     pastebin.com/lWPBR8DJ <http://pastebin.com/lWPBR8DJ>
>>
>>      And here it the PASTEBIN of my MAKEFILE and its errors:
>>
>>     pastebin.com/ffT1F26N <http://pastebin.com/ffT1F26N>
>>
>>     ALSO...Does anybody know of a good tutorial on how to write a PCI
>>     driver in Kernel space using kernel modules...also how to send
>>     data from and to the module from UserSpace?
>>
>>     _______________________________________________
>>     Kernelnewbies mailing list
>>     Kernelnewbies at kernelnewbies.org
>>     <mailto:Kernelnewbies@kernelnewbies.org>
>>     http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org  <mailto:Kernelnewbies@kernelnewbies.org>
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org <mailto:Kernelnewbies@kernelnewbies.org>
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140912/8066f623/attachment.html 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Fwd: My simple kernel module wont compile
  2014-09-12  8:11       ` testlaster
@ 2014-09-12 18:29         ` Bruno Guedes Souto
  0 siblings, 0 replies; 7+ messages in thread
From: Bruno Guedes Souto @ 2014-09-12 18:29 UTC (permalink / raw)
  To: kernelnewbies

testlaster <testlaster <at> gmail.com> writes:

> 
> 
>     Yes I did run sudo apt-get install build-essential
>     linux-headers-$(uname -r) to download the necessary headers. I also
>     ran an apt-get for source files and it did install a whole bunch of
>     them but Im not under the impression that you actually need the
>     source files as well since they suppose to come with the OS?

No, many distributions don't come with the source files. 

>     The thing its complaining about... unistd_32.h appears to really be
>     missing. Could this be because of a 64Bit version of the OS? 

No, I've ran your code last night on a 64bit machine of mine and beside some 
compiling errors due to wrong syntax and function declaration it was all 
fine.

>     Maybes
>     just doesnt install it because its not necessary. But that wouldnt
>     make sense because in unistd.h the only include there is will be the
>     unistd_32.h and nowhere inside stands anything of
>     #include<unistd_64.h>

It seems to me, you are just missing the necessary tools from your 
distribution 
to do the kind of work you want to do. Try a google search on your distro
+ kernel development and you probably will find what you need. Usually what 
you
must get are the linux-source, kernel-devel and kernel-tools packages.

Regards

Bruno Guedes Souto

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-12 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-11 11:12 My simple kernel module wont compile testlaster
2014-09-11 13:49 ` Gustavo Bittencourt
2014-09-11 14:13   ` testlaster
2014-09-11 15:06     ` Fwd: " Gustavo Bittencourt
2014-09-12  8:11       ` testlaster
2014-09-12 18:29         ` Bruno Guedes Souto
2014-09-11 15:11     ` Valdis.Kletnieks at vt.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).