All of lore.kernel.org
 help / color / mirror / Atom feed
* How to develop kernel modules on the target?
@ 2020-12-28 13:40 p32
  2020-12-28 13:48 ` [yocto] " Ovidiu Panait
  0 siblings, 1 reply; 4+ messages in thread
From: p32 @ 2020-12-28 13:40 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

Hello everyone,

I am using the Yocto-based build system provided by NXP (primarily via the meta-freescale layer) to create Linux images for an i.MX 8M board and would like to develop small kernel modules without going through the build process of the entire image after each modification. Therefore, I would prefer to compile the kernel modules on the target architecture and have added the following items to the IMAGE_INSTALL variable via my local.conf:
- packagegroup-core-buildessential
- kernel-modules
- kernel-dev
- kernel-devsrc

I then tried to follow the the official build instructions ( https://www.kernel.org/doc/html/latest/kbuild/modules.html ) on the target but was unable to create a kernel module:
imx8mqevk:~# make -C /lib/modules/$(uname -r)/build M=$PWD
make: Entering directory '/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build'
CC [M]  /root/hello.o
In file included from ./include/linux/types.h:6,
from ./include/linux/list.h:5,
from ./include/linux/module.h:9,
from /root/hello.c:1:
./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
[...]
compilation terminated.

What am I missing here? Is there something else I have to do on the target before I can compile kernel modules on the target?

For the sake of completeness: The build is based on the Zeus release and the following repo manifest file:
https://source.codeaurora.org/external/imx/imx-manifest/tree/imx-5.4.47-2.2.0.xml?h=imx-linux-zeus

Thanks!

[-- Attachment #2: Type: text/html, Size: 2184 bytes --]

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

* Re: [yocto] How to develop kernel modules on the target?
  2020-12-28 13:40 How to develop kernel modules on the target? p32
@ 2020-12-28 13:48 ` Ovidiu Panait
  2020-12-28 19:06   ` p32
  0 siblings, 1 reply; 4+ messages in thread
From: Ovidiu Panait @ 2020-12-28 13:48 UTC (permalink / raw)
  To: p32, yocto

[-- Attachment #1: Type: text/plain, Size: 1906 bytes --]

On 28.12.2020 15:40, p32 via lists.yoctoproject.org wrote:

> Hello everyone,
>
> I am using the Yocto-based build system provided by NXP (primarily via 
> the meta-freescale layer) to create Linux images for an i.MX 8M board 
> and would like to develop small kernel modules without going through 
> the build process of the entire image after each modification. 
> Therefore, I would prefer to compile the kernel modules on the target 
> architecture and have added the following items to the IMAGE_INSTALL 
> variable via my local.conf:
>  - packagegroup-core-buildessential
>  - kernel-modules
>  - kernel-dev
>  - kernel-devsrc
>
> I then tried to follow the the official build instructions 
> (https://www.kernel.org/doc/html/latest/kbuild/modules.html) on the 
> target but was unable to create a kernel module:
> imx8mqevk:~# make -C /lib/modules/$(uname -r)/build M=$PWD
> make: Entering directory '/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build'
>   CC [M]  /root/hello.o
> In file included from ./include/linux/types.h:6,
>                  from ./include/linux/list.h:5,
>                  from ./include/linux/module.h:9,
>                  from /root/hello.c:1:
> ./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such 
> file or directory
>     [...]
> compilation terminated.
>
Hi,


You need to run "make scripts prepare" in /usr/src/kernel before trying 
to compile kernel modules on target.


Ovidiu

> What am I missing here? Is there something else I have to do on the 
> target before I can compile kernel modules on the target?
>
> For the sake of completeness: The build is based on the Zeus release 
> and the following repo manifest file:
> https://source.codeaurora.org/external/imx/imx-manifest/tree/imx-5.4.47-2.2.0.xml?h=imx-linux-zeus
>
> Thanks!
>
> 
>

[-- Attachment #2: Type: text/html, Size: 3265 bytes --]

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

* Re: How to develop kernel modules on the target?
  2020-12-28 13:48 ` [yocto] " Ovidiu Panait
@ 2020-12-28 19:06   ` p32
  2020-12-29  1:43     ` [yocto] " Bruce Ashfield
  0 siblings, 1 reply; 4+ messages in thread
From: p32 @ 2020-12-28 19:06 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Hello,

The execution of "make scripts prepare" did actually solve the issue, thank you very much for your help!

However, the need to manually execute this command on the target platform made me look into the kernel-devsrc recipe ( https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-kernel/linux/kernel-devsrc.bb?h=zeus ) to see if it is possible to let the build host execute this step. Some comments imply that this is the case. Consider, for instance, the one in line 257:

> 
> Ensure we don't race against "make scripts" during cpio

Unfortunately, I was unable to figure out how to do this. Is there a way to let the recipe trigger this step automatically?

Thanks!

[-- Attachment #2: Type: text/html, Size: 891 bytes --]

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

* Re: [yocto] How to develop kernel modules on the target?
  2020-12-28 19:06   ` p32
@ 2020-12-29  1:43     ` Bruce Ashfield
  0 siblings, 0 replies; 4+ messages in thread
From: Bruce Ashfield @ 2020-12-29  1:43 UTC (permalink / raw)
  To: p32; +Cc: yocto

On Mon, Dec 28, 2020 at 2:06 PM p32 via lists.yoctoproject.org
<p32=tuta.io@lists.yoctoproject.org> wrote:
>
> Hello,
>
> The execution of "make scripts prepare" did actually solve the issue, thank you very much for your help!
>
> However, the need to manually execute this command on the target platform made me look into the kernel-devsrc recipe (https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-kernel/linux/kernel-devsrc.bb?h=zeus) to see if it is possible to let the build host execute this step. Some comments imply that this is the case. Consider, for instance, the one in line 257:
>
> Ensure we don't race against "make scripts" during cpio
>
> Unfortunately, I was unable to figure out how to do this. Is there a way to let the recipe trigger this step automatically?
>

Nope. There is no way to do this on the build host. Not without
complex use of qemu-user to generate and package for the target
architecture. We cannot package the output of scripts in the target
package, since it matches the host architecture and this will trigger
a QA error.

If you happen to be x86 build host and x86 target (or ARM/ARM), you
can partially get away with just invoking the steps .. but this needs
to be in your own layer and is a hack, and not appropriate for core.

About 4 years ago, we were partially through doing this work, when the
person doing the qemu parts stopped working on the project. The
partial work is captured in bugzilla.

Cheers,

Bruce

> Thanks!
> 
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

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

end of thread, other threads:[~2020-12-29  1:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 13:40 How to develop kernel modules on the target? p32
2020-12-28 13:48 ` [yocto] " Ovidiu Panait
2020-12-28 19:06   ` p32
2020-12-29  1:43     ` [yocto] " Bruce Ashfield

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.