Skip to contentSkip to conversation

Generating slightly different images for different IMAGE_FSTYPES

PATCH New Martin Jansa 4 participants 11 messages Feb 26, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

on om-gta01 we had problem that even our minimal image shr-lite-image is too big for its 64MB NAND chip

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Problem is that when we're booting on gta01, than /boot/uImage is used so it should be installed in .tar.gz image. But when booting from NAND, then kernel is usually in different NAND partition and /boot on rootfs partition is useless.

In patch is what I used now to generate images like this, but it's not optimal at all
1) It copies whole rootfs 3 times if you have all jffs2/ubi/ubifs in FSTYPES, instead just once for -no-boot version (it's possible ie if we expect certain order of making FSTYPES or prepare -no-boot always with normal rootfs and don't remove it
2) task-base still depends on kernel-image and I don't see how to easily remove that dependency, without defining different image recipe and building it separately. So with next kernel upgrade user will get new kernel-image which will probably fail to install because of lack of space.

Is there better way to solve it or should we try harder to save space somewhere else?

#1 lore raw

PATCH 1/1 om-gta01: remove /boot directory from jffs2/ubi/ubifs images

---
 conf/machine/om-gta01.conf |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
conf/machine/om-gta01.conf +5 -0
index ccd2b7a..578e90c 100644
@@ -57,6 +57,11 @@ ROOT_FLASH_SIZE = "60"
 
 IMAGE_FSTYPES += "tar.gz jffs2 ubi"
 
+# We don't want /boot directory in jffs2/ubi/ubifs images
+IMAGE_CMD_jffs2 = "cp -ra ${IMAGE_ROOTFS} ${IMAGE_ROOTFS}-no-boot && rm -rf ${IMAGE_ROOTFS}-no-boot/boot && mkfs.jffs2 -x lzo --root=${IMAGE_ROOTFS}-no-boot --faketime --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD} && rm -rf ${IMAGE_ROOTFS}-no-boot"
+IMAGE_CMD_ubi = "cp -ra ${IMAGE_ROOTFS} ${IMAGE_ROOTFS}-no-boot && rm -rf ${IMAGE_ROOTFS}-no-boot/boot && echo \[ubifs\] > ubinize.cfg ; echo mode=ubi >> ubinize.cfg ; echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg ; echo vol_id=0 >> ubinize.cfg ; echo vol_type=dynamic >> ubinize.cfg ; echo vol_name=${UBI_VOLNAME} >> ubinize.cfg ; echo vol_flags=autoresize >> ubinize.cfg;mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS} && ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${UBINIZE_ARGS} ubinize.cfg && rm -rf ${IMAGE_ROOTFS}-no-boot"
+IMAGE_CMD_ubifs = "cp -ra ${IMAGE_ROOTFS} ${IMAGE_ROOTFS}-no-boot && rm -rf ${IMAGE_ROOTFS}-no-boot/boot && mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.ubifs.img ${MKUBIFS_ARGS} && rm -rf ${IMAGE_ROOTFS}-no-boot"
+
 # extra jffs2 tweaks
 EXTRA_IMAGECMD_jffs2 = "--little-endian --eraseblock=0x20000 --pagesize=0x800 \
   --no-cleanmarkers --pad -n ; sumtool --eraseblock=0x20000 --no-cleanmarkers \
Signature · 1 line
1.7.0
#2 lore raw
In reply to Martin Jansa

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz
#3 lore raw
Quoted 8 lines · Marcin Juszkiewicz

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Quoted 8 lines

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"
Signature · 2 lines
Tom Rini <[email protected]>
Mentor Graphics Corporation
#4 lore raw
Quoted 18 lines · Tom Rini
Quoted 8 lines · Marcin Juszkiewicz

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Quoted 8 lines

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Quoted 5 lines

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"

This removes it from ALL FSTYPEs... not just jffs2/ubi/ubifs

Regards,

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#5 lore raw
Quoted 19 lines · Martin Jansa
Quoted 18 lines · Tom Rini
Quoted 16 lines · Marcin Juszkiewicz

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Quoted 7 lines
Quoted 5 lines

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"

This removes it from ALL FSTYPEs... not just jffs2/ubi/ubifs

I would strongly argue (especially after my last email) that you either always want a kernel in your rootfs, because it's actually booted from, or you never do and it's just wasting space (and just not critically so on other devices).

Signature · 2 lines
Tom Rini <[email protected]>
Mentor Graphics Corporation
#6 lore raw
Quoted 26 lines · Tom Rini
Quoted 25 lines · Martin Jansa
Quoted 23 lines · Tom Rini
Quoted 8 lines · Marcin Juszkiewicz

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Quoted 8 lines

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"
Quoted 6 lines
Quoted 1 line

This removes it from ALL FSTYPEs... not just jffs2/ubi/ubifs

I would strongly argue (especially after my last email) that you either always want a kernel in your rootfs, because it's actually booted from, or you never do and it's just wasting space (and just not critically so on other devices).

OK so more info:

Qi (alternative bootloader) usually used on om-gta02 (because it safer to reflash it there with u-boot still as fail-safe in NOR) looks for kernel on first partitions on uSD in /boot, then it loads kernel from specified (different than rootfs) partition in nand and pass right rootfs params. Qi doesn't read jffs2 (because nobody really needed it so much to implement it).

