From de9223c03d8cbe7011f2d284a3ed4062ce5682f6 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sat, 19 May 2018 09:38:49 +0100 Subject: [PATCH] gem5: aarch64 graphic mode works build: allow passing extra kernel config fragment with -c. Old -c was renamed to -C, and old -C to -f. --- README.adoc | 52 +++++++++++++++++------ build | 31 +++++++++----- build-usage.adoc | 13 ++++-- kernel_config_fragment/gem5-aarch64-hdlcd | 3 ++ 4 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 kernel_config_fragment/gem5-aarch64-hdlcd diff --git a/README.adoc b/README.adoc index e832879..88f6214 100644 --- a/README.adoc +++ b/README.adoc @@ -297,6 +297,7 @@ More concretely: .... git checkout gem5-arm ./build -aa -lg -K linux/arch/arm/configs/gem5_defconfig +./run -aa -gu .... and then on another shell: @@ -305,15 +306,30 @@ and then on another shell: vinagre localhost:5900 .... -TODO: without the `-K` it fails even though we have added to link:kernel_config_fragment/default[] on the branch: +The port `5900` is incremented by one if you already have something running on that port: `gem5` stdout tells us the right port on stdout as: .... -CONFIG_DRM=y -CONFIG_DRM_HDLCD=y -CONFIG_DRM_VIRT_ENCODER=y +system.vncserver: Listening for connections on port 5900 .... -so what other options are missing from `gem5_defconfig`? The failing dmesg is: +aarch64: + +.... +./build -aA -lg -K linux/arch/arm64/configs/gem5_defconfig -c kernel_config_fragment/gem5-aarch64-hdlcd +./run -aA -gu +.... + +We need the extra config fragment because the gem5 aarch64 defconfig does not enable HDLCD like the 32 bit one for some reason. + +TODO: without the `-K`: + +.... +git checkout gem5-arm +./build -aa -lg -c kernel_config_fragment/gem5-aarch64-hdlcd +./run -aa -gu +.... + +it does not work with a failing dmesg: .... [ 0.121078] [drm] found ARM HDLCD version r0p0 @@ -325,6 +341,8 @@ so what other options are missing from `gem5_defconfig`? The failing dmesg is: [ 0.121197] hdlcd: probe of 2b000000.hdlcd failed with error -12 .... +So what other options are missing from `gem5_defconfig`? It would be cool to minimize it out to better understand the options. + === Automatic startup commands When debugging a module, it becomes tedious to wait for build and re-type: @@ -2222,7 +2240,7 @@ TODO we were not able to get it working yet: https://stackoverflow.com/questions === Linux kernel configuration -==== Use your own kernel config +==== Modify kernel config options By default, we use a `.config` that is a mixture of: @@ -2237,14 +2255,24 @@ If you want to just use your own exact `.config` instead, do: 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 <>. 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. -==== Modify a config option - -Only effective for the current build: +Modify a single option: .... -./build -c 'CONFIG_FORTIFY_SOURCE=y' -l +./build -C 'CONFIG_FORTIFY_SOURCE=y' -l .... +Use an extra kernel config fragment file: + +.... +printf ' +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +' > myconfig +./build -c 'myconfig' -l +.... + +`-K`, `-c`, `-C` can all be used at the same time. Options passed via `-C` take precedence over `-c`, which takes precedence over `-K`. + ==== Find the kernel config Ge the build config in guest: @@ -3003,7 +3031,7 @@ TODO: can you get function arguments? https://stackoverflow.com/questions/276087 ==== Kprobes .... -./build -c 'CONFIG_KPROBES=y' +./build -C 'CONFIG_KPROBES=y' ./run -F 'insmod /kprobe_example.ko && sleep 4 & sleep 4 &' .... @@ -3282,7 +3310,7 @@ Make it harder to get hacked and easier to notice that you were, at the cost of Enable: .... -./build -c 'CONFIG_FORTIFY_SOURCE=y' +./build -C 'CONFIG_FORTIFY_SOURCE=y' .... Test it out: diff --git a/build b/build index add0aea..81da965 100755 --- a/build +++ b/build @@ -15,11 +15,12 @@ extra_make_args= j="$(nproc)" linux_reconfigure=false linux_kernel_custom_config_file= +kernel_config_fragments= post_script_args= qemu_sdl='--enable-sdl --with-sdlabi=2.0' suffix= v=0 -while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do +while getopts 'a:B:b:C:c:fGgj:hIiK:klp:qSs:v' OPT; do case "$OPT" in a) arch="$OPTARG" @@ -31,10 +32,13 @@ while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do config_fragments="${config_fragments} $(common_abspath "${OPTARG}")" ;; C) - configure=false + echo "$OPTARG" >> "$kernel_config_fragment_cli_file" ;; c) - echo "$OPTARG" >> "$kernel_config_fragment_cli_file" + kernel_config_fragments="${kernel_config_fragments} $(common_abspath "${OPTARG}")" + ;; + f) + configure=false ;; g) extra_make_args="${extra_make_args} gem5-reconfigure \\ @@ -145,15 +149,22 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\" echo "error: -K: file does not exist: ${linux_kernel_custom_config_file}" 1>&2 exit 1 fi + default_config_fragments= else - d=../kernel_config_fragment - f="${d}/min" - printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${f} ${d}/default ${kernel_config_fragment_cli_file}\"\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 + default_config_fragments="${d}/min ${d}/default" fi + d=../kernel_config_fragment + printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${default_config_fragments} ${kernel_config_fragments} ${kernel_config_fragment_cli_file}\"\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 "${d}/min" + fi + if [ "$arch" = 'mips64' ]; then + # Workaround for: + # 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" + fi + make O="$buildroot_out_dir" olddefconfig if [ "$arch" = 'mips64' ]; then # Workaround for: # http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html diff --git a/build-usage.adoc b/build-usage.adoc index d44d574..e82564f 100644 --- a/build-usage.adoc +++ b/build-usage.adoc @@ -12,13 +12,18 @@ |`-a` |`ARCH` |Build for architecture `ARCH`. |`-B` |`BR2_CONFIG` |Add a single Buildroot option to the current build. Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="512M"'` -|`-b` |`BR2_FILE` |Also use the given Buildroot configuration fragment file. +|`-b` |`BR2_CONFIG_FILE` |Also use the given Buildroot configuration fragment file. Pass multiple times to use multiple fragment files. -|`-C` | |Skip the Buildroot configuration. Saves a few seconds, - but requires you to know what you are doing :-) -|`-c` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example: +|`-C` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example: `./build -c 'CONFIG_FORTIFY_SOURCE=y'` Can be used multiple times for multiple configs. + These options take precedence over `-c`. +|`-c` |`KERNEL_CONFIG_FILE` |Also use the given kernel configuration fragment file. + Pass multiple times to use multiple fragment files. + These options take precedence over `-K`. +|`-f` | |Skip the Buildroot configuration. Saves a few seconds, + but requires you to know what you are doing :-) + Mnemonic: `fast`. |`-g` | |Enable gem5 build or force its rebuild. |`-h` | |Show this help message. |`-I` | |Enable initramfs for the current build. diff --git a/kernel_config_fragment/gem5-aarch64-hdlcd b/kernel_config_fragment/gem5-aarch64-hdlcd new file mode 100644 index 0000000..11b0c6a --- /dev/null +++ b/kernel_config_fragment/gem5-aarch64-hdlcd @@ -0,0 +1,3 @@ +CONFIG_DRM=y +CONFIG_DRM_HDLCD=y +CONFIG_DRM_VIRT_ENCODER=y