All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
@ 2018-04-23  5:59 Alexander Graf
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code Alexander Graf
                   ` (9 more replies)
  0 siblings, 10 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

We now have RISC-V support in U-Boot - which is great!

However, not that we're finally making progress to converge on
efi_loader and distro boot for booting on ARM platforms, we
really want to make sure there is no technical reason not to
do the same on RISC-V as well.

So this patch set introduces distro boot and efi_loader support
for RISC-V!

So far, I've only tested it with the selftest and hello world
target in U-Boot, as the number of target binaries to run is
still slim. But it should at least give us a good starting point.

v1 -> v2:

  - Allow 32bit target
  - Also save/restore ra, sp
  - Use edk2 default boot file names
  - Enable hello world binary
  - remove patch: efi_loader: selftest: Do not build relocation tests for risc-v
  - new patch: riscv: Add EFI application infrastructure

v2 -> v3:

  - Add missing crt0 source
  - Use official values for vci

Alexander Graf (8):
  riscv: Add setjmp/longjmp code
  riscv: Enable function sections
  riscv: Add EFI application infrastructure
  riscv: Add board_quiesce_devices stub
  efi_loader: Use EFI_CACHELINE_SIZE in the image loader too
  distro: Extend with RISC-V defines
  riscv: nx25: Enable distro boot
  efi_loader: Enable RISC-V support

 arch/riscv/config.mk                  |   7 +-
 arch/riscv/cpu/nx25/u-boot.lds        |  16 ++++
 arch/riscv/include/asm/setjmp.h       |  26 ++++++
 arch/riscv/include/asm/u-boot-riscv.h |   1 +
 arch/riscv/lib/Makefile               |  12 +++
 arch/riscv/lib/bootm.c                |   4 +
 arch/riscv/lib/crt0_riscv_efi.S       | 152 ++++++++++++++++++++++++++++++++++
 arch/riscv/lib/elf_riscv32_efi.lds    |  70 ++++++++++++++++
 arch/riscv/lib/elf_riscv64_efi.lds    |  70 ++++++++++++++++
 arch/riscv/lib/reloc_riscv_efi.c      |  97 ++++++++++++++++++++++
 arch/riscv/lib/setjmp.S               |  66 +++++++++++++++
 cmd/Kconfig                           |   2 +-
 configs/nx25-ae250_defconfig          |   1 +
 include/config_distro_bootcmd.h       |  11 +++
 include/configs/nx25-ae250.h          |  17 ++++
 include/efi_loader.h                  |   7 ++
 lib/efi_loader/Kconfig                |   2 +-
 lib/efi_loader/efi_image_loader.c     |   2 +-
 lib/efi_loader/efi_runtime.c          |  48 ++++++++---
 19 files changed, 595 insertions(+), 16 deletions(-)
 create mode 100644 arch/riscv/include/asm/setjmp.h
 create mode 100644 arch/riscv/lib/crt0_riscv_efi.S
 create mode 100644 arch/riscv/lib/elf_riscv32_efi.lds
 create mode 100644 arch/riscv/lib/elf_riscv64_efi.lds
 create mode 100644 arch/riscv/lib/reloc_riscv_efi.c
 create mode 100644 arch/riscv/lib/setjmp.S

-- 
2.12.3

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-05-07  2:25   ` rick at andestech.com
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 2/8] riscv: Enable function sections Alexander Graf
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

To support efi_loader we need to have platform support for setjmp/longjmp.
Add it here.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - Allow 32bit target
  - Also save/restore ra, sp
---
 arch/riscv/include/asm/setjmp.h | 26 ++++++++++++++++
 arch/riscv/lib/Makefile         |  1 +
 arch/riscv/lib/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 arch/riscv/include/asm/setjmp.h
 create mode 100644 arch/riscv/lib/setjmp.S

diff --git a/arch/riscv/include/asm/setjmp.h b/arch/riscv/include/asm/setjmp.h
new file mode 100644
index 0000000000..01ad6d081f
--- /dev/null
+++ b/arch/riscv/include/asm/setjmp.h
@@ -0,0 +1,26 @@
+/*
+ * (C) Copyright 2018 Alexander Graf <agraf@suse.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_	1
+
+/*
+ * This really should be opaque, but the EFI implementation wrongly
+ * assumes that a 'struct jmp_buf_data' is defined.
+ */
+struct jmp_buf_data {
+	/* x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, sp */
+	unsigned long s_regs[12];	/* s0 - s11 */
+	unsigned long ra;
+	unsigned long sp;
+};
+
+typedef struct jmp_buf_data jmp_buf[1];
+
+int setjmp(jmp_buf jmp);
+void longjmp(jmp_buf jmp, int ret);
+
+#endif /* _SETJMP_H_ */
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index 323cf3e835..6d97aa2719 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-y	+= interrupts.o
+obj-y   += setjmp.o
diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S
new file mode 100644
index 0000000000..103f359185
--- /dev/null
+++ b/arch/riscv/lib/setjmp.S
@@ -0,0 +1,66 @@
+/*
+ * (C) 2018 Alexander Graf <agraf@suse.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+
+#ifdef CONFIG_CPU_RISCV_64
+#define STORE_IDX(reg, idx)	sd reg, (idx*8)(a0)
+#define LOAD_IDX(reg, idx)	ld reg, (idx*8)(a0)
+#else
+#define STORE_IDX(reg, idx)	sw reg, (idx*4)(a0)
+#define LOAD_IDX(reg, idx)	lw reg, (idx*4)(a0)
+#endif
+
+.pushsection .text.setjmp, "ax"
+ENTRY(setjmp)
+	/* Preserve all callee-saved registers and the SP */
+	STORE_IDX(s0, 0)
+	STORE_IDX(s1, 1)
+	STORE_IDX(s2, 2)
+	STORE_IDX(s3, 3)
+	STORE_IDX(s4, 4)
+	STORE_IDX(s5, 5)
+	STORE_IDX(s6, 6)
+	STORE_IDX(s7, 7)
+	STORE_IDX(s8, 8)
+	STORE_IDX(s9, 9)
+	STORE_IDX(s10, 10)
+	STORE_IDX(s11, 11)
+	STORE_IDX(ra, 12)
+	STORE_IDX(sp, 13)
+	li  a0, 0
+	ret
+ENDPROC(setjmp)
+.popsection
+
+.pushsection .text.longjmp, "ax"
+ENTRY(longjmp)
+	LOAD_IDX(s0, 0)
+	LOAD_IDX(s1, 1)
+	LOAD_IDX(s2, 2)
+	LOAD_IDX(s3, 3)
+	LOAD_IDX(s4, 4)
+	LOAD_IDX(s5, 5)
+	LOAD_IDX(s6, 6)
+	LOAD_IDX(s7, 7)
+	LOAD_IDX(s8, 8)
+	LOAD_IDX(s9, 9)
+	LOAD_IDX(s10, 10)
+	LOAD_IDX(s11, 11)
+	LOAD_IDX(ra, 12)
+	LOAD_IDX(sp, 13)
+
+	/* Move the return value in place, but return 1 if passed 0. */
+	beq a1, zero, longjmp_1
+	mv a0, a1
+	ret
+
+	longjmp_1:
+	li a0, 1
+	ret
+ENDPROC(longjmp)
+.popsection
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 2/8] riscv: Enable function sections
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-04-23  7:35   ` Heinrich Schuchardt
  2018-05-07  2:24   ` rick at andestech.com
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 3/8] riscv: Add EFI application infrastructure Alexander Graf
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

The linker can remove sections that are never addressed, so it makes a lot
of sense to declare every function as an individual section.

This reduces the output U-Boot code size by ~30kb for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/riscv/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 6b681c4286..69f4cf6ce8 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
 			      -T $(srctree)/examples/standalone/riscv.lds
 
 PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
-PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
+PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections
 LDFLAGS_u-boot += --gc-sections -static -pie
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 3/8] riscv: Add EFI application infrastructure
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code Alexander Graf
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 2/8] riscv: Enable function sections Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub Alexander Graf
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

The hello world binary and a few selftests require to build EFI target
binaries, not just the EFI host environment.

This patch adds all required files to generate an EFI binary for
RISC-V.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

new in v2

v2 -> v3:

  - Add missing crt0 source
---
 arch/riscv/config.mk               |   5 ++
 arch/riscv/lib/Makefile            |  11 +++
 arch/riscv/lib/crt0_riscv_efi.S    | 152 +++++++++++++++++++++++++++++++++++++
 arch/riscv/lib/elf_riscv32_efi.lds |  70 +++++++++++++++++
 arch/riscv/lib/elf_riscv64_efi.lds |  70 +++++++++++++++++
 arch/riscv/lib/reloc_riscv_efi.c   |  97 +++++++++++++++++++++++
 6 files changed, 405 insertions(+)
 create mode 100644 arch/riscv/lib/crt0_riscv_efi.S
 create mode 100644 arch/riscv/lib/elf_riscv32_efi.lds
 create mode 100644 arch/riscv/lib/elf_riscv64_efi.lds
 create mode 100644 arch/riscv/lib/reloc_riscv_efi.c

diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index 69f4cf6ce8..9175aa765d 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -19,10 +19,12 @@ endif
 
 ifdef CONFIG_32BIT
 PLATFORM_LDFLAGS	+= -m $(32bit-emul)
+EFI_LDS			:= elf_riscv32_efi.lds
 endif
 
 ifdef CONFIG_64BIT
 PLATFORM_LDFLAGS	+= -m $(64bit-emul)
+EFI_LDS			:= elf_riscv64_efi.lds
 endif
 
 CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
@@ -31,3 +33,6 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
 PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
 PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections
 LDFLAGS_u-boot += --gc-sections -static -pie
+
+EFI_CRT0		:= crt0_riscv_efi.o
+EFI_RELOC		:= reloc_riscv_efi.o
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index 6d97aa2719..33f80ebdca 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -13,3 +13,14 @@ obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-y	+= interrupts.o
 obj-y   += setjmp.o
