mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Create the cli.gitignore mechanism to pass extra default cli options
Document that X11 mouse is not moving. Convert x='' to x= on all scripts, and also fix case ;; indentations. Add dummy value to QEMU's -trace enable= to prevent warning. Expand built-in package choice rationale.
This commit is contained in:
92
README.adoc
92
README.adoc
@@ -110,6 +110,22 @@ Not all packages have an alias, when they don't, just use the form:
|
||||
./build -- <pkg>-reconfigure
|
||||
....
|
||||
|
||||
=== Don't retype arguments all the time
|
||||
|
||||
It gets annoying to retype `-a aarch64` for every single command, or to remember `./build -B` setups.
|
||||
|
||||
So simplify that, do:
|
||||
|
||||
....
|
||||
cp cli.gitignore.example cli.gitignore
|
||||
....
|
||||
|
||||
and then edit the `cli.gitignore` file to your needs.
|
||||
|
||||
That file is used to pass extra command line arguments to most of our utilities.
|
||||
|
||||
Of course, you could get by with the shell history, or your own aliases, but we've felt that it was worth introducing a common mechanism for that.
|
||||
|
||||
=== Clean the build
|
||||
|
||||
You did something crazy, and nothing seems to work anymore?
|
||||
@@ -1231,12 +1247,52 @@ Inside QEMU:
|
||||
startx
|
||||
....
|
||||
|
||||
And then from the GUI you can start exciting graphical programs such as:
|
||||
|
||||
....
|
||||
xcalc
|
||||
xeyes
|
||||
....
|
||||
|
||||
image:x11.png[image]
|
||||
|
||||
More details: https://unix.stackexchange.com/questions/70931/how-to-install-x11-on-my-own-linux-buildroot-system/306116#306116
|
||||
|
||||
Not sure how well that graphics stack represents real systems, but if it does it would be a good way to understand how it works.
|
||||
|
||||
=== X11 mouse not moving
|
||||
|
||||
TODO 9076c1d9bcc13b6efdb8ef502274f846d8d4e6a1 I'm 100% sure that it was working before, but I didn't run it forever, and it stopped working at some point. Needs bisection, on whatever commit last touched x11 stuff.
|
||||
|
||||
* https://askubuntu.com/questions/730891/how-can-i-get-a-mouse-cursor-in-qemu
|
||||
* https://stackoverflow.com/questions/19665412/mouse-and-keyboard-not-working-in-qemu-emulator
|
||||
|
||||
`-show-cursor` did not help, I just get to see the host cursor, but the guest cursor still does not move.
|
||||
|
||||
Doing:
|
||||
|
||||
....
|
||||
watch -n 1 grep i8042 /proc/interrupts
|
||||
....
|
||||
|
||||
shows that interrupts do happen when mouse and keyboard presses are done, so I expect that it is some wrong either with:
|
||||
|
||||
* QEMU. Same behaviour if I try the host's QEMU 2.10.1 however.
|
||||
* X11 configuration. We do have `BR2_PACKAGE_XDRIVER_XF86_INPUT_MOUSE=y`.
|
||||
|
||||
`/var/log/Xorg.0.log` contains the following interesting lines:
|
||||
|
||||
....
|
||||
[ 27.549] (II) LoadModule: "mouse"
|
||||
[ 27.549] (II) Loading /usr/lib/xorg/modules/input/mouse_drv.so
|
||||
[ 27.590] (EE) <default pointer>: Cannot find which device to use.
|
||||
[ 27.590] (EE) <default pointer>: cannot open input device
|
||||
[ 27.590] (EE) PreInit returned 2 for "<default pointer>"
|
||||
[ 27.590] (II) UnloadModule: "mouse"
|
||||
....
|
||||
|
||||
The file `/dev/inputs/mice` does not exist.
|
||||
|
||||
=== X11 ARM
|
||||
|
||||
On ARM, `startx` hangs at a message:
|
||||
@@ -2621,9 +2677,10 @@ External open source benchmarks. We will try to create Buildroot packages for th
|
||||
Buildroot supports it, which makes everything just trivial:
|
||||
|
||||
....
|
||||
printf 'BR2_PACKAGE_OPENBLAS=y\n' >> br2.gitignore
|
||||
printf 'BR2_TARGET_ROOTFS_EXT2_SIZE="128M"\n' >> br2.gitignore
|
||||
./build -a arm -g -b br2.gitignore -- kernel_module-reconfigure
|
||||
./build \
|
||||
-a arm \
|
||||
-B 'BR2_PACKAGE_OPENBLAS=y' \
|
||||
;
|
||||
....
|
||||
|
||||
and then inside the guest run our test program:
|
||||
@@ -2635,7 +2692,7 @@ and then inside the guest run our test program:
|
||||
For x86, you also need:
|
||||
|
||||
....
|
||||
printf 'BR2_PACKAGE_OPENBLAS_TARGET="NEHALEM"\n' >> br2.gitignore
|
||||
-B 'BR2_PACKAGE_OPENBLAS_TARGET="NEHALEM"'
|
||||
....
|
||||
|
||||
to overcome this bug: https://bugs.busybox.net/show_bug.cgi?id=10856
|
||||
@@ -2741,7 +2798,7 @@ If you still want to run this, try it out with:
|
||||
|
||||
....
|
||||
./build \
|
||||
-a arm \
|
||||
-a aarch64 \
|
||||
-B 'BR2_PACKAGE_PARSEC_BENCHMARK=y' \
|
||||
-B 'BR2_PACKAGE_PARSEC_BENCHMARK_PARSECMGMT=y' \
|
||||
-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="3G"' \
|
||||
@@ -3398,12 +3455,7 @@ dmesg
|
||||
|
||||
We provide the following mechanisms:
|
||||
|
||||
* `./build -b br2.gitignore`: append the file `br2.gitignore` to a single build. Must be passed every time you run `./build`. A good template is provided by:
|
||||
+
|
||||
....
|
||||
cp br2.gitignore.example br2.gitignore
|
||||
....
|
||||
+
|
||||
* `./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.
|
||||
|
||||
=== Find Buildroot options with make menuconfig
|
||||
@@ -3563,8 +3615,22 @@ Our philosophy is:
|
||||
|
||||
* if something adds little to the build time, build it in by default
|
||||
* otherwise, make it optional
|
||||
|
||||
The build biggest time hog is always GCC, and it does not look like we can use a precompiled one: https://stackoverflow.com/questions/10833672/buildroot-environment-with-host-toolchain
|
||||
* try to keep the toolchain (GCC, Binutils) unchanged, otherwise a full rebuild is required.
|
||||
+
|
||||
So we generally just enable all toolchain options by defaut, even though this adds a bit of time to the build.
|
||||
+
|
||||
The biggest build time hog is always GCC, and it does not look like we can use a precompiled one: https://stackoverflow.com/questions/10833672/buildroot-environment-with-host-toolchain
|
||||
* if something is very vaulable, we just add it by default even if it increases the Build time, notably GDB and QEMU
|
||||
* runtime is sacred.
|
||||
+
|
||||
We do our best to reduce the instruction and feature count to the bare minimum needed, to make the system:
|
||||
+
|
||||
--
|
||||
** easier to understand
|
||||
** run faster, specially for <<gem5>>
|
||||
--
|
||||
+
|
||||
One possibility we could play with is to build loadable modules instead of built-in modules to reduce runtime, but make it easier to get started with the modules.
|
||||
|
||||
=== Benchmark machines
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
|
||||
|
||||
#BR2_PACKAGE_OPENSSH=y
|
||||
|
||||
#BR2_PACKAGE_OPENBLAS=y
|
||||
#BR2_PACKAGE_OPENBLAS_TARGET="NEHALEM"
|
||||
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK=y
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK_BUILD_LIST="all"
|
||||
#BR2_PACKAGE_PARSEC_BENCHMARK_INPUT_SIZE="test"
|
||||
46
build
46
build
@@ -1,83 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_build:-} "$@"
|
||||
arch=x86_64
|
||||
rm -f br2_cli.gitignore
|
||||
touch br2_cli.gitignore
|
||||
configure=true
|
||||
config_fragments='br2'
|
||||
extra_make_args=''
|
||||
extra_make_args=
|
||||
gem5=false
|
||||
j="$(($(nproc) - 2))"
|
||||
linux_reconfigure=false
|
||||
linux_kernel_custom_config_file=''
|
||||
post_script_args=''
|
||||
linux_kernel_custom_config_file=
|
||||
post_script_args=
|
||||
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
|
||||
v=0
|
||||
while getopts 'a:B:b:CGgj:hIiK:klp:qSv' OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
;;
|
||||
b)
|
||||
config_fragments="$config_fragments $OPTARG"
|
||||
;;
|
||||
;;
|
||||
B)
|
||||
echo "$OPTARG" >> br2_cli.gitignore
|
||||
;;
|
||||
;;
|
||||
C)
|
||||
configure=false
|
||||
;;
|
||||
;;
|
||||
G)
|
||||
extra_make_args="$extra_make_args gem5-reconfigure"
|
||||
gem5=true
|
||||
;;
|
||||
;;
|
||||
g)
|
||||
gem5=true
|
||||
;;
|
||||
;;
|
||||
h)
|
||||
cat build-usage.adoc 1>&2
|
||||
exit
|
||||
;;
|
||||
;;
|
||||
I)
|
||||
echo "
|
||||
BR2_TARGET_ROOTFS_CPIO=n
|
||||
BR2_TARGET_ROOTFS_EXT2=n
|
||||
BR2_TARGET_ROOTFS_INITRAMFS=y
|
||||
" >> br2_cli.gitignore
|
||||
;;
|
||||
;;
|
||||
i)
|
||||
echo "
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
BR2_TARGET_ROOTFS_EXT2=n
|
||||
BR2_TARGET_ROOTFS_INITRAMFS=n
|
||||
" >> br2_cli.gitignore
|
||||
;;
|
||||
;;
|
||||
j)
|
||||
echo "$OPTARG" >> br2_cli.gitignore
|
||||
;;
|
||||
;;
|
||||
K)
|
||||
linux_kernel_custom_config_file="$OPTARG"
|
||||
;;
|
||||
;;
|
||||
k)
|
||||
extra_make_args="$extra_make_args kernel_module-reconfigure"
|
||||
;;
|
||||
;;
|
||||
l)
|
||||
linux_reconfigure=true
|
||||
extra_make_args="$extra_make_args linux-reconfigure"
|
||||
;;
|
||||
;;
|
||||
p)
|
||||
post_script_args="$OPTARG"
|
||||
;;
|
||||
;;
|
||||
q)
|
||||
extra_make_args="$extra_make_args host-qemu-reconfigure"
|
||||
;;
|
||||
;;
|
||||
S)
|
||||
qemu_sdl=''
|
||||
;;
|
||||
qemu_sdl=
|
||||
;;
|
||||
v)
|
||||
v=1
|
||||
;;
|
||||
;;
|
||||
?)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
14
cli.gitignore.example
Normal file
14
cli.gitignore.example
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
arch=x86_64
|
||||
gem5=
|
||||
#gem5=-g
|
||||
printf '
|
||||
#BR2_TARGET_ROOTFS_EXT2_SIZE="1024M"
|
||||
' > br2.gitignore
|
||||
cli_build="-a ${arch} -b br2.gitignore -b br2_x11 ${gem5}"
|
||||
cli_run="-a ${arch} ${gem5}"
|
||||
cli_rungdb="-a ${arch} ${gem5}"
|
||||
cli_rungdbserver="-a ${arch} ${gem5}"
|
||||
cli_rungdb_user="-a ${arch} ${gem5}"
|
||||
cli_trace_boot="-a ${arch}"
|
||||
cli_trace2line="-a ${arch}"
|
||||
4
common
4
common
@@ -17,3 +17,7 @@ set_common_vars() {
|
||||
qemu_out_dir="${out_arch_dir}/qemu"
|
||||
common_dir="${out_dir}/common"
|
||||
}
|
||||
f=cli.gitignore
|
||||
if [ -f "$f" ]; then
|
||||
. "$f"
|
||||
fi
|
||||
|
||||
4
configure
vendored
4
configure
vendored
@@ -4,7 +4,7 @@ interactive_pkgs=libsdl2-dev
|
||||
gem5=false
|
||||
qemu=true
|
||||
submodules='buildroot linux'
|
||||
y=''
|
||||
y=
|
||||
while getopts gpqt OPT; do
|
||||
case "$OPT" in
|
||||
g)
|
||||
@@ -17,7 +17,7 @@ while getopts gpqt OPT; do
|
||||
qemu=false
|
||||
;;
|
||||
t)
|
||||
interactive_pkgs=''
|
||||
interactive_pkgs=
|
||||
y='-y'
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#/usr/bin/env bash
|
||||
set -eu
|
||||
arch=x86_64
|
||||
cross_compile=''
|
||||
j=''
|
||||
cross_compile=
|
||||
j=
|
||||
while getopts a:c:j: OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
|
||||
@@ -28,6 +28,8 @@ config BR2_PACKAGE_PARSEC_BENCHMARK_PARSECMGMT
|
||||
The other option would be to patch Parsec to use /bin/sh and be POSIX compliant.
|
||||
But let's take the path of smallest resistance for now.
|
||||
|
||||
if !BR2_PACKAGE_PARSEC_BENCHMARK_PARSECMGMT
|
||||
|
||||
config BR2_PACKAGE_PARSEC_BENCHMARK_INPUT_SIZE
|
||||
string "input_size"
|
||||
default test
|
||||
@@ -35,3 +37,5 @@ config BR2_PACKAGE_PARSEC_BENCHMARK_INPUT_SIZE
|
||||
Which input size to generate on the host for the guest.
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
24
run
24
run
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_run:-} "$@"
|
||||
|
||||
# CLI handling.
|
||||
arch=x86_64
|
||||
cpus=1
|
||||
debug_vm=''
|
||||
debug_vm=
|
||||
debug=false
|
||||
kgdb=false
|
||||
kvm=false
|
||||
@@ -14,18 +15,20 @@ kvm=false
|
||||
# nokaslr: https://unix.stackexchange.com/questions/397939/turning-off-kaslr-to-debug-linux-kernel-using-qemu-and-gdb
|
||||
# Turned on by default since v4.12
|
||||
extra_append='nokaslr norandmaps printk.devkmsg=on printk.time=y'
|
||||
extra_append_after_dash=''
|
||||
extra_flags=''
|
||||
extra_flags_qemu=''
|
||||
extra_append_after_dash=
|
||||
extra_flags=
|
||||
extra_flags_qemu=
|
||||
gem5=false
|
||||
gem5opts=''
|
||||
lkmc_eval=''
|
||||
gem5opts=
|
||||
lkmc_eval=
|
||||
initrd=false
|
||||
initramfs=false
|
||||
memory=256M
|
||||
nographic=true
|
||||
root=''
|
||||
trace_enable=''
|
||||
root=
|
||||
# A dummy value that is already turned on by default and does not produce large output,
|
||||
# just to prevent QEMU from emitting a warning that '' is not valid.
|
||||
trace_enable=pr_manager_run
|
||||
while getopts a:c:DdE:e:f:G:ghIiKkm:T:x OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
@@ -59,7 +62,7 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:x OPT; do
|
||||
h)
|
||||
cat build-usage.adoc 1>&2
|
||||
exit
|
||||
;;
|
||||
;;
|
||||
I)
|
||||
initramfs=true
|
||||
;;
|
||||
@@ -85,6 +88,9 @@ while getopts a:c:DdE:e:f:G:ghIiKkm:T:x OPT; do
|
||||
x)
|
||||
nographic=false
|
||||
;;
|
||||
?)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
|
||||
18
rungdb
18
rungdb
@@ -1,20 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
after=''
|
||||
set -- ${cli_rungdb:-} "$@"
|
||||
after=
|
||||
arch='x86_64'
|
||||
before=''
|
||||
before=
|
||||
gem5=false
|
||||
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/'"
|
||||
kgdb=false
|
||||
while getopts A:a:b:gkL OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
A)
|
||||
after="$OPTARG"
|
||||
;;
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
b)
|
||||
before="$OPTARG"
|
||||
;;
|
||||
@@ -25,7 +26,10 @@ while getopts A:a:b:gkL OPT; do
|
||||
kgdb=true
|
||||
;;
|
||||
L)
|
||||
lx_symbols=''
|
||||
lx_symbols=
|
||||
;;
|
||||
?)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -34,7 +38,7 @@ if [ "$#" -gt 0 ]; then
|
||||
brk="-ex 'break ${1}'"
|
||||
shift
|
||||
else
|
||||
brk=''
|
||||
brk=
|
||||
fi
|
||||
if "$gem5"; then
|
||||
port=7000
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_rungdb_user:-} "$@"
|
||||
usage="$0 <exec-relative-path> [<brk-symbol>]"
|
||||
arch='x86_64'
|
||||
gem5=false
|
||||
gem5_opt=''
|
||||
gem5_opt=
|
||||
while getopts a:gh OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
@@ -18,6 +19,9 @@ while getopts a:gh OPT; do
|
||||
echo "$usage"
|
||||
exit 0
|
||||
;;
|
||||
?)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
@@ -27,7 +31,7 @@ if [ "$#" -gt 0 ]; then
|
||||
brk="'$1'"
|
||||
shift
|
||||
else
|
||||
brk=''
|
||||
brk=
|
||||
fi
|
||||
set_common_vars "$arch" "$gem5"
|
||||
executable="${build_dir}/${executable_rel}"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_rungdbserver:-} "$@"
|
||||
arch='x86_64'
|
||||
gem5=false
|
||||
while getopts a:g OPT; do
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_trace_boot:-} "$@"
|
||||
arch=x86_64
|
||||
while getopts a: OPT; do
|
||||
case "$OPT" in
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
. common
|
||||
set -- ${cli_trace2line:-} "$@"
|
||||
arch=x86_64
|
||||
while getopts a: OPT; do
|
||||
case "$OPT" in
|
||||
|
||||
Reference in New Issue
Block a user