You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+78-26Lines changed: 78 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ see this: https://askubuntu.com/questions/496549/error-you-must-put-some-source-
98
98
99
99
It does not work if you just download the `.zip` from GitHub because we use link:.gitmodules[Git submodules], you must clone this repo. `./configure` then fetches only the required submodules for you.
100
100
101
-
After QEMU opens up, you can start playing with the kernel modules:
101
+
QEMU opens up and you can start playing with the kernel modules inside the simulated system:
102
102
103
103
....
104
104
insmod /hello.ko
@@ -216,12 +216,18 @@ and then rebuild the kernel modules and re-run to see it take effect:
216
216
217
217
Congratulations, you are now officially a kernel module hacker!
218
218
219
-
We use `./build-buildroot` here because kernel modules go into the root filesystem, and it is Buildroot that generates our root filesystem. The kernel modules are inside a Buildroot package.
219
+
We use `./build-buildroot` because the kernel modules go inside the root filesystem, and it is Buildroot that generates and updates our root filesystem. The kernel modules are link:packages/kernel_modules[inside a Buildroot package].
220
220
221
-
`--kernel-modules` is required even if files were modified as explained at: <<rebuild-buildroot-packages>>.
221
+
`--kernel-modules` is required for the rebuild even though files were modified as explained at: <<rebuild-buildroot-packages>>.
222
222
223
223
The reboot after rebuild is annoying. We don't have a perfect solution for it yet, but there are some ideas cooking at: <<gem5-restore-new-script>>.
224
224
225
+
Using <<KVM>> can speed boot up however if your host and guest have the same arch, e.g. on an `x86_64` host:
226
+
227
+
....
228
+
./run --kvm
229
+
....
230
+
225
231
Not satisfied with kernel modules? OK then, let's hack up the <<linux-kernel-entry-point,entry point of the>> Linux kernel itself.
226
232
227
233
Open the file:
@@ -1405,7 +1411,11 @@ The number of cores is modified as explained at: <<number-of-cores>>
1405
1411
`taskset` from the util-linux package sets the initial core affinity of a program:
This is specially interesting because QEMU and gem5 are capable of generating DTBs that match the selected machine depending on dynamic command line parameters for some types of machines.
2413
2436
2414
-
QEMU's `-M virt` for example, which we use by default for `aarch64`, boots just fine without the `-dtb` option:
2437
+
So observing the device tree from the guest allows to easily see what the emulator has generated.
2438
+
2439
+
Compile the `dtc` tool into the root filesystem:
2440
+
2441
+
....
2442
+
./build-buildroot \
2443
+
--arch aarch64 \
2444
+
--buildroot-config 'BR2_PACKAGE_DTC=y' \
2445
+
--buildroot-config 'BR2_PACKAGE_DTC_PROGRAMS=y' \
2446
+
;
2447
+
....
2448
+
2449
+
`-M virt` for example, which we use by default for `aarch64`, boots just fine without the `-dtb` option:
2415
2450
2416
2451
....
2417
2452
./run --arch aarch64
@@ -5514,6 +5549,14 @@ Each `enable` under the `events/` tree enables a certain set of functions, the h
5514
5549
5515
5550
TODO: can you get function arguments? https://stackoverflow.com/questions/27608752/does-ftrace-allow-capture-of-system-call-arguments-to-the-linux-kernel-or-only
kprobes is an instrumentation mechanism that injects arbitrary code at a given address in a trap instruction, much like GDB. Oh, the good old kernel. :-)
@@ -7843,7 +7886,13 @@ OK, this is why we used gem5 in the first place, performance measurements!
7843
7886
7844
7887
Let's see how many cycles https://en.wikipedia.org/wiki/Dhrystone[Dhrystone], which Buildroot provides, takes for a few different input parameters.
@@ -9219,20 +9268,11 @@ First, see if you can't get away without actually adding a new package, for exam
9219
9268
* 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:packages/kernel_modules/user[] and you are done
9220
9269
* 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-configs>>
9221
9270
9222
-
If none of those methods are flexible enough for you, create a new package as follows:
9271
+
If none of those methods are flexible enough for you, you can just fork or hack up link:packages/sample_package[] the sample package to do what you want.
9223
9272
9224
-
* use link:packages/sample_package[] as a starting point
9225
-
* fork this repository, and modify that package to do what you want
9226
-
* read the comments on that package to get an idea of how to start
9227
-
* check the main manual for more complicated things: https://buildroot.org/downloads/manual/manual.html
9228
-
* don't forget to rebuild with:
9229
-
+
9230
-
....
9231
-
./build-buildroot -- sample_package-reconfigure
9232
-
./run --eval-busybox '/sample_package.out'
9233
-
....
9234
-
+
9235
-
if you make any changes to that package after the initial build: <<rebuild-buildroot-packages>>
9273
+
For how to use that package, see: <<packages-directory>>.
9274
+
9275
+
Then iterate trying to do what you want and reading the manual until it works: https://buildroot.org/downloads/manual/manual.html
9236
9276
9237
9277
=== BR2_TARGET_ROOTFS_EXT2_SIZE
9238
9278
@@ -9490,7 +9530,9 @@ xdg-open graph-size.pdf
9490
9530
9491
9531
Our philosophy is:
9492
9532
9493
-
* keep the root filesystem as tiny as possible to make prebuilts small. It is easy to add new packages once you have the toolchain.
9533
+
* keep the root filesystem as tiny as possible to make <<prebuilt>> small: only add BusyBox to have a small interactive system.
9534
+
+
9535
+
It is easy to add new packages once you have the toolchain, and if you don't there are infinitely many packages to cover and we can't cover them all.
9494
9536
* enable every feature possible on the toolchain (GCC, Binutils), because changes imply Buildroot rebuilds
9495
9537
* runtime is sacred. Faster systems are:
9496
9538
+
@@ -10041,10 +10083,20 @@ Every directory inside it is a Buildroot package.
10041
10083
Those packages get automatically added to Buildroot's `BR2_EXTERNAL`, so all you need to do is to turn them on during build, e.g.:
0 commit comments