💾 Archived View for callistix.srht.site › projects › minimal_rpi › pages › 008_kernelsecondpass.gmi captured on 2024-03-21 at 15:12:24. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
We've ended up with a kernel with 645 enabled configuration options and a size of 3.4M.
The `/dev` filesystem contains 44 records, including directories.
The boot time from power on to `getty` prompt is now about 7 seconds.
It is likely that some of the configuration options I disabled "unlocked" other options, which could not be disabled at the first pass. Once again I will go through the remaining options to see what else I can disable.
I would also like to understand what the purpose of each device in the `/dev` filesystem actually is, to see if we need them all.
The kernel is currently stored twice, in `/boot` and again in `/boot/firmware`. I've removed it from the former and moved the `config` and `System.map` files to `/boot/firmware`, as I still want to keep them. Symlinks in root pointing at the kernel don't seem to be needed either. I've adjusted my `kernel_install` script accordingly.
Now that I'm cleaning up `/boot` I've also removed all unneeded files from `/boot/firmware` including the `bootcode.bin`, which is not used by the RPi 4. I've also removed all alternative `fixup`, `start`, and `dtb` files and left only the essential files. `/boot/firmware` now looks like this:
I also uncompressed `vmlinuz-callistix` like this:
mv vmlinuz-callistix vmlinuz-callistix.gz gunzip -c vmlinuz-callistix.gz >vmlinux-callistix rm vmlinuz-callistix.gz
The `kernel` option in `config.txt` needs to be adjusted accordingly, the file now only contains this:
kernel=vmlinux-callistix
Again, I've adjusted my `kernel_install` script to do all that automatically.
`/boot/firmware` now contains the following files:
System.map-callistix bcm2711-rpi-4-b.dtb config-callistix config.txt fixup4.dat start4.elf vmlinux-callistix
The directory is pretty small now and occupies only 11M, I will reduce the size of the partition later on.
The external USB harddisk is sometimes not mounted, but other than delaying the boot for some seconds there seems to be no easy workaround. I'll leave that aside for a moment, maybe we can solve that later with `autofs`, or some `cron` script. We'll see.
For now I'm using a very minimal kernel parameter string:
root=/dev/mmcblk0p2 rootwait
To further tweak this, I will refer to the official kernel admin guide. [1].
I've disabled a few more checkboxes here and there and we're now at 627 enabled configuration options and a uncompressed kernel size of 6.6M.
The `/boot` partition's usage is 10M and the `/dev` filesystem still contains 44 records, including directories. The boot time is around 6.5s.
There are a few errors in `dmesg` that I want to address before moving on, I'll walk through them one by one.
[ 0.006686] OF: /soc/cprman@7e101000: could not find phandle 4 [...] [ 0.633447] OF: /soc/cprman@7e101000: could not find phandle 4
A grep through the kernel sources reveals following documentation:
./Documentation/devicetree/bindings/clock/brcm,bcm2835-cprman.txt ./Documentation/devicetree/bindings/clock/brcm,bcm2835-aux-clock.txt
Although it's not immediately obvious to me what the error is exactly about. `CLK_BCM2835` is enabled in the kernel, but maybe I forgot something else? A search for `2835` with `/` key in `make menuconfig` reveals a whole plethora of configuration options that I left disabled.
In the end this error went away when enabling `sysfs` in the kernel.
[ 0.143362] pci_bus 0000:01: supply vpcie3v3 not found, using dummy regulator [ 0.143417] pci_bus 0000:01: supply vpcie3v3aux not found, using dummy regulator [ 0.143451] pci_bus 0000:01: supply vpcie12v not found, using dummy regulator
Reading through a patch notice [2] it seems that a dummy regulator is provided to prevent related syscalls from failing.
There is actually a Broadcom regulator in `drivers/regulator` called `bcm590xx-regulator.c`, but it's not showing up in `make menuconfig`, so there might be a dependency missing, although I'm not sure if I actually need to enable that regulator. I think I need to read a bit more about how regulators work, in particular on the RPi 4.
[ 0.257067] bcm2708_fb soc:fb: FB found 1 display(s) [ 0.269073] ------------[ cut here ]------------ [ 0.269096] WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5543 __alloc_pages+0x108/0x9a0 [ 0.269147] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.72-v8-callistix+ #163 [ 0.269174] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT) [ 0.269195] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.269221] pc : __alloc_pages+0x108/0x9a0 [ 0.269252] lr : __dma_direct_alloc_pages.constprop.0+0x60/0x150 [ 0.269287] sp : ffffff8000cf7890 [ 0.269305] x29: ffffff8000cf7890 x28: 0000000000000000 x27: ffffff8000c39300 [ 0.269341] x26: ffffff8000c9e120 x25: 0000000000000000 x24: ffffffc00807ea8c [ 0.269374] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000000000 [ 0.269405] x20: 000000000000000b x19: 00000000000006d8 x18: ffffffffffffffff [ 0.269436] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 0.269465] x14: 000000000000000c x13: 0000000000000000 x12: 0000000000000001 [ 0.269495] x11: ffffffc008005000 x10: 0000000000000040 x9 : ffffff8000cf77d0 [ 0.269526] x8 : 0000000000000000 x7 : 0000000000000cc0 x6 : 0000000000000018 [ 0.269556] x5 : 000000003fffffff x4 : 0000000040000000 x3 : 0000000000000000 [ 0.269587] x2 : 0000000000000000 x1 : 0000000000000001 x0 : ffffffc008687000 [ 0.269618] Call trace: [ 0.269635] __alloc_pages+0x108/0x9a0 [ 0.269666] __dma_direct_alloc_pages.constprop.0+0x60/0x150 [ 0.269696] dma_direct_alloc+0xd8/0x310 [ 0.269723] dma_alloc_attrs+0x78/0x9c [ 0.269749] bcm2708_fb_set_par+0xf0/0x310 [ 0.269778] bcm2708_fb_probe+0x3a0/0x4d0 [ 0.269805] platform_probe+0x64/0xbc [ 0.269835] really_probe+0xc4/0x290 [ 0.269859] __driver_probe_device+0x74/0x110 [ 0.269885] driver_probe_device+0x40/0x114 [ 0.269910] __driver_attach+0xe0/0x1bc [ 0.269934] bus_for_each_dev+0x5c/0x94 [ 0.269957] driver_attach+0x20/0x2c [ 0.269981] bus_add_driver+0x13c/0x1f0 [ 0.270004] driver_register+0x74/0xec [ 0.270030] __platform_driver_register+0x24/0x2c [ 0.270060] bcm2708_fb_init+0x18/0x20 [ 0.270090] do_one_initcall+0x58/0x120 [ 0.270120] kernel_init_freeable+0x1a4/0x1fc [ 0.270150] kernel_init+0x20/0x120 [ 0.270180] ret_from_fork+0x10/0x20 [ 0.270204] ---[ end trace 0000000000000000 ]--- [ 0.296341] Console: switching to colour frame buffer device 228x61
[ 0.637613] ------------[ cut here ]------------ [ 0.639374] clk_core_populate_parent_map: invalid NULL in dsi0p's .parent_names [ 0.641213] WARNING: CPU: 3 PID: 42 at drivers/clk/clk.c:4016 __clk_register+0x2c4/0x7f4 [ 0.643053] CPU: 3 PID: 42 Comm: kworker/u8:2 Tainted: G W 6.1.72-v8-callistix+ #163 [ 0.644875] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT) [ 0.646720] Workqueue: events_unbound deferred_probe_work_func [ 0.648600] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.650492] pc : __clk_register+0x2c4/0x7f4 [ 0.652390] lr : __clk_register+0x2c4/0x7f4 [ 0.654274] sp : ffffff800159b970 [ 0.656147] x29: ffffff800159b970 x28: ffffff800159baa0 x27: 0000000000000000 [ 0.658072] x26: 0000000000000100 x25: ffffff80017d2200 x24: ffffff80017d2340 [ 0.659998] x23: ffffffc0085d9c48 x22: 000000000000000a x21: ffffff8000e6b480 [ 0.661898] x20: 0000000000000008 x19: ffffff8000e6b600 x18: 0000000000000000 [ 0.663839] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000020 [ 0.665789] x14: 0000000000000000 x13: ffffff80fbf77bc0 x12: 000000000000024f [ 0.667736] x11: 00000000000000c5 x10: ffffff80fbf82bc0 x9 : ffffff80fbf77bc0 [ 0.669673] x8 : 00000000fffffdff x7 : ffffff80fbf82bc0 x6 : 80000000fffffe00 [ 0.671629] x5 : 00000000fffffdff x4 : 0000000000000000 x3 : 0000000000000001 [ 0.673590] x2 : ffffffc008661548 x1 : ffffffc008661548 x0 : 0000000000000043 [ 0.675562] Call trace: [ 0.677495] __clk_register+0x2c4/0x7f4 [ 0.679430] devm_clk_hw_register+0x58/0xcc [ 0.681399] bcm2835_register_clock+0x120/0x194 [ 0.683358] bcm2835_clk_probe+0x17c/0x280 [ 0.685296] platform_probe+0x64/0xbc [ 0.687208] really_probe+0xc4/0x290 [ 0.689098] __driver_probe_device+0x74/0x110 [ 0.690985] driver_probe_device+0x40/0x114 [ 0.692854] __device_attach_driver+0xcc/0x154 [ 0.694705] bus_for_each_drv+0x64/0xa0 [ 0.696536] __device_attach+0x98/0x154 [ 0.698380] device_initial_probe+0x10/0x20 [ 0.700206] bus_probe_device+0x94/0x9c [ 0.702029] deferred_probe_work_func+0x80/0xb4 [ 0.703826] process_one_work+0x1f4/0x370 [ 0.705610] worker_thread+0x268/0x4b0 [ 0.707396] kthread+0xc4/0xcc [ 0.709156] ret_from_fork+0x10/0x20 [ 0.710897] ---[ end trace 0000000000000000 ]--- [ 0.749767] bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
This error was gone once `sysfs` was compiled into the kernel.
[ 2.273743] hid-generic 0003:1038:161A.0004: device has no listeners, quitting
At this point I'm compiling the `/sys` filesystem back in to the kernel, as it would be useful for debugging, i.e. `lsusb` doesn't work without it. (File systems -> Pseudo filesystems -> sysfs file system support)
`dmesg` and `lsusb` show that `0003:1038:161A` is my SteelSeries Apex 3 keyboard with four interface descriptors:
0001 input: USB HID v1.11 Keyboard (Boot Interface Subclass) 0002 input: USB HID v1.11 Keyboard 0003 input: USB HID v1.11 Mouse 0004 device has no listeners, quitting
[ 2.276894] /dev/sda1: Can't open blockdev [ 2.379075] sda: sda1 [ 2.381915] sd 0:0:0:0: [sda] Attached SCSI disk [ 2.473081] usb 1-1.1.2: new full-speed USB device number 5 using xhci_hcd
This might be related to the USB mechanical harddisk not spinning up in time to be mounted during the first seconds of the boot process.
[1] The kernel's command-line parameters
[2] [PATCH] regulator: Provide optional dummy regulator for consumers
⬅ 7. Reducing the kernel further #2
➡ 9. Using the new kernel with an empty SD card
⬆ The minimal Raspberry 4 project
Created: 5/Feb/2024
Modified: 9/Feb/2024