+
+# For building EFI apps
+CFLAGS_$(EFI_CRT0) := $(CFLAGS_EFI)
+CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI)
+
+CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI)
+CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI)
+
+extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC)
+extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC)
+extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)
diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
new file mode 100644
index 0000000000..498870e1be
--- /dev/null
+++ b/arch/riscv/lib/crt0_riscv_efi.S
@@ -0,0 +1,152 @@
+/*
+ * crt0-efi-riscv.S - PE/COFF header for RISC-V EFI applications
+ *
+ * Copright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
+ * Copright (C) 2018 Alexander Graf <agraf@suse.de>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+     BSD-2-Clause
+ *
+ * This file is inspired by arch/arm/lib/crt0_aarch64_efi.S
+ */
+
+#include <asm-generic/pe.h>
+
+#if __riscv_xlen == 64
+#define SIZE_LONG	8
+#define SAVE_LONG(reg, idx)	sd	reg, (idx*SIZE_LONG)(sp)
+#define LOAD_LONG(reg, idx)	ld	reg, (idx*SIZE_LONG)(sp)
+#define PE_MACHINE	0x5064
+#else
+#define SIZE_LONG	4
+#define SAVE_LONG(reg, idx)	sw	reg, (idx*SIZE_LONG)(sp)
+#define LOAD_LONG(reg, idx)	lw	reg, (idx*SIZE_LONG)(sp)
+#define PE_MACHINE	0x5032
+#endif
+
+
+	.section	.text.head
+
+	/*
+	 * Magic "MZ" signature for PE/COFF
+	 */
+	.globl	ImageBase
+ImageBase:
+	.ascii	"MZ"
+	.skip	58				/* 'MZ' + pad + offset == 64 */
+	.long	pe_header - ImageBase		/* Offset to the PE header */
+pe_header:
+	.ascii	"PE"
+	.short	0
+coff_header:
+	.short	PE_MACHINE			/* RISC-V 64/32-bit */
+	.short	2				/* nr_sections */
+	.long	0				/* TimeDateStamp */
+	.long	0				/* PointerToSymbolTable */
+	.long	1				/* NumberOfSymbols */
+	.short	section_table - optional_header	/* SizeOfOptionalHeader */
+	/*
+	 * Characteristics: IMAGE_FILE_DEBUG_STRIPPED |
+	 * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED
+	 */
+	.short	0x206
+optional_header:
+	.short	0x20b				/* PE32+ format */
+	.byte	0x02				/* MajorLinkerVersion */
+	.byte	0x14				/* MinorLinkerVersion */
+	.long	_edata - _start			/* SizeOfCode */
+	.long	0				/* SizeOfInitializedData */
+	.long	0				/* SizeOfUninitializedData */
+	.long	_start - ImageBase		/* AddressOfEntryPoint */
+	.long	_start - ImageBase		/* BaseOfCode */
+
+extra_header_fields:
+	.quad	0				/* ImageBase */
+	.long	0x20				/* SectionAlignment */
+	.long	0x8				/* FileAlignment */
+	.short	0				/* MajorOperatingSystemVersion */
+	.short	0				/* MinorOperatingSystemVersion */
+	.short	0				/* MajorImageVersion */
+	.short	0				/* MinorImageVersion */
+	.short	0				/* MajorSubsystemVersion */
+	.short	0				/* MinorSubsystemVersion */
+	.long	0				/* Win32VersionValue */
+
+	.long	_edata - ImageBase		/* SizeOfImage */
+
+	/*
+	 * Everything before the kernel image is considered part of the header
+	 */
+	.long	_start - ImageBase		/* SizeOfHeaders */
+	.long	0				/* CheckSum */
+	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
+	.short	0				/* DllCharacteristics */
+	.quad	0				/* SizeOfStackReserve */
+	.quad	0				/* SizeOfStackCommit */
+	.quad	0				/* SizeOfHeapReserve */
+	.quad	0				/* SizeOfHeapCommit */
+	.long	0				/* LoaderFlags */
+	.long	0x6				/* NumberOfRvaAndSizes */
+
+	.quad	0				/* ExportTable */
+	.quad	0				/* ImportTable */
+	.quad	0				/* ResourceTable */
+	.quad	0				/* ExceptionTable */
+	.quad	0				/* CertificationTable */
+	.quad	0				/* BaseRelocationTable */
+
+	/* Section table */
+section_table:
+
+	/*
+	 * The EFI application loader requires a relocation section
+	 * because EFI applications must be relocatable.  This is a
+	 * dummy section as far as we are concerned.
+	 */
+	.ascii	".reloc"
+	.byte	0
+	.byte	0			/* end of 0 padding of section name */
+	.long	0
+	.long	0
+	.long	0			/* SizeOfRawData */
+	.long	0			/* PointerToRawData */
+	.long	0			/* PointerToRelocations */
+	.long	0			/* PointerToLineNumbers */
+	.short	0			/* NumberOfRelocations */
+	.short	0			/* NumberOfLineNumbers */
+	.long	0x42100040		/* Characteristics (section flags) */
+
+
+	.ascii	".text"
+	.byte	0
+	.byte	0
+	.byte	0			/* end of 0 padding of section name */
+	.long	_edata - _start		/* VirtualSize */
+	.long	_start - ImageBase	/* VirtualAddress */
+	.long	_edata - _start		/* SizeOfRawData */
+	.long	_start - ImageBase	/* PointerToRawData */
+
+	.long	0		/* PointerToRelocations (0 for executables) */
+	.long	0		/* PointerToLineNumbers (0 for executables) */
+	.short	0		/* NumberOfRelocations  (0 for executables) */
+	.short	0		/* NumberOfLineNumbers  (0 for executables) */
+	.long	0xe0500020	/* Characteristics (section flags) */
+
+_start:
+	addi		sp, sp, -(SIZE_LONG * 3)
+	SAVE_LONG(a0, 0)
+	SAVE_LONG(a1, 1)
+	SAVE_LONG(ra, 2)
+
+	lla		a0, ImageBase
+	lla		a1, _DYNAMIC
+	call		_relocate
+	bne		a0, zero, 0f
+
+	LOAD_LONG(a1, 1)
+	LOAD_LONG(a0, 0)
+	call		efi_main
+
+	LOAD_LONG(ra, 2)
+
+0:	addi		sp, sp, (SIZE_LONG * 3)
+	ret
diff --git a/arch/riscv/lib/elf_riscv32_efi.lds b/arch/riscv/lib/elf_riscv32_efi.lds
new file mode 100644
index 0000000000..96d11985b0
--- /dev/null
+++ b/arch/riscv/lib/elf_riscv32_efi.lds
@@ -0,0 +1,70 @@
+/*
+ * U-Boot riscv32 EFI linker script
+ *
+ * SPDX-License-Identifier:	BSD-2-Clause
+ *
+ * Modified from arch/arm/lib/elf_aarch64_efi.lds
+ */
+
+OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
+OUTPUT_ARCH(riscv)
+ENTRY(_start)
+SECTIONS
+{
+	.text 0x0 : {
+		_text = .;
+		*(.text.head)
+		*(.text)
+		*(.text.*)
+		*(.gnu.linkonce.t.*)
+		*(.srodata)
+		*(.rodata*)
+		. = ALIGN(16);
+	}
+	_etext = .;
+	_text_size = . - _text;
+	.dynamic  : { *(.dynamic) }
+	.data : {
+		_data = .;
+		*(.sdata)
+		*(.data)
+		*(.data1)
+		*(.data.*)
+		*(.got.plt)
+		*(.got)
+
+		/*
+		 * The EFI loader doesn't seem to like a .bss section, so we
+		 * stick it all into .data:
+		 */
+		. = ALIGN(16);
+		_bss = .;
+		*(.sbss)
+		*(.scommon)
+		*(.dynbss)
+		*(.bss)
+		*(.bss.*)
+		*(COMMON)
+		. = ALIGN(16);
+		_bss_end = .;
+		_edata = .;
+	}
+	.rela.dyn : { *(.rela.dyn) }
+	.rela.plt : { *(.rela.plt) }
+	.rela.got : { *(.rela.got) }
+	.rela.data : { *(.rela.data) *(.rela.data*) }
+	_data_size = . - _etext;
+
+	. = ALIGN(4096);
+	.dynsym   : { *(.dynsym) }
+	. = ALIGN(4096);
+	.dynstr   : { *(.dynstr) }
+	. = ALIGN(4096);
+	.note.gnu.build-id : { *(.note.gnu.build-id) }
+	/DISCARD/ : {
+		*(.rel.reloc)
+		*(.eh_frame)
+		*(.note.GNU-stack)
+	}
+	.comment 0 : { *(.comment) }
+}
diff --git a/arch/riscv/lib/elf_riscv64_efi.lds b/arch/riscv/lib/elf_riscv64_efi.lds
new file mode 100644
index 0000000000..25c863de8a
--- /dev/null
+++ b/arch/riscv/lib/elf_riscv64_efi.lds
@@ -0,0 +1,70 @@
+/*
+ * U-Boot riscv64 EFI linker script
+ *
+ * SPDX-License-Identifier:	BSD-2-Clause
+ *
+ * Modified from arch/arm/lib/elf_aarch64_efi.lds
+ */
+
+OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
+OUTPUT_ARCH(riscv)
+ENTRY(_start)
+SECTIONS
+{
+	.text 0x0 : {
+		_text = .;
+		*(.text.head)
+		*(.text)
+		*(.text.*)
+		*(.gnu.linkonce.t.*)
+		*(.srodata)
+		*(.rodata*)
+		. = ALIGN(16);
+	}
+	_etext = .;
+	_text_size = . - _text;
+	.dynamic  : { *(.dynamic) }
+	.data : {
+		_data = .;
+		*(.sdata)
+		*(.data)
+		*(.data1)
+		*(.data.*)
+		*(.got.plt)
+		*(.got)
+
+		/*
+		 * The EFI loader doesn't seem to like a .bss section, so we
+		 * stick it all into .data:
+		 */
+		. = ALIGN(16);
+		_bss = .;
+		*(.sbss)
+		*(.scommon)
+		*(.dynbss)
+		*(.bss)
+		*(.bss.*)
+		*(COMMON)
+		. = ALIGN(16);
+		_bss_end = .;
+		_edata = .;
+	}
+	.rela.dyn : { *(.rela.dyn) }
+	.rela.plt : { *(.rela.plt) }
+	.rela.got : { *(.rela.got) }
+	.rela.data : { *(.rela.data) *(.rela.data*) }
+	_data_size = . - _etext;
+
+	. = ALIGN(4096);
+	.dynsym   : { *(.dynsym) }
+	. = ALIGN(4096);
+	.dynstr   : { *(.dynstr) }
+	. = ALIGN(4096);
+	.note.gnu.build-id : { *(.note.gnu.build-id) }
+	/DISCARD/ : {
+		*(.rel.reloc)
+		*(.eh_frame)
+		*(.note.GNU-stack)
+	}
+	.comment 0 : { *(.comment) }
+}
diff --git a/arch/riscv/lib/reloc_riscv_efi.c b/arch/riscv/lib/reloc_riscv_efi.c
new file mode 100644
index 0000000000..d80ffc975c
--- /dev/null
+++ b/arch/riscv/lib/reloc_riscv_efi.c
@@ -0,0 +1,97 @@
+/* reloc_riscv.c - position independent ELF shared object relocator
+   Copyright (C) 2018 Alexander Graf <agraf@suse.de>
+   Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
+   Copyright (C) 1999 Hewlett-Packard Co.
+	Contributed by David Mosberger <davidm@hpl.hp.com>.
+
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions
+    are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials
+      provided with the distribution.
+    * Neither the name of Hewlett-Packard Co. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+    CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+    BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+    THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+    SUCH DAMAGE.
+*/
+
+#include <efi.h>
+
+#include <elf.h>
+
+#if __riscv_xlen == 64
+#define Elf_Dyn		Elf64_Dyn
+#define Elf_Rela	Elf64_Rela
+#define ELF_R_TYPE	ELF64_R_TYPE
+#else
+#define Elf_Dyn		Elf32_Dyn
+#define Elf_Rela	Elf32_Rela
+#define ELF_R_TYPE	ELF32_R_TYPE
+#endif
+
+efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image,
+		       struct efi_system_table *systab)
+{
+	long relsz = 0, relent = 0;
+	Elf_Rela *rel = 0;
+	unsigned long *addr;
+	int i;
+
+	for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
+		switch (dyn[i].d_tag) {
+		case DT_RELA:
+			rel = (Elf_Rela *)((ulong)dyn[i].d_un.d_ptr + ldbase);
+			break;
+		case DT_RELASZ:
+			relsz = dyn[i].d_un.d_val;
+			break;
+		case DT_RELAENT:
+			relent = dyn[i].d_un.d_val;
+			break;
+		default:
+			break;
+		}
+	}
+
+	if (!rel && relent == 0)
+		return EFI_SUCCESS;
+
+	if (!rel || relent == 0)
+		return EFI_LOAD_ERROR;
+
+	while (relsz > 0) {
+		/* apply the relocs */
+		switch (ELF_R_TYPE(rel->r_info)) {
+		case R_RISCV_RELATIVE:
+			addr = (ulong *)(ldbase + rel->r_offset);
+			*addr = ldbase + rel->r_addend;
+			break;
+		default:
+			/* Panic */
+			while (1) ;
+		}
+		rel = (Elf_Rela *)((char *)rel + relent);
+		relsz -= relent;
+	}
+	return EFI_SUCCESS;
+}
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (2 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 3/8] riscv: Add EFI application infrastructure Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-05-07  2:25   ` rick at andestech.com
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too Alexander Graf
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

This patch adds an empty stub for board_quiesce_devices() which allows boards
to quiesce their devices before we boot into an OS in a platform agnostic way.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/riscv/include/asm/u-boot-riscv.h | 1 +
 arch/riscv/lib/bootm.c                | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/arch/riscv/include/asm/u-boot-riscv.h b/arch/riscv/include/asm/u-boot-riscv.h
index 18099cd260..0b6428b1ae 100644
--- a/arch/riscv/include/asm/u-boot-riscv.h
+++ b/arch/riscv/include/asm/u-boot-riscv.h
@@ -17,5 +17,6 @@ int cleanup_before_linux(void);
 
 /* board/.../... */
 int board_init(void);
+void board_quiesce_devices(void);
 
 #endif	/* _U_BOOT_RISCV_H_ */
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 9242fa891a..b80274adba 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -16,6 +16,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+__weak void board_quiesce_devices(void)
+{
+}
+
 int arch_fixup_fdt(void *blob)
 {
 	return 0;
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (3 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-04-23  7:19   ` Heinrich Schuchardt
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines Alexander Graf
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

