[PATCH v4 14/14] doc: update FU540 RISC-V documentation

Pragnesh Patel pragnesh.patel at sifive.com
Mon Feb 24 09:32:46 CET 2020


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

Signed-off-by: Pragnesh Patel <pragnesh.patel at sifive.com>
---
 doc/board/sifive/fu540.rst | 409 ++++++++++++++++++++++++++++++++++---
 1 file changed, 385 insertions(+), 24 deletions(-)

diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 3937222c6c..e5414f4eef 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -42,8 +42,60 @@ Building
    export ARCH=riscv
    export CROSS_COMPILE=<riscv64 toolchain prefix>
 
-3. make sifive_fu540_defconfig
-4. make
+User can use FSBL or u-boot-spl as a 1st stage bootloader.
+
+1) Use FSBL as a 1st stage bootloader
+
+.. code-block:: console
+
+	git clone https://github.com/sifive/freedom-u540-c000-bootloader.git
+	cd freedom-u540-c000-bootloader
+	make
+
+	cd <u-boot-dir>
+	make sifive_fu540_defconfig
+	make
+
+	git clone https://github.com/riscv/opensbi.git
+	cd opensbi
+	make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot.bin>
+
+This will generate a fw_payload.bin(build/platform/sifive/fu540/firmware/fw_payload.bin)
+
+u-boot.bin is used as a payload of the OpenSBI FW_PAYLOAD firmware.
+
+More detailed description of steps required to build FW_PAYLOAD firmware
+is beyond the scope of this document. Please refer OpenSBI documenation.
+(Note: OpenSBI git repo is at https://github.com/riscv/opensbi.git)
+
+2) Use u-boot-spl as a 1st stage bootloader
+
+Before building U-Boot SPL, OpenSBI must be build first. OpenSBI can be
+cloned and build for FU540 as below:
+
+.. code-block:: console
+
+	git clone https://github.com/riscv/opensbi.git
+	cd opensbi
+	make PLATFORM=sifive/fu540
+
+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
 --------
@@ -53,28 +105,55 @@ The current U-Boot port is supported in S-mode only and loaded from DRAM.
 A prior stage M-mode firmware/bootloader (e.g OpenSBI) is required to
 boot the u-boot.bin in S-mode and provide M-mode runtime services.
 
-Currently, the u-boot.bin is used as a payload of the OpenSBI FW_PAYLOAD
-firmware. We need to compile OpenSBI with below command:
+1) Use FSBL as a 1st stage bootloader
+
+ZSBL loads the FSBL(fsbl.bin) from a partition with GUID type
+5B193300-FC78-40CD-8002-E86C45580B47
+
+FSBL loads the fw_payload.bin from a partition with GUID type
+2E54B353-1271-4842-806F-E436D6AF6985
+
+Once the prior stage firmware/bootloader binary is generated, it should be
+copied to the first partition of the sdcard.
 
 .. code-block:: none
 
-make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot-dtb.bin>
+     sudo dd if=fsbl.bin of=/dev/disk2s4 bs=1024
+     sudo dd if=fw_payload.bin of=/dev/disk2s1 bs=1024
 
-More detailed description of steps required to build FW_PAYLOAD firmware
-is beyond the scope of this document. Please refer OpenSBI documenation.
-(Note: OpenSBI git repo is at https://github.com/riscv/opensbi.git)
+Assuming that /dev/disk2s4 partition is of GUID type
+5B193300-FC78-40CD-8002-E86C45580B47 and /dev/disk2s1 partition
+is of GUID type 2E54B353-1271-4842-806F-E436D6AF6985
+
+2) Use u-boot-spl as a 1st stage bootloader
+
+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 1st partition(/dev/sdc1)
+of SD card irrespective of GUID
+
+FIT image(u-boot.itb) is a combination of fw_dynamic.bin, u-boot-nodtb.bin and
+device tree blob(hifive-unleashed-a00.dtb)
 
 Once the prior stage firmware/bootloader binary is generated, it should be
 copied to the first partition of the sdcard.
 
 .. code-block:: none
 
-    sudo dd if=<prior_stage_firmware_binary> of=/dev/disk2s1 bs=1024
+    sudo dd if=spl/u-boot-spl.bin of=/dev/disk2s4 bs=1024
+    sudo dd if=u-boot.itb of=/dev/disk2s1 bs=1024
+
+Assuming that /dev/disk2s4 partition is of GUID type
+5B193300-FC78-40CD-8002-E86C45580B47 and /dev/disk2s1 is of
+any GUID type raw partition.
 
 Booting
 -------
 Once you plugin the sdcard and power up, you should see the U-Boot prompt.
 
+1) Use FSBL as a 1st stage bootloader
+
 Sample boot log from HiFive Unleashed board
 -------------------------------------------
 
@@ -145,19 +224,6 @@ load uImage.
    Filename '/sifive/fu540/Image'.
    Load address: 0x84000000
    Loading: #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
-            #################################################################
             #################################################################
             #################################################################
             #################################################################
