All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pragnesh Patel <pragnesh.patel@sifive.com>
To: u-boot@lists.denx.de
Subject: [PATCH v12 17/18] configs: fu540: Add config options for U-Boot SPL
Date: Mon, 25 May 2020 13:03:30 +0530	[thread overview]
Message-ID: <20200525073333.14131-18-pragnesh.patel@sifive.com> (raw)
In-Reply-To: <20200525073333.14131-1-pragnesh.patel@sifive.com>

With sifive_fu540_defconfig:

User can use FSBL or u-boot-spl.bin anyone at a time.

For FSBL,
fsbl->fw_payload.bin (opensbi + U-Boot)

For u-boot-spl.bin,
u-boot-spl.bin->FIT image (opensbi + U-Boot proper + dtb)

U-Boot SPL will be loaded by ZSBL from SD card (replace fsbl.bin with
u-boot-spl.bin) and runs in L2 LIM in machine mode and then load FIT
image u-boot.itb from SD card into RAM.

U-Boot SPL expects u-boot.itb FIT image at the starting of SD card sector
number (0x822) of GUID type "2E54B353-1271-4842-806F-E436D6AF6985"

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
 configs/sifive_fu540_defconfig |   8 +++
 doc/board/sifive/fu540.rst     | 124 +++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+)

diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index f805aacc7a..8d412f8d6a 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -1,6 +1,11 @@
 CONFIG_RISCV=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x3000
 CONFIG_ENV_SIZE=0x20000
+CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_SPL=y
+CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_TARGET_SIFIVE_FU540=y
 CONFIG_ARCH_RV64I=y
 CONFIG_RISCV_SMODE=y
@@ -9,7 +14,10 @@ CONFIG_FIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_OF_BOARD_FIXUP=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_CLK=y
 CONFIG_DM_MTD=y
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 610ba87074..5a37e0021d 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -31,6 +31,9 @@ TODO:
         stdout-path = "/soc/serial at 10010000:115200";
    };
 
+Booting from MMC using FSBL
+---------------------------
+
 Building
 --------
 
@@ -421,3 +424,124 @@ as well.
 
    Please press Enter to activate this console.
    / #
