update mtd

This commit is contained in:
Martijn Scheepers
2023-01-04 10:07:01 +01:00
parent bf023c09ab
commit 9cf6679634
4 changed files with 51 additions and 71 deletions

View File

@@ -1,60 +0,0 @@
From 95633c4dfe943a701d4fcd809e6cabf4bf8710b8 Mon Sep 17 00:00:00 2001
From: Barry Grussling <barry@grussling.com>
Date: Sun, 12 Jan 2020 12:33:32 -0800
Subject: [PATCH] mtd-utils: Fix return value of ubiformat
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>
Backported-from: 95633c4dfe943a701d4fcd809e6cabf4bf8710b8
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
ubi-utils/ubiformat.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 64afad2..be40e52 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -550,6 +550,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
struct ubi_vtbl_record *vtbl;
int eb1 = -1, eb2 = -1;
long long ec1 = -1, ec2 = -1;
+ int ret = -1;
write_size = UBI_EC_HDR_SIZE + mtd->subpage_size - 1;
write_size /= mtd->subpage_size;
@@ -643,8 +644,10 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
if (!args.quiet && !args.verbose)
printf("\n");
- if (novtbl)
+ if (novtbl) {
+ ret = 0;
goto out_free;
+ }
if (eb1 == -1 || eb2 == -1) {
errmsg("no eraseblocks for volume table");
@@ -669,7 +672,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
out_free:
free(hdr);
- return -1;
+ return ret;
}
int main(int argc, char * const argv[])
--
2.24.1

View File

@@ -54,6 +54,9 @@ config BR2_PACKAGE_MTD_FLASH_OTP_LOCK
config BR2_PACKAGE_MTD_FLASH_OTP_WRITE
bool "flash_otp_write"
config BR2_PACKAGE_MTD_FLASH_OTP_ERASE
bool "flash_otp_erase"
config BR2_PACKAGE_MTD_FLASH_UNLOCK
bool "flash_unlock"
default y
@@ -68,6 +71,9 @@ config BR2_PACKAGE_MTD_JFFS2DUMP
bool "jffs2dump"
select BR2_PACKAGE_MTD_JFFS_UTILS
config BR2_PACKAGE_MTD_LSMTD
bool "lsmtd"
config BR2_PACKAGE_MTD_MKFSJFFS2
bool "mkfs.jffs2"
select BR2_PACKAGE_MTD_JFFS_UTILS
@@ -95,6 +101,9 @@ config BR2_PACKAGE_MTD_NANDWRITE
bool "nandwrite"
default y
config BR2_PACKAGE_MTD_NANDFLIPBITS
bool "nandflipbits"
config BR2_PACKAGE_MTD_NFTLDUMP
bool "nftldump"
@@ -137,6 +146,14 @@ config BR2_PACKAGE_MTD_UBIFORMAT
bool "ubiformat"
default y
config BR2_PACKAGE_MTD_UBIHEALTHD
bool "ubihealthd"
default y
depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17 # getrandom()
comment "ubihealthd needs a toolchain w/ headers >= 3.17"
depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
config BR2_PACKAGE_MTD_UBIMKVOL
bool "ubimkvol"
default y

View File

@@ -1,4 +1,4 @@
# Locally calculated after checking pgp signature
# ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-2.1.1.tar.bz2.asc
sha256 8d15e8b70f036d6af1a66011f8ca0e048e9675fa7983d33bea92c24313a232d2 mtd-utils-2.1.1.tar.bz2
sha256 dcc100d4161cc0b7177545ab6e47216f84857cda3843847c792a25289852dcaa COPYING
# ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-2.1.5.tar.bz2.asc
sha256 386e27fd121699b6b729bc2e8e04dda987b31cca6b16e12fb6cc6dcf26449f46 mtd-utils-2.1.5.tar.bz2
sha256 dcc100d4161cc0b7177545ab6e47216f84857cda3843847c792a25289852dcaa COPYING

View File

