mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
bring a minimal buildroot kernel modules example to life
More importantly, to make modules_install on the Linux kernel build.
This commit is contained in:
5
buildroot_packages/kernel_modules/Config.in
Normal file
5
buildroot_packages/kernel_modules/Config.in
Normal file
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_KERNEL_MODULES
|
||||
bool "kernel_modules"
|
||||
depends on BR2_LINUX_KERNEL
|
||||
help
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#kernel_modules-package
|
||||
10
buildroot_packages/kernel_modules/Makefile
Normal file
10
buildroot_packages/kernel_modules/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
obj-m += $(addsuffix .o, $(notdir $(basename $(filter-out %.mod.c, $(wildcard $(BR2_EXTERNAL_KERNEL_MODULES_PATH)/*.c)))))
|
||||
ccflags-y := -DDEBUG -g -std=gnu99 -Werror -Wno-declaration-after-statement -Wframe-larger-than=1000000000
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all:
|
||||
$(MAKE) -C '/lib/modules/$(shell uname -r)/build' M='$(PWD)' modules
|
||||
|
||||
clean:
|
||||
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
|
||||
18
buildroot_packages/kernel_modules/buildroot_dep.c
Normal file
18
buildroot_packages/kernel_modules/buildroot_dep.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#kernel-module-dependencies */
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
u32 lkmc_dep = 42;
|
||||
EXPORT_SYMBOL(lkmc_dep);
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void myexit(void) {}
|
||||
|
||||
module_init(myinit)
|
||||
module_exit(myexit)
|
||||
MODULE_LICENSE("GPL");
|
||||
18
buildroot_packages/kernel_modules/buildroot_dep2.c
Normal file
18
buildroot_packages/kernel_modules/buildroot_dep2.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#kernel-module-dependencies */
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
extern u32 lkmc_dep;
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
pr_info("%llu\n", (long long unsigned)lkmc_dep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void myexit(void) {}
|
||||
|
||||
module_init(myinit)
|
||||
module_exit(myexit)
|
||||
MODULE_LICENSE("GPL");
|
||||
19
buildroot_packages/kernel_modules/buildroot_hello.c
Normal file
19
buildroot_packages/kernel_modules/buildroot_hello.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#getting-started-natively */
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
pr_info("init buildroot\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void myexit(void)
|
||||
{
|
||||
pr_info("exit buildroot\n");
|
||||
}
|
||||
|
||||
module_init(myinit)
|
||||
module_exit(myexit)
|
||||
MODULE_LICENSE("GPL");
|
||||
1
buildroot_packages/kernel_modules/external.desc
Normal file
1
buildroot_packages/kernel_modules/external.desc
Normal file
@@ -0,0 +1 @@
|
||||
name: KERNEL_MODULES
|
||||
12
buildroot_packages/kernel_modules/external.mk
Normal file
12
buildroot_packages/kernel_modules/external.mk
Normal file
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
#
|
||||
# kernel_modules
|
||||
#
|
||||
################################################################################
|
||||
|
||||
KERNEL_MODULES_VERSION = 1.0
|
||||
KERNEL_MODULES_SITE = $(BR2_EXTERNAL_KERNEL_MODULES_PATH)
|
||||
KERNEL_MODULES_SITE_METHOD = local
|
||||
|
||||
$(eval $(kernel-module))
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user