We were using our EFI_CACHELINE_SIZE define only in the runtime service
code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE.

This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts
the image loader to use it.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/efi_loader.h              | 7 +++++++
 lib/efi_loader/efi_image_loader.c | 2 +-
 lib/efi_loader/efi_runtime.c      | 7 -------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 17f9d3d1ef..0b1b3df55a 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -76,6 +76,13 @@ const char *__efi_nesting_dec(void);
 		##__VA_ARGS__); \
 	})
 
+#ifdef CONFIG_SYS_CACHELINE_SIZE
+#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
+#else
+/* Just use the greatest cache flush alignment requirement I'm aware of */
+#define EFI_CACHELINE_SIZE 128
+#endif
+
 extern struct efi_runtime_services efi_runtime_services;
 extern struct efi_system_table systab;
 
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index d5fbba3138..2476a97a6a 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -290,7 +290,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
 
 	/* Flush cache */
 	flush_cache((ulong)efi_reloc,
-		    ALIGN(virt_size, CONFIG_SYS_CACHELINE_SIZE));
+		    ALIGN(virt_size, EFI_CACHELINE_SIZE));
 	invalidate_icache_all();
 
 	/* Populate the loaded image interface bits */
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 8558124c0a..573a5d6ac1 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -30,13 +30,6 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
 static efi_status_t __efi_runtime EFIAPI efi_device_error(void);
 static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
 
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
-#else
-/* Just use the greatest cache flush alignment requirement I'm aware of */
-#define EFI_CACHELINE_SIZE 128
-#endif
-
 #if defined(CONFIG_ARM64)
 #define R_RELATIVE	1027
 #define R_MASK		0xffffffffULL
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (4 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-04-23  6:56   ` Heinrich Schuchardt
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot Alexander Graf
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

While we don't have UEFI naming conventions for RISC-V file paths yet,
we need to search for something. So let's copy the removable file paths
from the RISC-V edk2 port.

Also add the official VCI strings that contain the standardized RISC-V
architecture ID fields.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - Use edk2 default boot file names

v2 -> v3:

  - Use official values for vci
---
 include/config_distro_bootcmd.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index f567cebd38..989b5556af 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -100,6 +100,10 @@
 #define BOOTEFI_NAME "bootia32.efi"
 #elif defined(CONFIG_X86_RUN_64BIT)
 #define BOOTEFI_NAME "bootx64.efi"
+#elif defined(CONFIG_CPU_RISCV_32)
+#define BOOTEFI_NAME "bootriscv32.efi"
+#elif defined(CONFIG_CPU_RISCV_64)
+#define BOOTEFI_NAME "bootriscv64.efi"
 #endif
 #endif
 
@@ -241,6 +245,7 @@
 
 #if defined(CONFIG_CMD_DHCP)
 #if defined(CONFIG_EFI_LOADER)
+/* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
 #if defined(CONFIG_ARM64)
 #define BOOTENV_EFI_PXE_ARCH "0xb"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000"
@@ -251,6 +256,12 @@
 /* Always assume we're running 64bit */
 #define BOOTENV_EFI_PXE_ARCH "0x7"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
+#elif defined(CONFIG_CPU_RISCV_32)
+#define BOOTENV_EFI_PXE_ARCH "0x19"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000"
+#elif defined(CONFIG_CPU_RISCV_64)
+#define BOOTENV_EFI_PXE_ARCH "0x1b"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
 #else
 #error Please specify an EFI client identifier
 #endif
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (5 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-04-24  6:28   ` rick at andestech.com
  2018-05-07  2:33   ` rick at andestech.com
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 8/8] efi_loader: Enable RISC-V support Alexander Graf
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

Distro boot allows for a common boot path on systems that allow distributions
to easily boot from a default configuration.

This patch enables distro boot for the nx25-ae250. Hopefully this can serve
as a good example for new boards, so they enable it as well.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 configs/nx25-ae250_defconfig |  1 +
 include/configs/nx25-ae250.h | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/configs/nx25-ae250_defconfig b/configs/nx25-ae250_defconfig
index 4f9bd58f75..437083231b 100644
--- a/configs/nx25-ae250_defconfig
+++ b/configs/nx25-ae250_defconfig
@@ -37,3 +37,4 @@ CONFIG_DM_SPI=y
 CONFIG_ATCSPI200_SPI=y
 CONFIG_TIMER=y
 CONFIG_ATCPIT100_TIMER=y
+CONFIG_DISTRO_DEFAULTS=y
diff --git a/include/configs/nx25-ae250.h b/include/configs/nx25-ae250.h
index 0e4c431cab..a90c75abc4 100644
--- a/include/configs/nx25-ae250.h
+++ b/include/configs/nx25-ae250.h
@@ -105,4 +105,21 @@
 /* Increase max gunzip size */
 #define CONFIG_SYS_BOOTM_LEN	(64 << 20)
 
+/* When we use RAM as ENV */
+#define CONFIG_ENV_SIZE 0x2000
+
+/* Enable distro boot */
+#define BOOT_TARGET_DEVICES(func) \
+	func(MMC, mmc, 0) \
+	func(DHCP, dhcp, na)
+#include <config_distro_bootcmd.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS	\
+				"kernel_addr_r=0x00080000\0" \
+				"pxefile_addr_r=0x01f00000\0" \
+				"scriptaddr=0x01f00000\0" \
+				"fdt_addr_r=0x02000000\0" \
+				"ramdisk_addr_r=0x02800000\0" \
+				BOOTENV
+
 #endif /* __CONFIG_H */
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 8/8] efi_loader: Enable RISC-V support
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (6 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot Alexander Graf
@ 2018-04-23  5:59 ` Alexander Graf
  2018-05-06 20:59 ` [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
  2018-05-06 21:11 ` Tom Rini
  9 siblings, 0 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23  5:59 UTC (permalink / raw)
  To: u-boot

We have almost all pieces needed to support RISC-V UEFI binaries in place
already. The only missing piece are ELF relocations for runtime code and
data.

This patch adds respective support in the linker script and the runtime
relocation code. It also allows users to enable the EFI_LOADER configuration
switch on RISC-V platforms.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - Enable hello world binary
---
 arch/riscv/cpu/nx25/u-boot.lds | 16 ++++++++++++++++
 cmd/Kconfig                    |  2 +-
 lib/efi_loader/Kconfig         |  2 +-
 lib/efi_loader/efi_runtime.c   | 41 ++++++++++++++++++++++++++++++++++++-----
 4 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/cpu/nx25/u-boot.lds b/arch/riscv/cpu/nx25/u-boot.lds
index 936fd779aa..508fa7e58d 100644
--- a/arch/riscv/cpu/nx25/u-boot.lds
+++ b/arch/riscv/cpu/nx25/u-boot.lds
@@ -38,6 +38,22 @@ SECTIONS
 		KEEP(*(SORT(.u_boot_list*)));
 	}
 
+	. = ALIGN(4);
+
+	.efi_runtime : {
+                __efi_runtime_start = .;
+		*(efi_runtime_text)
+		*(efi_runtime_data)
+                __efi_runtime_stop = .;
+	}
+
+	.efi_runtime_rel : {
+                __efi_runtime_rel_start = .;
+		*(.relaefi_runtime_text)
+		*(.relaefi_runtime_data)
+                __efi_runtime_rel_stop = .;
+	}
+
     . = ALIGN(4);
 
     /DISCARD/ : { *(.rela.plt*) }
diff --git a/cmd/Kconfig b/cmd/Kconfig
index bc1d2f31c0..c9883a40e7 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -228,7 +228,7 @@ config CMD_BOOTEFI
 
 config CMD_BOOTEFI_HELLO_COMPILE
 	bool "Compile a standard EFI hello world binary for testing"
-	depends on CMD_BOOTEFI && (ARM || X86)
+	depends on CMD_BOOTEFI && (ARM || X86 || RISCV)
 	default y
 	help
 	  This compiles a standard EFI hello world application with U-Boot so
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 83d75c4fdc..9de58bb012 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,6 @@
 config EFI_LOADER
 	bool "Support running EFI Applications in U-Boot"
