Re: [U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-13 Thread Kevin Hilman
Atish Patra  writes:

>> On Feb 12, 2019, at 4:18 PM, Kevin Hilman  wrote:
>> 
>> Anup Patel  writes:
>> 
>>> From: Atish Patra 
>>> 
>>> The readme guide describes the procedure to build, flash and boot Linux
>>> using U-Boot on HiFive Unleashed. It also explains the current state of
>>> U-boot support and future action items.
>>> 
>>> Signed-off-by: Atish Patra 
>>> Signed-off-by: Anup Patel 
>>> Reviewed-by: Lukas Auer 
>> 
>> I'm testing this with the mainline kernel (v5.0-rc6) and running into
>> some problems getting kernel output on the serial console.
>> 
>
> Unfortunately. 
>

[...]

>> First question: this doc doesn't explain how there is a DT at
>> 0x8220, and what it contains.
>> 
>
> DT is being passed from the previous stage boot loader to OpenSBI and OpenSBI 
> passed it to U-Boot
> after modifying few entries (hart masks and plic entries).
>
> There is a way to provide custom DT in OpenSBI as well.

And if u-boot were load (or TFTP) a custom DT, this should work too,
right?

>> Trying this with a freshly build u-boot payload with OpenSBI, bootm
>> seems to detect a DT there, but I don't understand how it got there, or
>> what it is in it.
>> 
>> Looking a little closer, it appears that this DT (and the address) is
>> hard-coded in the OpenSBI code.  This should proably be documented here
>> for clarity sake.
>> 
>
> I will update the document to add more clarity.

Thanks.

>>> +## Booting kernel from Legacy Image at 8020 ...
>>> +   Image Name:   Linux
>>> +   Image Type:   RISC-V Linux Kernel Image (uncompressed)
>>> +   Data Size:14939068 Bytes = 14.2 MiB
>>> +   Load Address: 8020
>>> +   Entry Point:  8020
>>> +   Verifying Checksum ... OK
>>> +## Flattened Device Tree blob at 8220
>>> +   Booting using the fdt blob at 0x8220
>>> +   Loading Kernel Image ... OK
>>> +   Using Device Tree in place at 8220, end 82205c69
>>> +
>>> +Starting kernel ...
>> 
>> Next, I'm able to DHCP and TFTP my uImage just like above, but I don't
>> see any output on the console after the "Starting kernel".
>> 
>> That suggests that whatever DT is present there doesn't have the right
>> settings for the serial console.
>> 
>> I tried setting the u-boot bootargs to "console=ttySIF0 earlyprintk",
>> but I'm still seeing nothing on the console.
>> 
>> Dumping the hard-coded OpenSBI DT from u-boot[1], it seem that the
>> chosen node has the right value (as documented in this patch):
>> 
>> Hmm, maybe I'm missing the obvious... is there even an upstream serial
>> driver for this UART in v5.0-rc6...  (/me goes searching for the
>> compatible)... hmm, doesn't look like it.
>> 
>
> Unfortunately, all the drivers for unleashed are not upstreamed yet. It is a 
> mess and hopefully it will be resolved soon.
>
>>> +[0.00] OF: fdt: Ignoring memory range 0x8000 - 0x8020
>>> +[0.00] Linux version 5.0.0-rc1-00020-g4b51f736 (atish@jedi-01) 
>>> (gcc version 7.2.0 (GCC)) #262 SMP Mon Jan 21 17:39:27 PST 2019
>> 
>> Looks like you're testing with a handful of out-of-tree kernel patches.
>> Can you give a pointer to where you're building your kernel from?
>> 
>
> Here is my branch based on 5.0-rc5 that should work.

Yes, building a kernel from there, using the config options you
mentioned works.  Thanks.

> https://github.com/atishp04/linux/  v5.0-rc5_unleashed_uboot
>
> 1-8 patches are mostly SMP fixes and currently under review. They should be 
> part of next merge window.
> --
> 1. 4a0edc9b RISC-V: Assign hwcap as per comman capabilities.
> 2. c29e4afa irqchip/irq-sifive-plic: Check and continue in case of an invalid 
> cpuid.
> 3. 6c191098 clocksource/drivers/riscv: Add required checks during clock 
> source init
> 4. d89bfcf6 RISC-V: Compare cpuid with NR_CPUS before mapping.
> 5. 474cb3e3 RISC-V: Allow hartid-to-cpuid function to fail.
> 6. 5e07a2f4 RISC-V: Remove NR_CPUs check during hartid search from DT
> 7. cf5f2ec6 RISC-V: Move cpuid to hartid mapping to SMP.
> 8. 7838fe36 RISC-V: Do not wait indefinitely in __cpu_up
> --
>
> The real mess is the following driver patches for unleashed board. 
>
> 9. d46dc16f spi: sifive: no dma hack
> 10. e8ea1346 spi: add driver for the SiFive SPI controller
> 11. 120d5658 pcie-microsemi: added support for the Vera-board root complex
> 12. afb97b09 RISC-V: Networking fix Hack
> 13. 4ca6e585 pwm-sifive: add a driver for SiFive SoC PWM
> 14. ddb4b49e gpio-sifive: support GPIO on SiFive SoCs
> 15. f8859c7d u54-prci: driver for core U54 clocks
> 16. 27b6fd77 u54-prci: driver for core U54 clocks
> 17. dcd33855 gemgxl-mgmt: implement clock switch for GEM tx_clk
> 18. b25bb020 tty: serial: add driver for the SiFive UART
> 19. fd6f363f dt-bindings: serial: add documentation for the SiFive UART driver
>
> Please make sure following configs are enabl

Re: [U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-13 Thread Atish Patra

On 2/13/19 1:52 AM, Auer, Lukas wrote:

On Wed, 2019-02-13 at 01:31 +, Atish Patra wrote:

On Feb 12, 2019, at 4:18 PM, Kevin Hilman 
wrote:

Anup Patel  writes:


From: Atish Patra 

The readme guide describes the procedure to build, flash and boot
Linux
using U-Boot on HiFive Unleashed. It also explains the current
state of
U-boot support and future action items.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Lukas Auer 


I'm testing this with the mainline kernel (v5.0-rc6) and running
into
some problems getting kernel output on the serial console.



Unfortunately.


[...]


+=> setenv ethaddr 70:B3:D5:92:F0:C2
+=> setenv ipaddr 10.196.157.189
+=> setenv serverip 10.11.143.218
+=> setenv gatewayip 10.196.156.1
+=> setenv netmask 255.255.252.0
+=> bdinfo
+boot_params = 0x
+DRAM bank   = 0x
+-> start= 0x8000
+-> size = 0x0002
+relocaddr   = 0xfff9
+reloc off   = 0x7fd9
+ethaddr = 70:B3:D5:92:F0:C2
+IP addr = 10.196.157.189
+baudrate= 115200 bps
+=> tftpboot uImage
+ethernet@1009: PHY present at 0
+ethernet@1009: Starting autonegotiation...
+ethernet@1009: Autonegotiation complete
+ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
+Using ethernet@1009 device
+TFTP from server 10.11.143.218; our IP address is
10.196.157.189; sending through gateway 10.196.156.1
+Filename 'uImage'.
+Load address: 0x8020
+Loading:
#
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
##
+ ###
###
+ 2.5 MiB/s
+done
+Bytes transferred = 14939132 (e

Re: [U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-13 Thread Auer, Lukas
On Wed, 2019-02-13 at 01:31 +, Atish Patra wrote:
> > On Feb 12, 2019, at 4:18 PM, Kevin Hilman 
> > wrote:
> > 
> > Anup Patel  writes:
> > 
> > > From: Atish Patra 
> > > 
> > > The readme guide describes the procedure to build, flash and boot
> > > Linux
> > > using U-Boot on HiFive Unleashed. It also explains the current
> > > state of
> > > U-boot support and future action items.
> > > 
> > > Signed-off-by: Atish Patra 
> > > Signed-off-by: Anup Patel 
> > > Reviewed-by: Lukas Auer 
> > 
> > I'm testing this with the mainline kernel (v5.0-rc6) and running
> > into
> > some problems getting kernel output on the serial console.
> > 
> 
> Unfortunately. 
> 
> > [...]
> > 
> > > +=> setenv ethaddr 70:B3:D5:92:F0:C2
> > > +=> setenv ipaddr 10.196.157.189
> > > +=> setenv serverip 10.11.143.218
> > > +=> setenv gatewayip 10.196.156.1
> > > +=> setenv netmask 255.255.252.0
> > > +=> bdinfo
> > > +boot_params = 0x
> > > +DRAM bank   = 0x
> > > +-> start= 0x8000
> > > +-> size = 0x0002
> > > +relocaddr   = 0xfff9
> > > +reloc off   = 0x7fd9
> > > +ethaddr = 70:B3:D5:92:F0:C2
> > > +IP addr = 10.196.157.189
> > > +baudrate= 115200 bps
> > > +=> tftpboot uImage
> > > +ethernet@1009: PHY present at 0
> > > +ethernet@1009: Starting autonegotiation...
> > > +ethernet@1009: Autonegotiation complete
> > > +ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
> > > +Using ethernet@1009 device
> > > +TFTP from server 10.11.143.218; our IP address is
> > > 10.196.157.189; sending through gateway 10.196.156.1
> > > +Filename 'uImage'.
> > > +Load address: 0x8020
> > > +Loading:
> > > #
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##
> > > + ###
> > > ##

Re: [U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-12 Thread Atish Patra


> On Feb 12, 2019, at 4:18 PM, Kevin Hilman  wrote:
> 
> Anup Patel  writes:
> 
>> From: Atish Patra 
>> 
>> The readme guide describes the procedure to build, flash and boot Linux
>> using U-Boot on HiFive Unleashed. It also explains the current state of
>> U-boot support and future action items.
>> 
>> Signed-off-by: Atish Patra 
>> Signed-off-by: Anup Patel 
>> Reviewed-by: Lukas Auer 
> 
> I'm testing this with the mainline kernel (v5.0-rc6) and running into
> some problems getting kernel output on the serial console.
> 

Unfortunately. 

> [...]
> 
>> +=> setenv ethaddr 70:B3:D5:92:F0:C2
>> +=> setenv ipaddr 10.196.157.189
>> +=> setenv serverip 10.11.143.218
>> +=> setenv gatewayip 10.196.156.1
>> +=> setenv netmask 255.255.252.0
>> +=> bdinfo
>> +boot_params = 0x
>> +DRAM bank   = 0x
>> +-> start= 0x8000
>> +-> size = 0x0002
>> +relocaddr   = 0xfff9
>> +reloc off   = 0x7fd9
>> +ethaddr = 70:B3:D5:92:F0:C2
>> +IP addr = 10.196.157.189
>> +baudrate= 115200 bps
>> +=> tftpboot uImage
>> +ethernet@1009: PHY present at 0
>> +ethernet@1009: Starting autonegotiation...
>> +ethernet@1009: Autonegotiation complete
>> +ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
>> +Using ethernet@1009 device
>> +TFTP from server 10.11.143.218; our IP address is 10.196.157.189; sending 
>> through gateway 10.196.156.1
>> +Filename 'uImage'.
>> +Load address: 0x8020
>> +Loading: #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #
>> + #

Re: [U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-12 Thread Kevin Hilman
Anup Patel  writes:

> From: Atish Patra 
>
> The readme guide describes the procedure to build, flash and boot Linux
> using U-Boot on HiFive Unleashed. It also explains the current state of
> U-boot support and future action items.
>
> Signed-off-by: Atish Patra 
> Signed-off-by: Anup Patel 
> Reviewed-by: Lukas Auer 

I'm testing this with the mainline kernel (v5.0-rc6) and running into
some problems getting kernel output on the serial console.

[...]

> +=> setenv ethaddr 70:B3:D5:92:F0:C2
> +=> setenv ipaddr 10.196.157.189
> +=> setenv serverip 10.11.143.218
> +=> setenv gatewayip 10.196.156.1
> +=> setenv netmask 255.255.252.0
> +=> bdinfo
> +boot_params = 0x
> +DRAM bank   = 0x
> +-> start= 0x8000
> +-> size = 0x0002
> +relocaddr   = 0xfff9
> +reloc off   = 0x7fd9
> +ethaddr = 70:B3:D5:92:F0:C2
> +IP addr = 10.196.157.189
> +baudrate= 115200 bps
> +=> tftpboot uImage
> +ethernet@1009: PHY present at 0
> +ethernet@1009: Starting autonegotiation...
> +ethernet@1009: Autonegotiation complete
> +ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
> +Using ethernet@1009 device
> +TFTP from server 10.11.143.218; our IP address is 10.196.157.189; sending 
> through gateway 10.196.156.1
> +Filename 'uImage'.
> +Load address: 0x8020
> +Loading: #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + #
> + ##
> + 2.5 MiB/s
> +done
> +Bytes transferred = 14939132 (e3f3fc hex)
> +=> bootm 0x8020 - 0x8220

Fi

[U-Boot] [PATCH v7 14/15] doc: Add a readme guide for SiFive FU540

2019-02-10 Thread Anup Patel
From: Atish Patra 

The readme guide describes the procedure to build, flash and boot Linux
using U-Boot on HiFive Unleashed. It also explains the current state of
U-boot support and future action items.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Lukas Auer 
---
 doc/README.sifive-fu540 | 303 
 1 file changed, 303 insertions(+)
 create mode 100644 doc/README.sifive-fu540

diff --git a/doc/README.sifive-fu540 b/doc/README.sifive-fu540
new file mode 100644
index 00..fd9f2a8e46
--- /dev/null
+++ b/doc/README.sifive-fu540
@@ -0,0 +1,303 @@
+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. SPI driver is still missing. So MMC card can't be used in U-Boot as of now.
+2. U-Boot expects the serial console device entry to be present under /chosen
+   DT node. Example:
+   chosen {
+stdout-path = "/soc/serial@1001: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=
+3. make sifive_fu540_defconfig
+4. make
+
+Flashing
+
+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 or BBL) is required to
+load the u-boot.bin into memory and provide runtime services. The u-boot.bin
+can be given as a payload to the prior stage (M-mode) firmware/bootloader.
+
+The description of steps required to build the firmware is beyond the scope of
+this document. Please refer OpenSBI or BBL documenation.
+(Note: OpenSBI git repo is at https://github.com/riscv/opensbi.git)
+(Note: BBL git repo is at https://github.com/riscv/riscv-pk.git)
+
+Once the prior stage firmware/bootloader binary is generated, it should be
+copied to the first partition of the sdcard.
+
+sudo dd if= 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.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+CPU:   rv64imafdc
+Model: sifive,hifive-unleashed-a00
+DRAM:  8 GiB
+In:serial@1001
+Out:   serial@1001
+Err:   serial@1001
+Net:
+Warning: ethernet@1009 (eth0) using random MAC address - b6:75:4d:48:50:94
+eth0: ethernet@1009
+Hit any key to stop autoboot:  0
+=> version
+U-Boot 2019.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+riscv64-linux-gcc.br_real (Buildroot 2018.11-rc2-3-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 ethaddr 70:B3:D5:92:F0:C2
+=> setenv ipaddr 10.196.157.189
+=> setenv serverip 10.11.143.218
+=> setenv gatewayip 10.196.156.1
+=> setenv netmask 255.255.252.0
+=> bdinfo
+boot_params = 0x
+DRAM bank   = 0x
+-> start= 0x8000
+-> size = 0x0002
+relocaddr   = 0xfff9
+reloc off   = 0x7fd9
+ethaddr = 70:B3:D5:92:F0:C2
+IP addr = 10.196.157.189
+baudrate= 115200 bps
+=> tftpboot uImage
+ethernet@1009: PHY present at 0
+ethernet@1009: Starting autonegotiation...
+ethernet@1009: Autonegotiation complete
+ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
+Using ethernet@1009 device
+TFTP from server 10.11.143.218; our IP address is 10.196.157.189; sending 
through gateway 10.196.156.1
+Filename 'uImage'.
+Load address: 0x8020
+Loading: #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+