From a9174d91842fff5ed46c424d5db8772763d61eab Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 10 Jan 2020 16:49:08 +0100 Subject: [PATCH] runtime/fe310: do peripheral initialization in an explicit call This avoids some issues with interp in the next commit. --- src/runtime/runtime_fe310.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runtime/runtime_fe310.go b/src/runtime/runtime_fe310.go index 14a00563..d96f4e46 100644 --- a/src/runtime/runtime_fe310.go +++ b/src/runtime/runtime_fe310.go @@ -46,6 +46,7 @@ func main() { riscv.MSTATUS.SetBits(1 << 3) // MIE preinit() + initPeripherals() initAll() callMain() abort() @@ -76,12 +77,8 @@ func handleInterrupt() { } } -func init() { - pric_init() - machine.UART0.Configure(machine.UARTConfig{}) -} - -func pric_init() { +// initPeripherals configures periperhals the way the runtime expects them. +func initPeripherals() { // Make sure the HFROSC is on sifive.PRCI.HFROSCCFG.SetBits(sifive.PRCI_HFROSCCFG_ENABLE) @@ -94,6 +91,9 @@ func pric_init() { // Enable the RTC. sifive.RTC.RTCCFG.Set(sifive.RTC_RTCCFG_ENALWAYS) + + // Configure the UART. + machine.UART0.Configure(machine.UARTConfig{}) } func preinit() {