1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
FU540-C000 RISC-V SoC
=====================
The FU540-C000 is the world’s first 4+1 64-bit RISC‑V SoC from SiFive.
The HiFive Unleashed development platform is based on FU540-C000 and capable
of running Linux.
Mainline support
================
The support for following drivers are already enabled:
1. SiFive UART Driver.
2. SiFive PRCI Driver for clock.
3. Cadence MACB ethernet driver for networking support.
TODO:
1. U-Boot expects the serial console device entry to be present under /chosen
DT node. Example:
chosen {
stdout-path = "/soc/serial@10010000:115200";
};
Without a serial console U-Boot will panic.
Building
========
1. Add the RISC-V toolchain to your PATH.
2. Setup ARCH & cross compilation enviornment variable.
a. export ARCH=riscv
b. export CROSS_COMPILE=<riscv64 toolchain prefix>
3. make sifive_fu540_defconfig
4. make
Flashing
========
The current U-Boot port is supported in S-mode only and loaded directly
into 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:
make PLATFORM=sifive/fu540 FW_PAYLOAD_PATH=<path to u-boot.bin> FW_PAYLOAD_FDT_PATH=<path to hifive-unleashed-a00.dtb from Linux>
(Note: Prefer hifive-unleashed-a00.dtb from Linux-5.3 or higher)
(Note: Linux-5.2 is also fine but it does not have ethernet DT node)
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)
Once the prior stage firmware/bootloader binary is generated, it should be
copied to the first partition of the sdcard.
sudo dd if=<prior_stage_firmware_binary> of=/dev/disk2s1 bs=1024
Booting
=======
Once you plugin the sdcard and power up, you should see the U-Boot prompt.
Sample boot log from HiFive Unleashed board
===========================================
U-Boot 2019.07-rc4-00013-g1837f893b0 (Jun 20 2019 - 11:08:48 +0530)
CPU: rv64imafdc
Model: SiFive HiFive Unleashed A00
DRAM: 8 GiB
In: serial@10010000
Out: serial@10010000
Err: serial@10010000
Net: eth0: ethernet@10090000
Hit any key to stop autoboot: 0
=> version
U-Boot 2019.07-rc4-00013-g1837f893b0 (Jun 20 2019 - 11:08:48 +0530)
riscv64-linux-gcc.br_real (Buildroot 2018.11-rc2-00003-ga0787e9) 8.2.0
GNU ld (GNU Binutils) 2.31.1
=>
===============================================================================
Now you can configure your networking, tftp server and use tftp boot method to
load uImage.
==========================================================================
=> setenv ipaddr 10.206.5.241
=> setenv netmask 255.255.252.0
=> setenv serverip 10.206.4.143
=> setenv gateway 10.206.4.1
=> tftpboot ${kernel_addr_r} /sifive/fu540/uImage
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 1000Mbps full-duplex (lpa: 0x7c00)
Using ethernet@10090000 device
TFTP from server 10.206.4.143; our IP address is 10.206.5.241
Filename '/sifive/fu540/uImage'.
Load address: 0x80600000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########################################
1.5 MiB/s
done
Bytes transferred = 9162364 (8bce7c hex)
=> tftpboot ${ramdisk_addr_r} /sifive/fu540/uRamdisk
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
ethernet@10090000: Autonegotiation complete
ethernet@10090000: link up, 1000Mbps full-duplex (lpa: 0x7c00)
Using ethernet@10090000 device
TFTP from server 10.206.4.143; our IP address is 10.206.5.241
Filename '/sifive/fu540/uRamdisk'.
Load address: 0x82500000
Loading: #################################################################
#################################################################
##################################
448.2 KiB/s
done
Bytes transferred = 2398272 (249840 hex)
=> setenv bootargs "root=/dev/ram rw console=ttySIF0 earlycon=sbi"
=> bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdtcontroladdr}
## Booting kernel from Legacy Image at 80600000 ...
Image Name: Linux
Image Type: RISC-V Linux Kernel Image (uncompressed)
Data Size: 9162300 Bytes = 8.7 MiB
Load Address: 80200000
Entry Point: 80200000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 82500000 ...
Image Name: Linux RootFS
Image Type: RISC-V Linux RAMDisk Image (uncompressed)
Data Size: 2398208 Bytes = 2.3 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at ff795730
Booting using the fdt blob at 0xff795730
Loading Kernel Image ... OK
Using Device Tree in place at 00000000ff795730, end 00000000ff799dac
Starting kernel ...
[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[ 0.000000] Linux version 5.2.0-rc1-00003-gb9543e66e700 (anup@anup-lab-machine) (gcc version 8.2.0 (Buildroot 2018.11-rc2-00003-ga0787e9)) #1 SMP Thu Jun 20 11:41:26 IST 2019
[ 0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[ 0.000000] printk: bootconsole [sbi0] enabled
[ 0.000000] Initial ramdisk at: 0x(____ptrval____) (2398208 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 0xfb795000-0xff795000] (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 s29592 r8192 d31848 u69632
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 2067975
[ 0.000000] Kernel command line: root=/dev/ram rw console=ttySIF0 earlycon=sbi
[ 0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[ 0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
[ 0.000000] Sorting __ex_table...
[ 0.000000] Memory: 8182056K/8386560K available (5753K kernel code, 357K rwdata, 1804K rodata, 204K init, 808K bss, 204504K reserved, 0K cma-reserved)
[ 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.008553] Console: colour dummy device 80x25
[ 0.012990] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=4000)
[ 0.023103] pid_max: default: 32768 minimum: 301
[ 0.028269] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes)
[ 0.035068] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes)
[ 0.042770] *** VALIDATE proc ***
[ 0.045610] *** VALIDATE cgroup1 ***
[ 0.049157] *** VALIDATE cgroup2 ***
[ 0.053743] rcu: Hierarchical SRCU implementation.
[ 0.058297] smp: Bringing up secondary CPUs ...
[ 0.064134] smp: Brought up 1 node, 4 CPUs
[ 0.069114] devtmpfs: initialized
[ 0.073281] random: get_random_u32 called from bucket_table_alloc.isra.10+0x4e/0x160 with crng_init=0
[ 0.082157] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.091634] futex hash table entries: 1024 (order: 4, 65536 bytes)
[ 0.098480] NET: Registered protocol family 16
[ 0.114101] vgaarb: loaded
[ 0.116397] SCSI subsystem initialized
[ 0.120358] usbcore: registered new interface driver usbfs
[ 0.125541] usbcore: registered new interface driver hub
[ 0.130936] usbcore: registered new device driver usb
[ 0.136618] clocksource: Switched to clocksource riscv_clocksource
[ 0.148108] NET: Registered protocol family 2
[ 0.152358] tcp_listen_portaddr_hash hash table entries: 4096 (order: 4, 65536 bytes)
[ 0.159928] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
[ 0.169027] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
[ 0.178360] TCP: Hash tables configured (established 65536 bind 65536)
[ 0.184653] UDP hash table entries: 4096 (order: 5, 131072 bytes)
[ 0.190819] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes)
[ 0.197618] NET: Registered protocol family 1
[ 0.201892] RPC: Registered named UNIX socket transport module.
[ 0.207395] RPC: Registered udp transport module.
[ 0.212159] RPC: Registered tcp transport module.
[ 0.216940] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.223445] PCI: CLS 0 bytes, default 64
[ 0.227726] Unpacking initramfs...
[ 0.260556] Freeing initrd memory: 2336K
[ 0.264652] workingset: timestamp_bits=62 max_order=21 bucket_order=0
[ 0.278452] NFS: Registering the id_resolver key type
[ 0.282841] Key type id_resolver registered
[ 0.287067] Key type id_legacy registered
[ 0.291155] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.298299] NET: Registered protocol family 38
[ 0.302470] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
[ 0.309906] io scheduler mq-deadline registered
[ 0.314501] io scheduler kyber registered
[ 0.354134] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[ 0.360725] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 4, base_baud = 0) is a SiFive UART v0
[ 0.369191] printk: console [ttySIF0] enabled
[ 0.369191] printk: console [ttySIF0] enabled
[ 0.377938] printk: bootconsole [sbi0] disabled
[ 0.377938] printk: bootconsole [sbi0] disabled
[ 0.387298] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 1, base_baud = 0) is a SiFive UART v0
[ 0.396411] [drm] radeon kernel modesetting enabled.
[ 0.409818] loop: module loaded
[ 0.412606] libphy: Fixed MDIO Bus: probed
[ 0.416870] macb 10090000.ethernet: Registered clk switch 'sifive-gemgxl-mgmt'
[ 0.423570] macb: GEM doesn't support hardware ptp.
[ 0.428469] libphy: MACB_mii_bus: probed
[ 1.053009] Microsemi VSC8541 SyncE 10090000.ethernet-ffffffff:00: attached PHY driver [Microsemi VSC8541 SyncE] (mii_bus:phy_addr=10090000.ethernet-ffffffff:00, irq=POLL)
[ 1.067548] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109 at 0x10090000 irq 7 (70:b3:d5:92:f2:f3)
[ 1.077330] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[ 1.083069] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 1.089061] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1.095485] ehci-pci: EHCI PCI platform driver
[ 1.099947] ehci-platform: EHCI generic platform driver
[ 1.105196] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 1.111286] ohci-pci: OHCI PCI platform driver
[ 1.115742] ohci-platform: OHCI generic platform driver
[ 1.121142] usbcore: registered new interface driver uas
[ 1.126269] usbcore: registered new interface driver usb-storage
[ 1.132331] mousedev: PS/2 mouse device common for all mice
[ 1.137978] usbcore: registered new interface driver usbhid
[ 1.143325] usbhid: USB HID core driver
[ 1.148022] NET: Registered protocol family 10
[ 1.152609] Segment Routing with IPv6
[ 1.155571] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 1.161927] NET: Registered protocol family 17
[ 1.165907] Key type dns_resolver registered
[ 1.171694] Freeing unused kernel memory: 204K
[ 1.175375] This architecture does not have kernel memory protection.
[ 1.181792] Run /init as init process
_ _
| ||_|
| | _ ____ _ _ _ _
| || | _ \| | | |\ \/ /
| || | | | | |_| |/ \
|_||_|_| |_|\____|\_/\_/
Busybox Rootfs
Please press Enter to activate this console.
/ #
|