Compare commits

...

60 Commits

Author SHA1 Message Date
David Abdurachmanov cc7e05b47a
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2020-01-07 10:37:47 +02:00
David Abdurachmanov 35bf0004b6
Fix riscv patches
- missing addappend (emtpy patch)
- failing to find DTB on QEMU

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2020-01-02 17:35:57 +02:00
David Abdurachmanov 6848b8c211
Rebase patches to RC5
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-29 21:20:25 +02:00
David Abdurachmanov d354a60762
Remove obsolete patches
These have landed in RC5.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-29 20:52:34 +02:00
David Abdurachmanov 8f589f71e3
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-28 20:08:05 +02:00
David Abdurachmanov c05c9a2db0
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-14 16:36:40 +02:00
David Abdurachmanov fe367fe99a Revert "Disable most of RISC-V patches for debugging"
This reverts commit 70d2045031.
2019-12-14 16:32:50 +02:00
David Abdurachmanov 70d2045031
Disable most of RISC-V patches for debugging
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-09 10:06:43 +02:00
David Abdurachmanov 964c83d011
Match CONFIG_NR_CPUS to Linux configuration (32)
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-05 22:20:29 +02:00
David Abdurachmanov ec8b6389cf
Rebase riscv64 patches for RC4
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-05 11:22:37 +02:00
David Abdurachmanov fbdd0d0c77
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-12-05 10:56:56 +02:00
David Abdurachmanov 5186624912
Incl. patch to fix booting on SiFive FU540
See: https://patchwork.ozlabs.org/patch/1196837/

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-19 12:35:19 +02:00
David Abdurachmanov cb2612aa04
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-19 12:32:49 +02:00
David Abdurachmanov 81fcb577f1
Rename kernel_gz_addr_r to kernel_comp_addr_r
I missed this while pulling in a new version of patchset.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-16 08:25:43 +02:00
David Abdurachmanov 47f52c146b
Rebase all RISCV patches on top of RC2
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-13 14:40:25 +02:00
David Abdurachmanov bb6b35ba8b
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-13 13:47:47 +02:00
David Abdurachmanov 4ac22964ab
Fix bogus date in changelog
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-01 08:36:22 +02:00
David Abdurachmanov 12e45d3b64
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-11-01 05:45:44 +02:00
David Abdurachmanov 8fbcc5a382
Define kernel_gz_addr_r and kernel_gz_size for RISC-V boards
This allows us to use Image.gz with booti command. This saves ~50%
of kernel size.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-30 16:33:37 +02:00
David Abdurachmanov ad3de44704
Fix addappend patch
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-29 12:03:24 +02:00
David Abdurachmanov 1abb99241a
Update addappend patch
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-28 17:03:44 +02:00
David Abdurachmanov d2cc99b787
Add 'addappend' label to PXE/EXTLINUX configuration
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-28 11:36:07 +02:00
David Abdurachmanov 0600cc956f
Incl. misc not upstream patches for RISC-V
1. Increase default stack size from 8KiB to 16KiB to avoid illegal instruction
   panics while bringing up harts online. Not posted yet online.
2. Add Image.gz booti support (RFC/RFT) for testing.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-17 10:30:05 +03:00
David Abdurachmanov 2b10fe613a
Merge remote-tracking branch 'up/f31' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-17 10:18:30 +03:00
David Abdurachmanov c026d2881e
Misc. RISCV fixes
- Align boot image header format
- Set preboot for QEMU to copy DTB in expected location
- Set default bootargs for the boards

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-09 15:08:23 +03:00
David Abdurachmanov 27068a5bf6
Merge remote-tracking branch 'up/f31' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-10-09 13:43:51 +03:00
David Abdurachmanov 4caac69d44
Set fdt_addr to fdt_addr_r value for PXE/EXTLINUX
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-09-26 19:10:33 +02:00
David Abdurachmanov 2499c1d49a
Remove all custom patches and start fresh
CONFIG_PREBOOT might need re-work, thus let's start fresh to see
check uboot environment before changes.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-09-24 07:53:22 +03:00
David Abdurachmanov b37aa919da
Merge remote-tracking branch 'up/f31' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-09-24 07:49:48 +03:00
David Abdurachmanov 39828c439d
Remove CONFIG_PREBOOT for SiFive FU540
fdtcontroladdr points to a wrong location for FDT and 5.3 kernel fails
to boot.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-30 10:08:31 -07:00
David Abdurachmanov 96ba5aabb5
Remove easylogo/easylogo
Tool was removed upstream.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-27 09:52:43 -07:00
David Abdurachmanov c2f204c668
Boot from MMC and PXE SiFive FU540
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-27 01:07:02 -07:00
David Abdurachmanov aaf7235ecb
Update to 2019.10 RC3
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-26 18:15:03 -07:00
David Abdurachmanov e3b3eec4c9
Remove some README.* files
Some README.* files were converted to reST to be used with Sphinx
and places in different locations.

