Skip to contentSkip to conversation

riscv: board: Support OpenPiton SoC

PATCH Superseded Tianrui Wei 3 participants 22 messages May 6, 2021 – May 19, 2021 RISC-V Page 2 of 2

v4 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#14 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

In reply to Sean Anderson
Quoted 847 lines · Sean Anderson
Quoted 846 lines · Tianrui Wei

Hi Sean,

Quoted 164 lines · Sean Anderson
Quoted 163 lines · Tianrui Wei
Quoted 161 lines · Sean Anderson
Quoted 160 lines · Tianrui Wei
Quoted 156 lines · Sean Anderson
Quoted 72 lines · Tianrui Wei

Hi Sean,

Many thanks again for reviewing our code! We really appreciate it. Will fix the things you're suggesting ;p Though I have a few questions in line in the comment. Also, checkpatch didn't catch any of the identation issues. I was wondering if there are some specific flags to enable some of the checks? I'm running ./utils/checkpatch.pl this.patch right now.

Quoted 50 lines · Sean Anderson
Quoted 5 lines · Tianrui Wei

From: Tianrui Wei <[email protected]>
Date: Thu, 6 May 2021 11:30:20 +0800
Subject: [PATCH V4 2/2] riscv: board: Support OpenPiton SoC

This patch add board support for OpenPiton.

Please add some information to the commit message describing the board.

Quoted 40 lines

---

? arch/riscv/Kconfig????????????????????? |?? 4 +
? arch/riscv/dts/Makefile???????????????? |?? 1 +
? arch/riscv/dts/openpiton-riscv64.dts??? | 159 +++++
? board/openpiton/riscv/Kconfig?????????? |? 42 ++
? board/openpiton/riscv/MAINTAINERS?????? |?? 6 +
? board/openpiton/riscv/Makefile????????? |?? 5 +
? board/openpiton/riscv/openpiton-riscv.c |? 41 ++
? configs/openpiton_riscv64_defconfig???? | 132 ++++
? doc/board/index.rst???????????????????? |?? 1 +
? doc/board/openpiton/index.rst?????????? |?? 9 +
? doc/board/openpiton/riscv64.rst???????? | 885 

++++++++++++++++++++++++
? include/configs/openpiton-riscv.h?????? |? 58 ++ ? 12 files changed, 1343 insertions(+)
? create mode 100644 arch/riscv/dts/openpiton-riscv64.dts ? create mode 100644 board/openpiton/riscv/Kconfig ? create mode 100644 board/openpiton/riscv/MAINTAINERS ? create mode 100644 board/openpiton/riscv/Makefile ? create mode 100644 board/openpiton/riscv/openpiton-riscv.c ? create mode 100644 configs/openpiton_riscv64_defconfig ? create mode 100644 doc/board/openpiton/index.rst ? create mode 100644 doc/board/openpiton/riscv64.rst ? create mode 100644 include/configs/openpiton-riscv.h

arch/riscv/Kconfig +0 -0
index 30b05408..9e7deb34 100644
@@ -23,6 +23,9 @@ config TARGET_SIFIVE_FU540

? config TARGET_SIPEED_MAIX
????? bool "Support Sipeed Maix Board"
? +config TARGET_OPENPITON_RISCV
+? bool "Support riscv cores on openpiton SoC"
+
? endchoice

Quoted 8 lines
Quoted 6 lines

??? config SYS_ICACHE_OFF

arch/riscv/Kconfig +0 -0
@@ -55,6 +58,7 @@ config SPL_SYS_DCACHE_OFF

? source "board/AndesTech/ax25-ae350/Kconfig"
? source "board/emulation/qemu-riscv/Kconfig"
? source "board/microchip/mpfs_icicle/Kconfig"
+source "board/openpiton/riscv/Kconfig"

Fix indentation.

Quoted 2 lines

It shows correct formatting in my client, and there's no warning in checkpatch for some reason

Ignore this, sorry.

Quoted 78 lines
Quoted 78 lines
Quoted 47 lines

? source "board/sifive/fu540/Kconfig"
? source "board/sipeed/maix/Kconfig"
? diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile index 3a6f96c6..b511cd74 100644

arch/riscv/dts/Makefile +0 -0
@@ -1,6 +1,7 @@

? # SPDX-License-Identifier: GPL-2.0+
??? dtb-$(CONFIG_TARGET_AX25_AE350) += ae350_32.dtb ae350_64.dtb +dtb-$(CONFIG_TARGET_OPENPITON_RISCV) += openpiton-riscv64.dtb ? dtb-$(CONFIG_TARGET_SIFIVE_FU540) += hifive-unleashed-a00.dtb ? dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb ? diff --git a/arch/riscv/dts/openpiton-riscv64.dts b/arch/riscv/dts/openpiton-riscv64.dts
new file mode 100644
index 00000000..ce732b92

arch/riscv/dts/openpiton-riscv64.dts new file +5 -0
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Copyright (c) 2021 Tianrui Wei <[email protected]> */
+
+/*
+ * This dts is for a dual core instance of OpenPiton+Ariane 

built
+ * to run on a Digilent Genesys 2 FPGA at 66.67MHz. These files
+ * are automatically generated by the OpenPiton build system and
+ * this configuration may not be what you need if your configuration
+ * is different from the below.
+ */

