Skip to content

Commit

Permalink
tools/mkimage: Update U-Boot to version 2019.07
Browse files Browse the repository at this point in the history
This updates the U-Boot which provides the host tools like mkimage to
version 2019.07.
The patches were cleaned up and it was checked if this still compiles
on Linux and FreeBSD.

CONFIG_FIT_SIGNATURE_MAX_SIZE is set to the default value.

The patch for libressl was merged upstream.

Signed-off-by: Hauke Mehrtens <[email protected]>
  • Loading branch information
hauke committed Sep 4, 2019
1 parent 662394f commit 169152c
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 159 deletions.
6 changes: 4 additions & 2 deletions tools/mkimage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=mkimage
PKG_VERSION:=2018.03
PKG_VERSION:=2019.07

PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://ftp.denx.de/pub/u-boot
PKG_HASH:=7e7477534409d5368eb1371ffde6820f0f79780a1a1f676161c48442cb303dfd
PKG_HASH:=bff4fa77e8da17521c030ca4c5b947a056c1b1be4d3e6ee8637020b8d50251d0

HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)

Expand All @@ -29,7 +29,9 @@ define Host/Compile
HOSTLDFLAGS="$(HOST_LDFLAGS)" \
no-dot-config-targets=tools-only \
CONFIG_MKIMAGE_DTC_PATH=dtc \
CONFIG_FIT=y \
CONFIG_FIT_SIGNATURE=y \
CONFIG_FIT_SIGNATURE_MAX_SIZE=0x10000000 \
tools-only
endef

Expand Down
13 changes: 0 additions & 13 deletions tools/mkimage/patches/010-freebsd-ulong-fix.patch

This file was deleted.

10 changes: 0 additions & 10 deletions tools/mkimage/patches/020-include_compile_fix.patch

This file was deleted.

18 changes: 10 additions & 8 deletions tools/mkimage/patches/030-allow-to-use-different-magic.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
This patch makes it possible to set a custom image magic.

