[oe] initramfs generation with OE

Paul Sokolovsky pmiscml at gmail.com
Sat Feb 16 11:17:23 UTC 2008


Hello,

On Fri, 15 Feb 2008 23:40:16 +0000
Richard Purdie <rpurdie at rpsys.net> wrote:

> Hi,
> 
> So if recursive bitbake isn't an option (its not), how do we generate
> an initramfs with OE? I've had a think about this and I have an idea.
> Its totally untested but its also neat and simple so here goes.
> 
> We don't actually care if we generate a normal kernel as a side effect
> and Pauls code already does this. Its even really close to whats
> needed, it just misses some task dependency magic. My untested
> solution would be:
> 
> """
> 
> INITRAMFS_SYMLINK_NAME ?= "initramfs-${MACHINE}"
> INITRAMFS_IMAGE_TARGET ?= "initramfs-image"
> 
> do_builtin_initramfs() {
>        unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
>        cp "${DEPLOY_DIR_IMAME}/${INITRAMFS_SYMLINK_NAME}"
> usr/initramfs_data.cpio.gz oe_runmake ${KERNEL_IMAGETYPE}
> CC="${KERNEL_CC}" LD="${KERNEL_LD}" install -d ${DEPLOY_DIR_IMAGE}
>        install -m 0644 ${KERNEL_OUTPUT}
> ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}-initramfs.bin # Make
> sure to kill injected initramfs, in case someone will do "-c compile
> -f" rm usr/initramfs_data.cpio.gz }
> addtask builtin_initramfs after do_deploy before do_build
> do_builtin_initramfs[nostamp] = "1"
> do_builtin_initramfs[depends] = "${INITRAMFS_IMAGE_TARGET}:do_rootfs"
> 
> """
> 
> of which the last line is the magic key. From that, bitbake should be
> able to handle the rest. 

What would be really needed is:

do_builtin_initramfs[depends] = "${INITRAMFS_IMAGE_TARGET}:do_rootfs
(MACHINE=${INITRAMFS_MACHINE} SYSTYPE=${INITRAMFS_SYSTYPE} ...)"

Where stuff in braces after dependent task specification means: run
the task specified and all its subtasks with environment modified with
those settings (environment is restored after the task finishes).
Without that, it doesn't solve directly my usecase (need to build uclibc
initramfs for glibc-built kernel). My recursive bitbake invocation is
exactly attempt to emulate that at the OS level (and thanks to Unix
nature, where process recursion is first-class phenomena, the attempt
is very successful I would add, as it even works, even though bitbake
was not designed for such use ;-) ).

Well, back to pragmatics, there's of course no difference with
glibc-built kernel and uclibc-built kernel (and its kind of
inefficiency the same kernel is built twice). So, supposedly that can
be worked around with building just uclibc-kernel and then shuffling
deploy dirs.

> In addition to this you need to add something
> to initramfs-image that:
> 
> * symlinks from ${DEPLOY_DIR_IMAME}/${INITRAMFS_SYMLINK_NAME} to the
> initramfs image
> * makes sure IMAGE_FSTYPES has cpio.gz in it
> 
> Also note that task should move to a separate .bbclass since it is now
> added before do_build and not everything will want to build this.
> Alternatively, we can drop the "before do_build" bit and mean users
> manually run:
> 
> bitbake kernel -c builtin_initramfs
> 
> Anyhow, this is something we can discuss and find a way forward with
> if the basic idea works.

The most interesting thing with all this is package writing. That's
what took me lot of time to make it work, and still only "somehow".

[]

> 
> Cheers,
> 
> Richard
> 
> 



-- 
Best regards,
 Paul                          mailto:pmiscml at gmail.com




More information about the Openembedded-devel mailing list