-	depends on (ARM || X86) && OF_LIBFDT
+	depends on (ARM || X86 || RISCV) && OF_LIBFDT
 	# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
 	depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 573a5d6ac1..33bbc8d6cc 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -41,6 +41,25 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
 #include <asm/elf.h>
 #define R_RELATIVE	R_386_RELATIVE
 #define R_MASK		0xffULL
+#elif defined(CONFIG_RISCV)
+#include <elf.h>
+#define R_RELATIVE	R_RISCV_RELATIVE
+#define R_MASK		0xffULL
+#define IS_RELA		1
+
+struct dyn_sym {
+	ulong foo1;
+	ulong addr;
+	u32 foo2;
+	u32 foo3;
+};
+#ifdef CONFIG_CPU_RISCV_32
+#define R_ABSOLUTE	R_RISCV_32
+#define SYM_INDEX	8
+#else
+#define R_ABSOLUTE	R_RISCV_64
+#define SYM_INDEX	32
+#endif
 #else
 #error Need to add relocation awareness
 #endif
@@ -247,15 +266,27 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
 
 		p = (void*)((ulong)rel->offset - base) + gd->relocaddr;
 
-		if ((rel->info & R_MASK) != R_RELATIVE) {
-			continue;
-		}
+		debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__, rel->info, *p, rel->offset);
 
+		switch (rel->info & R_MASK) {
+		case R_RELATIVE:
 #ifdef IS_RELA
-		newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE;
+			newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE;
 #else
-		newaddr = *p - lastoff + offset;
+			newaddr = *p - lastoff + offset;
 #endif
+			break;
+#ifdef R_ABSOLUTE
+		case R_ABSOLUTE: {
+			ulong symidx = rel->info >> SYM_INDEX;
+			extern struct dyn_sym __dyn_sym_start[];
+			newaddr = __dyn_sym_start[symidx].addr + offset;
+			break;
+		}
+#endif
+		default:
+			continue;
+		}
 
 		/* Check if the relocation is inside bounds */
 		if (map && ((newaddr < map->virtual_start) ||
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines Alexander Graf
@ 2018-04-23  6:56   ` Heinrich Schuchardt
  0 siblings, 0 replies; 28+ messages in thread
From: Heinrich Schuchardt @ 2018-04-23  6:56 UTC (permalink / raw)
  To: u-boot

On 04/23/2018 07:59 AM, Alexander Graf wrote:
> While we don't have UEFI naming conventions for RISC-V file paths yet,
> we need to search for something. So let's copy the removable file paths
> from the RISC-V edk2 port.
> 
> Also add the official VCI strings that contain the standardized RISC-V
> architecture ID fields.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> 
> ---
> 
> v1 -> v2:
> 
>    - Use edk2 default boot file names
> 
> v2 -> v3:
> 
>    - Use official values for vci
> ---
>   include/config_distro_bootcmd.h | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index f567cebd38..989b5556af 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -100,6 +100,10 @@
>   #define BOOTEFI_NAME "bootia32.efi"
>   #elif defined(CONFIG_X86_RUN_64BIT)
>   #define BOOTEFI_NAME "bootx64.efi"
> +#elif defined(CONFIG_CPU_RISCV_32)
> +#define BOOTEFI_NAME "bootriscv32.efi"
> +#elif defined(CONFIG_CPU_RISCV_64)
> +#define BOOTEFI_NAME "bootriscv64.efi"
>   #endif
>   #endif
>   
> @@ -241,6 +245,7 @@
>   
>   #if defined(CONFIG_CMD_DHCP)
>   #if defined(CONFIG_EFI_LOADER)
> +/* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */
>   #if defined(CONFIG_ARM64)
>   #define BOOTENV_EFI_PXE_ARCH "0xb"
>   #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000"
> @@ -251,6 +256,12 @@
>   /* Always assume we're running 64bit */
>   #define BOOTENV_EFI_PXE_ARCH "0x7"
>   #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000"
> +#elif defined(CONFIG_CPU_RISCV_32)
> +#define BOOTENV_EFI_PXE_ARCH "0x19"
> +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000"
> +#elif defined(CONFIG_CPU_RISCV_64)
> +#define BOOTENV_EFI_PXE_ARCH "0x1b"
> +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
>   #else
>   #error Please specify an EFI client identifier
>   #endif
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too Alexander Graf
@ 2018-04-23  7:19   ` Heinrich Schuchardt
  0 siblings, 0 replies; 28+ messages in thread
From: Heinrich Schuchardt @ 2018-04-23  7:19 UTC (permalink / raw)
  To: u-boot

On 04/23/2018 07:59 AM, Alexander Graf wrote:
> We were using our EFI_CACHELINE_SIZE define only in the runtime service
> code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE.
> 
> This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts
> the image loader to use it.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   include/efi_loader.h              | 7 +++++++
>   lib/efi_loader/efi_image_loader.c | 2 +-
>   lib/efi_loader/efi_runtime.c      | 7 -------
>   3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 17f9d3d1ef..0b1b3df55a 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -76,6 +76,13 @@ const char *__efi_nesting_dec(void);
>   		##__VA_ARGS__); \
>   	})
>   
> +#ifdef CONFIG_SYS_CACHELINE_SIZE
> +#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
> +#else
> +/* Just use the greatest cache flush alignment requirement I'm aware of */
> +#define EFI_CACHELINE_SIZE 128
> +#endif
> +
>   extern struct efi_runtime_services efi_runtime_services;
>   extern struct efi_system_table systab;
>   
> diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
> index d5fbba3138..2476a97a6a 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -290,7 +290,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
>   
>   	/* Flush cache */
>   	flush_cache((ulong)efi_reloc,
> -		    ALIGN(virt_size, CONFIG_SYS_CACHELINE_SIZE));
> +		    ALIGN(virt_size, EFI_CACHELINE_SIZE));
>   	invalidate_icache_all();
>   
>   	/* Populate the loaded image interface bits */
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 8558124c0a..573a5d6ac1 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -30,13 +30,6 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
>   static efi_status_t __efi_runtime EFIAPI efi_device_error(void);
>   static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
>   
> -#ifdef CONFIG_SYS_CACHELINE_SIZE
> -#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
> -#else
> -/* Just use the greatest cache flush alignment requirement I'm aware of */
> -#define EFI_CACHELINE_SIZE 128
> -#endif
> -
>   #if defined(CONFIG_ARM64)
>   #define R_RELATIVE	1027
>   #define R_MASK		0xffffffffULL
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 2/8] riscv: Enable function sections
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 2/8] riscv: Enable function sections Alexander Graf
@ 2018-04-23  7:35   ` Heinrich Schuchardt
  2018-04-23 17:21     ` Alexander Graf
  2018-05-07  2:24   ` rick at andestech.com
  1 sibling, 1 reply; 28+ messages in thread
From: Heinrich Schuchardt @ 2018-04-23  7:35 UTC (permalink / raw)
  To: u-boot



On 04/23/2018 07:59 AM, Alexander Graf wrote:
> The linker can remove sections that are never addressed, so it makes a lot
> of sense to declare every function as an individual section.
> 
> This reduces the output U-Boot code size by ~30kb for me.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>   arch/riscv/config.mk | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
> index 6b681c4286..69f4cf6ce8 100644
> --- a/arch/riscv/config.mk
> +++ b/arch/riscv/config.mk
> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
>   			      -T $(srctree)/examples/standalone/riscv.lds
>   
>   PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2 -ffunction-sections

Other architectures also use -fdata-sections.
Why wouldn't we set it for RISC-V?

Cf. 
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/Optimize-Options.html#index-fdata-sections

Regards

Heinrich

>   LDFLAGS_u-boot += --gc-sections -static -pie
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 2/8] riscv: Enable function sections
  2018-04-23  7:35   ` Heinrich Schuchardt
@ 2018-04-23 17:21     ` Alexander Graf
  0 siblings, 0 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-23 17:21 UTC (permalink / raw)
  To: u-boot



On 23.04.18 09:35, Heinrich Schuchardt wrote:
> 
> 
> On 04/23/2018 07:59 AM, Alexander Graf wrote:
>> The linker can remove sections that are never addressed, so it makes a
>> lot
>> of sense to declare every function as an individual section.
>>
>> This reduces the output U-Boot code size by ~30kb for me.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>   arch/riscv/config.mk | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
>> index 6b681c4286..69f4cf6ce8 100644
>> --- a/arch/riscv/config.mk
>> +++ b/arch/riscv/config.mk
>> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
>>                     -T $(srctree)/examples/standalone/riscv.lds
>>     PLATFORM_CPPFLAGS    += -ffixed-gp -fpic
>> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
>> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
>> -ffunction-sections
> 
> Other architectures also use -fdata-sections.
> Why wouldn't we set it for RISC-V?

I think we could. That definitely makes sense as a follow-up patch -
ideally slightly more cross-architecture :).


Alex

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot Alexander Graf
@ 2018-04-24  6:28   ` rick at andestech.com
  2018-04-24  7:53     ` Alexander Graf
  2018-05-07  2:33   ` rick at andestech.com
  1 sibling, 1 reply; 28+ messages in thread
From: rick at andestech.com @ 2018-04-24  6:28 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, April 23, 2018 2:00 PM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
> Schuchardt; schwab at suse.de
> Subject: [PATCH v3 7/8] riscv: nx25: Enable distro boot
>
> Distro boot allows for a common boot path on systems that allow distributions to
> easily boot from a default configuration.
>
> This patch enables distro boot for the nx25-ae250. Hopefully this can serve as a
> good example for new boards, so they enable it as well.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  configs/nx25-ae250_defconfig |  1 +
>  include/configs/nx25-ae250.h | 17 +++++++++++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/configs/nx25-ae250_defconfig b/configs/nx25-ae250_defconfig index
> 4f9bd58f75..437083231b 100644
> --- a/configs/nx25-ae250_defconfig
> +++ b/configs/nx25-ae250_defconfig
> @@ -37,3 +37,4 @@ CONFIG_DM_SPI=y
>  CONFIG_ATCSPI200_SPI=y
>  CONFIG_TIMER=y
>  CONFIG_ATCPIT100_TIMER=y
> +CONFIG_DISTRO_DEFAULTS=y
> diff --git a/include/configs/nx25-ae250.h b/include/configs/nx25-ae250.h index
> 0e4c431cab..a90c75abc4 100644
> --- a/include/configs/nx25-ae250.h
> +++ b/include/configs/nx25-ae250.h
> @@ -105,4 +105,21 @@
>  /* Increase max gunzip size */
>  #define CONFIG_SYS_BOOTM_LEN (64 << 20)
>
> +/* When we use RAM as ENV */
> +#define CONFIG_ENV_SIZE 0x2000
> +
> +/* Enable distro boot */
> +#define BOOT_TARGET_DEVICES(func) \
> +     func(MMC, mmc, 0) \
> +     func(DHCP, dhcp, na)
> +#include <config_distro_bootcmd.h>
> +
> +#define CONFIG_EXTRA_ENV_SETTINGS    \
> +                             "kernel_addr_r=0x00080000\0" \
> +                             "pxefile_addr_r=0x01f00000\0" \
> +                             "scriptaddr=0x01f00000\0" \
> +                             "fdt_addr_r=0x02000000\0" \
> +                             "ramdisk_addr_r=0x02800000\0" \
> +                             BOOTENV
> +

