Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] buildroot and kernel modules
@ 2013-06-19 15:26 jerryalex at tx.rr.com
  2013-06-19 15:35 ` Thomas Petazzoni
  0 siblings, 1 reply; 13+ messages in thread
From: jerryalex at tx.rr.com @ 2013-06-19 15:26 UTC (permalink / raw)
  To: buildroot

looking into how to enter sysbuild rules to automatically have my kernel modules loaded on bootup.

Standard linux uses depmod to enter modules into modules.dep so that they are automatically loaded on bootup.
Right now our NFS file system does not have the depmod command and it appears that editing 
modules.dep by hand and adding entries does not work.

Does buildroot have their own rules to load modules or does it use depmod.
I did not find any instructions in the buildroot user manual addressing the above.

                                                          Thanks,
                                                                  jerry

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

* [Buildroot] buildroot and kernel modules
  2013-06-19 15:26 [Buildroot] buildroot and kernel modules jerryalex at tx.rr.com
@ 2013-06-19 15:35 ` Thomas Petazzoni
       [not found]   ` <20130619155518.8G4TE.59637.root@cdptpa-web08-z02>
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Petazzoni @ 2013-06-19 15:35 UTC (permalink / raw)
  To: buildroot

Dear jerryalex at tx.rr.com,

On Wed, 19 Jun 2013 11:26:41 -0400, jerryalex at tx.rr.com wrote:
> looking into how to enter sysbuild rules to automatically have my kernel modules loaded on bootup.
> 
> Standard linux uses depmod to enter modules into modules.dep so that they are automatically loaded on bootup.

No, that's not how it works. depmod is a tool that you run at kernel
*build* time to generate modules.dep (describes dependencies between
modules), modules.alias (module aliases). Those modules.* files
in /lib/modules/<version>/ are completely unrelated to whether modules
are loaded automatically at boot or not.

To get modules loaded at boot or not, you have two choices (which
sometimes need to be combined together) :

 * Run a hotplug agent, such as udev or mdev, which will get a message
   from the kernel when a device appears, and load the module that
   implements a driver capable of handling this device. To do this,
   the kernel sends a description of the hardware (such as USB VID and
   PID) to the hotplug agent, which can run 'modprobe' with those
   informations, and in turn modprobe will look at modules.alias to
   find the corresponding module to load.

   This works fine if the modules to be loaded are related to some
   piece of hardware for which there is a proper notification from the
   kernel to a userspace hotplug agent.

 * Have a text file like /etc/modules that lists the modules to be
   loaded at boot, and a script in /etc/init.d/ that goes
   through /etc/modules and modprobes each module.

> Right now our NFS file system does not have the depmod command and it appears that editing 
> modules.dep by hand and adding entries does not work.

The depmod command is not needed at run time, only when you build the
kernel and installs the modules.

Editing modules.dep will not change anything in terms of automatic
module loading at boot.

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] 13+ messages in thread

* [Buildroot] buildroot and kernel modules
       [not found]   ` <20130619155518.8G4TE.59637.root@cdptpa-web08-z02>
@ 2013-06-20  7:39     ` Thomas Petazzoni
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Petazzoni @ 2013-06-20  7:39 UTC (permalink / raw)
  To: buildroot

Hello,

Please do not reply to me directly, but keep the Buildroot mailing list
Cc'ed. It would also be nice if you could comply with the basic e-mail
rules: no top-posting, wrapping at ~80 characters, etc.

Anyway, my answers below.

On Wed, 19 Jun 2013 11:55:18 -0400, jerryalex at tx.rr.com wrote:

>         I checked our tftpboot file system and there is no /etc/modules or a comparable script
>         under /etc/init.d to install the modules on bootup.

Because there is no such mechanism in Buildroot by default. You have to
create this /etc/modules file and a corresponding script
in /etc/init.d/.

>         With regard to hotplugging via udev, every time a device is added or removed, the kernel sends a 
>         uevent to notify udev of the change.  This requires the module to be installed for udev to recognize
>         it and create the corresponding /dev entry.
>         So I am missing something on how udev receives notification and runs modprobe.  
>         Modules are being loaded on our bootup so the mechanism exists but I have not been able to determine
>         how it is loading the modules.
>         How does the kernel recognize the device and notify udev of the device availability without loading
>         the module first.

Because the device driver for a given device is not needed to detect
that the device is here. Take USB for example: to detect the USB
devices on a USB bus, you need the driver for the USB *controller* to
be loaded, but not at all the drivers for the USB *devices*. So, as
long as the USB *controller* driver is loaded, it will enumerate the
USB devices that are available on the system's USB busses, and will
send udev events about those devices. udev will then load the USB
*device* drivers using modprobe, and the kernel will be able to
actually use these devices.

Didn't you notice that 'lsusb' shows *all* USB devices, regardless of
whether there is a corresponding kernel driver for them?

So again, on USB or PCI, being able to enumerate/recognize a device is
completely independent from the fact of having a driver for this
particular device.

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] 13+ messages in thread

* [Buildroot] Buildroot and kernel modules
@ 2014-11-12  5:04 Sid Bharij
  2014-11-12 10:03 ` Thomas Petazzoni
  0 siblings, 1 reply; 13+ messages in thread