arch/riscv/dts/openpiton-riscv64.dts new file +12 -0
+
+/dts-v1/;
+
+/ {
+??? #address-cells = <2>;
+??? #size-cells = <2>;
+??? u-boot,dm-pre-reloc;
+??? compatible = "openpiton,ariane";
+
+??? chosen {
+?????? stdout-path = "uart0:115200";
+??? };

arch/riscv/dts/openpiton-riscv64.dts

Quoted 10 lines
arch/riscv/dts/openpiton-riscv64.dts new file +10 -0
+
+??? aliases {
+??????? console = &uart0;
+??????? serial0 = &uart0;
+??? };
+
+??? cpus {
+??????? #address-cells = <1>;
+??????? #size-cells = <0>;
+??????? u-boot,dm-pre-reloc;

This is unnecessary since riscv_cpu has DM_FLAG_PRE_RELOC.

Quoted 4 lines

+ timebase-frequency = <520835>;
+
+??????? CPU0: cpu at 0 {
+??????????? clock-frequency = <66667000>;

Please add a clocks node. If you just have one clock for the whole soc,
you can always use a fixed-clock binding.

Quoted 5 lines

+ u-boot,dm-pre-reloc;
+??????????? device_type = "cpu";
+??????????? reg = <0>;
+??????????? status = "okay";
+??????????? compatible = "eth, ariane", "riscv";

There should be no space after the comma. And what is "eth"? Should this
be lowrisc?

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Oh eth was ETH Zurich, who developed ariane riscv64 CPU.

As I understand it, ETH is an abbreviation like 'UC' in 'UC Berkeley'. So perhaps a better compatible string would be 'zurich,ariane' or 'eth-zurich,ariane'.

Thank you for your feed back. We plan to change it to openhwgroup, cva6 as it's new rebranded name

Quoted 429 lines
Quoted 429 lines
Quoted 427 lines
Quoted 416 lines
Quoted 71 lines
Quoted 71 lines
Quoted 38 lines
Quoted 4 lines
Quoted 12 lines

+??????????? riscv,isa = "rv64imafdc"; +??????????? mmu-type = "riscv,sv39"; +??????????? tlb-split;
+??????????? // HLIC - hart local interrupt controller +??????????? CPU0_intc: interrupt-controller { +??????????????? #interrupt-cells = <1>; +??????????????? interrupt-controller; +??????????????? compatible = "riscv,cpu-intc"; +??????????? };
+??????? };
+
+??????? CPU1: cpu at 1 {

Same comments as above.

Quoted 19 lines

+ clock-frequency = <66667000>;
+??????????? u-boot,dm-pre-reloc; +??????????? device_type = "cpu"; +??????????? reg = <1>;
+??????????? status = "okay";
+??????????? compatible = "eth, ariane", "riscv"; +??????????? riscv,isa = "rv64imafdc"; +??????????? mmu-type = "riscv,sv39"; +??????????? tlb-split;
+??????????? // HLIC - hart local interrupt controller +??????????? CPU1_intc: interrupt-controller { +??????????????? #interrupt-cells = <1>; +??????????????? interrupt-controller; +??????????????? compatible = "riscv,cpu-intc"; +??????????? };
+??????? };

arch/riscv/dts/openpiton-riscv64.dts new file +3 -0
+
+??? };
+
Quoted 8 lines
Quoted 6 lines

+??? memory at 80000000 {
+??????? u-boot,dm-pre-reloc;
+??????? device_type = "memory";
+??????? reg = < 0x00000000 0x80000000 0x00000000 0x40000000 >; +??? };
+

Everything below this line should be under a soc node.

Will do

Quoted 18 lines
Quoted 3 lines

+??? uart0: uart at fff0c2c000 {
+??????? u-boot,dm-pre-reloc;

This is unnecessary. ns16550_serial has DM_FLAG_PRE_RELOC.

Quoted 3 lines

+??????? compatible = "ns16550";
+??????? reg = < 0x000000ff 0xf0c2c000 0x00000000 0x000d4000 >; +??????? clock-frequency = <66667000>;

Please add a clocks node.Documentation/devicetree/bindings/serial/serial.yaml

Quoted 1 line

+??????? current-speed = <115200>;

This is only necessary if the baud rate cannot otherwise be determined.
Please remove this.

Quoted 5 lines
Quoted 1 line

Oh this was necessary to hard code

Why is that? It should be possible to determine the current baud rate
from the input clock and the divider.

That makes sense, will do.

Quoted 48 lines
Quoted 48 lines
Quoted 46 lines
Quoted 5 lines

+??????? interrupt-parent = <&PLIC0>;

Please specify this under /soc.

Quoted 24 lines

+??????? interrupts = <1>;
+??????? reg-shift = <0>;
+??????? // regs are spaced on 8 bit boundary
+??? };

arch/riscv/dts/openpiton-riscv64.dts new file +20 -0
+
+??? eth: ethernet at fff0d00000 {
+??????? compatible = "xlnx,xps-ethernetlite-1.00.a";
+??????? device_type = "network";
+??????? reg = < 0x000000ff 0xf0d00000 0x00000000 0x00100000 >;
+??????? interrupt-parent = <&PLIC0>;
+??????? interrupts = <2>;
+??????? local-mac-address = [ 00 18 3E 02 E3 E5 ];
+??????? phy-handle = <&phy0>;
+??????? xlnx,duplex = <0x1>;
+??????? xlnx,include-global-buffers = <0x1>;
+??????? xlnx,include-internal-loopback = <0x0>;
+??????? xlnx,include-mdio = <0x1>;
+??????? xlnx,rx-ping-pong = <0x1>;
+??????? xlnx,s-axi-id-width = <0x1>;
+??????? xlnx,tx-ping-pong = <0x1>;
+??????? xlnx,use-internal = <0x0>;
+??????? axi_ethernetlite_0_mdio: mdio {
+??????????? #address-cells = <1>;
+??????????? #size-cells = <0>;

arch/riscv/dts/openpiton-riscv64.dts

Quoted 10 lines
arch/riscv/dts/openpiton-riscv64.dts new file +10 -0
+??????????? phy0: phy at 1 {
+??????????????? compatible = "ethernet-phy-id001C.C915";
+??????????????? device_type = "ethernet-phy";
+??????????????? reg = <1>;
+??????????? };
+??????? };
+??? };
+
+??? debug-controller at fff1000000 {
+??????? compatible = "riscv,debug-013";

Is this binding needed? Will U-Boot/Linux/whoever need to initialize
this device?

Quoted 4 lines
Quoted 1 line

I think

Well, for the moment there is no driver for this in U-Boot or Linux.

Oh then I must be mistaken, will remove.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines

+ interrupts-extended = < &CPU0_intc 65535 +??????????????????????????????? &CPU1_intc 65535 >;

Please align these.

Quoted 5 lines

+??????? reg = < 0x000000ff 0xf1000000 0x00000000 0x00001000 >; +??????? reg-names = "control";
+??? };
+
+??? sdhci_0: sdhci at 0xf000000000 {

No 0x prefix please.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+ u-boot,dm-pre-reloc;

Why does this need to be pre-reloc?

We're using it in SPL

Then please use u-boot,dm-spl

Will do

Quoted 248 lines
Quoted 248 lines
Quoted 130 lines
Quoted 8 lines

+??????? status = "okay";
+??????? compatible = "openpiton,piton-mmc";
+??????? reg = < 0x000000f0 0x00000000 0x00000000 0x00300000 >; +??? };

Missing newline.

Quoted 2 lines

+??? clint at fff1020000 {
+??????? u-boot,dm-pre-reloc;

Again, unnecessary since the driver has the flag set.

Quoted 5 lines

+??????? compatible = "sifive,clint0";
+??????? interrupts-extended = < &CPU0_intc 3
+??????????????????????????????? &CPU0_intc 7
+??????????????????????????????? &CPU1_intc 3
+??????????????????????????????? &CPU1_intc 7 >;

Please align this.

Quoted 2 lines

+??????? reg = < 0x000000ff 0xf1020000 0x00000000 0x000c0000 >; +??????? reg-names = "control";

Please add a clocks property.

Quoted 4 lines

+??? };
+
+??? PLIC0: plic at fff1100000 {
+??????? u-boot,dm-pre-reloc;

Again, unnecessary.

Quoted 1 line

+??????? #address-cells = <0>;

Remove this.

Quoted 7 lines

+??????? #interrupt-cells = <1>;
+??????? compatible = "sifive,plic-1.0.0";
+??????? interrupt-controller;
+??????? interrupts-extended = < &CPU0_intc 11
+??????????????????????????????? &CPU0_intc 9
+??????????????????????????????? &CPU1_intc 11
+??????????????????????????????? &CPU1_intc 9 >;

Align these please.

Quoted 4 lines

+??????? reg = < 0x000000ff 0xf1100000 0x00000000 0x04000000 >; +??????? riscv,max-priority = <7>;
+??????? riscv,ndev = <2>;
+??? };

In general, please add soc-specific compatible strings (e.g. "openpiton,ns16550") to allow for forward compatibility.

Quoted 38 lines
arch/riscv/dts/openpiton-riscv64.dts new file +3 -0
+
+};
+
board/openpiton/riscv/Kconfig new file +28 -0
new file mode 100644
index 00000000..31ae44d5
@@ -0,0 +1,42 @@
+if TARGET_OPENPITON_RISCV
+
+config SYS_BOARD
+??? default "riscv"
+
+config SYS_VENDOR
+??? default "openpiton"
+
+config SYS_CPU
+??? default "generic"
+
+config SYS_CONFIG_NAME
+??? default "openpiton-riscv"
+
+config SYS_TEXT_BASE
+??? default 0x81000000 if SPL
+??? default 0x80000000 if !RISCV_SMODE
+??? default 0x81000000 if RISCV_SMODE
+
+config SPL_TEXT_BASE
+??? default 0x80000000
+
+config SPL_OPENSBI_LOAD_ADDR
+??? default 0x81000000
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+??? def_bool y
+??? select ARCH_EARLY_INIT_R

board/openpiton/riscv/Kconfig line 38

Quoted 10 lines
board/openpiton/riscv/Kconfig new file +10 -0
+??? select SUPPORT_SPL
+??? imply CPU_RISCV
+??? imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE)
+??? imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE)
+??? imply CMD_CPU
+??? imply SPL_CPU_SUPPORT
+??? imply SPL_OPENSBI
+??? imply SPL_LOAD_FIT
+??? imply SPL_SMP
+??? imply SPL_MMC

Fix indentation please. Did you run checkpatch?

board/openpiton/riscv/MAINTAINERS line 1

Quoted 12 lines
board/openpiton/riscv/Kconfig new file +4 -0
+??? imply SMP
+??? imply SPL_RISCV_MMODE
+
+endif
board/openpiton/riscv/MAINTAINERS new file +1 -0
new file mode 100644
index 00000000..1db6fb60
@@ -0,0 +1,6 @@
+Openpiton Riscv Bootloader

OpenPiton BOARD

board/openpiton/riscv/MAINTAINERS line 4

Quoted 3 lines
board/openpiton/riscv/MAINTAINERS new file +3 -0
+M:??? Tianrui Wei<[email protected]>
+S:??? Maintained
+F:??? board/openpiton/riscv/

Will there be non-riscv openpiton boards?

Quoted 5 lines

In general, the directory layout here is

board/manufacturer/board_name

So who manufactures OpenPiton?

There will probably be, yes.

OpenPiton is a community project, and will continue to support other isas in the future ( already a few other supported now )

Quoted 104 lines
Quoted 53 lines
board/openpiton/riscv/MAINTAINERS new file +2 -0
+F: include/configs/openpiton-riscv.h
+F:??? configs/openpiton_riscv_defconfig
board/openpiton/riscv/Makefile new file +5 -0
new file mode 100644
index 00000000..8cc20e7c
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2021 Tianrui Wei
+# Tianrui Wei <[email protected]>
+obj-y += openpiton-riscv.o
board/openpiton/riscv/openpiton-riscv.c new file +31 -0
new file mode 100644
index 00000000..5be407e7
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 SiFive, Inc
+ * Copyright (c) 2021 Tianrui Wei
+ *
+ *
+ * Authors:
+ *?? Pragnesh Patel <[email protected]>
+ *?? Tianrui Wei <[email protected]>
+ */
+#include <common.h>
+#include <init.h>
+#include <configs/openpiton-riscv.h>
+#include <dm.h>
+#include <spl.h>
+
+#ifdef CONFIG_SPL
+void board_boot_order(u32 *spl_boot_list)
+{
+??? u8 i;
+??? u32 boot_devices[] = {
+??????? BOOT_DEVICE_MMC1,
+??? };
+
+??? for (i = 0; i < ARRAY_SIZE(boot_devices); i++)
+??????? spl_boot_list[i] = boot_devices[i];
+}
+#endif
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)

board/openpiton/riscv/openpiton-riscv.c line 41

Quoted 10 lines
board/openpiton/riscv/openpiton-riscv.c new file +10 -0
+{
+??? /* boot using first FIT config */
+??? return 0;
+}
+#endif
+
+int board_init(void)
+{
+??????? return 0;
+}

Do you need get_effective_memsize?

Quoted 38 lines
configs/openpiton_riscv64_defconfig new file +31 -0
new file mode 100644
index 00000000..37aa3c80
@@ -0,0 +1,132 @@
+CONFIG_RISCV=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_SPL=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="openpiton-riscv64"
+CONFIG_TARGET_OPENPITON_RISCV=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_MISC_INIT_R=n
+CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
+CONFIG_SPL_PAYLOAD=""
+CONFIG_LIBDISK_SUPPORT=y
+CONFIG_NR_CPUS=32
+CONFIG_CMODEL_MEDANY=y
+CONFIG_EXPORT=n
+CONFIG_HASH=n
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_BANNER_PRINT=n
+CONFIG_SPL_CRC32_SUPPORT=n
+CONFIG_GENERATE_SMBIOS_TABLE=n
+CONFIG_EFI_LOADER=n
+CONFIG_LIB_DATA=y
+CONFIG_SPL_USE_TINY_PRINTF=y
+CONFIG_SPL_TINY_MEMSET=y
+CONFIG_FS_EXT4=y
+CONFIG_DM_RTC=y
+CONFIG_SYS_NS16550=y
+CONFIG_SPL_OPENSBI=n
+CONFIG_SPL_RTC_SUPPORT=y
+CONFIG_SPL_FS_EXT4=y
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

configs/openpiton_riscv64_defconfig line 39

Quoted 8 lines
configs/openpiton_riscv64_defconfig new file +8 -0
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_CMD_NET=n
+CONFIG_EFI_PARTITION=y
+CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=128
+CONFIG_EFI_PARTITION_ENTRIES_OFF=0
+CONFIG_SPL_EFI_PARTITION=y
+CONFIG_PARTITION_UUIDS=y
+CONFIG_OF_EMBED=y

