From 753cbe68ff50bea0982e1791c8a2178a999d8377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 6 Nov 2018 00:00:00 +0000 Subject: [PATCH] build-buildroot: add the --no-overlay option Initial motivation: modprobe. More to come most likely. --- README.adoc | 16 ++++++++-------- build-buildroot | 16 +++++++++++++--- buildroot_packages/kernel_modules/Config.in | 2 +- buildroot_packages/kernel_modules/README.adoc | 1 + 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 buildroot_packages/kernel_modules/README.adoc diff --git a/README.adoc b/README.adoc index 65663e3..dff6c77 100644 --- a/README.adoc +++ b/README.adoc @@ -3172,9 +3172,7 @@ We are not installing out custom `./build-modules` modules there, because: * we don't know the right way. Why is there no `install` or `install_modules` target for kernel modules? + -This can of course be solved by running Buildroot in verbose mode, and copying whatever it is doing. -+ -See also: https://askubuntu.com/questions/299676/how-to-install-3rd-party-module-so-that-it-is-loaded-on-boot +This can of course be solved by running Buildroot in verbose mode, and copying whatever it is doing, initial exploration at: https://stackoverflow.com/questions/22783793/how-to-install-kernel-modules-from-source-code-error-while-make-process/53169078#53169078 * we would have to think how to not have to include the kernel modules twice in the root filesystem, but still have <<9p>> working for fast development as described at: <> === kmod @@ -11322,17 +11320,15 @@ A custom build script can give you more flexibility: e.g. the package can be mad Source: link:buildroot_packages/kernel_modules/[] -An example of how to kernel modules in Buildroot. - -Procedure described in detail at: https://stackoverflow.com/questions/40307328/how-to-add-a-linux-kernel-driver-module-as-a-buildroot-package/43874273#43874273 +An example of how to use kernel modules in Buildroot. Usage: .... -rm -rf "$(./getvar out_rootfs_overlay_dir)/lib/modules" ./build-buildroot \ --build-linux \ --config 'BR2_PACKAGE_KERNEL_MODULES=y' \ + --no-overlay \ -- \ kernel_modules-reconfigure \ ; @@ -11346,10 +11342,14 @@ Then test one of the modules with: Source: link:buildroot_packages/kernel_modules/buildroot_hello.c[] -The `rm -rf` is required otherwise our `modules.order` generated by `./build-linux` and installed with `BR2_ROOTFS_OVERLAY` overwrites the Buildroot generated one. +As you have just seen, this sets up everything so that <> can conrrectly find the module. `./build-buildroot --build-linux` and `./run --buildroot-linux` are needed because the Buildroot kernel modules must use the Buildroot Linux kernel at build and run time. +The `--no-overlay` is required otherwise our `modules.order` generated by `./build-linux` and installed with `BR2_ROOTFS_OVERLAY` overwrites the Buildroot generated one. + +Implementattion described at: https://stackoverflow.com/questions/40307328/how-to-add-a-linux-kernel-driver-module-as-a-buildroot-package/43874273#43874273 + ==== patches directory ===== patches/global diff --git a/build-buildroot b/build-buildroot index a21645e..36a4dd6 100755 --- a/build-buildroot +++ b/build-buildroot @@ -46,6 +46,15 @@ Pass multiple times to use multiple fragment files. help='''\ Don't build the all target which normally gets build by default. That target builds the root filesystem and all its dependencies. +''' + ) + parser.add_argument( + '--no-overlay', default=self._defaults['no_all'], action='store_true', + help='''\ +Don't add our overlay which contains all files we build without going through Buildroot. +This prevents us from overwriting certain Buildroot files. Remember however that you must +still rebuild the Buildroot package that provides those files to actually put the Buildroot +files on the root filesystem. ''' ) parser.add_argument( @@ -106,9 +115,6 @@ usually extra Buildroot targets. 'BR2_PACKAGE_OVERRIDE_FILE="{}"'.format( self._path_relative_to_buildroot(os.path.join(common.root_dir, 'buildroot_override')) ), - 'BR2_ROOTFS_OVERLAY="{}"'.format( - self._path_relative_to_buildroot(common.out_rootfs_overlay_dir), - ), 'BR2_ROOTFS_POST_BUILD_SCRIPT="{}"'.format( self._path_relative_to_buildroot(os.path.join(common.root_dir, 'rootfs-post-build-script')) ), @@ -116,6 +122,10 @@ usually extra Buildroot targets. self._path_relative_to_buildroot(os.path.join(common.root_dir, 'user_table')) ), ]) + if not args.no_overlay: + configs.append('BR2_ROOTFS_OVERLAY="{}"'.format( + self._path_relative_to_buildroot(common.out_rootfs_overlay_dir) + )) config_fragments = [ os.path.join(common.root_dir, 'buildroot_config', 'default') ] + args.config_fragment diff --git a/buildroot_packages/kernel_modules/Config.in b/buildroot_packages/kernel_modules/Config.in index f897377..cb71e7e 100644 --- a/buildroot_packages/kernel_modules/Config.in +++ b/buildroot_packages/kernel_modules/Config.in @@ -2,4 +2,4 @@ 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 + See README.adoc diff --git a/buildroot_packages/kernel_modules/README.adoc b/buildroot_packages/kernel_modules/README.adoc new file mode 100644 index 0000000..b54c484 --- /dev/null +++ b/buildroot_packages/kernel_modules/README.adoc @@ -0,0 +1 @@ +https://github.com/cirosantilli/linux-kernel-module-cheat#kernel_modules-package