Initial commit

This commit is contained in:
domenico
2025-06-24 13:14:22 +02:00
commit 4002f145fc
9002 changed files with 1731834 additions and 0 deletions

53
tools/mkimage/Makefile Normal file
View File

@@ -0,0 +1,53 @@
#
# 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:=2021.01
PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
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:=b407e1510a74e863b8b5cb42a24625344f0e0c2fc7582d8c866bd899367d0454
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)
include $(INCLUDE_DIR)/host-build.mk
define Host/Prepare
$(Host/Prepare/Default)
mkdir -p $(HOST_BUILD_DIR)/include/config
touch $(HOST_BUILD_DIR)/include/config/auto.conf
mkdir -p $(HOST_BUILD_DIR)/include/generated/
touch $(HOST_BUILD_DIR)/include/generated/autoconf.h
endef
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR) \
HOSTCFLAGS="$(HOST_CFLAGS)" \
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
define Host/Install
$(CP) $(HOST_BUILD_DIR)/tools/mkimage $(STAGING_DIR_HOST)/bin/
$(CP) $(HOST_BUILD_DIR)/tools/mkenvimage $(STAGING_DIR_HOST)/bin/
endef
define Host/Clean
rm -f $(STAGING_DIR_HOST)/bin/mkimage
rm -f $(STAGING_DIR_HOST)/bin/mkenvimage
endef
$(eval $(call HostBuild))

View File