Hi Alexander

This default env setting seem try to load something(maybe script, or kernel and dtb ?) from mmc and tftpserver
But I do not know how to prepare this script or image.

I am not sure if the understanding is correct ?
Can you explain it ?

Thank you

Rick :)

>  #endif /* __CONFIG_H */
> --
> 2.12.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot
  2018-04-24  6:28   ` rick at andestech.com
@ 2018-04-24  7:53     ` Alexander Graf
  0 siblings, 0 replies; 28+ messages in thread
From: Alexander Graf @ 2018-04-24  7:53 UTC (permalink / raw)
  To: u-boot

On 04/24/2018 08:28 AM, rick at andestech.com wrote:
>
>> -----Original Message-----
>> From: Alexander Graf [mailto:agraf at suse.de]
>> Sent: Monday, April 23, 2018 2:00 PM
>> To: u-boot at lists.denx.de
>> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
>> Schuchardt; schwab at suse.de
>> Subject: [PATCH v3 7/8] riscv: nx25: Enable distro boot
>>
>> Distro boot allows for a common boot path on systems that allow distributions to
>> easily boot from a default configuration.
>>
>> This patch enables distro boot for the nx25-ae250. Hopefully this can serve as a
>> good example for new boards, so they enable it as well.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>   configs/nx25-ae250_defconfig |  1 +
>>   include/configs/nx25-ae250.h | 17 +++++++++++++++++
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/configs/nx25-ae250_defconfig b/configs/nx25-ae250_defconfig index
>> 4f9bd58f75..437083231b 100644
>> --- a/configs/nx25-ae250_defconfig
>> +++ b/configs/nx25-ae250_defconfig
>> @@ -37,3 +37,4 @@ CONFIG_DM_SPI=y
>>   CONFIG_ATCSPI200_SPI=y
>>   CONFIG_TIMER=y
>>   CONFIG_ATCPIT100_TIMER=y
>> +CONFIG_DISTRO_DEFAULTS=y
>> diff --git a/include/configs/nx25-ae250.h b/include/configs/nx25-ae250.h index
>> 0e4c431cab..a90c75abc4 100644
>> --- a/include/configs/nx25-ae250.h
>> +++ b/include/configs/nx25-ae250.h
>> @@ -105,4 +105,21 @@
>>   /* Increase max gunzip size */
>>   #define CONFIG_SYS_BOOTM_LEN (64 << 20)
>>
>> +/* When we use RAM as ENV */
>> +#define CONFIG_ENV_SIZE 0x2000
>> +
>> +/* Enable distro boot */
>> +#define BOOT_TARGET_DEVICES(func) \
>> +     func(MMC, mmc, 0) \
>> +     func(DHCP, dhcp, na)
>> +#include <config_distro_bootcmd.h>
>> +
>> +#define CONFIG_EXTRA_ENV_SETTINGS    \
>> +                             "kernel_addr_r=0x00080000\0" \
>> +                             "pxefile_addr_r=0x01f00000\0" \
>> +                             "scriptaddr=0x01f00000\0" \
>> +                             "fdt_addr_r=0x02000000\0" \
>> +                             "ramdisk_addr_r=0x02800000\0" \
>> +                             BOOTENV
>> +
> Hi Alexander
>
> This default env setting seem try to load something(maybe script, or kernel and dtb ?) from mmc and tftpserver
> But I do not know how to prepare this script or image.
>
> I am not sure if the understanding is correct ?
> Can you explain it ?

The distro boot script logic is described quite nicely here:

   https://github.com/u-boot/u-boot/blob/master/doc/README.distro

I personally only care about a subset of it though, which is the 
efi_loader loading logic:

   https://github.com/u-boot/u-boot/blob/master/doc/README.uefi

With distro boot enabled, the distro boot script will automatically 
search for a file called /efi/boot/bootriscv64.efi (or 32 respectively) 
and execute it as UEFI binary. The next step I need to get to still is 
to enable RISC-V UEFI support in grub. Once we have that, we can boot 
RISC-V systems like any other platform we support in openSUSE.


Alex

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (7 preceding siblings ...)
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 8/8] efi_loader: Enable RISC-V support Alexander Graf
@ 2018-05-06 20:59 ` Alexander Graf
  2018-05-07  2:13   ` rick at andestech.com
  2018-05-06 21:11 ` Tom Rini
  9 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-05-06 20:59 UTC (permalink / raw)
  To: u-boot



On 23.04.18 07:59, Alexander Graf wrote:
> We now have RISC-V support in U-Boot - which is great!
> 
> However, not that we're finally making progress to converge on
> efi_loader and distro boot for booting on ARM platforms, we
> really want to make sure there is no technical reason not to
> do the same on RISC-V as well.
> 
> So this patch set introduces distro boot and efi_loader support
> for RISC-V!
> 
> So far, I've only tested it with the selftest and hello world
> target in U-Boot, as the number of target binaries to run is
> still slim. But it should at least give us a good starting point.

Rick, can this go into 2018.07?

Via which tree do you want to push it? I can take it via the efi one or
you can take it if you like ;).


Alex

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
                   ` (8 preceding siblings ...)
  2018-05-06 20:59 ` [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
@ 2018-05-06 21:11 ` Tom Rini
  2018-05-07  2:18   ` rick at andestech.com
  9 siblings, 1 reply; 28+ messages in thread
From: Tom Rini @ 2018-05-06 21:11 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 23, 2018 at 07:59:42AM +0200, Alexander Graf wrote:

> We now have RISC-V support in U-Boot - which is great!
> 
> However, not that we're finally making progress to converge on
> efi_loader and distro boot for booting on ARM platforms, we
> really want to make sure there is no technical reason not to
> do the same on RISC-V as well.
> 
> So this patch set introduces distro boot and efi_loader support
> for RISC-V!
> 
> So far, I've only tested it with the selftest and hello world
> target in U-Boot, as the number of target binaries to run is
> still slim. But it should at least give us a good starting point.

Any more comments from the RISC-V team?  It would be great to have this
in for v2018.07, thanks!

-- 
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/20180506/8235ccc6/attachment.sig>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-06 20:59 ` [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
@ 2018-05-07  2:13   ` rick at andestech.com
  2018-05-09  7:30     ` Alexander Graf
  0 siblings, 1 reply; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:13 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, May 07, 2018 4:59 AM
> To: u-boot at lists.denx.de
> Cc: Heinrich Schuchardt; schwab at suse.de; Greentime Hu; Rick Jian-Zhi Chen(陳
> 建志)
> Subject: Re: [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
>
>
>
> On 23.04.18 07:59, Alexander Graf wrote:
> > We now have RISC-V support in U-Boot - which is great!
> >
> > However, not that we're finally making progress to converge on
> > efi_loader and distro boot for booting on ARM platforms, we really
> > want to make sure there is no technical reason not to do the same on
> > RISC-V as well.
> >
> > So this patch set introduces distro boot and efi_loader support for
> > RISC-V!
> >
> > So far, I've only tested it with the selftest and hello world target
> > in U-Boot, as the number of target binaries to run is still slim. But
> > it should at least give us a good starting point.
>
> Rick, can this go into 2018.07?
>
> Via which tree do you want to push it? I can take it via the efi one or you can take
> it if you like ;).
>
>

Yes
I prefer to u-boot-riscv.git
If this can enter main line, I will fetch it
I think you can take it via the efi one. :)


But when I verify the efi flow this days.
I find one issue and still clarify it now.

I find the auto flow can not be disabled from make menuconfig
Following are the experiments I do:

Currently the boot flow will auto scan *.efi file from sd card and tftp server.
If I do not insert sd card and tftp server caple.

The boot message will as below:

U-Boot 2018.03-00351-g1dd246f-dirty (Apr 23 2018 - 15:34:32 +0800)

DRAM:  1 GiB
No arch specific invalidate_icache_all available!
MMC:
Loading Environment from SPI Flash... SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB
*** Warning - bad CRC, using default environment

Failed (-5)
In:    serial at f0300000
Out:   serial at f0300000
Err:   serial at f0300000
Net:   no alias for ethernet0

Warning: mac at e0100000 (eth0) using random MAC address - 66:7d:d7:be:c0:10
eth0: mac at e0100000
Hit any key to stop autoboot:  0
No MMC device available
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Retry time exceeded; starting again
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6
BOOTP broadcast 7
BOOTP broadcast 8
BOOTP broadcast 9
BOOTP broadcast 10
BOOTP broadcast 11
BOOTP broadcast 12
BOOTP broadcast 13
BOOTP broadcast 14
BOOTP broadcast 15
BOOTP broadcast 16
BOOTP broadcast 17

Retry time exceeded; starting again
RISC-V #


Then I think if I don't want enter this auto flow, what can I do ?

1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
 But it still enter auto flow.

2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h
 And Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
 And it will NOT enter auto flow

#ifdef CONFIG_DISTRO_DEFAULTS
/* Enable distro boot */
#define BOOT_TARGET_DEVICES(func) \
        func(MMC, mmc, 0) \
        func(DHCP, dhcp, na)

#include <config_distro_bootcmd.h>

#define CONFIG_EXTRA_ENV_SETTINGS       \
                                "kernel_addr_r=0x00080000\0" \
                                "pxefile_addr_r=0x01f00000\0" \
                                "scriptaddr=0x01f00000\0" \
                                "fdt_addr_r=0x02000000\0" \
                                "ramdisk_addr_r=0x02800000\0" \
                                BOOTENV
#endif

3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h
 And do NOT Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
 But disable CONFIG_DISTRO_DEFAULTS from make menuconfig
   General setup  --->
     [ ] Select defaults suitable for booting general purpose Linux distributions
 And it still enter auto flow

Offering this information for you.

Rick

> Alex
CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-06 21:11 ` Tom Rini
@ 2018-05-07  2:18   ` rick at andestech.com
  0 siblings, 0 replies; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:18 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Tom Rini [mailto:trini at konsulko.com]
