summaryrefslogtreecommitdiff
path: root/nanddump.c
AgeCommit message (Collapse)Author
2015-11-11mtd-utils: Restructure the mtd-utils source.Dongsheng Yang
* There is no code modification in this commit, only moving * the files to proper place. The user tools looks a little messy as we place almost the all tools in the root directory of mtd-utils. To make it more clear, I propose to introduce the following structure for our source code. mtd-utils/ |-- lib |-- include |-- misc-utils |-- jffsX-utils |-- nand-utils |-- nor-utils |-- ubi-utils |-- ubifs-utils `-- tests Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-07-01nand{dump, test, write}: clean up --help handlingMike Frysinger
We should send the output to stdout when the user passes -h/--help and then exit(0), but otherwise the output should go to stderr and then exit(1). Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01use xstrdup in a few more placesMike Frysinger
These call sites either assume there is no failure (they deref the pointer right away), or the exit themselves. Use xstrdup() instead. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2013-07-01move _GNU_SOURCE to the main makefileMike Frysinger
A bunch of utils are relying on _GNU_SOURCE already. The new prompt code uses getline() which is now part of POSIX, but in older versions of glibc, it was behind _GNU_SOURCE as it was a GNU extension. This change doesn't actually tie us to glibc. Only code that uses GNU extensions does that. It just kills warning when using older versions of glibc. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2011-09-11mtd-utils: update mtd-abi.hBrian Norris
Kernel ABI header added a new ioctl, killed an old one, and exposed OOB modes to user-space. Plus, it added a lot of documentation. We have some trivial name changes for some MTD mode constants as well. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-23nanddump: kill usages of MEMSETOOBSEL ioctlBrian Norris
The ioctl MEMSETOOBSEL hasn't existed for a long time. Using it as a backup to MTDFILEMODE is pointless, so just remove every time it is used. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-06-29nanddump: remove unused variableBrian Norris
The "bb_default" bool was temporarily being used to straighten out potential issues with the changing --bb=METHOD options and to warn users properly. Now, it's unnecessary. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-27autogenerate version.h from build systemMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-25nanddump: default to NOT dumping OOB dataBrian Norris
Since nandwrite doesn't write OOB data by default, we don't dump OOB data by default, in order to be a more proper inverse function. Remove the warnings and change the default. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-25nanddump: change -o to mean --oob, not --omitoobBrian Norris
As warned earlier, we are changing the meaning of `nanddump -o' to mirror the usage in nandwrite, where -o means to include OOB (i.e., `nandwrite -o' writes data to both in-band and out-of-band areas, so `nanddump -o' should dump data from both in-band and out-of-band areas). Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-25nanddump: change default to --bb=skipbadBrian Norris
As promised, we change the default bad block handling method to --bb=skipbad. This works as a better inverse to nandwrite, since nandwrite skips bad blocks when writing data. And of course, we remove the warning messages. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-25nanddump: kill --omitbad, --noskipbadBrian Norris
As mentioned previously, we are killing --omitbad in favor of the new --bb=skipbad option, which functions fairly similarly. Also, --noskipbad has become --bb=dumpbad, so remove the old `-N' and `--noskipbad' flags. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-25mtd-utils: bump nanddump, mtdinfo version numbersBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-23nanddump: document, warn about future default --omitoobBrian Norris
To work as a proper inverse to nandwrite, nanddump must not dump OOB data by default. This patch prints a warning regarding the future change. We also suggest using the new flag, `--oob', for transitioning to the next release with new default behavior. Note that we are changing `-o' to mean `--oob' in the next release, similar to `nandwrite -o'. This is a break from previous behavior. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-23nanddump: add --oob optionBrian Norris
Adds an explicit option for including OOB data in our data dump. Currently, this is the default behavior, but in the next release, the default will be to exclude OOB data. This is done to mirror the '-o' option in nandwrite. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-23nanddump: warn about new default BB handlingBrian Norris
In an upcoming release, we will no longer default to --bb=padbad. Instead, the default will be --bb=skipbad. This makes nanddump a better inverse operation to nandwrite. This patch prints warnings for users so that they get a chance to update their scripts before the default changes officially. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-23nanddump: update help message for BB method changesBrian Norris
--noskipbad will soon be replaced by --bb=dumpbad, and --omitbad is being removed entirely in favor of --bb=skipbad. This patch adds warnings when using inappropriate configurations and adds info to the help message. Please plan to migrate to the new usages shortly. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-23nanddump: remove --skipbad, leaving --bb=skipbadBrian Norris
We are moving to unify bad block handling methods under the --bb=METHOD option. Since --skipbad has not been included in a mtd-utils release yet, we can safely replace it without a deprecation and phase-out period. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-23nanddump: add --bb=METHOD optionBrian Norris
We have too many separate bad block handling methods: --omitbad --noskipbad --skipbad On top of these, we have the default option: that bad blocks are replaced with 0xFF. These options will be unified under --bb=METHOD. The end goal will be something like: ---------------------------------------------------------------------------------------------- Old option New option Comment ---------------------------------------------------------------------------------------------- <default> --bb=padbad dump flash data, substituting 0xFF for any bad blocks --noskipbad --bb=dumpbad dump flash data, including any bad blocks --skipbad --bb=skipbad dump good data, completely skipping any bad blocks (new default) --omitbad N/A very similar to `skipbad' (DEPRECTATED) The BB options are all mutually exclusive, so we check that we do not have more than one BB option explicitly enabled on the command line by tracking whether or not a BB method has been set by the user. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-06nanddump: sort options in help message alphabetically by shortnameBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-06-06nanddump: add --skipbad option for bad blocksBrian Norris
This patch adds a new option "--skipbad" to nanddump. It is subtly different than "--omitbad". The following description was included in the help message to attempt to clarify the differences. Notes on --omitbad and --skipbad: With either option, we stop dumping data when we encounter a bad block and resume dumping at the next good block. However, with --omitbad, we count the bad block as part of the total dump length, whereas with --skipbad, the bad block is 'skipped,' that is, not counted toward the total dump length. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2011-03-18nanddump: fail if -s parameter is unalignedArtem Bityutskiy
Implement the feature which we planned long time ago - make nanddump fail if the -s parameter is not NAND page-aligned. Also bump nanddump version. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-12-02nanddump: choose correct "printf" format-specifierBrian Norris
The mtd-descriptor attributes contain signed data, not unsigned. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-12-02nanddump: check for negative inputsBrian Norris
Includes error messages for negative device offsets and negative lengths, telling the user what the offending option and value were. Previous patch left out the "negative" in the error message. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-12-02nanddump: change "unsigned" to "signed"Brian Norris
For consistency between nanddump and nandwrite and in order to provide better means for checking for negative inputs, the "offset" and "length" types in nanddump should be changed to signed integer types. This also solves a signed/unsigned comparison warning. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-12-02nanddump: Refactor pretty print code into an sprintf()Brian Norris
A do-while loop in pretty_dump_to_buffer() can be refactored into a single sprintf() statement. MAX() and MIN() are used to ensure that: (1) We have at least a single space between hex and ASCII output (2) We don't overflow the line buffer This patch was suggested by Mike Frysinger. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-12-02nanddump/nandwrite: use "simple_" str functionsBrian Norris
Per Mike Frysinger's suggestion, we check for strtoll() and strtoull() errors by using the "common.h" helper functions simple_strtoll() and simple_strtoull(). Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-11-13mtd-utils: nanddump: Allow 64-bit lengthsBrian Norris
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>
2010-10-25mtd-utils: nanddump: add 64-bit support, utilize libmtdBrian Norris
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>
2010-10-25mtd-utils: nanddump/nandwrite: style, signed-ness, printing fixupsBrian Norris
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>
2010-10-18nanddump: warn when the start address is not page alignedBaruch Siach
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>
2010-10-17mtd-utils: nanddump/nandwrite: Style fixupsBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-17mtd-utils: nanddump: Dynamic buffer, increase pagesize/oobsizeBrian Norris
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>
2010-10-16nanddump: always check the first erase blockBaruch Siach
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>
2010-10-12nanddump: fix initialization of bad blocks oob data bufferBaruch Siach
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>
2010-09-27mtd-utils: standardize PROGRAM_NAMEMike Frysinger
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>
2010-09-18nanddump: rename --nobad to --noskipbadv1.4.0Wolfram Sang
"nobad" might lead to the assumption that bad blocks are skipped, but this option does exactly the opposite. Use a more descriptive name. Reported-by: Jon Povey <Jon.Povey@racelogic.co.uk> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Cc: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-12nanddump: add --nobad to read bad blocksMike Frysinger
Sometimes dumping bad blocks is useful, like when the data isn't actually bad but the OOB layout isn't what the kernel is expecting or is otherwise screwed up. The --nobad option allows just that. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-09-12nanddump: drop unused --ignoreerrors optionMike Frysinger
Nowhere in the nanddump code is the "ignoreerrors" variable used. So drop the option completely. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-08-30nanddump: Fix hexdump nybble orderingJon Povey
Hex dumps were being printed with the nybbles reversed since commit 6ff458433ba15b8a7cb258ce64e64e98982df26e Fix. Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk> CC: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-21nanddump: add "forcebinary" flagBrian Norris
Restrict binary dumping so that by default, binary garbage is not printed directly to a terminal. Output redicted to files or piped to other commands should not be affected (as judged by "isatty(ofd)"). A new flag "-a" or "--forcebinary" is included so that users can override this behavior if necessary. Signed-off-by: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-21nanddump: add canonical (hex+ascii) flagBrian Norris
Added the "-c" or "--canonicalprint" flag (modelled off 'hexdump -C') so that users can choose to print ASCII output next to the prettyprint output. This is really an extension to the prettyprint option, so the two options do not conflict if they are both included in the same execution. Signed-off-by: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-21nanddump: robust pretty hexdumpBrian Norris
Adapted code from the linux kernel hex_dump_to_buffer() (lib/hexdump.c) to provide a more robust hexdump for the pretty option. Now, nanddump can print out any size of OOB (or page for that matter...) without having to worry about non-multiples of 16. This also provides ability to dump ASCII format next to the hex output once additional command-line flags are added. Tested with Samsung K9GAG08U0D Signed-off-by: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-18nanddump: increase max OOB sizeBrian Norris
Supported OOB and page sizes can now be changed more easily by a macro constant. NAND_MAX_OOBSIZE needed increased to support 218 and 224 byte OOB. Signed-off-by: Brian Norris <norris@broadcom.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-06-12mtd-utils: support 4096+64 page sizesEnric Balletbo i Serra
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>
2010-05-05nanddump: Support 4096+218 and 4096+224 page sizesKevin Cernekee
Tested with Samsung K9GAG08U0D. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2008-09-08nanddump: Add Support for Quiet OptionGrant Erickson
Added support for the '-q,--quiet' option to suppress diagnostic output. Made the new option mutually-exclusive with the pretty print option. Signed-off-by: Grant Erickson <gerickson@nuovations.com> Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2008-09-08nanddump: Clean-up Usage OutputGrant Erickson
Realign help usage output to make it more explict when a description needs to be wrapped. Use sentence case for the help usage output option short descriptions. Signed-off-by: Grant Erickson <gerickson@nuovations.com> Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2008-09-08nanddump: Use Boolean Mnemonics from stdbool.hGrant Erickson
Added include directive for stdbool.h and leveraged where appropriate to improve code readability by making variable intent and usage more explicit. Signed-off-by: Grant Erickson <gerickson@nuovations.com> Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2008-09-08nanddump: Pass Real Names as Arguments to perrorGrant Erickson
Pass the MTD device node and dump file name as arguments to perror rather than more ambigous, static messages on open failures. Signed-off-by: Grant Erickson <gerickson@nuovations.com> Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>