Hello all,

I have an unusual and uncommon situation, and could use some help to get Yocto 
to do what I need.

I'm working on a legacy system which is being ported to use Yocto and Linux. 
The hardware architecture is complex, but the main detail to know is that the 
processor I'm running on boots entirely from RAM. A co-processor puts a FIT 
image into shared memory, which this processor uses to boot Linux and then 
decompress the initramfs, which is not an "initial" ramdisk but is actually the 
only rootfs it uses. Unfortunately, RAM is quite limited, and the image has 
become large enough that Linux runs out of space decompressing it.

The problem is that to decompress the rootfs, there has to be enough RAM for 
the compressed image, and the decompressed image, and working space for the 
decompressor. However, I figured out a workaround: I can have a minimal 
initramfs that contains just enough to boot plus the desired compressed rootfs. 
This way it only needs ~12MB free to decompress the outer rootfs. Once the 
kernel is done booting and has freed some memory used during boot, there's 
enough free memory that it can decompress the inner rootfs and pivot_root. It 
sounds a little crazy, but it does work.

This is easy enough to do manually:
* Create the inner rootfs as a .cpio.xz (or whatever)
* Create the outer rootfs, which is similar to core-image-minimal-initramfs.
* To the outer rootfs, manually add inner_rootfs.cpio.xz and a script to 
decompress it and pivot_root.

I can do that the evil way (by modifying the outer rootfs inside the 
build/tmp/work/ directory, which I know will confuse sstate) or in a nicer but 
still manual way (with a script run afterwards to decompress the outer rootfs, 
add the files, and recompress it... however, putting a bootable image back 
together involves several extra steps on this baroque system, more than just 
building a CPIO and FIT image).

The ideal way would be to put this into a recipe or class, and that's where I'm 
stuck. There doesn't seem to be a way to do it with just an image recipe; you 
can't simply RDEPEND on it, nor do image recipes generate package output that 
could be "installed" in another recipe. I was hoping that IMAGE_FSTYPES="live" 
might get me close, but alas that depends on Syslinux and is only for x86.

Has anyone seen something like this two-stage boot or nested images before? I 
searched around but couldn't find anything useful to my situation.

Assuming a class is the best way to do this, any suggestions on how to 
implement this? I'm pretty competent with ordinary recipes, but the code for 
generating images is a lot more opaque, and I'm having a hard time figuring out 
what will be required. (For instance, it's not even clear to me whether inner 
image should depend on outer image, or outer image should depend on inner 
image.)
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#49733): https://lists.yoctoproject.org/g/yocto/message/49733
Mute This Topic: https://lists.yoctoproject.org/mt/75073524/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to