@@ -0,0 +1,71 @@
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 =
.arch = IH_ARCH_PPC,
.type = IH_TYPE_KERNEL,
.comp = IH_COMP_GZIP,
+ .magic = IH_MAGIC,
.dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
.imagename = "",
.imagename2 = "",
@@ -82,11 +83,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 -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"
@@ -150,7 +152,7 @@ static void process_args(int argc, char
int opt;
while ((opt = getopt(argc, argv,
- "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qstT:vVx")) != -1) {
+ "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:lM:n:N:p:O:rR:qstT:vVx")) != -1) {
switch (opt) {
case 'a':
params.addr = strtoull(optarg, &ptr, 16);
@@ -237,6 +239,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
@@ -120,7 +120,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, addr);
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -56,6 +56,7 @@ struct image_tool_params {
int arch;
int type;
int comp;
+ unsigned int magic;
char *dtc;
unsigned int addr;
unsigned int ep;

View File

@@ -0,0 +1,67 @@
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.
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/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

View File

@@ -0,0 +1,134 @@
From 44165e4c676d266f73fda2e6ba82b4bf3262daf2 Mon Sep 17 00:00:00 2001
From: Fabien Parent <fparent@baylibre.com>
Date: Fri, 16 Oct 2020 19:52:37 +0200
Subject: [PATCH] tools: mtk_image: add support for booting ARM64 images
mkimage is only able to package aarch32 binaries. Add support for
AArch64 images.
One can create a ARM64 image using the following command line:
mkimage -T mtk_image -a 0x201000 -e 0x201000 -n "media=emmc;arm64=1"
-d bl2.bin bl2.img
Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
tools/mtk_image.c | 28 ++++++++++++++++++++++++----
tools/mtk_image.h | 6 +++++-
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index 2ca519483d..bde1e5da4b 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -246,6 +246,7 @@ static const struct brom_img_type {
/* Image type selected by user */
static enum brlyt_img_type hdr_media;
static int use_lk_hdr;
+static bool is_arm64_image;
/* LK image name */
static char lk_name[32] = "U-Boot";
@@ -276,6 +277,7 @@ static int mtk_brom_parse_imagename(const char *imagename)
static const char *media = "";
static const char *nandinfo = "";
static const char *lk = "";
+ static const char *arm64_param = "";
key = buf;
while (key) {
@@ -323,6 +325,9 @@ static int mtk_brom_parse_imagename(const char *imagename)
if (!strcmp(key, "lkname"))
snprintf(lk_name, sizeof(lk_name), "%s", val);
+
+ if (!strcmp(key, "arm64"))
+ arm64_param = val;
}
if (next)
@@ -354,6 +359,9 @@ static int mtk_brom_parse_imagename(const char *imagename)
}
}
+ if (arm64_param && arm64_param[0] == '1')
+ is_arm64_image = true;
+
free(buf);
if (hdr_media == BRLYT_TYPE_INVALID) {
@@ -458,6 +466,9 @@ static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
le32_to_cpu(gfh->file_info.load_addr) +
le32_to_cpu(gfh->file_info.jump_offset));
+ if (print)
+ printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM");
+
return 0;
}
@@ -523,6 +534,9 @@ static int mtk_image_verify_nand_header(const uint8_t *ptr, int print)
le32_to_cpu(gfh->file_info.load_addr) +
le32_to_cpu(gfh->file_info.jump_offset));
+ if (print)
+ printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM");
+
return 0;
}
@@ -581,6 +595,8 @@ static void put_ghf_common_header(struct gfh_common_header *gfh, int size,
static void put_ghf_header(struct gfh_header *gfh, int file_size,
int dev_hdr_size, int load_addr, int flash_type)
{
+ uint32_t cfg_bits;
+
memset(gfh, 0, sizeof(struct gfh_header));
/* GFH_FILE_INFO header */
@@ -608,11 +624,15 @@ static void put_ghf_header(struct gfh_header *gfh, int file_size,
/* GFH_BROM_CFG header */
put_ghf_common_header(&gfh->brom_cfg.gfh, sizeof(gfh->brom_cfg),
GFH_TYPE_BROM_CFG, 3);
- gfh->brom_cfg.cfg_bits = cpu_to_le32(
- GFH_BROM_CFG_USBDL_AUTO_DETECT_DIS |
- GFH_BROM_CFG_USBDL_BY_KCOL0_TIMEOUT_EN |
- GFH_BROM_CFG_USBDL_BY_FLAG_TIMEOUT_EN);
+ cfg_bits = GFH_BROM_CFG_USBDL_AUTO_DETECT_DIS |
+ GFH_BROM_CFG_USBDL_BY_KCOL0_TIMEOUT_EN |
+ GFH_BROM_CFG_USBDL_BY_FLAG_TIMEOUT_EN;
gfh->brom_cfg.usbdl_by_kcol0_timeout_ms = cpu_to_le32(5000);
+ if (is_arm64_image) {
+ gfh->brom_cfg.jump_bl_arm64 = GFH_BROM_CFG_JUMP_BL_ARM64;
+ cfg_bits |= GFH_BROM_CFG_JUMP_BL_ARM64_EN;
+ }
+ gfh->brom_cfg.cfg_bits = cpu_to_le32(cfg_bits);
/* GFH_BL_SEC_KEY header */
put_ghf_common_header(&gfh->bl_sec_key.gfh, sizeof(gfh->bl_sec_key),
diff --git a/tools/mtk_image.h b/tools/mtk_image.h
index 4e78b3d0ff..7dda71ce88 100644
--- a/tools/mtk_image.h
+++ b/tools/mtk_image.h
@@ -136,7 +136,9 @@ struct gfh_brom_cfg {
struct gfh_common_header gfh;
uint32_t cfg_bits;
uint32_t usbdl_by_auto_detect_timeout_ms;
- uint8_t unused[0x48];
+ uint8_t unused[0x45];
+ uint8_t jump_bl_arm64;
+ uint8_t unused2[2];
uint32_t usbdl_by_kcol0_timeout_ms;
uint32_t usbdl_by_flag_timeout_ms;
uint32_t pad;
@@ -146,6 +148,8 @@ struct gfh_brom_cfg {
#define GFH_BROM_CFG_USBDL_AUTO_DETECT_DIS 0x10
#define GFH_BROM_CFG_USBDL_BY_KCOL0_TIMEOUT_EN 0x80
#define GFH_BROM_CFG_USBDL_BY_FLAG_TIMEOUT_EN 0x100
+#define GFH_BROM_CFG_JUMP_BL_ARM64_EN 0x1000
+#define GFH_BROM_CFG_JUMP_BL_ARM64 0x64
struct gfh_bl_sec_key {
struct gfh_common_header gfh;
--
2.30.1

View File

@@ -0,0 +1,226 @@
From patchwork Tue Mar 9 07:52:31 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Weijie Gao <weijie.gao@mediatek.com>
X-Patchwork-Id: 1449568
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Authentication-Results: ozlabs.org;
spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
(client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: ozlabs.org;
dkim=pass (1024-bit key;
unprotected) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256
header.s=dk header.b=i1dK9gFR;
dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
[IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest
SHA256)
(No client certificate requested)
by ozlabs.org (Postfix) with ESMTPS id 4DvnX84rrHz9sW1
for <incoming@patchwork.ozlabs.org>; Tue, 9 Mar 2021 18:53:44 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
by phobos.denx.de (Postfix) with ESMTP id DF60F8219C;
Tue, 9 Mar 2021 08:53:29 +0100 (CET)
Authentication-Results: phobos.denx.de;
dmarc=pass (p=none dis=none) header.from=mediatek.com
Authentication-Results: phobos.denx.de;
spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
dkim=pass (1024-bit key;
unprotected) header.d=mediatek.com header.i=@mediatek.com
header.b="i1dK9gFR";
dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
id 5456882625; Tue, 9 Mar 2021 08:53:28 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level:
X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,
DKIM_VALID,DKIM_VALID_AU,MIME_BASE64_TEXT,RDNS_NONE,SPF_HELO_NONE,
UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2
Received: from mailgw02.mediatek.com (unknown [1.203.163.81])
by phobos.denx.de (Postfix) with ESMTP id 7526E80EF2
for <u-boot@lists.denx.de>; Tue, 9 Mar 2021 08:53:19 +0100 (CET)
Authentication-Results: phobos.denx.de;
dmarc=pass (p=none dis=none) header.from=mediatek.com
Authentication-Results: phobos.denx.de;
spf=pass smtp.mailfrom=weijie.gao@mediatek.com
X-UUID: 3b5ccbd89ab948daa31ec738ee94e7ed-20210309
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=mediatek.com;
s=dk;
h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
bh=mijplkmurYfYet7eQPGQD6GyyMtN6xMXZKHVAlpy0hM=;
b=i1dK9gFRfmkqD5vAud81Q3CdZlOQm3XK0H/NwbxYyncwalZqRZA1YBKTQhmPW0avcbwOQpGVlRmu1VAfALWgK80acX7bPIjWjtaJtK4/99vc+wIthmm1E5QMewyBAFkzGfx7A8ryh4HdcsG/esbnI0Mk2nletBHwRFAEVs3uUfU=;
X-UUID: 3b5ccbd89ab948daa31ec738ee94e7ed-20210309
Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com
(envelope-from <weijie.gao@mediatek.com>)
(mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
with ESMTP id 23424931; Tue, 09 Mar 2021 15:53:06 +0800
Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N1.mediatek.inc
(172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2;
Tue, 9 Mar 2021 15:52:58 +0800
Received: from mcddlt001.mediatek.inc (10.19.240.15) by MTKCAS32.mediatek.inc
(172.27.4.170) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
Transport; Tue, 9 Mar 2021 15:52:58 +0800
From: Weijie Gao <weijie.gao@mediatek.com>
To: <u-boot@lists.denx.de>
CC: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>, Weijie Gao
<weijie.gao@mediatek.com>
Subject: [PATCH] tools: mtk_image: add an option to set device header offset
Date: Tue, 9 Mar 2021 15:52:31 +0800
Message-ID: <1615276351-30641-1-git-send-email-weijie.gao@mediatek.com>
X-Mailer: git-send-email 1.9.1
MIME-Version: 1.0
X-TM-SNTS-SMTP:
B09EA906E69093D91FA73A3F764A0B89D3838DA91A4FA20DA0483EBE19962CA02000:8
X-MTK: N
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
<mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de
X-Virus-Status: Clean
This patch adds an option which allows setting the device header offset.
This is useful if this tool is used to generate ATF BL2 image of mt7622 for
SD cards.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
tools/mtk_image.c | 50 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index bde1e5da4b..418c5fd54b 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -243,8 +243,13 @@ static const struct brom_img_type {
}
};
+/* Indicates whether we're generating or verifying */
+static bool img_gen;
+static uint32_t img_size;
+
/* Image type selected by user */
static enum brlyt_img_type hdr_media;
+static uint32_t hdr_offset;
static int use_lk_hdr;
static bool is_arm64_image;
@@ -275,6 +280,7 @@ static int mtk_brom_parse_imagename(const char *imagename)
/* User passed arguments from image name */
static const char *media = "";
+ static const char *hdr_offs = "";
static const char *nandinfo = "";
static const char *lk = "";
static const char *arm64_param = "";
@@ -317,6 +323,9 @@ static int mtk_brom_parse_imagename(const char *imagename)
if (!strcmp(key, "media"))
media = val;
+ if (!strcmp(key, "hdroffset"))
+ hdr_offs = val;
+
if (!strcmp(key, "nandinfo"))
nandinfo = val;
@@ -359,6 +368,10 @@ static int mtk_brom_parse_imagename(const char *imagename)
}
}
+ /* parse device header offset */
+ if (hdr_offs && hdr_offs[0])
+ hdr_offset = strtoul(hdr_offs, NULL, 0);
+
if (arm64_param && arm64_param[0] == '1')
is_arm64_image = true;
@@ -422,6 +435,7 @@ static int mtk_image_vrec_header(struct image_tool_params *params,
static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
{
union gen_boot_header *gbh = (union gen_boot_header *)ptr;
+ uint32_t gfh_offset, total_size, devh_size;
struct brom_layout_header *bh;
struct gfh_header *gfh;
const char *bootmedia;
@@ -453,7 +467,32 @@ static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
le32_to_cpu(bh->type) != BRLYT_TYPE_SDMMC))
return -1;
- gfh = (struct gfh_header *)(ptr + le32_to_cpu(bh->header_size));
+ devh_size = sizeof(struct gen_device_header);
+
+ if (img_gen) {
+ gfh_offset = devh_size;
+ } else {
+ gfh_offset = le32_to_cpu(bh->header_size);
+
+ if (gfh_offset + sizeof(struct gfh_header) > img_size) {
+ /*
+ * This may happen if the hdr_offset used to generate
+ * this image is not zero.
+ * Since device header size is not fixed, we can't
+ * cover all possible cases.
+ * Assuming the image is valid only if the real
+ * device header size equals to devh_size.
+ */
+ total_size = le32_to_cpu(bh->total_size);
+
+ if (total_size - gfh_offset > img_size - devh_size)
+ return -1;
+
+ gfh_offset = devh_size;
+ }
+ }
+
+ gfh = (struct gfh_header *)(ptr + gfh_offset);
if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME))
return -1;
@@ -549,6 +588,8 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,
if (le32_to_cpu(lk->magic) == LK_PART_MAGIC)
return 0;
+ img_size = image_size;
+
if (!strcmp((char *)ptr, NAND_BOOT_NAME))
return mtk_image_verify_nand_header(ptr, 0);
else
@@ -682,8 +723,8 @@ static void mtk_image_set_gen_header(void *ptr, off_t filesize,
/* BRLYT header */
put_brom_layout_header(&hdr->brlyt, hdr_media);
- hdr->brlyt.header_size = cpu_to_le32(sizeof(struct gen_device_header));
- hdr->brlyt.total_size = cpu_to_le32(filesize);
+ hdr->brlyt.header_size = cpu_to_le32(hdr_offset + sizeof(*hdr));
+ hdr->brlyt.total_size = cpu_to_le32(hdr_offset + filesize);
hdr->brlyt.header_size_2 = hdr->brlyt.header_size;
hdr->brlyt.total_size_2 = hdr->brlyt.total_size;
@@ -747,6 +788,9 @@ static void mtk_image_set_header(void *ptr, struct stat *sbuf, int ifd,
return;
}
+ img_gen = true;
+ img_size = sbuf->st_size;
+
if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND)
mtk_image_set_nand_header(ptr, sbuf->st_size, params->addr);
else

View File

@@ -0,0 +1,14 @@
OpenWrt links the libressl statically against mkimage, make sure all the
needed dependencies are added too.
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -158,7 +158,7 @@ ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CON
HOSTCFLAGS_kwbimage.o += \
$(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
HOSTLDLIBS_mkimage += \
- $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
+ $(shell pkg-config --libs --static libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
# OS X deprecate openssl in favour of CommonCrypto, supress deprecation
# warnings on those systems