incaseoftrouble
Posts: 4
Joined: Fri Feb 19, 2016 10:05 am

Raspberry Pi 2 Custom Kernel with initramfs

Fri Feb 19, 2016 10:17 am

I'm desperately trying to get a self-compiled kernel running together with an initramfs. It worked on the old raspberry, but somehow I can't get it to run.

What I'm trying to do exactly: Load kernel, "run" initramfs with a busybox and some other tools, performing some checks (system-update etc.), mounting a squashfs image with the "real" system and invoking switch_root on said system.

But the kernel somehow refuses to run the initramfs' init. I tried various settings in cmdline.txt / config.txt but none of them seem to work, the kernel always waits for some root to be available (or fails with "VFS: unable to mount root fs on unknown block" depending on my setting of the root= flag). I assume that I'm missing some cmdline setting (probably a correct root=.... root=/dev/ram0 for example did not work) or a kernel flag. My current cmdline: dwc_otg.lpm_enable=0 console=tty1 elevator=deadline rootwait, config.txt: initramfs initramfs.gz followkernel. When I add root=/dev/mmcblk0p6 roottype=ext4 the whole system boots (into some test-linux I added to verify the kernel itself works).

I checked that the kernel is compiled with initramfs support (BLK_DEV_INITRD=y), compiling the initramfs into the kernel image is not an option sadly. The kernel (4.1 stable) is compiled using buildroot. Kernel binary format is zImage (seems not to work with vmlinux, screen stays black). The initramfs is created with find . -print0 | cpio --null --create --format=newc | gzip --rsyncable -9 > initramfs.gz.

Thanks for any input.

PS: FYI, I'm duplicating my unix.stackexchange post, as nobody seems to have an answer there. I hope that is ok.

User avatar
rpdom
Posts: 12745
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Raspberry Pi 2 Custom Kernel with initramfs

Fri Feb 19, 2016 1:50 pm

Did you add the right options in to /boot/config.txt?

incaseoftrouble
Posts: 4
Joined: Fri Feb 19, 2016 10:05 am

Re: Raspberry Pi 2 Custom Kernel with initramfs

Sun Feb 21, 2016 9:35 am

Hi,

sorry for the late response, forgot to turn on email notifications.

I mentioned it in my OP, but I guess it's pretty easy to overlook (is there a "monospaced font" tag?). My config.txt looks like this:

Code: Select all

initramfs initramfs.gz followkernel
Nothing more. I'm not sure if this is correct, but it worked with the old raspberry / kernel (3.12.26).

For completeness' sake, my cmdline:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 elevator=deadline rootwait
I also tried integrating the initramfs directly into the kernel, which worked (sort of). Albeit echos and similar where not printed (i.e. screen stayed black), init definitely was executed.

incaseoftrouble
Posts: 4
Joined: Fri Feb 19, 2016 10:05 am

Re: Raspberry Pi 2 Custom Kernel with initramfs

Sun Feb 21, 2016 3:24 pm

Okay so I started from scratch and after hours of trial-and-error I got to the source(s) of my problem, which basically were just some stupid mistakes: 1) My build script generated the initramfs with absolute paths (i.e. not, for example, lib/libc.so but rather ~/Work/project/target/lib/libc.so), which obviously causes the kernel to not find the inital init 2) Embedded initramfs apparently is behaving slighlty different compared to an external one, namely that echo commands and suchlike in the init script don't get printed. When tinkering around with an external initramfs I forgot to remove the embedded one, resulting in the external init (and only that one) being executed, but not printing anything :roll: .

cosmicboy
Posts: 17
Joined: Mon Sep 03, 2012 9:25 am

Re: Raspberry Pi 2 Custom Kernel with initramfs

Thu Apr 26, 2018 2:49 pm

could you explain how the boot-parameters have to be set with an internal (compiled into the kernel) initramfs?
I am trying since hours and don't seem to get which cmdline options need to be set...

Thanks for any hint!

incaseoftrouble
Posts: 4
Joined: Fri Feb 19, 2016 10:05 am

Re: Raspberry Pi 2 Custom Kernel with initramfs

Thu Apr 26, 2018 8:18 pm

Sorry I don't recall anything from that anymore. My current setup is working with an external initramfs. If I remember correctly, I never actually got the internal thing to properly work at all. But again, this is years ago, probably things have changed.

What exactly do you mean by boot parameters? The cmdline and config.txt can be found above. Apart from that, there are only kernel compilation settings, right?

Return to “Linux Kernel”

Who is online

Users browsing this forum: No registered users and 1 guest