BUILDSTDERR: error: File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.uefi
BUILDSTDERR: error: File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.arm64
RPM build errors:
BUILDSTDERR: error: File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.qemu-riscv
BUILDSTDERR: error: File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.sifive-fu540
BUILDSTDERR: error: File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.ae350
BUILDSTDERR:     File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.uefi
BUILDSTDERR:     File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.arm64
BUILDSTDERR:     File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.qemu-riscv
BUILDSTDERR:     File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.sifive-fu540
BUILDSTDERR:     File not found: /builddir/build/BUILDROOT/uboot-tools-2019.10-0.1.rc2.0.riscv64.fc31.riscv64/usr/share/doc/uboot-tools/README.ae350
Child return code was: 1

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-24 09:58:42 -07:00
David Abdurachmanov 70e5155e0a
Fix envtools build errors
Patchset from https://patchwork.ozlabs.org/cover/1152432/

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-24 08:22:28 -07:00
David Abdurachmanov 24e8ba91b7
Update RISC-V (riscv64) patch
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-23 16:44:13 -07:00
David Abdurachmanov dd5b903d3b
Clean up RISC-V (riscv64) patches
Old patches are upstreamed, but upstream was broken while converting
PREBOOT stuff to Kconfig.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-23 14:30:19 -07:00
David Abdurachmanov 27c9eecc4a
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-08-23 14:18:58 -07:00
David Abdurachmanov 5d662178ca
Rebase patch for RC4
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-04 16:22:03 +03:00
David Abdurachmanov a29ada2896
Update VirtIO PCI patches
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-04 15:10:52 +03:00
David Abdurachmanov 2602a671e9
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-07-02 14:28:07 +03:00
David Abdurachmanov b62e49859d
Call pci enum before virtio scan
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-29 12:10:48 +03:00
David Abdurachmanov c7647e64da
Bump Release
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-29 11:08:12 +03:00
David Abdurachmanov de3f529caf
Update patch to use setenv instead of local variable
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-29 11:06:55 +03:00
David Abdurachmanov a87326e86a
Run virtio scan before booting from VirtIO Block Device over PCIe
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-28 16:57:06 +03:00
David Abdurachmanov 8a5a414e3c
Add VIRTIO_PCI to RISC-V QEMU emulation
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-26 09:55:27 +03:00
David Abdurachmanov b8d8a2c629
Remove obsolete patch for RISC-V
The changes were merged upstream.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-21 18:02:00 +03:00
David Abdurachmanov 85b660c788
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
2019-06-21 17:31:11 +03:00
David Abdurachmanov 2e821a1b29
Fix path for README.odroid-c2
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-05-05 17:00:30 +03:00
David Abdurachmanov 5ca523f5a9
Remove ARM Tegra patch (needs rebasing, not upstreamed)
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-05-05 16:15:29 +03:00
David Abdurachmanov f8612e71c8
Remove upstreamed patches
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-05-05 16:14:46 +03:00
David Abdurachmanov 2fc7774edf
Update to 2019.07 RC1
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-05-05 15:32:55 +03:00
David Abdurachmanov f0e754c7e3
Merge remote-tracking branch 'up/master' into master-riscv64
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-05-05 15:29:23 +03:00
David Abdurachmanov 162c2f023b
Apply pull request which incl. SMP support for RISC-V
See: https://lists.denx.de/pipermail/u-boot/2019-April/364281.html

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-04-08 15:19:27 +02:00
David Abdurachmanov 2225e1aa63
Update RISC-V offsets again
Memory starts at 0x80000000, but kernel entry point is at 0x80200000,
i.e. 2MB aligned memory address. Also modify kernel_addr_r to be 64MB
away to give enough space for kernel.

