All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Cross-Compiling out-of-tree driver
@ 2013-04-05 11:40 universeII at gmx.de
  2013-04-05 12:01 ` Samuel Martin
  2013-04-05 12:07 ` Thomas Petazzoni
  0 siblings, 2 replies; 7+ messages in thread
From: universeII at gmx.de @ 2013-04-05 11:40 UTC (permalink / raw)
  To: buildroot

An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130405/9fc8d0b0/attachment.html>

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

* [Buildroot] Cross-Compiling out-of-tree driver
  2013-04-05 11:40 [Buildroot] Cross-Compiling out-of-tree driver universeII at gmx.de
@ 2013-04-05 12:01 ` Samuel Martin
  2013-04-05 12:07 ` Thomas Petazzoni
  1 sibling, 0 replies; 7+ messages in thread
From: Samuel Martin @ 2013-04-05 12:01 UTC (permalink / raw)
  To: buildroot

Hi Andreas,

2013/4/5  <universeII@gmx.de>:
> Dear all,
> I'm trying to use buildroot to create a Linux system for our custom VME
> PowerPC board.
> I succeeded in modifying the kernel to run on our special hardware but I'm
> stuck in compiling a driver out-of-tree.
> In-kernel compilation is no problem but for development and debugging of
> drivers it is much simpler to be able to compile drivers quickly out-of-tree
> and insert/remove them manually.
> I started to compile a dummy driver out-of-tree on my linux PC which works
> fine. Now I'm trying to use the linux kernel inside buildroot tree (setting
> KDIR appropriately) and use the cross-compile tool from buildroot. I
> searched the buildroot documentation but only found instructions how to
> compile own applications/libraries. Also TODOs from the internet on
> cross-compiling drivers did not help.
> Maybe I just oversee some simple things
>
> Can anybody give me a hint, how to cross-compile a linux driver out-of-tree
> using buildroot?

To to this, you can try something similar to what lttng-modules does, see:
http://git.buildroot.net/buildroot/tree/package/lttng-modules/lttng-modules.mk

Regards,

-- 
Samuel

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

* [Buildroot] Cross-Compiling out-of-tree driver
  2013-04-05 11:40 [Buildroot] Cross-Compiling out-of-tree driver universeII at gmx.de
  2013-04-05 12:01 ` Samuel Martin
@ 2013-04-05 12:07 ` Thomas Petazzoni
       [not found]   ` <trinity-e6e255fe-1d77-40c4-934f-3c35573b2dbc-1365166479514@3capp-gmx-bs29>
  2013-04-05 14:03   ` [Buildroot] " universeII at gmx.de
  1 sibling, 2 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2013-04-05 12:07 UTC (permalink / raw)
  To: buildroot

Hello Andreas,

(Would be nice if your e-mail had been wrapped to ~80 characters).

On Fri, 5 Apr 2013 13:40:59 +0200 (CEST), universeII at gmx.de wrote:

> I'm trying to use buildroot to create a Linux system for our custom
> VME PowerPC board.
>
> I succeeded in modifying the kernel to run on our special hardware
> but I'm stuck in compiling a driver out-of-tree.
>
> In-kernel compilation is no problem but for development and
> debugging of drivers it is much simpler to be able to compile drivers
> quickly out-of-tree and insert/remove them manually.
>
> I started to compile a dummy driver out-of-tree on my linux PC
> which works fine. Now I'm trying to use the linux kernel inside
> buildroot tree (setting KDIR appropriately) and use the cross-compile
> tool from buildroot. I searched the buildroot documentation but only
> found instructions how to compile own applications/libraries. Also
> TODOs from the internet on cross-compiling drivers did not help.
>
> Maybe I just oversee some simple things
>
> Can anybody give me a hint, how to cross-compile a linux driver
> out-of-tree using buildroot?

Yes. See the mail I posted a long time ago, which provided an example
of a kernel module and the associated .mk file:

  http://lists.busybox.net/pipermail/buildroot/2011-August/044807.html

Note however that the .mk file will need a few modifications,
especially the last line should just be:

$(eval $(generic-package))

