summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-08-24Remove unused symbolsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Update ax_pthreadDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Remove libtool usage from configure.acDavid Oberhollenzer
We do not build any shared libraries, there is no reason to use libtool or disable static. We do build static libraries, for which we need ranlib. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-23mtd-utils: nandtest: handle large nand devicesChristian Wendt he/him
Running nandtest on devices with sizes of 4Gb or more does not work, as the size returned in mtd_info_user is reported as 0 for 4Gb devices for example. The patch uses sysfs to figure out the size of the nand device (as recommended in a comment in include/mtd/mtd-abi.h) and changes sizes and offsets to 64 bit values. [From: Christian Wendt <cw@brainaid.de>] Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30mtd-utils: Add new syntax to get devices by nameBrandon Maier
This introduces a new feature to the MTD command line utilities that allows MTD devices to be referenced by name instead of device node. For example this looks like: > # Display info for the MTD device with name "data" > mtdinfo mtd:data > # Copy file to MTD device with name "data" > flashcp /my/file mtd:data This follows the syntax supported by the kernel which allows MTD device's to be mounted by name[1]. Add the function mtd_find_dev_node() that accepts an MTD "identifier" and returns the MTD's device node. The function accepts a string starting with "mtd:" which it treats as the MTD's name. It then attempts to search for the MTD, and if found maps it back to the /dev/mtdX device node. If the string does not start with "mtd:", then assume it's the old style and refers directly to a MTD device node. The function is then hooked into existing tools like flashcp, mtdinfo, flash_unlock, etc. To load in the new MTD parsing code in a consistent way across programs. [1] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_mtdblock Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30libmtd: Add function to get MTD info by device nameBrandon Maier
This is a convenience function for end users. In some situations it's easier to reference MTD device's by their name then by MTD number, as the name may be more reliable if device partitioning is dynamic or for porting between systems. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30mkfs.ubifs: Fix mkfs.ubifs failure with option selinuxZijun Hu
Below failure happens when mkfs.ubifs --selinux=FILE ... "Error: bad file context FILE 1" "No such file or directory (error 2)" It is fixed by this change. Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-04-24misc-utils: flashcp: correct casting for percent displaycchoux
Add correct casting for written to prevent overflow that size_t is only 32 bits on a 32-bit platform. Signed-off-by: cchoux <chou.cosmo@gmail.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Measure read while write latencyMiquel Raynal
The Read While Write (RWW) feature allows to perform reads from the flash array into cache while a program (from cache) or an erase operation happens, provided that the two areas are located on different banks. The main benefit is the possible reduced latency when requesting to read a page while a much longer operation is ongoing, like a write or an erase. We can try to compare the positive impact of such a feature by enhancing the flash_speed test tool with the following test: - Measure the time taken by an eraseblock write in parallel with an eraseblock read. - Measure when the read operation ends. - Compare the two to get the latency saved with the RWW feature. To be sure the mtd_write actually starts (and acquires the necessary locks) before the mtd_read does, we use SCHED_FIFO at rather high (arbitrary) priorities, respectively 42 and 41. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Rework the time counting helpersMiquel Raynal
In order to be able to have interleaved measures, let's not use the start and finish global variables from the time helpers directly, provide parameters for these variables so that we can provide either the global entries, or more specific ones when relevant. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: mtdpart: document partition of size 0Brandon Maier
If the partition size passed in to the BLKPG_ADD_PARTITION ioctl is 0, Linux will make the partition fill to the end of the device[1]. Document this feature in the help. [1] https://elixir.bootlin.com/linux/v6.0.6/source/drivers/mtd/mtdpart.c#L254 Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: abort on --partition and --erase-allBrandon Maier
Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: verify data in --partitionBrandon Maier
The --partition mode is not verifying that data is being written successfully. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: fix buffer overflowBrandon Maier
The DIFF_BLOCKS code requires that src and dest buffers be large enough to hold one MTD erasesize. This is because each loop operates on one eraseblock so that it can erase and write one whole sector. But the src and dest buffers are fixed at BUFSIZE, so on platforms where the MTD erasesize are larger then BUFSIZE it will overflow the buffers. Instead allocate the buffers dynamically so that they can be sized to fit the erasesize. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: simplify loggingBrandon Maier
Most of the uses of log_printf fall into two styles > if (flags & FLAG_VERBOSE) > log_printf(LOG_NORMAL, ...); or > log_printf(LOG_ERROR, ...) > exit(EXIT_FAILURE); Replace them with log_verbose and log_failure respectively. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: add safe_memeraseBrandon Maier
Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: check for lseek errorsBrandon Maier
Add a safe_lseek wrapper to check for lseek errors. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: add safe_writeBrandon Maier
Share the writing code between the two write implementations. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07Release mtd-utils-2.1.5v2.1.5David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07Fix warning about unaligned pointer in jffs2readerFrederic Germain
gcc 9.3.0-17ubuntu1~20.04 warning on time_t ctime value is : Fix taking address of packed member of ‘struct jffs2_raw_inode’ may result in an unaligned pointer value [-Waddress-of-packed-member]. Signed-off-by: Frederic Germain <frederic.germain@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07.gitignore: add new ubiscan utilityFrederic Germain
Signed-off-by: Frederic Germain <frederic.germain@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-04nor-utils: fix memory leakliaohua
This patch replace "free(rfd.sector_map)" with "free(rfd.header)" to fix memory leak. Signed-off-by: liaohua <liaohua4@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27libmtd: do not ignore non-zero eraseblock size when MTD_NO_ERASE is setEnrico Jorns
In 54d68799, mtd->eb_cnt was enforced to be '1' if MTD_NO_ERASE is set. This was done with the aim of preventing divisions by zero. However, even if MTD_NO_ERASE is set, mtd->eb_size (eraseblock size) can still be set to a non-zero value which would not cause a division by zero. Instead, enforcing an eraseblock count of '1' here even leads to inconsistent eraseblock counting in mtd-utils and lets for example a 'flash_erase' on an mtdnand device fail: | # flash_erase /dev/mtd0 0 0 | Erasing 32768 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 255, mtd0 has 1 eraseblocks | flash_erase: error!: /dev/mtd0: MTD Erase entire chip failureTrying one by one each sector. | error 22 (Invalid argument) | Erasing 128 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 1, mtd0 has 1 eraseblocks | flash_erase: error!: /dev/mtd0: MTD get bad block failed | error 22 (Invalid argument) Also mtdinfo would look inconsistent (eraseblock size vs amount): | # mtdinfo /dev/mtd0 | mtd0 | Name: mtdram test device | Type: ram | Eraseblock size: 131072 bytes, 128.0 KiB | Amount of eraseblocks: 1 (33554432 bytes, 32.0 MiB) | Minimum input/output unit size: 1 byte | Sub-page size: 1 byte | Character device major/minor: 90:0 | Bad blocks are allowed: false | Device is writable: true Fix this by enforcing mtd->eb_cnt to be '1' only when mtd->eb_size is actually zero and would lead to a division by zero otherwise. Fixes: 54d68799 ("libmtd: avoid divide by zero") Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27mtd-utils: flash_otp_dump make offset optionalMichael Walle
Commit 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to flash_otp_dump") introduced an offset parameter. This should have been optional, but there was a typo. Fix it. Reported-by: Sergei Antonov <saproj@gmail.com> Fixes: 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to flash_otp_dump") Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Sergei Antonov <saproj@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27mkfs.jffs2: fix spelling of --compression-mode parameter in help textAlex Henrie
--compr-mode is not accepted as an alias of --compression-mode. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-08-08tests: Remove unused linux/fs.h header from includesKhem Raj
This header is not needed, moreover it includes linux/mount.h which is now in conflict[1] with glibc provided sys/mount.h from glibc 2.36 onwards [1] https://sourceware.org/glibc/wiki/Release/2.36 Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-06-27nandflipbits: fix corrupted oobChristophe Kerello
If a bit is flipped in block 1 or higher, the OOB is corrupted with the OOB of block 0. Mtd_read_oob API has to take into account the block number to be able to calculate the right offset. Fixes: 9fc8db29cf62 ("mtd-utils: Add nandflipbits tool") Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-06-13ubinfo: Fix --vol_id return code for absent volume idAndrew Mellor
When using --vol_id and that volume is missing, it should return non-zero like the --name option does. Signed-off-by: Andrew Mellor <andrew.mellor@casa-systems.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-06-08mtd-utils: nanddump: fix writing big images on 32bit machinesSascha Hauer
When writing a full 4GiB NAND to a file end_addr becomes 0x100000000. With that writing out the first page to the file doesn't happen because size_left is calculated to 0x100000000 - 0 = 0x100000000 which is then truncated to 32bit and becomes zero. Fix this by using an appropriate 64bit type for size_left. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-03-28nandwrite: warn about writing 0xff blocksRafał Miłecki
Such blocks may be incorrectly treated as empty (even though they may have non-erase OOB). Warn about it so people may start useing --skip-all-ffs . Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-01-17fix test bashismMike Frysinger
Using == with `test` is a bashism. POSIX shell only supports =. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-01-06Release mtd-utils-2.1.4v2.1.4David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-01-05Fix: add missing new-line-escape in jffsX-utils Makemodule.amDavid Oberhollenzer
In commit a888044525, various header files that were added to the distribution tarball via EXTRA_DIST were instead added to the source lists of their respective programs instead. In the case of jffsX-utils, a missing escape for a new-line in the source list caused the include/linux/jffs2.h header to not be packged in the release tarball. This went undiscovered, as the system on which the release tarball was built, had the same header installed installed in the system include directory, so a `make distcheck` succeeded. Fixes: a888044525 Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-12-06fectest.c: fix buffer overrunRalph Siemsen
misc-utils/fectest.c:37:11: warning: iteration 47 invokes undefined behavior [-Waggressive-loop-optimizations] 37 | srcs[i] = buf + (i * PKT_SIZE); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-12-06mtd-tests: use pages during readtest and stressRalph Siemsen
Same fix as a2c6bbc ("mtd-tests: Read and write pages during speed tests") but applied to flash_readtest and flash_stress. Resolves failure of flash_readtest when subpages are present. The test reads a (sub)page followed by the entire OOB. Upon reaching the 2nd subpage, the OOB read fails because it is beyond the end of OOB. Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2021-10-13mtd-tests: Read and write pages during speed testsMiquel Raynal
The speed test does reads and writes of different sizes: - eraseblock - page - two pages At least this is the theory because, as opposed to the legacy kernel module doing the same measurement, the userspace tool uses the subpage size (hence accessing the same page 4, 8 or 16 times depending on the subpage setting). Of course if the controller does not support subpages, this issue is not visible. Use mtd.min_io_size instead for non-NOR devices in order to get the right bandwidth (at least one that fits the logs). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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>