]> www.infradead.org Git - mtd-utils.git/log
mtd-utils.git
14 years agomtd-utils: move libmtd source files to lib/ subdirectory
Kevin Cernekee [Thu, 8 Jul 2010 00:30:10 +0000 (17:30 -0700)]
mtd-utils: move libmtd source files to lib/ subdirectory

Source files for libmtd, crc32, and fec are scattered throughout the
tree.  Move them to a central location so they can be built into a
common "libmtd.a" library used by all mtd-utils programs.

This patch only renames/deletes files and does not change the content.

Also modify the build system and source code so that libmtd.a can be built
from a "common" location (lib/).  Statically link all utilities at the top
level with libmtd.a . Minor changes to mkfs.ubifs to allow using the common
crc32 implementation.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibscan: rename hdr to ech
Artem Bityutskiy [Wed, 16 Jun 2010 06:47:27 +0000 (09:47 +0300)]
libscan: rename hdr to ech

... to make it clear that this is EC header, not VID header.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-test: seed the random genrator in tests
Artem Bityutskiy [Tue, 15 Jun 2010 11:01:31 +0000 (14:01 +0300)]
ubi-test: seed the random genrator in tests

Add a common seed_random_generator() and make tests use it
for seeding the random generator.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-tests: use rand instead of random in io_paral
Artem Bityutskiy [Tue, 15 Jun 2010 10:31:16 +0000 (13:31 +0300)]
ubi-tests: use rand instead of random in io_paral

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-tests: remove some junk from the integ test
Artem Bityutskiy [Tue, 15 Jun 2010 10:30:46 +0000 (13:30 +0300)]
ubi-tests: remove some junk from the integ test

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: harmonize mtd device node variables
Artem Bityutskiy [Tue, 15 Jun 2010 10:03:14 +0000 (13:03 +0300)]
ubi-utils: harmonize mtd device node variables

Consistently use 'mtd_dev_node' to name variables consining
MTD device node path.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: harmonize libmtd interface a bit
Artem Bityutskiy [Tue, 15 Jun 2010 09:53:00 +0000 (12:53 +0300)]
ubi-utils: harmonize libmtd interface a bit

Let's consistently use 'mtd_num' name for MTD device number. At the
moment some code uses 'mtd_num', other 'dev_num'. Harmonize that.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubigen: make init_vid_hdr externally visible
Artem Bityutskiy [Mon, 14 Jun 2010 12:19:12 +0000 (15:19 +0300)]
libubigen: make init_vid_hdr externally visible

ubi-tests need it.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubigen: move header comments
Artem Bityutskiy [Mon, 14 Jun 2010 10:40:46 +0000 (13:40 +0300)]
libubigen: move header comments

To be consistent with other ubi libraries, move header comments
to the .h file.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubigen: do not create huge arrays on stack
Artem Bityutskiy [Mon, 14 Jun 2010 10:33:39 +0000 (13:33 +0300)]
libubigen: do not create huge arrays on stack

Stop creating 128KiB and larger arrays on stack - allocate RAM
using malloc() instead.

This patch also teaches libubigen to always set errno.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibmtd: add mtd_write_img
Artem Bityutskiy [Mon, 14 Jun 2010 10:25:07 +0000 (13:25 +0300)]
libmtd: add mtd_write_img

Add another helper interface which can be used to write an image
to an mtd device.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-tests: add normsg
Artem Bityutskiy [Mon, 14 Jun 2010 08:35:26 +0000 (11:35 +0300)]
ubi-tests: add normsg

Just like we have in ubi-utils.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-tests: teach errmsg and failed return error code
Artem Bityutskiy [Mon, 14 Jun 2010 07:06:05 +0000 (10:06 +0300)]
ubi-tests: teach errmsg and failed return error code

Just like we do in ubi-utils.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-tests: rename err_msg to errmsg
Artem Bityutskiy [Mon, 14 Jun 2010 07:03:34 +0000 (10:03 +0300)]
ubi-tests: rename err_msg to errmsg

For consistency with ubi-utils.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubi: provide mtd number in UBI device information
Artem Bityutskiy [Mon, 14 Jun 2010 04:55:14 +0000 (07:55 +0300)]
libubi: provide mtd number in UBI device information

