On 10/01/2011 09:46 AM, Stuart Hughes wrote:
>
> Hi Jurgen,
>
> Thanks for the patch.  I'll try to get that in as time permits.
>
> Please send your UBU and I'll try to get that in too.
>
In attach 2 cvs unified diffs and a new file.
This adds UBI support.
Mark: you need a recent mtd-utils on your PC (=host)! I compiled it 
myself: v1.4.6.
And also the mtd-utils on the target be recent if you want to run ubi 
commands in linux, e.g. ubiupdatevol!
So I first cross-compiled mtd-utils 1.4.6 (already mailed it), but now I 
just use the mtd-utils tools inside busybox. It does not have ubinfo, 
but the necessary tools are there and work.

Enjoy,
Jürgen
>
>
> Please post your imx27pdk, maybe someone else on the list would have
> time to clean it up and re-submit it.  Even if not, it could be helpful
> to others.
>
> Regards, Stuart
>
[snip]

-- 
Jürgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk

Index: config/userspace/deployment.lkc
===================================================================
RCS file: /sources/ltib/ltib/config/userspace/deployment.lkc,v
retrieving revision 1.6
diff -U 3 -r1.6 deployment.lkc
--- config/userspace/deployment.lkc	28 Dec 2009 11:00:18 -0000	1.6
+++ config/userspace/deployment.lkc	3 Oct 2011 13:10:27 -0000
@@ -20,6 +20,28 @@
         help
             build a yaffs2 flash filesystem image
 
