summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-09-06Add ubiscan utilityDiego Ismirlian
ubiscan will scan the PEBs in a specific MTD device and print a summary of the PEB erase counters and (optionally) details about each PEB's status. Example output: # ./ubiscan /dev/mtd6 Summary ========================================================= mtd : 6 type : nand size : 110362624 bytes (105.2 MiB) PEBs : 842 min I/O: 2048 bytes PEB erase counters ========================================================= valid : 834 empty : 0 corrupted: 0 alien : 0 bad : 8 Histogram ========================================================= from to count min avg max --------------------------------------------------------- 0 .. 9: 55 1 4 9 10 .. 99: 174 10 48 99 100 .. 999: 514 103 287 987 1000 .. 9999: 91 1004 1880 2251 10000 .. 99999: 0 0 0 0 100000 .. inf: 0 0 0 0 --------------------------------------------------------- Total : 834 1 392 2251 If the --verbose switch is given, ubiscan will print PEB details: # ./ubiscan --verbose /dev/mtd6 [... same output as before ...] Details ========================================================= PEB 0: 253 PEB 1: 1489 PEB 2: 1 PEB 3: 1 PEB 4: 1 PEB 5: 1 PEB 6: 1 PEB 7: 1 PEB 8: 1 PEB 9: 1 PEB 10: 1 ... PEB 832: 1225 PEB 833: 252 PEB 834: 111 PEB 835: 298 PEB 836: 1264 PEB 837: 11 PEB 838: EB_BAD PEB 839: EB_BAD PEB 840: EB_BAD PEB 841: EB_BAD Signed-off-by: Diego Ismirlian <dismirlian@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-07-25Release mtd-utils-2.1.3v2.1.3David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-07-25Add missing filljffs2.sh to EXTRA_DISTDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-06-12misc-utils: flashcp: Add new function that copy only different blocksHarvey Wu
- The original flashcp process is erase, write and verify all blocks in one time from file to device. This patch will add a function that only copy different block data from file to device. The function will compare blocks by block between file and device, then erase and write block data from file to device if found different block. Signed-off-by: Harvey Wu <harveywu95@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-06-12mtd-utils: Add flash_otp_eraseMichael Walle
On some SPI NOR flashes you can actually erase the OTP region until its fully locked. Add a small utility for that. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-05-05mtd-utils: flash_erase: Add flash erase chipLarisa Ileana Grigore
Some flash types support full erase chip command which can reduce the flash erase time. Try first to erase the entire flash and fall back to the old method if the operation fails. Signed-off-by: Larisa Ileana Grigore <larisa.grigore@nxp.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-03-22mkfs.ubifs: Fix runtime assertions when running without cryptoHenri Roosen
Running mkfs.ubifs which was build without crypto triggered the following assertion: mkfs.ubifs: ubifs-utils/mkfs.ubifs/fscrypt.h:166: inherit_fscrypt_context: Assertion `0' failed. A previous commit-cc4c5e295f54 ("mkfs.ubifs: Enable support for building without crypto") added a check for an existing fscrypt context before calling functions inherit_fscrypt_context() and free_fscrypt_context(), however did not properly do this for each call to these functions. Fixes: cc4c5e295f54 ("mkfs.ubifs: Enable support for building without crypto") Signed-off-by: Henri Roosen <henri.roosen@ginzinger.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-02-28mtd-utils: Use AC_SYS_LARGEFILESascha Hauer
Currently mtd-utils on 32bit systems fail on devices >2GiB due to off_t being a signed 32bit type. Add AC_SYS_LARGEFILE to make off_t a 64bit type. Adding AC_SYS_LARGEFILE results in _FILE_OFFSET_BITS being defined to 64 in include/config.h. To let this have an effect we must make sure that include/config.h is included before all other includes which is archieved by adding its inclusion to CPPFLAGS. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Fix test binary installationDavid Oberhollenzer
- Remove "install tests" configure option, we already have an option whether to build tests or not. Don't try to work around autotools semantics that people building the package expect. - Fix the installation path by propperly defining it and using the correct name for the libexec path. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Cleanup: Automake: remove single use variablesDavid Oberhollenzer
Throughout the Automake files, there is a consistent pattern somewhat like this: FOO_BINS = .... sbin_PROGRAMS += $(FOO_BINS) This commit all such patterns whenever the variable is not used anywhere else and appends to the target directly. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-01-20Remove headers from EXTRA_DISTDavid Oberhollenzer
This commit removes the C header files from the EXTRA_DIST variables and instead assigns them to the SOURCE variable of the respective components they belong to. This takes care of having them distributed in the release tar ball and helps with dependency tracking a little. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-11-29libmtd: avoid divide by zeroChris Packham
The concept of erase blocks doesn't apply to mtd-ram devices. Such devices set MTD_NO_ERASE to indicate this and some report 0 for the erase block size. Avoid a divide by zero when calculating the erase block count for such devices. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-11-29mtd-utils: ubihealthd: this tool does not depend on UBIFSJuergen Borleis
The "need_getrandom" check and result is used only for the "ubihealthd". This tool is very important to have it around at run-time, while the corresponding "mkfs.ubifs" tool is still optional (think about offline generated ubifs images). Since compiling "mkfs.ubifs" adds more dependencies (various shared libraries), buildsystems for embedded devices will add these shared libraries to the root filesystem even if "mkfs.ubifs" isn't used or installed. Thus, handling both tools independently makes sense. The previous behavior is kept, e.g. if UBIFS support is enabled, it enables "ubihealthd" as well. Signed-off-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-11-18Add an ubifs mount helperUwe Kleine-König
This abstracts away attaching of the right ubi and then selecting the right ubi device and volume to mount. As described in the comment at the top this allows to mount ubifs volumes directly from /etc/fstab without having to use hardcoded numbers (which depend on mount order and so are unreliable) and extra magic to care for attaching. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-10-18mkfs.ubifs: remove OPENSSL_no_config()Torben Hohn
Especially for the pkcs11 engine, a configuration is required because the provider has to be configured. Its not clear why OPENSSL_no_config() is called. Remove OPENSSL_no_config() and call OPENSSL_config(NULL) instead. Signed-off-by: Torben Hohn <torben.hohn@linutronix.de> Signed-off-by: Bastian Germann <bage@linutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-10-18mtd-utils: Add nandflipbits toolBoris Brezillon
The nandflipbits tool is intended to be used when one need to flip one or several specific bits on a NAND media. It can be useful to manually recover from an unexpected bit flip on a flash device, though the main purpose of this tool is to provide a way to test ECC algorithms robustness. One typical example I used this tool for is testing HW ECC engines behavior when bitflips occur in an erased page: most HW engines do not correctly handle this case, because, most of the time, ECC bits generated for an empty page are not all 1s, and, empty page detection embedded in such engines is only validating that all bits are set to 1s (which is not true when a bit-flip has occurred). Another use of this tool is replacing nandbiterrs test which absolutely do not work with MLC-like chips because of the rewriting of the pages in raw mode to toggle ones into zeroes. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> [miquel: Took Boris' work from 2014, addressed comments from Brian made in 2015, updated it, tested more extensively and fixed issues] Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-09-29misc-utils: Add fectest to build systemBastian Germann
8f627247f6("mtd-utils: move libmtd source files to lib/ subdirectory") removed fectest.c from the build system 10 years ago. Add it again. Signed-off-by: Bastian Germann <bastiangermann@fishpost.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-09-23mkfs.ubifs: Fix build with SELinuxBastian Germann
In v2.1.0, SELinux support was introduced. It never compiled with ubifs because it uses the old add_xattr signature that also changed in v2.1.0 with a1bd316e23("mkfs.ubifs: Implement fscrypto context store as xattr"). Add the ubifs_ino_node and name to the call and remove the nm that is contructed in the new function version. Signed-off-by: Bastian Germann <bastiangermann@fishpost.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-09-11Fix typos found by Debian's lintian toolBastian Germann
Signed-off-by: Bastian Germann <bastiangermann@fishpost.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-07-31fix build of jffs2reader and jffs2dump if zlib or lzo headers are not in ↵Rolf Eike Beer
default paths Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-07-13Release mtd-utils-2.1.2v2.1.2David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-07-13Add the mkfs.ubifs sign.h header to the list of sourcesDavid Oberhollenzer
The sign.h header added by the authentication patch set was omitted from the automake file and thus not added to the distribution tarball. The resulting tarballs were unable to be compiled. Fixes: a739b59 ("mkfs.ubifs: Add authentication support") Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mkfs.ubifs: fix broken build if fscrtyp is disabledDavid Oberhollenzer
First, there is no option named of X509_OPTION. It was presumably changed during development to AUTH_CERT_OPTION. This commit fixes the name in the !WITH_CRYPTO branch. Similarly, '}' got moved into the WITH_CRYPTO branch, but not into else branch, resulting in tons of errors if fscrypt is disabled. This commit pulls it back out of both branches. Fixes: a739b59e ("mkfs.ubifs: Add authentication support") Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Add checks to code that copies strings into fixed sized buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix potentially unterminated stringsDavid Oberhollenzer
This commit fixes some uses of strncpy that could leave the destination buffer unterminated. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix "are we really at EOF" test logic in libubi read_dataDavid Oberhollenzer
The function reads file data into a buffer and then checks if we actually are at the end-of-file by trying to read one more byte. For whatever reason, the code uses an int instead of a char. It's not pretty but works. But again, this is something that every static analysis tool barks at. Further more, the error messages are inverted. "We aren't at EOF yet" is printed on failure and something like "read error %m" is printed on success. This patch fixes all of the above. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix wrong argument to sizeof in nanddumpDavid Oberhollenzer
Some temporary buffers are allocated with "sizeof(pointer) * count" as size argument, which cannot possibly be correct. Assuming what was meant was "sizeof(pointer[0]) * count" makes sense in the context of how the buffers are used, but is actually pretty pointless, since the buffers are unsigend char. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix some simple cases of uninitialized value readsDavid Oberhollenzer
This patch modifies the internal helpers to read and parse integers from sysfs files by initializing them first and removes turns an obscure "a = open(...) if (a >= 0) {...} if (a == -1) {...}" inside recv_image into a more straight forward if/else branch. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix various TOCTOU issuesDavid Oberhollenzer
This patch restructures various code parts that follow the pattern of "stat(x, &sb) ... makes_sense(&sb) ... open(x)". Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix potential negative arguments passed to close(2)David Oberhollenzer
Many tools open a file descriptor, close it a the end and have some form of error path in between that jumps to the end. In some cases, if opening the file fails the error path is taken and the utility ends up closing one or more invalid file descriptors. It's technically not a real issue but something that pretty much any static analysis tool barks at. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-09mtd-utils: Fix printf format specifiers with the wrong typeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-30libubi: remove private kernel header from includesBastian Germann
libubi.h includes ubi-media.h which was made private in the kernel a long time ago. There are users of libubi.h, e.g. swupdate, which have to have ubi-media.h available at build time with this inclusion. However, libubi.h uses only one symbol from ubi-media.h. Define that symbol in the header to enable using libubi.h without installing ubi-media.h. Make up for the transitive symbol use in ubiformat.c by including ubi-media.h. Signed-off-by: Bastian Germann <bastiangermann@fishpost.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-30libubigen: remove unnecessary includeBastian Germann
libubigen.h does not use any symbol from mtd/ubi-media.h, so remove it from includes. Signed-off-by: Bastian Germann <bastiangermann@fishpost.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-13mtd-utils: Fix return value of ubiformatBarry Grussling
This changeset fixes a feature regression in ubiformat. Older versions of ubiformat, when invoked with a flash-image, would return 0 in the case no error was encountered. Upon upgrading to latest, it was discovered that ubiformat returned 255 even without encountering an error condition. This changeset corrects the above issue and causes ubiformat, when given an image file, to return 0 when no errors are detected. Tested by running through my loading scripts and verifying ubiformat returned 0. Signed-off-by: Barry Grussling <barry@grussling.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-13mtd-utils: add optional offset parameter to flash_otp_dumpMichael Walle
There are flashes which have gaps between OTP regions and flashes where the regions don't start at 0 (for example the Winbond 25Q series, which has three 256 bytes OTP regions starting at 0x1000, 0x2000 and 0x3000). At the moment it is impossible to dump the OTP memory. Fix it by passing an optional offset parameter. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-12-08ubihealthd: Build only if sys/random.h is presentMarek Vasut
The ubihealthd depends on sys/random.h , which is not present on some older systems. Build ubihealthd only if sys/random.h is present. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10fs-tests: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10jittertest: fix error check for open system callDavid Oberhollenzer
The value 0 is a valid file descriptor. The existing error handling would not only treat that as an error, but subsequently leak the file descriptor in the error handling path. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mtd_debug: cleanup error handling in flash_to_fileDavid Oberhollenzer
The existing code had multiple error handling labels and did things like checking if a buffer is not NULL before freeing it. This patch collapses all of this into a single label. We can do this, because the standard guarantees us that it is safe to call free() with a NULL pointer. This also has the side effect of removing the possibility of using the wrong error label and accidentally leaking something. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10nanddump: don't leak copied command line argumentsDavid Oberhollenzer
For some command line flags, the argument string is copied. Simply writing over the buffer leads to a resource leak if the same flag is specified on the command line more than once. This patch adds a free() call to the old buffer before overwriting it with the new copy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10ubiformat: don't leak file descriptorsDavid Oberhollenzer
The original code had a 'goto out_close' directly after a return error code, which is obviously not what was intended. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10ftl_format: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10ftl_check: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10libmtd: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.jffs2: don't leak temporary buffer if readlink failsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.ubifs: propperly cleanup in ALL interpret_table_entry error pathsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.ubifs: don't leak temporary buffersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.ubifs: don't leak hastable iteratorsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.ubifs: free derived fscrypt context in add_directory error pathsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-10mkfs.ubifs: don't leak copied command line argumentsDavid Oberhollenzer
For some command line flags, the argument string is copied. Simply writing over the buffer leads to a resource leak if the same flag is specified on the command line more than once. This patch adds a free() call to the old buffer before overwriting it with the new copy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>