Add an 'mtd_num' field to the UBI device information structure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubi: remove few fields from volume info
Artem Bityutskiy [Mon, 14 Jun 2010 05:00:18 +0000 (08:00 +0300)]
libubi: remove few fields from volume info

Remove the 'dev_major' and 'dev_minor' fields from the volume
information structure, because these fields should be provided
by the device information structure.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomtd-utils: support 4096+64 page sizes
Enric Balletbo i Serra [Tue, 18 May 2010 09:53:59 +0000 (11:53 +0200)]
mtd-utils: support 4096+64 page sizes

Add support for oobsize 64 and writesize 4096 in nanddump & nandwrite.

Artem: some more info from further e-mail exchange:

> Are there flashes with the 4096 page / 64 spare combination? Could you
> refer to one? May be any URL? I thought 4096 comes with 128.

Much to my regret I can't provide a URL because is not public. IGEP v2
board has a Onenand with two dice of 2048/64 spare combination but mtd
views 4096/64. The minimal write page is 4K (2K from first dice and 2K
from second dice).

Signed-off-by: Enric Balletbo i Serra <eballetbo@iseebcn.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: check if the start address is page-aligned
Stanley.Miao [Tue, 18 May 2010 12:23:10 +0000 (20:23 +0800)]
nandwrite: check if the start address is page-aligned

Only page-aligned address is permitted in NAND subsystem.

Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: fix the bug of writing a yaffs2 image to NAND
Stanley.Miao [Tue, 18 May 2010 12:23:09 +0000 (20:23 +0800)]
nandwrite: fix the bug of writing a yaffs2 image to NAND

The tool mkyaffs2image doesn't know the oob layout of a NAND flash, so it
puts the yaffs2 tags at the offset 0 of oob area, as a result, the image
generated by mkyaffs2image is different with the image dumped by nanddump.
Now adding a parameter "-r" for nandwrite to differentiate these images.

Write a image generated by mkyaffs2image:
$> nandwrite -a -o /dev/mtd3 yaffs2.bin

Write a image dumped by nanddump:
$> nandwrite -a -r /dev/mtd3 image.bin

Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoMerge branch 'master' of git://git.infradead.org/mtd-utils
Artem Bityutskiy [Sat, 22 May 2010 05:32:23 +0000 (08:32 +0300)]
Merge branch 'master' of git://git.infradead.org/mtd-utils

15 years agonanddump: Support 4096+218 and 4096+224 page sizes
Kevin Cernekee [Tue, 4 May 2010 04:14:39 +0000 (21:14 -0700)]
nanddump: Support 4096+218 and 4096+224 page sizes

Tested with Samsung K9GAG08U0D.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoMerge branch 'master' of ssh://git.infradead.org/srv/git/mtd-utils
Artem Bityutskiy [Wed, 5 May 2010 11:15:43 +0000 (14:15 +0300)]
Merge branch 'master' of ssh://git.infradead.org/srv/git/mtd-utils

15 years agoRevert "UBI: sync ubi-user.h with the lates kernel verion"
Artem Bityutskiy [Tue, 27 Apr 2010 07:32:42 +0000 (10:32 +0300)]
Revert "UBI: sync ubi-user.h with the lates kernel verion"

This reverts commit 13b77ef356e876f42f489f6a08840e12847135c5.

We do not support block devices. This patch was pushed by accident.

15 years agoubiattach/ubidetach: add support to attach/detach by path
Mika Westerberg [Mon, 1 Feb 2010 09:03:48 +0000 (10:03 +0100)]
ubiattach/ubidetach: add support to attach/detach by path

Now there is a new option '-p' (or '--dev-path') that can be used to pass path
to a MTD device node.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubi: add support to attach/detach by MTD device path
Mika Westerberg [Mon, 1 Feb 2010 09:03:47 +0000 (10:03 +0100)]
libubi: add support to attach/detach by MTD device path

struct ubi_attach_request now has additional field 'dev' that can contain path
to the MTD device node in the filesystem. Also there are two new functions that
are able to handle path to the MTD device node:

ubi_attach() - attach MTD device by number or by path
ubi_detach() - detach MTD device by path

