All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] In Buildroot, how to compile kernel modules
@ 2014-02-25  9:04 Frank Ihle
  2014-02-25 10:23 ` Raúl Sánchez Siles
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Ihle @ 2014-02-25  9:04 UTC (permalink / raw)
  To: buildroot

Hi everyone,

the Internet and the buildroot manual couldn't help me out. I have a .c code which should be compiled to a .ko kernel module. Right now I'm doing this separately, the steps are: 

1. I run "make" of buildroot
2. Building the kernel module with the link to the linux kernel, that buildroot has downloaded.
3. After another make of buildroot, the .ko file is included via a fs-overlay and can be included with the "insmod" command

Usually this works, but often I get error messages which  tell me I'm using a different kernel version. So to avoid this I'd like to enqueue this .c code to the make process of buildroot. But I'm not sure how this is done. 

I actually just want to make changes on the Buildroot or Linux configuration and if Image is generated I'd still like to have a runnable kernel module. 

Can somebody tell me a hint about the steps, a manual or a tutorial ?

Kind Regards

Frank Ihle

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140225/07161769/attachment.html>

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

* [Buildroot] In Buildroot, how to compile kernel modules
  2014-02-25  9:04 [Buildroot] In Buildroot, how to compile kernel modules Frank Ihle
@ 2014-02-25 10:23 ` Raúl Sánchez Siles
  2014-02-25 10:38   ` [Buildroot] Antw: " Frank Ihle
  0 siblings, 1 reply; 7+ messages in thread
From: Raúl Sánchez Siles @ 2014-02-25 10:23 UTC (permalink / raw)
  To: buildroot

On Tue, Feb 25, 2014 at 10:04:34AM +0100, Frank Ihle wrote:
> Hi everyone,
> 
[...]
> 
> I actually just want to make changes on the Buildroot or Linux configuration
> and if Image is generated I'd still like to have a runnable kernel module.
> 
> Can somebody tell me a hint about the steps, a manual or a tutorial ?
> 
> Kind Regards
> 
> Frank Ihle

  Hello:

  Consider this example for aufs, which I'll someday manage to submit. You'll
need to created an aufs package, in this case Config.in and aufs.mk

  The interesting part is aufs.mk:

------8<--------
AUFS_SITE_METHOD = git
AUFS_SITE = http://git.code.sf.net/p/aufs/aufs3-standalone

AUFS_DEPENDENCIES = linux
AUFS_INSTALL_STAGING = YES

define AUFS_BUILD_CMDS
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) aufs.ko
endef

define AUFS_INSTALL_TARGET_CMDS
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) install
endef

define AUFS_INSTALL_STAGING_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) -f scripts/Makefile.host \
                scripts/unifdef
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) usr/include/linux/aufs_type.h
        $(INSTALL) -p -m 0644 $(@D)/usr/include/linux/aufs_type.h $(STAGING_DIR)/usr/include/linux
endef

$(eval $(generic-package))
------>8--------

  Mind that this is targetted for 2013.11 so it may not work that straight
forward on a more recent (or older) version.

  Notes:

  - STAGING may not be needed in your case
  - You may need to add/remove some stuff to get your case working.
  - Consider following [0] guideliness

[0] http://buildroot.net/downloads/manual/manual.html#adding-packages

  Disclaimer: This snippet is not an aufs fully working example.

  Regards,

-- 
Ra?l S?nchez Siles

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

* [Buildroot] Antw: Re:  In Buildroot, how to compile kernel modules
  2014-02-25 10:23 ` Raúl Sánchez Siles
@ 2014-02-25 10:38   ` Frank Ihle
  2014-02-25 20:40     ` Arnout Vandecappelle
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Ihle @ 2014-02-25 10:38 UTC (permalink / raw)
  To: buildroot

Hi and thanks for your response. Before i start hacking this, is it
really that complicated ? For me it doesn't seem a big deal ?



>>> Ra?l S?nchezSiles <rasasi78@gmail.com> 25.02.14 11.24 Uhr >>>
Hello:

  Consider this example for aufs, which I'll someday manage to submit.
You'll
need to created an aufs package, in this case Config.in and aufs.mk

  The interesting part is aufs.mk:

------8<--------
AUFS_SITE_METHOD = git
AUFS_SITE = http://git.code.sf.net/p/aufs/aufs3-standalone

AUFS_DEPENDENCIES = linux
AUFS_INSTALL_STAGING = YES

define AUFS_BUILD_CMDS
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) aufs.ko
endef

define AUFS_INSTALL_TARGET_CMDS
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) install
endef

define AUFS_INSTALL_STAGING_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) -f
scripts/Makefile.host \
                scripts/unifdef
        $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR)
usr/include/linux/aufs_type.h
        $(INSTALL) -p -m 0644 $(@D)/usr/include/linux/aufs_type.h
$(STAGING_DIR)/usr/include/linux
endef

$(eval $(generic-package))
------>8--------

  Mind that this is targetted for 2013.11 so it may not work that
straight
forward on a more recent (or older) version.

  Notes:

  - STAGING may not be needed in your case
  - You may need to add/remove some stuff to get your case working.
  - Consider following [0] guideliness

[0] http://buildroot.net/downloads/manual/manual.html#adding-packages

  Disclaimer: This snippet is not an aufs fully working example.

  Regards,

-- 
Ra?l S?nchez Siles
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140225/a2e68db6/attachment.html>

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

