Skip to content

Commit

Permalink
tools/mkimage: update to version 2018.03
Browse files Browse the repository at this point in the history
This activates support for fit images and some other new mkimage
features. Some of the patches were applied upstream and could be
removed.

Signed-off-by: Hauke Mehrtens <[email protected]>
  • Loading branch information
hauke committed Apr 18, 2018
1 parent 68150d3 commit b13e981
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 1,071 deletions.
21 changes: 10 additions & 11 deletions tools/mkimage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=mkimage
PKG_VERSION:=2014.10
PKG_VERSION:=2018.03

PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=\
http://mirror2.openwrt.org/sources \
ftp://ftp.denx.de/pub/u-boot
PKG_HASH:=d3b132a7a9b3f3182b7aad71c2dfbd4fc15bea83e12c76134eb3ffefc07d1c71
PKG_CAT:=bzcat
PKG_HASH:=7e7477534409d5368eb1371ffde6820f0f79780a1a1f676161c48442cb303dfd

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
mkdir -p $(HOST_BUILD_DIR)/include/config
touch $(HOST_BUILD_DIR)/include/config/auto.conf
endef

define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR) defconfig HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" HOST_LOADLIBES="$$$$(pkg-config --static --libs libcrypto)"
$(MAKE) -C $(HOST_BUILD_DIR) tools-only HOSTCFLAGS="$(HOST_CPPFLAGS) $(HOST_CFLAGS)" HOSTLDFLAGS="$(HOST_LDFLAGS)" HOST_LOADLIBES="$$$$(pkg-config --static --libs libcrypto)"
$(MAKE) -C $(HOST_BUILD_DIR) \
HOSTCFLAGS="$(HOST_CFLAGS)" \
HOSTLDFLAGS="$(HOST_LDFLAGS)" \
no-dot-config-targets=tools-only \
CONFIG_FIT_SIGNATURE=y \
tools-only
endef

define Host/Install
Expand Down
6 changes: 3 additions & 3 deletions tools/mkimage/patches/010-freebsd-ulong-fix.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
--- a/include/image.h
+++ b/include/image.h
@@ -44,6 +44,10 @@ struct lmb;
@@ -51,6 +51,10 @@ struct lmb;

#endif /* USE_HOSTCC */

+#ifndef ulong
+#define ulong unsigned long
+#endif
+
#if defined(CONFIG_FIT)
#if IMAGE_ENABLE_FIT
#include <hash.h>
#include <libfdt.h>
#include <linux/libfdt.h>
78 changes: 42 additions & 36 deletions tools/mkimage/patches/030-allow-to-use-different-magic.patch
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -24,6 +24,7 @@ struct image_tool_params params = {
@@ -21,6 +21,7 @@ static struct image_tool_params params =
.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 @@ main (int argc, char **argv)
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 @@ static void usage(void)
fprintf (stderr, "Usage: %s -l image\n"
@@ -77,11 +78,12 @@ static void usage(const char *msg)
" -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"
fprintf(stderr,
- " %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
+ " %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"
@@ -144,7 +146,7 @@ static void process_args(int argc, char
int opt;

while ((opt = getopt(argc, argv,
- "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
+ "a:A:b:c:C:d:D:e:Ef:Fk:i:K:lM:n:N:p:O:rR:qsT:vVx")) != -1) {
switch (opt) {
case 'a':
params.addr = strtoull(optarg, &ptr, 16);
@@ -222,6 +224,14 @@ static void process_args(int argc, char
case 'l':
params.lflag = 1;
break;
+ case 'M':
+ params.magic = strtoull(optarg, &ptr, 16);
+ if (*ptr) {
+ fprintf(stderr, "%s: invalid magic %s\n",
+ params.cmdname, optarg);
+ exit(EXIT_FAILURE);
+ }
+ break;
case 'n':
params.imagename = optarg;
break;
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -98,7 +98,7 @@ static void image_set_header(void *ptr,
sbuf->st_size - sizeof(image_header_t));
@@ -106,7 +106,7 @@ static void image_set_header(void *ptr,
imagesize = 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_time(hdr, time);
image_set_size(hdr, imagesize);
image_set_load(hdr, params->addr);
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -44,6 +44,7 @@ struct image_tool_params {
@@ -54,6 +54,7 @@ struct image_tool_params {
int arch;
int type;
int comp;
Expand Down
11 changes: 0 additions & 11 deletions tools/mkimage/patches/040-include_order.patch

This file was deleted.

2 changes: 1 addition & 1 deletion tools/mkimage/patches/050-image_h_portability.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Define this to avoid #ifdefs later on */
struct lmb;
@@ -258,13 +257,13 @@ struct lmb;
@@ -308,13 +307,13 @@ enum {
* all data in network byte order (aka natural aka bigendian).
*/
typedef struct image_header {
Expand Down
2 changes: 1 addition & 1 deletion tools/mkimage/patches/060-remove_kernel_includes.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -58,6 +58,11 @@ typedef uint8_t __u8;
@@ -66,6 +66,11 @@ typedef uint8_t __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef unsigned int uint;
Expand Down
52 changes: 0 additions & 52 deletions tools/mkimage/patches/070-socfpgaimage_portability.patch

This file was deleted.

14 changes: 7 additions & 7 deletions tools/mkimage/patches/080-remove_compiler_check.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--- 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
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -146,13 +146,6 @@

#if GCC_VERSION >= 40000

-/* GCC 4.1.[01] miscompiles __weak */
-#ifdef __KERNEL__
Expand All @@ -12,5 +12,5 @@
-#endif
-
#define __used __attribute__((__used__))
#define __must_check __attribute__((warn_unused_result))
#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
#define __compiler_offsetof(a, b) \
__builtin_offsetof(a, b)
82 changes: 0 additions & 82 deletions tools/mkimage/patches/090-reproducible-SOURCE_DATE_EPOCH.patch

This file was deleted.

2 changes: 1 addition & 1 deletion tools/mkimage/patches/100-freebsd-compat.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/Makefile
+++ b/Makefile
@@ -584,7 +584,10 @@ UBOOTINCLUDE := \
@@ -634,7 +634,10 @@ UBOOTINCLUDE := \
-I$(srctree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h

Expand Down
Loading

0 comments on commit b13e981

Please sign in to comment.