Also we can ignore rule that kernel should be mapped into the 1st 128MB
of memory because of CONFIG_AUTO_ZRELADDR. That's ARMv7 specific bit.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-04-06 15:39:54 +02:00
David Abdurachmanov af139e3d4c
Update RISC-V patch to allow kernels up to 64MB
5.1-rc3+ passed 16MB threshold. 64MB was picked based on some ARM boards.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-04-05 18:01:35 +02:00
David Abdurachmanov 92694119a7
Add CONFIG_REBOOT to set fdt_addr
This is needed for PXE/extlinux boot to find FDT (Device Tree Blob)
otherwise we don't boot. Also configure fdt command with FDT address
so we could use it out-of-the-box in U-Boot prompt.

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-03-30 20:31:09 +01:00
David Abdurachmanov 60e6ad3bb8 Bump release
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-03-26 13:47:49 +01:00
David Abdurachmanov 073d9f7cdf
qemu-riscv64_smode_defconfig: enable fat and bootz commands
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-03-26 13:45:15 +01:00
David Abdurachmanov b39fdd19d6
Add support for RISC-V (riscv64)
Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
2019-03-25 20:15:51 +01:00
8 changed files with 583 additions and 3 deletions

View File

@ -0,0 +1,267 @@
diff --git a/cmd/booti.c b/cmd/booti.c
index 841eff10..60bb4920 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/sizes.h>
+DECLARE_GLOBAL_DATA_PTR;
/*
* Image booting support
*/
@@ -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 comp_len;
+ unsigned long decomp_len;
+ int ctype;
ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
images, 1);
@@ -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);
+ 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_comp_addr_r is outside of DRAM range!\n");
+ return -EINVAL;
+ }
+
+ 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 *)ld);
+
ret = booti_setup(ld, &relocated_addr, &image_size, false);
if (ret != 0)
return 1;
@@ -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 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"
+ "\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 ab6e6f4e..67b49e1e 100644
--- a/doc/README.distro
+++ b/doc/README.distro
@@ -246,6 +246,18 @@ kernel_addr_r:
A size of 16MB for the kernel is likely adequate.
+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.
+
+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 7807f5b2..df2c5ad8 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -138,6 +138,10 @@ load uImage.
=> setenv netmask 255.255.252.0
=> setenv serverip 10.206.4.143
=> setenv gateway 10.206.4.1
+
+If you want to use a flat kernel image such as Image file
+
+.. code-block:: none
=> tftpboot ${kernel_addr_r} /sifive/fu540/Image
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
@@ -177,6 +181,57 @@ load uImage.
1.2 MiB/s
done
Bytes transferred = 8867100 (874d1c hex)
+
+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.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.gz'.
+ Load address: 0x84000000
+ Loading: #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ ##########################################
+ 1.2 MiB/s
+ done
+ Bytes transferred = 4809458 (4962f2 hex)
+ =>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
+as well.
+
+.. code-block:: none
=> 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

@ -0,0 +1,22 @@
diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
index 33776f03..42ec49eb 100644
--- a/configs/qemu-riscv64_smode_defconfig
+++ b/configs/qemu-riscv64_smode_defconfig
@@ -13,3 +13,7 @@ CONFIG_CMD_NVEDIT_EFI=y
# CONFIG_CMD_MII is not set
CONFIG_OF_PRIOR_STAGE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0 earlycon"
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000;"
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 790da976..dff48057 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -11,3 +11,5 @@ CONFIG_DISPLAY_CPUINFO=y
CONFIG_DISPLAY_BOARDINFO=y
CONFIG_OF_PRIOR_STAGE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttySIF0 earlycon"

View File