From: Sid Bharij @ 2014-11-12  5:04 UTC (permalink / raw)
  To: buildroot

Hi,

I have been successful in getting the Linux kernel running on
raspberry pi using build root. I wanted to create my own simple driver
(a kernel module) and make it a part of the kernel. How can I do that
using buildroot?

Thanks,
Sid

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12  5:04 [Buildroot] Buildroot " Sid Bharij
@ 2014-11-12 10:03 ` Thomas Petazzoni
  2014-11-12 12:21   ` Paassen, Hiram van
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Petazzoni @ 2014-11-12 10:03 UTC (permalink / raw)
  To: buildroot

Dear Sid Bharij,

On Tue, 11 Nov 2014 23:04:31 -0600, Sid Bharij wrote:

> I have been successful in getting the Linux kernel running on
> raspberry pi using build root. I wanted to create my own simple driver
> (a kernel module) and make it a part of the kernel. How can I do that
> using buildroot?

When I do my kernel development, I do it outside Buildroot, i.e I just
build the kernel separately. If needed, once the kernel development is
done, I use the final kernel version with my developments in Buildroot.

If you really want to do it with Buildroot, have a look at the
OVERRIDE_SRCDIR feature in the Buildroot manual.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 10:03 ` Thomas Petazzoni
@ 2014-11-12 12:21   ` Paassen, Hiram van
  2014-11-12 12:34     ` Thomas Petazzoni
  0 siblings, 1 reply; 13+ messages in thread
From: Paassen, Hiram van @ 2014-11-12 12:21 UTC (permalink / raw)
  To: buildroot

On wo, 2014-11-12 at 11:03 +0100, Thomas Petazzoni wrote:
> Dear Sid Bharij,
>
> On Tue, 11 Nov 2014 23:04:31 -0600, Sid Bharij wrote:
>
> > I have been successful in getting the Linux kernel running on
> > raspberry pi using build root. I wanted to create my own simple driver
> > (a kernel module) and make it a part of the kernel. How can I do that
> > using buildroot?
>
> When I do my kernel development, I do it outside Buildroot, i.e I just
> build the kernel separately. If needed, once the kernel development is
> done, I use the final kernel version with my developments in Buildroot.
>
> If you really want to do it with Buildroot, have a look at the
> OVERRIDE_SRCDIR feature in the Buildroot manual.
>
> Best regards,
>
> Thomas

As an alternative we use a buildroot package with something like this in
it:

KERNELMODULE_DEPENDENCIES = linux

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

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

$(eval $(generic-package))


which basically builds a normal out of tree module.
So your source folder would contain you foo.c file an a makefile
suitable for normal out of tree building:

ifneq ($(KERNELRELEASE),)
# kbuild part of makefile
obj-m  := foo.o

else
# normal makefile
KDIR ?= /lib/modules/`uname -r`/build

default:
        $(MAKE) -C $(KDIR) M=$$PWD
clean:
        $(MAKE) -C $(KDIR) M=$$PWD clean
endif

Hiram

________________________________

Power Products, LLC Email Notice

This message is intended only for the use of the Addressee and may contain information that is PRIVILEGED and/or CONFIDENTIAL.
This email is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this email is not an intended recipient, you have received this email in error and any review, dissemination, distribution or copying is strictly prohibited.
If you have received this email in error, please notify the sender immediately by return mail and permanently delete the copy you received.

Thank you.

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 12:21   ` Paassen, Hiram van
@ 2014-11-12 12:34     ` Thomas Petazzoni
  2014-11-12 18:25       ` Sid Bharij
  2014-11-12 19:26       ` Bryce Schober
  0 siblings, 2 replies; 13+ messages in thread
From: Thomas Petazzoni @ 2014-11-12 12:34 UTC (permalink / raw)
  To: buildroot

Dear Paassen, Hiram van,

On Wed, 12 Nov 2014 12:21:12 +0000, Paassen, Hiram van wrote:

> As an alternative we use a buildroot package with something like this in
> it:
> 
> KERNELMODULE_DEPENDENCIES = linux
> 
> define KERNELMODULE_BUILD_CMDS
>    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules
> endef
> 
> define KERNELMODULE_INSTALL_TARGET_CMDS
>    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules_install
> endef
> 
> $(eval $(generic-package))
> 
> 
> which basically builds a normal out of tree module.

Yes, that's what should be done if your module is out of tree, indeed.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 12:34     ` Thomas Petazzoni
@ 2014-11-12 18:25       ` Sid Bharij
  2014-11-12 21:27         ` Thomas Petazzoni
  2014-11-12 19:26       ` Bryce Schober
  1 sibling, 1 reply; 13+ messages in thread
From: Sid Bharij @ 2014-11-12 18:25 UTC (permalink / raw)
  To: buildroot

Thank you gentlemen!
So I have the driver source file and makefile for it.
Where does this part go into ? Does it go into the Config.in file or some
top level makefile or the same makefile needed for compiling the driver
code?

KERNELMODULE_DEPENDENCIES = linux

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

define KERNELMODULE_INSTALL_TARGET_
CMDS
   $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules_install
endef

$(eval $(generic-package))


On Wed, Nov 12, 2014 at 6:34 AM, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:

> Dear Paassen, Hiram van,
>
> On Wed, 12 Nov 2014 12:21:12 +0000, Paassen, Hiram van wrote:
>
> > As an alternative we use a buildroot package with something like this in
> > it:
> >
> > KERNELMODULE_DEPENDENCIES = linux
> >
> > define KERNELMODULE_BUILD_CMDS
> >    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules
> > endef
> >
> > define KERNELMODULE_INSTALL_TARGET_CMDS
> >    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules_install
> > endef
> >
> > $(eval $(generic-package))
> >
> >
> > which basically builds a normal out of tree module.
>
> Yes, that's what should be done if your module is out of tree, indeed.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20141112/8a0808eb/attachment.html>

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 12:34     ` Thomas Petazzoni
  2014-11-12 18:25       ` Sid Bharij
@ 2014-11-12 19:26       ` Bryce Schober
  2014-11-12 21:03         ` Thomas Petazzoni
  1 sibling, 1 reply; 13+ messages in thread
From: Bryce Schober @ 2014-11-12 19:26 UTC (permalink / raw)
  To: buildroot

I reluctantly hijack this thread to ask a very closely related question: Is
there a way to build an out-of-tree module like this using the
buildroot-compiled linux headers, instead of the possibly-older
toolchain-provided linux headers?


<><  <><  <><
Bryce Schober

On Wed, Nov 12, 2014 at 4:34 AM, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:

> Dear Paassen, Hiram van,
>
> On Wed, 12 Nov 2014 12:21:12 +0000, Paassen, Hiram van wrote:
>
> > As an alternative we use a buildroot package with something like this in
> > it:
> >
> > KERNELMODULE_DEPENDENCIES = linux
> >
> > define KERNELMODULE_BUILD_CMDS
> >    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules
> > endef
> >
> > define KERNELMODULE_INSTALL_TARGET_CMDS
> >    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules_install
> > endef
> >
> > $(eval $(generic-package))
> >
> >
> > which basically builds a normal out of tree module.
>
> Yes, that's what should be done if your module is out of tree, indeed.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
> _______________________________________________
> 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/20141112/6c98aabe/attachment.html>

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 19:26       ` Bryce Schober
@ 2014-11-12 21:03         ` Thomas Petazzoni
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Petazzoni @ 2014-11-12 21:03 UTC (permalink / raw)
  To: buildroot

Dear Bryce Schober,

On Wed, 12 Nov 2014 11:26:00 -0800, Bryce Schober wrote:

> I reluctantly hijack this thread to ask a very closely related question: Is
> there a way to build an out-of-tree module like this using the
> buildroot-compiled linux headers, instead of the possibly-older
> toolchain-provided linux headers?

A kernel module is never built using the linux headers provided by the
toolchain. The linux headers provided by the toolchain only contain the
userspace part of the kernel headers, and they are therefore
insufficient to build kernel modules (which as their name suggest,
contain kernel code).

Therefore, when you do something like:

> > > define KERNELMODULE_BUILD_CMDS
> > >    $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules
> > > endef

It uses the kernel code in $(LINUX_DIR), and mainly the kernel headers
+ kernel configuration, to build your kernel modules.

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 18:25       ` Sid Bharij
@ 2014-11-12 21:27         ` Thomas Petazzoni
  2014-11-12 22:19           ` Sid Bharij
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Petazzoni @ 2014-11-12 21:27 UTC (permalink / raw)
  To: buildroot