This is not allowed for mainline boards. Please use OF_SEPARATE (for M-mode) or OF_PRIOR_STAGE (for S-mode).

Quoted 4 lines
Quoted 1 line

Interesting. Does it work for SPL also?

For SPL two binaries are produced, one with a DTB and one without. You can use either in whatever build step follows.

Thank you. As long as SPL has an embedded dtb, we're fine.

Quoted 229 lines
Quoted 220 lines
Quoted 220 lines
Quoted 219 lines
Quoted 209 lines
Quoted 209 lines
Quoted 159 lines
Quoted 87 lines
configs/openpiton_riscv64_defconfig new file +83 -0
+CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_CPU=y
+CONFIG_CPU_RISCV=y
+CONFIG_MMC=y
+CONFIG_DM_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_MMC_PITON=y
+CONFIG_MMC_QUIRKS=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_NS16550=y
+CONFIG_DEBUG_UART_SHIFT=0
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_DEBUG_UART_BASE=0xfff0c2c000
+CONFIG_DEBUG_UART_CLOCK=66667000
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_MMC_VERBOSE=n
+CONFIG_MMC_WRITE=n
+CONFIG_MMC_HW_PARTITIONING=n
+CONFIG_SYS_RELOC_GD_ENV_ADDR=n
+CONFIG_SAVEENV=n
+CONFIG_NET=n
+CONFIG_SPL_PARTITION_UUIDS=n
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_READ=y
+CONFIG_CMD_LSBLK=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_EXPERT=n
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_LEGACY_IMAGE_FORMAT=n
+CONFIG_ARCH_FIXUP_FDT_MEMORY=n
+CONFIG_MENU=y
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_PART=y
+CONFIG_SHOW_REGS=y
+CONFIG_LOG=y
+CONFIG_LOGLEVEL=9
+CONFIG_SPL_LOGLEVEL=9
+CONFIG_TPL_LOGLEVEL=9
+CONFIG_SPL_LOG=y
+CONFIG_SPL_LOG_MAX_LEVEL=9
+CONFIG_SPL_LOG_CONSOLE=y
+CONFIG_LOG_ERROR_RETURN=y
+CONFIG_CMD_CPU=n
+CONFIG_BOOTM_NETBSD=n
+CONFIG_BOOTM_PLAN9=n
+CONFIG_BOOTM_RTEMS=n
+CONFIG_BOOTM_VXWORKS=n
+CONFIG_CMD_RUN=n
+CONFIG_CMD_IMI=n
+CONFIG_CMD_XIMG=n
+CONFIG_CMD_EXPORTENV=n
+CONFIG_CMD_IMPORTENV=n
+CONFIG_CMD_EDITENV=n
+CONFIG_CMD_SAVEENV=n
+CONFIG_CMD_CRC32=n
+CONFIG_CMD_RANDOM=n
+CONFIG_CMD_LZMADEC=n
+CONFIG_CMD_UNLZ4=n
+CONFIG_CMD_UNZIP=n
+CONFIG_CMD_FLASH=n
+CONFIG_RANDOM_UUID=n
+CONFIG_CMD_LOADB=n
+CONFIG_CMD_LOADS=n
+CONFIG_CMD_ECHO=n
+CONFIG_CMD_ITEST=n
+CONFIG_CMD_SOURCE=n
+CONFIG_CMD_SETEXPR=n
+CONFIG_CMD_BLOCK_CACHE=n
+CONFIG_CMD_DATE=n
+CONFIG_CMD_SLEEP=n
+CONFIG_CMD_SYSBOOT=y
+CONFIG_CMD_FAT=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ISO_PARTITION=y
+CONFIG_DM_ETH=y
+CONFIG_RAM=y
+CONFIG_SPL_RAM=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_MAX_CLUSTSIZE=65536

configs/openpiton_riscv64_defconfig line 132

Quoted 10 lines
configs/openpiton_riscv64_defconfig new file +10 -0
+CONFIG_FS_SQUASHFS=y
+CONFIG_SHA1=y
+CONFIG_SHA256=y
+CONFIG_MD5=y
+CONFIG_ZLIB_UNCOMPRESS=y
+CONFIG_SPL_GZIP=y
+CONFIG_SPL_ZLIB=y
+CONFIG_GETOPT=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_RAM_SIFIVE=n

Did you generate this with "make savedefconfig"?

Quoted 9 lines
doc/board/index.rst +0 -0
index 915f1be8..51e60ac4 100644
@@ -17,6 +17,7 @@ Board-specific doc

???? google/index
???? intel/index
???? kontron/index
+?? openpiton/index

Fix indentation

Quoted 47 lines

???? renesas/index
???? rockchip/index
???? sifive/index

doc/board/openpiton/index.rst new file +9 -0
new file mode 100644
index 00000000..c469102c
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+OpenPiton
+=========
+
+.. toctree::
+?? :maxdepth: 2
+
+?? riscv64
doc/board/openpiton/riscv64.rst new file +8 -0
new file mode 100644
index 00000000..dc934bb4
@@ -0,0 +1,885 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Openpiton RISC-V SoC
+====================
+
+OpenPiton RISC-V SoC
+--------------------
+OpenPiton is an open source, manycore processor and research 

platform. It is a tiled manycore framework scalable from one to 1/2 billion cores. It supports a number of ISAs including RISC-V with its P-Mesh cache coherence protocol and networks on chip. It is highly configurable in both core and uncore components. OpenPiton has been verified in both ASIC and multiple Xilinx FPGA prototypes running full-stack Debian linux.

doc/board/openpiton/riscv64.rst new file +4 -0
+
+RISCV-V Standard Bootflow
+-------------------------
+Currently, OpenPiton implements RISC-V standard bootflow in 

the following steps
+mover.S -> u-boot-spl -> opensbi -> u-boot -> Linux

Quoted 8 lines
Quoted 6 lines
doc/board/openpiton/riscv64.rst new file +5 -0
+This board supports S-mode u-boot as well as M-mode SPL
+
+Building OpenPition
+---------------------
+If you'd like to build OpenPiton, please go to OpenPiton 

github repo to build from the latest changes

Please link to the github.

Will do

Quoted 35 lines
Quoted 32 lines
doc/board/openpiton/riscv64.rst new file +31 -0
+
+Building Images
+---------------------------
+
+SPL
+---
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. make openpiton_riscv64_defconfig
+4. make
+
+U-Boot
+------
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. make openpiton_riscv64_defconfig
+4. make menuconfig, then change CONFIG_SYS_TEXT_BASE to 
Quoted 1 line

0x81020000

Why isn't this the default?

Quoted 5 lines
Quoted 3 lines

Because u-boot SPL will just to CONFIG)SYS_TEXT_BASE ( where opensbi is ). If I change that, it will just jump to the wrong location.

Can you make this dependent on S-Mode?

I'm not sure making it dependent on S-mode helpful, because in essense we need to generate u-boot and u-boot spl in 2 passes, so it had to be different

Quoted 6 lines
Quoted 2 lines

U-Boot and SPL should be produced in the same pass. See e.g. SiFive Unleashed.

Hmm that's only possible because they're using FIT, whereas we aren't though.

I don't see what that has to do with anything.

Quoted 7 lines
Quoted 4 lines

If we're using fit, SPL will jump to any address as indicated by fit.

If not however, SPL will jump to CONFIG_SYS_TEXT_BASE, which is the text base for u-boot proper

Ok, so use FIT. I believe the standard boot flow is to have SPL load a FIT with OpenSBI and U-Boot.

I just realized for qemu, SPL and U-Boot was actually produced in separate defconfigs. Would that work here?

Quoted 203 lines
Quoted 203 lines
Quoted 203 lines
Quoted 185 lines
Quoted 185 lines
Quoted 184 lines
Quoted 59 lines
Quoted 54 lines
Quoted 44 lines
Quoted 44 lines

+5. make

doc/board/openpiton/riscv64.rst new file +15 -0
+
+
+opensbi
+-------
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. Go to OpenSBI directory
+4. Edit platform/fpga/openpiton/config.mk, and change 

FW_TEXT_START to 0x81000000
+5. make PLATFORM=fpga/openpiton FW_PAYLOAD_PATH=<path to u-boot-nodtb.bin>

doc/board/openpiton/riscv64.rst new file +5 -0
+
+
+Using fw_payload.bin with linux
+-------------------------------
+Put the generated fw_payload.bin into the /boot directory on 

the root filesystem, plug in the SD card, then flash the bitstream. Linux will boot automatically.

doc/board/openpiton/riscv64.rst new file +4 -0
+
+Booting
+-------
+Once you plugin the sdcard and power up, you should see the 

U-Boot prompt.
+

Quoted 8 lines

doc/board/openpiton/riscv64.rst

Quoted 6 lines
doc/board/openpiton/riscv64.rst new file +6 -0
+Sample Dual-core Debian boot log from OpenPiton
+-----------------------------------------------
+
+.. code-block:: none
+
+? <debug_uart>

Please use a log without debug uart.

Quoted 4 lines

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

Quoted 4 lines

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having alignment problems in k210, so it could be something similar.

Hmm that was a good idea. Thanks for the suggestion!

Quoted 100 lines
Quoted 100 lines
Quoted 28 lines
include/configs/openpiton-riscv.h +0 -0
Quoted 24 lines

new file mode 100644
index 00000000..0f30609b

include/configs/openpiton-riscv.h new file +3 -0
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its 

affiliates.
+ * Copyright (c) 2021 Tianrui Wei
+ *
+ * Authors:
+ *?? Anup Patel <[email protected]>
+ *?? Tianrui Wei <[email protected]>
+ */

include/configs/openpiton-riscv.h new file +9 -0
+
+#ifndef __OPENPITON_RISCV_CONFIG_H
+#define __OPENPITON_RISCV_CONFIG_H
+
+#include <linux/sizes.h>
+#define DEBUG
+#ifdef CONFIG_SPL
+#define CONFIG_SPL_MAX_SIZE???? 0x00100000
+#define CONFIG_SPL_BSS_START_ADDR?? 0x82000000
Quoted 8 lines

