aboutsummaryrefslogtreecommitdiffstats
path: root/tools/mkimage
diff options
context:
space:
mode:
authorJames <>2015-11-04 11:49:21 +0000
committerJames <>2015-11-04 11:49:21 +0000
commit716ca530e1c4515d8683c9d5be3d56b301758b66 (patch)
tree700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /tools/mkimage
downloadtrunk-47381-master.tar.gz
trunk-47381-master.tar.bz2
trunk-47381-master.zip
trunk-47381HEADmaster
Diffstat (limited to 'tools/mkimage')
-rw-r--r--tools/mkimage/Makefile46
-rw-r--r--tools/mkimage/patches/010-freebsd-ulong-fix.patch13
-rw-r--r--tools/mkimage/patches/020-include_compile_fix.patch10
-rw-r--r--tools/mkimage/patches/030-allow-to-use-different-magic.patch63
-rw-r--r--tools/mkimage/patches/040-include_order.patch11
-rw-r--r--tools/mkimage/patches/050-image_h_portability.patch31
-rw-r--r--tools/mkimage/patches/060-remove_kernel_includes.patch35
-rw-r--r--tools/mkimage/patches/070-socfpgaimage_portability.patch52
-rw-r--r--tools/mkimage/patches/080-remove_compiler_check.patch16
-rw-r--r--tools/mkimage/patches/100-freebsd-compat.patch14
-rw-r--r--tools/mkimage/patches/200-gcc5_compat.patch93
11 files changed, 384 insertions, 0 deletions
diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile
new file mode 100644
index 0000000..f73cc56
--- /dev/null
+++ b/tools/mkimage/Makefile
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mkimage
+PKG_VERSION:=2014.10
+
+PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=\
+ http://mirror2.openwrt.org/sources \
+ ftp://ftp.denx.de/pub/u-boot
+PKG_MD5SUM:=3ddcaee2f05b7c464778112ec83664b5
+PKG_CAT:=bzcat
+
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+define Host/Prepare
+ $(Host/Prepare/Default)
+ rm -f \
+ $(HOST_BUILD_DIR)/include/errno.h \
+ $(HOST_BUILD_DIR)/include/malloc.h \
+ $(HOST_BUILD_DIR)/tools/.depend
+ touch $(HOST_BUILD_DIR)/include/config.mk
+ touch $(HOST_BUILD_DIR)/include/config.h
+endef
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR) defconfig HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)"
+ $(MAKE) -C $(HOST_BUILD_DIR) tools-only HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)"
+endef
+
+define Host/Install
+ $(CP) $(HOST_BUILD_DIR)/tools/mkimage $(STAGING_DIR_HOST)/bin/
+endef
+
+define Host/Clean
+ rm -f $(STAGING_DIR_HOST)/bin/mkimage
+endef
+
+$(eval $(call HostBuild))
diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
new file mode 100644
index 0000000..75b9e89
--- /dev/null
+++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
@@ -0,0 +1,13 @@
+--- a/include/image.h
++++ b/include/image.h
+@@ -44,6 +44,10 @@
+
+ #endif /* USE_HOSTCC */
+
++#ifndef ulong
++#define ulong unsigned long
++#endif
++
+ #if defined(CONFIG_FIT)
+ #include <hash.h>
+ #include <libfdt.h>
diff --git a/tools/mkimage/patches/020-include_compile_fix.patch b/tools/mkimage/patches/020-include_compile_fix.patch
new file mode 100644
index 0000000..276cae0
--- /dev/null
+++ b/tools/mkimage/patches/020-include_compile_fix.patch
@@ -0,0 +1,10 @@
+--- a/include/u-boot/rsa-checksum.h
++++ b/include/u-boot/rsa-checksum.h
+@@ -7,7 +7,6 @@
+ #ifndef _RSA_CHECKSUM_H
+ #define _RSA_CHECKSUM_H
+
+-#include <errno.h>
+ #include <image.h>
+ #include <u-boot/sha1.h>
+ #include <u-boot/sha256.h>
diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
new file mode 100644
index 0000000..d5afdd3
--- /dev/null
+++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
@@ -0,0 +1,63 @@
+--- a/tools/mkimage.c
++++ b/tools/mkimage.c
+@@ -24,6 +24,7 @@
+ .arch = IH_ARCH_PPC,
+ .type = IH_TYPE_KERNEL,
+ .comp = IH_COMP_GZIP,
++ .magic = IH_MAGIC,
+ .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
+ .imagename = "",
+ .imagename2 = "",
+@@ -168,6 +169,16 @@
+ genimg_get_comp_id (*++argv)) < 0)
+ usage ();
+ goto NXTARG;
++ case 'M':
++ if (--argc <=0)
++ usage ();
++ params.magic = strtoul (*++argv, &ptr, 16);
++ if (*ptr) {
++ fprintf (stderr,
++ "%s: invalid magic %s\n",
++ params.cmdname, *argv);
++ }
++ goto NXTARG;
+ case 'D':
+ if (--argc <= 0)
+ usage ();
+@@ -623,12 +634,13 @@
+ fprintf (stderr, "Usage: %s -l image\n"
+ " -l ==> list image header information\n",
+ params.cmdname);
+- fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp "
++ fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp -M magic "
+ "-a addr -e ep -n name -d data_file[:data_file...] image\n"
+ " -A ==> set architecture to 'arch'\n"
+ " -O ==> set operating system to 'os'\n"
+ " -T ==> set image type to 'type'\n"
+ " -C ==> set compression type 'comp'\n"
++ " -M ==> set image magic to 'magic'\n"
+ " -a ==> set load address to 'addr' (hex)\n"
+ " -e ==> set entry point to 'ep' (hex)\n"
+ " -n ==> set image name to 'name'\n"
+--- a/tools/default_image.c
++++ b/tools/default_image.c
+@@ -98,7 +98,7 @@
+ sbuf->st_size - sizeof(image_header_t));
+
+ /* Build new header */
+- image_set_magic(hdr, IH_MAGIC);
++ image_set_magic(hdr, params->magic);
+ image_set_time(hdr, sbuf->st_mtime);
+ image_set_size(hdr, sbuf->st_size - sizeof(image_header_t));
+ image_set_load(hdr, params->addr);
+--- a/tools/imagetool.h
++++ b/tools/imagetool.h
+@@ -44,6 +44,7 @@
+ int arch;
+ int type;
+ int comp;
++ unsigned int magic;
+ char *dtc;
+ unsigned int addr;
+ unsigned int ep;
diff --git a/tools/mkimage/patches/040-include_order.patch b/tools/mkimage/patches/040-include_order.patch
new file mode 100644
index 0000000..3b9ecc6
--- /dev/null
+++ b/tools/mkimage/patches/040-include_order.patch
@@ -0,0 +1,11 @@
+--- a/tools/Makefile
++++ b/tools/Makefile
+@@ -194,7 +194,7 @@ endif # !LOGO_BMP
+ # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
+ #
+ HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
+- $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
++ -I$(srctree)/include \
+ -I$(srctree)/lib/libfdt \
+ -I$(srctree)/tools \
+ -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
diff --git a/tools/mkimage/patches/050-image_h_portability.patch b/tools/mkimage/patches/050-image_h_portability.patch
new file mode 100644
index 0000000..b3ad273
--- /dev/null
+++ b/tools/mkimage/patches/050-image_h_portability.patch
@@ -0,0 +1,31 @@
+--- a/include/image.h
++++ b/include/image.h
+@@ -17,7 +17,6 @@
+ #define __IMAGE_H__
+
+ #include "compiler.h"
+-#include <asm/byteorder.h>
+
+ /* Define this to avoid #ifdefs later on */
+ struct lmb;
+@@ -258,13 +257,13 @@ struct lmb;
+ * all data in network byte order (aka natural aka bigendian).
+ */
+ typedef struct image_header {
+- __be32 ih_magic; /* Image Header Magic Number */
+- __be32 ih_hcrc; /* Image Header CRC Checksum */
+- __be32 ih_time; /* Image Creation Timestamp */
+- __be32 ih_size; /* Image Data Size */
+- __be32 ih_load; /* Data Load Address */
+- __be32 ih_ep; /* Entry Point Address */
+- __be32 ih_dcrc; /* Image Data CRC Checksum */
++ uint32_t ih_magic; /* Image Header Magic Number */
++ uint32_t ih_hcrc; /* Image Header CRC Checksum */
++ uint32_t ih_time; /* Image Creation Timestamp */
++ uint32_t ih_size; /* Image Data Size */
++ uint32_t ih_load; /* Data Load Address */
++ uint32_t ih_ep; /* Entry Point Address */
++ uint32_t ih_dcrc; /* Image Data CRC Checksum */
+ uint8_t ih_os; /* Operating System */
+ uint8_t ih_arch; /* CPU architecture */
+ uint8_t ih_type; /* Image Type */
diff --git a/tools/mkimage/patches/060-remove_kernel_includes.patch b/tools/mkimage/patches/060-remove_kernel_includes.patch
new file mode 100644
index 0000000..fa533cd
--- /dev/null
+++ b/tools/mkimage/patches/060-remove_kernel_includes.patch
@@ -0,0 +1,35 @@
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -58,6 +58,11 @@ typedef uint8_t __u8;
+ typedef uint16_t __u16;
+ typedef uint32_t __u32;
+ typedef unsigned int uint;
++typedef uint64_t __u64;
++#ifndef linux
++typedef int __kernel_daddr_t;
++typedef unsigned int __kernel_ino_t;
++#endif
+
+ #define uswap_16(x) \
+ ((((x) & 0xff00) >> 8) | \
+--- a/include/linux/posix_types.h
++++ b/include/linux/posix_types.h
+@@ -43,6 +43,8 @@ typedef void (*__kernel_sighandler_t)(in
+ /* Type of a SYSV IPC key. */
+ typedef int __kernel_key_t;
+
++#ifdef linux
+ #include <asm/posix_types.h>
++#endif
+
+ #endif /* _LINUX_POSIX_TYPES_H */
+--- a/include/linux/types.h
++++ b/include/linux/types.h
+@@ -2,7 +2,6 @@
+ #define _LINUX_TYPES_H
+
+ #include <linux/posix_types.h>
+-#include <asm/types.h>
+ #include <stdbool.h>
+
+ #ifndef __KERNEL_STRICT_NAMES
diff --git a/tools/mkimage/patches/070-socfpgaimage_portability.patch b/tools/mkimage/patches/070-socfpgaimage_portability.patch
new file mode 100644
index 0000000..e273c27
--- /dev/null
+++ b/tools/mkimage/patches/070-socfpgaimage_portability.patch
@@ -0,0 +1,52 @@
+--- a/tools/socfpgaimage.c
++++ b/tools/socfpgaimage.c
+@@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socf
+ static void build_header(uint8_t *buf, uint8_t version, uint8_t flags,
+ uint16_t length_bytes)
+ {
+- header.validation = htole32(VALIDATION_WORD);
++ header.validation = cpu_to_le32(VALIDATION_WORD);
+ header.version = version;
+ header.flags = flags;
+- header.length_u32 = htole16(length_bytes/4);
++ header.length_u32 = cpu_to_le16(length_bytes/4);
+ header.zero = 0;
+- header.checksum = htole16(hdr_checksum(&header));
++ header.checksum = cpu_to_le16(hdr_checksum(&header));
+
+ memcpy(buf, &header, sizeof(header));
+ }
+@@ -92,12 +92,12 @@ static int verify_header(const uint8_t *
+ {
+ memcpy(&header, buf, sizeof(header));
+
+- if (le32toh(header.validation) != VALIDATION_WORD)
++ if (le32_to_cpu(header.validation) != VALIDATION_WORD)
+ return -1;
+- if (le16toh(header.checksum) != hdr_checksum(&header))
++ if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
+ return -1;
+
+- return le16toh(header.length_u32) * 4;
++ return le16_to_cpu(header.length_u32) * 4;
+ }
+
+ /* Sign the buffer and return the signed buffer size */
+@@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf,
+ /* Calculate and apply the CRC */
+ calc_crc = ~pbl_crc32(0, (char *)buf, len);
+
+- *((uint32_t *)(buf + len)) = htole32(calc_crc);
++ *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
+
+ if (!pad_64k)
+ return len + 4;
+@@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *
+
+ calc_crc = ~pbl_crc32(0, (const char *)buf, len);
+
+- buf_crc = le32toh(*((uint32_t *)(buf + len)));
++ buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
+
+ if (buf_crc != calc_crc) {
+ fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",
diff --git a/tools/mkimage/patches/080-remove_compiler_check.patch b/tools/mkimage/patches/080-remove_compiler_check.patch
new file mode 100644
index 0000000..3e71ad5
--- /dev/null
+++ b/tools/mkimage/patches/080-remove_compiler_check.patch
@@ -0,0 +1,16 @@
+--- a/include/linux/compiler-gcc4.h
++++ b/include/linux/compiler-gcc4.h
+@@ -2,13 +2,6 @@
+ #error "Please don't include <linux/compiler-gcc4.h> directly, include <linux/compiler.h> instead."
+ #endif
+
+-/* GCC 4.1.[01] miscompiles __weak */
+-#ifdef __KERNEL__
+-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
+-# error Your version of gcc miscompiles the __weak directive
+-# endif
+-#endif
+-
+ #define __used __attribute__((__used__))
+ #define __must_check __attribute__((warn_unused_result))
+ #define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
diff --git a/tools/mkimage/patches/100-freebsd-compat.patch b/tools/mkimage/patches/100-freebsd-compat.patch
new file mode 100644
index 0000000..e014af5
--- /dev/null
+++ b/tools/mkimage/patches/100-freebsd-compat.patch
@@ -0,0 +1,14 @@
+--- a/Makefile
++++ b/Makefile
+@@ -584,7 +584,10 @@ UBOOTINCLUDE := \
+ -I$(srctree)/arch/$(ARCH)/include \
+ -include $(srctree)/include/linux/kconfig.h
+
+-NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
++ifneq ($(shell uname),FreeBSD)
++ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
++endif
++
+ CHECKFLAGS += $(NOSTDINC_FLAGS)
+
+ # FIX ME
diff --git a/tools/mkimage/patches/200-gcc5_compat.patch b/tools/mkimage/patches/200-gcc5_compat.patch
new file mode 100644
index 0000000..4d55f00
--- /dev/null
+++ b/tools/mkimage/patches/200-gcc5_compat.patch
@@ -0,0 +1,93 @@
+From 478b02f1a7043b673565075ea5016376f3293b23 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede@redhat.com>
+Date: Sat, 7 Feb 2015 22:52:40 +0100
+Subject: [PATCH] Add linux/compiler-gcc5.h to fix builds with gcc5
+
+Add linux/compiler-gcc5/h from the kernel sources at:
+
+commit 5631b8fba640a4ab2f8a954f63a603fa34eda96b
+Author: Steven Noonan <steven@uplinklabs.net>
+Date: Sat Oct 25 15:09:42 2014 -0700
+
+ compiler/gcc4+: Remove inaccurate comment about 'asm goto' miscompiles
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+---
+ include/linux/compiler-gcc5.h | 65 +++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 65 insertions(+)
+ create mode 100644 include/linux/compiler-gcc5.h
+
+diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
+new file mode 100644
+index 0000000..c8c5659
+--- /dev/null
++++ b/include/linux/compiler-gcc5.h
+@@ -0,0 +1,65 @@
++#ifndef __LINUX_COMPILER_H
++#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
++#endif
++
++#define __used __attribute__((__used__))
++#define __must_check __attribute__((warn_unused_result))
++#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
++
++/* Mark functions as cold. gcc will assume any path leading to a call
++ to them will be unlikely. This means a lot of manual unlikely()s
++ are unnecessary now for any paths leading to the usual suspects
++ like BUG(), printk(), panic() etc. [but let's keep them for now for
++ older compilers]
++
++ Early snapshots of gcc 4.3 don't support this and we can't detect this
++ in the preprocessor, but we can live with this because they're unreleased.
++ Maketime probing would be overkill here.
++
++ gcc also has a __attribute__((__hot__)) to move hot functions into
++ a special section, but I don't see any sense in this right now in
++ the kernel context */
++#define __cold __attribute__((__cold__))
++
++#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
++
++#ifndef __CHECKER__
++# define __compiletime_warning(message) __attribute__((warning(message)))
++# define __compiletime_error(message) __attribute__((error(message)))
++#endif /* __CHECKER__ */
++
++/*
++ * Mark a position in code as unreachable. This can be used to
++ * suppress control flow warnings after asm blocks that transfer
++ * control elsewhere.
++ *
++ * Early snapshots of gcc 4.5 don't support this and we can't detect
++ * this in the preprocessor, but we can live with this because they're
++ * unreleased. Really, we need to have autoconf for the kernel.
++ */
++#define unreachable() __builtin_unreachable()
++
++/* Mark a function definition as prohibited from being cloned. */
++#define __noclone __attribute__((__noclone__))
++
++/*
++ * Tell the optimizer that something else uses this function or variable.
++ */
++#define __visible __attribute__((externally_visible))
++
++/*
++ * GCC 'asm goto' miscompiles certain code sequences:
++ *
++ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
++ *
++ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
++ *
++ * (asm goto is automatically volatile - the naming reflects this.)
++ */
++#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
++
++#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
++#define __HAVE_BUILTIN_BSWAP32__
++#define __HAVE_BUILTIN_BSWAP64__
++#define __HAVE_BUILTIN_BSWAP16__
++#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
+--
+1.7.10.4
+