@@ -184,8 +250,6 @@ load uImage.
    Filename '/sifive/fu540/uRamdisk'.
    Load address: 0x88300000
    Loading: #################################################################
-            #################################################################
-            #################################################################
             #################################################################
             #################################################################
             #################################################################
@@ -363,3 +427,300 @@ load uImage.
 
    Please press Enter to activate this console.
    / #
+
+
+2) Use u-boot-spl as a 1st stage bootloader
+
+The U-Boot SPL will boot in M mode and load the FIT image which include
+OpenSBI and U-Boot proper images. After loading progress, it will jump
+to OpenSBI first and then U-Boot proper which will run in S mode.
+
+Sample boot log from HiFive Unleashed board
+-------------------------------------------
+
+.. code-block:: none
+
+   U-Boot SPL 2020.04-rc1-00212-g375b0a2dad-dirty (Feb 13 2020 - 17:45:44 +0530)
+   Trying to boot from MMC1
+
+
+   U-Boot 2020.04-rc1-00212-g375b0a2dad-dirty (Feb 13 2020 - 17:45:44 +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 - 92:79:17:2d:7b:b7
+   eth0: ethernet at 10090000
+   Hit any key to stop autoboot:  0
+   => version
+   U-Boot 2020.04-rc1-00212-g375b0a2dad-dirty (Feb 13 2020 - 17:45:44 +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     0x00000800      0x000107ff      "SiFive bare-metal (or stage 2 loader"
+   attrs:  0x0000000000000000
+   type:   2e54b353-1271-4842-806f-e436d6af6985
+   guid:   3c9eabe1-b16b-4a2e-9b4e-f065c740bb86
+   2     0x00040800      0x00ecdfde      "Linux filesystem"
+   attrs:  0x0000000000000000
+   type:   0fc63daf-8483-4772-8e79-3d69d8477de4
+   guid:   ad9309ff-d204-42f0-9f99-f3275a83f565
+
+Now you can configure your networking, tftp server and use tftp boot method to
+load uImage.
+
+.. code-block:: none
+
+   => setenv serverip 172.16.35.74
+   => setenv ipaddr 172.16.35.40
+   => 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: 0x41e1)
+   Using ethernet at 10090000 device
+   TFTP from server 172.16.35.74; our IP address is 172.16.35.40
+   Filename 'fit.itb'.
+   Load address: 0x83000000
+   Loading: #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   #################################################################
+   ################################################################
+   ###################################
+   878.9 KiB/s
+   done
+   Bytes transferred = 13823823 (d2ef4f 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:    9247260 Bytes = 8.8 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:   0x838d3378
+   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 0x838d3378 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:   0x838d1b80
+   Data Size:    6023 Bytes = 5.9 KiB
+   Architecture: RISC-V
+   Verifying Hash Integrity ... OK
+   Booting using the fdt blob at 0x838d1b80
+   Loading Kernel Image
+   Using Device Tree in place at 00000000838d1b80, end 00000000838d6306
+
+   Starting kernel ...
+
+   [    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
+   [    0.000000] Linux version 5.3.0-13236-g97f9a3c4eee5 (pragneshp at sachinj2-OptiPlex-7010) (gcc version 8.2.0 (Buildroot 2018.11-rc2-00003-ga0787e9
+   [    0.000000] earlycon: sifive0 at MMIO 0x0000000010010000 (options '')
+   [    0.000000] printk: bootconsole [sifive0] enabled
+   [    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 s30680 r8192 d30760 u69632
+   [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
+   [    0.000000] Kernel command line: earlycon=sifive,0x10010000 console=ttySIF0,115200
+   [    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: 8179828K/8386560K available (6081K kernel code, 388K rwdata, 2025K rodata, 209K init, 307K bss, 206732K reserved, 0K cma-r)
+   [    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 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 [2]
+   [    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
+   [    0.000006] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
+   [    0.008467] Console: colour dummy device 80x25
+   [    0.012819] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=4000)
+   [    0.022844] pid_max: default: 32768 minimum: 301
+   [    0.027915] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
+   [    0.035332] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
+   [    0.044791] rcu: Hierarchical SRCU implementation.
+   [    0.049255] smp: Bringing up secondary CPUs ...
+   [    0.055034] smp: Brought up 1 node, 4 CPUs
+   [    0.059664] devtmpfs: initialized
+   [    0.063818] random: get_random_u32 called from bucket_table_alloc.isra.29+0x4e/0x160 with crng_init=0
+   [    0.072588] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
+   [    0.082000] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
+   [    0.089513] NET: Registered protocol family 16
+   [    0.105911] vgaarb: loaded
+   [    0.108166] SCSI subsystem initialized
+   [    0.111946] usbcore: registered new interface driver usbfs
+   [    0.117105] usbcore: registered new interface driver hub
+   [    0.122486] usbcore: registered new device driver usb
+   [    0.128073] clocksource: Switched to clocksource riscv_clocksource
+   [    0.140277] NET: Registered protocol family 2
+   [    0.144449] tcp_listen_portaddr_hash hash table entries: 4096 (order: 4, 65536 bytes, linear)
+   [    0.152620] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
+   [    0.162238] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes, linear)
+   [    0.172159] TCP: Hash tables configured (established 65536 bind 65536)
+   [    0.178343] UDP hash table entries: 4096 (order: 5, 131072 bytes, linear)
+   [    0.185140] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes, linear)
+   [    0.192553] NET: Registered protocol family 1
+   [    0.196752] RPC: Registered named UNIX socket transport module.
+   [    0.202145] RPC: Registered udp transport module.
+   [    0.206828] RPC: Registered tcp transport module.
+   [    0.211512] RPC: Registered tcp NFSv4.1 backchannel transport module.
+   [    0.217939] PCI: CLS 0 bytes, default 64
+   [    0.222139] Unpacking initramfs...
+   [    0.578803] Freeing initrd memory: 4460K
+   [    0.582972] workingset: timestamp_bits=62 max_order=21 bucket_order=0
+   [    0.596643] NFS: Registering the id_resolver key type
+   [    0.600950] Key type id_resolver registered
+   [    0.605134] Key type id_legacy registered
+   [    0.609090] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
+   [    0.615928] 9p: Installing v9fs 9p2000 file system support
+   [    0.621581] NET: Registered protocol family 38
+   [    0.625700] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
+   [    0.633051] io scheduler mq-deadline registered
+   [    0.637559] io scheduler kyber registered
+   [    0.685592] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
+   [    0.692184] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 4, base_baud = 0) is a SiFive UART v0
+   [    0.700566] printk: console [ttySIF0] enabled
+   [    0.700566] printk: console [ttySIF0] enabled
+   [    0.709228] printk: bootconsole [sifive0] disabled
+   [    0.709228] printk: bootconsole [sifive0] disabled
+   [    0.719030] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 1, base_baud = 0) is a SiFive UART v0
+   [    0.728364] [drm] radeon kernel modesetting enabled.
+   [    0.745292] loop: module loaded
+   [    0.748208] sifive_spi 10040000.spi: mapped; irq=3, cs=1
+   [    0.753490] sifive_spi 10050000.spi: mapped; irq=5, cs=1
+   [    0.758811] libphy: Fixed MDIO Bus: probed
+   [    0.762886] macb 10090000.ethernet: Registered clk switch 'sifive-gemgxl-mgmt'
+   [    0.769643] macb: GEM doesn't support hardware ptp.
+   [    0.774532] libphy: MACB_mii_bus: probed
+   [    0.940349] Microsemi VSC8541 SyncE 10090000.ethernet-ffffffff:00: attached PHY driver [Microsemi VSC8541 SyncE] (mii_bus:phy_addr=10090000.et)
+   [    0.954893] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109 at 0x10090000 irq 6 (92:79:17:2d:7b:b7)
+   [    0.964698] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
+   [    0.970417] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
+   [    0.976410] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+   [    0.982832] ehci-pci: EHCI PCI platform driver
+   [    0.987288] ehci-platform: EHCI generic platform driver
+   [    0.992547] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
+   [    0.998646] ohci-pci: OHCI PCI platform driver
+   [    1.003092] ohci-platform: OHCI generic platform driver
+   [    1.008557] usbcore: registered new interface driver uas
+   [    1.013621] usbcore: registered new interface driver usb-storage
+   [    1.019695] mousedev: PS/2 mouse device common for all mice
+   [    1.050569] mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff, cd polling
+   [    1.057714] usbcore: registered new interface driver usbhid
+   [    1.063098] usbhid: USB HID core driver
+   [    1.067805] NET: Registered protocol family 10
+   [    1.072421] Segment Routing with IPv6
+   [    1.075367] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
+   [    1.081745] NET: Registered protocol family 17
+   [    1.085867] 9pnet: Installing 9P2000 support
+   [    1.089951] Key type dns_resolver registered
+   [    1.096367] Freeing unused kernel memory: 208K
+   [    1.100023] This architecture does not have kernel memory protection.
+   [    1.106468] 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
+   [    1.167972] mmc0: host does not support reading read-only switch, assuming write-enable
+   [    1.175224] mmc0: new SDHC card on SPI
+   [    1.180428] mmcblk0: mmc0:0000 SC16G 14.8 GiB
+   [    1.214935]  mmcblk0: p1 p2 p4
+   modprobe: can't change directory to '/lib/modules': No such file or directory
+   Initializing random number generator... [    1.664435] random: dd: uninitialized urandom read (512 bytes read)
+   done.
+   Starting network: udhcpc: started, v1.29.3
+   udhcpc: sending discover
+   [    3.756700] macb 10090000.ethernet eth0: link up (100/Full)
+   [    3.761515] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
+   udhcpc: sending discover
+   udhcpc: sending select for 172.16.35.4
+   udhcpc: lease of 172.16.35.4 obtained, lease time 3600
+   deleting routers
+   adding dns 172.16.34.75
+   adding dns 172.16.24.25
+   OK
+   Starting dropbear sshd: [    4.893179] 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