Age | Commit message (Collapse) | Author |
|
The ioctl UBI_IOCATT has been extended with max_beb_per1024 parameter.
This parameter is used for adjusting the "maximum expected number of
bad blocks per 1024 blocks" for each mtd device.
The number of physical erase blocks (PEB) that UBI will reserve for bad
block handling is now:
whole_flash_chipset__PEB_number * max_beb_per1024 / 1024
This means that for a 4096 PEB NAND device with 3 MTD partitions:
mtd0: 512 PEB
mtd1: 1536 PEB
mtd2: 2048 PEB
the commands:
ubiattach -m 0 -d 0 -b 20 /dev/ubi_ctrl
ubiattach -m 1 -d 1 -b 20 /dev/ubi_ctrl
ubiattach -m 2 -d 2 -b 20 /dev/ubi_ctrl
will attach mtdx to UBIx and reserve:
80 PEB for bad block handling on UBI0
80 PEB for bad block handling on UBI1
80 PEB for bad block handling on UBI2
=> for the whole device, 240 PEB will be reserved for bad block
handling.
This may seems a waste of space, but as far as the bad blocks can appear
every where on a flash device, in the worst case scenario they can
all appear in one MTD partition.
So the maximum number of expected erase blocks given by the NAND
manufacturer should be reserve on each MTD partition.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
The 'ubi_attach_mtd()' is not used and it is redundant now. 'ubi_attach()'
function may be used instead.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
The req->mtd_num value is now updated with the MTD device number found
by mtd_node_to_num.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Also remove the eraseblock type support, because kernel commit
a65a0eb6d198e058687a9214683bd1c418f20d39 set the dtype
parameter as obsolete.
Also adjust to some renames:
* 'UBI_PROP_DIRECT_WRITE' -> 'UBI_VOL_PROP_DIRECT_WRITE'
* 'struct ubi_set_prop_req' -> 'struct ubi_set_vol_prop_req'.
* 'UBI_IOCSETPROP' -> 'UBI_IOCSETVOLPROP'
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
When we have assigned non-consecutive device numbers to our MTD devices,
then we run `mtdinfo --all', we get errors once mtdinfo tries to process
the devices in the "hole". For instance, suppose that at boot time, we have
one MTD (/dev/mtd0) then perform a sequence like the following:
# modprobe mtdram
# modprobe nandsim
# rmmod mtdram
Then at this point, we have should have devices 0 and 2 without 1. Then:
# mtdinfo --all
...
mtdinfo: error!: mtd1 does not correspond to any existing MTD device
We add a check to first see if device is present, then continue to the next
ID if it doesn't exist.
Reported-by: Brian Foster <brian.foster@maxim-ic.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
When we have assigned non-consecutive device numbers to our UBI devices,
then we run `ubinfo --all', we get errors once ubinfo tries to process the
devices in the "hole". For instance, suppose there are two UBI devices,
/dev/ubi0 and /dev/ubi10; then, ubinfo will fail trying to open /dev/ubi1
with:
ubinfo: error!: cannot get information about UBI device 1
error 2 (No such file or directory)
This patch adds a check to first see if device is present, then continue
to the next ID if it doesn't exist.
Reported-by: Brian Foster <brian.foster@maxim-ic.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
We will use this function in ubinfo.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
|
|
If the user specifies neither a MTD argument nor the `-a' flag, we print
a cryptic message; i.e.,
# mtdinfo
libmtd: error!: cannot get information about "(null)"
error 14 (Bad address)
mtdinfo: error!: cannot get information about MTD device "(null)"
error 14 (Bad address)
This is a regression; previously, mtdinfo would give some short info
about number of devices, etc. when used without arguments. To fix this,
we revert commit d53c03b0989f8354a7e4dbb947a150fc7fe3f6d1 and call
print_general_info() when no device is specified.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
|
|
This issue was reported and analyzed by
Anton Olofsson <anol.martinsson@gmail.com>:
when ubiformat encounters a write error while flashing the UBI image (which may
come from a file of from stdout), it correctly marks the faulty eraseblock as
bad and skips it. However, it also incorrectly drops the data buffer which was
supposed to be written, and reads next block of data.
This patch fixes this issue - in case of a write error, we preserve the current
data and write it to the next eraseblock, instead of dropping it.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
To support the MEMWRITE ioctl, we will need a different sort of libmtd
interface for writing to flash. We will expand mtd_write to include more
functionality; for now, we just change the function definition and
description as we begin to add the actual functionality.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
|
|
The help message for mtdinfo is unnecessarily disjointed. It is split
into three strings which reuse the PROGRAM_NAME string inefficiently and
don't have a consistent style.
This fixup should provide a cleaner look with aligned columns and
easier-to-read source code.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
Line up columns better so that everything is more readable.
Remove "Example 1" since `mtdinfo' does not print information when not
given any arguments.
Remove "...UBI layout information" from description of Example 4, since
Example 4 (now 3) doesn't include the `-u' flag.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
We weren't very consistent in how we listed our options in the mtdinfo
help string (listing short options, long options, or both). Plus, not all
options are inter-operable, so we should distinguish this somewhat.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
This "fixes" a regression found in:
commit 266061ebd5d72391f0a0e831b018e8fc7fea68a1
mtdinfo: add regioninfo/eraseblock map display
On certain flash (NOR flash that have eraseblock region info),
`mtdinfo -a' tries to open the MTD node file, for use with the ioctl
MEMGETREGIONINFO; however, we didn't supply a device node path to
`mtdinfo -a', so it's using NULL, resulting in errors like:
mtdinfo: error!: couldn't open MTD dev: (null)
error 14 (Bad address)
For now, we can just skip dumping region_info with the `-a' flag. If we
find a better way to do this (e.g., export via sysfs, find device nodes
via automatic routines, etc.), then we can kill the workaround and this
FIXME should be removed.
The regression was first reported at:
http://lists.infradead.org/pipermail/linux-mtd/2011-July/037232.html
The result of recent changes is that we cannot get region_info for devices
via the `--all' option. We add a note in the help message warning that
mtdinfo may find more info when given a device patch, e.g., /dev/mtdX.
Reported-by: Brian Foster <brian.foster@maxim-ic.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
|
|
We have removed the -m option, but did not remove args.mtdn which represents
the -m parameters. Kill args.mtdn as well.
Tweaked by Brian Norris.
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
According to feature-removal-schedule, we shouldn't use `-m', since
it relies on a specific device-naming pattern.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
|
|
More utilities now use the common VERSION system.
For utils that printed a very simple message, we use the new
common_print_version() "function."
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
|
|
The ubi-utils/src/ subdir is tossed as it just complicates things for no
real gain. The dictionary.h header is relocated to the ubi-utils/include/
since other headers in there need it.
The top level clean is replaced with a `find -delete` on objects, so it
might prune more than necessary, but many projects now do this sort of
thing and no one complained there.
A "mkdep" helper generates the actual rule, and the variables are used
with "foreach" to expand these automatically.
The tests subdir is updated only to reflect the ubi-utils source move.
Otherwise, it is left untouched as making that non-recursive isn't really
worth the effort.
While we're gutting things, also through in kbuild style output while
building to make things more legible.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This brings the mtdinfo utility in line with the functionality
of the flash_info utility. It dumps the erase regioninfo (if
the devices has it) as well as showing a handy eraseblock map
(if the user has requested it). The eraseblock map also shows
which blocks are locked and which ones are bad.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
A previous commit moved the code using this var into a diff func.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
We are going to add some more code which prints eraseblocks map, so we need to
make 'print_dev_info()' a bit smaller to keep the code readable.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Usage/version information should go to stdout when it is expected behavior
(i.e. the user requested it explicitly). This info should go to stderr
only when the usage info is being shown as a result of incorrect options.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
... because mtd device node name do not have to follow the "/dev/mtd%d"
pattern.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Commit 924862c864da0b62cf93ba7abf2dc78a7e6ac48f broke ubimkvol parrameters
parsing by initializing the 'error' parameter of 'simple_strtoul()' to 1
instead of 0. This patch fixes the issue.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Instead of using strtol and Co directly, use our share simple_strtoX()
helpers. This is just a cleanup.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The utilities are unmaintained for long time, and many of them
do not even work, just compile, and no on complains about this.
This suggests they are unused and we can now safely kill them.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Shrink the data size a little by declaring addresses of constant strings
instead of pointers to it.
Also slip in static & const on long_options missing them.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Make sure all the utils define PROGRAM_NAME and do so at the start of
the file so that sub-headers may assume it exists.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Considering this is marked as "old" which is synonymous with "dead",
having the dir cause build failures because of warnings makes no
sense. So drop the -Werror usage.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Reformat the help text of ubiattach and ubidetach to display nicely on
80 column terminals, also fix a couple of bits that did not make sense.
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Modify ubiattach and ubidetach to default to /dev/ubi_ctrl if not supplied
rather than requiring the user to type it in every time.
Also bump version from 1.0 to 1.1
Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Because of namespace collisions mkfs.ubifs uses crc32() implementation from
/lib/libz.so.1, which generates incompatible CRC and later on the kernel reports
many CRC errors.
Fix this by re-naming mtd-utils' crc32 function to mtd_crc32.
Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This patch is base on Kevin Cernekee's patch posted to the MTD mailing
list. It adds MEMERASE64 support to the 'mtd_erase()' call. Now it
first tries to use MEMERASE64, and if that is not supported, falls
back to the old MEMERASE ioctl.
This patch also introduces an 'offs64_ioctl' flag to the libmtd
descriptor. However, we cannot initialize it in 'libmtd_open()',
because we need an MTD device node, which we do not have in
'libmtd_open()'. Thus, we firs mark this flag as "uninitialized",
and at the first invocation of 'mtd_erase()' we initialize it.
This also means that we have to pass the limbtd descriptor to
'mtd_erase()', to save the flag value. This, in turn, requires
tweaking 'mtd_erase()' users.
This is not very nice, but good enough so far.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Now include/common.h contains things that really everyone can use.
And all the stuff specific to ubi-utils is in ubi-utils/include/ubiutils-common.h
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
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>
|
|
... to make it clear that this is EC header, not VID header.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Consistently use 'mtd_dev_node' to name variables consining
MTD device node path.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
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>
|
|
ubi-tests need it.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
To be consistent with other ubi libraries, move header comments
to the .h file.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
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>
|
|
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>
|
|
Add an 'mtd_num' field to the UBI device information structure.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
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>
|