ubi_attach() works like ubi_attach_mtd() when it is passed empty req->dev,
otherwise it looks up correct MTD device number based on the given device node
path.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoUBI: sync ubi-user.h with the lates kernel verion
Mika Westerberg [Thu, 28 Jan 2010 13:26:57 +0000 (15:26 +0200)]
UBI: sync ubi-user.h with the lates kernel verion

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubinfo: document the new -N option
Artem Bityutskiy [Thu, 8 Apr 2010 08:48:08 +0000 (11:48 +0300)]
ubinfo: document the new -N option

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubinfo: add -N option to get info by name of ubi volume
Jon Ringle [Tue, 23 Mar 2010 15:16:12 +0000 (11:16 -0400)]
ubinfo: add -N option to get info by name of ubi volume

Signed-off-by: Jon Ringle <jon@ringle.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomtd_debug: fix creation mode parameter
Ferenc Wagner [Sun, 7 Mar 2010 21:15:58 +0000 (22:15 +0100)]
mtd_debug: fix creation mode parameter

creat(2) expects a creation mode parameter, not an open flag.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandtest: fix --keep argument
Radoslav Kolev [Thu, 25 Feb 2010 13:58:10 +0000 (15:58 +0200)]
nandtest: fix --keep argument

When called with the --keep argument nandtest is supposed to restore the
original content after testing, but currently it doesn't. The patch
below fixes the problem.

Signed-off-by: Radoslav Kolev <radoslav.kolev@rnd.bg>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomkfs.jffs2: fix --enable-compressor
Adrian Bunk [Wed, 24 Feb 2010 13:32:29 +0000 (15:32 +0200)]
mkfs.jffs2: fix --enable-compressor

The short option -X was working, but the documented long option
--enable-compressor was missing.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiattach/ubidetach: add support to attach/detach by path
Mika Westerberg [Mon, 1 Feb 2010 09:03:48 +0000 (10:03 +0100)]
ubiattach/ubidetach: add support to attach/detach by path

Now there is a new option '-p' (or '--dev-path') that can be used to pass path
to a MTD device node.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agolibubi: add support to attach/detach by MTD device path
Mika Westerberg [Mon, 1 Feb 2010 09:03:47 +0000 (10:03 +0100)]
libubi: add support to attach/detach by MTD device path

struct ubi_attach_request now has additional field 'dev' that can contain path
to the MTD device node in the filesystem. Also there are two new functions that
are able to handle path to the MTD device node:

ubi_attach() - attach MTD device by number or by path
ubi_detach() - detach MTD device by path

ubi_attach() works like ubi_attach_mtd() when it is passed empty req->dev,
otherwise it looks up correct MTD device number based on the given device node
path.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agobuild: add option to not force largefile support
Peter Korsgaard [Wed, 3 Feb 2010 09:18:46 +0000 (10:18 +0100)]
build: add option to not force largefile support

Not all systems have largefile support (E.G. uClibc depending on config),
so unconditionally enforcing largefile breaks the build.

Work around it by adding a WITHOUT_LARGEFILE flag, similar to the existing
WITHOUT_XATTR.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: boost version to 1.5 v1.3.1
Artem Bityutskiy [Fri, 15 Jan 2010 17:04:21 +0000 (19:04 +0200)]
ubiformat: boost version to 1.5

We fixed the sequence numbers bug, which is quite serious.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: be consistent with sequence numbers
Artem Bityutskiy [Sat, 9 Jan 2010 23:39:24 +0000 (01:39 +0200)]
ubiformat: be consistent with sequence numbers

This commit fixes a stupid an nasty bug. When we flash an UBI image,
we do not change its sequence numbers. But when we format the rest
of the PEBs (beyond the flashed image), we use a random (or specified
via cmdline) sequence number. As a result, we have a broken flash
format and UBI refuses it, because half of it has one sequence number,
another half has a different one.

What we have to do instead, we have to substitute image's sequence
number with ours.

Reported-by: Jeff Angielski <jeff@theptrgroup.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tested-by: Jeff Angielski <jeff@theptrgroup.com>
15 years agoubiformat: always initialize seq number
Artem Bityutskiy [Sat, 9 Jan 2010 23:33:31 +0000 (01:33 +0200)]
ubiformat: always initialize seq number

For some reasons sequence number was set to 0 in some case, which
is wrong.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: be consistent with sequence numbers
Artem Bityutskiy [Sat, 9 Jan 2010 23:39:24 +0000 (01:39 +0200)]
ubiformat: be consistent with sequence numbers

