Age | Commit message (Collapse) | Author |
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
This updates ubifs-media.h to Linux-5.3-rc3 which brings us the bits
and pieces necessary for UBIFS authentication and offline signing.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
I added ZSTD support to mkfs.ubifs and compared the ZSTD results with
zlib/lzo and the available ZSTD compression levels. The results are in
the following table:
Comp image MiB time image2 MiB time
none 271 0m 0,723s 223 0m 0,589s
lzo 164 0m13,705s 116 0m11,636s
zlib 150 0m 7,654s 103 0m 6,347s
favor-lzo 158 0m21,137s 110 0m17,764s
zstd-01 154 0m 1,607s 106 0m 1,429s
zstd-02 153 0m 1,704s 105 0m 1,479s
zstd-03* 152 0m 1,888s 104 0m 1,668s
zstd-04 151 0m 2,741s 103 0m 2,391s
zstd-05 150 0m 3,257s 102 0m 2,916s
zstd-06 150 0m 3,735s 102 0m 3,356s
zstd-07 150 0m 4,066s 102 0m 3,705s
zstd-08 152 0m 1,857s 104 0m 1,644s
zstd-09 152 0m 1,855s 104 0m 1,639s
zstd-10 150 0m 6,654s 102 0m 6,195s
zstd-11 150 0m10,027s 102 0m 9,130s
zstd-12 149 0m14,724s 101 0m13,415s
zstd-13 148 0m18,232s 100 0m16,719s
zstd-14 148 0m20,859s 100 0m19,554s
zstd-15 148 0m25,033s 100 0m23,186s
zstd-16 148 0m38,837s 100 0m36,543s
zstd-17 148 0m46,051s 100 0m43,120s
zstd-18 148 0m49,157s 100 0m45,807s
zstd-19 148 0m49,421s 100 0m45,951s
zstd-20 148 0m51,271s 100 0m48,030s
zstd-21 148 0m51,015s 100 0m48,676s
zstd-22 148 0m52,575s 100 0m50,013s
The UBIFS image was created via
mkfs.ubifs -x $Comp -m 512 -e 128KiB -c 2200 -r $image $out
I used "debootstrap sid" to create a basic RFS and the results are in
the `image' column. The image2 column denotes the results for the same
image but with .deb files removed.
The time column contains the output of the run time of the command.
ZSTD's compression level three is currently default. Based on the
compression results (for the default level) it outperforms LZO in
run time and compression and is almost as good as ZLIB in terms of
compression but quicker.
The higher compression levels make almost no difference in compression
but take a lot of time.
The compression level used is the default offered by ZSTD. It does not
make sense the higher levels.
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):
In file included from ../git/lib/libmtd.c:40:0:
../git/lib/libmtd.c: In function 'mtd_read':
../git/include/common.h:110:18: warning: format '%ld' expects argument of
type 'long int', but argument 5 has type 'off_t {aka long long int}'
[-Wformat=]
../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
errmsg(fmt, ##__VA_ARGS__); \
^~~~~~
../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
^~~~~~~~~~
/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
#define PRId32 "d"
Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The prompt() function is intended to query a yes/no reply from a command
line user by reading in an entire line of text using getline() and checking
the first character. If the line is empty, a default value is returned.
First of all, this patch replaces the usage of getline() with fgets() to
avoid compilation problems on some smaller C libraries, like klibc, that
do not have a getline() implementation. Since we now have a static line
length, this may break some build setups that input lengthy giberish
instead of 'y' or 'n'.
Second, this patch fixes a more severe bug in prompt(), replacing a 'while'
keyword with the 'if' that was most likely intended. In the old version, if
getline() reported an error, it would print an error message inside a while
loop, immediately followed by a break and then march on and process the
erroneous input instead of using the default value as printed to stdout.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Now that we have per-UBI volume flags (for instance for skipping CRC
check when opening it) from the Linux header, let's add it to the
ubi_mkvol_request in libubi and assign the flags to ubi_mkvol_req from
the Linux header from ubi_mkvol.
Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Update both header files to add support for flag specifying whether to
skip the CRC check for static UBI volumes.
Taken from the kernel headers.
Some users of static UBI volumes implement their own integrity check,
thus making the volume CRC check done at open time useless. For
instance, this is the case when one use the ubiblock + dm-verity +
squashfs combination, where dm-verity already checks integrity of the
block device but this time at the block granularity instead of verifying
the whole volume.
Skipping this test drastically improves the boot-time.
Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch exposes OOB available size to user. Then user can use
OOB free area according to OOB available size.
Steps to get OOB available size:
First, access /sys/class/mtd/mtdX/oobavail. If not exist, then
try to get ecc layout by ioctl "ECCGETLAYOUT". If none of them
work, set OOB available size to 0.
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Rock Lee <rockdotlee@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
A common pattern in command line processing is having a usage()
function that prints out how to use the command line options and
then terminates.
The function is typically used inside a switch block for command
line options like `-h' or unknown options. In a lot of places, the
break keyword is omitted, because the function exits anyway. However,
this triggers gcc warnings about implicit fall-through.
Rather than adding a phony "/* fall-through */" this patch flags the
usage() style function with a gcc attribute, indicating that they do
not return and removes further superfluous break statements.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
AC_CHECK_HEADERS already makes sure our config header contains a
HAVE_$FOO_H macro if a header was found. There is no need to
awkwardly set our own Automake conditionals and check for it all
over the place in the Automake files.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Fixes:
| LD ubi-utils/ubiformat
| .../git/ubi-utils/libiniparser.a(libiniparser.o): In function
| ` LD ubi-utils/ubirename
| iniparser_getdouble':
| .../git/ubi-utils/libiniparser.c:336: undefined reference to `atof'
Grep doesn't reveal any occurrence of iniparser_getdouble(), using atof() so
remove it: floating-point is not supported in klibc
Upstream-Status: Pending
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The documentation of libmtd_open says, if it returns NULL and errno is
zero, MTD is not present. However, the current version always returns
a libmtd_t object. The function internally checks, if it can access the
MTD sysfs files and, if not, sets a flag to use the procfs fallback.
This patch adds an additional check to libmtd_open, to test if the
MTD procfs file can be read and fails with errno cleared if it does
not exist.
Furhtermore, mtd_get_info is documented to fail with errno set to ENODEV
if MTD is not present. First of all, this was broken in the original
version. It was implemented to specification for the sysfs code path,
but if MTD is not present, that won't be executed, because of the flag
set by libmtd_open. This makes the check not only redundant, but masks
an actual error (the sysfs paths suddenly not being readable anymore).
The legacy path that was used if the sysfs files are not avaible fails
with ENOENT if it cannot read the procfs file. With the above changes
in addition, we don't have a libmtd_t object if neither sysfs nor
procfs is readable, so this error status no longer makes sense.
This patch removes the documentation on the ENODEV errno, and
makes sure that mtd_get_info always returns with apropriate errno
on failure.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This is based on the patch from Khem Raj used by openembedded. In
addition to the original patch, this also removes the fallback
implementation that was provided for C libraries that don't implement
rpmatch.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
On 32bit systems (e.g. ARM) the size of off_t can be 4 byte and the size of loff_t 8 byte.
This causes compiler warnings like the following:
flash_erase.c: In function 'show_progress':
flash_erase.c:56:22: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'off_t {aka long int}' [-Wformat=]
bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
and an output like this:
~# flash_erase /dev/mtd2 0 1
Erasing 64 Kibyte @ 6400000000 -- 0 % complete
~#
Since the size of off_t and loff_t can differ from each other, the
printf format specifier should be determined separately for both.
Further the format specifiers should be based directly on the size of the
particular data type.
Signed-off-by: Torsten Fleischer <torfl6749@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Pull the buffer content checking code into separate function and
simplify the code invoking it slightly.
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Several tools are simply not checking return code of functions marked
with 'warn_unused_result'.
Provide wrappers for the read/write functions to avoid patching old
code and providing proper error handling.
Fix the remaining ones (calls to fgets() and system()).
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
|
|
Compiling for x86_64 generates a lot of warning because the PRIxoff_t and
PRIdoff_t are not properly defined, which comes from the missing
SIZEOF_LONG definition.
Use the autotools to generate a config.h header, include this header from
common.h and ask autoheader to generate the SIZEOF_LONG and SIZEOF_LOFF_T
definitions.
Use these new definitions to assign the proper descriptors to PRIxoff_t
and PRIdoff_t.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
|
|
Historically, the mtd-utils and ubi-utils were seperate packages. The
ubi-utils were at some point merged into the mtd-utils. They first
appeared in the release tar-ball in version 1.1.0 in their own
sub-hirarchy with their own buildsystem, readme, documentation, etc.
A lot of the duplicated stuff got centralized/removed over time.
This patch further cleans up the directory hirarchy duplication by
moving common libraries from the ubi-utils/ into the central lib/
and include/ directories in the top directory of the mtd-utils package.
This includes:
- libuib.a & libubigen.a used by the ubi utilities
- libscan.a currently only used by ubiformat
- libiniparser.a used by ubinize
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch moves the remaining 3 functions from ubiutils-common.{c,h}
into libmtd common.{c,h}.
The functions are only generic utility functions that other mtd-utils
programs may also find usefull and every program that uses libubi links
against libmtd anyway so there is no real reason for keeping around a
seperate ubiutils-common with only generic helper functions.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
This patch adds a libmissing library to mtd-utils, containing
implementations of functionality found in glibc but typically
missing from embedded C libraries such as uclibc ot musl.
For now, the library only contains stub implementations of
the backtrace*() family of functions.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
When a program does sophisticated enough command line processing
(i.e. getopt), make sure it responds to -V and --version.
When a program prints a version string, make sure it uses the
common_print_version macro to print out its name, that it is part
of mtd-utils and the mtd-utils version from the build system in a
fashion similar to common program packages like the GNU coreutils.
When a program responds to -V/--version or -h/--help, make sure it
reports success exit status.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
This patch is largely based on Richards original RFC.
The major differences to the RFC patch are:
- Add missing sumtools & mtdpart targets
- Fix name of mkfs.jffs2 target
- Add missing subdir-objects option for non-recursive make
- Move all automake options to configure.ac
- Add manpages to install target
- Make XATTR & LZO support configurable
- Install binaries to sbin directory like in the old build system
- Install flash_erase wrapper script
- Add files missing from distribution target
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
The function _tries_ to support short reads but doesn't adjust the
pointer into the buffer. If a short read happens, we scrambles the
flash contents. Interrupted reads aren't handled. Short or
interrupted writes aren't handled at all. Either a write succeeds
writing the entire buffer or the function gives up.
During an attempt at fixing it, it was discovered, that no mtd-utils
program uses this function. Furthermore, its highly specific nature
makes it more of a "feature looking for use case".
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
This patch fixes the follwing compiler warnings:
flash_erase.c: In function 'show_progress':
flash_erase.c:56:22: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'off_t {aka long long int}' [-Wformat=]
bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
^
./include/common.h:81:10: note: in definition of macro 'bareverbose'
printf(fmt, ##__VA_ARGS__);
which are linked to the following buggy numerical output:
Erasing 128 Kibyte @ 0 -- 917504 % complete flash_erase: Cleanmarker written at 0
Erasing 128 Kibyte @ 0 -- 1048576 % complete flash_erase: Cleanmarker written at 0
Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
These functions have always been defined in sys/sysmacros.h under
Linux C libraries. For some, including sys/types.h implicitly
includes that as well, but glibc wants to deprecate that, and some
others already have. Include the header explicitly for the funcs.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Like uClibc version older than (not yet released) 0.9.34 musl does not have
a rpmatch() implementation.
uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its
version and then for a non glibc implementation (like musl). Note, musl does
not define __MUSL__.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
... in order to have definitions of things like __le16.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
This file will be shared with the ubidump tool in the future.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
This patch adds four macros:
ALIGN, __ALIGN_MASK, min_t and max_t
to include/common.h.
Signed-off-by: hujianyang <hujianyang@huawei.com>
|
|
An implementation of rpmatch() was backported to the 0.9.33 branch of uClibc.
So the uClibc version check introduced in commit 50c9e11f7e (include/common.h:
fix build against current uClibc) is not enough. Rename the local rpmatch()
implementation to avoid collision.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Commit dbe0fd17f2 (mtd-utils: new prompt() helper for talking to the user)
introduced a rpmatch() call. However, uClibc versions older than (not yet
released) 0.9.34 don't have rpmatch() implementation. Add one.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
|
|
With the addition of block device access to UBI volumes, we now
add a simple userspace tool to access the new ioctls.
Usage of this tool is as simple as it gets:
$ ubiblock --create /dev/ubi0_0
will create a new block device /dev/ubiblock0_0, and
$ ubiblock --remove /dev/ubi0_0
will remove the device.
Artem: slightly changed the header comment.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
The helper is for user applications, and it is just a copy of
the kernel helper: mtd_type_is_nand();
Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
We've got a few tools that prompt the user for "yes/no" questions.
Add a common helper to simplify the various implementations.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
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>
|
|
They will be usefull when printing offsets.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Also remove the eraseblock type support, because kernel commit
a65a0eb6d198e058687a9214683bd1c418f20d39 set the dtype
parameter as obsolete.
Also adjust to some renames:
* 'UBI_PROP_DIRECT_WRITE' -> 'UBI_VOL_PROP_DIRECT_WRITE'
* 'struct ubi_set_prop_req' -> 'struct ubi_set_vol_prop_req'.
* 'UBI_IOCSETPROP' -> 'UBI_IOCSETVOLPROP'
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|