+
+Booting from MMC using U-Boot SPL
+---------------------------------
+
+Building
+--------
+
+Before building U-Boot SPL, OpenSBI must be built first. OpenSBI can be
+cloned and built for FU540 as below:
+
+.. code-block:: console
+
+	git clone https://github.com/riscv/opensbi.git
+	cd opensbi
+	make PLATFORM=generic
+	export OPENSBI=<path to opensbi/build/platform/generic/firmware/fw_dynamic.bin>
+
+Now build the U-Boot SPL and U-Boot proper
+
+.. code-block:: console
+
+	cd <U-Boot-dir>
+	make sifive_fu540_defconfig
+	make
+
+This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
+
+
+Flashing
+--------
+
+ZSBL loads the U-Boot SPL (u-boot-spl.bin) from a partition with GUID type
+5B193300-FC78-40CD-8002-E86C45580B47
+
+U-Boot SPL expects a U-Boot FIT image (u-boot.itb) from a partition with GUID
+type 2E54B353-1271-4842-806F-E436D6AF6985
+
+FIT image (u-boot.itb) is a combination of fw_dynamic.bin, u-boot-nodtb.bin and
+device tree blob (hifive-unleashed-a00.dtb)
+
+Format the SD card (make sure the disk has GPT, otherwise use gdisk to switch)
+
+.. code-block:: none
+
+	# sudo sgdisk --clear \
+	> --set-alignment=2 \
+	> --new=1:34:2081 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \
+	> --new=2:2082:10273 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
+	> --new=3:10274: --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \
+	> /dev/sda
+
+Program the SD card
+
+.. code-block:: none
+
+	sudo dd if=spl/u-boot-spl.bin of=/dev/sda seek=34
+	sudo dd if=u-boot.itb of=/dev/sda seek=2082
+
+Booting
+-------
+Once you plugin the sdcard and power up, you should see the U-Boot prompt.
+
+Sample boot log from HiFive Unleashed board
+-------------------------------------------
+
+.. code-block:: none
+
+	U-Boot SPL 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530)
+	Trying to boot from MMC1
+
+
+	U-Boot 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530)
+
+	CPU:   rv64imafdc
+	Model: SiFive HiFive Unleashed A00
+	DRAM:  8 GiB
+	MMC:   spi at 10050000:mmc at 0: 0
+	In:    serial at 10010000
+	Out:   serial at 10010000
+	Err:   serial at 10010000
+	Net:   eth0: ethernet at 10090000
+	Hit any key to stop autoboot:  0
+	=> version
+	U-Boot 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530)
+
+	riscv64-unknown-linux-gnu-gcc (crosstool-NG 1.24.0.37-3f461da) 9.2.0
+	GNU ld (crosstool-NG 1.24.0.37-3f461da) 2.32
+	=> mmc info
+	Device: spi at 10050000:mmc at 0
+	Manufacturer ID: 3
+	OEM: 5344
+	Name: SC16G
+	Bus Speed: 20000000
+	Mode: SD Legacy
+	Rd Block Len: 512
+	SD version 2.0
+	High Capacity: Yes
+	Capacity: 14.8 GiB
+	Bus Width: 1-bit
+	Erase Group Size: 512 Bytes
+	=> mmc part
+
+	Partition Map for MMC device 0  --   Partition Type: EFI
+
+	Part    Start LBA       End LBA         Name
+	Attributes
+	Type GUID
+	Partition GUID
+	1     0x00000022      0x00000821      "loader1"
+	attrs:  0x0000000000000000
+	type:   5b193300-fc78-40cd-8002-e86c45580b47
+	guid:   66e2b5d2-74db-4df8-ad6f-694b3617f87f
+	2     0x00000822      0x00002821      "loader2"
+	attrs:  0x0000000000000000
+	type:   2e54b353-1271-4842-806f-e436d6af6985
+	guid:   8befaeaf-bca0-435d-b002-e201f37c0a2f
+	3     0x00002822      0x01dacbde      "rootfs"
+	attrs:  0x0000000000000000
+	type:   0fc63daf-8483-4772-8e79-3d69d8477de4
+	type:   linux
+	guid:   9faa81b6-39b1-4418-af5e-89c48f29c20d
-- 
2.17.1

  parent reply	other threads:[~2020-05-25  7:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  7:33 [PATCH v12 00/18] RISC-V SiFive FU540 support SPL Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 01/18] misc: add driver for the SiFive otp controller Pragnesh Patel
2020-05-25 21:44   ` Simon Glass
2020-05-26  5:10     ` Pragnesh Patel
2020-05-28  3:08       ` Simon Glass
2020-05-29  7:18         ` Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 02/18] riscv: sifive: fu540: Use OTP DM driver for serial environment variable Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 03/18] riscv: Add _image_binary_end for SPL Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 04/18] lib: Makefile: build crc7.c when CONFIG_MMC_SPI Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 05/18] riscv: sifive: dts: fu540: Add board -u-boot.dtsi files Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 06/18] sifive: fu540: add ddr driver Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 07/18] sifive: dts: fu540: Add DDR controller and phy register settings Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 08/18] riscv: sifive: dts: fu540: add U-Boot dmc node Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 09/18] clk: sifive: fu540-prci: Add clock enable and disable ops Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 10/18] clk: sifive: fu540-prci: Add ddr clock initialization Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 11/18] clk: sifive: fu540-prci: Release ethernet clock reset Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 12/18] riscv: dts: sifive: Sync hifive-unleashed-a00 dts from linux Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 13/18] riscv: cpu: fu540: Add support for cpu fu540 Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 14/18] riscv: sifive: fu540: add SPL configuration Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 15/18] sifive: fu540: Add sample SD gpt partition layout Pragnesh Patel
2020-05-25  7:33 ` [PATCH v12 16/18] sifive: fu540: Add U-Boot proper sector start Pragnesh Patel
2020-05-25  7:33 ` Pragnesh Patel [this message]
2020-05-25  7:33 ` [PATCH v12 18/18] doc: sifive: fu540: Add description for OpenSBI generic platform Pragnesh Patel
2020-05-25 13:12 ` [PATCH v12 00/18] RISC-V SiFive FU540 support SPL Bin Meng
2020-05-25 14:22   ` Pragnesh Patel
2020-05-26  8:05     ` Jagan Teki
2020-05-26  8:08       ` Bin Meng
2020-05-26  8:10         ` Jagan Teki
2020-05-26  8:53       ` Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200525073333.14131-18-pragnesh.patel@sifive.com \
    --to=pragnesh.patel@sifive.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.