This commit fixes a stupid an nasty bug. When we flash an UBI image,
we do not change its sequence numbers. But when we format the rest
of the PEBs (beyond the flashed image), we use a random (or specified
via cmdline) sequence number. As a result, we have a broken flash
format and UBI refuses it, because half of it has one sequence number,
another half has a different one.

What we have to do instead, we have to substitute image's sequence
number with ours.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: always initialize seq number
Artem Bityutskiy [Sat, 9 Jan 2010 23:33:31 +0000 (01:33 +0200)]
ubiformat: always initialize seq number

For some reasons sequence number was set to 0 in some case, which
is wrong.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: fix error message v1.3.0
Artem Bityutskiy [Wed, 9 Dec 2009 14:42:59 +0000 (16:42 +0200)]
ubiformat: fix error message

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: check that min IO size is power of 2
Artem Bityutskiy [Wed, 9 Dec 2009 14:31:41 +0000 (16:31 +0200)]
ubiformat: check that min IO size is power of 2

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoflash_unlock: enhancing for unlocking of specified number of blocks
Vimal Singh [Wed, 2 Dec 2009 14:30:14 +0000 (20:00 +0530)]
flash_unlock: enhancing for unlocking of specified number of blocks

This patch enhances the flash_unlock utility to be able to do
unlocking for specified blocks range.
This patch also fixes calculation of 'length' as in previous patch.

Say there are 240 blocks present in the device. Then:
offset starts from: 0x0
and full size of device: 0x1E00000

doing: 240 * 0x20000 gives -> 0x1E00000
But last block address should be 0x1DE0000 (which spans for 0x20000
bytes, adding up to size of 0x1E00000)

Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoflash_lock: fix length being passed
Vimal Singh [Wed, 2 Dec 2009 14:28:08 +0000 (19:58 +0530)]
flash_lock: fix length being passed

This patch fixes the 'length' calculation.
Making it:
+       mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize;
Rather:
-       mtdLockInfo.length = num_sectors * mtdInfo.erasesize;

Say there are 240 blocks present in the device. Then:
offset starts from: 0x0
and full size of device: 0x1E00000

doing: 240 * 0x20000 gives -> 0x1E00000
But last block address should be 0x1DE0000 (which spans for 0x20000
bytes, adding upto size of 0x1E00000)

Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: add ubirsvol to .gitignore
Artem Bityutskiy [Thu, 26 Nov 2009 09:40:18 +0000 (11:40 +0200)]
ubi-utils: add ubirsvol to .gitignore

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: fix --erase-counter handling
Artem Bityutskiy [Thu, 26 Nov 2009 09:38:45 +0000 (11:38 +0200)]
ubiformat: fix --erase-counter handling

The --erase-counter option did not work and this was reproted by
Darwin Rambo <drambo@broadcom.com>

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomkfs.ubifs: fix crosscompilation issues
Matthias Fuchs [Fri, 23 Oct 2009 16:05:04 +0000 (18:05 +0200)]
mkfs.ubifs: fix crosscompilation issues

This patch adds support for passing the location of the lzo
library and headers.

Also BUILDDIR must be referenced to find the libubi.a archive.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: add ubirsvol tool to resize UBI volumes
Arnaud Mouiche [Thu, 1 Oct 2009 09:31:47 +0000 (11:31 +0200)]
ubi-utils: add ubirsvol tool to resize UBI volumes

This is nearly a copy/paste from ubirmvol.

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@thomson.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubinize/ubiformat: improve random number seeding
Artem Bityutskiy [Mon, 28 Sep 2009 08:50:51 +0000 (11:50 +0300)]
ubinize/ubiformat: improve random number seeding

Add current time to the PID to improve the pseudo-random number
generator seeding. Also, use 'rand()' instead of 'random()', because
'srand()' is for 'rand()'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat/ubinize: Don't randomize 0xFFFFFFFF sequence number
Michael Roth [Wed, 23 Sep 2009 13:01:27 +0000 (15:01 +0200)]
ubiformat/ubinize: Don't randomize 0xFFFFFFFF sequence number

args.image_seq is of type uint32_t and was initialized to -1 which
becomes 0xFFFFFFFF in this case. Later the value -1 was used as a flag
that args.image_seq should be replaced with a randomized value.

With the option --image-seq (-Q) a user could provide any sequence
number at will.