@ -0,0 +1,24 @@
diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
index a7b0e06a..99f8111a 100644
--- a/configs/qemu-riscv64_smode_defconfig
+++ b/configs/qemu-riscv64_smode_defconfig
@@ -14,3 +14,8 @@ CONFIG_CMD_NVEDIT_EFI=y
CONFIG_OF_PRIOR_STAGE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_DM_MTD=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0 earlycon"
+CONFIG_NR_CPUS=32
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000;"
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 7d38ec9a..b120537d 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -13,3 +13,6 @@ CONFIG_DISPLAY_BOARDINFO=y
CONFIG_OF_SEPARATE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_DM_MTD=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttySIF0 earlycon"
+CONFIG_NR_CPUS=32

4
riscv64-boards Normal file
View File

@ -0,0 +1,4 @@
qemu-riscv64
qemu-riscv64_smode
ae350_rv64
sifive_fu540

View File

@ -0,0 +1,31 @@
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
index fa9b9af9..bc831a84 100644
--- a/include/configs/qemu-riscv.h
+++ b/include/configs/qemu-riscv.h
@@ -56,6 +56,7 @@
"initrd_high=0xffffffffffffffff\0" \
"kernel_addr_r=0x84000000\0" \
"fdt_addr_r=0x88000000\0" \
+ "fdt_addr=0x88000000\0" \
"scriptaddr=0x88100000\0" \
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 736ceb1f..59cf0281 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -36,13 +36,10 @@
"initrd_high=0xffffffffffffffff\0" \
"kernel_addr_r=0x84000000\0" \
"fdt_addr_r=0x88000000\0" \
+ "fdt_addr=0x88000000\0" \
"scriptaddr=0x88100000\0" \
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
BOOTENV
-#define CONFIG_PREBOOT \
- "setenv fdt_addr ${fdtcontroladdr};" \
- "fdt addr ${fdtcontroladdr};"
-
#endif /* __CONFIG_H */

146
uboot-addappend.patch Normal file
View File

