Age | Commit message (Collapse) | Author |
|
legacy_get_dev_info() forgot to set the OOB size
Signed-off-by: Ketil Froyn <ketil@froyn.name>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Change type off "offs" for type consistency of 64-bit data types. The
"loff_t" type is no longer needed for the MEMGETBADBLOCK ioctl since
it isn't called dirently anymore - this is handled by mtd_is_bad().
Also change an accompanying printf().
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Several ioctls are replaced with libmtd calls which should give us 64-bit
support for large devices. libmtd mostly provides drop-in replacements
for the functionality we need. However, when we require erasure of a
badly-written block, mtd_erase() only erases a single block, whereas
MEMERASE could erase a larger region. In nandwrite, we may have a "virtual
blocksize" of more than one (when blockalign > 1). Thus, I added a loop
for this case.
The mtd_oob_buf struct is no longer needed, nor is "erase_info_t".
Error messages for the new libmtd calls reflect the style found in
flash_erase.
Tested with nandsim and with NAND chips up to 4GB in size (I don't have
a device that truly requires 64-bit addressing yet).
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
For large block- and page-sizes, the multiplication of ebsize_aligned
and pagelen can overflow a 32-bit integer. This overflow can be
prevented by a simple change in order of operations (i.e., do division
first).
Since ebsize_aligned is always a multiple of mtd.min_io_size, this
produces no change in results.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Commit 07005d915d6a79dbdee14b0c4360df5058c3a98b made changes to the
buffer allocation in nandwrite and did not handle all affected code
areas properly. In particular, we were assigning:
oob.ptr = noecc ? oobreadbuf : oobbuf;
However, since oobreadbuf and oobbuf are declared dynamically, they
are NULL at this point. If they aren't properly assigned later, we
unwittingly are passing a NULL pointer as oob buffer.
This assignment line is best moved after the buffer allocations and
pointer assignment.
Effects of this problem can be seen when writing oob data with the "-o"
flag and without the "-n" flag:
$ ./nandwrite -o /dev/mtd0 img.bin
Writing data to block 0 at offset 0x0
ioctl(MEMWRITEOOB): Bad address
Data was only partially written due to error
: Bad address
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
To support large NAND devices, we need 64-bit data types for
write offsets. This patch makes data type changes along with
their corresponding printf() formats and the input conversion
(i.e., use "strtoll()" instead of "strol()").
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Begin utilizing libmtd for MTD operations: use mtd_get_dev_info() to return
a more detailed set of information about our MTD. Most importantly, libmtd
will yield a 64-bit "size" parameter. This is necessary to properly detect
devices larer than 4GB.
printf() arguments needed reformatted for the new mtd_dev_info data types.
In addition, the printf() was restructured to keep lines shorter.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The text of a printf() states that we're printing OOB area, but the
corresponding argument passes writesize. That probably wasn't the intent.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Due to the presence of the "--block-align" flag, nandwrite uses a
blocksize throughout that, depeding on the execution parameters, may
not be the actual erasesize of the NAND flash. In order to clarify
this situation for the untrained viewer of nandwrite's code, we should
not change the value of "meminfo.erasesize" itself; rather, we can
utilize a separate, calculated "ebsize_aligned". Then, when a user
actually wants to refer to the physical erasesize, it's straightforward.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Comment on "blockalign" default value is incorrect; it only defaults
to a 1x multiplier of the actual block size. Perhaps this is a relic
of early NAND where all block sizes were 16KB?
Reformatted a multi-line comment.
Changed separete "if" statements to a combined "if-else-if" since they
were logically combinable. Should have no effect on results with minor
effect on efficiency.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
We should allow the dump length to be 64-bit, especially since the value
was read in as a "long long" by strtoll().
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This patch heals 'make install' which tried to install the utilities
to '/usr/local//usr/sbin'.
Reported-by: Charles Manning <manningc2@actrix.gen.nz>
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The short option for specifying the count of erase blocks for orphans '-p'
was not detected due to a typo.
Signed-off-by: Vivenzio Pagliari <vivenzio.pagliari@gmx.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Adds support for 64-bit offsets (i.e., devices larger than 4GB).
Utilizes the "unsigned long long" data type as the standard type
for 64-bit offsets throughout. Reformats a few printf statements
to avoid casting and to properly handle "long long."
Calls to ioctls are mostly replaced by libmtd interfaces (which should
choose the proper ioctls for us); however, a few remain and probably
should be handled with more robust interfaces, as some of these
ioctls are considered "legacy."
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
There were some signed/unsigned integer comparisons. Their types were
changed for safety. Also, "strtol" was improperly used for unsigned
data types.
Nanddump's pretty print options needed a slight reformat to prepare for
printing offsets that are more than 32 bits (8 hex characters) wide.
This prevents overlap of output and ensures that at least one space is
printed between hex and ascii printouts. Perhaps this could use some
better alignment in the future.
Other fixes:
* Corrected several simple spacing issues
* Changed indentation of some global variable declarations in
order to prepare for the next patch, which makes those
declarations longer
* Used macro for PRETTY_ROW_SIZE instead of constant 16
* Reformatted, edited a multi-line comment
* Removed some unnecessary casts
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
nanddump should be consistent with nandwrite, which does not accept non page
aligned start addresses. Thus, non page aligned dumps are useless.
To ease migration only warn for now. Add the plan of making this an error to
feature-removal-schedule.txt.
Tweaked by Artem.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Need to use unsigned arithmetic and a 64-bit cast in order to
calculate and output the correct offset for eraseblocks at large
offsets. Signed integer arithmetic does not produce the correct
result "uint64_t" result, so for offsets over 2GB we get
messages like:
Erasing 512 Kibyte @ ffffffff83180000 -- 4308642136 % complete.
Note that this error was not affecting proper erasure; it just
produced incorrect status messages.
Also, we should not add an extra eraseblock for the final status
message; this gives misleading output when, for example, the
following statement is executed:
$ flash_erase /dev/mtd0 0 1
Erasing 512 Kibyte @ 80000 -- 100 % complete
We aren't erasing at offset 0x80000; it should display offset 0.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Dynamic allocation of the oob buffer provides the necessary
support for removing the oob size check. Now, new unknown OOB
sizes can be handled correctly (for example, 8KB page + 448B
OOB).
Included common.h for the use of xmalloc.
Memory freeing should occur on "restoreoob" as well as on
"closeall."
[Conflicts resolved by Artem]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The buffers used for dumping page and OOB data needed dynamic
allocation to help eliminate burdens for updating (i.e., every
time there's a new OOB size we don't have to increase the sizes).
Also, there is no need to check flash chips for "standard sizes."
With recent changes to the printing codebase, we should be able to
handle arbitrary sizes with no problem.
More exit operations are now necessary on program failure, so
"goto closeall" is used more liberally.
Also, common.h is included for the use of xmalloc.
[conflicts fixed by Artem]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Check the first block even when start_addr is not eraseblock aligned.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
When dumping oob data of a bad block, initialize oobbuf with 0xff, instead of
readbuf. This avoids bogus oob data on output.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This converts libmtd to the common xalloc helpers and in doing so, makes
memory allocation failures fatal rather than returning an error to the
caller. I think this is acceptable behavior.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Since these functions take no parameters, declare them as such. The
subtle difference here is that gcc allows (without warning) people to
accidentally call funcs declared with "()" with arguments. Using void
makes sure that gcc will reject such typos at compile time.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
By using the same error message string, we only need one copy of it
in memory at runtime.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
I'm not sure that if we actually are out of memory that declaring the
failing allocation size is useful in the output. So use the same
simple string in every error message to cut down on size (there will
only be one copy of this at runtime). Size is a much more common
concern than handling OOM issues which most likely aren't the fault
of mtd-utils in the first place.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Some C library headers will define MIN(), so add an #ifndef check.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Rather than do a for loop and output 1 space at a time, let the printf
code take care of indenting the string based on the constant length.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
On my default build, this cumulatively shaves off ~100KiB of unused
code and data from the mtd-utils programs.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The mkfs.jffs2 program has local wrappers for memory related functions
that are useful beyond mkfs.jffs2, so break them out into a common header.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
$(PWD) comes from the shell and may cause unexpected side effects when
using "make -C".
$(CURDIR) is defined internally by GNU make.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
These have overlapping functionality, and while flash_eraseall supports
newer 64bit ioctls, flash_erase does not. So rather than graft support
onto flash_erase, merge the functionality of two into flash_erase so we
only have to support one util from now on.
A simple wrapper is provided to ease old flash_eraseall users into the
new combined flash_erase util.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Simply usage of converting strings to numbers by adding some wrappers
around the standard strtoX functions. These helpers simplify the api
of these functions a bit by providing an optional "error" pointer and
automatic error message.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Make PROGRAM_NAME required in order to include common.h so we can rely
on it existing.
Further, stop embedding PROGRAM_NAME in every error message so that we
can save string space with it being declare only once.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The __USE_GNU define is an internal define that source code should never
be touching. So switch it to the proper exported _BSD_SOURCE define.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
|
|
The rtime logic causes gcc to emit an unused warning about srclen, so
mark it with an unused attribute to shut it up.
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>
|
|
We're already in 'if (autoplace) { }' block at ths moment.
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Add a new helper that lets people do simple verbose output without any
implicit strings added around it. Good for progress bars and such.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|