--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -21,6 +21,7 @@ static struct image_tool_params params =
@@ -20,6 +20,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 = "",
@@ -77,11 +78,12 @@ static void usage(const char *msg)
@@ -76,11 +77,12 @@ static void usage(const char *msg)
" -l ==> list image header information\n",
params.cmdname);
fprintf(stderr,
Expand All @@ -22,7 +24,7 @@
" -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
@@ -143,7 +145,7 @@ static void process_args(int argc, char
int opt;

while ((opt = getopt(argc, argv,
Expand All @@ -31,7 +33,7 @@
switch (opt) {
case 'a':
params.addr = strtoull(optarg, &ptr, 16);
@@ -222,6 +224,14 @@ static void process_args(int argc, char
@@ -221,6 +223,14 @@ static void process_args(int argc, char
case 'l':
params.lflag = 1;
break;
Expand All @@ -48,18 +50,18 @@
break;
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -106,7 +106,7 @@ static void image_set_header(void *ptr,
imagesize = sbuf->st_size - sizeof(image_header_t);
@@ -116,7 +116,7 @@ static void image_set_header(void *ptr,
}

/* Build new header */
- image_set_magic(hdr, IH_MAGIC);
+ image_set_magic(hdr, params->magic);
image_set_time(hdr, time);
image_set_size(hdr, imagesize);
image_set_load(hdr, params->addr);
image_set_load(hdr, addr);
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -54,6 +54,7 @@ struct image_tool_params {
@@ -53,6 +53,7 @@ struct image_tool_params {
int arch;
int type;
int comp;
Expand Down
182 changes: 179 additions & 3 deletions tools/mkimage/patches/050-image_h_portability.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
Some of the Linux header files are not available on non Linux host
systems like FreeBSD or MacOSX.

The __le32 and __be32 types are only defined in Linux in
asm/byteorder.h, but not on all other BSD systems.
Use uint32_t instead of __le32 and __be32.

__swab32 is also a Linux only function, it looks like be32_to_cpu()
would be better here anyway.

--- a/include/image.h
+++ b/include/image.h
@@ -17,7 +17,6 @@
@@ -16,7 +16,6 @@
#define __IMAGE_H__

#include "compiler.h"
-#include <asm/byteorder.h>
#include <stdbool.h>

/* Define this to avoid #ifdefs later on */
struct lmb;
@@ -308,13 +307,13 @@ enum {
@@ -317,13 +316,13 @@ enum {
* all data in network byte order (aka natural aka bigendian).
*/
typedef struct image_header {
Expand All @@ -29,3 +39,169 @@
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
--- a/tools/mtk_image.h
+++ b/tools/mtk_image.h
@@ -15,8 +15,8 @@
union gen_boot_header {
struct {
char name[12];
- __le32 version;
- __le32 size;
+ uint32_t version;
+ uint32_t size;
};

uint8_t pad[0x200];
@@ -32,14 +32,14 @@ union nand_boot_header {
char name[12];
char version[4];
char id[8];
- __le16 ioif;
- __le16 pagesize;
- __le16 addrcycles;
- __le16 oobsize;
- __le16 pages_of_block;
- __le16 numblocks;
- __le16 writesize_shift;
- __le16 erasesize_shift;
+ uint16_t ioif;
+ uint16_t pagesize;
+ uint16_t addrcycles;
+ uint16_t oobsize;
+ uint16_t pages_of_block;
+ uint16_t numblocks;
+ uint16_t writesize_shift;
+ uint16_t erasesize_shift;
uint8_t dummy[60];
uint8_t ecc_parity[28];
};
@@ -54,14 +54,14 @@ union nand_boot_header {
/* BootROM layout header */
struct brom_layout_header {
char name[8];
- __le32 version;
- __le32 header_size;
- __le32 total_size;
- __le32 magic;
- __le32 type;
- __le32 header_size_2;
- __le32 total_size_2;
- __le32 unused;
+ uint32_t version;
+ uint32_t header_size;
+ uint32_t total_size;
+ uint32_t magic;
+ uint32_t type;
+ uint32_t header_size_2;
+ uint32_t total_size_2;
+ uint32_t unused;
};

#define BRLYT_NAME "BRLYT"
@@ -90,8 +90,8 @@ struct gen_device_header {
struct gfh_common_header {
uint8_t magic[3];
uint8_t version;
- __le16 size;
- __le16 type;
+ uint16_t size;
+ uint16_t type;
};

#define GFH_HEADER_MAGIC "MMM"
@@ -106,17 +106,17 @@ struct gfh_common_header {
struct gfh_file_info {
struct gfh_common_header gfh;
char name[12];
- __le32 unused;
- __le16 file_type;
+ uint32_t unused;
+ uint16_t file_type;
uint8_t flash_type;
uint8_t sig_type;
- __le32 load_addr;
- __le32 total_size;
- __le32 max_size;
- __le32 hdr_size;
- __le32 sig_size;
- __le32 jump_offset;
- __le32 processed;
+ uint32_t load_addr;
+ uint32_t total_size;
+ uint32_t max_size;
+ uint32_t hdr_size;
+ uint32_t sig_size;
+ uint32_t jump_offset;
+ uint32_t processed;
};

#define GFH_FILE_INFO_NAME "FILE_INFO"
@@ -129,16 +129,16 @@ struct gfh_file_info {

struct gfh_bl_info {
struct gfh_common_header gfh;
- __le32 attr;
+ uint32_t attr;
};

struct gfh_brom_cfg {
struct gfh_common_header gfh;
- __le32 cfg_bits;
- __le32 usbdl_by_auto_detect_timeout_ms;
+ uint32_t cfg_bits;
+ uint32_t usbdl_by_auto_detect_timeout_ms;
uint8_t unused[0x48];
- __le32 usbdl_by_kcol0_timeout_ms;
- __le32 usbdl_by_flag_timeout_ms;
+ uint32_t usbdl_by_kcol0_timeout_ms;
+ uint32_t usbdl_by_flag_timeout_ms;
uint32_t pad;
};

@@ -157,15 +157,15 @@ struct gfh_anti_clone {
uint8_t ac_b2k;
uint8_t ac_b2c;
uint16_t pad;
- __le32 ac_offset;
- __le32 ac_len;
+ uint32_t ac_offset;
+ uint32_t ac_len;
};

struct gfh_brom_sec_cfg {
struct gfh_common_header gfh;
- __le32 cfg_bits;
+ uint32_t cfg_bits;
char customer_name[0x20];
- __le32 pad;
+ uint32_t pad;
};

#define BROM_SEC_CFG_JTAG_EN 1
@@ -184,11 +184,11 @@ struct gfh_header {

union lk_hdr {
struct {
- __le32 magic;
- __le32 size;
+ uint32_t magic;
+ uint32_t size;
char name[32];
- __le32 loadaddr;
- __le32 mode;
+ uint32_t loadaddr;
+ uint32_t mode;
};

uint8_t data[512];
--- a/tools/zynqmpbif.c
+++ b/tools/zynqmpbif.c
@@ -517,7 +517,7 @@ static int bif_add_bit(struct bif_entry
debug("Bitstream Length: 0x%x\n", bitlen);
for (i = 0; i < bitlen; i += sizeof(uint32_t)) {
uint32_t *bitbin32 = (uint32_t *)&bitbin[i];
- *bitbin32 = __swab32(*bitbin32);
+ *bitbin32 = be32_to_cpu(*bitbin32);
}

if (!bf->dest_dev)
38 changes: 16 additions & 22 deletions tools/mkimage/patches/060-remove_kernel_includes.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -66,6 +66,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) | \
The Kernel includes are only available on Linux hosts, remove then on
non Linux hosts.

--- a/include/linux/posix_types.h
+++ b/include/linux/posix_types.h
@@ -43,6 +43,8 @@ typedef void (*__kernel_sighandler_t)(in
Expand All @@ -23,13 +12,18 @@
+#endif

#endif /* _LINUX_POSIX_TYPES_H */
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -2,7 +2,6 @@
#define _LINUX_TYPES_H
--- a/include/imx8image.h
+++ b/include/imx8image.h
@@ -11,7 +11,12 @@
#include <image.h>
#include <inttypes.h>
#include "imagetool.h"
+#ifdef linux
#include "linux/kernel.h"
+#else
+#define ALIGN(x,a) __ALIGN_MASK((x),(typeof(x))(a)-1)
+#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
+#endif

#include <linux/posix_types.h>
-#include <asm/types.h>
#include <stdbool.h>
#define __packed __attribute__((packed))

#ifndef __KERNEL_STRICT_NAMES
16 changes: 0 additions & 16 deletions tools/mkimage/patches/080-remove_compiler_check.patch

This file was deleted.

14 changes: 0 additions & 14 deletions tools/mkimage/patches/100-freebsd-compat.patch

This file was deleted.

Loading

0 comments on commit 169152c

Please sign in to comment.