> Sent: Monday, May 07, 2018 5:12 AM
> To: Alexander Graf; Rick Jian-Zhi Chen(陳建志); Greentime Hu
> Cc: u-boot at lists.denx.de; Heinrich Schuchardt; schwab at suse.de
> Subject: Re: [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
>
> On Mon, Apr 23, 2018 at 07:59:42AM +0200, Alexander Graf wrote:
>
> > We now have RISC-V support in U-Boot - which is great!
> >
> > However, not that we're finally making progress to converge on
> > efi_loader and distro boot for booting on ARM platforms, we really
> > want to make sure there is no technical reason not to do the same on
> > RISC-V as well.
> >
> > So this patch set introduces distro boot and efi_loader support for
> > RISC-V!
> >
> > So far, I've only tested it with the selftest and hello world target
> > in U-Boot, as the number of target binaries to run is still slim. But
> > it should at least give us a good starting point.
>
> Any more comments from the RISC-V team?  It would be great to have this in
> for v2018.07, thanks!
>

Hi Tom

I am also happy to have this in.
And I have some responses to Alex. :)

Rick
> --
> Tom
CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 2/8] riscv: Enable function sections
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 2/8] riscv: Enable function sections Alexander Graf
  2018-04-23  7:35   ` Heinrich Schuchardt
@ 2018-05-07  2:24   ` rick at andestech.com
  1 sibling, 0 replies; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:24 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, April 23, 2018 2:00 PM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
> Schuchardt; schwab at suse.de
> Subject: [PATCH v3 2/8] riscv: Enable function sections
>
> The linker can remove sections that are never addressed, so it makes a lot of
> sense to declare every function as an individual section.
>
> This reduces the output U-Boot code size by ~30kb for me.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/riscv/config.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk index
> 6b681c4286..69f4cf6ce8 100644
> --- a/arch/riscv/config.mk
> +++ b/arch/riscv/config.mk
> @@ -29,5 +29,5 @@ CONFIG_STANDALONE_LOAD_ADDR = 0x00000000 \
>                             -T $(srctree)/examples/standalone/riscv.lds
>
>  PLATFORM_CPPFLAGS    += -ffixed-gp -fpic
> -PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
> +PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -gdwarf-2
> +-ffunction-sections

Reviewed-by: Rick Chen <rick@andestech.com>

>  LDFLAGS_u-boot += --gc-sections -static -pie
> --
> 2.12.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code Alexander Graf
@ 2018-05-07  2:25   ` rick at andestech.com
  0 siblings, 0 replies; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:25 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, April 23, 2018 2:00 PM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
> Schuchardt; schwab at suse.de
> Subject: [PATCH v3 1/8] riscv: Add setjmp/longjmp code
>
> To support efi_loader we need to have platform support for setjmp/longjmp.
> Add it here.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
>
> ---
>
> v1 -> v2:
>
>   - Allow 32bit target
>   - Also save/restore ra, sp
> ---
>  arch/riscv/include/asm/setjmp.h | 26 ++++++++++++++++
>  arch/riscv/lib/Makefile         |  1 +
>  arch/riscv/lib/setjmp.S         | 66
> +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 93 insertions(+)
>  create mode 100644 arch/riscv/include/asm/setjmp.h  create mode 100644
> arch/riscv/lib/setjmp.S
>
> diff --git a/arch/riscv/include/asm/setjmp.h b/arch/riscv/include/asm/setjmp.h
> new file mode 100644 index 0000000000..01ad6d081f
> --- /dev/null
> +++ b/arch/riscv/include/asm/setjmp.h
> @@ -0,0 +1,26 @@
> +/*
> + * (C) Copyright 2018 Alexander Graf <agraf@suse.de>
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#ifndef _SETJMP_H_
> +#define _SETJMP_H_   1
> +
> +/*
> + * This really should be opaque, but the EFI implementation wrongly
> + * assumes that a 'struct jmp_buf_data' is defined.
> + */
> +struct jmp_buf_data {
> +     /* x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, sp */
> +     unsigned long s_regs[12];       /* s0 - s11 */
> +     unsigned long ra;
> +     unsigned long sp;
> +};
> +
> +typedef struct jmp_buf_data jmp_buf[1];
> +
> +int setjmp(jmp_buf jmp);
> +void longjmp(jmp_buf jmp, int ret);
> +
> +#endif /* _SETJMP_H_ */
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index
> 323cf3e835..6d97aa2719 100644
> --- a/arch/riscv/lib/Makefile
> +++ b/arch/riscv/lib/Makefile
> @@ -12,3 +12,4 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
>  obj-$(CONFIG_CMD_GO) += boot.o
>  obj-y        += cache.o
>  obj-y        += interrupts.o
> +obj-y   += setjmp.o
> diff --git a/arch/riscv/lib/setjmp.S b/arch/riscv/lib/setjmp.S new file mode 100644
> index 0000000000..103f359185
> --- /dev/null
> +++ b/arch/riscv/lib/setjmp.S
> @@ -0,0 +1,66 @@
> +/*
> + * (C) 2018 Alexander Graf <agraf@suse.de>
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +
> +#include <config.h>
> +#include <linux/linkage.h>
> +
> +#ifdef CONFIG_CPU_RISCV_64
> +#define STORE_IDX(reg, idx)  sd reg, (idx*8)(a0)
> +#define LOAD_IDX(reg, idx)   ld reg, (idx*8)(a0)
> +#else
> +#define STORE_IDX(reg, idx)  sw reg, (idx*4)(a0)
> +#define LOAD_IDX(reg, idx)   lw reg, (idx*4)(a0)
> +#endif
> +
> +.pushsection .text.setjmp, "ax"
> +ENTRY(setjmp)
> +     /* Preserve all callee-saved registers and the SP */
> +     STORE_IDX(s0, 0)
> +     STORE_IDX(s1, 1)
> +     STORE_IDX(s2, 2)
> +     STORE_IDX(s3, 3)
> +     STORE_IDX(s4, 4)
> +     STORE_IDX(s5, 5)
> +     STORE_IDX(s6, 6)
> +     STORE_IDX(s7, 7)
> +     STORE_IDX(s8, 8)
> +     STORE_IDX(s9, 9)
> +     STORE_IDX(s10, 10)
> +     STORE_IDX(s11, 11)
> +     STORE_IDX(ra, 12)
> +     STORE_IDX(sp, 13)
> +     li  a0, 0
> +     ret
> +ENDPROC(setjmp)
> +.popsection
> +
> +.pushsection .text.longjmp, "ax"
> +ENTRY(longjmp)
> +     LOAD_IDX(s0, 0)
> +     LOAD_IDX(s1, 1)
> +     LOAD_IDX(s2, 2)
> +     LOAD_IDX(s3, 3)
> +     LOAD_IDX(s4, 4)
> +     LOAD_IDX(s5, 5)
> +     LOAD_IDX(s6, 6)
> +     LOAD_IDX(s7, 7)
> +     LOAD_IDX(s8, 8)
> +     LOAD_IDX(s9, 9)
> +     LOAD_IDX(s10, 10)
> +     LOAD_IDX(s11, 11)
> +     LOAD_IDX(ra, 12)
> +     LOAD_IDX(sp, 13)
> +
> +     /* Move the return value in place, but return 1 if passed 0. */
> +     beq a1, zero, longjmp_1
> +     mv a0, a1
> +     ret
> +
> +     longjmp_1:
> +     li a0, 1
> +     ret
> +ENDPROC(longjmp)
> +.popsection

Reviewed-by: Rick Chen <rick@andestech.com>

> --
> 2.12.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub Alexander Graf
@ 2018-05-07  2:25   ` rick at andestech.com
  0 siblings, 0 replies; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:25 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, April 23, 2018 2:00 PM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
> Schuchardt; schwab at suse.de
> Subject: [PATCH v3 4/8] riscv: Add board_quiesce_devices stub
>
> This patch adds an empty stub for board_quiesce_devices() which allows boards
> to quiesce their devices before we boot into an OS in a platform agnostic way.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/riscv/include/asm/u-boot-riscv.h | 1 +
>  arch/riscv/lib/bootm.c                | 4 ++++
>  2 files changed, 5 insertions(+)
>
> diff --git a/arch/riscv/include/asm/u-boot-riscv.h
> b/arch/riscv/include/asm/u-boot-riscv.h
> index 18099cd260..0b6428b1ae 100644
> --- a/arch/riscv/include/asm/u-boot-riscv.h
> +++ b/arch/riscv/include/asm/u-boot-riscv.h
> @@ -17,5 +17,6 @@ int cleanup_before_linux(void);
>
>  /* board/.../... */
>  int board_init(void);
> +void board_quiesce_devices(void);
>
>  #endif       /* _U_BOOT_RISCV_H_ */
> diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index
> 9242fa891a..b80274adba 100644
> --- a/arch/riscv/lib/bootm.c
> +++ b/arch/riscv/lib/bootm.c
> @@ -16,6 +16,10 @@
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> +__weak void board_quiesce_devices(void) { }
> +

Reviewed-by: Rick Chen <rick@andestech.com>

