Skip to content

Commit de9223c

Browse files
committed
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.
1 parent d9df5f9 commit de9223c

File tree

4 files changed

+72
-25
lines changed

4 files changed

+72
-25
lines changed

README.adoc

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ More concretely:
297297
....
298298
git checkout gem5-arm
299299
./build -aa -lg -K linux/arch/arm/configs/gem5_defconfig
300+
./run -aa -gu
300301
....
301302

302303
and then on another shell:
@@ -305,15 +306,30 @@ and then on another shell:
305306
vinagre localhost:5900
306307
....
307308

308-
TODO: without the `-K` it fails even though we have added to link:kernel_config_fragment/default[] on the branch:
309+
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:
309310

310311
....
311-
CONFIG_DRM=y
312-
CONFIG_DRM_HDLCD=y
313-
CONFIG_DRM_VIRT_ENCODER=y
312+
system.vncserver: Listening for connections on port 5900
314313
....
315314

316-
so what other options are missing from `gem5_defconfig`? The failing dmesg is:
315+
aarch64:
316+
317+
....
318+
./build -aA -lg -K linux/arch/arm64/configs/gem5_defconfig -c kernel_config_fragment/gem5-aarch64-hdlcd
319+
./run -aA -gu
320+
....
321+
322+
We need the extra config fragment because the gem5 aarch64 defconfig does not enable HDLCD like the 32 bit one for some reason.
323+
324+
TODO: without the `-K`:
325+
326+
....
327+
git checkout gem5-arm
328+
./build -aa -lg -c kernel_config_fragment/gem5-aarch64-hdlcd
329+
./run -aa -gu
330+
....
331+
332+
it does not work with a failing dmesg:
317333

318334
....
319335
[ 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:
325341
[ 0.121197] hdlcd: probe of 2b000000.hdlcd failed with error -12
326342
....
327343

344+
So what other options are missing from `gem5_defconfig`? It would be cool to minimize it out to better understand the options.
345+
328346
=== Automatic startup commands
329347

330348
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
22222240

22232241
=== Linux kernel configuration
22242242

2225-
==== Use your own kernel config
2243+
==== Modify kernel config options
22262244

22272245
By default, we use a `.config` that is a mixture of:
22282246

@@ -2237,14 +2255,24 @@ If you want to just use your own exact `.config` instead, do:
22372255

22382256
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.
22392257

2240-
==== Modify a config option
2258+
Modify a single option:
2259+
2260+
....
2261+
./build -C 'CONFIG_FORTIFY_SOURCE=y' -l
2262+
....
22412263

2242-
Only effective for the current build:
2264+
Use an extra kernel config fragment file:
22432265

22442266
....
2245-
./build -c 'CONFIG_FORTIFY_SOURCE=y' -l
2267+
printf '
2268+
CONFIG_IKCONFIG=y
2269+
CONFIG_IKCONFIG_PROC=y
2270+
' > myconfig
2271+
./build -c 'myconfig' -l
22462272
....
22472273

2274+
`-K`, `-c`, `-C` can all be used at the same time. Options passed via `-C` take precedence over `-c`, which takes precedence over `-K`.
2275+
22482276
==== Find the kernel config
22492277

22502278
Ge the build config in guest:
@@ -3003,7 +3031,7 @@ TODO: can you get function arguments? https://stackoverflow.com/questions/276087
30033031
==== Kprobes
30043032

30053033
....
3006-
./build -c 'CONFIG_KPROBES=y'
3034+
./build -C 'CONFIG_KPROBES=y'
30073035
./run -F 'insmod /kprobe_example.ko && sleep 4 & sleep 4 &'
30083036
....
30093037

@@ -3282,7 +3310,7 @@ Make it harder to get hacked and easier to notice that you were, at the cost of
32823310
Enable:
32833311

32843312
....
3285-
./build -c 'CONFIG_FORTIFY_SOURCE=y'
3313+
./build -C 'CONFIG_FORTIFY_SOURCE=y'
32863314
....
32873315

32883316
Test it out:

build

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ extra_make_args=
1515
j="$(nproc)"
1616
linux_reconfigure=false
1717
linux_kernel_custom_config_file=
18+
kernel_config_fragments=
1819
post_script_args=
1920
qemu_sdl='--enable-sdl --with-sdlabi=2.0'
2021
suffix=
2122
v=0
22-
while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do
23+
while getopts 'a:B:b:C:c:fGgj:hIiK:klp:qSs:v' OPT; do
2324
case "$OPT" in
2425
a)
2526
arch="$OPTARG"
@@ -31,10 +32,13 @@ while getopts 'a:B:b:Cc:Ggj:hIiK:klp:qSs:v' OPT; do
3132
config_fragments="${config_fragments} $(common_abspath "${OPTARG}")"
3233
;;
3334
C)
34-
configure=false
35+
echo "$OPTARG" >> "$kernel_config_fragment_cli_file"
3536
;;
3637
c)
37-
echo "$OPTARG" >> "$kernel_config_fragment_cli_file"
38+
kernel_config_fragments="${kernel_config_fragments} $(common_abspath "${OPTARG}")"
39+
;;
40+
f)
41+
configure=false
3842
;;
3943
g)
4044
extra_make_args="${extra_make_args} gem5-reconfigure \\
@@ -145,21 +149,28 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\"
145149
echo "error: -K: file does not exist: ${linux_kernel_custom_config_file}" 1>&2
146150
exit 1
147151
fi
152+
default_config_fragments=
148153
else
149-
d=../kernel_config_fragment
150-
f="${d}/min"
151-
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${f} ${d}/default ${kernel_config_fragment_cli_file}\"\n" >> "$config_file"
152-
if "${linux_reconfigure}"; then
153-
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
154-
touch "$f"
155-
fi
154+
default_config_fragments="${d}/min ${d}/default"
155+
fi
156+
d=../kernel_config_fragment
157+
printf "BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES=\"${default_config_fragments} ${kernel_config_fragments} ${kernel_config_fragment_cli_file}\"\n" >> "$config_file"
158+
if "${linux_reconfigure}"; then
159+
# https://stackoverflow.com/questions/49260466/why-when-i-change-br2-linux-kernel-custom-config-file-and-run-make-linux-reconfi
160+
touch "${d}/min"
156161
fi
157162
if [ "$arch" = 'mips64' ]; then
158163
# Workaround for:
159164
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
160165
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file"
161166
fi
162167
make O="$buildroot_out_dir" olddefconfig
168+
if [ "$arch" = 'mips64' ]; then
169+
# Workaround for:
170+
# http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html
171+
sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file"
172+
fi
173+
make O="$buildroot_out_dir" olddefconfig
163174
fi
164175