But when the user provided sequence number was 0xFFFFFFFF this was
understood effectivly as -1 and got overridden by a randomized
sequence number.

So this patch change the programm flow to respect the principle of
least surprise and never use a randomized sequence number when the
user provide one at own will.

Signed-off-by: Michael Roth <mroth@nessie.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat/ubinize: fix more 64-bit image sequence number confusion
Michael Roth [Wed, 23 Sep 2009 13:01:26 +0000 (15:01 +0200)]
ubiformat/ubinize: fix more 64-bit image sequence number confusion

The sequence number is only 32 bit as the strtoul() function.

Signed-off-by: Michael Roth <mroth@nessie.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: add image sequence support
Artem Bityutskiy [Mon, 24 Aug 2009 13:25:47 +0000 (16:25 +0300)]
ubiformat: add image sequence support

Similarly to ubinize, add image sequence number support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubinize: fix 64-bit image sequence number confusion
Artem Bityutskiy [Mon, 24 Aug 2009 12:41:21 +0000 (15:41 +0300)]
ubinize: fix 64-bit image sequence number confusion

UBI image sequence number which we store in EC headers is 32 bits,
not 64-bits. I was confused when noticed that the 'image_seq'
variable had type 'unsigned long long'. Turn it into a 'uint32_t'
type.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: fix typo in the help output
Artem Bityutskiy [Mon, 24 Aug 2009 12:29:26 +0000 (15:29 +0300)]
ubiformat: fix typo in the help output

The UBI image sequence number is a 64-bit integer, not 32-bit integer.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomkfs.ubifs: do not forget to torture PEB
Artem Bityutskiy [Mon, 24 Aug 2009 12:24:41 +0000 (15:24 +0300)]
mkfs.ubifs: do not forget to torture PEB

We added PEB torturing for the case when we fail during flashing
an image, but forgot to add it for the case when we are formating
the flash. Add the forgottent torturing call.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: allow writing the OOB when using the standard input
Jehan Bing [Thu, 6 Aug 2009 00:41:23 +0000 (17:41 -0700)]
nandwrite: allow writing the OOB when using the standard input

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: fix incorrect use of errno.
Jehan Bing [Thu, 6 Aug 2009 00:41:08 +0000 (17:41 -0700)]
nandwrite: fix incorrect use of errno.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: unified reading from standard input and from file - part 3
Jehan Bing [Thu, 6 Aug 2009 00:40:55 +0000 (17:40 -0700)]
nandwrite: unified reading from standard input and from file - part 3

Nandwrite tries to use lseek() when failing to write on a page. lseek()
will fail when used on the standard input so nandwrite fails. This code
replaces lseek with a buffer.

When the data is read, it is put in a buffer (filebuf). This buffer is
reset at each block boundary. So a "seek" just means reading from the
beginning of the buffer. writebuf and oobreadbuf are now just pointers
to locations in filebuf.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: unified reading from standard input and from file - part2
Jehan Bing [Thu, 6 Aug 2009 00:40:42 +0000 (17:40 -0700)]
nandwrite: unified reading from standard input and from file - part2

Use the same code structure when reading the OOB than when reading the
regular data.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agonandwrite: unified reading from standard input and from file - part 1
Jehan Bing [Thu, 6 Aug 2009 00:40:24 +0000 (17:40 -0700)]
nandwrite: unified reading from standard input and from file - part 1

Use same code path for reading data (not the OOB) from either the
standard input or a regular file.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agomkfs.ubifs: correct devtable increment handling
Daniel Neukomm [Tue, 11 Aug 2009 08:33:23 +0000 (11:33 +0300)]
mkfs.ubifs: correct devtable increment handling

With the device table one can add /dev entries to the root file system
image. The device table file contains among others the fields minor,
start, increment and count. If there is an entry with minor=0 start=0
increment=32 and count=4 the mkfs.ubifs makes 128 device entries, with
minor numbers from 0 to 127. The correct version makes 4 entries with
minor number 0,32,64,96.

/dev/mtd c 640 0 0 90 0 0  2 7
This gives 14 devices /dev/mtdXX instead of  7 devices.
Due to this error mtd_debug info /dev/mtd3 delivers the information of
/dev/mtd1 instead of.

