mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
sample-package: create
This commit is contained in:
36
README.adoc
36
README.adoc
@@ -221,6 +221,7 @@ Not all packages have an alias, when they don't, just use the form:
|
|||||||
./build -- <pkg>-reconfigure
|
./build -- <pkg>-reconfigure
|
||||||
....
|
....
|
||||||
|
|
||||||
|
[[retype]]
|
||||||
=== Don't retype arguments all the time
|
=== Don't retype arguments all the time
|
||||||
|
|
||||||
It gets annoying to retype `-a aarch64` for every single command, or to remember `./build -B` setups.
|
It gets annoying to retype `-a aarch64` for every single command, or to remember `./build -B` setups.
|
||||||
@@ -2792,15 +2793,7 @@ Buildroot built-in libraries, mostly under Libraries > Other:
|
|||||||
* libtommath
|
* libtommath
|
||||||
* qhull
|
* qhull
|
||||||
|
|
||||||
There are not yet enabled, but it should be easy to so:
|
There are not yet enabled, but it should be easy to so, see: <<add-new-buildroot-packages>>
|
||||||
|
|
||||||
* enable them in link:br2[] and rebuild
|
|
||||||
* create a test program that uses each library under link:kernel_module/user[]
|
|
||||||
|
|
||||||
External open source benchmarks. We will try to create Buildroot packages for them, add them to this repo, and potentially upstream:
|
|
||||||
|
|
||||||
* http://parsec.cs.princeton.edu/ Mentioned on docs: http://gem5.org/PARSEC_benchmarks
|
|
||||||
* http://www.m5sim.org/Splash_benchmarks
|
|
||||||
|
|
||||||
===== BLAS
|
===== BLAS
|
||||||
|
|
||||||
@@ -3637,13 +3630,15 @@ dmesg
|
|||||||
|
|
||||||
== Buildroot
|
== Buildroot
|
||||||
|
|
||||||
=== Change Buildroot options
|
=== Custom Buildroot options
|
||||||
|
|
||||||
We provide the following mechanisms:
|
We provide the following mechanisms:
|
||||||
|
|
||||||
* `./build -b mybr2.gitignore`: append the file `mybr2.gitignore` to a single build. Must be passed every time you run `./build`. A good template is provided by:
|
* `./build -b mybr2.gitignore`: append the file `mybr2.gitignore` to a single build. Must be passed every time you run `./build`. A good template is provided by:
|
||||||
* `./build -B 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
* `./build -B 'BR2_SOM_OPTION="myval"'`: append a single option to a single build.
|
||||||
|
|
||||||
|
You will then likely want to make those more permanent with: <<retype>>
|
||||||
|
|
||||||
=== Find Buildroot options with make menuconfig
|
=== Find Buildroot options with make menuconfig
|
||||||
|
|
||||||
`make menuconfig` is a convenient way to find Buildroot configurations:
|
`make menuconfig` is a convenient way to find Buildroot configurations:
|
||||||
@@ -3733,6 +3728,27 @@ watch -n1 'ccache -s'
|
|||||||
|
|
||||||
while a build is going on in another terminal and my cooler is humming. Especially when the hit count goes up ;-) The joys of system programming.
|
while a build is going on in another terminal and my cooler is humming. Especially when the hit count goes up ;-) The joys of system programming.
|
||||||
|
|
||||||
|
=== Add new Buildroot packages
|
||||||
|
|
||||||
|
First, see if you can't get away without actually adding a new package, for example:
|
||||||
|
|
||||||
|
* 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_module/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: <<custom-buildroot-options>>
|
||||||
|
|
||||||
|
If none of those methods are flexible enough for you, create a new package as follows:
|
||||||
|
|
||||||
|
* use link:sample_package[] as a starting point
|
||||||
|
* fork this repository, and modify that package to do what you want
|
||||||
|
* read the comments on that package to get an idea of how to start
|
||||||
|
* check the main manual for more complicated things: https://buildroot.org/downloads/manual/manual.html
|
||||||
|
* don't forget to rebuild with:
|
||||||
|
+
|
||||||
|
....
|
||||||
|
./build -- sample_package-reconfigure
|
||||||
|
....
|
||||||
|
+
|
||||||
|
if you make any changes to that package after the initial build: <<rebuild>>
|
||||||
|
|
||||||
=== BR2_TARGET_ROOTFS_EXT2_SIZE
|
=== BR2_TARGET_ROOTFS_EXT2_SIZE
|
||||||
|
|
||||||
When adding new large package to the Buildroot root filesystem, it may fail with the message:
|
When adding new large package to the Buildroot root filesystem, it may fail with the message:
|
||||||
|
|||||||
1
br2
1
br2
@@ -1,5 +1,6 @@
|
|||||||
# Custom packages
|
# Custom packages
|
||||||
BR2_PACKAGE_KERNEL_MODULE=y
|
BR2_PACKAGE_KERNEL_MODULE=y
|
||||||
|
BR2_SAMPLE_PACKAGE=y
|
||||||
|
|
||||||
# Rootfs
|
# Rootfs
|
||||||
BR2_TARGET_ROOTFS_CPIO=n
|
BR2_TARGET_ROOTFS_CPIO=n
|
||||||
|
|||||||
2
build
2
build
@@ -112,7 +112,7 @@ if "$configure"; then
|
|||||||
for p in $(find "${root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
for p in $(find "${root_dir}/buildroot_patches/" -maxdepth 1 -name '*.patch' -print); do
|
||||||
patch -N -r - -p 1 <"$p" || :
|
patch -N -r - -p 1 <"$p" || :
|
||||||
done
|
done
|
||||||
make O="$buildroot_out_dir" BR2_EXTERNAL="../kernel_module:../gem5:../parsec-benchmark" "$defconfig"
|
make O="$buildroot_out_dir" BR2_EXTERNAL="../kernel_module:../gem5:../parsec-benchmark:../sample_package" "$defconfig"
|
||||||
# TODO Can't get rid of these for now.
|
# TODO Can't get rid of these for now.
|
||||||
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
|
||||||
for config_fragment in $config_fragments; do
|
for config_fragment in $config_fragments; do
|
||||||
|
|||||||
4
sample_package/Config.in
Normal file
4
sample_package/Config.in
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
config BR2_PACKAGE_SAMPLE_PACKAGE
|
||||||
|
bool "sample_package"
|
||||||
|
help
|
||||||
|
Sample Buildroot package.
|
||||||
16
sample_package/Makefile
Normal file
16
sample_package/Makefile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
CFLAGS_EXTRA ?= -ggdb3 -fopenmp -O0 -std=c99 -Wall -Werror -Wextra
|
||||||
|
IN_EXT ?= .c
|
||||||
|
LIBS :=
|
||||||
|
OUT_EXT ?= .out
|
||||||
|
|
||||||
|
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
||||||
|
|
||||||
|
all: $(OUTS)
|
||||||
|
|
||||||
|
%$(OUT_EXT): %$(IN_EXT)
|
||||||
|
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *'$(OUT_EXT)'
|
||||||
1
sample_package/external.desc
Normal file
1
sample_package/external.desc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
name: SAMPLE_PACKAGE
|
||||||
21
sample_package/external.mk
Normal file
21
sample_package/external.mk
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# sample_package
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
SAMPLE_PACKAGE_VERSION = 1.0
|
||||||
|
SAMPLE_PACKAGE_SITE = $(BR2_EXTERNAL_SAMPLE_PACKAGE_PATH)
|
||||||
|
SAMPLE_PACKAGE_SITE_METHOD = local
|
||||||
|
|
||||||
|
define SAMPLE_PACKAGE_BUILD_CMDS
|
||||||
|
# D contains the source code of this package.
|
||||||
|
$(MAKE) -C '$(@D)' CC="$(TARGET_CC)" LD="$(TARGET_LD)"
|
||||||
|
endef
|
||||||
|
|
||||||
|
define SAMPLE_PACKAGE_INSTALL_TARGET_CMDS
|
||||||
|
# Anything put inside TARGET_DIR will end up on the guest relative to the root directory.
|
||||||
|
$(INSTALL) -D -m 0755 $(@D)/*.out '$(TARGET_DIR)'
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(generic-package))
|
||||||
7
sample_package/sample_package.c
Normal file
7
sample_package/sample_package.c
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
puts("hello sample_package");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user