include/configs/openpiton-riscv.h

Quoted 6 lines
include/configs/openpiton-riscv.h new file +2 -0
+#define CONFIG_SPL_BSS_MAX_SIZE???? 0x00100000
+#define CONFIG_SYS_SPL_MALLOC_START 

(CONFIG_SPL_BSS_START_ADDR + \
+??????? CONFIG_SPL_BSS_MAX_SIZE)

include/configs/openpiton-riscv.h new file +2 -0
+#define CONFIG_SYS_SPL_MALLOC_SIZE? 0x0100000
+#define CONFIG_SPL_STACK??? (0x80000000 + 0x04000000 - \

Please use SZ_64M here, or just use an absolute address.

Will fix

Quoted 32 lines
Quoted 17 lines

+ GENERATED_GBL_DATA_SIZE)

include/configs/openpiton-riscv.h new file +15 -0
+
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "boot/fw_payload.bin"
+#define CONFIG_SPL_GD_ADDR 0x85000000
+#endif
+
+/* Environment options */
+#define CONFIG_SYS_SDRAM_BASE 0x80000000
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
+#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
+#define CONFIG_SYS_MALLOC_LEN?????? SZ_256M
+#define CONFIG_SYS_BOOTM_LEN??????? SZ_256M
+
+/* -------------------------------------------------
+ * Environment
+ */

include/configs/openpiton-riscv.h

Quoted 10 lines
include/configs/openpiton-riscv.h new file +8 -1
+//Disable persistent environment variable storage
+#define CONFIG_ENV_IS_NOWHERE?? 1
+
+/* 
--------------------------------------------------------------------- 
 
+ * Board boot configuration
+ */
+
+#define CONFIG_EXTRA_ENV_SETTINGS "\0"

Please define some of the raw addresses used below to make modifying the
boot process easier. For example,

Quoted 5 lines

??? fdt_addr_r=0x86000000
??? kernel_addr_r=0x80200000
??? image=Image
??? mmcdev=0
??? mmcpart=1

Good idea! Will do!

Quoted 17 lines

include/configs/openpiton-riscv.h

Quoted 8 lines
include/configs/openpiton-riscv.h new file +6 -0
+
+#define CONFIG_USE_BOOTCOMMAND
+#define CONFIG_BOOTCOMMAND \
+??? "fdt addr ${fdtcontroladdr}; " \
+??? "fdt move ${fdtcontroladdr} 0x86000000; " \
+??? "ext4load mmc 0:1 0x80200000 boot/Image; " \

Can you use "load" from CONFIG_CMD_FS_GENERIC?

Quoted 1 line

+??? "booti 0x80200000 - 0x86000000; "

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is there a bootm flow?

No we don't support fit yet for some hardware reasons.

Can you elaborate on that? I wasn't aware of any restrictions in this
area.

So OpenPiton is actually some kind of SoC generator that generates different SoC on FPGA. The device tree was generated at bitstream creation time to facilitate different configurations, so each board can have different device trees. We're aware of any way to do this in
FIT.

Quoted 7 lines
Quoted 3 lines

Oh, so you're saying that the devicetree is placed at a specific address
in hardware? Does it need any fixups?

No for now we just embed it in SPL, will be converted into the bootrom for the chip with a small ZSBL.

Well, atm you are using the DTS embedded in U-Boot.

I don't know what the correct way to do this is...

+CC Bin, Heinrich: Do you have a comment on this?

Quoted 3 lines

Also, now that you mention fixups u-boot spl doesn't work at high address like 0xffffff0000 for now. Is that the case?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

What happens why you try that?

It would simply fail to compile with some link errors

Hm, I don't know the specific cause of that. You would have to post the errors.

The exact error message is

common/built-in.o: in function `malloc_trim':
/u-boot/common/dlmalloc.c:2236:(.text.malloc_trim+0x7e): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR0' common/built-in.o: in function free':
/u-boot/common/dlmalloc.c:1603:(.text.free+0x62): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR3' common/built-in.o: in function malloc_extend_top':
/u-boot/common/dlmalloc.c:1124:(.text.malloc+0x284): relocation truncated to fit: R_RISCV_PCREL_HI20 against `.LANCHOR3' scripts/Makefile.spl:463: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1
Makefile:1904: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2
make: *** Waiting for unfinished jobs....

With the qemu_riscv64_spl_defconfig on u-boot HEAD, only changing CONFIG_SPL_TEXT_BASE to 0xfff00000000.

Thanks,

Tianrui

Quoted 14 lines

--Sean

Quoted 9 lines

Many thanks for your valuable feedbacks!

Tianrui

Quoted 2 lines

--Sean

#15 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

In reply to Sean Anderson

Hi Sean,

Quoted 847 lines · Sean Anderson
Quoted 846 lines · Tianrui Wei

Hi Sean,

Quoted 164 lines · Sean Anderson
Quoted 163 lines · Tianrui Wei
Quoted 161 lines · Sean Anderson
Quoted 160 lines · Tianrui Wei
Quoted 156 lines · Sean Anderson
Quoted 72 lines · Tianrui Wei

Hi Sean,

Many thanks again for reviewing our code! We really appreciate it. Will fix the things you're suggesting ;p Though I have a few questions in line in the comment. Also, checkpatch didn't catch any of the identation issues. I was wondering if there are some specific flags to enable some of the checks? I'm running ./utils/checkpatch.pl this.patch right now.

Quoted 50 lines · Sean Anderson
Quoted 5 lines · Tianrui Wei

From: Tianrui Wei <[email protected]>
Date: Thu, 6 May 2021 11:30:20 +0800
Subject: [PATCH V4 2/2] riscv: board: Support OpenPiton SoC

This patch add board support for OpenPiton.

Please add some information to the commit message describing the board.

Quoted 40 lines

---

? arch/riscv/Kconfig????????????????????? |?? 4 +
? arch/riscv/dts/Makefile???????????????? |?? 1 +
? arch/riscv/dts/openpiton-riscv64.dts??? | 159 +++++
? board/openpiton/riscv/Kconfig?????????? |? 42 ++
? board/openpiton/riscv/MAINTAINERS?????? |?? 6 +
? board/openpiton/riscv/Makefile????????? |?? 5 +
? board/openpiton/riscv/openpiton-riscv.c |? 41 ++
? configs/openpiton_riscv64_defconfig???? | 132 ++++
? doc/board/index.rst???????????????????? |?? 1 +
? doc/board/openpiton/index.rst?????????? |?? 9 +
? doc/board/openpiton/riscv64.rst???????? | 885 

++++++++++++++++++++++++
? include/configs/openpiton-riscv.h?????? |? 58 ++ ? 12 files changed, 1343 insertions(+)
? create mode 100644 arch/riscv/dts/openpiton-riscv64.dts ? create mode 100644 board/openpiton/riscv/Kconfig ? create mode 100644 board/openpiton/riscv/MAINTAINERS ? create mode 100644 board/openpiton/riscv/Makefile ? create mode 100644 board/openpiton/riscv/openpiton-riscv.c ? create mode 100644 configs/openpiton_riscv64_defconfig ? create mode 100644 doc/board/openpiton/index.rst ? create mode 100644 doc/board/openpiton/riscv64.rst ? create mode 100644 include/configs/openpiton-riscv.h

arch/riscv/Kconfig +0 -0
index 30b05408..9e7deb34 100644
@@ -23,6 +23,9 @@ config TARGET_SIFIVE_FU540

? config TARGET_SIPEED_MAIX
????? bool "Support Sipeed Maix Board"
? +config TARGET_OPENPITON_RISCV
+? bool "Support riscv cores on openpiton SoC"
+
? endchoice

Quoted 8 lines
Quoted 6 lines

??? config SYS_ICACHE_OFF

arch/riscv/Kconfig +0 -0
@@ -55,6 +58,7 @@ config SPL_SYS_DCACHE_OFF

? source "board/AndesTech/ax25-ae350/Kconfig"
? source "board/emulation/qemu-riscv/Kconfig"
? source "board/microchip/mpfs_icicle/Kconfig"
+source "board/openpiton/riscv/Kconfig"

Fix indentation.

Quoted 2 lines

It shows correct formatting in my client, and there's no warning in checkpatch for some reason

Ignore this, sorry.

Quoted 78 lines
Quoted 78 lines
Quoted 47 lines

? source "board/sifive/fu540/Kconfig"
? source "board/sipeed/maix/Kconfig"
? diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile index 3a6f96c6..b511cd74 100644

arch/riscv/dts/Makefile +0 -0
@@ -1,6 +1,7 @@

? # SPDX-License-Identifier: GPL-2.0+
??? dtb-$(CONFIG_TARGET_AX25_AE350) += ae350_32.dtb ae350_64.dtb +dtb-$(CONFIG_TARGET_OPENPITON_RISCV) += openpiton-riscv64.dtb ? dtb-$(CONFIG_TARGET_SIFIVE_FU540) += hifive-unleashed-a00.dtb ? dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb ? diff --git a/arch/riscv/dts/openpiton-riscv64.dts b/arch/riscv/dts/openpiton-riscv64.dts
new file mode 100644
index 00000000..ce732b92

arch/riscv/dts/openpiton-riscv64.dts new file +5 -0
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Copyright (c) 2021 Tianrui Wei <[email protected]> */
+
+/*
+ * This dts is for a dual core instance of OpenPiton+Ariane 

built
+ * to run on a Digilent Genesys 2 FPGA at 66.67MHz. These files
+ * are automatically generated by the OpenPiton build system and
+ * this configuration may not be what you need if your configuration
+ * is different from the below.
+ */

