Rebase all RISCV patches on top of RC2

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2019-11-13 14:40:25 +02:00
parent bb6b35ba8b
commit 47f52c146b
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
5 changed files with 149 additions and 319 deletions

View File

@ -1,222 +1,144 @@
From patchwork Thu Oct 10 21:23:17 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Atish Patra <atish.patra@wdc.com>
X-Patchwork-Id: 1174807
X-Patchwork-Delegate: trini@ti.com
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=none (mailfrom) smtp.mailfrom=lists.denx.de
(client-ip=81.169.180.215; helo=lists.denx.de;
envelope-from=u-boot-bounces@lists.denx.de;
receiver=<UNKNOWN>)
Authentication-Results: ozlabs.org;
dmarc=fail (p=none dis=none) header.from=wdc.com
Authentication-Results: ozlabs.org;
dkim=fail reason="signature verification failed" (2048-bit key;
unprotected) header.d=wdc.com header.i=@wdc.com header.b="jLbUoQO5";
dkim-atps=neutral
Received: from lists.denx.de (dione.denx.de [81.169.180.215])
by ozlabs.org (Postfix) with ESMTP id 46q3wm58g1z9s7T
for <incoming@patchwork.ozlabs.org>;
Fri, 11 Oct 2019 08:23:34 +1100 (AEDT)
Received: by lists.denx.de (Postfix, from userid 105)
id 936A1C21E13; Thu, 10 Oct 2019 21:23:31 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID
autolearn=unavailable autolearn_force=no version=3.4.0
Received: from lists.denx.de (localhost [IPv6:::1])
by lists.denx.de (Postfix) with ESMTP id E723AC21C38;
Thu, 10 Oct 2019 21:23:27 +0000 (UTC)
Received: by lists.denx.de (Postfix, from userid 105)
id 385B1C21C38; Thu, 10 Oct 2019 21:23:26 +0000 (UTC)
Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42])
by lists.denx.de (Postfix) with ESMTPS id 37872C21C27
for <u-boot@lists.denx.de>; Thu, 10 Oct 2019 21:23:25 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com;
t=1570742605; x=1602278605;
h=from:to:cc:subject:date:message-id:mime-version:
content-transfer-encoding;
bh=Kp4i9HSKZ54C5mzMriNg89Nhk+VaBisYH/XOTqfSl4E=;
b=jLbUoQO5C/ZQCZ0SR+j5DgTnEkj86ErU1+lf8lxjyoIKLzn66uEknDG9
/tRe9acH8qooP2fdyOLs8QsHTFfaf10P/0Ys5FUIKeD1DFVksnIkH3dIj
A2m5arryrA5KvhdYMJqZkmV7Yj5X7B1i/Ceptnyn1GWAgjuCfQuiaG9cx
Barh2ZenBQkpTpa+SE5lnNcTQiJDpnvxhoiKkiSvaECx0Mv8qFFCBlZTf
Ztgz4Geld8p+8DSqxfuevNbzwU03CwAishA5lyCqRsn4TKYTLiQSsUjJa
ulZoeJWT0NKwC9qr13OwYgmmvHyAivnN6StRmLwQRmqOUe4EFlCM3H6jr g==;
IronPort-SDR: TwtnnsJy/N00N83EtuiWHVWsh2VFqg7rc28xVqFc7H/NBZMX//1pVrhxcRdYwAY1REc3H45wX9
vzCshumIJa7Lb++uKHaWfUrIKnJfJv2fz8JdA9GMtSqgjebXPthQAedOM+gMDahv1Zb6q+o1vV
p6YRbznrXtzqlIwPnbaoqs+6BkfMxWSzRABM6ydvqQ7a9lYpcGOuVHWRPR4xq7/I8z4lN1pZAM
RHOQu7NPPaippZV/eKdblYChITakYGJwd5Pkk8bb4ODcMpE+uU32JB+yjCH1vc7LFpa0wz+OF3
ZmM=
X-IronPort-AV: E=Sophos;i="5.67,281,1566835200"; d="scan'208";a="120282489"
Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com)
([199.255.45.15])
by ob1.hgst.iphmx.com with ESMTP; 11 Oct 2019 05:23:23 +0800
IronPort-SDR: 1LgY18tiY3vOm+mPdKRhTMfwqngixI4mOg6LEGQawZgPnwtSvk30LW5mGAhjr71XS1VNnWitJo
ZnvWLumBpWTvrcMGLbslV5jVqZQ+NOfA5NVOGRUVVjd7ARikTNZlRy8ytdJoCnHzXPYXkVCIX+
oznGSQBvjfnL3bg9tFmS62GpVy1zbAgKdzVC1LZCEjUrXN1wF9qt1zOEEgRefKOpCXi+vT4iT2
6sPzJIL4z9CBm7gBsh8qYpjGG68mKEzWbLZwcIu1OY3OkSB3fLw+uc0NCUvl5CUVNU50tq/pTB
K0THcmrxb75ovie2yGWsDvwz
Received: from uls-op-cesaip01.wdc.com ([10.248.3.36])
by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
10 Oct 2019 14:19:20 -0700
IronPort-SDR: mHx+paImtg13Y6VpyjKx/DHfspMkO9tPvRKNExNKsGOi2npXC0K7EvZvyX7BgEjaAn2qWUC9ca
rsWGJjDp6SLRYIveYCVqRTlL2sUTMv5dhS8VQxBAr/bXFZTns4kTSObcoQ+CUg1Rcsnx1URNGJ
NITy8IWCmmxM432KYP7c9G1dAqm2mCYcEJs6YaQcXtJYdZ9rHqE8Q4kfrGsAgssIW9XMrAquLi
dLhyXKTsqSMt/v+6RMbgzH58kiGy+EScEWfjsZ7BpDRoNDczEvPqXq+kvSW3SXx0X+Wx4tNzkt
PMk=
WDCIronportException: Internal
Received: from jedi-01.sdcorp.global.sandisk.com (HELO
jedi-01.int.fusionio.com) ([10.11.143.218])
by uls-op-cesaip01.wdc.com with ESMTP; 10 Oct 2019 14:23:23 -0700
From: Atish Patra <atish.patra@wdc.com>
To: u-boot@lists.denx.de
Date: Thu, 10 Oct 2019 14:23:17 -0700
Message-Id: <20191010212317.3884-1-atish.patra@wdc.com>
X-Mailer: git-send-email 2.21.0
MIME-Version: 1.0
Cc: david.abdurachmanov@sifive.com, Joe Hershberger <joe.hershberger@ni.com>,
Alexander Graf <agraf@csgraf.de>
Subject: [U-Boot] [RFC/RFT U-Boot PATCH] image: Add Image.gz parsing support
in booti.
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.18
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: <http://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>
Add gz parsing logic so that booti can parse both Image
and Image.gz to boot Linux. Currently, it is difficult to calculate
a safe address for every board where the Image.gz can be decompressed.
It is also not possible to figure out the size of the compressed file
as well. Thus, user need to set two additional environment variables
kernel_gz_addr_r and kernel_gz_size to make Image.gz work.
Tested on HiFive Unleashed and Qemu for RISC-V.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
I could not test this patch on any ARM64 devices due to lack of
access to any ARM64 board. If anybody can test it on ARM64, that
would be great.
---
cmd/booti.c | 39 ++++++++++++++++++++++++++-
doc/README.distro | 11 ++++++++
doc/board/sifive/fu540.rst | 55 ++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/cmd/booti.c b/cmd/booti.c
index c36b0235df8c..6c37f84833d0 100644
index 841eff10..60bb4920 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -13,6 +13,9 @@
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/sizes.h>
+DECLARE_GLOBAL_DATA_PTR;
+#define GZ_HEADER_0 0x1f
+#define GZ_HEADER_1 0x8b
/*
* Image booting support
*/
@@ -23,6 +26,10 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -23,6 +24,12 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
ulong ld;
ulong relocated_addr;
ulong image_size;
+ uint8_t *temp;
+ ulong dest;
+ ulong dest_end;
+ unsigned long gz_len;
+ unsigned long comp_len;
+ unsigned long decomp_len;
+ int ctype;
ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
images, 1);
@@ -37,6 +44,34 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -37,6 +44,33 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
debug("* kernel: cmdline image address = 0x%08lx\n", ld);
}
+ temp = map_sysmem(ld, 0);
+
+ if (*(temp) == GZ_HEADER_0 && *(temp+1) == GZ_HEADER_1) {
+ dest = env_get_ulong("kernel_gz_addr_r", 16, 0);
+ gz_len = env_get_ulong("kernel_gz_size", 16, 0);
+ if (!dest || !gz_len) {
+ puts("kernel_gz_addr_r or kernel_gz_size is not provided for Image.gz!\n");
+ ctype = image_decomp_type(temp, 2);
+ if (ctype > 0) {
+ dest = env_get_ulong("kernel_comp_addr_r", 16, 0);
+ comp_len = env_get_ulong("filesize", 16, 0);
+ if (!dest || !comp_len) {
+ puts("kernel_comp_addr_r or filesize is not provided!\n");
+ return -EINVAL;
+ }
+ if (dest < gd->ram_base || dest > gd->ram_top) {
+ puts("kernel_gz_addr_r size is outside of dram range!\n");
+ puts("kernel_comp_addr_r is outside of DRAM range!\n");
+ return -EINVAL;
+ }
+
+ debug("Image.gz of size = 0x%08lx will be decompressed at 0x%08lx\n",
+ gz_len, (ulong)dest);
+
+ ret = image_decomp(IH_COMP_GZIP, 0, ld, IH_TYPE_KERNEL,
+ (void *)dest, (void *)ld, gz_len,
+ CONFIG_SYS_BOOTM_LEN, &dest_end);
+ debug("kernel image compression type %d size = 0x%08lx address = 0x%08lx\n",
+ ctype, comp_len, (ulong)dest);
+ decomp_len = comp_len * 10;
+ ret = image_decomp(ctype, 0, ld, IH_TYPE_KERNEL,
+ (void *)dest, (void *)ld, comp_len,
+ decomp_len, &dest_end);
+ if (ret)
+ return ret;
+ /* dest_end contains the uncompressed Image size */
+ memmove((void *) ld, (void *)dest, dest_end);
+ unmap_sysmem((void *)dest);
+ }
+ unmap_sysmem((void *)ld);
+
ret = booti_setup(ld, &relocated_addr, &image_size, false);
if (ret != 0)
return 1;
@@ -96,10 +131,12 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -99,10 +133,14 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_SYS_LONGHELP
static char booti_help_text[] =
"[addr [initrd[:size]] [fdt]]\n"
- " - boot Linux 'Image' stored at 'addr'\n"
+ " - boot Linux 'Image' or Image.gz stored at 'addr'\n"
+ " - boot Linux flat or compressed 'Image' stored at 'addr'\n"
"\tThe argument 'initrd' is optional and specifies the address\n"
"\tof an initrd in memory. The optional parameter ':size' allows\n"
"\tspecifying the size of a RAW initrd.\n"
+ "\tIn order to boot from Image.gz, user have to set kernel_gz_addr_r\n"
+ "\tand kernel_gz_size enviornment variables beforehand.\n"
+ "\tCurrently only booting from gz, bz2, lzma and lz4 compression\n"
+ "\ttypes are supported. In order to boot from any of these compressed\n"
+ "\timages, user have to set kernel_comp_addr_r and filesize enviornment\n"
+ "\tvariables beforehand.\n"
#if defined(CONFIG_OF_LIBFDT)
"\tSince booting a Linux kernel requires a flat device-tree, a\n"
"\tthird argument providing the address of the device-tree blob\n"
diff --git a/common/image.c b/common/image.c
index f17fa40c..cbd6c494 100644
--- a/common/image.c
+++ b/common/image.c
@@ -197,6 +197,14 @@ struct table_info {
const table_entry_t *table;
};
+static const struct comp_magic_map image_comp[] = {
+ { IH_COMP_BZIP2, "bzip2", {0x42, 0x5a},},
+ { IH_COMP_GZIP, "gzip", {0x1f, 0x8b},},
+ { IH_COMP_LZMA, "lzma", {0x5d, 0x00},},
+ { IH_COMP_LZO, "lzo", {0x89, 0x4c},},
+ { IH_COMP_NONE, "none", {}, },
+};
+
static const struct table_info table_info[IH_COUNT] = {
{ "architecture", IH_ARCH_COUNT, uimage_arch },
{ "compression", IH_COMP_COUNT, uimage_comp },
@@ -402,6 +410,21 @@ static void print_decomp_msg(int comp_type, int type, bool is_xip)
printf(" Uncompressing %s\n", name);
}
+int image_decomp_type(const unsigned char *buf, ulong len)
+{
+ const struct comp_magic_map *cmagic = image_comp;
+
+ if (len < 2)
+ return -EINVAL;
+
+ for (; cmagic->comp_id > 0; cmagic++) {
+ if (!memcmp(buf, cmagic->magic, 2))
+ break;
+ }
+
+ return cmagic->comp_id;
+}
+
int image_decomp(int comp, ulong load, ulong image_start, int type,
void *load_buf, void *image_buf, ulong image_len,
uint unc_len, ulong *load_end)
diff --git a/doc/README.distro b/doc/README.distro
index ab6e6f4e74be..dbf6eef07e35 100644
index ab6e6f4e..67b49e1e 100644
--- a/doc/README.distro
+++ b/doc/README.distro
@@ -246,6 +246,17 @@ kernel_addr_r:
@@ -246,6 +246,18 @@ kernel_addr_r:
A size of 16MB for the kernel is likely adequate.
+kernel_gz_addr_r:
+ Optional. This is only required if user wants to boot Linux from a Image.gz
+ using booti command. It represents the location in RAM where a Image.gz will
+ be decompressed temporarily. Once the decompression is complete, decompressed
+ data will be moved kernel_addr_r for booting.
+kernel_comp_addr_r:
+ Optional. This is only required if user wants to boot Linux from a compressed
+ Image(.gz, .bz2, .lzma, .lzo) using booti command. It represents the location
+ in RAM where the compressed Image will be decompressed temporarily. Once the
+ decompression is complete, decompressed data will be moved kernel_addr_r for
+ booting.
+
+kernel_gz_size:
+ Optional. This is only required if user wants to boot Linux from a Image.gz
+ using booti command. It represents the size of the Image.gz file. The size
+ has to at least the size of Image.gz file for decompression to succeed.
+filesize:
+ Optional. This is only required if user wants to boot Linux from a compressed
+ Image using booti command. It represents the size of the compressed file. The
+ size has to at least the size of loaded image for decompression to succeed.
+
pxefile_addr_r:
Mandatory. The location in RAM where extlinux.conf will be loaded to prior
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 7807f5b2c128..ad4485eb7cdb 100644
index 7807f5b2..df2c5ad8 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -138,6 +138,10 @@ load uImage.
@ -238,14 +160,14 @@ index 7807f5b2c128..ad4485eb7cdb 100644
+Or if you want to use a compressed kernel image file such as Image.gz
+
+.. code-block:: none
+ => tftpboot ${kernel_addr_r} /sifive/fu540/Image
+ => tftpboot ${kernel_addr_r} /sifive/fu540/Image.gz
+ ethernet@10090000: PHY present at 0
+ ethernet@10090000: Starting autonegotiation...
+ ethernet@10090000: Autonegotiation complete
+ ethernet@10090000: link up, 1000Mbps full-duplex (lpa: 0x3c00)
+ Using ethernet@10090000 device
+ TFTP from server 10.206.4.143; our IP address is 10.206.7.133
+ Filename '/sifive/fu540/Image'.
+ Filename '/sifive/fu540/Image.gz'.
+ Load address: 0x84000000
+ Loading: #################################################################
+ #################################################################
@ -277,8 +199,8 @@ index 7807f5b2c128..ad4485eb7cdb 100644
+ 1.2 MiB/s
+ done
+ Bytes transferred = 4809458 (4962f2 hex)
+ =>setenv kernel_gz_addr_r 0x90000000
+ =>setenv kernel_gz_size 0x500000
+ =>setenv kernel_comp_addr_r 0x90000000
+ =>setenv filesize 0x500000
+
+By this time, correct kernel image is loaded and required enviornment variables
+are set. You can proceed to load the ramdisk and device tree from the tftp server
@ -288,3 +210,58 @@ index 7807f5b2c128..ad4485eb7cdb 100644
=> tftpboot ${ramdisk_addr_r} /sifive/fu540/uRamdisk
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
diff --git a/include/image.h b/include/image.h
index f4d2aaf5..823c187b 100644
--- a/include/image.h
+++ b/include/image.h
@@ -447,6 +447,15 @@ typedef struct table_entry {
char *lname; /* long (output) name to print for messages */
} table_entry_t;
+/*
+ * Compression type and magic number mapping table.
+ */
+struct comp_magic_map {
+ int comp_id;
+ const char *name;
+ unsigned char magic[2];
+};
+
/*
* get_table_entry_id() scans the translation table trying to find an
* entry that matches the given short name. If a matching entry is
@@ -851,6 +860,18 @@ static inline int image_check_target_arch(const image_header_t *hdr)
}
#endif /* USE_HOSTCC */
+/**
+ * image_decomp_type() - Find out compression type of an image
+ *
+ * @buf: Address in U-Boot memory where image is loaded.
+ * @len: Length of the compressed image.
+ * @return compression type or IH_COMP_NONE if not compressed.
+ *
+ * Note: Only following compression types are supported now.
+ * lzo, lzma, gzip, bzip2
+ */
+int image_decomp_type(const unsigned char *buf, ulong len);
+
/**
* image_decomp() - decompress an image
*
diff --git a/lib/Kconfig b/lib/Kconfig
index b8a8509d..53661baf 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -397,6 +397,11 @@ config GZIP
help
This enables support for GZIP compression algorithm.
+config BZIP2
+ bool "Enable bzip2 decompression support"
+ help
+ This enables support for BZIP2 compression algorithm.
+
config ZLIB
bool
default y

View File

@ -1,141 +0,0 @@
From patchwork Wed Oct 9 01:14:02 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Atish Patra <atish.patra@wdc.com>
X-Patchwork-Id: 1173557
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=none (mailfrom) smtp.mailfrom=lists.denx.de
(client-ip=81.169.180.215; helo=lists.denx.de;
envelope-from=u-boot-bounces@lists.denx.de;
receiver=<UNKNOWN>)
Authentication-Results: ozlabs.org;
dmarc=fail (p=none dis=none) header.from=wdc.com
Authentication-Results: ozlabs.org;
dkim=fail reason="signature verification failed" (2048-bit key;
unprotected) header.d=wdc.com header.i=@wdc.com header.b="gtFhR2Pl";
dkim-atps=neutral
Received: from lists.denx.de (dione.denx.de [81.169.180.215])
by ozlabs.org (Postfix) with ESMTP id 46nx9M2gjMz9sPJ
for <incoming@patchwork.ozlabs.org>;
Wed, 9 Oct 2019 12:15:33 +1100 (AEDT)
Received: by lists.denx.de (Postfix, from userid 105)
id E8E79C21EF7; Wed, 9 Oct 2019 01:15:23 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID
autolearn=unavailable autolearn_force=no version=3.4.0
Received: from lists.denx.de (localhost [IPv6:::1])
by lists.denx.de (Postfix) with ESMTP id 0C1C6C21DEC;
Wed, 9 Oct 2019 01:15:22 +0000 (UTC)
Received: by lists.denx.de (Postfix, from userid 105)
id CC46CC21DEC; Wed, 9 Oct 2019 01:15:19 +0000 (UTC)
Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141])
by lists.denx.de (Postfix) with ESMTPS id C8941C21C38
for <u-boot@lists.denx.de>; Wed, 9 Oct 2019 01:15:18 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com;
t=1570583719; x=1602119719;
h=from:to:cc:subject:date:message-id:mime-version:
content-transfer-encoding;
bh=svAg//dsQ1xSEGIXIiHkuIHltzOaETv1pGmecUe8B9g=;
b=gtFhR2Plcfn/+ugh0ZySqZ2uPyFAKoSPRAr1i9Ns8gxJceu1whMVdkzl
srFuy8/er88wP3FYxeU7AGFT3suYndiT3nbArtM1N6McHyzgYU/qVs5HD
CVM1IaH8z3w/4fkiU9wCsrw1guGNWyrf9roAg2knx3piFhNDcVZM62Vp+
UEpDFRJztTgPl0QIhoFVky0+Hf3KdmXV+OOOzzm0Z7Q5v50aXSE1vD1+J
ln+KR4SsqhtiQQf8UJI77INRz2Lxs7TNdtv3vfjoyXr8H1H86BFejeEyp
0HU5xbyaxQhEuOqW9Yxo7PY4KefFfH7UdQX4utU4QfnBbRePmlt27ZrKG w==;
IronPort-SDR: sgogNYpUsZGzLeDJAWo084U0k0ZU9wpDWm3t4S454aWfuYpvgVUqpjsMDz8EIKqqvGWKYIEeXn
dcI7HvYw88Li02yYVMZ3EgWbSdYyB6eH0Y2A5iQ9GkweAgHHdlGDKeFMkR15U0zZ3ykgENByCh
fwVVSj21S10S0JA8Kj78n//9wJ8ilZY73VZK5xfmPp667JpJkR9qeQHHX0xRbyuclLP4vZq8Aj
Q5mZFiCs9B/Bc5rHVqKwnFxb4GmA47eecNgTraHiPVP5F+LNWvX6Pp6v4f9DQ2XSyRALVZXBLr
zjs=
X-IronPort-AV: E=Sophos;i="5.67,273,1566835200"; d="scan'208";a="124526357"
Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com)
([199.255.45.15])
by ob1.hgst.iphmx.com with ESMTP; 09 Oct 2019 09:15:16 +0800
IronPort-SDR: Buy5knbyrOlIPw883De4JQRCyL13MC+JUKv2QQHfk2RqqRn47FtggQ3q0Vym3kSgxnxeA7Yc8x
riyH9+bdnQg6eihgDLKWH/vRjEHs/Z0ERN27PJ2uKZyqtzxM7HSXwvh3RC0gdL/qfIzo2i9GJm
F0RQsBIbtZdpDd/eEfImVJs7RIYMYgPB1LwqfxvjDCybjznjURM3tJbCGGAK5Xjqd3UwSO1rz+
Aiw96+5ut5Px6otY5gmqnIIqaUh8WaH5y8DsfxEZYXy5cVFkOzvuR9clYRIe7kZ5/9lWkODh+i
mQYFP6OQprMQCadWgutUuUbq
Received: from uls-op-cesaip01.wdc.com ([10.248.3.36])
by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
08 Oct 2019 18:11:16 -0700
IronPort-SDR: 6InoWq/jhVafNMtixHXFGtBARFkZWd63qbIi4fZHmKXP/zR0GpGae73S7qZZgZMwBjMELgmlUq
N0P84XWhIgTwZTu5mhZ72pljZkiUDKdRrA441zR0F+quzmQpoCTUlzjxUUNjgnpu3DygmWNH6Y
bFdk85ApZmnCKpQWCotp2eTzsFpIOFWJJY0EAHJTKBEgGPqo47vtoz9bEKxtXPOZBk+LxDmPBx
ncKAhnuEoHrNlqPFbE7BYRK3Kz6A9odnkc9D4JXN9UBnjD9v4f6m0mg4Lqr4vYAtjB/AkV3PU9
mBc=
WDCIronportException: Internal
Received: from jedi-01.sdcorp.global.sandisk.com (HELO
jedi-01.int.fusionio.com) ([10.11.143.218])
by uls-op-cesaip01.wdc.com with ESMTP; 08 Oct 2019 18:15:16 -0700
From: Atish Patra <atish.patra@wdc.com>
To: u-boot@lists.denx.de
Date: Tue, 8 Oct 2019 18:14:02 -0700
Message-Id: <20191009011402.13728-1-atish.patra@wdc.com>
X-Mailer: git-send-email 2.21.0
MIME-Version: 1.0
Cc: David Abdurachmanov <david.abdurachmanov@sifive.com>
Subject: [U-Boot] [PATCH] RISC-V: Align boot image header with Linux.
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.18
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: <http://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>
The release linux boot image header in v5.3 is different from the
one present in U-boot. Align the header with the new version. The
changes in Linux are backward compatible. Previous u-boot releases
with older header will continue to work as well. As v5.3 kernel is
the first one to support image header, there is no compatibility
issue between new U-boot (with this patch) and older kernel.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
arch/riscv/lib/image.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c
index d063beb7dfbe..41fca5939020 100644
--- a/arch/riscv/lib/image.c
+++ b/arch/riscv/lib/image.c
@@ -14,20 +14,21 @@
DECLARE_GLOBAL_DATA_PTR;
-/* ASCII version of "RISCV" defined in Linux kernel */
-#define LINUX_RISCV_IMAGE_MAGIC 0x5643534952
+/* ASCII version of "RSC\0x5" defined in Linux kernel */
+#define LINUX_RISCV_IMAGE_MAGIC 0x05435352
struct linux_image_h {
uint32_t code0; /* Executable code */
uint32_t code1; /* Executable code */
uint64_t text_offset; /* Image load offset */
uint64_t image_size; /* Effective Image size */
- uint64_t res1; /* reserved */
+ uint64_t flags; /* kernel flags(little endian) */
+ uint32_t version; /* version of the header */
+ uint32_t res1; /* reserved */
uint64_t res2; /* reserved */
uint64_t res3; /* reserved */
- uint64_t magic; /* Magic number */
+ uint32_t magic; /* Magic number */
uint32_t res4; /* reserved */
- uint32_t res5; /* reserved */
};
int booti_setup(ulong image, ulong *relocated_addr, ulong *size,

View File

@ -1,9 +1,9 @@
diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
index 1c7a2d15..5548a649 100644
index 7e1e5a77..792afee8 100644
--- a/configs/qemu-riscv64_smode_defconfig
+++ b/configs/qemu-riscv64_smode_defconfig
@@ -10,3 +10,7 @@ CONFIG_DISPLAY_BOARDINFO=y
CONFIG_CMD_BOOTEFI_SELFTEST=y
@@ -11,3 +11,7 @@ CONFIG_CMD_BOOTEFI_SELFTEST=y
CONFIG_CMD_NVEDIT_EFI=y
# CONFIG_CMD_MII is not set
CONFIG_OF_PRIOR_STAGE=y
+CONFIG_USE_BOOTARGS=y

View File

@ -7,7 +7,7 @@ index bc831a84..442f0f9d 100644
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
+ "kernel_gz_addr_r=0x90000000\0" \
+ "kernel_gz_size=0x4000000\0" \
+ "filesize=0x4000000\0" \
BOOTENV
#endif
@ -20,7 +20,7 @@ index 59cf0281..5114dde1 100644
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
+ "kernel_gz_addr_r=0x90000000\0" \
+ "kernel_gz_size=0x4000000\0" \
+ "filesize=0x4000000\0" \
BOOTENV
#endif /* __CONFIG_H */

View File

@ -49,10 +49,6 @@ Patch20: riscv64-set-fdt_addr.patch
# https://patchwork.kernel.org/patch/11165207/
Patch21: riscv-bootargs-preboot.patch
# https://patchwork.ozlabs.org/patch/1173557/
# https://lists.denx.de/pipermail/u-boot/2019-October/385906.html
Patch22: riscv-align-boot-image-header.patch
# Not upstream
# Adds support for Image.gz to booti (RFC/RFT)
# See: https://patchwork.ozlabs.org/patch/1174807/
@ -68,8 +64,8 @@ Patch24: riscv-increase-stack-size-to-16KiB.patch
Patch25: uboot-addappend.patch
# Not upstream
# Define kernel_gz_addr_r and kernel_gz_size for booti Image.gz support
Patch26: uboot-riscv-def-kernel_gz_addr_r-kernel_gz_size.patch
# Define kernel_gz_addr_r and filesize for booti Image.gz support
Patch26: uboot-riscv-def-kernel_gz_addr_r-filesize.patch
BuildRequires: bc
BuildRequires: dtc
@ -334,19 +330,17 @@ cp -p board/warp7/README builds/docs/README.warp7
%endif
%changelog
<<<<<<< HEAD
* Fri Nov 1 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> 2020.01-0.1.0.riscv64
* Wed Nov 13 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> 2020.01-0.3.0.riscv64
- Add support for RISC-V (riscv64)
- Define kernel_gz_size and kernel_gz_addr_r for QEMU virt and SiFive FU540 boards
- Define filesize and kernel_gz_addr_r for QEMU virt and SiFive FU540 boards
to support Image.gz with booti
- Add 'addappend' label to PXE/EXTLINUX configuration
=======
* Tue Nov 12 2019 Peter Robinson <pbrobinson@fedoraproject.org> 2020.01-0.3
- 2020.01 RC2
* Tue Nov 5 2019 Peter Robinson <pbrobinson@fedoraproject.org> 2020.01-0.2
- Include new ATF 2.2
>>>>>>> up/master
* Wed Oct 30 2019 Peter Robinson <pbrobinson@fedoraproject.org> 2020.01-0.1
- 2020.01 RC1