@@ -363,3 +363,379 @@ load uImage.
Please press Enter to activate this console.
/ #
+
+
+How to build U-Boot SPL
+-----------------------
+
+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
+
+
+How to build U-Boot SPL booting from MMC
+----------------------------------------
+
+With sifive_fu540_spl_defconfig:
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation enviornment variable:
+
+.. code-block:: none
+
+ export ARCH=riscv
+ export CROSS_COMPILE=<riscv64 toolchain prefix>
+
+3. make sifive_fu540_spl_defconfig
+4. make
+
+
+Flashing
+--------
+
+ZSBL loads the U-boot SPL(u-boot-spl.bin) from a partition with
+GUID type 2e54b353-1271-4842-806f-e436d6af6985
+
+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)
+
+.. code-block:: none
+
+ sudo dd if=spl/u-boot-spl.bin of=/dev/disk2s4 bs=1024
+ sudo dd if=u-boot.itb of=/dev/disk2s1 bs=1024
+
+
+Running U-Boot SPL
+------------------
+
+Once you plugin the sdcard and power up, you should see the U-Boot prompt.
+
+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.01-00176-g095f705725-dirty (Jan 22 2020 - 12:53:16 +0530)
+ Trying to boot from MMC1
+
+
+ U-Boot 2020.01-00176-g095f705725-dirty (Jan 22 2020 - 12:53:16 +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 - ce:dc:0d:a4:e4:76
+ eth0: ethernet at 10090000
+ Hit any key to stop autoboot: 0
+ => version
+ U-Boot 2020.01-00176-g095f705725-dirty (Jan 22 2020 - 12:53:16 +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: #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ ###################################
+ 945.3 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.000007] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
+ [ 0.008471] Console: colour dummy device 80x25
+ [ 0.012818] 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.044789] rcu: Hierarchical SRCU implementation.
+ [ 0.049254] smp: Bringing up secondary CPUs ...
+ [ 0.055035] smp: Brought up 1 node, 4 CPUs
+ [ 0.059670] devtmpfs: initialized
+ [ 0.063825] random: get_random_u32 called from bucket_table_alloc.isra.29+0x4e/0x160 with crng_init=0
+ [ 0.072594] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
+ [ 0.082007] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
+ [ 0.089521] NET: Registered protocol family 16
+ [ 0.105923] vgaarb: loaded
+ [ 0.108174] SCSI subsystem initialized
+ [ 0.111961] usbcore: registered new interface driver usbfs
+ [ 0.117115] usbcore: registered new interface driver hub
+ [ 0.122495] usbcore: registered new device driver usb
+ [ 0.128086] clocksource: Switched to clocksource riscv_clocksource
+ [ 0.140287] NET: Registered protocol family 2
+ [ 0.144459] tcp_listen_portaddr_hash hash table entries: 4096 (order: 4, 65536 bytes, linear)
+ [ 0.152630] TCP established hash table entries: 65536 (order: 7, 524288 bytes, linear)
+ [ 0.162249] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes, linear)
+ [ 0.172168] TCP: Hash tables configured (established 65536 bind 65536)
+ [ 0.178352] UDP hash table entries: 4096 (order: 5, 131072 bytes, linear)
+ [ 0.185149] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes, linear)
+ [ 0.192564] NET: Registered protocol family 1
+ [ 0.196791] RPC: Registered named UNIX socket transport module.
+ [ 0.202160] RPC: Registered udp transport module.
+ [ 0.206844] RPC: Registered tcp transport module.
+ [ 0.211519] RPC: Registered tcp NFSv4.1 backchannel transport module.
+ [ 0.217949] PCI: CLS 0 bytes, default 64
+ [ 0.222148] Unpacking initramfs...
+ [ 0.578819] Freeing initrd memory: 4460K
+ [ 0.582990] workingset: timestamp_bits=62 max_order=21 bucket_order=0
+ [ 0.596656] NFS: Registering the id_resolver key type
+ [ 0.600959] Key type id_resolver registered
+ [ 0.605146] Key type id_legacy registered
+ [ 0.609102] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
+ [ 0.615940] 9p: Installing v9fs 9p2000 file system support
+ [ 0.621590] NET: Registered protocol family 38
+ [ 0.625711] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
+ [ 0.633062] io scheduler mq-deadline registered
+ [ 0.637570] io scheduler kyber registered
+ [ 0.685604] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
+ [ 0.692195] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 4, base_baud = 0) is a SiFive UART v0
+ [ 0.700577] printk: console [ttySIF0] enabled
+ [ 0.700577] printk: console [ttySIF0] enabled
+ [ 0.709239] printk: bootconsole [sifive0] disabled
+ [ 0.709239] printk: bootconsole [sifive0] disabled
+ [ 0.719032] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 1, base_baud = 0) is a SiFive UART v0
+ [ 0.728378] [drm] radeon kernel modesetting enabled.
+ [ 0.745305] loop: module loaded
+ [ 0.748219] sifive_spi 10040000.spi: mapped; irq=3, cs=1
+ [ 0.753503] sifive_spi 10050000.spi: mapped; irq=5, cs=1
+ [ 0.758827] libphy: Fixed MDIO Bus: probed
+ [ 0.762901] macb 10090000.ethernet: Registered clk switch 'sifive-gemgxl-mgmt'
+ [ 0.769657] macb: GEM doesn't support hardware ptp.
+ [ 0.774546] libphy: MACB_mii_bus: probed
+ [ 0.940370] Microsemi VSC8541 SyncE 10090000.ethernet-ffffffff:00: attached PHY driver [Microsemi VSC8541 SyncE] (mii_bus:phy_addr=10090000.et)
+ [ 0.954914] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109 at 0x10090000 irq 6 (ce:dc:0d:a4:e4:76)
+ [ 0.964717] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
+ [ 0.970437] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
+ [ 0.976429] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+ [ 0.982853] ehci-pci: EHCI PCI platform driver
+ [ 0.987310] ehci-platform: EHCI generic platform driver
+ [ 0.992568] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
+ [ 0.998668] ohci-pci: OHCI PCI platform driver
+ [ 1.003113] ohci-platform: OHCI generic platform driver
+ [ 1.008577] usbcore: registered new interface driver uas
+ [ 1.013639] usbcore: registered new interface driver usb-storage
+ [ 1.019716] mousedev: PS/2 mouse device common for all mice
+ [ 1.050586] mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff, cd polling
+ [ 1.057730] usbcore: registered new interface driver usbhid
+ [ 1.063114] usbhid: USB HID core driver
+ [ 1.067825] NET: Registered protocol family 10
+ [ 1.072448] Segment Routing with IPv6
+ [ 1.075394] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
+ [ 1.081770] NET: Registered protocol family 17
+ [ 1.085893] 9pnet: Installing 9P2000 support
+ [ 1.089981] Key type dns_resolver registered
+ [ 1.096414] Freeing unused kernel memory: 208K
+ [ 1.100094] This architecture does not have kernel memory protection.
+ [ 1.106509] 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.168422] mmc0: host does not support reading read-only switch, assuming write-enable
+ [ 1.175673] mmc0: new SDHC card on SPI
+ [ 1.180707] mmcblk0: mmc0:0000 SC16G 14.8 GiB
+ [ 1.215845] mmcblk0: p1 p2 p4
+ modprobe: can't change directory to '/lib/modules': No such file or directory
+ Initializing random number generator... [ 1.655294] random: dd: uninitialized urandom read (512 bytes read)
+ done.
+ Starting network: udhcpc: started, v1.29.3
+ udhcpc: sending discover
+ [ 3.724714] macb 10090000.ethernet eth0: link up (100/Full)
+ [ 3.729531] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
+ udhcpc: sending discover
+ udhcpc: sending select for 172.16.35.100
+ udhcpc: sending select for 172.16.35.100
+ udhcpc: sending select for 172.16.35.100
+ udhcpc: lease of 172.16.35.100 obtained, lease time 28800
+ deleting routers
+ adding dns 172.16.34.150
+ adding dns 172.16.24.25
+ OK
+ Starting dropbear sshd: [ 10.289079] random: dropbear: uninitialized urandom read (32 bytes read)
+ OK
+
+ Welcome to Buildroot
+ buildroot login: root
+ Password:
+ #
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 | 376 +++++++++++++++++++++++++++++++++++++ 1 file changed, 376 insertions(+)