arch/riscv/dts/openpiton-riscv64.dts new file +12 -0
+
+/dts-v1/;
+
+/ {
+??? #address-cells = <2>;
+??? #size-cells = <2>;
+??? u-boot,dm-pre-reloc;
+??? compatible = "openpiton,ariane";
+
+??? chosen {
+?????? stdout-path = "uart0:115200";
+??? };

arch/riscv/dts/openpiton-riscv64.dts

Quoted 10 lines
arch/riscv/dts/openpiton-riscv64.dts new file +10 -0
+
+??? aliases {
+??????? console = &uart0;
+??????? serial0 = &uart0;
+??? };
+
+??? cpus {
+??????? #address-cells = <1>;
+??????? #size-cells = <0>;
+??????? u-boot,dm-pre-reloc;

This is unnecessary since riscv_cpu has DM_FLAG_PRE_RELOC.

Quoted 4 lines

+ timebase-frequency = <520835>;
+
+??????? CPU0: cpu at 0 {
+??????????? clock-frequency = <66667000>;

Please add a clocks node. If you just have one clock for the whole soc,
you can always use a fixed-clock binding.

Quoted 5 lines

+ u-boot,dm-pre-reloc;
+??????????? device_type = "cpu";
+??????????? reg = <0>;
+??????????? status = "okay";
+??????????? compatible = "eth, ariane", "riscv";

There should be no space after the comma. And what is "eth"? Should this
be lowrisc?

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Oh eth was ETH Zurich, who developed ariane riscv64 CPU.

As I understand it, ETH is an abbreviation like 'UC' in 'UC Berkeley'. So perhaps a better compatible string would be 'zurich,ariane' or 'eth-zurich,ariane'.

Thank you for your feed back. We plan to change it to openhwgroup, cva6 as it's new rebranded name

Quoted 429 lines
Quoted 429 lines
Quoted 427 lines
Quoted 416 lines
Quoted 71 lines
Quoted 71 lines
Quoted 38 lines
Quoted 4 lines
Quoted 12 lines

+??????????? riscv,isa = "rv64imafdc"; +??????????? mmu-type = "riscv,sv39"; +??????????? tlb-split;
+??????????? // HLIC - hart local interrupt controller +??????????? CPU0_intc: interrupt-controller { +??????????????? #interrupt-cells = <1>; +??????????????? interrupt-controller; +??????????????? compatible = "riscv,cpu-intc"; +??????????? };
+??????? };
+
+??????? CPU1: cpu at 1 {

Same comments as above.

Quoted 19 lines

+ clock-frequency = <66667000>;
+??????????? u-boot,dm-pre-reloc; +??????????? device_type = "cpu"; +??????????? reg = <1>;
+??????????? status = "okay";
+??????????? compatible = "eth, ariane", "riscv"; +??????????? riscv,isa = "rv64imafdc"; +??????????? mmu-type = "riscv,sv39"; +??????????? tlb-split;
+??????????? // HLIC - hart local interrupt controller +??????????? CPU1_intc: interrupt-controller { +??????????????? #interrupt-cells = <1>; +??????????????? interrupt-controller; +??????????????? compatible = "riscv,cpu-intc"; +??????????? };
+??????? };

arch/riscv/dts/openpiton-riscv64.dts new file +3 -0
+
+??? };
+
Quoted 8 lines
Quoted 6 lines

+??? memory at 80000000 {
+??????? u-boot,dm-pre-reloc;
+??????? device_type = "memory";
+??????? reg = < 0x00000000 0x80000000 0x00000000 0x40000000 >; +??? };
+

Everything below this line should be under a soc node.

Will do

Quoted 18 lines
Quoted 3 lines

+??? uart0: uart at fff0c2c000 {
+??????? u-boot,dm-pre-reloc;

This is unnecessary. ns16550_serial has DM_FLAG_PRE_RELOC.

Quoted 3 lines

+??????? compatible = "ns16550";
+??????? reg = < 0x000000ff 0xf0c2c000 0x00000000 0x000d4000 >; +??????? clock-frequency = <66667000>;

Please add a clocks node.Documentation/devicetree/bindings/serial/serial.yaml

Quoted 1 line

+??????? current-speed = <115200>;

This is only necessary if the baud rate cannot otherwise be determined.
Please remove this.

Quoted 5 lines
Quoted 1 line

Oh this was necessary to hard code

Why is that? It should be possible to determine the current baud rate
from the input clock and the divider.

That makes sense, will do.

Quoted 48 lines
Quoted 48 lines
Quoted 46 lines
Quoted 5 lines

+??????? interrupt-parent = <&PLIC0>;

Please specify this under /soc.

Quoted 24 lines

+??????? interrupts = <1>;
+??????? reg-shift = <0>;
+??????? // regs are spaced on 8 bit boundary
+??? };

arch/riscv/dts/openpiton-riscv64.dts new file +20 -0
+
+??? eth: ethernet at fff0d00000 {
+??????? compatible = "xlnx,xps-ethernetlite-1.00.a";
+??????? device_type = "network";
+??????? reg = < 0x000000ff 0xf0d00000 0x00000000 0x00100000 >;
+??????? interrupt-parent = <&PLIC0>;
+??????? interrupts = <2>;
+??????? local-mac-address = [ 00 18 3E 02 E3 E5 ];
+??????? phy-handle = <&phy0>;
+??????? xlnx,duplex = <0x1>;
+??????? xlnx,include-global-buffers = <0x1>;
+??????? xlnx,include-internal-loopback = <0x0>;
+??????? xlnx,include-mdio = <0x1>;
+??????? xlnx,rx-ping-pong = <0x1>;
+??????? xlnx,s-axi-id-width = <0x1>;
+??????? xlnx,tx-ping-pong = <0x1>;
+??????? xlnx,use-internal = <0x0>;
+??????? axi_ethernetlite_0_mdio: mdio {
+??????????? #address-cells = <1>;
+??????????? #size-cells = <0>;

arch/riscv/dts/openpiton-riscv64.dts

Quoted 10 lines
arch/riscv/dts/openpiton-riscv64.dts new file +10 -0
+??????????? phy0: phy at 1 {
+??????????????? compatible = "ethernet-phy-id001C.C915";
+??????????????? device_type = "ethernet-phy";
+??????????????? reg = <1>;
+??????????? };
+??????? };
+??? };
+
+??? debug-controller at fff1000000 {
+??????? compatible = "riscv,debug-013";

Is this binding needed? Will U-Boot/Linux/whoever need to initialize
this device?

Quoted 4 lines
Quoted 1 line

I think

Well, for the moment there is no driver for this in U-Boot or Linux.

Oh then I must be mistaken, will remove.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines

+ interrupts-extended = < &CPU0_intc 65535 +??????????????????????????????? &CPU1_intc 65535 >;

Please align these.

Quoted 5 lines

+??????? reg = < 0x000000ff 0xf1000000 0x00000000 0x00001000 >; +??????? reg-names = "control";
+??? };
+
+??? sdhci_0: sdhci at 0xf000000000 {

No 0x prefix please.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+ u-boot,dm-pre-reloc;

Why does this need to be pre-reloc?

We're using it in SPL

Then please use u-boot,dm-spl

Will do

Quoted 248 lines
Quoted 248 lines
Quoted 130 lines
Quoted 8 lines

+??????? status = "okay";
+??????? compatible = "openpiton,piton-mmc";
+??????? reg = < 0x000000f0 0x00000000 0x00000000 0x00300000 >; +??? };

Missing newline.

Quoted 2 lines

+??? clint at fff1020000 {
+??????? u-boot,dm-pre-reloc;

Again, unnecessary since the driver has the flag set.

Quoted 5 lines

+??????? compatible = "sifive,clint0";
+??????? interrupts-extended = < &CPU0_intc 3
+??????????????????????????????? &CPU0_intc 7
+??????????????????????????????? &CPU1_intc 3
+??????????????????????????????? &CPU1_intc 7 >;

Please align this.

Quoted 2 lines

+??????? reg = < 0x000000ff 0xf1020000 0x00000000 0x000c0000 >; +??????? reg-names = "control";

Please add a clocks property.

Quoted 4 lines

+??? };
+
+??? PLIC0: plic at fff1100000 {
+??????? u-boot,dm-pre-reloc;

Again, unnecessary.

Quoted 1 line

+??????? #address-cells = <0>;

Remove this.

Quoted 7 lines

+??????? #interrupt-cells = <1>;
+??????? compatible = "sifive,plic-1.0.0";
+??????? interrupt-controller;
+??????? interrupts-extended = < &CPU0_intc 11
+??????????????????????????????? &CPU0_intc 9
+??????????????????????????????? &CPU1_intc 11
+??????????????????????????????? &CPU1_intc 9 >;

Align these please.

Quoted 4 lines

+??????? reg = < 0x000000ff 0xf1100000 0x00000000 0x04000000 >; +??????? riscv,max-priority = <7>;
+??????? riscv,ndev = <2>;
+??? };

In general, please add soc-specific compatible strings (e.g. "openpiton,ns16550") to allow for forward compatibility.

Quoted 38 lines
arch/riscv/dts/openpiton-riscv64.dts new file +3 -0
+
+};
+
board/openpiton/riscv/Kconfig new file +28 -0
new file mode 100644
index 00000000..31ae44d5
@@ -0,0 +1,42 @@
+if TARGET_OPENPITON_RISCV
+
+config SYS_BOARD
+??? default "riscv"
+
+config SYS_VENDOR
+??? default "openpiton"
+
+config SYS_CPU
+??? default "generic"
+
+config SYS_CONFIG_NAME
+??? default "openpiton-riscv"
+
+config SYS_TEXT_BASE
+??? default 0x81000000 if SPL
+??? default 0x80000000 if !RISCV_SMODE
+??? default 0x81000000 if RISCV_SMODE
+
+config SPL_TEXT_BASE
+??? default 0x80000000
+
+config SPL_OPENSBI_LOAD_ADDR
+??? default 0x81000000
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+??? def_bool y
+??? select ARCH_EARLY_INIT_R

board/openpiton/riscv/Kconfig line 38

Quoted 10 lines
board/openpiton/riscv/Kconfig new file +10 -0
+??? select SUPPORT_SPL
+??? imply CPU_RISCV
+??? imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE)
+??? imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE)
+??? imply CMD_CPU
+??? imply SPL_CPU_SUPPORT
+??? imply SPL_OPENSBI
+??? imply SPL_LOAD_FIT
+??? imply SPL_SMP
+??? imply SPL_MMC

Fix indentation please. Did you run checkpatch?

board/openpiton/riscv/MAINTAINERS line 1