@@ -4,13 +4,24 @@
#
################################################################################
MTD_VERSION = 2.1.1
MTD_VERSION = 2.1.5
MTD_SOURCE = mtd-utils-$(MTD_VERSION).tar.bz2
MTD_SITE = ftp://ftp.infradead.org/pub/mtd-utils
MTD_LICENSE = GPL-2.0
MTD_LICENSE_FILES = COPYING
MTD_CPE_ID_VENDOR = mtd-utils_project
MTD_CPE_ID_PRODUCT = mtd-utils
MTD_INSTALL_STAGING = YES
MTD_LDFLAGS = $(TARGET_LDFLAGS)
ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
MTD_DEPENDENCIES += libexecinfo
MTD_LDFLAGS += -lexecinfo
endif
MTD_CONF_ENV += LDFLAGS="$(MTD_LDFLAGS)"
ifeq ($(BR2_PACKAGE_MTD_JFFS_UTILS),y)
MTD_DEPENDENCIES += zlib lzo host-pkgconf
MTD_CONF_OPTS += --with-jffs
@@ -21,7 +32,8 @@ endif
ifeq ($(BR2_PACKAGE_MTD_UBIFS_UTILS),y)
MTD_DEPENDENCIES += util-linux zlib lzo host-pkgconf
MTD_CONF_OPTS += --with-ubifs
ifeq ($(BR2_PACKAGE_OPENSSL),y)
# crypto needs linux/hash_info.h
ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_12)$(BR2_PACKAGE_OPENSSL),yy)
MTD_DEPENDENCIES += openssl
MTD_CONF_OPTS += --with-crypto
else
@@ -37,10 +49,16 @@ else
MTD_CONF_OPTS += --without-ubifs
endif
ifeq ($(BR2_PACKAGE_MTD_TESTS),y)
MTD_CONF_OPTS += --enable-tests --enable-install-tests
ifeq ($(BR2_PACKAGE_MTD_UBIHEALTHD),y)
MTD_CONF_OPTS += --enable-ubihealthd
else
MTD_CONF_OPTS += --disable-tests --disable-install-tests
MTD_CONF_OPTS += --disable-ubihealthd
endif
ifeq ($(BR2_PACKAGE_MTD_TESTS),y)
MTD_CONF_OPTS += --enable-tests
else
MTD_CONF_OPTS += --disable-tests
endif
# If extended attributes are required, the acl package must
@@ -52,10 +70,11 @@ else
MTD_CONF_OPTS += --without-xattr
endif
HOST_MTD_DEPENDENCIES = host-zlib host-lzo host-util-linux host-zstd
HOST_MTD_DEPENDENCIES = host-acl host-zlib host-lzo host-util-linux host-zstd
HOST_MTD_CONF_OPTS = \
--with-jffs \
--with-ubifs \
--without-crypto \
--disable-tests
MKFS_JFFS2 = $(HOST_DIR)/sbin/mkfs.jffs2
@@ -70,10 +89,12 @@ MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_OTP_DUMP) += flash_otp_dump
MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_OTP_INFO) += flash_otp_info
MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_OTP_LOCK) += flash_otp_lock
MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_OTP_WRITE) += flash_otp_write
MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_OTP_ERASE) += flash_otp_erase
MTD_TARGETS_$(BR2_PACKAGE_MTD_FLASH_UNLOCK) += flash_unlock
MTD_TARGETS_$(BR2_PACKAGE_MTD_FTL_CHECK) += ftl_check
MTD_TARGETS_$(BR2_PACKAGE_MTD_FTL_FORMAT) += ftl_format
MTD_TARGETS_$(BR2_PACKAGE_MTD_JFFS2DUMP) += jffs2dump
MTD_TARGETS_$(BR2_PACKAGE_MTD_LSMTD) += lsmtd
MTD_TARGETS_$(BR2_PACKAGE_MTD_MKFSJFFS2) += mkfs.jffs2
MTD_TARGETS_$(BR2_PACKAGE_MTD_MTD_DEBUG) += mtd_debug
MTD_TARGETS_$(BR2_PACKAGE_MTD_MTDPART) += mtdpart
@@ -92,6 +113,7 @@ MTD_TARGETS_$(BR2_PACKAGE_MTD_UBIATTACH) += ubiattach
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBICRC32) += ubicrc32
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBIDETACH) += ubidetach
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBIFORMAT) += ubiformat
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBIHEALTHD) += ubihealthd
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBIMKVOL) += ubimkvol
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBINFO) += ubinfo
MTD_TARGETS_$(BR2_PACKAGE_MTD_UBINIZE) += ubinize
@@ -109,6 +131,7 @@ MTD_TARGETS_$(BR2_PACKAGE_MTD_INTEGCK) += integck
MTD_TARGETS_$(BR2_PACKAGE_MTD_NANDBITERRS) += nandbiterrs
MTD_TARGETS_$(BR2_PACKAGE_MTD_NANDPAGETEST) += nandpagetest
MTD_TARGETS_$(BR2_PACKAGE_MTD_NANDSUBPAGETEST) += nandsubpagetest
MTD_TARGETS_$(BR2_PACKAGE_MTD_NANDFLIPBITS) += nandflipbits
define MTD_INSTALL_TARGET_CMDS
$(foreach f,$(MTD_TARGETS_y), \
@@ -119,8 +142,8 @@ endef
# Those libraries are not installed by "make install", but are needed
# by other packages, such as swupdate.
define MTD_INSTALL_LIBS
$(INSTALL) -D -m 0755 $(@D)/include/libmtd.h $(STAGING_DIR)/usr/include/mtd/libmtd.h
$(INSTALL) -D -m 0755 $(@D)/include/libubi.h $(STAGING_DIR)/usr/include/mtd/libubi.h
$(INSTALL) -D -m 0755 $(@D)/include/libmtd.h $(STAGING_DIR)/usr/include/libmtd.h
$(INSTALL) -D -m 0755 $(@D)/include/libubi.h $(STAGING_DIR)/usr/include/libubi.h
$(INSTALL) -D -m 0755 $(@D)/include/mtd/ubi-media.h $(STAGING_DIR)/usr/include/mtd/ubi-media.h
$(INSTALL) -D -m 0755 $(@D)/libmtd.a $(STAGING_DIR)/usr/lib/libmtd.a
$(INSTALL) -D -m 0755 $(@D)/libubi.a $(STAGING_DIR)/usr/lib/libubi.a