summaryrefslogtreecommitdiffstats
path: root/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2018-01-29 00:05:07 +0100
committerArmin Kuster <akuster808@gmail.com>2018-02-11 11:50:56 -0800
commitedbe41f53ec15eeae4673498c41a1f3a42ac813b (patch)
treed27d63b3249b2d4ebfee8ad5e837466d256e7ac2 /meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc
parent75356b6a76e965f6e282e8219e88afc1ab4f3240 (diff)
downloadmeta-openembedded-edbe41f53ec15eeae4673498c41a1f3a42ac813b.tar.gz
ubi-utils-klibc_1.5.2: fix build for qemuarm
Building the recipe with TUNE_FEATURES = "aarch64" and TARGET_FPU = "" fails. See patch headers for more details. Patch sent upstream for master, here rebased for 1.5.2. Tested runtime on armv5. While there backport one more patch fixing warnings in libmtd.c and move the patches in their specific dir, preparing for v2.0.1. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch84
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch27
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch76
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch84
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch49
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch85
6 files changed, 0 insertions, 405 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch
deleted file mode 100644
index 6e1b9ff100..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch
+++ /dev/null
@@ -1,84 +0,0 @@
1From c4e6bd9378645d577e9d9f85da85f1438afe7c50 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:32:29 +0200
4Subject: [PATCH 1/6] Makefile: build ubi-utils only
5
6We build all the static ubi-utils but actually only ubiattach is needed in
7a minimalistic initramfs for the mount of ubi volumes.
8
9More fixes are needed in order to build the full mtd-utils.
10The first issue is:
11
12| mkfs.jffs2.c:64:20: fatal error: libgen.h: No such file or directory
13| #include <libgen.h>
14
15Removing the include then the second error is:
16
17| mkfs.jffs2.c:1570:22: error: '_SC_PAGESIZE' undeclared
18| (first use in this function)
19| page_size = sysconf(_SC_PAGESIZE);
20
21Upstream-Status: Inappropriate [embedded specific]
22
23Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
24---
25 Makefile | 24 ++----------------------
26 1 file changed, 2 insertions(+), 22 deletions(-)
27
28Index: git/Makefile
29===================================================================
30--- git.orig/Makefile
31+++ git/Makefile
32@@ -16,28 +16,11 @@ endif
33
34 TESTS = tests
35
36-MTD_BINS = \
37- ftl_format flash_erase nanddump doc_loadbios \
38- ftl_check mkfs.jffs2 flash_lock flash_unlock \
39- flash_otp_info flash_otp_dump flash_otp_lock flash_otp_write \
40- mtd_debug flashcp nandwrite nandtest mtdpart \
41- jffs2dump \
42- nftldump nftl_format docfdisk \
43- rfddump rfdformat \
44- serve_image recv_image \
45- sumtool jffs2reader
46 UBI_BINS = \
47 ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
48 ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock
49
50-BINS = $(MTD_BINS)
51-BINS += mkfs.ubifs/mkfs.ubifs
52-BINS += $(addprefix ubi-utils/,$(UBI_BINS))
53-SCRIPTS = flash_eraseall
54-
55-TARGETS = $(BINS)
56-TARGETS += lib/libmtd.a
57-TARGETS += ubi-utils/libubi.a
58+BINS = $(addprefix ubi-utils/,$(UBI_BINS))
59
60 OBJDEPS = $(BUILDDIR)/include/version.h
61
62@@ -61,12 +44,9 @@ endif
63 rm -f $(BUILDDIR)/include/version.h
64 $(MAKE) -C $(TESTS) clean
65
66-install:: $(addprefix $(BUILDDIR)/,${BINS}) ${SCRIPTS}
67+install:: $(addprefix $(BUILDDIR)/,${BINS})
68 mkdir -p ${DESTDIR}/${SBINDIR}
69 install -m 0755 $^ ${DESTDIR}/${SBINDIR}/
70- mkdir -p ${DESTDIR}/${MANDIR}/man1
71- install -m 0644 mkfs.jffs2.1 ${DESTDIR}/${MANDIR}/man1/
72- -gzip -9f ${DESTDIR}/${MANDIR}/man1/*.1
73
74 tests::
75 $(MAKE) -C $(TESTS)
76@@ -91,8 +71,6 @@ LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
77 LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
78 LDLIBS_jffs2reader = -lz $(LZOLDLIBS)
79
80-$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
81-
82 #
83 # Common libmtd
84 #
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch
deleted file mode 100644
index f46824b5cd..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From f3609c7c0450b4c31e1d4603fcf2cfb1ba46f994 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:37:28 +0200
4Subject: [PATCH 2/6] common.mk: for klibc $(CC) is klcc
5
6Do not hardcode: assign the value to the variable if it is not already defined.
7
8Upstream-Status: Pending
9
10Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
11---
12 common.mk | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/common.mk b/common.mk
16index ba87377..59c56df 100644
17--- a/common.mk
18+++ b/common.mk
19@@ -1,4 +1,4 @@
20-CC := $(CROSS)gcc
21+CC ?= $(CROSS)gcc
22 AR := $(CROSS)ar
23 RANLIB := $(CROSS)ranlib
24
25--
261.9.1
27
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch
deleted file mode 100644
index 962b3685f3..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From 72a39bb3290a79e76b0dbf59eef83ea2d9b577a1 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:40:15 +0200
4Subject: [PATCH 3/6] libubi.c: add klibc specific fixes for ioctl
5
6First issue is that ioctl() in klibc doesn't expect a constant as arg3.
7Second issue is that arg3 in klibc ioctl() implementation is not optional.
8
9Fixes:
10
11| ubi-utils/libubi.c: In function 'do_attach':
12| ubi-utils/libubi.c:698:8: warning: passing argument 3 of 'ioctl' discards
13| 'const' qualifier from pointer target type
14| ret = ioctl(fd, UBI_IOCATT, r);
15| ^
16| In file included from ubi-utils/libubi.c:32:0:
17| .../lib/klibc/include/sys/ioctl.h:15:14: note: expected 'void *' but argument
18| is of type 'const struct ubi_attach_req *'
19| __extern int ioctl(int, int, void *);
20| ^
21
22| ubi-utils/libubi.c: In function 'ubi_vol_block_create':
23| ubi-utils/libubi.c:1118:9: error: too few arguments to function 'ioctl'
24| return ioctl(fd, UBI_IOCVOLCRBLK);
25| ^
26| In file included from ubi-utils/libubi.c:32:0:
27| .../lib/klibc/include/sys/ioctl.h:15:14: note: declared here
28| __extern int ioctl(int, int, void *);
29| ^
30| ubi-utils/libubi.c: In function 'ubi_vol_block_remove':
31| ubi-utils/libubi.c:1123:9: error: too few arguments to function 'ioctl'
32| return ioctl(fd, UBI_IOCVOLRMBLK);
33| ^
34| In file included from ubi-utils/libubi.c:32:0:
35| .../usr/lib/klibc/include/sys/ioctl.h:15:14: note: declared here
36| __extern int ioctl(int, int, void *);
37| ^
38
39Upstream-Status: Inappropriate [klibc specific]
40
41Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
42---
43 ubi-utils/libubi.c | 6 +++---
44 1 file changed, 3 insertions(+), 3 deletions(-)
45
46diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
47index 1e08b7d..491e525 100644
48--- a/ubi-utils/libubi.c
49+++ b/ubi-utils/libubi.c
50@@ -687,7 +687,7 @@ void libubi_close(libubi_t desc)
51 * success and %-1 in case of failure. @r->ubi_num contains newly created UBI
52 * device number.
53 */
54-static int do_attach(const char *node, const struct ubi_attach_req *r)
55+static int do_attach(const char *node, struct ubi_attach_req *r)
56 {
57 int fd, ret;
58
59@@ -1115,12 +1115,12 @@ int ubi_rsvol(libubi_t desc, const char *node, int vol_id, long long bytes)
60
61 int ubi_vol_block_create(int fd)
62 {
63- return ioctl(fd, UBI_IOCVOLCRBLK);
64+ return ioctl(fd, UBI_IOCVOLCRBLK, NULL);
65 }
66
67 int ubi_vol_block_remove(int fd)
68 {
69- return ioctl(fd, UBI_IOCVOLRMBLK);
70+ return ioctl(fd, UBI_IOCVOLRMBLK, NULL);
71 }
72
73 int ubi_update_start(libubi_t desc, int fd, long long bytes)
74--
751.9.1
76
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch
deleted file mode 100644
index fee1cbcf90..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch
+++ /dev/null
@@ -1,84 +0,0 @@
1From e56767b9caa02e7c41803499c77dc939d5a7f64a Mon Sep 17 00:00:00 2001
2From: Thorsten Glaser <tg@mirbsd.org>
3Date: Fri, 20 Jun 2014 10:56:27 +0000
4Subject: [PATCH 4/6] Restore compatibility to dietlibc, klibc, musl libc after commit 4f1b108
5
6Each C library has their own way to define off_t, and the <features.h>
7header is nonstandard and specific to the GNU libc and those that clone
8it (uClibc). Fefe’s dietlibc uses different flags, and klibc always uses
9a 64-bit off_t (like the BSDs); musl libc cannot be recognised using cpp
10instructions, so we assume 64 bit there (and on unknown C libraries) and
11leave it to the user to submit a follow-up fix if we guess wrong. I also
12added a static assertion to verify the 64 bit guess is correct.
13
14It would be really better using a configure script for this instead.
15
16Fixes:
17| CC lib/libmtd.o
18| In file included from ubi-utils/ubiutils-common.c:35:0:
19| ./include/common.h:29:22: fatal error: features.h: No such file or directory
20| #include <features.h>
21| ^
22| compilation terminated.
23
24Upstream-Status: Pending
25
26Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
27Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
28---
29 include/common.h | 24 ++++++++++++++++++++++++
30 1 file changed, 24 insertions(+)
31
32diff --git a/include/common.h b/include/common.h
33index 6895e5c..77f3f7d 100644
34--- a/include/common.h
35+++ b/include/common.h
36@@ -26,7 +26,9 @@
37 #include <string.h>
38 #include <fcntl.h>
39 #include <errno.h>
40+#if defined(__GLIBC__) || defined(__UCLIBC__)
41 #include <features.h>
42+#endif
43 #include <inttypes.h>
44 #include "version.h"
45
46@@ -52,6 +54,21 @@ extern "C" {
47 #endif
48
49 /* define a print format specifier for off_t */
50+#if defined(__KLIBC__)
51+/* always 64 bit on klibc */
52+#define PRIxoff_t PRIx64
53+#define PRIdoff_t PRId64
54+#elif defined(__dietlibc__)
55+/* depends on compiler flags on dietlibc */
56+#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
57+#define PRIxoff_t PRIx64
58+#define PRIdoff_t PRId64
59+#else
60+#define PRIxoff_t "l"PRIx32
61+#define PRIdoff_t "l"PRId32
62+#endif
63+#elif defined(__GLIBC__) || defined(__UCLIBC__)
64+/* depends on compiler flags on glibc and uClibc */
65 #ifdef __USE_FILE_OFFSET64
66 #define PRIxoff_t PRIx64
67 #define PRIdoff_t PRId64
68@@ -59,6 +76,13 @@ extern "C" {
69 #define PRIxoff_t "l"PRIx32
70 #define PRIdoff_t "l"PRId32
71 #endif
72+#else
73+/* unknown libc or musl */
74+#define PRIxoff_t PRIx64
75+#define PRIdoff_t PRId64
76+/* verify our guess of 64 bit is correct */
77+static char __PRIxoff_t_static_assert[sizeof(off_t) == 8 ? 1 : -1];
78+#endif
79
80 /* Verbose messages */
81 #define bareverbose(verbose, fmt, ...) do { \
82--
831.9.1
84
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch
deleted file mode 100644
index 6b09c14d6c..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch
+++ /dev/null
@@ -1,49 +0,0 @@
1From 8318852ef4f768bed31072aa7b57e11adc1f639c Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:44:03 +0200
4Subject: [PATCH 5/6] common.h: more workarounds for klibc compatibility
5
6Patch is addressing two issues:
7* First, Klibc doesn't have rpmatch().
8* Second, Klibc lacks getline()
9
10Fixes:
11| LD ubi-utils/ubiformat
12| .../git/ubi-utils/ubiformat.o: In function `prompt':
13| .../git/./include/common.h:157: undefined reference to `getline'
14| .../git/./include/common.h:164: undefined reference to `rpmatch'
15| .../git/./include/common.h:157: undefined reference to `getline'
16| .../git/./include/common.h:164: undefined reference to `rpmatch'
17
18Upstream-Status: Pending
19
20Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
21---
22 include/common.h | 10 ++++++----
23 1 file changed, 6 insertions(+), 4 deletions(-)
24
25Index: git/include/common.h
26===================================================================
27--- git.orig/include/common.h
28+++ git/include/common.h
29@@ -161,15 +161,17 @@ static inline int __rpmatch(const char *
30 */
31 static inline bool prompt(const char *msg, bool def)
32 {
33- char *line = NULL;
34- size_t len;
35+ char *line;
36 bool ret = def;
37
38+ const int sizeof_line = 2;
39+ line = malloc(sizeof_line);
40+
41 do {
42 normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N');
43 fflush(stdout);
44
45- while (getline(&line, &len, stdin) == -1) {
46+ while (fgets(line, sizeof_line, stdin) == NULL) {
47 printf("failed to read prompt; assuming '%s'\n",
48 def ? "yes" : "no");
49 break;
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch
deleted file mode 100644
index 043a89d67e..0000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch
+++ /dev/null
@@ -1,85 +0,0 @@
1From 72a04a9b9ed33c889d2e2b86f306c5be9f6cde35 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:44:57 +0200
4Subject: [PATCH 6/6] libiniparser: remove unused function needing float
5
6Fixes:
7| LD ubi-utils/ubiformat
8| .../git/ubi-utils/libiniparser.a(libiniparser.o): In function
9| ` LD ubi-utils/ubirename
10| iniparser_getdouble':
11| .../git/ubi-utils/libiniparser.c:336: undefined reference to `atof'
12
13Grep doesn't reveal any occurrence of iniparser_getdouble(), using atof() so
14remove it: floating-point is not supported in klibc
15
16Upstream-Status: Pending
17
18Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
19---
20 ubi-utils/include/libiniparser.h | 15 ---------------
21 ubi-utils/libiniparser.c | 22 ----------------------
22 2 files changed, 37 deletions(-)
23
24diff --git a/ubi-utils/include/libiniparser.h b/ubi-utils/include/libiniparser.h
25index be3c667..abd77aa 100644
26--- a/ubi-utils/include/libiniparser.h
27+++ b/ubi-utils/include/libiniparser.h
28@@ -158,21 +158,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound);
29
30 /*-------------------------------------------------------------------------*/
31 /**
32- @brief Get the string associated to a key, convert to a double
33- @param d Dictionary to search
34- @param key Key string to look for
35- @param notfound Value to return in case of error
36- @return double
37-
38- This function queries a dictionary for a key. A key as read from an
39- ini file is given as "section:key". If the key cannot be found,
40- the notfound value is returned.
41- */
42-/*--------------------------------------------------------------------------*/
43-double iniparser_getdouble(dictionary * d, char * key, double notfound);
44-
45-/*-------------------------------------------------------------------------*/
46-/**
47 @brief Get the string associated to a key, convert to a boolean
48 @param d Dictionary to search
49 @param key Key string to look for
50diff --git a/ubi-utils/libiniparser.c b/ubi-utils/libiniparser.c
51index 898f57f..ba70c08 100644
52--- a/ubi-utils/libiniparser.c
53+++ b/ubi-utils/libiniparser.c
54@@ -316,28 +316,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound)
55
56 /*-------------------------------------------------------------------------*/
57 /**
58- @brief Get the string associated to a key, convert to a double
59- @param d Dictionary to search
60- @param key Key string to look for
61- @param notfound Value to return in case of error
62- @return double
63-
64- This function queries a dictionary for a key. A key as read from an
65- ini file is given as "section:key". If the key cannot be found,
66- the notfound value is returned.
67- */
68-/*--------------------------------------------------------------------------*/
69-double iniparser_getdouble(dictionary * d, char * key, double notfound)
70-{
71- char * str ;
72-
73- str = iniparser_getstring(d, key, INI_INVALID_KEY);
74- if (str==INI_INVALID_KEY) return notfound ;
75- return atof(str);
76-}
77-
78-/*-------------------------------------------------------------------------*/
79-/**
80 @brief Get the string associated to a key, convert to a boolean
81 @param d Dictionary to search
82 @param key Key string to look for
83--
841.9.1
85