Quoted 12 lines
board/openpiton/riscv/Kconfig new file +4 -0
+??? imply SMP
+??? imply SPL_RISCV_MMODE
+
+endif
board/openpiton/riscv/MAINTAINERS new file +1 -0
new file mode 100644
index 00000000..1db6fb60
@@ -0,0 +1,6 @@
+Openpiton Riscv Bootloader

OpenPiton BOARD

board/openpiton/riscv/MAINTAINERS line 4

Quoted 3 lines
board/openpiton/riscv/MAINTAINERS new file +3 -0
+M:??? Tianrui Wei<[email protected]>
+S:??? Maintained
+F:??? board/openpiton/riscv/

Will there be non-riscv openpiton boards?

Quoted 5 lines

In general, the directory layout here is

board/manufacturer/board_name

So who manufactures OpenPiton?

There will probably be, yes.

OpenPiton is a community project, and will continue to support other isas in the future ( already a few other supported now )

Quoted 104 lines
Quoted 53 lines
board/openpiton/riscv/MAINTAINERS new file +2 -0
+F: include/configs/openpiton-riscv.h
+F:??? configs/openpiton_riscv_defconfig
board/openpiton/riscv/Makefile new file +5 -0
new file mode 100644
index 00000000..8cc20e7c
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2021 Tianrui Wei
+# Tianrui Wei <[email protected]>
+obj-y += openpiton-riscv.o
board/openpiton/riscv/openpiton-riscv.c new file +31 -0
new file mode 100644
index 00000000..5be407e7
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 SiFive, Inc
+ * Copyright (c) 2021 Tianrui Wei
+ *
+ *
+ * Authors:
+ *?? Pragnesh Patel <[email protected]>
+ *?? Tianrui Wei <[email protected]>
+ */
+#include <common.h>
+#include <init.h>
+#include <configs/openpiton-riscv.h>
+#include <dm.h>
+#include <spl.h>
+
+#ifdef CONFIG_SPL
+void board_boot_order(u32 *spl_boot_list)
+{
+??? u8 i;
+??? u32 boot_devices[] = {
+??????? BOOT_DEVICE_MMC1,
+??? };
+
+??? for (i = 0; i < ARRAY_SIZE(boot_devices); i++)
+??????? spl_boot_list[i] = boot_devices[i];
+}
+#endif
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)

board/openpiton/riscv/openpiton-riscv.c line 41

Quoted 10 lines
board/openpiton/riscv/openpiton-riscv.c new file +10 -0
+{
+??? /* boot using first FIT config */
+??? return 0;
+}
+#endif
+
+int board_init(void)
+{
+??????? return 0;
+}

Do you need get_effective_memsize?

Quoted 38 lines
configs/openpiton_riscv64_defconfig new file +31 -0
new file mode 100644
index 00000000..37aa3c80
@@ -0,0 +1,132 @@
+CONFIG_RISCV=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_SPL=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="openpiton-riscv64"
+CONFIG_TARGET_OPENPITON_RISCV=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_MISC_INIT_R=n
+CONFIG_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
+CONFIG_SPL_PAYLOAD=""
+CONFIG_LIBDISK_SUPPORT=y
+CONFIG_NR_CPUS=32
+CONFIG_CMODEL_MEDANY=y
+CONFIG_EXPORT=n
+CONFIG_HASH=n
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_BANNER_PRINT=n
+CONFIG_SPL_CRC32_SUPPORT=n
+CONFIG_GENERATE_SMBIOS_TABLE=n
+CONFIG_EFI_LOADER=n
+CONFIG_LIB_DATA=y
+CONFIG_SPL_USE_TINY_PRINTF=y
+CONFIG_SPL_TINY_MEMSET=y
+CONFIG_FS_EXT4=y
+CONFIG_DM_RTC=y
+CONFIG_SYS_NS16550=y
+CONFIG_SPL_OPENSBI=n
+CONFIG_SPL_RTC_SUPPORT=y
+CONFIG_SPL_FS_EXT4=y
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

configs/openpiton_riscv64_defconfig line 39

Quoted 8 lines
configs/openpiton_riscv64_defconfig new file +8 -0
+CONFIG_SPL_LEGACY_IMAGE_SUPPORT=n
+CONFIG_CMD_NET=n
+CONFIG_EFI_PARTITION=y
+CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=128
+CONFIG_EFI_PARTITION_ENTRIES_OFF=0
+CONFIG_SPL_EFI_PARTITION=y
+CONFIG_PARTITION_UUIDS=y
+CONFIG_OF_EMBED=y

This is not allowed for mainline boards. Please use OF_SEPARATE (for M-mode) or OF_PRIOR_STAGE (for S-mode).

Quoted 4 lines
Quoted 1 line

Interesting. Does it work for SPL also?

For SPL two binaries are produced, one with a DTB and one without. You can use either in whatever build step follows.

Thank you. As long as SPL has an embedded dtb, we're fine.

Quoted 229 lines
Quoted 220 lines
Quoted 220 lines
Quoted 219 lines
Quoted 209 lines
Quoted 209 lines
Quoted 159 lines
Quoted 87 lines
configs/openpiton_riscv64_defconfig new file +83 -0
+CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_CPU=y
+CONFIG_CPU_RISCV=y
+CONFIG_MMC=y
+CONFIG_DM_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_MMC_PITON=y
+CONFIG_MMC_QUIRKS=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_NS16550=y
+CONFIG_DEBUG_UART_SHIFT=0
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_DEBUG_UART_BASE=0xfff0c2c000
+CONFIG_DEBUG_UART_CLOCK=66667000
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_MMC_VERBOSE=n
+CONFIG_MMC_WRITE=n
+CONFIG_MMC_HW_PARTITIONING=n
+CONFIG_SYS_RELOC_GD_ENV_ADDR=n
+CONFIG_SAVEENV=n
+CONFIG_NET=n
+CONFIG_SPL_PARTITION_UUIDS=n
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_READ=y
+CONFIG_CMD_LSBLK=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_EXPERT=n
+CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_LEGACY_IMAGE_FORMAT=n
+CONFIG_ARCH_FIXUP_FDT_MEMORY=n
+CONFIG_MENU=y
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_PART=y
+CONFIG_SHOW_REGS=y
+CONFIG_LOG=y
+CONFIG_LOGLEVEL=9
+CONFIG_SPL_LOGLEVEL=9
+CONFIG_TPL_LOGLEVEL=9
+CONFIG_SPL_LOG=y
+CONFIG_SPL_LOG_MAX_LEVEL=9
+CONFIG_SPL_LOG_CONSOLE=y
+CONFIG_LOG_ERROR_RETURN=y
+CONFIG_CMD_CPU=n
+CONFIG_BOOTM_NETBSD=n
+CONFIG_BOOTM_PLAN9=n
+CONFIG_BOOTM_RTEMS=n
+CONFIG_BOOTM_VXWORKS=n
+CONFIG_CMD_RUN=n
+CONFIG_CMD_IMI=n
+CONFIG_CMD_XIMG=n
+CONFIG_CMD_EXPORTENV=n
+CONFIG_CMD_IMPORTENV=n
+CONFIG_CMD_EDITENV=n
+CONFIG_CMD_SAVEENV=n
+CONFIG_CMD_CRC32=n
+CONFIG_CMD_RANDOM=n
+CONFIG_CMD_LZMADEC=n
+CONFIG_CMD_UNLZ4=n
+CONFIG_CMD_UNZIP=n
+CONFIG_CMD_FLASH=n
+CONFIG_RANDOM_UUID=n
+CONFIG_CMD_LOADB=n
+CONFIG_CMD_LOADS=n
+CONFIG_CMD_ECHO=n
+CONFIG_CMD_ITEST=n
+CONFIG_CMD_SOURCE=n
+CONFIG_CMD_SETEXPR=n
+CONFIG_CMD_BLOCK_CACHE=n
+CONFIG_CMD_DATE=n
+CONFIG_CMD_SLEEP=n
+CONFIG_CMD_SYSBOOT=y
+CONFIG_CMD_FAT=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ISO_PARTITION=y
+CONFIG_DM_ETH=y
+CONFIG_RAM=y
+CONFIG_SPL_RAM=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_MAX_CLUSTSIZE=65536

configs/openpiton_riscv64_defconfig line 132

Quoted 10 lines
configs/openpiton_riscv64_defconfig new file +10 -0
+CONFIG_FS_SQUASHFS=y
+CONFIG_SHA1=y
+CONFIG_SHA256=y
+CONFIG_MD5=y
+CONFIG_ZLIB_UNCOMPRESS=y
+CONFIG_SPL_GZIP=y
+CONFIG_SPL_ZLIB=y
+CONFIG_GETOPT=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_RAM_SIFIVE=n

Did you generate this with "make savedefconfig"?

Quoted 9 lines
doc/board/index.rst +0 -0
index 915f1be8..51e60ac4 100644
@@ -17,6 +17,7 @@ Board-specific doc

???? google/index
???? intel/index
???? kontron/index
+?? openpiton/index

Fix indentation

Quoted 47 lines

???? renesas/index
???? rockchip/index
???? sifive/index

doc/board/openpiton/index.rst new file +9 -0
new file mode 100644
index 00000000..c469102c
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+OpenPiton
+=========
+
+.. toctree::
+?? :maxdepth: 2
+
+?? riscv64
doc/board/openpiton/riscv64.rst new file +8 -0
new file mode 100644
index 00000000..dc934bb4
@@ -0,0 +1,885 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Openpiton RISC-V SoC
+====================
+
+OpenPiton RISC-V SoC
+--------------------
+OpenPiton is an open source, manycore processor and research 

platform. It is a tiled manycore framework scalable from one to 1/2 billion cores. It supports a number of ISAs including RISC-V with its P-Mesh cache coherence protocol and networks on chip. It is highly configurable in both core and uncore components. OpenPiton has been verified in both ASIC and multiple Xilinx FPGA prototypes running full-stack Debian linux.

doc/board/openpiton/riscv64.rst new file +4 -0
+
+RISCV-V Standard Bootflow
+-------------------------
+Currently, OpenPiton implements RISC-V standard bootflow in 