165176
mkdir -p \

build-usage.adoc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
|`-a` |`ARCH` |Build for architecture `ARCH`.
1313
|`-B` |`BR2_CONFIG` |Add a single Buildroot option to the current build.
1414
Example: `-B 'BR2_TARGET_ROOTFS_EXT2_SIZE="512M"'`
15-
|`-b` |`BR2_FILE` |Also use the given Buildroot configuration fragment file.
15+
|`-b` |`BR2_CONFIG_FILE` |Also use the given Buildroot configuration fragment file.
1616
Pass multiple times to use multiple fragment files.
17-
|`-C` | |Skip the Buildroot configuration. Saves a few seconds,
18-
but requires you to know what you are doing :-)
19-
|`-c` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example:
17+
|`-C` |`CONFIG_SOMETHING` |Also use the given Linux kernel configuration, example:
2018
`./build -c 'CONFIG_FORTIFY_SOURCE=y'`
2119
Can be used multiple times for multiple configs.
20+
These options take precedence over `-c`.
21+
|`-c` |`KERNEL_CONFIG_FILE` |Also use the given kernel configuration fragment file.
22+
Pass multiple times to use multiple fragment files.
23+
These options take precedence over `-K`.
24+
|`-f` | |Skip the Buildroot configuration. Saves a few seconds,
25+
but requires you to know what you are doing :-)
26+
Mnemonic: `fast`.
2227
|`-g` | |Enable gem5 build or force its rebuild.
2328
|`-h` | |Show this help message.
2429
|`-I` | |Enable initramfs for the current build.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_DRM=y
2+
CONFIG_DRM_HDLCD=y
3+
CONFIG_DRM_VIRT_ENCODER=y

0 commit comments

Comments
 (0)