Dear Sid Bharij,

On Wed, 12 Nov 2014 12:25:45 -0600, Sid Bharij wrote:

> So I have the driver source file and makefile for it.
> Where does this part go into ? Does it go into the Config.in file or some
> top level makefile or the same makefile needed for compiling the driver
> code?

You seem to misunderstand what Buildroot is. Buildroot is a build
system, its aim is to build the various components of your embedded
Linux system. It is not meant to carry the source code of those
individual components.

So your driver source file and makefile for it has to be its own
project, stored somewhere (most likely under version control), and
Buildroot will download it from where it's located and build it.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 21:27         ` Thomas Petazzoni
@ 2014-11-12 22:19           ` Sid Bharij
  2014-11-12 22:20             ` Thomas Petazzoni
  0 siblings, 1 reply; 13+ messages in thread
From: Sid Bharij @ 2014-11-12 22:19 UTC (permalink / raw)
  To: buildroot

I am sorry if I caused this confusion. I do understand that buildroot
is a build system, I am just trying to build my driver files using
build root by the way of packages. What I was referring to were the
lines pasted by Hiram below:(Do I need to add these to a top level
package.mk file?)

KERNELMODULE_DEPENDENCIES = linux

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

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

$(eval $(generic-package))

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

* [Buildroot] Buildroot and kernel modules
  2014-11-12 22:19           ` Sid Bharij
@ 2014-11-12 22:20             ` Thomas Petazzoni
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Petazzoni @ 2014-11-12 22:20 UTC (permalink / raw)
  To: buildroot

