From 07a000cae742a82a1af22081ef85f91bae3d1895 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: Fri, 2 Nov 2018 22:00:08 +0000 Subject: [PATCH] rename packages to buildroot_packages fix BR2_SAMPLE_PACKAGE to PACKAGE_SAMPLE_PACKAGE on README Add some more README.adoc to subdirs. --- README.adoc | 75 ++++++++----------- build-buildroot | 5 +- buildroot_packages/README.adoc | 1 + .../lkmc_many_files/Config.in | 0 .../lkmc_many_files/Makefile | 0 .../lkmc_many_files/external.desc | 0 .../lkmc_many_files/external.mk | 0 .../lkmc_many_files/lkmc_many_files.c | 0 .../parsec_benchmark/Config.in | 0 .../parsec_benchmark/external.desc | 0 .../parsec_benchmark/external.mk | 0 .../sample_package/Config.in | 0 .../sample_package/Makefile | 0 .../sample_package/external.desc | 0 .../sample_package/external.mk | 0 .../sample_package/sample_package.c | 0 common.py | 3 +- linux_config/README.adoc | 1 + packages/README.adoc | 1 - patches/README.adoc | 1 + 20 files changed, 36 insertions(+), 51 deletions(-) create mode 100644 buildroot_packages/README.adoc rename {packages => buildroot_packages}/lkmc_many_files/Config.in (100%) rename {packages => buildroot_packages}/lkmc_many_files/Makefile (100%) rename {packages => buildroot_packages}/lkmc_many_files/external.desc (100%) rename {packages => buildroot_packages}/lkmc_many_files/external.mk (100%) rename {packages => buildroot_packages}/lkmc_many_files/lkmc_many_files.c (100%) rename {packages => buildroot_packages}/parsec_benchmark/Config.in (100%) rename {packages => buildroot_packages}/parsec_benchmark/external.desc (100%) rename {packages => buildroot_packages}/parsec_benchmark/external.mk (100%) rename {packages => buildroot_packages}/sample_package/Config.in (100%) rename {packages => buildroot_packages}/sample_package/Makefile (100%) rename {packages => buildroot_packages}/sample_package/external.desc (100%) rename {packages => buildroot_packages}/sample_package/external.mk (100%) rename {packages => buildroot_packages}/sample_package/sample_package.c (100%) create mode 100644 linux_config/README.adoc delete mode 100644 packages/README.adoc create mode 100644 patches/README.adoc diff --git a/README.adoc b/README.adoc index a9ea095..032a833 100644 --- a/README.adoc +++ b/README.adoc @@ -175,11 +175,15 @@ Then rebuild the Linux kernel, quit QEMU and reboot the modified kernel: ./run .... -and, surely enough, your message has appeared at the beginning of the boot. +and, surely enough, your message has appeared at the beginning of the boot: + +.... +<6>[ 0.000000] I'VE HACKED THE LINUX KERNEL!!! +.... So you are now officially a Linux kernel hacker, way to go! -We could have used just link:build[] as in the <> instead of link:build-linux[], but building just the required individual components is preferred during development: +We could have used just link:build[] to rebuild the kernel as in the <> instead of link:build-linux[], but building just the required individual components is preferred during development: * saves a few seconds from parsing Make scripts and reading timestamps * makes it easier to understand what is being done in more detail @@ -9850,7 +9854,7 @@ For example, if you decide to <> after .... ./build-buildroot \ --config 'BR2_OPTIMIZE_3=y' \ - --config 'BR2_SAMPLE_PACKAGE=y' \ + --config 'BR2_PACKAGE_SAMPLE_PACKAGE=y' \ -- sample_package-dirclean \ sample_package-reconfigure \ @@ -9890,7 +9894,7 @@ Then, you have two choices: .... ./build-buildroot \ --config 'BR2_OPTIMIZE_3=y' \ - --config 'BR2_SAMPLE_PACKAGE=y' \ + --config 'BR2_PACKAGE_SAMPLE_PACKAGE=y' \ -- \ sample_package-dirclean \ sample_package-reconfigure \ @@ -9979,9 +9983,9 @@ First, see if you can't get away without actually adding a new package, for exam * if you have a standalone C file with no dependencies besides the C standard library to be compiled with GCC, just add a new file under link:kernel_modules/user[] and you are done * if you have a dependency on a library, first check if Buildroot doesn't have a package for it already with `ls buildroot/package`. If yes, just enable that package as explained at: <> -If none of those methods are flexible enough for you, you can just fork or hack up link:packages/sample_package[] the sample package to do what you want. +If none of those methods are flexible enough for you, you can just fork or hack up link:buildroot_packages/sample_package[] the sample package to do what you want. -For how to use that package, see: <>. +For how to use that package, see: <>. Then iterate trying to do what you want and reading the manual until it works: https://buildroot.org/downloads/manual/manual.html @@ -11148,35 +11152,6 @@ git -C "$(./getvar buildroot_src_dir)" checkout - === Directory structure -* `data`: gitignored user created data. Deleting this might lead to loss of data. Of course, if something there becomes is important enough to you, git track it. -** `data/9p`: see <<9p>> -** `data/gem5/`: see: <> -* link:packages/lkmc[]: Buildroot package that contains our kernel modules and userland C tests -* `out`: gitignored Build outputs. You won't lose data by deleting this folder since everything there can be re-generated, only time. -** `out/`: arch specific outputs -*** `out//buildroot`: standard Buildroot output -**** `out//buildroot/build/linux-custom`: symlink to a variant, custom madness that we do on top of Buildroot: <> -**** `out//buildroot/build/linux-custom.`: what `linux-custom` points to -*** `out//qemu`: QEMU runtime outputs -*** `out//qemu//run.sh`: full CLI used to run QEMU. See: <> -*** `out//gem5//`: gem5 runtime outputs -**** `out//gem5//m5out` -**** `out//gem5//run.sh`: full CLI used to run gem5. See: <> -** `out/common`: cross arch outputs, for when we can gain a lot of time and space by sharing things that are common across different archs. -*** `out/common/dl/`: Buildroot caches downloaded source there due to `BR2_DL_DIR` -*** `out/common/gem5/`: `arm` and `aarch64` have the same build. -**** `out/common/gem5//`: gem5 build output. In common to share the ARM and aarch64 builds. -***** `out/common/gem5//build/`: main build outputs, including the `gem5.opt` executable and object files -***** `out/common/gem5//system/`: `M5_PATH` directory, with DTBs and bootloaders - -==== gem5 directory - -We Build the gem5 emulator through Buildroot basically just to reuse its timestamping system to avoid rebuilds. - -There is also the `m5` tool that we must build through Buildroot ans install on the root filesystem, but we could just make two separate builds. - -This directory has the following structure: - ==== include directory link:include/[] contains headers that are shared across both kernel modules and userland structures. @@ -11245,20 +11220,14 @@ It is also possible to build other architectures with the host toolchain for oth You won't be able to run those executables directly, but this is interesting if you are playing around with <>. -==== packages directory +==== buildroot_packages directory Every directory inside it is a Buildroot package. Those packages get automatically added to Buildroot's `BR2_EXTERNAL`, so all you need to do is to turn them on during build, e.g.: .... -./build-buildroot --config 'BR2_SAMPLE_PACKAGE=y' -.... - -or force a rebuild after the first one with: - -.... -./build-buildroot --config 'BR2_SAMPLE_PACKAGE=y' -- sample_package-reconfigure +./build-buildroot --config 'BR2_PACKAGE_SAMPLE_PACKAGE=y' .... then test it out with: @@ -11267,9 +11236,25 @@ then test it out with: ./run --eval-busybox '/sample_package.out' .... -In particular, our kernel modules are stored inside a Buildroot package: link:packages/lkmc[]. +and you should see: -==== patches +.... +hello sample_package +.... + +Source: link:buildroot_packages/sample_package/sample_package.c[] + +You can force a rebuild with: + +.... +./build-buildroot --config 'BR2_PACKAGE_SAMPLE_PACKAGE=y' -- sample_package-reconfigure +.... + +Buildroot packages are convenient, but in general, if a package if very important to you, but not really mergeable back to Buildroot, you might want to just use a custom build script for it, and point it to the Buildroot toolchain, and then use `BR2_ROOTFS_OVERLAY`, much like we do for <>. + +A custom build script can give you more flexibility: e.g. the package can be made work with other root filesystems more easily, have better <<9p>> support, and rebuild faster as it evades some Buildroot boilerplate. + +==== patches directory ===== patches/global diff --git a/build-buildroot b/build-buildroot index c24db99..e49f211 100755 --- a/build-buildroot +++ b/build-buildroot @@ -71,9 +71,8 @@ usually extra Buildroot targets. elif args.arch == 'aarch64': defconfig = 'qemu_aarch64_virt_defconfig' br2_external_dirs = [] - packages_dir = os.path.join(common.root_dir, 'packages') - for package_dir in os.listdir(packages_dir): - package_dir_abs = os.path.join(packages_dir, package_dir) + for package_dir in os.listdir(common.packages_dir): + package_dir_abs = os.path.join(common.packages_dir, package_dir) if os.path.isdir(package_dir_abs): br2_external_dirs.append(self._path_relative_to_buildroot(package_dir_abs)) br2_external_str = ':'.join(br2_external_dirs) diff --git a/buildroot_packages/README.adoc b/buildroot_packages/README.adoc new file mode 100644 index 0000000..319a2c6 --- /dev/null +++ b/buildroot_packages/README.adoc @@ -0,0 +1 @@ +https://github.com/cirosantilli/linux-kernel-module-cheat#buildroot_packages-directory diff --git a/packages/lkmc_many_files/Config.in b/buildroot_packages/lkmc_many_files/Config.in similarity index 100% rename from packages/lkmc_many_files/Config.in rename to buildroot_packages/lkmc_many_files/Config.in diff --git a/packages/lkmc_many_files/Makefile b/buildroot_packages/lkmc_many_files/Makefile similarity index 100% rename from packages/lkmc_many_files/Makefile rename to buildroot_packages/lkmc_many_files/Makefile diff --git a/packages/lkmc_many_files/external.desc b/buildroot_packages/lkmc_many_files/external.desc similarity index 100% rename from packages/lkmc_many_files/external.desc rename to buildroot_packages/lkmc_many_files/external.desc diff --git a/packages/lkmc_many_files/external.mk b/buildroot_packages/lkmc_many_files/external.mk similarity index 100% rename from packages/lkmc_many_files/external.mk rename to buildroot_packages/lkmc_many_files/external.mk diff --git a/packages/lkmc_many_files/lkmc_many_files.c b/buildroot_packages/lkmc_many_files/lkmc_many_files.c similarity index 100% rename from packages/lkmc_many_files/lkmc_many_files.c rename to buildroot_packages/lkmc_many_files/lkmc_many_files.c diff --git a/packages/parsec_benchmark/Config.in b/buildroot_packages/parsec_benchmark/Config.in similarity index 100% rename from packages/parsec_benchmark/Config.in rename to buildroot_packages/parsec_benchmark/Config.in diff --git a/packages/parsec_benchmark/external.desc b/buildroot_packages/parsec_benchmark/external.desc similarity index 100% rename from packages/parsec_benchmark/external.desc rename to buildroot_packages/parsec_benchmark/external.desc diff --git a/packages/parsec_benchmark/external.mk b/buildroot_packages/parsec_benchmark/external.mk similarity index 100% rename from packages/parsec_benchmark/external.mk rename to buildroot_packages/parsec_benchmark/external.mk diff --git a/packages/sample_package/Config.in b/buildroot_packages/sample_package/Config.in similarity index 100% rename from packages/sample_package/Config.in rename to buildroot_packages/sample_package/Config.in diff --git a/packages/sample_package/Makefile b/buildroot_packages/sample_package/Makefile similarity index 100% rename from packages/sample_package/Makefile rename to buildroot_packages/sample_package/Makefile diff --git a/packages/sample_package/external.desc b/buildroot_packages/sample_package/external.desc similarity index 100% rename from packages/sample_package/external.desc rename to buildroot_packages/sample_package/external.desc diff --git a/packages/sample_package/external.mk b/buildroot_packages/sample_package/external.mk similarity index 100% rename from packages/sample_package/external.mk rename to buildroot_packages/sample_package/external.mk diff --git a/packages/sample_package/sample_package.c b/buildroot_packages/sample_package/sample_package.c similarity index 100% rename from packages/sample_package/sample_package.c rename to buildroot_packages/sample_package/sample_package.c diff --git a/common.py b/common.py index 7347800..c17036d 100644 --- a/common.py +++ b/common.py @@ -29,8 +29,7 @@ p9_dir = os.path.join(data_dir, '9p') gem5_non_default_src_root_dir = os.path.join(data_dir, 'gem5') out_dir = os.path.join(root_dir, 'out') bench_boot = os.path.join(out_dir, 'bench-boot.txt') -packages_dir = os.path.join(root_dir, 'packages') -lkmc_package_src_dir = os.path.join(this_module.packages_dir, 'lkmc') +packages_dir = os.path.join(root_dir, 'buildroot_packages') kernel_modules_subdir = 'kernel_modules' kernel_modules_src_dir = os.path.join(this_module.root_dir, this_module.kernel_modules_subdir) userland_subdir = 'userland' diff --git a/linux_config/README.adoc b/linux_config/README.adoc new file mode 100644 index 0000000..db9ccc4 --- /dev/null +++ b/linux_config/README.adoc @@ -0,0 +1 @@ +https://github.com/cirosantilli/linux-kernel-module-cheat#about-our-linux-kernel-configs diff --git a/packages/README.adoc b/packages/README.adoc deleted file mode 100644 index f64a50e..0000000 --- a/packages/README.adoc +++ /dev/null @@ -1 +0,0 @@ -https://github.com/cirosantilli/linux-kernel-module-cheat#packages_directory diff --git a/patches/README.adoc b/patches/README.adoc new file mode 100644 index 0000000..c3c3830 --- /dev/null +++ b/patches/README.adoc @@ -0,0 +1 @@ +https://github.com/cirosantilli/linux-kernel-module-cheat#patches-directory