Signed-off-by: Daniel Neukomm <Neukomm@vtxmail.ch>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agojffs2dump: rewrite --help output to be more suitable for help2man
Timo Juhani Lindfors [Mon, 27 Jul 2009 21:05:30 +0000 (00:05 +0300)]
jffs2dump: rewrite --help output to be more suitable for help2man

$ help2man /usr/sbin/jffs2dump | man /dev/stdin

currently creates badly formatted output like

-b          --bigendian                 image is big endian
-l          --littleendian              image   is   little
endian  -c          --content                   dump  image
contents  -e  fname    --endianconvert=fname        convert
image endianness, output to file fname -r         --recalc-

This patch modifies the --help output for jffs2dump to be more
suitable for help2man and thus makes it possible to easily create
manual pages that stay up-to-date.

Signed-off-by: Timo Juhani Lindfors <timo.lindfors@iki.fi>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: clean up help output a little
Artem Bityutskiy [Thu, 30 Jul 2009 20:18:45 +0000 (23:18 +0300)]
ubiformat: clean up help output a little

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubinize: add sequence number support
Artem Bityutskiy [Sun, 26 Jul 2009 15:06:58 +0000 (18:06 +0300)]
ubinize: add sequence number support

UBI now supports the image sequence number feature which
prevents UBI from mistakingly accepting half-written images,
if the image was written on top of an older image. Support
this feature in ubinize and make it pick a random
number for the UBI image sequence number.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: update ubi-media.h
Artem Bityutskiy [Sun, 26 Jul 2009 13:40:04 +0000 (16:40 +0300)]
ubi-utils: update ubi-media.h

Update the ubi-media.h file in order to add UBI sequence number
support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: remove depricated -d option
Artem Bityutskiy [Sun, 26 Jul 2009 13:17:36 +0000 (16:17 +0300)]
ubi-utils: remove depricated -d option

It's already about 2 years since the "-d" option was declared
deprecated. UBI utils have printed a warning about this. Now
it is time to kill this option completely.

The affected utilities are ubimkvol, ubirmvol and ubiupdatevol.
Their versions are also increased.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agocommon: remove depricated KB,MB,GB support
Artem Bityutskiy [Sun, 26 Jul 2009 13:05:46 +0000 (16:05 +0300)]
common: remove depricated KB,MB,GB support

KiB, MiB and GiB should be used instead.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: version 1.4
Artem Bityutskiy [Sun, 26 Jul 2009 12:56:57 +0000 (15:56 +0300)]
ubiformat: version 1.4

Increase ubiformat version to reflect the fact that now we
torture PEBs before marking them as bad.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: make badblocks output less confusing
Artem Bityutskiy [Sun, 26 Jul 2009 12:51:11 +0000 (15:51 +0300)]
ubiformat: make badblocks output less confusing

When ubiformat prints something like

ubiformat: bad eraseblocks: 1400

it looks like there are 1400 bad eraseblock, although there is
only one with number 1400. Fix this but turning the print into

ubiformat: 1 bad eraseblock found, numbers: 1400

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: nicify error output
Artem Bityutskiy [Sun, 26 Jul 2009 12:50:00 +0000 (15:50 +0300)]
ubiformat: nicify error output

Do not print extra newline if write fails, because mtd_write
prints a message and adds newline.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: minor printing clean-up
Artem Bityutskiy [Sun, 26 Jul 2009 12:43:03 +0000 (15:43 +0300)]
ubiformat: minor printing clean-up

When a PEB is marked as bad while we are formatting, ubiformat
prints 99% done at the end. Make it print 100% done instead.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: torture eraseblocks on write errors
Artem Bityutskiy [Sun, 26 Jul 2009 12:40:32 +0000 (15:40 +0300)]
ubiformat: torture eraseblocks on write errors

When fail to write to PEBs, and the error is EIO, torture the
PEB before marking it as bad. Basically, the code is copied
from the kernel UBI.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubi-utils: fix compilation errors when using CPPFLAGS
Mike Frysinger [Thu, 2 Jul 2009 01:15:03 +0000 (21:15 -0400)]
ubi-utils: fix compilation errors when using CPPFLAGS

The CPPFLAGS in the env changes how make initializes/appends CPPFLAGS
in sub-makes. This causes the old ubi utils to find the newer headers
at ubi-utils/include/ before the ubi-utils/old-utils/inc/.

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
15 years agoubiformat: allow zero erase counter
Artem Bityutskiy [Tue, 30 Jun 2009 10:03:45 +0000 (13:03 +0300)]
ubiformat: allow zero erase counter