* [Buildroot] Antw: Re:  In Buildroot, how to compile kernel modules
  2014-02-25 10:38   ` [Buildroot] Antw: " Frank Ihle
@ 2014-02-25 20:40     ` Arnout Vandecappelle
  2014-02-26  7:31       ` [Buildroot] " Frank Ihle
  0 siblings, 1 reply; 7+ messages in thread
From: Arnout Vandecappelle @ 2014-02-25 20:40 UTC (permalink / raw)
  To: buildroot

On 25/02/14 11:38, Frank Ihle wrote:
> Hi and thanks for your response. Before i start hacking this, is it
> really that complicated ? For me it doesn't seem a big deal ?

 Actually, a much better example for simple modules is
package/on2-8170-modules/on2-8170-modules.mk

 You need to set VERSION and SITE like for all packages.

 You need to set DEPENDENCIES to LINUX (and also in the Config.in you
need to depend on BR2_LINUX_KERNEL).

 And you need the following build/install commands:

define ON2_8170_MODULES_BUILD_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D)
endef

define ON2_8170_MODULES_INSTALL_TARGET_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D) \
		modules_install
endef



 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

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

* [Buildroot] In Buildroot, how to compile kernel modules
  2014-02-25 20:40     ` Arnout Vandecappelle
@ 2014-02-26  7:31       ` Frank Ihle
  2014-02-26 17:32         ` Arnout Vandecappelle
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Ihle @ 2014-02-26  7:31 UTC (permalink / raw)
  To: buildroot

Right setting kernel dependencies makes sense, but I'm not so sure about the process: when I have the following makefile

obj-m += /<path-to-module>/measurement_gpio.o
KDIR := /<BR-path>/output/build/linux-2.6.39/
PWD := $(shell pwd)
default:
    $(MAKE) ARCH=arm CROSS_COMPILE=/<BR-path>/output/host/opt/ext-toolchain/bin/arm-none-linux-gnueabi- -C modules

where is then the generated .ko file and how can I make sure that in this build process the .ko file will be moved to a certain place ?

Kind Regards

Frank


>>> Arnout Vandecappelle <arnout@mind.be> 25.02.14 21.42 Uhr >>>
On 25/02/14 11:38, Frank Ihle wrote:
> Hi and thanks for your response. Before i start hacking this, is it
> really that complicated ? For me it doesn't seem a big deal ?

 Actually, a much better example for simple modules is
package/on2-8170-modules/on2-8170-modules.mk

 You need to set VERSION and SITE like for all packages.

 You need to set DEPENDENCIES to LINUX (and also in the Config.in you
need to depend on BR2_LINUX_KERNEL).

 And you need the following build/install commands:

define ON2_8170_MODULES_BUILD_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D)
endef

define ON2_8170_MODULES_INSTALL_TARGET_CMDS
        $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D) \
        modules_install
endef



 Regards,
 Arnout

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140226/b0a79691/attachment.html>

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

* [Buildroot] In Buildroot, how to compile kernel modules
  2014-02-26  7:31       ` [Buildroot] " Frank Ihle
@ 2014-02-26 17:32         ` Arnout Vandecappelle
  2014-02-28  8:05           ` [Buildroot] Antw: " Frank Ihle
  0 siblings, 1 reply; 7+ messages in thread
From: Arnout Vandecappelle @ 2014-02-26 17:32 UTC (permalink / raw)
  To: buildroot

On 26/02/14 08:31, Frank Ihle wrote:
> Right setting kernel dependencies makes sense, but I'm not so sure about
> the process: when I have the following makefile
> 
> obj-m += /<path-to-module>/measurement_gpio.o

 The obj-m should not contain a path.

> KDIR := /<BR-path>/output/build/linux-2.6.39/
> PWD := $(shell pwd)
> default:
>     $(MAKE) ARCH=arm
> CROSS_COMPILE=/<BR-path>/output/host/opt/ext-toolchain/bin/arm-none-linux-gnueabi-
> -C modules
> 
> where is then the generated .ko file and how can I make sure that in this
> build process the .ko file will be moved to a certain place ?

 The modules_install target of the kernel will do that:

define ON2_8170_MODULES_INSTALL_TARGET_CMDS
$(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D) \
        modules_install
endef


 If you want to support the same from your own makefile, you should add
something like:

make -C $(KDIR) M=`pwd` INSTALL_MOD_PATH=<...>/output/target \
	modules_install


 By the way, please don't top-post, and strip the irrelevant parts from
the quoted text.

 Regards,
 Arnout

> 
> Kind Regards
> 
> Frank
> 

[snip]

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

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

* [Buildroot] Antw: Re:  In Buildroot, how to compile kernel modules
  2014-02-26 17:32         ` Arnout Vandecappelle
@ 2014-02-28  8:05           ` Frank Ihle
  0 siblings, 0 replies; 7+ messages in thread
From: Frank Ihle @ 2014-02-28  8:05 UTC (permalink / raw)
  To: buildroot

Thanks for the help I'll try that pretty soon. I guess this could get a nice feature in buildroot, if you can tell buildroot where the .c file is located and which parameters should be used and then the program then creates the module to a specific directory in the image.

Kind Regards

Frank

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140228/f18606cb/attachment.html>

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

end of thread, other threads:[~2014-02-28  8:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-25  9:04 [Buildroot] In Buildroot, how to compile kernel modules Frank Ihle
2014-02-25 10:23 ` Raúl Sánchez Siles
2014-02-25 10:38   ` [Buildroot] Antw: " Frank Ihle
2014-02-25 20:40     ` Arnout Vandecappelle
2014-02-26  7:31       ` [Buildroot] " Frank Ihle
2014-02-26 17:32         ` Arnout Vandecappelle
2014-02-28  8:05           ` [Buildroot] Antw: " Frank Ihle

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.