u-boot env shipped with device by default looks for kernel in nand and in menu is option to load kernel from first small fat32 partition on uSD and rootfs in second partition.

I know that I can change flash layout/u-boot env (and I would do it on my om-gta01 if I had one :)), but I'm trying to make smaller images without forcing gta users to mess with their bootloader/flash layout.

As I don't even have gta01 (gta02 has bigger flash), than I can say that I'll wait for someone else to do it, or someone can sort out which icons are not realy needed in image and remove them instead of unused kernel (which is as useless as not used icons but harder to remove).

Kind regards,

I really appreciate your comments/advise (if it looks different).

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#7 lore raw
In reply to Tom Rini
Quoted 18 lines · Tom Rini
Quoted 8 lines · Marcin Juszkiewicz

Dnia pi??tek, 26 lutego 2010 o 17:39:16 Martin Jansa napisa??(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Quoted 8 lines

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Quoted 5 lines

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"

This worked for me:

RDEPENDS_kernel-base = ""

As kernel.bbclass suggests the following:

# Allow machines to override this dependency if kernel image files are

# not wanted in images as standard
RDEPENDS_kernel-base ?= "kernel-image"
Signature · 1 line
Denys
#8 lore raw
Quoted 27 lines · Denys Dmytriyenko
Quoted 18 lines · Tom Rini
Quoted 8 lines · Marcin Juszkiewicz

Dnia pi??tek, 26 lutego 2010 o 17:39:16 Martin Jansa napisa??(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Quoted 8 lines

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Quoted 5 lines

Or (as there's a number of ways to do this):
PACKAGE_REMOVE = "kernel-image-*" ROOTFS_POSTPROCESS_COMMAND_om-gta01 += "opkg-cl ${IPKG_ARGS}

-force-depends \
                                remove ${PACKAGE_REMOVE};"

This worked for me:

Quoted 8 lines

RDEPENDS_kernel-base = ""

As kernel.bbclass suggests the following:

# Allow machines to override this dependency if kernel image files are

# not wanted in images as standard
RDEPENDS_kernel-base ?= "kernel-image"

That's also for ALL fstypes of that image.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Problem is that when we're booting on gta01, than /boot/uImage is used so it should be installed in .tar.gz image.

ahh I'm missing "booting from uSD on gta01".

So once more and hopefully better:

so with rootfs in NAND, kernel from different NAND partition is used (and is ignored in /boot on its jffs2/ubi/ubifs rootfs).

with rootfs on some uSD partition, then kernel is used from /boot/uImage on the same partition

User can choose which rootfs is booting with every reboot and I don't want to force every user to modify/reflash bootloader.

Regards,

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#9 lore raw
In reply to Marcin Juszkiewicz
Quoted 12 lines · Marcin Juszkiewicz

Dnia piątek, 26 lutego 2010 o 17:39:16 Martin Jansa napisał(a):

Quoted 5 lines

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Is there better way to solve it or should we try harder to save space
somewhere else?

Learn about ROOTFS_POSTPROCESS_COMMAND variable present in classes/rootfs_*.bbclass files. You can use it to launch your function after rootfs is populated.

Quoted 6 lines

So for example your shr-lite-image has drop_kernel_from_boot function in which you check "MACHINE==om-gta01" and if it is then "rm -rf /boot/uImage". After your function all normal ext2/ubifs/jffs2/tarball images will be created without kernel in them.

Regards,

with additional IRC chat about hrw's umbaumba-wonders :P moved to recipes/images/shr-image.inc in faster version (which moves only /boot)

# We don't want /boot directory in jffs2/ubi/ubifs images IMAGE_CMD_jffs2 = "
mv ${IMAGE_ROOTFS}/boot ${IMAGE_ROOTFS}-boot
&& mkfs.jffs2 ....
&& mv ${IMAGE_ROOTFS}-boot ${IMAGE_ROOTFS}/boot"

Any better idea?

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#10 lore raw
In reply to Martin Jansa
Quoted 13 lines · Martin Jansa

Hi,

on om-gta01 we had problem that even our minimal image shr-lite-image is too big for its 64MB NAND chip

We're slowly stripping packages not really needed, but it would be nice to remove whole /boot with kernel-image.

Problem is that when we're booting on gta01, than /boot/uImage is used so it should be installed in .tar.gz image. But when booting from NAND, then kernel is usually in different NAND partition and /boot on rootfs partition is useless.

Quoted 8 lines

In patch is what I used now to generate images like this, but it's not optimal at all
1) It copies whole rootfs 3 times if you have all jffs2/ubi/ubifs in FSTYPES, instead just once for -no-boot version (it's possible ie if we expect certain order of making FSTYPES or prepare -no-boot always with normal rootfs and don't remove it
2) task-base still depends on kernel-image and I don't see how to easily remove that dependency, without defining different image recipe and building it separately. So with next kernel upgrade user will get new kernel-image which will probably fail to install because of lack of space.

Here's one more thing you could try. Assuming U-Boot, apparently you can have it load a kernel from jffs2 or ubifs, so rework flash layout a little bit and load /boot/uImage.

Signature · 2 lines
Tom Rini <[email protected]>
Mentor Graphics Corporation