mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-29 13:04:27 +01:00
build: -l touches config files to overcome https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
Introduce -G option that forces gem5 rebuild in addition to -g.
This commit is contained in:
46
README.adoc
46
README.adoc
@@ -73,7 +73,7 @@ git ls-files | grep modulename
|
|||||||
|
|
||||||
=== Rebuild
|
=== Rebuild
|
||||||
|
|
||||||
After making changes to a package, you must explicitly tell it to be rebuilt.
|
After making changes to a package, you must explicitly request it to be rebuilt.
|
||||||
|
|
||||||
For example, you you modify the kernel modules, you must rebuild with:
|
For example, you you modify the kernel modules, you must rebuild with:
|
||||||
|
|
||||||
@@ -92,17 +92,25 @@ where `kernel_module` is the name of out Buildroot package that contains the ker
|
|||||||
Other important targets are:
|
Other important targets are:
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -- linux-reconfigure host-qemu-reconfigure
|
./build -l -q -G
|
||||||
....
|
....
|
||||||
|
|
||||||
which are aliased respectively to:
|
which rebuild the Linux kernel, and QEMU and gem5 respectively. They are essentially aliases for:
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -l -q
|
./build -- linux-reconfigure host-qemu-reconfigure gem5-reconfigure
|
||||||
....
|
....
|
||||||
|
|
||||||
|
However, some of our aliases such as `-l` also have some magic convenience properties. So generally just use the aliases instead.
|
||||||
|
|
||||||
We don't rebuild by default because, even with `make` incremental rebuilds, the timestamp check takes a few annoying seconds.
|
We don't rebuild by default because, even with `make` incremental rebuilds, the timestamp check takes a few annoying seconds.
|
||||||
|
|
||||||
|
Not all packages have an alias, when they don't, just use the form:
|
||||||
|
|
||||||
|
....
|
||||||
|
./build -- <pkg>-reconfigure
|
||||||
|
....
|
||||||
|
|
||||||
=== Clean the build
|
=== Clean the build
|
||||||
|
|
||||||
You did something crazy, and nothing seems to work anymore?
|
You did something crazy, and nothing seems to work anymore?
|
||||||
@@ -1417,11 +1425,10 @@ So the only argument that QEMU needs is the `-kernel`, no `-drive` not even `-in
|
|||||||
Try it out with:
|
Try it out with:
|
||||||
|
|
||||||
....
|
....
|
||||||
touch kernel_config_fragment
|
./build -I -l && ./run -I
|
||||||
./build -I && ./run -I
|
|
||||||
....
|
....
|
||||||
|
|
||||||
The `touch` should only be used the first time you move to / from a different root filesystem method (ext2 or cpio) to initramfs to overcome: <<force-linux-kernel-configuration-update>>. Further builds should be done simply as:
|
The `-l` (ell) should only be used the first time you move to / from a different root filesystem method (ext2 or cpio) to initramfs to overcome: https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
||||||
|
|
||||||
....
|
....
|
||||||
./build -I && ./run -I
|
./build -I && ./run -I
|
||||||
@@ -1457,12 +1464,9 @@ By default, we use a `.config` that is a mixture of:
|
|||||||
If you want to just use your own exact `.config` instead, do:
|
If you want to just use your own exact `.config` instead, do:
|
||||||
|
|
||||||
....
|
....
|
||||||
touch myconfig
|
./build -K myconfig -l
|
||||||
./build -K myconfig
|
|
||||||
....
|
....
|
||||||
|
|
||||||
The `touch` is only need the first time you move to a new kernel configuration: <<force-linux-kernel-configuration-update>>.
|
|
||||||
|
|
||||||
Beware that Buildroot can `sed` override some of the configurations we make no matter what, e.g. it forces `CONFIG_BLK_DEV_INITRD=y` when `BR2_TARGET_ROOTFS_CPIO` is on, so you might want to double check as explained at <<find-the-kernel-config>>. TODO check if there is a way to prevent that patching and maybe patch Buildroot for it, it is too fuzzy. People should be able to just build with whatever `.config` they want.
|
Beware that Buildroot can `sed` override some of the configurations we make no matter what, e.g. it forces `CONFIG_BLK_DEV_INITRD=y` when `BR2_TARGET_ROOTFS_CPIO` is on, so you might want to double check as explained at <<find-the-kernel-config>>. TODO check if there is a way to prevent that patching and maybe patch Buildroot for it, it is too fuzzy. People should be able to just build with whatever `.config` they want.
|
||||||
|
|
||||||
==== Find the kernel config
|
==== Find the kernel config
|
||||||
@@ -1479,26 +1483,6 @@ or on host:
|
|||||||
cat buildroot/output.*~/build/linux-custom/.config
|
cat buildroot/output.*~/build/linux-custom/.config
|
||||||
....
|
....
|
||||||
|
|
||||||
==== Force Linux kernel configuration update
|
|
||||||
|
|
||||||
https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
|
||||||
|
|
||||||
To save rebuild time, Buildroot does many things based on timestamps.
|
|
||||||
|
|
||||||
This means that some operations end up not updating the Linux kernel `.config`, and we just require you to do it manually with:
|
|
||||||
|
|
||||||
....
|
|
||||||
touch kernel_config_fragment
|
|
||||||
....
|
|
||||||
|
|
||||||
When this works, you should see Buildroot run the kernel rebuild commands:
|
|
||||||
|
|
||||||
The reason we don't do that automatically all the time, is that this would defeat the purpose of the timestamp, and add some overhead even when you are not modifying the config at all.
|
|
||||||
|
|
||||||
Maybe we could think of smarter methods to overcome this problem more automatically, e.g. take hashes and check them whenever a suspicious operations happens.
|
|
||||||
|
|
||||||
But for now we just require you to do the `touch` manually yourself, and document when this is needed.
|
|
||||||
|
|
||||||
=== Find the kernel version
|
=== Find the kernel version
|
||||||
|
|
||||||
We try to use the latest possible kernel major release version.
|
We try to use the latest possible kernel major release version.
|
||||||
|
|||||||
28
build
28
build
@@ -9,11 +9,12 @@ config_fragments='br2'
|
|||||||
extra_make_args=''
|
extra_make_args=''
|
||||||
gem5=false
|
gem5=false
|
||||||
j="$(($(nproc) - 2))"
|
j="$(($(nproc) - 2))"
|
||||||
|
linux_reconfigure=false
|
||||||
linux_kernel_custom_config_file=''
|
linux_kernel_custom_config_file=''
|
||||||
post_script_args=''
|
post_script_args=''
|
||||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||||
v=0
|
v=0
|
||||||
while getopts 'a:b:c:Cgj:hIiK:klp:qSv' OPT; do
|
while getopts 'a:b:c:CGgj:hIiK:klp:qSv' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
a)
|
||||||
arch="$OPTARG"
|
arch="$OPTARG"
|
||||||
@@ -27,6 +28,10 @@ while getopts 'a:b:c:Cgj:hIiK:klp:qSv' OPT; do
|
|||||||
C)
|
C)
|
||||||
configure=false
|
configure=false
|
||||||
;;
|
;;
|
||||||
|
G)
|
||||||
|
extra_make_args="$extra_make_args gem5-reconfigure"
|
||||||
|
gem5=true
|
||||||
|
;;
|
||||||
g)
|
g)
|
||||||
gem5=true
|
gem5=true
|
||||||
;;
|
;;
|
||||||
@@ -58,6 +63,7 @@ BR2_TARGET_ROOTFS_INITRAMFS=n
|
|||||||
extra_make_args="$extra_make_args kernel_module-reconfigure"
|
extra_make_args="$extra_make_args kernel_module-reconfigure"
|
||||||
;;
|
;;
|
||||||
l)
|
l)
|
||||||
|
linux_reconfigure=true
|
||||||
extra_make_args="$extra_make_args linux-reconfigure"
|
extra_make_args="$extra_make_args linux-reconfigure"
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
@@ -121,17 +127,29 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"$post_script_args\"
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$linux_kernel_custom_config_file" ]; then
|
if [ -n "$linux_kernel_custom_config_file" ]; then
|
||||||
|
f="../${linux_kernel_custom_config_file}"
|
||||||
|
if [ -f "$f" ]; then
|
||||||
|
printf "BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"${f}\"\n" >> "${config_file}"
|
||||||
|
if "${linux_reconfigure}"; then
|
||||||
|
touch "$f"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "error: -K: file does not exist: ${linux_kernel_custom_config_file}" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"../kernel_config_fragment\"\n" >> "${config_file}"
|
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"../kernel_config_fragment\"\n" >> "${config_file}"
|
||||||
|
if "${linux_reconfigure}"; then
|
||||||
|
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
||||||
|
touch "$f"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$arch" = 'mips64' ]; then
|
if [ "$arch" = 'mips64' ]; then
|
||||||
# Workaround for:
|
# Workaround for:
|
||||||
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
|
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
|
||||||
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "${config_file}"
|
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "${config_file}"
|
||||||
fi
|
fi
|
||||||
if [ -n "$linux_kernel_custom_config_file" ]; then
|
|
||||||
printf "BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=\"../${linux_kernel_custom_config_file}\"\n" >> "${config_file}"
|
|
||||||
fi
|
|
||||||
make O="$out_dir" olddefconfig
|
make O="$out_dir" olddefconfig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
./build [OPTIONS] [-- EXTRA_MAKE_ARGS]
|
./build [OPTIONS] [-- EXTRA_MAKE_ARGS]
|
||||||
....
|
....
|
||||||
|
|
||||||
|
== Configuration options
|
||||||
|
|
||||||
[options="header"]
|
[options="header"]
|
||||||
|===
|
|===
|
||||||
|Name |Argument name | Description
|
|Name |Argument name | Description
|
||||||
@@ -14,25 +16,30 @@
|
|||||||
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="500M"'`
|
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="500M"'`
|
||||||
|`-c` |`BR2_FILE` | Also use the given Buildroot configuration fragment file.
|
|`-c` |`BR2_FILE` | Also use the given Buildroot configuration fragment file.
|
||||||
Pass multiple times to use multiple fragment files.
|
Pass multiple times to use multiple fragment files.
|
||||||
|`-C` | | Skip the Buildroot configuration. Saves a few seconds, but requires
|
|`-C` | | Skip the Buildroot configuration. Saves a few seconds,
|
||||||
you to know what you are doing :-)
|
but requires you to know what you are doing :-)
|
||||||
|`-g` | | Enable gem5 build. You also need to use `-- gem5-reconfigure`
|
|`-g` | | Enable gem5 build and disable QEMU build. You also need
|
||||||
to rebuild gem5 after the initial build.
|
to use `-G` or `-- gem5-reconfigure` to rebuild gem5
|
||||||
|
after the initial build.
|
||||||
|`-h` | | Show this help message.
|
|`-h` | | Show this help message.
|
||||||
|`-I` | | Enable initramfs for the current build.
|
|`-I` | | Enable initramfs for the current build.
|
||||||
|`-i` | | Enable initrd for the current build.
|
|`-i` | | Enable initrd for the current build.
|
||||||
|`-K` |`KERNEL_CONFIG_FILE` | Use `KERNEL_CONFIG_FILE` as the exact Linux
|
|`-K` |`KERNEL_CONFIG_FILE` | Use `KERNEL_CONFIG_FILE` as the exact Linux kernel
|
||||||
kernel configuration. Ignore the default `kernel_config_fragment`.
|
configuration. Ignore the default `kernel_config_fragment`.
|
||||||
You also need to `touch KERNEL_CONFIG_FILE` if that file is
|
|
||||||
older than the latest build.
|
|
||||||
|`-k` | | Reconfigure and rebuild the kernel module package.
|
|
||||||
Shortcut for `-- kernel_module-reconfigure`.
|
|
||||||
|`-l` | | Reconfigure and rebuild the linux kernel.
|
|
||||||
Shortcut for `-- linux-reconfigure`.
|
|
||||||
|`-p` | | Pass extra arguments to the `rootfs_post_build_script`.
|
|`-p` | | Pass extra arguments to the `rootfs_post_build_script`.
|
||||||
|`-q` | | Reconfigure and rebuild QEMU.
|
|
||||||
Shortcut for `-- host-qemu-reconfigure`.
|
|
||||||
|`-S` | | Don't build QEMU with SDL support.
|
|`-S` | | Don't build QEMU with SDL support.
|
||||||
Graphics such as X11 won't work, only the terminal.
|
Graphics such as X11 won't work, only the terminal.
|
||||||
|`-v` | | Do a verbose build.
|
|`-v` | | Do a verbose build.
|
||||||
|===
|
|===
|
||||||
|
|
||||||
|
== Build target options
|
||||||
|
|
||||||
|
[options="header"]
|
||||||
|
|===
|
||||||
|
|Name |Forces rebuild of |Extra actions
|
||||||
|
|`-G` |gem5 |Implies `-g`.
|
||||||
|
|`-k` |Kernel modules |
|
||||||
|
|`-l` |Linux kernel |Touches kernel configuration files to overcome:
|
||||||
|
https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
|
||||||
|
|`-q` |QEMU |
|
||||||
|
|===
|
||||||
|
|||||||
Reference in New Issue
Block a user