+    config DEPLOYMENT_UBIFS
+        bool "ubifs"
+        help
+            build a ubi flash filesystem image
+            Apart from the options below, also the /bin/ubifs_ubinize_tmpl.ini
+            file is used to create a partition with 1 rootfs volume
+            (http://www.linux-mtd.infradead.org/faq/ubi.html#L_ubi_mkimg):
+            * image: name of the image file; automatically filled in
+            * vol_size: volume size : for fixed size; or NA with autoresize
+              flag, so left away here (if absent, the volume size is assumed to
+              be equivalent to the size of the image file).
+            * vol_type: 'dynamic' for RW and 'static' for RO
+            * vol_name: name used during mounting, so must match the name given
+              by the bootloader to the kernel!
+            * vol_alignment: put to 1; this is only useful, for example, when
+              one wants to maintain a block device on top of an UBI volume. In
+              this case, it is desirable to fit an integer number of blocks in
+              logical eraseblocks of this UBI volume.
+            * vol_flags: autoresize flag: then autoresize if you want to use
+              all available LEBs (because some PEBs are bad, it is not possible
+              to know in forehand what the maximum available LEBs are)
+
     config DEPLOYMENT_RAMDISK
         bool "ext2.gz ramdisk"
         help
@@ -56,6 +78,7 @@
 
 if CAP_DEPLOYMENT_ELF && (DEPLOYMENT_JFFS2 \
                       || DEPLOYMENT_YAFFS2 \
+                      || DEPLOYMENT_UBIFS \
                       || DEPLOYMENT_RAMDISK)
 config DEPLOYMENT_ELF
        bool "Create a combined ELF image"
@@ -75,6 +98,7 @@
     string
     default JFFS2      if DEPLOYMENT_JFFS2
     default YAFFS2     if DEPLOYMENT_YAFFS2
+    default UBIFS      if DEPLOYMENT_UBIFS
     default RAMDISK    if DEPLOYMENT_RAMDISK
     default CRAMFS     if DEPLOYMENT_CRAMFS
     default ROMFS      if DEPLOYMENT_ROMFS 
@@ -107,6 +131,96 @@
 endif
 
 
+if DEPLOYMENT_UBIFS
+
+config DEPLOYMENT_MIN_I0_UNIT_SIZE
+    string  "ubifs minimum I/O unit size"
+    default 2048
+    help
+        This set the UBIFS minimum I/O unit size in Byte.
+        Is usually 1B for NOR flashes, and agrees with the page size of NAND
+        flashes (without spare). 
+        See http://www.linux-mtd.infradead.org/doc/ubi.html#L_min_io_unit
+
+config DEPLOYMENT_SUB_PAGE_SIZE
+    string  "ubifs sub-page size"
+    default 512
+    help
+        This set the UBIFS sub-page size in Byte - only for NAND flash.
+        In practice, this is the minimum unit size for ECC calculation. See
+        http://www.linux-mtd.infradead.org/doc/ubi.html#L_subpage.
+        Easiest way to discover this (and all) parameter is to run linux on
+        your board (from NFS or JFFS2), keep a spare partition in flash, and do
+        'ubiformat' and 'ubiattach'; the latter will show all parameters.
+
+config DEPLOYMENT_PEB_SIZE
+    string "ubifs physical erase block (PEB) size"
+    default 128KiB
+    help
+        This sets the UBIFS Physical erase block (PEB) size of your Chip.
+        Is your Chip (erase) "block size" without spare (spare area is reserved
+        by UBI for ECC data). Size might be specified kilobytes (KiB),
+        megabytes (MiB), gigabytes (GiB) or bytes (no modifier).
+
+config DEPLOYMENT_LEB_SIZE
+    string  "ubifs logical erase block (LEB) size in Bytes"
+    default 126KiB
+    help
+        This set the UBIFS Logical Erase Block (LEB) size in bytes. This has to
+        be smaller than the PEB size because of the UBI EC and VID headers (see
+        http://www.linux-mtd.infradead.org/doc/ubi.html#L_overhead): 2 pages if
+        the flash has no sub-pages, else 1 page (nand page = minimum I/O unit).
+
+config DEPLOYMENT_MAX_LEB_COUNT
+    string  "ubifs maximum logical erase block (LEB) count"
+    default 4096
+    help
+        This set maximum LEB count, the logical maximum size of the image =
+        (LEB_COUNT * LEB_SIZE). This is the maximum volume size you want to
+        support for this image to be put on. Don't exagerate, because it will
+        cost performance.        
+        See http://www.linux-mtd.infradead.org/faq/ubifs.html#L_max_leb_cnt.
+
+choice
+    prompt "ubifs compression type"
+    default DEPLOYMENT_UBIFS_NONE
+    help
+        Default UBIFS build without compression.
+
+    config DEPLOYMENT_UBIFS_NONE
+        bool "no compression"
+        help
+            Choose to build ubifs image without compression.
+
+    config DEPLOYMENT_UBIFS_LZO
+        bool "LZO compression"
+        help
+            choose lzo compression ubifs image, lzo compressor is
+            generally faster than zlib but compresses worse.
+
+    config DEPLOYMENT_UBIFS_FAVOR_LZO
+        bool "try both compressions"
+        help
+            It is a method of combining "lzo" and "zlib" compressors. Namely,
+            mkfs.ubifs tries to compress data with both "lzo" and "zlib"
+            compressors, then it compares which compressor is better. 
+
+    config DEPLOYMENT_UBIFS_ZLIB
+        bool "zlib compression"
+        help
+            zlib compresses better than LZO but it is slower.
+
+endchoice
+
+config DEPLOYMENT_UBIFS_COMPR_TYPE
+    string
+    default none      if DEPLOYMENT_UBIFS_NONE
+    default lzo       if DEPLOYMENT_UBIFS_LZO
+    default favor_lzo if DEPLOYMENT_UBIFS_FAVOR_LZO
+    default zlib      if DEPLOYMENT_UBIFS_ZLIB
+
+endif
+
 config DEPLOYMENT_ZIP
     depends DEPLOYMENT_ROMFS
     bool "Create a compressed image of the kernel/romfs image"
@@ -136,7 +250,7 @@
     default n
 
 config SYSCFG_TMPFS_SIZE
-    depends SYSCFG_READONLY_FS || DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2
+    depends SYSCFG_READONLY_FS || DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2 || DEPLOYMENT_UBIFS
     string "tmpfs size"
     default "512k"
     help
@@ -147,16 +261,16 @@
        from the total available RAM to the system.
 
 config SYSCFG_RAM_DIRS
-    depends SYSCFG_READONLY_FS || DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2
+    depends SYSCFG_READONLY_FS || DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2 || DEPLOYMENT_UBIFS
     string "Place these dirs in writable RAM"
     default "/tmp /etc /var" if SYSCFG_READONLY_FS
-    default "/tmp /var"      if DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2
+    default "/tmp /var"      if DEPLOYMENT_JFFS2 || DEPLOYMENT_YAFFS2 || DEPLOYMENT_UBIFS
     help
        Flash may only be erased a finite number of times (of the order
-       of 100000 times for a NOR device).  If you deploy to Flash,
-       frequently written files should be written to RAM to avoid
-       exhausting Flash.  List here a space separated list of directories
-       to be put in tmpfs (RAM).  Changes to these directories will 
+       of 100000 times for a NOR device and a NAND device with good ECC).
+       If you deploy to Flash, frequently written files should be written to
+       RAM to avoid exhausting Flash.  List here a space separated list of
+       directories to be put in tmpfs (RAM).  Changes to these directories will
        be lost on reboot.  You may also want to use this option if
        you choose to deploy a read-only root filesystem.  Note that
        if you have chosen a read-only root filesystem, the default
Index: bin/Ltibutils.pm
===================================================================
RCS file: /sources/ltib/ltib/bin/Ltibutils.pm,v
retrieving revision 1.38
diff -U 3 -r1.38 Ltibutils.pm
--- bin/Ltibutils.pm	7 Aug 2011 15:05:53 -0000	1.38
+++ bin/Ltibutils.pm	3 Oct 2011 13:05:38 -0000
@@ -697,6 +688,10 @@
 then
     rm -f $tdir/rootfs.yaffs2
 fi
+if [ "$pcf->{DEPLOYMENT_UBIFS}" = "y" ]
+then
+    rm -f $tdir/rootfs.ubifs.img
+fi
 if [ "$pcf->{DEPLOYMENT_CRAMFS}" = "y" ]
 then
     rm -f $tdir/cramfs.*
@@ -856,6 +851,9 @@
     # genext2fs seems to use 1k block size
     my $blocks = $fs_size;
     my $inodes = $fs_count + 400;
+    my $ubinize_config_tmpl = "bin/ubifs_ubinize_tmpl.ini";
+    my $ubinize_config_file = "$tdir/ubinize.ini";
+    my $ubinize_image_location_str = "UBI_IMAGE_LOCATION";
 
     # try to sanely guess the endian of the target
     my $endian = '-l';
@@ -890,6 +888,7 @@
 fi
 if [ "$pcf->{DEPLOYMENT_JFFS2}" = "y" ]
 then
+    echo "creating jffs2 image: $tdir/rootfs.jffs2"
     mkfs.jffs2 -n $pad_opt -D $dev_tab -U $endian -e $pcf->{DEPLOYMENT_ERASE_BLOCK_SIZE} -d $stage -o $tdir/rootfs.jffs2
     ln -sf $tdir/rootfs.jffs2 $tdir/rootfs_image
 fi
@@ -898,6 +897,25 @@
     mkfs.yaffs2 -r -p $stage/etc/passwd -N -D $dev_tab $endian $stage $tdir/rootfs.yaffs2
     ln -sf $tdir/rootfs.yaffs2 $tdir/rootfs_image
 fi
+if [ "$pcf->{DEPLOYMENT_UBIFS}" = "y" ]
+then
+    echo "creating ubifs image: $tdir/rootfs.ubifs.img"
+    mkfs.ubifs -U -D $dev_tab -d $stage -o $tdir/rootfs.ubifs \\
+        -m $pcf->{DEPLOYMENT_MIN_I0_UNIT_SIZE} \\
+        -e $pcf->{DEPLOYMENT_LEB_SIZE} \\
+        -c $pcf->{DEPLOYMENT_MAX_LEB_COUNT} \\
+        -x $pcf->{DEPLOYMENT_UBIFS_COMPR_TYPE}
+    # genrate the ini file from .tmpl file.
+    sed -e 's:$ubinize_image_location_str:$tdir/rootfs.ubifs:g' \\
+        $ubinize_config_tmpl > $ubinize_config_file
+    ubinize -o $tdir/rootfs.ubifs.img \\
+        -m $pcf->{DEPLOYMENT_MIN_I0_UNIT_SIZE} \\
+        -s $pcf->{DEPLOYMENT_SUB_PAGE_SIZE} \\
+        -p $pcf->{DEPLOYMENT_PEB_SIZE} $ubinize_config_file
+    rm $ubinize_config_file
+    rm $tdir/rootfs.ubifs
+    ln -sf $tdir/rootfs.ubifs.img $tdir/rootfs_image
+fi
 if [ "$pcf->{DEPLOYMENT_CRAMFS}" = "y" ]
 then
     mkfs.cramfs -q -D $dev_tab $endian $stage $tdir/rootfs.cramfs
[rootfs]
mode=ubi
image=UBI_IMAGE_LOCATION
vol_id=0
vol_type=dynamic
vol_name=root
vol_alignment=1
vol_flags=autoresize
_______________________________________________
LTIB home page: http://ltib.org

Ltib mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ltib

Reply via email to