[oe] initramfs howto?

Tom Rini trini at kernel.crashing.org
Fri Apr 17 18:39:27 UTC 2009


On Fri, Apr 17, 2009 at 06:18:19PM +0200, Sledz, Steffen wrote:

> We want to use a little initramfs for our machine (hipox
> with linux-2.6.24) to load some modules. I've found some
> samples (e.g. initramfs-image.bb). But the usage is totally
> unclear to me.

I don't think that out of the box, "load some modules" can work.  The
current initramfs stuff, if I read it right, makes use of a premade
cpio.  It should however, be possible to fix this up, with the hardest
part being fixing up of the dev nodes.  What follows is a hack I've done
to a specific kernel's do_compile:

# We need to make an initramfs.  First step, extract the
# initramfs
# contents, minus modules.
mkdir -p rootfs/dev
fakeroot tar -C rootfs -xf ${DEPLOY_DIR_IMAGE}/myinitramfs.tar

# Second, build first kernel and modules.
oe_runmake ${KERNEL_IMAGETYPE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}"

# Third, install modules
oe_runmake DEPMOD=`which ${TARGET_PREFIX}depmod-2.6` \
  INSTALL_MOD_PATH="rootfs" modules_install

# Fourth, make the cpio list AND add in /dev/null and
# /dev/console
sh ./scripts/gen_initramfs_list.sh rootfs > rootfs.list
echo "nod /dev/console 0600 0 0 c 5 1" >> rootfs.list
echo "nod /dev/null 0666 0 0 c 1 3" >> rootfs.list

# Fifth, build a kernel with the full initramfs.
sed -i -e 's|\(CONFIG_INITRAMFS_SOURCE\)=""|\1="rootfs.list"|g' .config
echo "CONFIG_INITRAMFS_ROOT_UID=`id -u`" >> .config
echo "CONFIG_INITRAMFS_ROOT_GID=`id -g`" >> .config
oe_runmake ${KERNEL_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"

And I also put in:
# For our initramfs.  It must exist and if we clean this, we should
# clean that.
do_compile[depends] += "myinitramfs-image:do_rootfs"
do_clean[depends] += "myinitramfs-image:do_clean"

This should somehow be generalized a bit and put into kernel.bbclass,
quite probably.

-- 
Tom Rini




More information about the Openembedded-devel mailing list