This patch fixes the following issue:

$ ubiformat /dev/mtd2 -e 0
ubiformat: error!: bad erase counter value: "0"

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agonandwrite: fix error handling
Jehan Bing [Mon, 8 Jun 2009 20:43:26 +0000 (13:43 -0700)]
nandwrite: fix error handling

Artem Bityutskiy wrote:
> Yes, write and erase failure mean that the erasblock is bad. But I think
> marking a block as bad straight away is just dangerous. Who knows may be
> this is a small glitch in a bus, or a software bug, or some-one
> corrupted driver's memory, or whatever. This is why UBI is doing
> eraseblock torturing before marking it as bad. And it is very careful
> about error codes - only EIO code is considered as a reason to mark an
> eraseblock as bad.

Fixed broken behavior in case of write failure. More specifically:
- Only try to mark a block bad if the errors are EIO. Other errors
will abort the tool.
- Also abort the tool if the marking fails instead of ignoring it.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agonandwrite: return error if failure when reading from standard input
Jehan Bing [Mon, 8 Jun 2009 16:32:38 +0000 (09:32 -0700)]
nandwrite: return error if failure when reading from standard input

Fix nandwrite to return EXIT_FAILURE in case of error when using the
standard input instead of a file for input.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: fix wrong size calculation with sizes > 4GiB
Detlef Bardtholdt [Mon, 8 Jun 2009 07:34:55 +0000 (09:34 +0200)]
libubi: fix wrong size calculation with sizes > 4GiB

This fixes the handling of total_bytes, avail_bytes and rsvd_bytes.
The result of the multiplication must be 64 Bit.

Signed-off-by: Detlef Bardtholdt <bardtholdt.detlef@ng-litef.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
16 years agonandwrite: amend loop condition
Jehan Bing [Sat, 6 Jun 2009 01:45:53 +0000 (18:45 -0700)]
nandwrite: amend loop condition

If the file contains only a few bytes in the last page and the
--oob option is selected, the loop may exit early
(readlen < meminfo.oobsize).
Most of the time it will still work though because the code
tries to read the whole OOB in one chunk.

Signed-off-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubiformat: add a TODO entry
Artem Bityutskiy [Fri, 5 Jun 2009 16:41:47 +0000 (19:41 +0300)]
ubiformat: add a TODO entry

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomkfs.ubifs: inclreas version to 1.3
Artem Bityutskiy [Fri, 5 Jun 2009 09:43:03 +0000 (12:43 +0300)]
mkfs.ubifs: inclreas version to 1.3

... because of the previous serious bug-fix.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomkfs.ubifs: fix brown paper-bag bug
Artem Bityutskiy [Fri, 5 Jun 2009 09:42:22 +0000 (12:42 +0300)]
mkfs.ubifs: fix brown paper-bag bug

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibmts: recognize pre-MTD-sysfs kernels better
Artem Bityutskiy [Tue, 2 Jun 2009 13:11:35 +0000 (16:11 +0300)]
libmts: recognize pre-MTD-sysfs kernels better

Not-so-old linux kernel like 2.6.29 do already have "/sys/class/mtd/mtdX"
directories, while very old kernels do not. But in 2.6.29 these
directories do not contain any information.

Anyway, the logic in libmtd which checked whether the system
supports sysfs was broken, because it assumed that old systems
do not even have "/sys/class/mtd/" directory.

Fix this problem by checking for "/sys/class/mtd/mtdX/name". If this
is present - the system really has sysfs support.

This patch also adds an extra print to libmtd.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomkfs.ubifs: use libubi to format UBI volume
Corentin Chary [Tue, 26 May 2009 13:08:36 +0000 (15:08 +0200)]
mkfs.ubifs: use libubi to format UBI volume

libubi is now used to format directly UBI volume.
Typing mkfs.ubifs /dev/ubi0_0 is now possible.
dtypes should be ok as they are taken from UBIFS code.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomkfs.ubifs: remove duplicated code
Corentin Chary [Mon, 25 May 2009 06:26:26 +0000 (08:26 +0200)]
mkfs.ubifs: remove duplicated code