the following steps
+mover.S -> u-boot-spl -> opensbi -> u-boot -> Linux

Quoted 8 lines
Quoted 6 lines
doc/board/openpiton/riscv64.rst new file +5 -0
+This board supports S-mode u-boot as well as M-mode SPL
+
+Building OpenPition
+---------------------
+If you'd like to build OpenPiton, please go to OpenPiton 

github repo to build from the latest changes

Please link to the github.

Will do

Quoted 35 lines
Quoted 32 lines
doc/board/openpiton/riscv64.rst new file +31 -0
+
+Building Images
+---------------------------
+
+SPL
+---
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. make openpiton_riscv64_defconfig
+4. make
+
+U-Boot
+------
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. make openpiton_riscv64_defconfig
+4. make menuconfig, then change CONFIG_SYS_TEXT_BASE to 
Quoted 1 line

0x81020000

Why isn't this the default?

Quoted 5 lines
Quoted 3 lines

Because u-boot SPL will just to CONFIG)SYS_TEXT_BASE ( where opensbi is ). If I change that, it will just jump to the wrong location.

Can you make this dependent on S-Mode?

I'm not sure making it dependent on S-mode helpful, because in essense we need to generate u-boot and u-boot spl in 2 passes, so it had to be different

Quoted 6 lines
Quoted 2 lines

U-Boot and SPL should be produced in the same pass. See e.g. SiFive Unleashed.

Hmm that's only possible because they're using FIT, whereas we aren't though.

I don't see what that has to do with anything.

Quoted 70 lines
Quoted 4 lines

If we're using fit, SPL will jump to any address as indicated by fit.

If not however, SPL will jump to CONFIG_SYS_TEXT_BASE, which is the text base for u-boot proper

Ok, so use FIT. I believe the standard boot flow is to have SPL load a FIT with OpenSBI and U-Boot.

Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 53 lines
Quoted 43 lines
Quoted 43 lines

+5. make

doc/board/openpiton/riscv64.rst new file +15 -0
+
+
+opensbi
+-------
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+?? export CROSS_COMPILE=<riscv64 toolchain prefix>
+?? export ARCH=riscv
+
+3. Go to OpenSBI directory
+4. Edit platform/fpga/openpiton/config.mk, and change 

FW_TEXT_START to 0x81000000
+5. make PLATFORM=fpga/openpiton FW_PAYLOAD_PATH=<path to u-boot-nodtb.bin>

doc/board/openpiton/riscv64.rst new file +5 -0
+
+
+Using fw_payload.bin with linux
+-------------------------------
+Put the generated fw_payload.bin into the /boot directory on 

the root filesystem, plug in the SD card, then flash the bitstream. Linux will boot automatically.

doc/board/openpiton/riscv64.rst new file +4 -0
+
+Booting
+-------
+Once you plugin the sdcard and power up, you should see the 

U-Boot prompt.
+

Quoted 8 lines

doc/board/openpiton/riscv64.rst

Quoted 6 lines
doc/board/openpiton/riscv64.rst new file +6 -0
+Sample Dual-core Debian boot log from OpenPiton
+-----------------------------------------------
+
+.. code-block:: none
+
+? <debug_uart>

Please use a log without debug uart.

Quoted 4 lines

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having alignment problems in k210, so it could be something similar.

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

Thanks,

Tianrui

Quoted 161 lines
Quoted 137 lines
Quoted 137 lines
Quoted 122 lines
Quoted 122 lines
Quoted 121 lines

Hmm that was a good idea. Thanks for the suggestion!

Quoted 100 lines
Quoted 100 lines
Quoted 28 lines
include/configs/openpiton-riscv.h +0 -0
Quoted 24 lines

new file mode 100644
index 00000000..0f30609b

include/configs/openpiton-riscv.h new file +3 -0
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its 

affiliates.
+ * Copyright (c) 2021 Tianrui Wei
+ *
+ * Authors:
+ *?? Anup Patel <[email protected]>
+ *?? Tianrui Wei <[email protected]>
+ */

include/configs/openpiton-riscv.h new file +9 -0
+
+#ifndef __OPENPITON_RISCV_CONFIG_H
+#define __OPENPITON_RISCV_CONFIG_H
+
+#include <linux/sizes.h>
+#define DEBUG
+#ifdef CONFIG_SPL
+#define CONFIG_SPL_MAX_SIZE???? 0x00100000
+#define CONFIG_SPL_BSS_START_ADDR?? 0x82000000
Quoted 8 lines

include/configs/openpiton-riscv.h

Quoted 6 lines
include/configs/openpiton-riscv.h new file +2 -0
+#define CONFIG_SPL_BSS_MAX_SIZE???? 0x00100000
+#define CONFIG_SYS_SPL_MALLOC_START 

(CONFIG_SPL_BSS_START_ADDR + \
+??????? CONFIG_SPL_BSS_MAX_SIZE)

include/configs/openpiton-riscv.h new file +2 -0
+#define CONFIG_SYS_SPL_MALLOC_SIZE? 0x0100000
+#define CONFIG_SPL_STACK??? (0x80000000 + 0x04000000 - \

Please use SZ_64M here, or just use an absolute address.

Will fix

Quoted 32 lines
Quoted 17 lines

+ GENERATED_GBL_DATA_SIZE)

include/configs/openpiton-riscv.h new file +15 -0
+
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "boot/fw_payload.bin"
+#define CONFIG_SPL_GD_ADDR 0x85000000
+#endif
+
+/* Environment options */
+#define CONFIG_SYS_SDRAM_BASE 0x80000000
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
+#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
+#define CONFIG_SYS_MALLOC_LEN?????? SZ_256M
+#define CONFIG_SYS_BOOTM_LEN??????? SZ_256M
+
+/* -------------------------------------------------
+ * Environment
+ */

include/configs/openpiton-riscv.h

Quoted 10 lines
include/configs/openpiton-riscv.h new file +8 -1
+//Disable persistent environment variable storage
+#define CONFIG_ENV_IS_NOWHERE?? 1
+
+/* 
--------------------------------------------------------------------- 
 
+ * Board boot configuration
+ */
+
+#define CONFIG_EXTRA_ENV_SETTINGS "\0"

Please define some of the raw addresses used below to make modifying the
boot process easier. For example,

Quoted 5 lines

??? fdt_addr_r=0x86000000
??? kernel_addr_r=0x80200000
??? image=Image
??? mmcdev=0
??? mmcpart=1

Good idea! Will do!

Quoted 17 lines

include/configs/openpiton-riscv.h

Quoted 8 lines
include/configs/openpiton-riscv.h new file +6 -0
+
+#define CONFIG_USE_BOOTCOMMAND
+#define CONFIG_BOOTCOMMAND \
+??? "fdt addr ${fdtcontroladdr}; " \
+??? "fdt move ${fdtcontroladdr} 0x86000000; " \
+??? "ext4load mmc 0:1 0x80200000 boot/Image; " \

Can you use "load" from CONFIG_CMD_FS_GENERIC?

Quoted 1 line

+??? "booti 0x80200000 - 0x86000000; "

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is there a bootm flow?

No we don't support fit yet for some hardware reasons.

Can you elaborate on that? I wasn't aware of any restrictions in this
area.

So OpenPiton is actually some kind of SoC generator that generates different SoC on FPGA. The device tree was generated at bitstream creation time to facilitate different configurations, so each board can have different device trees. We're aware of any way to do this in
FIT.

Quoted 7 lines
Quoted 3 lines

Oh, so you're saying that the devicetree is placed at a specific address
in hardware? Does it need any fixups?

No for now we just embed it in SPL, will be converted into the bootrom for the chip with a small ZSBL.

Well, atm you are using the DTS embedded in U-Boot.

I don't know what the correct way to do this is...

+CC Bin, Heinrich: Do you have a comment on this?

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Also, now that you mention fixups u-boot spl doesn't work at high address like 0xffffff0000 for now. Is that the case?

What happens why you try that?

It would simply fail to compile with some link errors

Hm, I don't know the specific cause of that. You would have to post the errors.

--Sean

Quoted 9 lines

Many thanks for your valuable feedbacks!

Tianrui

Quoted 2 lines

--Sean

#16 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

[snip]

Quoted 16 lines · Sean Anderson
Quoted 15 lines · Tianrui Wei
Quoted 14 lines · Sean Anderson
Quoted 13 lines · Tianrui Wei
Quoted 12 lines · Sean Anderson
Quoted 11 lines · Tianrui Wei
Quoted 10 lines · Sean Anderson
Quoted 9 lines · Tianrui Wei
Quoted 7 lines · Sean Anderson
Quoted 2 lines

Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

This is a bit of a strange request, but can you try adding some nops() (around 10-30) to some function (e.g. board_init). I've been having alignment problems in k210, so it could be something similar.

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

--Sean

#17 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

Hi Sean,

Quoted 41 lines · Sean Anderson

[snip]

Quoted 22 lines · Sean Anderson
Quoted 15 lines · Tianrui Wei
Quoted 14 lines · Sean Anderson
Quoted 13 lines · Tianrui Wei
Quoted 12 lines · Sean Anderson
Quoted 11 lines · Tianrui Wei
Quoted 10 lines · Sean Anderson
Quoted 9 lines · Tianrui Wei
Quoted 7 lines · Sean Anderson
Quoted 2 lines

Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having
alignment problems in k210, so it could be something similar.

Quoted 3 lines

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

Quoted 3 lines

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

I did try to switch from -Os to -O2, and it didn't help either. I've also encountered

the same debugger situation unfortunately, so I have not much luck finding the

faulty instruction either.? Maybe we should bring this issue up with the others along

the compilation error?

Thanks,

Tianrui

Quoted 2 lines

--Sean

#18 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

Hi Tianrui,

Quoted 53 lines · Tianrui Wei

Hi Sean,

Quoted 41 lines · Sean Anderson

[snip]

