[PATCH v7 22/22] doc: sifive: fu540: Add description for RISC-V FU540 U-Boot SPL

Pragnesh Patel pragnesh.patel at sifive.com
Sat May 2 12:06:26 CEST 2020


Add descriptions about U-Boot SPL feature and how to build and run
from MMC.

Signed-off-by: Pragnesh Patel <pragnesh.patel at sifive.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 doc/board/sifive/fu540.rst | 376 +++++++++++++++++++++++++++++++++++++
 1 file changed, 376 insertions(+)

diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 1c3d4740f3..2911e3652e 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -38,6 +38,9 @@ TODO:
 		reg = <0x0 0x2000000 0x0 0xc0000>;
 	};
 
+Booting from MMC using FSBL
+---------------------------
+
 Building
 --------
 
@@ -428,3 +431,376 @@ 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 FW_DYNAMIC=y
+
+Copy OpenSBI FW_DYNAMIC image
+(build/platform/sifive/fu540/firmware/fw_dynamic.bin) into U-Boot
+root directory
+
+.. code-block:: console
+
+	cp build/platform/sifive/fu540/firmware/fw_dynamic.bin <u-boot-dir>
+
+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
+	Board serial number should not be 0 !!
+	Net:
+	Warning: ethernet at 10090000 (eth0) using random MAC address - 96:06:92:18:eb:04
+	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
+
+Now you can configure your networking, tftp server and use tftp boot method to
+load uImage.
+
+.. code-block:: none
+
+	=> setenv serverip 192.168.0.103
+	=> setenv serverip 192.168.0.102
+	=> tftpboot 0x83000000 fit.itb
+	ethernet at 10090000: PHY present at 0
+	ethernet at 10090000: Starting autonegotiation...
+	ethernet at 10090000: Autonegotiation complete
+	ethernet at 10090000: link up, 100Mbps full-duplex (lpa: 0x4de1)
+	*** ERROR: `ipaddr' not set
+	=> setenv serverip 192.168.0.103
+	=> setenv ipaddr 192.168.0.102
+	=> tftpboot 0x83000000 fit.itb
+	ethernet at 10090000: PHY present at 0
+	ethernet at 10090000: Starting autonegotiation...
+	ethernet at 10090000: Autonegotiation complete
+	ethernet at 10090000: link up, 100Mbps full-duplex (lpa: 0x4de1)
+	Using ethernet at 10090000 device
+	TFTP from server 192.168.0.103; our IP address is 192.168.0.102
+	Filename 'fit.itb'.
+	Load address: 0x83000000
+	Loading: #################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#################################################################
+	#######################################################
+	4.2 MiB/s
+	done
+	Bytes transferred = 14254183 (d98067 hex)
+	=> bootm 0x83000000
+	## Loading kernel from FIT Image at 83000000 ...
+	Using 'config-1' configuration
+	Trying 'kernel at 1' kernel subimage
+	Description:  Linux kernel
+	Type:         Kernel Image
+	Compression:  uncompressed
+	Data Start:   0x830000d8
+	Data Size:    9676752 Bytes = 9.2 MiB
+	Architecture: RISC-V
+	OS:           Linux
+	Load Address: 0x80200000
+	Entry Point:  0x80200000
+	Verifying Hash Integrity ... OK
+	## Loading ramdisk from FIT Image at 83000000 ...
+	Using 'config-1' configuration
+	Trying 'ramdisk at 1' ramdisk subimage
+	Description:  ramdisk
+	Type:         RAMDisk Image
+	Compression:  gzip compressed
+	Data Start:   0x8393c490
+	Data Size:    4568674 Bytes = 4.4 MiB
+	Architecture: RISC-V
+	OS:           Linux
+	Load Address: 0x82000000
+	Entry Point:  unavailable
+	Verifying Hash Integrity ... OK
+	Loading ramdisk from 0x8393c490 to 0x82000000
+	WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its file!
+	## Loading fdt from FIT Image at 83000000 ...
+	Using 'config-1' configuration
+	Trying 'fdt at 1' fdt subimage
+	Description:  unavailable
+	Type:         Flat Device Tree
+	Compression:  uncompressed
+	Data Start:   0x8393a934
+	Data Size:    6889 Bytes = 6.7 KiB
+	Architecture: RISC-V
+	Verifying Hash Integrity ... OK
+	Booting using the fdt blob at 0x8393a934
+	Loading Kernel Image
+	Using Device Tree in place at 000000008393a934, end 000000008393f41c
+
+	Starting kernel ...
+
+	[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
+	[    0.000000] Linux version 5.6.0-rc3-00026-g63623fd44972 (pragneshp at sachinj2-OptiPlex-7010) (gcc version 9.2.0 (crosstool-NG 1.24.0.37-3f461da)) #3 SMP Tue Feb 25 14:59:12 IST 2020
+	[    0.000000] Initial ramdisk at: 0x(____ptrval____) (4568674 bytes)
+	[    0.000000] Zone ranges:
+	[    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
+	[    0.000000]   Normal   [mem 0x0000000100000000-0x000000027fffffff]
+	[    0.000000] Movable zone start for each node
+	[    0.000000] Early memory node ranges
+	[    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
+	[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000027fffffff]
+	[    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
+	[    0.000000] CPU with hartid=0 is not available
+	[    0.000000] CPU with hartid=0 is not available
+	[    0.000000] elf_hwcap is 0x112d
+	[    0.000000] percpu: Embedded 17 pages/cpu s31848 r8192 d29592 u69632
+	[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
+	[    0.000000] Kernel command line:
+	[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
+	[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
+	[    0.000000] Sorting __ex_table...
+	[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
+	[    0.000000] Memory: 8179388K/8386560K available (6288K kernel code, 458K rwdata, 2135K rodata, 239K init, 311K bss, 207172K reserved, 0K cma-reserved)
+	[    0.000000] Virtual kernel memory layout:
+	[    0.000000]       fixmap : 0xffffffcefee00000 - 0xffffffceff000000   (2048 kB)
+	[    0.000000]       pci io : 0xffffffceff000000 - 0xffffffcf00000000   (  16 MB)
+	[    0.000000]      vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff   (4095 MB)
+	[    0.000000]      vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff   (65535 MB)
+	[    0.000000]       lowmem : 0xffffffe000000000 - 0xffffffe1ffe00000   (8190 MB)
+	[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
+	[    0.000000] rcu: Hierarchical RCU implementation.
+	[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
+	[    0.000000] rcu:     RCU debug extended QS entry/exit.
+	[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
+	[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
+	[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
+	[    0.000000] plic: mapped 53 interrupts with 4 handlers for 9 contexts.
+	[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
+	[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
+	[    0.000007] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
+	[    0.000159] Console: colour dummy device 80x25
+	[    0.001130] printk: console [tty0] enabled
+	[    0.001193] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=4000)
+	[    0.001259] pid_max: default: 32768 minimum: 301
+	[    0.001798] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
+	[    0.002191] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
+	[    0.004308] rcu: Hierarchical SRCU implementation.
+	[    0.004981] smp: Bringing up secondary CPUs ...
+	[    1.024833] CPU1: failed to come online
+	[    2.049612] CPU2: failed to come online
+	[    3.074387] CPU3: failed to come online
+	[    3.074453] smp: Brought up 1 node, 1 CPU
+	[    3.075612] devtmpfs: initialized
+	[    3.077517] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x15e with crng_init=0
+	[    3.077774] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
+	[    3.077899] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
+	[    3.078689] NET: Registered protocol family 16
+	[    3.094523] vgaarb: loaded
+	[    3.094914] SCSI subsystem initialized
+	[    3.095364] usbcore: registered new interface driver usbfs
+	[    3.095444] usbcore: registered new interface driver hub
+	[    3.095533] usbcore: registered new device driver usb
+	[    3.096290] clocksource: Switched to clocksource riscv_clocksource
+	[    3.103494] NET: Registered protocol family 2
+	[    3.104158] tcp_listen_portaddr_hash hash table entries: 4096 (order: 5, 163840 bytes, linear)
+	[    3.104806] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
+	[    3.106882] TCP bind hash table entries: 65536 (order: 9, 2097152 bytes, linear)
+	[    3.114045] TCP: Hash tables configured (established 65536 bind 65536)
+	[    3.114589] UDP hash table entries: 4096 (order: 6, 393216 bytes, linear)
+	[    3.115949] UDP-Lite hash table entries: 4096 (order: 6, 393216 bytes, linear)
+	[    3.117578] NET: Registered protocol family 1
+	[    3.118255] RPC: Registered named UNIX socket transport module.
+	[    3.118295] RPC: Registered udp transport module.
+	[    3.118328] RPC: Registered tcp transport module.
+	[    3.118360] RPC: Registered tcp NFSv4.1 backchannel transport module.
+	[    3.118397] PCI: CLS 0 bytes, default 64
+	[    3.118621] Unpacking initramfs...
+	[    3.475555] Freeing initrd memory: 4460K
+	[    3.476511] workingset: timestamp_bits=62 max_order=21 bucket_order=0
+	[    3.485899] NFS: Registering the id_resolver key type
+	[    3.485961] Key type id_resolver registered
+	[    3.485994] Key type id_legacy registered
+	[    3.486037] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
+	[    3.486236] 9p: Installing v9fs 9p2000 file system support
+	[    3.486651] NET: Registered protocol family 38
+	[    3.486729] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
+	[    3.486788] io scheduler mq-deadline registered
+	[    3.486822] io scheduler kyber registered
+	[    3.528973] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
+	[    3.530114] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 1, base_baud = 0) is a SiFive UART v0
+	[    4.061558] printk: console [ttySIF0] enabled
+	[    4.066211] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 10, base_baud = 0) is a SiFive UART v0
+	[    4.075620] [drm] radeon kernel modesetting enabled.
+	[    4.092998] loop: module loaded
+	[    4.096007] sifive_spi 10040000.spi: mapped; irq=12, cs=1
+	[    4.101380] sifive_spi 10050000.spi: mapped; irq=13, cs=1
+	[    4.107129] libphy: Fixed MDIO Bus: probed
+	[    4.111232] macb 10090000.ethernet: Registered clk switch 'sifive-gemgxl-mgmt'
+	[    4.117841] macb 10090000.ethernet: GEM doesn't support hardware ptp.
+	[    4.124654] libphy: MACB_mii_bus: probed
+	[    4.133149] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109 at 0x10090000 irq 14 (86:5d:6f:58:d6:3d)
+	[    4.142400] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
+	[    4.148053] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
+	[    4.154051] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+	[    4.160470] ehci-pci: EHCI PCI platform driver
+	[    4.164930] ehci-platform: EHCI generic platform driver
+	[    4.170185] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
+	[    4.176284] ohci-pci: OHCI PCI platform driver
+	[    4.180736] ohci-platform: OHCI generic platform driver
+	[    4.186226] usbcore: registered new interface driver uas
+	[    4.191257] usbcore: registered new interface driver usb-storage
+	[    4.197392] mousedev: PS/2 mouse device common for all mice
+	[    4.228311] mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff, cd polling
+	[    4.235528] usbcore: registered new interface driver usbhid
+	[    4.240870] usbhid: USB HID core driver
+	[    4.245515] NET: Registered protocol family 10
+	[    4.250603] Segment Routing with IPv6
+	[    4.253602] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
+	[    4.259978] NET: Registered protocol family 17
+	[    4.264098] 9pnet: Installing 9P2000 support
+	[    4.268159] Key type dns_resolver registered
+	[    4.279265] Freeing unused kernel memory: 236K
+	[    4.282989] This architecture does not have kernel memory protection.
+	[    4.289390] Run /init as init process
+	Starting syslogd: OK
+	Starting klogd: OK
+	Starting mdev...
+	/etc/init.d/S10mdev: line 9: can't create /proc/sys/kernel/hotplug: nonexistent directory
+	[    4.354461] mmc0: host does not support reading read-only switch, assuming write-enable
+	[    4.361778] mmc0: new SDHC card on SPI
+	[    4.381184] mmcblk0: mmc0:0000 SC16G 14.8 GiB
+	[    4.424975]  mmcblk0: p1 p2 p3
+	modprobe: can't change directory to '/lib/modules': No such file or directory
+	Initializing random number generator... [    5.041362] random: dd: uninitialized urandom read (512 bytes read)
+	done.
+	Starting network: [    5.240580] macb 10090000.ethernet eth0: PHY [10090000.ethernet-ffffffff:00] driver [Microsemi VSC8541 SyncE] (irq=POLL)
+	[    5.250752] macb 10090000.ethernet eth0: configuring for phy/gmii link mode
+	udhcpc: started, v1.29.3
+	udhcpc: sending discover
+	[    7.301682] macb 10090000.ethernet eth0: Link is Up - 100Mbps/Full - flow control tx
+	[    7.308726] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
+	udhcpc: sending discover
+	udhcpc: sending discover
+	udhcpc: no lease, failing
+	FAIL
+	Starting dropbear sshd: [   14.309152] random: dropbear: uninitialized urandom read (32 bytes read)
+	OK
+
+	Welcome to Buildroot
+	buildroot login: root
+	Password:
+	#
-- 
2.17.1



More information about the U-Boot mailing list