tools/mkimage: update to 2020.04

also change the download source to https and add a mirror
drop merged patches

Signed-off-by: Lucian Cristian <lucian.cristian@gmail.com>
[Add extra changes to compile on FreeBSD, merge two patches]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Lucian Cristian 2020-04-19 16:07:10 +03:00 committed by Hauke Mehrtens
parent 066ec97167
commit 042917f1c4
7 changed files with 113 additions and 241 deletions

View File

@ -7,11 +7,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mkimage
PKG_VERSION:=2019.07
PKG_VERSION:=2020.04
PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://ftp.denx.de/pub/u-boot
PKG_HASH:=bff4fa77e8da17521c030ca4c5b947a056c1b1be4d3e6ee8637020b8d50251d0
PKG_SOURCE_URL:= \
https://mirror.cyberbits.eu/u-boot \
https://ftp.denx.de/pub/u-boot \
ftp://ftp.denx.de/pub/u-boot
PKG_HASH:=fe732aaf037d9cc3c0909bad8362af366ae964bbdac6913a34081ff4ad565372
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)

View File

@ -50,7 +50,7 @@ This patch makes it possible to set a custom image magic.
break;
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -116,7 +116,7 @@ static void image_set_header(void *ptr,
@@ -120,7 +120,7 @@ static void image_set_header(void *ptr,
}
/* Build new header */

View File

@ -0,0 +1,95 @@
From 590b23a46b7ae0f5ec5e8f57a85c0e7578c71141 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sun, 26 Apr 2020 17:15:17 +0200
Subject: [PATCH 1/2] Add compatibility with non Linux hosts
This adds some changes to the u-boot tools to make it possible to build
them on non Linux hosts like MacOS or FreeBSD.
asm/byteorder.h, asm/posix_types.h, asm/types.h and linux/kernel.h are
not available on such systems. Remove the include and add the necessary
parts for these header files manually or remove the usage too.
__u64 is not available on FreeBSD, remove its usage.
<malloc.h> has been replaced by <stdlib.h>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/image.h | 2 ++
include/imx8image.h | 5 +++++
include/linux/posix_types.h | 2 ++
include/linux/types.h | 4 +++-
lib/rsa/rsa-sign.c | 2 +-
5 files changed, 13 insertions(+), 2 deletions(-)
--- a/include/image.h
+++ b/include/image.h
@@ -16,7 +16,9 @@
#define __IMAGE_H__
#include "compiler.h"
+#ifdef linux
#include <asm/byteorder.h>
+#endif
#include <stdbool.h>
/* Define this to avoid #ifdefs later on */
--- 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
#define __packed __attribute__((packed))
--- 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,9 @@
#define _LINUX_TYPES_H
#include <linux/posix_types.h>
+#ifdef linux
#include <asm/types.h>
+#endif
#include <stdbool.h>
#ifndef __KERNEL_STRICT_NAMES
@@ -142,7 +144,7 @@ typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
typedef __u32 __bitwise __be32;
-#if defined(__GNUC__)
+#if defined(__GNUC__) && defined(linux)
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;
#endif
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -4,7 +4,7 @@
*/
#include "mkimage.h"
-#include <malloc.h>
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <image.h>

View File

@ -1,207 +0,0 @@
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
@@ -16,7 +16,6 @@
#define __IMAGE_H__
#include "compiler.h"
-#include <asm/byteorder.h>
#include <stdbool.h>
/* Define this to avoid #ifdefs later on */
@@ -317,13 +316,13 @@ enum {
* 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 */
--- 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)

View File

@ -1,29 +0,0 @@
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
/* 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/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
#define __packed __attribute__((packed))

View File

@ -0,0 +1,10 @@
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -11,7 +11,6 @@
#include "imagetool.h"
#include <image.h>
#include "imximage.h"
-#include <generated/autoconf.h>
#define UNDEFINED 0xFFFFFFFF

View File

@ -3,7 +3,7 @@ needed dependencies are added too.
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -151,7 +151,7 @@ ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CON
@@ -162,7 +162,7 @@ ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CON
HOSTCFLAGS_kwbimage.o += \
$(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
HOSTLOADLIBES_mkimage += \