Initial commit

This commit is contained in:
domenico
2025-06-24 15:51:28 +02:00
commit 22031d9dab
6862 changed files with 1462554 additions and 0 deletions

48
tools/mkimage/Makefile Normal file
View File

@@ -0,0 +1,48 @@
#
# 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:=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:=7e7477534409d5368eb1371ffde6820f0f79780a1a1f676161c48442cb303dfd
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
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_SIGNATURE=y \
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,13 @@
--- a/include/image.h
+++ b/include/image.h
@@ -51,6 +51,10 @@ struct lmb;
#endif /* USE_HOSTCC */
+#ifndef ulong
+#define ulong unsigned long
+#endif
+
#if IMAGE_ENABLE_FIT
#include <hash.h>
#include <linux/libfdt.h>

View File

@@ -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>

View File

@@ -0,0 +1,69 @@
--- 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 = "",
@@ -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 -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
@@ -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, time);
image_set_size(hdr, imagesize);
image_set_load(hdr, params->addr);
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -54,6 +54,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,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;
@@ -308,13 +307,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 */

View File

@@ -0,0 +1,34 @@
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -66,6 +66,10 @@ typedef uint8_t __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef unsigned int uint;
+#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

View File

@@ -0,0 +1,16 @@
--- 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__
-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
-# error Your version of gcc miscompiles the __weak directive
-# endif
-#endif
-
#define __used __attribute__((__used__))
#define __compiler_offsetof(a, b) \
__builtin_offsetof(a, b)

View File

@@ -0,0 +1,14 @@
--- a/Makefile
+++ b/Makefile
@@ -634,7 +634,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

View File

@@ -0,0 +1,68 @@
From 69176c8602e29f4bd30457240374800d88dc39ed Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sat, 14 Apr 2018 22:39:34 +0200
Subject: [PATCH] rsa-sign: add support for libressl
---
lib/rsa/rsa-sign.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -21,7 +21,8 @@
#define HAVE_ERR_REMOVE_THREAD_STATE
#endif
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
static void RSA_get0_key(const RSA *r,
const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
{
@@ -300,7 +301,8 @@ static int rsa_init(void)
{
int ret;
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
ret = SSL_library_init();
#else
ret = OPENSSL_init_ssl(0, NULL);
@@ -309,7 +311,7 @@ static int rsa_init(void)
fprintf(stderr, "Failure to init SSL library\n");
return -1;
}
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
@@ -355,7 +357,7 @@ err_set_rsa:
err_engine_init:
ENGINE_free(e);
err_engine_by_id:
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
ENGINE_cleanup();
#endif
return ret;
@@ -363,7 +365,7 @@ err_engine_by_id:
static void rsa_remove(void)
{
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();
#ifdef HAVE_ERR_REMOVE_THREAD_STATE
@@ -433,7 +435,8 @@ static int rsa_sign_with_key(RSA *rsa, s
ret = rsa_err("Could not obtain signature");
goto err_sign;
}
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
+ #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ defined(LIBRESSL_VERSION_NUMBER)
EVP_MD_CTX_cleanup(context);
#else
EVP_MD_CTX_reset(context);

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
@@ -145,7 +145,7 @@ endif
# MXSImage needs LibSSL
ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X)$(CONFIG_FIT_SIGNATURE),)
HOSTLOADLIBES_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