summaryrefslogtreecommitdiff
path: root/nanddump.c
AgeCommit message (Collapse)Author
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>
2008-09-08nanddump: Utilize Standard Exit MnemonicsGrant Erickson
Replace main exit and return status codes with equivalent mnemonics. 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: Qualifier Clean-upGrant Erickson
Static-qualified all globals except 'main' because they have no use beyond file scope. Constant-qualified MTD device and input positional parameter globals. Constant-qualified argv array. 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-08-21mtd-utils: add support for 4k pages.Thomas Gleixner
Add support for 4K pages in nanddump & nandwrite. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2007-08-03Remove $Id:$ tagsJosh Boyer
The $Id:$ tags are left over from the old CVS repository. Several files have since been changed, and they generally have little value in a git repo so they should be removed. Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2007-03-15MTD-Utils: fix handling of ioctl return value in nand-utilsFrank Haverkamp
Older kernel do not implement the MTDFILEMODE ioctl. In this case nandwrite and nanddump should have used MEMGETOOBSEL in combination with MEMSETOOBSEL. Unfortunately the return value of the unsucessfull ioctl is not -ENOTTY, but -1 and errno contains ENOTTY. This change fixes this issue. I have not tested all cornercases. Would be good if someone could do more careful testing than I did, or maybe reviewing is sufficient in this case. Signed-off-by: Frank Haverkamp <haver@vnet.ibm.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2007-02-08[MTD] Utils: Add 1KB page & 32 bytes spare NANDKyungmin Park
Some OneNAND chips use this spec. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2006-12-05nanddump.c: fix up long_optionsTimo Lindhorst
Add the missing long option '--file'. From: Timo Lindhorst <lindhors@linux.vnet.ibm.com> Signed-off-by: Timo Lindhorst <lindhors@linux.vnet.ibm.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2006-10-09Fixup whitespaceJosh Boyer
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
2006-05-30Update mtd-abi.h and use new NAND ECC functionalityThomas Gleixner
The NAND rework exposes more information to userspace and has a different mechanism to read raw FLASH contents without ECC. Update nanddump and nandwrite. Use the new ECC statistics ioctl to inform the user about corrected and uncorrectable bitflips. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2006-05-23s/oobblock/writesize/gJoern Engel
Follow the kernel in the rename. Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
2006-05-14MTD Utils. (Resubmit as attachment)Steve Finney
Modify nanddump to take a '-n' argument for reading without error correction; also accept hex (and octal) for start and length. Signed-off-by: Steven Finney (sfinney@healthhero.com)
2006-04-11Initial commitDavid Woodhouse