* Re: [Buildroot] how can i implement my kernel module and debug it
[not found] <mailman.16364.1634462006.241441.buildroot@buildroot.org>
@ 2021-10-17 9:45 ` Andreas Ziegler
[not found] ` <CA+eej5PtS6iCJ+W1b6W0mZXk-fQJcB1hhr20_D7cE=fja8NzTw@mail.gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2021-10-17 9:45 UTC (permalink / raw)
To: Esa?e Ledoux NJONGSSI KOUAM; +Cc: buildroot
Hi Esaie,
On 2021-10-17 09:13, Esa?e Ledoux NJONGSSI KOUAM <kouamdoux@gmail.com>
wrote:
> Hi everyone .
> Sorry for the inconvenience , ...
>
> I want to know how to load my kernel module, run it see these traces
> using
> dmesg and debug it.
>
Buildroot is essentially a deployment tool, not a development
infrastructure. You do need a working package to be able to integrate
it.
Preferably, you do this step-by-step:
-- develop your kernel module, make sure it compiles and works correctly
in your development environment
-- integrate the package into Buildroot (see comments below)
-- check if the package builds correctly within Buildroot and gets
deployed to target/lib/modules
-- test on target hardware
> So , i have read this part of the (manual
> <https://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_building_kernel_modules>)
> , but i don't know how to use it :
>
> | What you may have noticed is that, unlike other package
> infrastructures,
> we | explicitly invoke a second infrastructure. This allows a package
> to
> build a kernel | module, but also, if needed, use any one of other
> package
> infrastructures to | build normal userland components (libraries,
> executables?). Using the kernel-module infrastructure on its own is not
> sufficient; another package infrastructure *must* be used.
This means that a 'normal' build infrastructure (make, cmake, etc.) has
to be used; you covered this by using "generic-package" and providing a
(project) make file.
> but in my way , i have try something :
>
> - Config.in
>
> config BR2_PACKAGE_KERNEL_MODULE
> bool "kernel_module"
> depends on BR2_LINUX_KERNEL
> help
> Linux Kernel Module Cheat.
>
> - external.mk
>
> KERNEL_MODULE_VERSION = 1.0
> KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)
> KERNEL_MODULE_SITE_METHOD = local
> $(eval $(kernel-module))
> $(eval $(generic-package))
This file has the same name as your package: "kernel-module.mk". Do not
mix Buildroot configuration (BR2_EXTERNAL) and development project;
provide a path to your source directory in KERNEL_MODULE_SITE.
If you want to use a BR2_EXTERNAL directory structure, some more work is
necessary; see [1]. It will be easier to install your configuration in
the Buildroot tree; in that case, all of these files go into the
Buildroot package directory, inside a directory named "kernel-module".
Edit "package/Config.in" and add your package under a convenient menu
heading.
The files below go into your project directory, the one that is
referenced by $KERNEL_MODULE_SITE
> - Makefile
>
> obj-m += $(addsuffix .o, $(notdir $(basename $(wildcard
> $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/*.c))))
> ccflags-y := -DDEBUG -g -std=gnu99 -Wno-declaration-after-statement
>
> .PHONY: all clean
>
> all:
> $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' modules
>
> clean:
> $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
Do not use Buildroot specific variables in your project makefile.
Variables should be initialized. You are missing a modules_install
target, see [2].
> - hello.c
>
> #include <linux/module.h>#include <linux/kernel.h>
>
> MODULE_LICENSE("GPL");
> static int myinit(void)
> {
> printk(KERN_INFO "hello init\n");
> return 0;
> }
> static void myexit(void)
> {
> printk(KERN_INFO "hello exit\n");
> }
>
> module_init(myinit)
> module_exit(myexit)
>
> And in the terminal :
>
> make BR2_EXTERNAL="$(pwd)/../kernel_module" qemu_x86_64_defconfig
> echo 'BR2_PACKAGE_KERNEL_MODULE=y' >> .config
> make BR2_JLEVEL="$(($(nproc) - 2))" all
> qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive
> file=output/images/rootfs.ext2,if=virtio,format=raw -append
> root=/dev/vda -net nic,model=virtio -net user
If you plan to use BR2_EXTERNAL, provide all necessary files.
make <defconfig> needs to be run only once, to create a configuration.
The configuration persists, until you modify it with "make
{menu,n}config" or you call "make distclean". For the different
configuration editors, see [3].
Start the config editor, select your package, exit and save. Afterwards
start the build process:
$ make nconfig
$ make
> On qemu :
>
> modprobe hello
> modprobe: module hello not found in modules.dep
The module has not been built and is not present on the target system.
> how can i solve it ??
>
> please i need your help
Kind regards,
Andreas
[1] https://buildroot.org/downloads/manual/manual.html#outside-br-custom
[2]
https://www.kernel.org/doc/html/latest/kbuild/modules.html?highlight=modules%20symvers
[3]
https://buildroot.org/downloads/manual/manual.html#_buildroot_quick_start
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
[not found] ` <CA+eej5PtS6iCJ+W1b6W0mZXk-fQJcB1hhr20_D7cE=fja8NzTw@mail.gmail.com>
@ 2021-10-19 5:47 ` Andreas Ziegler
2021-10-19 14:34 ` Esaïe Ledoux NJONGSSI KOUAM
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2021-10-19 5:47 UTC (permalink / raw)
To: Esaïe Ledoux NJONGSSI KOUAM; +Cc: buildroot
Hi Esaïe
<appended Buildroot list>
On 2021-10-18 23:19, Esaïe Ledoux NJONGSSI KOUAM wrote:
> my kernel module works very well ,
>
> in qemu , i have type lsmod , but nothing , doesn't it means that
> linux kernel image doesn't build ??
<cut>
With the original config files, the module will not be built. Once it
gets built, the missing modules_install may prevent copying it into
/lib/modules in the target.
To see which steps were executed by Buildroot, run
$ grep kernel-module build/build-time.log
This file contains timestamps of all tasks executed by the Buildroot
environment.
> i have make something like you have said , but the problem still occur
-- Make sure your configuration is visible to Buildroot. You must be
able to select it in the menu editor (make nconfig).
-- Build your module separately by calling 'make kernel-module-rebuild'
and analyze the output. You should get headings for the separate build
steps (downloading, extracting, patching, configuring, building,
installing). Some sections may be missing or empty, but at least
'building/installing' must show output from your module. You might also
run build steps separately, until you find the one that fails; see [4]
-- Verify that the directory build/kernel-module exists and contains the
expected files.
-- Check target/lib/modules/${BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE} to
see if your module is included.
Kind regards,
Andreas
[4] https://buildroot.org/downloads/manual/manual.html#pkg-build-steps
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-19 14:34 ` Esaïe Ledoux NJONGSSI KOUAM
@ 2021-10-19 12:45 ` Arnout Vandecappelle
2021-10-20 7:17 ` Andreas Ziegler
1 sibling, 0 replies; 11+ messages in thread
From: Arnout Vandecappelle @ 2021-10-19 12:45 UTC (permalink / raw)
To: Esaïe Ledoux NJONGSSI KOUAM, Andreas Ziegler; +Cc: buildroot
On 19/10/2021 16:34, Esaïe Ledoux NJONGSSI KOUAM wrote:
[snip]
> kernel_module_test.mk <http://kernel_module_test.mk> :
>
> KERNEL_MODULE_VERSION = 1.0
> KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
> KERNEL_MODULE_SITE_METHOD = local
> $(eval $(kernel_module_test))
This should be kernel-module, not kernel_module_test.
Regards,
Arnout
> $(eval $(generic-package))
[snip]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-19 5:47 ` Andreas Ziegler
@ 2021-10-19 14:34 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-19 12:45 ` Arnout Vandecappelle
2021-10-20 7:17 ` Andreas Ziegler
0 siblings, 2 replies; 11+ messages in thread
From: Esaïe Ledoux NJONGSSI KOUAM @ 2021-10-19 14:34 UTC (permalink / raw)
To: Andreas Ziegler; +Cc: buildroot
[-- Attachment #1.1: Type: text/plain, Size: 2581 bytes --]
so i have develop my kernel module and it is working very well.
there is my folder :
hello.c :
#include <linux/module.h> // included for all kernel modules
#include <linux/kernel.h> // included for KERN_INFO
#include <linux/init.h> // included for __init and __exit macros
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world!\n");
return 0; // Non-zero return means that the module couldn't be
loaded.
}
static void __exit hello_cleanup(void)
{
printk(KERN_INFO "Cleaning up module.\n");
}
module_init(hello_init);
module_exit(hello_cleanup);
> Makefile :
obj-m += helloKernelModule.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
when i run make , it generate some files like hello.o , hello.ko , ...
> integrate the package into Buildroot (see comments below)
But , i'm not understanding very well when you said i integrate the package
on buildroot. Is it only the Makefile and the hello.c code or Makefile ,
hello.c code , hello.o , hello.ko , ... ?
> check if the package builds correctly within Buildroot and gets
deployed to target/lib/modules
Okay , i have put the project on one folder kernel_module_test in buildroot
tree
external.desc :
name: BR2_PACKAGE_KERNEL_MODULE_TEST
external.mk :
include $(sort $(wildcard $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/*/*.mk))
Config.in :
config BR2_PACKAGE_KERNEL_MODULE_TEST
bool "kernel_module_test"
depends on BR2_LINUX_KERNEL
help
Linux Kernel Module Cheat.
kernel_module_test.mk :
KERNEL_MODULE_VERSION = 1.0
KERNEL_MODULE_SITE =
$(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
KERNEL_MODULE_SITE_METHOD = local
$(eval $(kernel_module_test))
$(eval $(generic-package))
As you can see , i want to use a BR2_EXTERNAL directory structure.
So i have make it by typing :
/buildroot# make BR2_EXTERNAL=kernel_module_test menuconfig
Go ahead into External Options , and fortunatly , i have see my package
inside, .. so i have saved it and exit.
After that i have type make.
i have seen my package on output/build , looks like kernel_module_test
folder that contains some files.
Finaly , i have seen some files on
output/target/lib/modules/${BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE} but not
my module.
So i think that it means that my modules/package was not loaded and i can't
exploit it.
please where i have mistaken ??
[-- Attachment #1.2: Type: text/html, Size: 4262 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-19 14:34 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-19 12:45 ` Arnout Vandecappelle
@ 2021-10-20 7:17 ` Andreas Ziegler
2021-10-21 7:58 ` Esaïe Ledoux NJONGSSI KOUAM
1 sibling, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2021-10-20 7:17 UTC (permalink / raw)
To: Esaïe Ledoux NJONGSSI KOUAM; +Cc: buildroot
Hi Esaïe,
TL;DR: Main problem is probably the one Arnout mentioned. Fix
external.desc, kernel-module-test.mk and Makefile; in that order.
There are still some inconsistencies in your configuration, see remarks
below.
Stick to '-' (dash) in file names and '_' (underscore) in (k)config
variables. The Linux kernel uses the same convention.
On 2021-10-19 14:34, Esaïe Ledoux NJONGSSI KOUAM wrote:
> so i have develop my kernel module and it is working very well.
>
> there is my folder :
>
> hello.c :
>
> #include <linux/module.h> // included for all kernel modules
> #include <linux/kernel.h> // included for KERN_INFO
> #include <linux/init.h> // included for __init and __exit macros
>
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Lakshmanan");
> MODULE_DESCRIPTION("A Simple Hello World module");
>
> static int __init hello_init(void)
> {
> printk(KERN_INFO "Hello world!\n");
> return 0; // Non-zero return means that the module couldn't be
> loaded.
> }
>
> static void __exit hello_cleanup(void)
> {
> printk(KERN_INFO "Cleaning up module.\n");
> }
>
> module_init(hello_init);
> module_exit(hello_cleanup);
>
>> Makefile :
>
> obj-m += helloKernelModule.o
> all:
> make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
>
> clean:
> make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
>
> when i run make , it generate some files like hello.o , hello.ko , ...
This Makefile is broken, and will also not work correctly when run from
inside the Buildroot environment: the syntax is incorrect, there is no
rule how to make helloKernelModule.o from hello.c, you have an absolute
reference to your host kernel, which is different from the one Buildroot
uses.
Introduce variables that work on your development machine, but can be
overridden by Buildroot:
obj-m := HelloKernelModule.o
HelloKernelModule-objs := hello.o
MAKE := make
KSRC := /lib/modules/$(shell uname -r)/build/
SRC := $(shell pwd)
modules:
$(MAKE) -C $(KSRC) M=$(SRC) modules
modules_install:
$(MAKE) -C $(KSRC) M=$(SRC) modules_install
clean:
$(MAKE) -C $(KSRC) M=$(SRC) clean
>> integrate the package into Buildroot (see comments below)
>
> But , i'm not understanding very well when you said i integrate the
> package on buildroot. Is it only the Makefile and the hello.c code or
> Makefile , hello.c code , hello.o , hello.ko , ... ?
None of these. Your project is distinct; Buildroot sees it only as a
source code package - a tarball that you download from the internet.
Buildroot integration means defining where the source code can be found
and what to to with it (Config.in and kernel-module-test.mk).
>> check if the package builds correctly within Buildroot and gets
> deployed to target/lib/modules
>
> Okay , i have put the project on one folder kernel_module_test in
> buildroot tree
>
> external.desc :
>
> name: BR2_PACKAGE_KERNEL_MODULE_TEST
This is not a Buildroot variable, but something that you define. So call
it just KERNEL_MODULE_TEST. The string defined here will be inserted
between 'BR2_EXTERNAL_' and '_PATH' ...
> external.mk [1] :
>
> include $(sort $(wildcard
> $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/*/*.mk))
BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH is undefined and expands to an
empty string. This probably works only because the files are located
inside the buildroot tree. Should work correctly, once you fix 'name' in
external.desc.
> Config.in :
>
> config BR2_PACKAGE_KERNEL_MODULE_TEST
> bool "kernel_module_test"
> depends on BR2_LINUX_KERNEL
> help
> Linux Kernel Module Cheat.
>
> kernel_module_test.mk [2] :
>
> KERNEL_MODULE_VERSION = 1.0
> KERNEL_MODULE_SITE =
> $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
> KERNEL_MODULE_SITE_METHOD = local
> $(eval $(kernel_module_test))
> $(eval $(generic-package))
You renamed the project to KERNEL_MODULE_TEST. You must also do this to
the variables in the .mk file. But do NOT rename $(eval
$(kernel-module))!
> As you can see , i want to use a BR2_EXTERNAL directory structure.
>
> So i have make it by typing :
>
> /buildroot# make BR2_EXTERNAL=kernel_module_test menuconfig
>
> Go ahead into External Options , and fortunatly , i have see my
> package inside, .. so i have saved it and exit.
>
> After that i have type make.
>
> i have seen my package on output/build , looks like
> kernel_module_test folder that contains some files.
Yes, but which files? They should be identical to the output of 'make'
in the project folder. The important file is HelloKernelModule.ko.
> Finaly , i have seen some files on
> output/target/lib/modules/${BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE} but
> not my module.
Eventually you will have a folder 'extra' in target/lib/modules/$(uname
-r), containing HelloKernelModule.ko. Also modules.dep will have a
corresponding entry at the end.
> So i think that it means that my modules/package was not loaded and i
> can't exploit it.
>
> please where i have mistaken ??
>
>
> Links:
> ------
> [1] http://external.mk
> [2] http://kernel_module_test.mk
Kind regards,
Andreas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-21 7:58 ` Esaïe Ledoux NJONGSSI KOUAM
@ 2021-10-21 6:41 ` Andreas Ziegler
2021-10-21 10:51 ` Esaïe Ledoux NJONGSSI KOUAM
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Ziegler @ 2021-10-21 6:41 UTC (permalink / raw)
To: Esaïe Ledoux NJONGSSI KOUAM; +Cc: buildroot
Hi Esaïe,
check the variables in kernel_module_test.mk. They need to be prefixed
with KERNEL_MODULE_TEST.
On 2021-10-21 07:58, Esaïe Ledoux NJONGSSI KOUAM wrote:
> Okay ...
> I think I have a new form of error, I think it is while compiling.
>
> buildroot# make kernel_module_test-dirclean
> rm -Rf
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test
>
> /buildroot# make
>>>> kernel_module_test Extracting
>>>> kernel_module_test Patching
>>>> kernel_module_test Configuring
>>>> kernel_module_test Building
>>>> kernel_module_test Building kernel module(s)
> PATH="/home/ledoux/Documents/buildroot/output/host/bin:/home/ledoux/Documents/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
> PKG_CONFIG="/home/ledoux/Documents/buildroot/output/host/bin/pkg-config"
> PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
> PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
> PKG_CONFIG_LIBDIR="/home/ledoux/Documents/buildroot/output/host/lib/pkgconfig:/home/ledoux/Documents/buildroot/output/host/share/pkgconfig"
> BR_BINARIES_DIR=/home/ledoux/Documents/buildroot/output/images
> KCFLAGS=-Wno-attribute-alias /usr/bin/make -j3 -C
> /home/ledoux/Documents/buildroot/output/build/linux-5.10.73
> HOSTCC="/usr/bin/gcc -O2
> -I/home/ledoux/Documents/buildroot/output/host/include
> -L/home/ledoux/Documents/buildroot/output/host/lib
> -Wl,-rpath,/home/ledoux/Documents/buildroot/output/host/lib"
> ARCH=x86_64
> INSTALL_MOD_PATH=/home/ledoux/Documents/buildroot/output/target
> CROSS_COMPILE="/home/ledoux/Documents/buildroot/output/host/bin/x86_64-buildroot-linux-uclibc-"
> DEPMOD=/home/ledoux/Documents/buildroot/output/host/sbin/depmod
> INSTALL_MOD_STRIP=1
> PWD=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.
> M=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.
> modules
> make[1] : on entre dans le répertoire «
> /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
> scripts/Makefile.build:44:
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile:
> Aucun fichier ou dossier de ce type
> make[2]: *** Aucune règle pour fabriquer la cible «
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile
> ». Arrêt.
> make[1]: *** [Makefile:1822 :
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/.]
> Erreur 2
> make[1] : on quitte le répertoire «
> /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
> make: *** [package/pkg-generic.mk:295 [4] :
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/.stamp_built]
> Erreur 2
<cut>
Kind regards,
Andreas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-20 7:17 ` Andreas Ziegler
@ 2021-10-21 7:58 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-21 6:41 ` Andreas Ziegler
0 siblings, 1 reply; 11+ messages in thread
From: Esaïe Ledoux NJONGSSI KOUAM @ 2021-10-21 7:58 UTC (permalink / raw)
To: Andreas Ziegler; +Cc: buildroot
[-- Attachment #1.1: Type: text/plain, Size: 9057 bytes --]
Okay ...
I think I have a new form of error, I think it is while compiling.
buildroot# make kernel_module_test-dirclean
rm -Rf /home/ledoux/Documents/buildroot/output/build/kernel_module_test
/buildroot# make
>>> kernel_module_test Extracting
>>> kernel_module_test Patching
>>> kernel_module_test Configuring
>>> kernel_module_test Building
>>> kernel_module_test Building kernel module(s)
PATH="/home/ledoux/Documents/buildroot/output/host/bin:/home/ledoux/Documents/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
PKG_CONFIG="/home/ledoux/Documents/buildroot/output/host/bin/pkg-config"
PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
PKG_CONFIG_LIBDIR="/home/ledoux/Documents/buildroot/output/host/lib/pkgconfig:/home/ledoux/Documents/buildroot/output/host/share/pkgconfig"
BR_BINARIES_DIR=/home/ledoux/Documents/buildroot/output/images
KCFLAGS=-Wno-attribute-alias /usr/bin/make -j3 -C
/home/ledoux/Documents/buildroot/output/build/linux-5.10.73
HOSTCC="/usr/bin/gcc -O2
-I/home/ledoux/Documents/buildroot/output/host/include
-L/home/ledoux/Documents/buildroot/output/host/lib
-Wl,-rpath,/home/ledoux/Documents/buildroot/output/host/lib" ARCH=x86_64
INSTALL_MOD_PATH=/home/ledoux/Documents/buildroot/output/target
CROSS_COMPILE="/home/ledoux/Documents/buildroot/output/host/bin/x86_64-buildroot-linux-uclibc-"
DEPMOD=/home/ledoux/Documents/buildroot/output/host/sbin/depmod
INSTALL_MOD_STRIP=1
PWD=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.
M=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/. modules
make[1] : on entre dans le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
scripts/Makefile.build:44:
/home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile:
Aucun fichier ou dossier de ce type
make[2]: *** Aucune règle pour fabriquer la cible
« /home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile
».
Arrêt.
make[1]: *** [Makefile:1822 :
/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.] Erreur 2
make[1] : on quitte le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
make: *** [package/pkg-generic.mk:295 :
/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.stamp_built]
Erreur 2
however here is what is inside the files:
Config.in :
config BR2_PACKAGE_KERNEL_MODULE_TEST
bool "kernel_module_test"
depends on BR2_LINUX_KERNEL
help
Linux Kernel Module Cheat.
Makefile :
obj-m := HelloKernelModule.o
HelloKernelModule-objs := hello.o
MAKE := make
KSRC := /lib/modules/$(shell uname -r)/build/
SRC := $(shell pwd)
modules:
$(MAKE) -C $(KSRC) M=$(SRC) modules
modules_install:
$(MAKE) -C $(KSRC) M=$(SRC) modules_install
clean:
$(MAKE) -C $(KSRC) M=$(SRC) clean
external.desc :
name: KERNEL_MODULE_TEST
kernel_module_test.mk :
KERNEL_MODULE_VERSION = 1.0
KERNEL_MODULE_SITE =
$(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
KERNEL_MODULE_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))
I'm not understanding very well that compilation error??
Where is it coming from ??
Le mer. 20 oct. 2021 à 08:17, Andreas Ziegler <br015@umbiko.net> a écrit :
> Hi Esaïe,
>
> TL;DR: Main problem is probably the one Arnout mentioned. Fix
> external.desc, kernel-module-test.mk and Makefile; in that order.
>
> There are still some inconsistencies in your configuration, see remarks
> below.
>
> Stick to '-' (dash) in file names and '_' (underscore) in (k)config
> variables. The Linux kernel uses the same convention.
>
> On 2021-10-19 14:34, Esaïe Ledoux NJONGSSI KOUAM wrote:
> > so i have develop my kernel module and it is working very well.
> >
> > there is my folder :
> >
> > hello.c :
> >
> > #include <linux/module.h> // included for all kernel modules
> > #include <linux/kernel.h> // included for KERN_INFO
> > #include <linux/init.h> // included for __init and __exit macros
> >
> > MODULE_LICENSE("GPL");
> > MODULE_AUTHOR("Lakshmanan");
> > MODULE_DESCRIPTION("A Simple Hello World module");
> >
> > static int __init hello_init(void)
> > {
> > printk(KERN_INFO "Hello world!\n");
> > return 0; // Non-zero return means that the module couldn't be
> > loaded.
> > }
> >
> > static void __exit hello_cleanup(void)
> > {
> > printk(KERN_INFO "Cleaning up module.\n");
> > }
> >
> > module_init(hello_init);
> > module_exit(hello_cleanup);
> >
> >> Makefile :
> >
> > obj-m += helloKernelModule.o
> > all:
> > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
> >
> > clean:
> > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
> >
> > when i run make , it generate some files like hello.o , hello.ko , ...
>
> This Makefile is broken, and will also not work correctly when run from
> inside the Buildroot environment: the syntax is incorrect, there is no
> rule how to make helloKernelModule.o from hello.c, you have an absolute
> reference to your host kernel, which is different from the one Buildroot
> uses.
>
> Introduce variables that work on your development machine, but can be
> overridden by Buildroot:
>
> obj-m := HelloKernelModule.o
> HelloKernelModule-objs := hello.o
>
> MAKE := make
> KSRC := /lib/modules/$(shell uname -r)/build/
> SRC := $(shell pwd)
>
> modules:
> $(MAKE) -C $(KSRC) M=$(SRC) modules
>
> modules_install:
> $(MAKE) -C $(KSRC) M=$(SRC) modules_install
>
> clean:
> $(MAKE) -C $(KSRC) M=$(SRC) clean
>
> >> integrate the package into Buildroot (see comments below)
> >
> > But , i'm not understanding very well when you said i integrate the
> > package on buildroot. Is it only the Makefile and the hello.c code or
> > Makefile , hello.c code , hello.o , hello.ko , ... ?
>
> None of these. Your project is distinct; Buildroot sees it only as a
> source code package - a tarball that you download from the internet.
> Buildroot integration means defining where the source code can be found
> and what to to with it (Config.in and kernel-module-test.mk).
>
> >> check if the package builds correctly within Buildroot and gets
> > deployed to target/lib/modules
> >
> > Okay , i have put the project on one folder kernel_module_test in
> > buildroot tree
> >
> > external.desc :
> >
> > name: BR2_PACKAGE_KERNEL_MODULE_TEST
>
> This is not a Buildroot variable, but something that you define. So call
> it just KERNEL_MODULE_TEST. The string defined here will be inserted
> between 'BR2_EXTERNAL_' and '_PATH' ...
>
> > external.mk [1] :
> >
> > include $(sort $(wildcard
> > $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/*/*.mk))
>
> BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH is undefined and expands to an
> empty string. This probably works only because the files are located
> inside the buildroot tree. Should work correctly, once you fix 'name' in
> external.desc.
>
> > Config.in :
> >
> > config BR2_PACKAGE_KERNEL_MODULE_TEST
> > bool "kernel_module_test"
> > depends on BR2_LINUX_KERNEL
> > help
> > Linux Kernel Module Cheat.
> >
> > kernel_module_test.mk [2] :
> >
> > KERNEL_MODULE_VERSION = 1.0
> > KERNEL_MODULE_SITE =
> > $(BR2_EXTERNAL_KERNEL_MODULE_TEST_PATH)/kernel_module_test
> > KERNEL_MODULE_SITE_METHOD = local
> > $(eval $(kernel_module_test))
> > $(eval $(generic-package))
>
> You renamed the project to KERNEL_MODULE_TEST. You must also do this to
> the variables in the .mk file. But do NOT rename $(eval
> $(kernel-module))!
>
> > As you can see , i want to use a BR2_EXTERNAL directory structure.
> >
> > So i have make it by typing :
> >
> > /buildroot# make BR2_EXTERNAL=kernel_module_test menuconfig
> >
> > Go ahead into External Options , and fortunatly , i have see my
> > package inside, .. so i have saved it and exit.
> >
> > After that i have type make.
> >
> > i have seen my package on output/build , looks like
> > kernel_module_test folder that contains some files.
>
> Yes, but which files? They should be identical to the output of 'make'
> in the project folder. The important file is HelloKernelModule.ko.
>
> > Finaly , i have seen some files on
> > output/target/lib/modules/${BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE} but
> > not my module.
>
> Eventually you will have a folder 'extra' in target/lib/modules/$(uname
> -r), containing HelloKernelModule.ko. Also modules.dep will have a
> corresponding entry at the end.
>
> > So i think that it means that my modules/package was not loaded and i
> > can't exploit it.
> >
> > please where i have mistaken ??
> >
> >
> > Links:
> > ------
> > [1] http://external.mk
> > [2] http://kernel_module_test.mk
>
> Kind regards,
> Andreas
>
[-- Attachment #1.2: Type: text/html, Size: 12004 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-21 6:41 ` Andreas Ziegler
@ 2021-10-21 10:51 ` Esaïe Ledoux NJONGSSI KOUAM
0 siblings, 0 replies; 11+ messages in thread
From: Esaïe Ledoux NJONGSSI KOUAM @ 2021-10-21 10:51 UTC (permalink / raw)
To: Andreas Ziegler; +Cc: buildroot
[-- Attachment #1.1: Type: text/plain, Size: 10050 bytes --]
thank you very much all of you.
It is working very well now .
So there is the kernel_module_test.mk :
KERNEL_MODULE_TEST_VERSION = 1.0
KERNEL_MODULE_TEST_SITE = kernel_module_test
KERNEL_MODULE_TEST_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))
there is the output :
>>> kernel_module_test 1.0 Syncing from source dir kernel_module_test
rsync -au --chmod=u=rwX,go=rX --exclude .svn --exclude .git --exclude .hg
--exclude .bzr --exclude CVS kernel_module_test/
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0
>>> kernel_module_test 1.0 Configuring
>>> kernel_module_test 1.0 Building
>>> kernel_module_test 1.0 Building kernel module(s)
PATH="/home/ledoux/Documents/buildroot/output/host/bin:/home/ledoux/Documents/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
PKG_CONFIG="/home/ledoux/Documents/buildroot/output/host/bin/pkg-config"
PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
PKG_CONFIG_LIBDIR="/home/ledoux/Documents/buildroot/output/host/lib/pkgconfig:/home/ledoux/Documents/buildroot/output/host/share/pkgconfig"
BR_BINARIES_DIR=/home/ledoux/Documents/buildroot/output/images
KCFLAGS=-Wno-attribute-alias /usr/bin/make -j3 -C
/home/ledoux/Documents/buildroot/output/build/linux-5.10.73
HOSTCC="/usr/bin/gcc -O2
-I/home/ledoux/Documents/buildroot/output/host/include
-L/home/ledoux/Documents/buildroot/output/host/lib
-Wl,-rpath,/home/ledoux/Documents/buildroot/output/host/lib" ARCH=x86_64
INSTALL_MOD_PATH=/home/ledoux/Documents/buildroot/output/target
CROSS_COMPILE="/home/ledoux/Documents/buildroot/output/host/bin/x86_64-buildroot-linux-uclibc-"
DEPMOD=/home/ledoux/Documents/buildroot/output/host/sbin/depmod
INSTALL_MOD_STRIP=1
PWD=/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/.
M=/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/.
modules
make[1] : on entre dans le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
CC [M]
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./hello.o
LD [M]
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./HelloKernelModule.o
MODPOST
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./Module.symvers
CC [M]
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./HelloKernelModule.mod.o
LD [M]
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./HelloKernelModule.ko
make[1] : on quitte le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
>>> kernel_module_test 1.0 Installing to target
>>> kernel_module_test 1.0 Installing kernel module(s)
PATH="/home/ledoux/Documents/buildroot/output/host/bin:/home/ledoux/Documents/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
PKG_CONFIG="/home/ledoux/Documents/buildroot/output/host/bin/pkg-config"
PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
PKG_CONFIG_LIBDIR="/home/ledoux/Documents/buildroot/output/host/lib/pkgconfig:/home/ledoux/Documents/buildroot/output/host/share/pkgconfig"
BR_BINARIES_DIR=/home/ledoux/Documents/buildroot/output/images
KCFLAGS=-Wno-attribute-alias /usr/bin/make -j3 -C
/home/ledoux/Documents/buildroot/output/build/linux-5.10.73
HOSTCC="/usr/bin/gcc -O2
-I/home/ledoux/Documents/buildroot/output/host/include
-L/home/ledoux/Documents/buildroot/output/host/lib
-Wl,-rpath,/home/ledoux/Documents/buildroot/output/host/lib" ARCH=x86_64
INSTALL_MOD_PATH=/home/ledoux/Documents/buildroot/output/target
CROSS_COMPILE="/home/ledoux/Documents/buildroot/output/host/bin/x86_64-buildroot-linux-uclibc-"
DEPMOD=/home/ledoux/Documents/buildroot/output/host/sbin/depmod
INSTALL_MOD_STRIP=1
PWD=/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/.
M=/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/.
modules_install
make[1] : on entre dans le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
INSTALL
/home/ledoux/Documents/buildroot/output/build/kernel_module_test-1.0/./HelloKernelModule.ko
DEPMOD 5.10.73
make[1] : on quitte le répertoire
« /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
the module.dep file :
kernel/drivers/char/hw_random/rng-core.ko:
kernel/drivers/char/hw_random/intel-rng.ko:
kernel/drivers/char/hw_random/rng-core.ko
kernel/drivers/char/hw_random/amd-rng.ko:
kernel/drivers/char/hw_random/rng-core.ko
kernel/drivers/char/hw_random/via-rng.ko:
kernel/drivers/char/hw_random/rng-core.ko
kernel/drivers/char/hw_random/virtio-rng.ko:
kernel/drivers/char/hw_random/rng-core.ko
kernel/drivers/thermal/intel/x86_pkg_temp_thermal.ko:
extra/HelloKernelModule.ko:
And there output/build/kernel_module_test-1.0 :
buildroot/output/build/kernel_module_test-1.0# ls -la
total 148
drwxr-xr-x 2 root root 4096 21 oct. 12:38 .
drwxr-xr-x 57 root root 4096 21 oct. 12:38 ..
-rwxr-xr-x 1 root root 164 21 oct. 12:19 Config.in
-rwxr-xr-x 1 root root 25 21 oct. 08:03 external.desc
-rwxr-xr-x 1 root root 49 19 oct. 20:58 external.mk
-rw-r--r-- 1 root root 0 21 oct. 12:38 .files-list-host.txt
-rw-r--r-- 1 root root 0 21 oct. 12:38 .files-list-staging.txt
-rw-r--r-- 1 root root 652 21 oct. 12:38 .files-list.txt
-rwxr-xr-x 1 root root 266 16 oct. 13:19 hello.c
-rw-r--r-- 1 root root 3696 21 oct. 12:38 HelloKernelModule.ko
-rw-r--r-- 1 root root 525 21 oct. 12:38 .HelloKernelModule.ko.cmd
-rw-r--r-- 1 root root 80 21 oct. 12:38 HelloKernelModule.mod
-rw-r--r-- 1 root root 534 21 oct. 12:38 HelloKernelModule.mod.c
-rw-r--r-- 1 root root 292 21 oct. 12:38 .HelloKernelModule.mod.cmd
-rw-r--r-- 1 root root 2648 21 oct. 12:38 HelloKernelModule.mod.o
-rw-r--r-- 1 root root 30656 21 oct. 12:38 .HelloKernelModule.mod.o.cmd
-rw-r--r-- 1 root root 1864 21 oct. 12:38 HelloKernelModule.o
-rw-r--r-- 1 root root 372 21 oct. 12:38 .HelloKernelModule.o.cmd
-rw-r--r-- 1 root root 1672 21 oct. 12:38 hello.o
-rw-r--r-- 1 root root 29282 21 oct. 12:38 .hello.o.cmd
-rwxr-xr-x 1 root root 169 21 oct. 12:21 kernel_module_test.mk
-rwxr-xr-x 1 root root 296 21 oct. 12:28 Makefile
-rw-r--r-- 1 root root 92 21 oct. 12:38 modules.order
-rw-r--r-- 1 root root 306 21 oct. 12:38 .modules.order.cmd
-rw-r--r-- 1 root root 0 21 oct. 12:38 Module.symvers
-rw-r--r-- 1 root root 337 21 oct. 12:38 .Module.symvers.cmd
-rw-r--r-- 1 root root 0 21 oct. 12:38 .stamp_built
-rw-r--r-- 1 root root 0 21 oct. 12:38 .stamp_configured
-rw-r--r-- 1 root root 0 21 oct. 12:38 .stamp_installed
-rw-r--r-- 1 root root 0 21 oct. 12:38 .stamp_rsynced
-rw-r--r-- 1 root root 0 21 oct. 12:38 .stamp_target_installed
I' so happy.
thank you for all again , ...
Le jeu. 21 oct. 2021 à 08:41, Andreas Ziegler <br015@umbiko.net> a écrit :
> Hi Esaïe,
>
> check the variables in kernel_module_test.mk. They need to be prefixed
> with KERNEL_MODULE_TEST.
>
> On 2021-10-21 07:58, Esaïe Ledoux NJONGSSI KOUAM wrote:
> > Okay ...
> > I think I have a new form of error, I think it is while compiling.
> >
> > buildroot# make kernel_module_test-dirclean
> > rm -Rf
> > /home/ledoux/Documents/buildroot/output/build/kernel_module_test
> >
> > /buildroot# make
> >>>> kernel_module_test Extracting
> >>>> kernel_module_test Patching
> >>>> kernel_module_test Configuring
> >>>> kernel_module_test Building
> >>>> kernel_module_test Building kernel module(s)
> >
> PATH="/home/ledoux/Documents/buildroot/output/host/bin:/home/ledoux/Documents/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
> > PKG_CONFIG="/home/ledoux/Documents/buildroot/output/host/bin/pkg-config"
> > PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
> > PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
> >
> PKG_CONFIG_LIBDIR="/home/ledoux/Documents/buildroot/output/host/lib/pkgconfig:/home/ledoux/Documents/buildroot/output/host/share/pkgconfig"
> > BR_BINARIES_DIR=/home/ledoux/Documents/buildroot/output/images
> > KCFLAGS=-Wno-attribute-alias /usr/bin/make -j3 -C
> > /home/ledoux/Documents/buildroot/output/build/linux-5.10.73
> > HOSTCC="/usr/bin/gcc -O2
> > -I/home/ledoux/Documents/buildroot/output/host/include
> > -L/home/ledoux/Documents/buildroot/output/host/lib
> > -Wl,-rpath,/home/ledoux/Documents/buildroot/output/host/lib"
> > ARCH=x86_64
> > INSTALL_MOD_PATH=/home/ledoux/Documents/buildroot/output/target
> >
> CROSS_COMPILE="/home/ledoux/Documents/buildroot/output/host/bin/x86_64-buildroot-linux-uclibc-"
> > DEPMOD=/home/ledoux/Documents/buildroot/output/host/sbin/depmod
> > INSTALL_MOD_STRIP=1
> > PWD=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.
> > M=/home/ledoux/Documents/buildroot/output/build/kernel_module_test/.
> > modules
> > make[1] : on entre dans le répertoire «
> > /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
> > scripts/Makefile.build:44:
> >
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile:
> > Aucun fichier ou dossier de ce type
> > make[2]: *** Aucune règle pour fabriquer la cible «
> >
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/./Makefile
> > ». Arrêt.
> > make[1]: *** [Makefile:1822 :
> > /home/ledoux/Documents/buildroot/output/build/kernel_module_test/.]
> > Erreur 2
> > make[1] : on quitte le répertoire «
> > /home/ledoux/Documents/buildroot/output/build/linux-5.10.73 »
> > make: *** [package/pkg-generic.mk:295 [4] :
> >
> /home/ledoux/Documents/buildroot/output/build/kernel_module_test/.stamp_built]
> > Erreur 2
>
> <cut>
>
> Kind regards,
> Andreas
>
[-- Attachment #1.2: Type: text/html, Size: 11891 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-16 16:57 Esaïe Ledoux NJONGSSI KOUAM
2021-10-16 17:21 ` Esaïe Ledoux NJONGSSI KOUAM
@ 2021-10-17 15:45 ` Arnout Vandecappelle
1 sibling, 0 replies; 11+ messages in thread
From: Arnout Vandecappelle @ 2021-10-17 15:45 UTC (permalink / raw)
To: Esaïe Ledoux NJONGSSI KOUAM, buildroot
On 16/10/2021 18:57, Esaïe Ledoux NJONGSSI KOUAM wrote:
> Hi everyone .
> Sorry for the inconvenience , ...
>
> I want to know how to load my kernel module, run it see these traces using dmesg
> and debug it.
>
> So , i have read this part of the (manual
> <https://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_building_kernel_modules>)
> , but i don't know how to use it :
>
> | What you may have noticed is that, unlike other package infrastructures, we |
> explicitly invoke a second infrastructure. This allows a package to build a
> kernel | module, but also, if needed, use any one of other package
> infrastructures to | build normal userland components (libraries, executables…).
> Using the |kernel-module| infrastructure on its own is not sufficient; another
> package infrastructure *must* be used.
>
> but in my way , i have try something :
>
> - Config.in
>
> |config BR2_PACKAGE_KERNEL_MODULE bool "kernel_module" depends on
> BR2_LINUX_KERNEL help Linux Kernel Module Cheat.|
>
> - external.mk <http://external.mk>
>
> |KERNEL_MODULE_VERSION = 1.0 KERNEL_MODULE_SITE =
> $(BR2_EXTERNAL_KERNEL_MODULE_PATH) KERNEL_MODULE_SITE_METHOD = local $(eval
> $(kernel-module)) $(eval $(generic-package))
You can't put the package .mk file directly in external.mk, because Buildroot
uses the directory name to derive the package name. So you need:
external.mk:
include kernel-module/kernel-module.mk
kernel-module/kernel-module.mk:
KERNEL_MODULE_VERSION = 1.0
KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/kernel-module
KERNEL_MODULE_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))
You should probably also choose a different name than kernel-module, there's a
risk that there is some symbol conflict somewhere. kernel-module-test or
something would do.
> - Makefile
>
> |obj-m += $(addsuffix .o, $(notdir $(basename $(wildcard
> $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/*.c)))) ccflags-y := -DDEBUG -g -std=gnu99
> -Wno-declaration-after-statement .PHONY: all clean all: $(MAKE) -C
> '$(LINUX_DIR)' M='$(PWD)' modules clean: $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
>
> - hello.c
>
> |#include <linux/module.h> #include <linux/kernel.h> MODULE_LICENSE("GPL");
> static int myinit(void) { printk(KERN_INFO "hello init\n"); return 0; } static
> void myexit(void) { printk(KERN_INFO "hello exit\n"); } module_init(myinit)
> module_exit(myexit)
>
> |And in the terminal : ||||
>
> |make BR2_EXTERNAL="$(pwd)/../kernel_module" qemu_x86_64_defconfig
> echo 'BR2_PACKAGE_KERNEL_MODULE=y' >> .config
> make BR2_JLEVEL="$(($(nproc) - 2))" all
Did you see any output about the kernel module being built? I expect not...
Before continuing with qemu, check that the kernel module has indeed been
built, and check in output/target/lib/modules if it's there.
Regards,
Arnout
> qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive
> file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net
> nic,model=virtio -net user
>
>
> |
>
> |On qemu :
> |
>
> |modprobe hello
> modprobe: module hello not found in modules.dep
>
> |
>
> |how can i solve it ??
> |
>
> |please i need your help
> |
>
> |
> |
>
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Buildroot] how can i implement my kernel module and debug it
2021-10-16 16:57 Esaïe Ledoux NJONGSSI KOUAM
@ 2021-10-16 17:21 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-17 15:45 ` Arnout Vandecappelle
1 sibling, 0 replies; 11+ messages in thread
From: Esaïe Ledoux NJONGSSI KOUAM @ 2021-10-16 17:21 UTC (permalink / raw)
To: buildroot
[-- Attachment #1.1: Type: text/plain, Size: 2747 bytes --]
In another way , i have seen some kernel modules infrastructure with
git grep "(kernel-module)" -- package/
, but i don't know how to load each kernel module and trace it or debug it .
How it is possible ??
Le sam. 16 oct. 2021 à 18:57, Esaïe Ledoux NJONGSSI KOUAM <
kouamdoux@gmail.com> a écrit :
> Hi everyone .
> Sorry for the inconvenience , ...
>
> I want to know how to load my kernel module, run it see these traces using
> dmesg and debug it.
>
> So , i have read this part of the (manual
> <https://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_building_kernel_modules>)
> , but i don't know how to use it :
>
> | What you may have noticed is that, unlike other package infrastructures,
> we | explicitly invoke a second infrastructure. This allows a package to
> build a kernel | module, but also, if needed, use any one of other package
> infrastructures to | build normal userland components (libraries,
> executables…). Using the kernel-module infrastructure on its own is not
> sufficient; another package infrastructure *must* be used.
>
> but in my way , i have try something :
>
> - Config.in
>
> config BR2_PACKAGE_KERNEL_MODULE
> bool "kernel_module"
> depends on BR2_LINUX_KERNEL
> help
> Linux Kernel Module Cheat.
>
> - external.mk
>
> KERNEL_MODULE_VERSION = 1.0
> KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)
> KERNEL_MODULE_SITE_METHOD = local
> $(eval $(kernel-module))
> $(eval $(generic-package))
>
> - Makefile
>
> obj-m += $(addsuffix .o, $(notdir $(basename $(wildcard $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/*.c))))
> ccflags-y := -DDEBUG -g -std=gnu99 -Wno-declaration-after-statement
>
> .PHONY: all clean
>
> all:
> $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' modules
>
> clean:
> $(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
>
> - hello.c
>
> #include <linux/module.h>#include <linux/kernel.h>
>
> MODULE_LICENSE("GPL");
> static int myinit(void)
> {
> printk(KERN_INFO "hello init\n");
> return 0;
> }
> static void myexit(void)
> {
> printk(KERN_INFO "hello exit\n");
> }
>
> module_init(myinit)
> module_exit(myexit)
>
> And in the terminal :
>
> make BR2_EXTERNAL="$(pwd)/../kernel_module" qemu_x86_64_defconfig
> echo 'BR2_PACKAGE_KERNEL_MODULE=y' >> .config
> make BR2_JLEVEL="$(($(nproc) - 2))" all
> qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user
>
>
> On qemu :
>
> modprobe hello
> modprobe: module hello not found in modules.dep
>
> how can i solve it ??
>
> please i need your help
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 4129 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Buildroot] how can i implement my kernel module and debug it
@ 2021-10-16 16:57 Esaïe Ledoux NJONGSSI KOUAM
2021-10-16 17:21 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-17 15:45 ` Arnout Vandecappelle
0 siblings, 2 replies; 11+ messages in thread
From: Esaïe Ledoux NJONGSSI KOUAM @ 2021-10-16 16:57 UTC (permalink / raw)
To: buildroot
[-- Attachment #1.1: Type: text/plain, Size: 2284 bytes --]
Hi everyone .
Sorry for the inconvenience , ...
I want to know how to load my kernel module, run it see these traces using
dmesg and debug it.
So , i have read this part of the (manual
<https://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_building_kernel_modules>)
, but i don't know how to use it :
| What you may have noticed is that, unlike other package infrastructures,
we | explicitly invoke a second infrastructure. This allows a package to
build a kernel | module, but also, if needed, use any one of other package
infrastructures to | build normal userland components (libraries,
executables…). Using the kernel-module infrastructure on its own is not
sufficient; another package infrastructure *must* be used.
but in my way , i have try something :
- Config.in
config BR2_PACKAGE_KERNEL_MODULE
bool "kernel_module"
depends on BR2_LINUX_KERNEL
help
Linux Kernel Module Cheat.
- external.mk
KERNEL_MODULE_VERSION = 1.0
KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)
KERNEL_MODULE_SITE_METHOD = local
$(eval $(kernel-module))
$(eval $(generic-package))
- Makefile
obj-m += $(addsuffix .o, $(notdir $(basename $(wildcard
$(BR2_EXTERNAL_KERNEL_MODULE_PATH)/*.c))))
ccflags-y := -DDEBUG -g -std=gnu99 -Wno-declaration-after-statement
.PHONY: all clean
all:
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' modules
clean:
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
- hello.c
#include <linux/module.h>#include <linux/kernel.h>
MODULE_LICENSE("GPL");
static int myinit(void)
{
printk(KERN_INFO "hello init\n");
return 0;
}
static void myexit(void)
{
printk(KERN_INFO "hello exit\n");
}
module_init(myinit)
module_exit(myexit)
And in the terminal :
make BR2_EXTERNAL="$(pwd)/../kernel_module" qemu_x86_64_defconfig
echo 'BR2_PACKAGE_KERNEL_MODULE=y' >> .config
make BR2_JLEVEL="$(($(nproc) - 2))" all
qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive
file=output/images/rootfs.ext2,if=virtio,format=raw -append
root=/dev/vda -net nic,model=virtio -net user
On qemu :
modprobe hello
modprobe: module hello not found in modules.dep
how can i solve it ??
please i need your help
[-- Attachment #1.2: Type: text/html, Size: 4852 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-10-21 8:52 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <mailman.16364.1634462006.241441.buildroot@buildroot.org>
2021-10-17 9:45 ` [Buildroot] how can i implement my kernel module and debug it Andreas Ziegler
[not found] ` <CA+eej5PtS6iCJ+W1b6W0mZXk-fQJcB1hhr20_D7cE=fja8NzTw@mail.gmail.com>
2021-10-19 5:47 ` Andreas Ziegler
2021-10-19 14:34 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-19 12:45 ` Arnout Vandecappelle
2021-10-20 7:17 ` Andreas Ziegler
2021-10-21 7:58 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-21 6:41 ` Andreas Ziegler
2021-10-21 10:51 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-16 16:57 Esaïe Ledoux NJONGSSI KOUAM
2021-10-16 17:21 ` Esaïe Ledoux NJONGSSI KOUAM
2021-10-17 15:45 ` Arnout Vandecappelle
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.