Skip to contentSkip to conversation

tools: Remove the out-of-date MinGW support codes

PATCH New Bin Meng 2 participants 6 messages Apr 18, 2020 – Apr 24, 2020

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/3 tools: Remove the out-of-date MinGW support codes

From: Bin Meng <[email protected]>

MinGW build for U-Boot tools has been broken for years. The official support of Windows build is now MSYS2. Remove the MinGW support codes.

---

 README                |  10 -----
 tools/mingw_support.c | 113 --------------------------------------------------
 tools/mingw_support.h |  45 --------------------
 tools/os_support.c    |   7 ++--
 tools/os_support.h    |   3 --
 5 files changed, 3 insertions(+), 175 deletions(-)
 delete mode 100644 tools/mingw_support.c
 delete mode 100644 tools/mingw_support.h
README +0 -10
index 19dae14..d0af6c6 100644
@@ -3186,16 +3186,6 @@ necessary. For example using the ELDK on a 4xx CPU, please enter:
 	$ CROSS_COMPILE=ppc_4xx-
 	$ export CROSS_COMPILE
 
-Note: If you wish to generate Windows versions of the utilities in
-      the tools directory you can use the MinGW toolchain
-      (http://www.mingw.org).  Set your HOST tools to the MinGW
-      toolchain and execute 'make tools'.  For example:
-
-       $ make HOSTCC=i586-mingw32msvc-gcc HOSTSTRIP=i586-mingw32msvc-strip tools
-
-      Binaries such as tools/mkimage.exe will be created which can
-      be executed on computers running Windows.
-
 U-Boot is intended to be simple to build. After installing the
 sources you must configure U-Boot for one specific board type. This
 is done by typing:
tools/mingw_support.c deleted +0 -113

113 lines not on this page · raw message

tools/mingw_support.h deleted +0 -45

45 lines not on this page · raw message

tools/os_support.c +3 -4
index 21e43c8..6890c31 100644
@@ -3,13 +3,12 @@
  * Copyright 2009 Extreme Engineering Solutions, Inc.
  */
 
+#include "compiler.h"
+
 /*
  * Include additional files required for supporting different operating systems
  */
-#include "compiler.h"
-#ifdef __MINGW32__
-#include "mingw_support.c"
-#endif
+
 #if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
 #include "getline.c"
 #endif
tools/os_support.h +0 -3
index 3a2106e..471d605 100644
@@ -11,9 +11,6 @@
 /*
  * Include additional files required for supporting different operating systems
  */
-#ifdef __MINGW32__
-#include "mingw_support.h"
-#endif
 
 #if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L
 #include "getline.h"
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/3 mkimage: fit: Unmmap the memory before closing fd in fit_import_data()

From: Lihua Zhao <[email protected]>

Without calling munmap(), the follow-up call to open() the same file with a flag O_TRUNC seems not to cause any issue on Linux, but it fails on Windows with error like below:

Can't open kernel_fdt.itb.tmp: Permission denied

Fix this by unmapping the memory before closing fd in fit_import_data().

---

 tools/fit_image.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
tools/fit_image.c +14 -10
index dd61a81..05c1f00 100644
@@ -556,21 +556,21 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
 		fprintf(stderr, "%s: Failed to allocate memory (%d bytes)\n",
 			__func__, size);
 		ret = -ENOMEM;
-		goto err_has_fd;
+		goto err_munmap;
 	}
 	ret = fdt_open_into(old_fdt, fdt, size);
 	if (ret) {
 		debug("%s: Failed to expand FIT: %s\n", __func__,
 		      fdt_strerror(errno));
 		ret = -EINVAL;
-		goto err_has_fd;
+		goto err_munmap;
 	}
 
 	images = fdt_path_offset(fdt, FIT_IMAGES_PATH);
 	if (images < 0) {
 		debug("%s: Cannot find /images node: %d\n", __func__, images);
 		ret = -EINVAL;
-		goto err_has_fd;
+		goto err_munmap;
 	}
 
 	for (node = fdt_first_subnode(fdt, images);
@@ -591,10 +591,12 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
 			debug("%s: Failed to write property: %s\n", __func__,
 			      fdt_strerror(ret));
 			ret = -EINVAL;
-			goto err_has_fd;
+			goto err_munmap;
 		}
 	}
 
+	munmap(old_fdt, sbuf.st_size);
+
 	/* Close the old fd so we can re-use it. */
 	close(fd);
 
@@ -609,22 +611,24 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
 		fprintf(stderr, "%s: Can't open %s: %s\n",
 			params->cmdname, fname, strerror(errno));
 		ret = -EIO;
-		goto err_no_fd;
+		goto err;
 	}
 	if (write(fd, fdt, new_size) != new_size) {
 		debug("%s: Failed to write external data to file %s\n",
 		      __func__, strerror(errno));
 		ret = -EIO;
-		goto err_has_fd;
+		goto err;
 	}
 
-	ret = 0;
-
-err_has_fd:
+	free(fdt);
 	close(fd);
-err_no_fd:
+	return 0;
+
+err_munmap:
 	munmap(old_fdt, sbuf.st_size);
+err:
 	free(fdt);
+	close(fd);
 	return ret;
 }
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 mkimage: fit: Unmmap the memory before closing fd in fit_import_data()

Quoted 6 lines · Bin Meng

From: Lihua Zhao <[email protected]>

Without calling munmap(), the follow-up call to open() the same file with a flag O_TRUNC seems not to cause any issue on Linux, but it fails on Windows with error like below:

Quoted 6 lines

Can't open kernel_fdt.itb.tmp: Permission denied

Fix this by unmapping the memory before closing fd in fit_import_data().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/9d19af36/attachment.sig>
author
#3 lore raw

PATCH 3/3 mkimage: fit: Free buf directly in fit_extract_data()

In reply to Bin Meng

From: Bin Meng <[email protected]>

If given ptr to free() is NULL, no operation is performed. Hence we can just free buf directly in fit_extract_data().

---

 tools/fit_image.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/fit_image.c +1 -2
index 05c1f00..965061d 100644
@@ -527,8 +527,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
 err_munmap:
 	munmap(fdt, sbuf.st_size);
 err:
-	if (buf)
-		free(buf);
+	free(buf);
 	close(fd);
 	return ret;
 }
Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/3 mkimage: fit: Free buf directly in fit_extract_data()

Quoted 6 lines · Bin Meng

From: Bin Meng <[email protected]>

If given ptr to free() is NULL, no operation is performed. Hence we can just free buf directly in fit_extract_data().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/dc491123/attachment.sig>
#5 lore raw

PATCH 1/3 tools: Remove the out-of-date MinGW support codes

In reply to Bin Meng
Quoted 6 lines · Bin Meng

From: Bin Meng <[email protected]>

MinGW build for U-Boot tools has been broken for years. The official support of Windows build is now MSYS2. Remove the MinGW support codes.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/9777e8c3/attachment.sig>