I hope this helps. If not, don't hesitate to come back with
any question you may have.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [Buildroot] Cross-Compiling out-of-tree driver
       [not found]   ` <trinity-e6e255fe-1d77-40c4-934f-3c35573b2dbc-1365166479514@3capp-gmx-bs29>
@ 2013-04-05 13:19     ` Thomas Petazzoni
       [not found]       ` <trinity-48f3adad-041a-4437-8b4e-0f18f5b0c02c-1365168640703@3capp-gmx-bs29>
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2013-04-05 13:19 UTC (permalink / raw)
  To: buildroot

Andreas,

Please do not reply to me directly: the list should be kept in Cc.
Thanks.

On Fri, 5 Apr 2013 14:54:39 +0200 (CEST), universeII at gmx.de wrote:

> thanks for your quick response. I'm still a little bit confused how to complile the driver.
> I have the dummy driver in an own directory including the Makefile which is just a "normal"
> makefile for compiling a driver out-of-tree.
> Example:
> 
> obj-m := dummy_driver.o
> KDIR := /lib/modules/$(shell uname -r)/build
> PWD := $(shell pwd)
> 
> default:
>     $(MAKE) -C $(KDIR) M=$(PWD) modules
> 
> 
> I change to the directory and issue a "make" command. I was woundering if it is possible to just set
> KDIR and the gcc approriately to the kernel sources and (cross-compile) tools from buildroot.

Aah, ok, you want to build your module manually outside of Buildroot.
What I showed in my previous e-mail was how to integrate it as a
Buildroot package.

If you want to build your out-of-tree module manually against a Linux
kernel that has been built by Buildroot, then you should just do:

KDIR = /path/to/buildroot/output/build/linux-x.y.z/

that should be enough. Then of course, you should install your module,
so maybe add something like:

DESTDIR = /path/to/buildroot/output/target/

install:
	$(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(DESTDIR)	modules_install

run "make install" in your module, which should install it in the
output/target/lib/modules/<kernelversion>/ directory. Then, run "make"
again in Buildroot so that your filesystem image gets regenerated to
include the module.

Of course, this is only needed if you want a clean installation of your
module. For quick and dirty testing, you can also just copy the .ko
file to your target, and insmod it.

> I had a look at your patch file and it seems to me that the .mk is somehow included in the
> buildroot make structure (I'm sorry that I do not know so much details how buildroot work internally)?

Yes, my patch shows how to add an out-of-tree kernel driver as a
Buildroot package, so that it is nicely integrated in the Buildroot
build process.

> How do you in this case issue a compilation of your driver?

You just enable your new package in 'make menuconfig', and run the
usual Buildroot 'make' command.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [Buildroot] Fw: Aw: Re:  Cross-Compiling out-of-tree driver
       [not found]       ` <trinity-48f3adad-041a-4437-8b4e-0f18f5b0c02c-1365168640703@3capp-gmx-bs29>
@ 2013-04-05 13:57         ` universeII at gmx.de
  0 siblings, 0 replies; 7+ messages in thread
From: universeII at gmx.de @ 2013-04-05 13:57 UTC (permalink / raw)
  To: buildroot

?

Gesendet:?Freitag, 05. April 2013 um 15:30 Uhr
Von:?universeII at gmx.de
An:?"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
Betreff:?Aw: Re: [Buildroot] Cross-Compiling out-of-tree driver

Thomas,
sorry for contacting your directly. I wasn't sure if my email is? shown in the list archive in the correct subtree when replying to the list. Is this correct or how do I reply correctly?
?
Setting KDIR to the right directory does not work sufficiently as I have to set the architecture correctly. I'm trying to cross-compile
for PowerPC architecture but my PC is x86_64.
I tried several recommendation from the internet (setting environment variables) but did not succeed.
What do I have to set in my Makefile to use the cross-compile toolchain from buildroot and tell the gcc to use the PowerPC part of kernel tree instead of x86_64?
?
Regards,
Andreas

?
P.S.: Acutally I just need to copy the .ko file to the target and do insmod/rmmod manually.
?

Gesendet:?Freitag, 05. April 2013 um 15:19 Uhr
Von:?"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
An:?universeII at gmx.de
Cc:?buildroot at uclibc.org
Betreff:?Re: [Buildroot] Cross-Compiling out-of-tree driver
Andreas,

Please do not reply to me directly: the list should be kept in Cc.
Thanks.

On Fri, 5 Apr 2013 14:54:39 +0200 (CEST), universeII at gmx.de wrote:

> thanks for your quick response. I'm still a little bit confused how to complile the driver.
> I have the dummy driver in an own directory including the Makefile which is just a "normal"
> makefile for compiling a driver out-of-tree.
> Example:
>
> obj-m := dummy_driver.o
> KDIR := /lib/modules/$(shell uname -r)/build
> PWD := $(shell pwd)
>
> default:
> $(MAKE) -C $(KDIR) M=$(PWD) modules
>
>
> I change to the directory and issue a "make" command. I was woundering if it is possible to just set
> KDIR and the gcc approriately to the kernel sources and (cross-compile) tools from buildroot.

Aah, ok, you want to build your module manually outside of Buildroot.
What I showed in my previous e-mail was how to integrate it as a
Buildroot package.

If you want to build your out-of-tree module manually against a Linux
kernel that has been built by Buildroot, then you should just do:

KDIR = /path/to/buildroot/output/build/linux-x.y.z/

that should be enough. Then of course, you should install your module,
so maybe add something like:

DESTDIR = /path/to/buildroot/output/target/

install:
$(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_PATH=$(DESTDIR) modules_install

run "make install" in your module, which should install it in the
output/target/lib/modules/<kernelversion>/ directory. Then, run "make"
again in Buildroot so that your filesystem image gets regenerated to
include the module.

Of course, this is only needed if you want a clean installation of your
module. For quick and dirty testing, you can also just copy the .ko
file to your target, and insmod it.

> I had a look at your patch file and it seems to me that the .mk is somehow included in the
> buildroot make structure (I'm sorry that I do not know so much details how buildroot work internally)?

Yes, my patch shows how to add an out-of-tree kernel driver as a
Buildroot package, so that it is nicely integrated in the Buildroot
build process.

> How do you in this case issue a compilation of your driver?

You just enable your new package in 'make menuconfig', and run the
usual Buildroot 'make' command.

Best regards,

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* [Buildroot] Cross-Compiling out-of-tree driver
  2013-04-05 12:07 ` Thomas Petazzoni
       [not found]   ` <trinity-e6e255fe-1d77-40c4-934f-3c35573b2dbc-1365166479514@3capp-gmx-bs29>
@ 2013-04-05 14:03   ` universeII at gmx.de
  2013-04-05 14:19     ` [Buildroot] SOLVED: " universeII at gmx.de
  1 sibling, 1 reply; 7+ messages in thread
From: universeII at gmx.de @ 2013-04-05 14:03 UTC (permalink / raw)
  To: buildroot

An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130405/192d50f1/attachment-0001.html>

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

* [Buildroot] SOLVED:  Cross-Compiling out-of-tree driver
  2013-04-05 14:03   ` [Buildroot] " universeII at gmx.de
