Bug 7096

Summary: Document how to use initramfs features
Product: [Documentation] BSP Guide Reporter: Paul Eggleton <bluelightning>
Component: bsp-docsAssignee: California Sullivan <california.l.sullivan>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: andrea.adami, dvhart, its.muhammadosama, jason.wessel, randy.macleod, sgw, srifenbark
Version: 1.8   
Target Milestone: 2.3 M2   
Hardware: All   
OS: Multiple   
Whiteboard: 25 Jan 2017: RESOLVED
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Done (doc changes complete)

Description Paul Eggleton 2014-12-22 14:46:26 UTC
We have support for building initramfs images in our system, but how-to documentation for it is very sparse. The best we appear to have at the moment is entries in the variable reference for the variables involved, but these are pretty much impenetrable for new users. We get quite frequent questions on the mailing lists and IRC about how to use the functionality we have and there's currently nowhere in the documentation to point users.

Whether this should appear in the BSP Guide or the Development Manual or somewhere else I'm not sure, but we need somewhere that gives an overview of what we support and step-by-step instructions on how to use it. We need someone to provide the raw background info for this to Scott so he can write a new section for it.
Comment 1 Bruce Ashfield 2015-02-10 21:05:25 UTC
documentation only, so putting this in M4.
Comment 2 Scott Rifenbark 2015-06-01 21:59:55 UTC
Hi, 

Will work on this when I get raw information.

Scott
Comment 3 Scott Rifenbark 2016-07-29 21:58:16 UTC
BTW - Some updating has been done to the INITRAMFS_IMAGE (http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-INITRAMFS_IMAGE) and the INITRAMFS_FSTYPES (http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-INITRAMFS_FSTYPES) variables.  You should consider these in the solution as well. 

Thanks, 
Scott
Comment 4 Scott Rifenbark 2016-07-29 23:14:39 UTC
Oh.. also, the description for INITRAMFS_IMAGE_BUNDLE has been enhanced as well - http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-INITRAMFS_IMAGE_BUNDLE.

Scott
Comment 5 Scott Rifenbark 2016-11-03 20:48:52 UTC
Changing to NEEDINFO as I need some raw steps for procedures.

Scott
Comment 6 Andrea Adami 2016-12-06 08:55:15 UTC
I can add my 2 cents adding some little documentation about the old-way of embedding an initramfs in the kernel. Links to kernels 3.8 are now outdated.

https://github.com/kexecboot/kexecboot/wiki/oe-yocto


It appears there is only an hint in kernel.bbclass about this:

    # NOTE: setting INITRAMFS_TASK is for backward compatibility
    #       The preferred method is to set INITRAMFS_IMAGE, because
    #       this INITRAMFS_TASK has circular dependency problems
    #       if the initramfs requires kernel modules

If you think, you could expand a bit in the documentation.
Comment 7 Scott Rifenbark 2016-12-06 21:29:01 UTC
Thanks for the extra bit Andrea... I still need information to move forward on this issue. 

Scott
Comment 8 California Sullivan 2016-12-06 22:54:48 UTC
I have been playing with initramfs stuff for other work recently, and I have more to add that might be of use...

To build an initramfs, and bundle it into the kernel, use the following variables:

INITRAMFS_IMAGE_BUNDLE = "1"
INITRAMFS_IMAGE = "<name of image recipe>"

With the INITRAMFS_IMAGE_BUNDLE flag set, the initramfs created by the recipe defined by INITRAMFS_IMAGE is unpacked into the ${B}/usr/ directory. That is then passed to the kernel's make via the CONFIG_INTRAMFS_SOURCE option, allowing it to be built in to the kernel in the normal way.

The recipe that INITRAMFS_IMAGE points to must produce a .cpio.gz, .cpio.tar, .cpio.lz4, .cpio.lzma, or .cpio.xz file (I also saw a patch adding support for plain uncompressed .cpio files recently, but not sure if that's in core yet). This can be done by setting the IMAGE_FSTYPES variable to one or more of the above.

Adding things to the initramfs image (in its recipe) should be done via PACKAGE_INSTALL = rather than IMAGE_INSTALL. PACKAGE_INSTALL gives more direct control of what is added to the image, as image.bbclass and/or core-image.bbclass set defaults that you do not necessarily want.

I think I have a decent general understanding of it now, so if you have any specific questions please do ask.
Comment 9 Scott Rifenbark 2016-12-29 18:28:41 UTC
Hi, 

I looked at the example in the link in Comment 6.  It uses INITRAMFS_TASK, which is noted as having some circular issues.  So, I am not sure what to incorporate in the new section from that example.  I did put that "NOTE" you mentioned in the comment as a note in the new section on how to build an initramfs. 

Changes have been made:

 * The main new "how-to" section to create initramfs images - http://www.yoctoproject.org/docs/2.3/dev-manual/dev-manual.html#building-an-initramfs-image

 * Change to the kernel.bbclass description to include a cross-reference to the new "how-to" section in the dev-manual - http://www.yoctoproject.org/docs/2.3/ref-manual/ref-manual.html#ref-classes-kernel

Pretty much all the variables cross-referenced in the new "how-to" section now link back to the new section for explanation on how to build an initramfs.

Let me know if there are any changes or corrections needed.

thanks, 
Scott
Comment 10 Andrea Adami 2016-12-29 22:12:31 UTC
I think that note is enough. Thanks.

I'd add two observations:

!) "To build an initramfs image and bundle it into the kernel, set the following variables: "
It is not clear that you must set INITRAMFS_IMAGE_BUNDLE = "1" in local.conf while INITRAMFS_IMAGE = "image_recipe_name" cab ne set in machine.conf or in the image.


2) "you produce one of these .cpio.* files by setting the IMAGE_FSTYPES variable"
I think that the right var to use is INITRAMFS_FSTYPES
This one can be set in machine.conf or even in the image.

Cheers

Andrea
Comment 11 Scott Rifenbark 2017-01-02 21:45:34 UTC
Andrea, 

Thanks for the feedback.  See http://www.yoctoproject.org/docs/2.3/dev-manual/dev-manual.html#building-an-initramfs-image for the changes and let me know if there is anything else I need to fix. 

Scott
Comment 12 California Sullivan 2017-01-25 17:34:41 UTC
Looks good to me as well.
Comment 13 Scott Rifenbark 2017-01-25 17:47:32 UTC
Cal, 

I set the doc flag to "done" since you set the issue to RESOLVED.  Also, updated the Whiteboard.

Thanks,
Scott