Quoted 22 lines · Sean Anderson
Quoted 15 lines · Tianrui Wei
Quoted 14 lines · Sean Anderson
Quoted 13 lines · Tianrui Wei
Quoted 12 lines · Sean Anderson
Quoted 11 lines · Tianrui Wei
Quoted 10 lines · Sean Anderson
Quoted 9 lines · Tianrui Wei
Quoted 7 lines · Sean Anderson
Quoted 2 lines

Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having
alignment problems in k210, so it could be something similar.

Quoted 3 lines

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

Quoted 3 lines

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

I did try to switch from -Os to -O2, and it didn't help either. I've also encountered

Quoted 7 lines

the same debugger situation unfortunately, so I have not much luck finding the

faulty instruction either. Maybe we should bring this issue up with the others along

the compilation error?

Sorry I lost the track. What problems are you seeing?

Regards,
Bin

#19 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

Hi Bin,

Quoted 51 lines · Bin Meng

Hi Tianrui,

Quoted 48 lines · Tianrui Wei

Hi Sean,

Quoted 38 lines · Sean Anderson

[snip]

Quoted 21 lines · Sean Anderson
Quoted 14 lines · Tianrui Wei
Quoted 13 lines · Sean Anderson
Quoted 12 lines · Tianrui Wei
Quoted 11 lines · Sean Anderson
Quoted 10 lines · Tianrui Wei
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Tianrui Wei
Quoted 7 lines · Sean Anderson
Quoted 2 lines

Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling debug uart acutally doesn't work for some reason, so we had to keep it open. Will submit another patch if we got it working with debug uart turned off.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having
alignment problems in k210, so it could be something similar.

Quoted 3 lines

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

Quoted 3 lines

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

I did try to switch from -Os to -O2, and it didn't help either. I've also encountered

Quoted 8 lines
Quoted 7 lines

the same debugger situation unfortunately, so I have not much luck finding the

faulty instruction either. Maybe we should bring this issue up with the others along

the compilation error?

Sorry I lost the track. What problems are you seeing?

There are two issues we're talking about.

The first issue is a compilation issue, where CONFIG_SYS_TEXT_BASE cannot be set to a high address, otherwise the linker will error. The error messages are as follows

common/built-in.o: in function `malloc_trim':
/u-boot/common/dlmalloc.c:2236:(.text.malloc_trim+0x7e): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR0' common/built-in.o: in function free':
/u-boot/common/dlmalloc.c:1603:(.text.free+0x62): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR3' common/built-in.o: in function malloc_extend_top':
/u-boot/common/dlmalloc.c:1124:(.text.malloc+0x284): relocation truncated to fit: R_RISCV_PCREL_HI20 against `.LANCHOR3' scripts/Makefile.spl:463: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1
Makefile:1904: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2
make: *** Waiting for unfinished jobs....

With the qemu_riscv64_spl_defconfig on u-boot HEAD and toolchain of xpack-riscv-none-embed-gcc-10.1.0-1.1, only changing CONFIG_SPL_TEXT_BASE to 0xfff00000000.

The second problem we're seeing is that u-boot can only successfully boot linux with a set of certain configuration options. In our case, we had to explicitly enable many irrelevant features and turn on uart debug for linux to boot, otherwise uboot will be stuck. Sean suspected there may be some alignment issues.

Thanks,

Tianrui

Quoted 3 lines

Regards,
Bin

#20 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

Hi Tianrui,

Quoted 62 lines · Tianrui Wei

Hi Bin,

Quoted 58 lines · Bin Meng

Hi Tianrui,

Quoted 55 lines · Tianrui Wei

Hi Sean,

Quoted 38 lines · Sean Anderson

[snip]

Quoted 21 lines · Sean Anderson
Quoted 14 lines · Tianrui Wei
Quoted 13 lines · Sean Anderson
Quoted 12 lines · Tianrui Wei
Quoted 11 lines · Sean Anderson
Quoted 10 lines · Tianrui Wei
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Tianrui Wei
Quoted 7 lines · Sean Anderson

Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling
debug uart acutally doesn't work for some reason, so we had to
keep it open. Will submit another patch if we got it working
with debug uart turned off.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is a bit of a strange request, but can you try adding some nops()
(around 10-30) to some function (e.g. board_init). I've been having
alignment problems in k210, so it could be something similar.

Quoted 3 lines

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

Quoted 3 lines

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

I did try to switch from -Os to -O2, and it didn't help either. I've also encountered

the same debugger situation unfortunately, so I have not much luck finding the

faulty instruction either. Maybe we should bring this issue up with the others along

the compilation error?

Quoted 9 lines
Quoted 1 line

Sorry I lost the track. What problems are you seeing?

There are two issues we're talking about.

The first issue is a compilation issue, where CONFIG_SYS_TEXT_BASE cannot be set to a high address, otherwise the linker will error. The error messages are as follows

Why do you need to set it to a high address?

Quoted 21 lines

common/built-in.o: in function `malloc_trim':
/u-boot/common/dlmalloc.c:2236:(.text.malloc_trim+0x7e): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR0' common/built-in.o: in function free':
/u-boot/common/dlmalloc.c:1603:(.text.free+0x62): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR3' common/built-in.o: in function malloc_extend_top':
/u-boot/common/dlmalloc.c:1124:(.text.malloc+0x284): relocation truncated to fit: R_RISCV_PCREL_HI20 against `.LANCHOR3' scripts/Makefile.spl:463: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1
Makefile:1904: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2
make: *** Waiting for unfinished jobs....

With the qemu_riscv64_spl_defconfig on u-boot HEAD and toolchain of xpack-riscv-none-embed-gcc-10.1.0-1.1, only changing CONFIG_SPL_TEXT_BASE to 0xfff00000000.

Quoted 6 lines

The second problem we're seeing is that u-boot can only successfully boot linux with a set of certain configuration options. In our case, we had to explicitly enable many irrelevant features and turn on uart debug for linux to boot, otherwise uboot will be stuck. Sean suspected there may be some alignment issues.

Does U-Boot boot, or were you talking about using U-Boot to boot Linux kernel and saw some random crash of U-Boot or Linux?

Regards,
Bin

#21 lore raw

PATCH v4 2/2 riscv: board: Support OpenPiton SoC

Hi Sean,

Quoted 65 lines · Bin Meng

Hi Tianrui,

Quoted 62 lines · Tianrui Wei

Hi Bin,

Quoted 58 lines · Bin Meng

Hi Tianrui,

Quoted 47 lines · Tianrui Wei

Hi Sean,

Quoted 38 lines · Sean Anderson

[snip]

Quoted 21 lines · Sean Anderson
Quoted 14 lines · Tianrui Wei
Quoted 13 lines · Sean Anderson
Quoted 12 lines · Tianrui Wei
Quoted 11 lines · Sean Anderson
Quoted 10 lines · Tianrui Wei
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Tianrui Wei

On 5/7/2021 10:32 AM, Sean Anderson wrote:
Please use a log without debug uart.

So this is the part where it was a little confusing. Disabling
debug uart acutally doesn't work for some reason, so we had to
keep it open. Will submit another patch if we got it working
with debug uart turned off.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is a bit of a strange request, but can you try adding
some nops()
(around 10-30) to some function (e.g. board_init). I've been
having
alignment problems in k210, so it could be something similar.

Quoted 3 lines

I was wondering if you have any idea what may cause the alignment problems, we're also hitting it constantly and adding nops seems to have no impact so far.

I have no idea :)

If adding nop()s doesn't solve it, it may not be an alignment problem. You can also try switching from -Os to -O2, which should move things around a bit.

My attempts to dig into this have been stymied by the poor debugging tools for the k210. The upstream openocd port only supports debugging hart 0. While Canaan's fork supports debugging both harts, you must pick the one to debug when launching the debugger. And both debuggers are very buggy themselves.

Quoted 3 lines

The other problem on the k210 at least is that the typical failure mode (trying to read from unaddressable/unmapped addresses) hangs the bus. This also has the tendancy of hanging the jtag debug port.

I did try to switch from -Os to -O2, and it didn't help either. I've also encountered

Quoted 7 lines

the same debugger situation unfortunately, so I have not much luck finding the

faulty instruction either. Maybe we should bring this issue up with the others along

the compilation error?

Sorry I lost the track. What problems are you seeing?

Quoted 7 lines
Quoted 6 lines

There are two issues we're talking about.

The first issue is a compilation issue, where CONFIG_SYS_TEXT_BASE cannot be set to a high address, otherwise the linker will error. The error messages are as follows

Why do you need to set it to a high address?

Out bootrom was at this address, and we were hoping to use SPL as ZSBL directly.

Quoted 21 lines
Quoted 21 lines

common/built-in.o: in function `malloc_trim':
/u-boot/common/dlmalloc.c:2236:(.text.malloc_trim+0x7e): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR0' common/built-in.o: in function free':
/u-boot/common/dlmalloc.c:1603:(.text.free+0x62): relocation truncated to fit: R_RISCV_PCREL_HI20 against .LANCHOR3' common/built-in.o: in function malloc_extend_top':
/u-boot/common/dlmalloc.c:1124:(.text.malloc+0x284): relocation truncated to fit: R_RISCV_PCREL_HI20 against `.LANCHOR3' scripts/Makefile.spl:463: recipe for target 'spl/u-boot-spl' failed make[1]: *** [spl/u-boot-spl] Error 1
Makefile:1904: recipe for target 'spl/u-boot-spl' failed
make: *** [spl/u-boot-spl] Error 2
make: *** Waiting for unfinished jobs....

With the qemu_riscv64_spl_defconfig on u-boot HEAD and toolchain of xpack-riscv-none-embed-gcc-10.1.0-1.1, only changing CONFIG_SPL_TEXT_BASE to 0xfff00000000.

Quoted 8 lines
Quoted 6 lines

The second problem we're seeing is that u-boot can only successfully boot linux with a set of certain configuration options. In our case, we had to explicitly enable many irrelevant features and turn on uart debug for linux to boot, otherwise uboot will be stuck. Sean suspected there may be some alignment issues.

Does U-Boot boot, or were you talking about using U-Boot to boot Linux kernel and saw some random crash of U-Boot or Linux?

U-Boot boots alright, but it will stuck when loading the kernel image without specific

configurations.

Quoted 3 lines

Regards,
Bin