ino->uid        = cpu_to_le32(st->st_uid);
ino->gid        = cpu_to_le32(st->st_gid);
was present twice.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubi-utils: fix memory corruptions
Artem Bityutskiy [Mon, 11 May 2009 16:22:34 +0000 (19:22 +0300)]
ubi-utils: fix memory corruptions

This patch contains changes similar to the ones in the previous
patch.

Also, it changes all invocations of memset and makes sure
the argument is 0, not '\0', because memset expects int,
not char.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: fix multiple memory corruptions
Corentin Chary [Sat, 9 May 2009 09:41:07 +0000 (11:41 +0200)]
libubi: fix multiple memory corruptions

The memset is obviously wrong, and valgrind tells
use there are some uninitialised bytes used after read()

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: add ubi_is_mapped() function
Corentin Chary [Sat, 9 May 2009 09:41:06 +0000 (11:41 +0200)]
libubi: add ubi_is_mapped() function

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomkfs.ubifs: fix -U option handling
Kevin Cernekee [Sun, 10 May 2009 06:41:33 +0000 (23:41 -0700)]
mkfs.ubifs: fix -U option handling

The long form (--squash-uids) is correct, but the short form (-U) is not.

Signed-off-by: Kevin Cernekee <kpc.mtd@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubi-utils: add sysfs interface support and new tool
Artem Bityutskiy [Sun, 26 Apr 2009 06:01:12 +0000 (09:01 +0300)]
ubi-utils: add sysfs interface support and new tool

This large commit makes several things.

1. Switches libmtd to use the new sysfs interface
2. Implements new handy 'mtdinfo' utility
3. Does minore amendmends in libubi and some ubi-tools.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubi-tests: add .gitignore file
Artem Bityutskiy [Mon, 11 May 2009 07:14:11 +0000 (10:14 +0300)]
ubi-tests: add .gitignore file

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubi-tests: improve io_paral test
Artem Bityutskiy [Fri, 8 May 2009 15:50:59 +0000 (18:50 +0300)]
ubi-tests: improve io_paral test

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: add ubi_leb_unmap interface
Artem Bityutskiy [Fri, 8 May 2009 15:50:25 +0000 (18:50 +0300)]
libubi: add ubi_leb_unmap interface

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: add ubi_set_property interface
Artem Bityutskiy [Fri, 8 May 2009 15:09:21 +0000 (18:09 +0300)]
libubi: add ubi_set_property interface

This is needed for io_paral test.

16 years agolibmtd: make type_str to be an array
Artem Bityutskiy [Sun, 26 Apr 2009 05:47:03 +0000 (08:47 +0300)]
libmtd: make type_str to be an array

This is a prepearation to the coming sysfs interface support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibmtd: rename num field
Artem Bityutskiy [Sun, 26 Apr 2009 05:19:42 +0000 (08:19 +0300)]
libmtd: rename num field

This is a preparation for the coming sysfs support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibmtd: rename rdonly field
Artem Bityutskiy [Sun, 26 Apr 2009 05:15:47 +0000 (08:15 +0300)]
libmtd: rename rdonly field

This is a preparation for the coming sysfs support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibmtd: rename allows_bb field
Artem Bityutskiy [Sun, 26 Apr 2009 05:11:58 +0000 (08:11 +0300)]
libmtd: rename allows_bb field

This is a preparation for the coming sysfs support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agomtd-utils: minor amendments in crc32.h
Artem Bityutskiy [Sun, 26 Apr 2009 05:04:16 +0000 (08:04 +0300)]
mtd-utils: minor amendments in crc32.h

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubigen: add missing include
Artem Bityutskiy [Sun, 26 Apr 2009 05:02:32 +0000 (08:02 +0300)]
libubigen: add missing include

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agoubi-tests: various changes
Artem Bityutskiy [Fri, 8 May 2009 09:35:42 +0000 (12:35 +0300)]
ubi-tests: various changes

Mostly improvments in io_paral.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
16 years agolibubi: do not use udevsettle
Artem Bityutskiy [Fri, 8 May 2009 09:33:56 +0000 (12:33 +0300)]
libubi: do not use udevsettle

Not sure why, but udevsettle does not work when threads are
used. In the io_paral test I experience the problem when
udevsettle opens UBI volumes and prevents tests to open
them (EBUSY is returned).

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>