>  int arch_fixup_fdt(void *blob)
>  {
>       return 0;
> --
> 2.12.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot
  2018-04-23  5:59 ` [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot Alexander Graf
  2018-04-24  6:28   ` rick at andestech.com
@ 2018-05-07  2:33   ` rick at andestech.com
  1 sibling, 0 replies; 28+ messages in thread
From: rick at andestech.com @ 2018-05-07  2:33 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Alexander Graf [mailto:agraf at suse.de]
> Sent: Monday, April 23, 2018 2:00 PM
> To: u-boot at lists.denx.de
> Cc: Rick Jian-Zhi Chen(陳建志); Greentime Hu; Philipp Tomsich; Heinrich
> Schuchardt; schwab at suse.de
> Subject: [PATCH v3 7/8] riscv: nx25: Enable distro boot
>
> Distro boot allows for a common boot path on systems that allow distributions to
> easily boot from a default configuration.
>
> This patch enables distro boot for the nx25-ae250. Hopefully this can serve as a
> good example for new boards, so they enable it as well.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  configs/nx25-ae250_defconfig |  1 +
>  include/configs/nx25-ae250.h | 17 +++++++++++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/configs/nx25-ae250_defconfig b/configs/nx25-ae250_defconfig index
> 4f9bd58f75..437083231b 100644
> --- a/configs/nx25-ae250_defconfig
> +++ b/configs/nx25-ae250_defconfig
> @@ -37,3 +37,4 @@ CONFIG_DM_SPI=y
>  CONFIG_ATCSPI200_SPI=y
>  CONFIG_TIMER=y
>  CONFIG_ATCPIT100_TIMER=y
> +CONFIG_DISTRO_DEFAULTS=y
> diff --git a/include/configs/nx25-ae250.h b/include/configs/nx25-ae250.h index
> 0e4c431cab..a90c75abc4 100644
> --- a/include/configs/nx25-ae250.h
> +++ b/include/configs/nx25-ae250.h
> @@ -105,4 +105,21 @@
>  /* Increase max gunzip size */
>  #define CONFIG_SYS_BOOTM_LEN (64 << 20)
>
> +/* When we use RAM as ENV */
> +#define CONFIG_ENV_SIZE 0x2000
> +
> +/* Enable distro boot */
> +#define BOOT_TARGET_DEVICES(func) \
> +     func(MMC, mmc, 0) \
> +     func(DHCP, dhcp, na)
> +#include <config_distro_bootcmd.h>
> +
> +#define CONFIG_EXTRA_ENV_SETTINGS    \
> +                             "kernel_addr_r=0x00080000\0" \
> +                             "pxefile_addr_r=0x01f00000\0" \
> +                             "scriptaddr=0x01f00000\0" \
> +                             "fdt_addr_r=0x02000000\0" \
> +                             "ramdisk_addr_r=0x02800000\0" \
> +                             BOOTENV
> +

Maybe Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the CONFIG_EXTRA_ENV_SETTINGS can disable auto boot easily.

Reviewed-by: Rick Chen <rick@andestech.com>

>  #endif /* __CONFIG_H */
> --
> 2.12.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-07  2:13   ` rick at andestech.com
@ 2018-05-09  7:30     ` Alexander Graf
  0 siblings, 0 replies; 28+ messages in thread
From: Alexander Graf @ 2018-05-09  7:30 UTC (permalink / raw)
  To: u-boot



On 07.05.18 04:13, rick at andestech.com wrote:
> 
> 
>> -----Original Message-----
>> From: Alexander Graf [mailto:agraf at suse.de]
>> Sent: Monday, May 07, 2018 4:59 AM
>> To: u-boot at lists.denx.de
>> Cc: Heinrich Schuchardt; schwab at suse.de; Greentime Hu; Rick Jian-Zhi Chen(陳
>> 建志)
>> Subject: Re: [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
>>
>>
>>
>> On 23.04.18 07:59, Alexander Graf wrote:
>>> We now have RISC-V support in U-Boot - which is great!
>>>
>>> However, not that we're finally making progress to converge on
>>> efi_loader and distro boot for booting on ARM platforms, we really
>>> want to make sure there is no technical reason not to do the same on
>>> RISC-V as well.
>>>
>>> So this patch set introduces distro boot and efi_loader support for
>>> RISC-V!
>>>
>>> So far, I've only tested it with the selftest and hello world target
>>> in U-Boot, as the number of target binaries to run is still slim. But
>>> it should at least give us a good starting point.
>>
>> Rick, can this go into 2018.07?
>>
>> Via which tree do you want to push it? I can take it via the efi one or you can take
>> it if you like ;).
>>
>>
> 
> Yes
> I prefer to u-boot-riscv.git
> If this can enter main line, I will fetch it
> I think you can take it via the efi one. :)
> 
> 
> But when I verify the efi flow this days.
> I find one issue and still clarify it now.
> 
> I find the auto flow can not be disabled from make menuconfig
> Following are the experiments I do:
> 
> Currently the boot flow will auto scan *.efi file from sd card and tftp server.
> If I do not insert sd card and tftp server caple.
> 
> The boot message will as below:
> 
> U-Boot 2018.03-00351-g1dd246f-dirty (Apr 23 2018 - 15:34:32 +0800)
> 
> DRAM:  1 GiB
> No arch specific invalidate_icache_all available!
> MMC:
> Loading Environment from SPI Flash... SF: Detected mx25u1635e with page size 256 Bytes, erase size 4 KiB, total 2 MiB
> *** Warning - bad CRC, using default environment
> 
> Failed (-5)
> In:    serial at f0300000
> Out:   serial at f0300000
> Err:   serial at f0300000
> Net:   no alias for ethernet0
> 
> Warning: mac at e0100000 (eth0) using random MAC address - 66:7d:d7:be:c0:10
> eth0: mac at e0100000
> Hit any key to stop autoboot:  0
> No MMC device available
> BOOTP broadcast 1
> BOOTP broadcast 2
> BOOTP broadcast 3
> BOOTP broadcast 4
> BOOTP broadcast 5
> BOOTP broadcast 6
> BOOTP broadcast 7
> BOOTP broadcast 8
> BOOTP broadcast 9
> BOOTP broadcast 10
> BOOTP broadcast 11
> BOOTP broadcast 12
> BOOTP broadcast 13
> BOOTP broadcast 14
> BOOTP broadcast 15
> BOOTP broadcast 16
> BOOTP broadcast 17
> 
> Retry time exceeded; starting again
> BOOTP broadcast 1
> BOOTP broadcast 2
> BOOTP broadcast 3
> BOOTP broadcast 4
> BOOTP broadcast 5
> BOOTP broadcast 6
> BOOTP broadcast 7
> BOOTP broadcast 8
> BOOTP broadcast 9
> BOOTP broadcast 10
> BOOTP broadcast 11
> BOOTP broadcast 12
> BOOTP broadcast 13
> BOOTP broadcast 14
> BOOTP broadcast 15
> BOOTP broadcast 16
> BOOTP broadcast 17
> 
> Retry time exceeded; starting again
> RISC-V #
> 
> 
> Then I think if I don't want enter this auto flow, what can I do ?
> 
> 1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
>  But it still enter auto flow.
> 
> 2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h
>  And Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
>  And it will NOT enter auto flow
> 
> #ifdef CONFIG_DISTRO_DEFAULTS
> /* Enable distro boot */
> #define BOOT_TARGET_DEVICES(func) \
>         func(MMC, mmc, 0) \
>         func(DHCP, dhcp, na)
> 
> #include <config_distro_bootcmd.h>
> 
> #define CONFIG_EXTRA_ENV_SETTINGS       \
>                                 "kernel_addr_r=0x00080000\0" \
>                                 "pxefile_addr_r=0x01f00000\0" \
>                                 "scriptaddr=0x01f00000\0" \
>                                 "fdt_addr_r=0x02000000\0" \
>                                 "ramdisk_addr_r=0x02800000\0" \
>                                 BOOTENV
> #endif
> 
> 3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h
>  And do NOT Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig
>  But disable CONFIG_DISTRO_DEFAULTS from make menuconfig
>    General setup  --->
>      [ ] Select defaults suitable for booting general purpose Linux distributions
>  And it still enter auto flow
> 
> Offering this information for you.

This is the same for all distro enabled boards. The basic idea is that
U-Boot ships with something that "just boots" for simple use cases.

If you want something more advanced, you usually want to put something
very target specific in there anyway, such as "bootm $nor_flash". In
that case, you adapt the CONFIG_BOOTCOMMAND parameter to whatever you want.

The boot command can also be overridden using the environment. So if you
have working environment store, you can change the U-Boot variable
"bootcmd" and U-Boot will run that instead when it boots.

The alternative to this default behavior would be no bootcmd at all
which means you just get dropped into the U-Boot prompt. While that's
reasonably useful for developers, it isn't for people deploying U-Boot
on real target systems :).


Alex

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-10  7:00   ` Rick Chen
@ 2018-05-10  7:16     ` Rick Chen
  0 siblings, 0 replies; 28+ messages in thread
From: Rick Chen @ 2018-05-10  7:16 UTC (permalink / raw)
  To: u-boot

2018-05-10 15:00 GMT+08:00 Rick Chen <rickchen36@gmail.com>:
> 2018-05-10 14:03 GMT+08:00 Alexander Graf <agraf@suse.de>:
>>
>>
>> Am 10.05.2018 um 05:27 schrieb Rick Chen <rickchen36@gmail.com>:
>>
>>>>>
>>>>> Then I think if I don't want enter this auto flow, what can I do ?
>>>>>
>>>>> 1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But it
>>>>> still enter auto flow.
>>>>>
>>>>> 2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And Remove
>>>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  And it will NOT
>>>>> enter auto flow
>>>>>
>>>>> #ifdef CONFIG_DISTRO_DEFAULTS
>>>>> /* Enable distro boot */
>>>>> #define BOOT_TARGET_DEVICES(func) \
>>>>>        func(MMC, mmc, 0) \
>>>>>        func(DHCP, dhcp, na)
>>>>>
>>>>> #include <config_distro_bootcmd.h>
>>>>>
>>>>> #define CONFIG_EXTRA_ENV_SETTINGS       \
>>>>>                                "kernel_addr_r=0x00080000\0" \
>>>>>                                "pxefile_addr_r=0x01f00000\0" \
>>>>>                                "scriptaddr=0x01f00000\0" \
>>>>>                                "fdt_addr_r=0x02000000\0" \
>>>>>                                "ramdisk_addr_r=0x02800000\0" \
>>>>>                                BOOTENV #endif
>>>>>
>>>>> 3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And do NOT Remove
>>>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But disable
>>>> CONFIG_DISTRO_DEFAULTS from make menuconfig
>>>>>   General setup  --->
>>>>>     [ ] Select defaults suitable for booting general purpose Linux
>>>>> distributions  And it still enter auto flow
>>>>>
>>>>> Offering this information for you.
>>>>
>>>> This is the same for all distro enabled boards. The basic idea is that U-Boot ships
>>>> with something that "just boots" for simple use cases.
>>>>
>>>> If you want something more advanced, you usually want to put something very
>>>> target specific in there anyway, such as "bootm $nor_flash". In that case, you
>>>> adapt the CONFIG_BOOTCOMMAND parameter to whatever you want.
>>>>
>>>> The boot command can also be overridden using the environment. So if you have
>>>> working environment store, you can change the U-Boot variable "bootcmd" and
>>>> U-Boot will run that instead when it boots.
>>>>
>>>> The alternative to this default behavior would be no bootcmd at all which means
>>>> you just get dropped into the U-Boot prompt. While that's reasonably useful for
>>>> developers, it isn't for people deploying U-Boot on real target systems :).
>>>>
>>>>
>>>> Alex
>>>
>>> Thanks for your advises.
>>>
>>> After you send those patchs into main trunk.
>>> I will fetch and push them to u-boot-riscv.git :)
>>
>> The usual flow would be the other way around: You apply them to u-boot-riscv.git with your Signed-off-by and send a pull request for the current merge window :).
>>
>> Unless I misunderstood your earlier reply and you would prefer to have me propagate them to mainline via the efi-next tree?
>>
>>
>> Alex
>>
>
> Yes. I prefer that you propagate them to mainline via the efi-next tree.
> Then you can grasp the schedule by yourself.
>
> When you ask "Via which tree do you want to push it? "
> I misunderstood it and reply preferring to u-boot-nds32.git.
> Sorry about that ~ ~
>
> But maybe I need to send patch-sets to change cpu and board nane.
> For example: rename nx25-ae250.h to ax25-ae350.h
>
> Will it affect your submitting flow ?
> I am wondering how to deal with the conflicts between the different patch-sets
>
> Rick

I just modify what I want base on your patch-sets and that will be fine.
I think too complicated. :)

Rick

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-10  6:03 ` Alexander Graf
@ 2018-05-10  7:00   ` Rick Chen
  2018-05-10  7:16     ` Rick Chen
  0 siblings, 1 reply; 28+ messages in thread
From: Rick Chen @ 2018-05-10  7:00 UTC (permalink / raw)
  To: u-boot

2018-05-10 14:03 GMT+08:00 Alexander Graf <agraf@suse.de>:
>
>
> Am 10.05.2018 um 05:27 schrieb Rick Chen <rickchen36@gmail.com>:
>
>>>>
>>>> Then I think if I don't want enter this auto flow, what can I do ?
>>>>
>>>> 1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But it
>>>> still enter auto flow.
>>>>
>>>> 2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And Remove
>>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  And it will NOT
>>>> enter auto flow
>>>>
>>>> #ifdef CONFIG_DISTRO_DEFAULTS
>>>> /* Enable distro boot */
>>>> #define BOOT_TARGET_DEVICES(func) \
>>>>        func(MMC, mmc, 0) \
>>>>        func(DHCP, dhcp, na)
>>>>
>>>> #include <config_distro_bootcmd.h>
>>>>
>>>> #define CONFIG_EXTRA_ENV_SETTINGS       \
>>>>                                "kernel_addr_r=0x00080000\0" \
>>>>                                "pxefile_addr_r=0x01f00000\0" \
>>>>                                "scriptaddr=0x01f00000\0" \
>>>>                                "fdt_addr_r=0x02000000\0" \
>>>>                                "ramdisk_addr_r=0x02800000\0" \
>>>>                                BOOTENV #endif
>>>>
>>>> 3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And do NOT Remove
>>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But disable
>>> CONFIG_DISTRO_DEFAULTS from make menuconfig
>>>>   General setup  --->
>>>>     [ ] Select defaults suitable for booting general purpose Linux
>>>> distributions  And it still enter auto flow
>>>>
>>>> Offering this information for you.
>>>
>>> This is the same for all distro enabled boards. The basic idea is that U-Boot ships
>>> with something that "just boots" for simple use cases.
>>>
>>> If you want something more advanced, you usually want to put something very
>>> target specific in there anyway, such as "bootm $nor_flash". In that case, you
>>> adapt the CONFIG_BOOTCOMMAND parameter to whatever you want.
>>>
>>> The boot command can also be overridden using the environment. So if you have
>>> working environment store, you can change the U-Boot variable "bootcmd" and
>>> U-Boot will run that instead when it boots.
>>>
>>> The alternative to this default behavior would be no bootcmd at all which means
>>> you just get dropped into the U-Boot prompt. While that's reasonably useful for
>>> developers, it isn't for people deploying U-Boot on real target systems :).
>>>
>>>
>>> Alex
>>
>> Thanks for your advises.
>>
>> After you send those patchs into main trunk.
>> I will fetch and push them to u-boot-riscv.git :)
>
> The usual flow would be the other way around: You apply them to u-boot-riscv.git with your Signed-off-by and send a pull request for the current merge window :).
>
> Unless I misunderstood your earlier reply and you would prefer to have me propagate them to mainline via the efi-next tree?
>
>
> Alex
>