Dear Sid Bharij,

On Wed, 12 Nov 2014 16:19:27 -0600, Sid Bharij wrote:
> I am sorry if I caused this confusion. I do understand that buildroot
> is a build system, I am just trying to build my driver files using
> build root by the way of packages. What I was referring to were the
> lines pasted by Hiram below:(Do I need to add these to a top level
> package.mk file?)

Just create your own package. This is explained extensively in the
Buildroot documentation, see
http://buildroot.org/downloads/manual/manual.html#adding-packages.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2014-11-12 22:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-19 15:26 [Buildroot] buildroot and kernel modules jerryalex at tx.rr.com
2013-06-19 15:35 ` Thomas Petazzoni
     [not found]   ` <20130619155518.8G4TE.59637.root@cdptpa-web08-z02>
2013-06-20  7:39     ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2014-11-12  5:04 [Buildroot] Buildroot " Sid Bharij
2014-11-12 10:03 ` Thomas Petazzoni
2014-11-12 12:21   ` Paassen, Hiram van
2014-11-12 12:34     ` Thomas Petazzoni
2014-11-12 18:25       ` Sid Bharij
2014-11-12 21:27         ` Thomas Petazzoni
2014-11-12 22:19           ` Sid Bharij
2014-11-12 22:20             ` Thomas Petazzoni
2014-11-12 19:26       ` Bryce Schober
2014-11-12 21:03         ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox