Skip to contentSkip to conversation

RISCV: image: Add booti support.

PATCH Superseded Atish Patra 2 participants 3 messages May 1, 2019 – May 6, 2019 1 message not in the archive RISC-V

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 RISCV: image: Add booti support.

This patch adds booti support for RISC-V Linux kernel. The existing bootm method will also continue to work as it is.

It depends on the following kernel patch which adds the header to the flat Image. Gzip compressed Image (Image.gz) support is not enabled with this patch.

https://patchwork.kernel.org/patch/10925543/

Tested on HiFive Unleashed and QEMU.

--
Changes from v2->v3
1. Updated the image header structure as per kernel patch.
2. Removed Image.gz support as it will be added as separate RFC patch.

---
 arch/riscv/lib/Makefile |  1 +
 arch/riscv/lib/image.c  | 55 +++++++++++++++++++++++++++++++++++++++++
 cmd/Kconfig             |  2 +-
 cmd/booti.c             |  8 ++++--
 4 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 arch/riscv/lib/image.c
arch/riscv/lib/Makefile +1 -0
index 1c332db436a9..6ae6ebbeafda 100644
@@ -7,6 +7,7 @@
 # Rick Chen, Andes Technology Corporation <[email protected]>
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-$(CONFIG_RISCV_RDTIME) += rdtime.o
arch/riscv/lib/image.c new file +55 -0

55 lines not on this page · raw message

cmd/Kconfig +1 -1
index 2bdbfcb3d091..d427b66d3714 100644
@@ -212,7 +212,7 @@ config CMD_BOOTZ
 
 config CMD_BOOTI
 	bool "booti"
-	depends on ARM64
+	depends on ARM64 || RISCV
 	default y
 	help
 	  Boot an AArch64 Linux Kernel image from memory.
cmd/booti.c +6 -2
index 04353b68eccc..c22ba9bae2e4 100644
@@ -77,7 +77,11 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	bootm_disable_interrupts();
 
 	images.os.os = IH_OS_LINUX;
+	#ifdef CONFIG_RISCV_SMODE
+		images.os.arch = IH_ARCH_RISCV;
+	#elif CONFIG_ARM64
 		images.os.arch = IH_ARCH_ARM64;
+	#endif
 	ret = do_bootm_states(cmdtp, flag, argc, argv,
 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
 			      BOOTM_STATE_RAMDISK |
@@ -92,7 +96,7 @@ 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 arm64 Linux Image stored in memory\n"
+	"    - boot arm64/riscv Linux Image stored in memory\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"
@@ -107,5 +111,5 @@ static char booti_help_text[] =
 
 U_BOOT_CMD(
 	booti,	CONFIG_SYS_MAXARGS,	1,	do_booti,
-	"boot arm64 Linux Image image from memory", booti_help_text
+	"boot arm64/riscv Linux Image image from memory", booti_help_text
 );
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/1 RISCV: image: Add booti support.

Quoted 9 lines · Atish Patra

This patch adds booti support for RISC-V Linux kernel. The existing bootm method will also continue to work as it is.

It depends on the following kernel patch which adds the header to the flat Image. Gzip compressed Image (Image.gz) support is not enabled with this patch.

https://patchwork.kernel.org/patch/10925543/

Quoted 7 lines

Tested on HiFive Unleashed and QEMU.

--
Changes from v2->v3
1. Updated the image header structure as per kernel patch.
2. Removed Image.gz support as it will be added as separate RFC patch.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190501/ee4ea743/attachment.sig>

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH v3 1/1 RISCV: image: Add booti support.

Quoted 16 lines · Karsten Merker
Quoted 7 lines · Atish Patra

This patch adds booti support for RISC-V Linux kernel. The existing bootm method will also continue to work as it is.

It depends on the following kernel patch which adds the header to the flat Image. Gzip compressed Image (Image.gz) support is not enabled with this patch.

Quoted 5 lines

https://patchwork.kernel.org/patch/10925543/

Tested on HiFive Unleashed and QEMU.

Hello,

Quoted 8 lines

the patch (both directly from my inbox as well as from patchwork) appears to be mangled and doesn't apply cleanly:

Applying: RISCV: image: Add booti support.
error: patch failed: cmd/booti.c:77
error: cmd/booti.c: patch does not apply Patch failed at 0001 RISCV: image: Add booti support.

I have fixed the patch and sent a v4. That should cleanly apply on top of master.

Quoted 6 lines

I have manually applied the changes on top of 2019.07-rc1 and run a number of tests together with the corresponding kernel patch (https://patchwork.kernel.org/patch/10925543/). With the patch applied I can successfully boot a kernel and an initramfs with booti on a qemu-system-riscv64 "virt" machine:

Thanks for testing the patch.

Regards,
Atish

Quoted 56 lines

OpenSBI v0.3 (May 4 2019 20:32:00)

    ____                    _____ ____ _____
   / __ \                  / ____|  _ \_   _|
  | |  | |_ __   ___ _ __ | (___ | |_) || |
  | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
  | |__| | |_) |  __/ | | |____) | |_) || |_
   \____/| .__/ \___|_| |_|_____/|____/_____|
         | |
         |_|

Platform Name : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs : 8
Current Hart : 0
Firmware Base : 0x80000000
Firmware Size : 100 KB
Runtime SBI Version : 0.1

PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)

U-Boot 2019.07-rc1-00001-g6b6a8d27ea-dirty (May 05 2019 - 01:05:15 +0200)

CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  8 GiB
In:    uart at 10000000
Out:   uart at 10000000
Err:   uart at 10000000

Net:
Warning: virtio-net#2 using MAC address from ROM
eth0: virtio-net#2
Hit any key to stop autoboot: 0
=> load virtio 0:1 ${kernel_addr_r} /boot/vmlinux-5.0.0-trunk-riscv64 9073676 bytes read in 5 ms (1.7 GiB/s)
=> load virtio 0:1 ${ramdisk_addr_r} /boot/initrd.img-5.0.0-trunk-riscv64 45823535 bytes read in 14 ms (3 GiB/s)
=> booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdtcontroladdr} ## Flattened Device Tree blob at ff77bd30

    Booting using the fdt blob at 0xff77bd30
    Using Device Tree in place at 00000000ff77bd30, end 00000000ff77fda5

Starting kernel ...

[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] No DTB passed to the kernel
[    0.000000] Linux version 5.0.0-trunk-riscv64 (debian-kernel at lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-7)) #1 SMP Debian 5.0.10-1~exp1 (2019-03-22)
[    0.000000] Initial ramdisk at: 0x(____ptrval____) (45823535 bytes)

[...]

Regards,
Karsten