Yes. I prefer that you propagate them to mainline via the efi-next tree.
Then you can grasp the schedule by yourself.

When you ask "Via which tree do you want to push it? "
I misunderstood it and reply preferring to u-boot-nds32.git.
Sorry about that ~ ~

But maybe I need to send patch-sets to change cpu and board nane.
For example: rename nx25-ae250.h to ax25-ae350.h

Will it affect your submitting flow ?
I am wondering how to deal with the conflicts between the different patch-sets

Rick

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
  2018-05-10  3:27 Rick Chen
@ 2018-05-10  6:03 ` Alexander Graf
  2018-05-10  7:00   ` Rick Chen
  0 siblings, 1 reply; 28+ messages in thread
From: Alexander Graf @ 2018-05-10  6:03 UTC (permalink / raw)
  To: u-boot



Am 10.05.2018 um 05:27 schrieb Rick Chen <rickchen36@gmail.com>:

>>> 
>>> Then I think if I don't want enter this auto flow, what can I do ?
>>> 
>>> 1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But it
>>> still enter auto flow.
>>> 
>>> 2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And Remove
>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  And it will NOT
>>> enter auto flow
>>> 
>>> #ifdef CONFIG_DISTRO_DEFAULTS
>>> /* Enable distro boot */
>>> #define BOOT_TARGET_DEVICES(func) \
>>>        func(MMC, mmc, 0) \
>>>        func(DHCP, dhcp, na)
>>> 
>>> #include <config_distro_bootcmd.h>
>>> 
>>> #define CONFIG_EXTRA_ENV_SETTINGS       \
>>>                                "kernel_addr_r=0x00080000\0" \
>>>                                "pxefile_addr_r=0x01f00000\0" \
>>>                                "scriptaddr=0x01f00000\0" \
>>>                                "fdt_addr_r=0x02000000\0" \
>>>                                "ramdisk_addr_r=0x02800000\0" \
>>>                                BOOTENV #endif
>>> 
>>> 3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
>>> CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And do NOT Remove
>>> CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But disable
>> CONFIG_DISTRO_DEFAULTS from make menuconfig
>>>   General setup  --->
>>>     [ ] Select defaults suitable for booting general purpose Linux
>>> distributions  And it still enter auto flow
>>> 
>>> Offering this information for you.
>> 
>> This is the same for all distro enabled boards. The basic idea is that U-Boot ships
>> with something that "just boots" for simple use cases.
>> 
>> If you want something more advanced, you usually want to put something very
>> target specific in there anyway, such as "bootm $nor_flash". In that case, you
>> adapt the CONFIG_BOOTCOMMAND parameter to whatever you want.
>> 
>> The boot command can also be overridden using the environment. So if you have
>> working environment store, you can change the U-Boot variable "bootcmd" and
>> U-Boot will run that instead when it boots.
>> 
>> The alternative to this default behavior would be no bootcmd at all which means
>> you just get dropped into the U-Boot prompt. While that's reasonably useful for
>> developers, it isn't for people deploying U-Boot on real target systems :).
>> 
>> 
>> Alex
> 
> Thanks for your advises.
> 
> After you send those patchs into main trunk.
> I will fetch and push them to u-boot-riscv.git :)

The usual flow would be the other way around: You apply them to u-boot-riscv.git with your Signed-off-by and send a pull request for the current merge window :).

Unless I misunderstood your earlier reply and you would prefer to have me propagate them to mainline via the efi-next tree?


Alex

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support
@ 2018-05-10  3:27 Rick Chen
  2018-05-10  6:03 ` Alexander Graf
  0 siblings, 1 reply; 28+ messages in thread
From: Rick Chen @ 2018-05-10  3:27 UTC (permalink / raw)
  To: u-boot

> >
> > Then I think if I don't want enter this auto flow, what can I do ?
> >
> > 1 Remove CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But it
> > still enter auto flow.
> >
> > 2 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
> > CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And Remove
> > CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  And it will NOT
> > enter auto flow
> >
> > #ifdef CONFIG_DISTRO_DEFAULTS
> > /* Enable distro boot */
> > #define BOOT_TARGET_DEVICES(func) \
> >         func(MMC, mmc, 0) \
> >         func(DHCP, dhcp, na)
> >
> > #include <config_distro_bootcmd.h>
> >
> > #define CONFIG_EXTRA_ENV_SETTINGS       \
> >                                 "kernel_addr_r=0x00080000\0" \
> >                                 "pxefile_addr_r=0x01f00000\0" \
> >                                 "scriptaddr=0x01f00000\0" \
> >                                 "fdt_addr_r=0x02000000\0" \
> >                                 "ramdisk_addr_r=0x02800000\0" \
> >                                 BOOTENV #endif
> >
> > 3 Add #ifdef CONFIG_DISTRO_DEFAULTS to encapsulate the
> > CONFIG_EXTRA_ENV_SETTINGS in nx25-ae250.h  And do NOT Remove
> > CONFIG_DISTRO_DEFAULTS=y from nx25-ae250_defconfig  But disable
> CONFIG_DISTRO_DEFAULTS from make menuconfig
> >    General setup  --->
> >      [ ] Select defaults suitable for booting general purpose Linux
> > distributions  And it still enter auto flow
> >
> > Offering this information for you.
>
> This is the same for all distro enabled boards. The basic idea is that U-Boot ships
> with something that "just boots" for simple use cases.
>
> If you want something more advanced, you usually want to put something very
> target specific in there anyway, such as "bootm $nor_flash". In that case, you
> adapt the CONFIG_BOOTCOMMAND parameter to whatever you want.
>
> The boot command can also be overridden using the environment. So if you have
> working environment store, you can change the U-Boot variable "bootcmd" and
> U-Boot will run that instead when it boots.
>
> The alternative to this default behavior would be no bootcmd at all which means
> you just get dropped into the U-Boot prompt. While that's reasonably useful for
> developers, it isn't for people deploying U-Boot on real target systems :).
>
>
> Alex

Thanks for your advises.

After you send those patchs into main trunk.
I will fetch and push them to u-boot-riscv.git :)

Rick

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2018-05-10  7:16 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23  5:59 [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
2018-04-23  5:59 ` [U-Boot] [PATCH v3 1/8] riscv: Add setjmp/longjmp code Alexander Graf
2018-05-07  2:25   ` rick at andestech.com
2018-04-23  5:59 ` [U-Boot] [PATCH v3 2/8] riscv: Enable function sections Alexander Graf
2018-04-23  7:35   ` Heinrich Schuchardt
2018-04-23 17:21     ` Alexander Graf
2018-05-07  2:24   ` rick at andestech.com
2018-04-23  5:59 ` [U-Boot] [PATCH v3 3/8] riscv: Add EFI application infrastructure Alexander Graf
2018-04-23  5:59 ` [U-Boot] [PATCH v3 4/8] riscv: Add board_quiesce_devices stub Alexander Graf
2018-05-07  2:25   ` rick at andestech.com
2018-04-23  5:59 ` [U-Boot] [PATCH v3 5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too Alexander Graf
2018-04-23  7:19   ` Heinrich Schuchardt
2018-04-23  5:59 ` [U-Boot] [PATCH v3 6/8] distro: Extend with RISC-V defines Alexander Graf
2018-04-23  6:56   ` Heinrich Schuchardt
2018-04-23  5:59 ` [U-Boot] [PATCH v3 7/8] riscv: nx25: Enable distro boot Alexander Graf
2018-04-24  6:28   ` rick at andestech.com
2018-04-24  7:53     ` Alexander Graf
2018-05-07  2:33   ` rick at andestech.com
2018-04-23  5:59 ` [U-Boot] [PATCH v3 8/8] efi_loader: Enable RISC-V support Alexander Graf
2018-05-06 20:59 ` [U-Boot] [PATCH v3 0/8] riscv: Enable efi_loader support Alexander Graf
2018-05-07  2:13   ` rick at andestech.com
2018-05-09  7:30     ` Alexander Graf
2018-05-06 21:11 ` Tom Rini
2018-05-07  2:18   ` rick at andestech.com
2018-05-10  3:27 Rick Chen
2018-05-10  6:03 ` Alexander Graf
2018-05-10  7:00   ` Rick Chen
2018-05-10  7:16     ` Rick Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.