@ 2013-04-05 14:19     ` universeII at gmx.de
  0 siblings, 0 replies; 7+ messages in thread
From: universeII at gmx.de @ 2013-04-05 14:19 UTC (permalink / raw)
  To: buildroot

O.k.,
reason for compilation problems was that the module loader support was disabled. Just enable this in kernel config,
recompile the kernel and the driver compilation works.
?
Thanks to you guys for the support.
?
Regards,
Andreas
?

Gesendet:?Freitag, 05. April 2013 um 16:03 Uhr
Von:?universeII at gmx.de
An:?buildroot at busybox.net
Betreff:?Re: [Buildroot] Cross-Compiling out-of-tree driver

In the meanwhile I figured out how to start the driver corss-compilation by hand:
Adding the cross tool directory to PATH and calling
make ARCH=powerpc CROSS_COMPILE=powerpc-linux-
?
But when doing this the gcc does not know kernel functions like printk(), alloc_chrdev_region(),
cdev_add(), ...
?
The driver code itself is correct, Just typing "make" without ARCH=... the driver compiles on my x86_64 PC.

?
Has somone an idea?
?
Regards,
Andreas
?

Gesendet:?Freitag, 05. April 2013 um 14:07 Uhr
Von:?"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
An:?universeII at gmx.de
Cc:?buildroot at busybox.net
Betreff:?Re: [Buildroot] Cross-Compiling out-of-tree driver
Hello Andreas,

(Would be nice if your e-mail had been wrapped to ~80 characters).

On Fri, 5 Apr 2013 13:40:59 +0200 (CEST), universeII at gmx.de wrote:

> I'm trying to use buildroot to create a Linux system for our custom
> VME PowerPC board.
>
> I succeeded in modifying the kernel to run on our special hardware
> but I'm stuck in compiling a driver out-of-tree.
>
> In-kernel compilation is no problem but for development and
> debugging of drivers it is much simpler to be able to compile drivers
> quickly out-of-tree and insert/remove them manually.
>
> I started to compile a dummy driver out-of-tree on my linux PC
> which works fine. Now I'm trying to use the linux kernel inside
> buildroot tree (setting KDIR appropriately) and use the cross-compile
> tool from buildroot. I searched the buildroot documentation but only
> found instructions how to compile own applications/libraries. Also
> TODOs from the internet on cross-compiling drivers did not help.
>
> Maybe I just oversee some simple things
>
> Can anybody give me a hint, how to cross-compile a linux driver
> out-of-tree using buildroot?

Yes. See the mail I posted a long time ago, which provided an example
of a kernel module and the associated .mk file:

http://lists.busybox.net/pipermail/buildroot/2011-August/044807.html

Note however that the .mk file will need a few modifications,
especially the last line should just be:

$(eval $(generic-package))

I hope this helps. If not, don't hesitate to come back with
any question you may have.

Best regards,

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com[http://free-electrons.com]
?
?

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

end of thread, other threads:[~2013-04-05 14:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-05 11:40 [Buildroot] Cross-Compiling out-of-tree driver universeII at gmx.de
2013-04-05 12:01 ` Samuel Martin
2013-04-05 12:07 ` Thomas Petazzoni
     [not found]   ` <trinity-e6e255fe-1d77-40c4-934f-3c35573b2dbc-1365166479514@3capp-gmx-bs29>
2013-04-05 13:19     ` Thomas Petazzoni
     [not found]       ` <trinity-48f3adad-041a-4437-8b4e-0f18f5b0c02c-1365168640703@3capp-gmx-bs29>
2013-04-05 13:57         ` [Buildroot] Fw: Aw: " universeII at gmx.de
2013-04-05 14:03   ` [Buildroot] " universeII at gmx.de
2013-04-05 14:19     ` [Buildroot] SOLVED: " universeII at gmx.de

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.