@ -0,0 +1,146 @@
diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index a636346b..9e2af76a 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -250,7 +250,7 @@ static struct pxe_label *label_create(void)
/*
* Free the memory used by a pxe_label, including that used by its name,
- * kernel, append and initrd members, if they're non NULL.
+ * kernel, append, addappend and initrd members, if they're non NULL.
*
* So - be sure to only use dynamically allocated memory for the members of
* the pxe_label struct, unless you want to clean it up first. These are
@@ -270,6 +270,9 @@ static void label_destroy(struct pxe_label *label)
if (label->append)
free(label->append);
+ if (label->addappend)
+ free(label->addappend);
+
if (label->initrd)
free(label->initrd);
@@ -301,7 +304,9 @@ static void label_print(void *data)
* environment variable is defined. Its contents will be executed as U-Boot
* command. If the label specified an 'append' line, its contents will be
* used to overwrite the contents of the 'bootargs' environment variable prior
- * to running 'localcmd'.
+ * to running 'localcmd'. If the label specified an 'addappend' line, it's
+ * contents will be appended to the 'bootargs' environment variable priot to
+ * running 'localcmd'.
*
* Returns 1 on success or < 0 on error.
*/
@@ -314,6 +319,22 @@ static int label_localboot(struct pxe_label *label)
if (!localcmd)
return -ENOENT;
+ if (label->addappend) {
+ char newbootargs[CONFIG_SYS_CBSIZE] = "";
+ char addappend[CONFIG_SYS_CBSIZE];
+
+ strncat(newbootargs, env_get("bootargs"), CONFIG_SYS_CBSIZE - 1);
+
+ cli_simple_process_macros(label->addappend, addappend);
+
+ if (strlen(newbootargs) + 1 < CONFIG_SYS_CBSIZE)
+ strcat(newbootargs, " ");
+ strncat(newbootargs, addappend,
+ CONFIG_SYS_CBSIZE - strlen(newbootargs) - 1);
+
+ env_set("bootargs", newbootargs);
+ }
+
if (label->append) {
char bootargs[CONFIG_SYS_CBSIZE];
@@ -340,6 +361,9 @@ static int label_localboot(struct pxe_label *label)
*
* If the label specifies an 'append' line, its contents will overwrite that
* of the 'bootargs' environment variable.
+ *
+ * If the label specifies an 'addappend' line, it's contents will be appended
+ * to the 'bootargs' environment variable.
*/
static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
{
@@ -406,19 +430,28 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
}
#endif
- if ((label->ipappend & 0x3) || label->append) {
+ if ((label->ipappend & 0x3) || label->append || label->addappend) {
char bootargs[CONFIG_SYS_CBSIZE] = "";
char finalbootargs[CONFIG_SYS_CBSIZE];
- if (strlen(label->append ?: "") +
+ if (strlen(label->append ?: "") + strlen(label->addappend ?: "") +
strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) {
- printf("bootarg overflow %zd+%zd+%zd+1 > %zd\n",
+ printf("bootarg overflow %zd+%zd+%zd+%zd+1 > %zd\n",
strlen(label->append ?: ""),
+ strlen(label->addappend ?: ""),
strlen(ip_str), strlen(mac_str),
sizeof(bootargs));
return 1;
}
+ if (label->addappend) {
+ strncat(bootargs, env_get("bootargs"), CONFIG_SYS_CBSIZE - 1);
+ if (strlen(bootargs) + 1 < CONFIG_SYS_CBSIZE)
+ strcat(bootargs, " ");
+ strncat(bootargs, label->addappend,
+ CONFIG_SYS_CBSIZE - strlen(bootargs) - 1);
+ }
+
if (label->append)
strncpy(bootargs, label->append, sizeof(bootargs));
@@ -570,6 +603,7 @@ enum token_type {
T_KERNEL,
T_LINUX,
T_APPEND,
+ T_ADDAPPEND,
T_INITRD,
T_LOCALBOOT,
T_DEFAULT,
@@ -605,6 +639,7 @@ static const struct token keywords[] = {
{"linux", T_LINUX},
{"localboot", T_LOCALBOOT},
{"append", T_APPEND},
+ {"addappend", T_ADDAPPEND},
{"initrd", T_INITRD},
{"include", T_INCLUDE},
{"devicetree", T_FDT},
@@ -1028,6 +1063,10 @@ static int parse_label(char **c, struct pxe_menu *cfg)
break;
+ case T_ADDAPPEND:
+ err = parse_sliteral(c, &label->addappend);
+ break;
+
case T_INITRD:
if (!label->initrd)
err = parse_sliteral(c, &label->initrd);
diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h
index a38ac81a..a6770679 100644
--- a/cmd/pxe_utils.h
+++ b/cmd/pxe_utils.h
@@ -28,6 +28,7 @@
* name - the name of the menu as given on the 'menu label' line.
* kernel - the path to the kernel file to use for this label.
* append - kernel command line to use when booting this label
+ * addappend - additional kernel command line options
* initrd - path to the initrd to use for this label.
* attempted - 0 if we haven't tried to boot this label, 1 if we have.
* localboot - 1 if this label specified 'localboot', 0 otherwise.
@@ -40,6 +41,7 @@ struct pxe_label {
char *kernel;
char *config;
char *append;
+ char *addappend;
char *initrd;
char *fdt;
char *fdtdir;

View File

@ -0,0 +1,24 @@
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
index 801d2f5c..0bcadb0f 100644
--- a/include/configs/qemu-riscv.h
+++ b/include/configs/qemu-riscv.h
@@ -59,6 +59,7 @@
"scriptaddr=0x88100000\0" \
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
+ "kernel_comp_addr_r=0x90000000\0" \
BOOTENV
#endif
diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
index 4fef86c1..864bb051 100644
--- a/include/configs/sifive-fu540.h
+++ b/include/configs/sifive-fu540.h
@@ -39,6 +39,7 @@
"scriptaddr=0x88100000\0" \
"pxefile_addr_r=0x88200000\0" \
"ramdisk_addr_r=0x88300000\0" \
+ "kernel_comp_addr_r=0x90000000\0" \
BOOTENV
#endif /* __CONFIG_H */

View File

@ -2,7 +2,7 @@
Name: uboot-tools
Version: 2020.01
Release: 1%{?candidate:.%{candidate}}%{?dist}
Release: 1%{?candidate:.%{candidate}}.0.riscv64%{?dist}
Summary: U-Boot utilities
License: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+
URL: http://www.denx.de/wiki/U-Boot
@ -13,6 +13,7 @@ Source2: arm-chromebooks
Source3: aarch64-boards
Source4: aarch64-chromebooks
Source5: 10-devicetree.install
Source6: riscv64-boards
# Fedoraisms patches
# Needed to find DT on boot partition that's not the first partition
@ -29,6 +30,32 @@ Patch8: arm-tegra-defaine-fdtfile-for-all-devices.patch
Patch9: zynqmp-Add-support-for-u-boot.itb-generation-with-ATF.patch
Patch10: zynqmp-Do-not-assing-MIO34-that-early-on-zcu100.patch
# PXE depends on fdt_addr (mandatory)
# fdt_addr is an address to DTB in HW (e.g. ROM)
# While off-chip NVM QSPI Flash is mapped to the memory our DTB comes from
# FSBL or OpenSBI (most likely).
# Both (FSBL and OpenSBI) incl. the latest DTB directly from the kernel build.
# Thus we have to set fdt_addr to the save value as fdt_addr_r which matches
# the location where OpenSBI will place embedded DTB.
Patch20: riscv64-set-fdt_addr.patch
# Set bootargs (console and earlycon)
# Set CPUs to 32 (same as Linux)
Patch21: riscv-set-bootargs-nrcpus-preboot.patch
# Not upstream
# Adds support for Image.gz to booti (RFC/RFT)
# See: https://patchwork.ozlabs.org/patch/1174807/
Patch22: image-add-image.gz-parsing-support-in-booti.patch
# Not upstream
# Add 'addappend' label to PXE/EXTLINUX configuration
Patch23: uboot-addappend.patch
# Not upstream
# Define kernel_comp_addr_r and filesize for booti Image.gz support
Patch24: uboot-riscv-def-kernel_comp_addr_r.patch
BuildRequires: bc
BuildRequires: dtc
BuildRequires: make
@ -88,10 +115,20 @@ BuildArch: noarch
u-boot bootloader binaries for armv7 boards
%endif
%ifarch riscv64
%package -n uboot-images-riscv64
Summary: u-boot bootloader images for riscv64 boards
Requires: uboot-tools
BuildArch: noarch
%description -n uboot-images-riscv64
u-boot bootloader binaries for riscv64 boards
%endif
%prep
%autosetup -p1 -n u-boot-%{version}%{?candidate:-%{candidate}}
cp %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4 .
cp %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4 %SOURCE6 .
%build
mkdir builds
@ -101,7 +138,7 @@ mkdir builds
%{?enable_devtoolset7:%{enable_devtoolset7}}
%endif
%ifarch aarch64 %{arm}
%ifarch aarch64 %{arm} riscv64
for board in $(cat %{_arch}-boards)
do
echo "Building board: $board"
@ -195,6 +232,19 @@ do
done
%endif
%ifarch riscv64
for board in $(cat %{_arch}-boards)
do
mkdir -p $RPM_BUILD_ROOT%{_datadir}/uboot/$(echo $board)/
for file in u-boot.bin u-boot-nodtb.bin
do
if [ -f builds/$(echo $board)/$(echo $file) ]; then
install -p -m 0644 builds/$(echo $board)/$(echo $file) $RPM_BUILD_ROOT%{_datadir}/uboot/$(echo $board)/
fi
done
done
%endif
for tool in bmp_logo dumpimage env/fw_printenv fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr gen_ethaddr_crc img2srec mkenvimage mkimage mksunxiboot ncb proftool sunxi-spl-image-builder ubsha1 xway-swap-bytes
do
install -p -m 0755 builds/tools/$tool $RPM_BUILD_ROOT%{_bindir}
@ -248,7 +298,19 @@ cp -p board/warp7/README builds/docs/README.warp7
%{_datadir}/uboot/*
%endif
%ifarch riscv64
%files -n uboot-images-riscv64
%{_datadir}/uboot/*
%endif
%changelog
* Tue Jan 7 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> 2020.01-1.0.riscv64
- Add support for RISC-V (riscv64)
- Define filesize and kernel_comp_addr_r for QEMU virt and SiFive FU540 boards
to support Image.gz with booti
- Add 'addappend' label to PXE/EXTLINUX configuration
- Match CONFIG_NR_CPUS to Linux configuration (32)
* Tue Jan 7 2020 Peter Robinson <pbrobinson@fedoraproject.org> 2020.01-1
- 2020.01