mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
cortexm: disable FPU on Cortex-M4
On some boards the FPU is already enabled on startup, probably as part of the bootloader. On other chips it was enabled as part of the runtime startup code. In all these cases, enabling the FPU is currently unsupported: the automatic stack sizing of goroutines assumes that the processor won't need to reserve space for FPU registers. Enabling the FPU therefore can lead to a stack overflow. This commit either removes the code that enables the FPU, or simply disables it in startup code. A future change should fully enable the FPU so that operations on float32 can be performed by the FPU instead of in software, greatly speeding up such code.
This commit is contained in:
committed by
Ron Evans
parent
4eac212695
commit
f79e66ac2e
@@ -16,6 +16,7 @@ func postinit() {}
|
||||
|
||||
//export Reset_Handler
|
||||
func main() {
|
||||
arm.SCB.CPACR.Set(0) // disable FPU if it is enabled
|
||||
preinit()
|
||||
run()
|
||||
abort()
|
||||
|
||||
@@ -102,11 +102,6 @@ func initSystem() {
|
||||
|
||||
func initPeripherals() {
|
||||
|
||||
// enable FPU - set CP10, CP11 full access
|
||||
nxp.SystemControl.CPACR.SetBits(
|
||||
((nxp.SCB_CPACR_CP10_CP10_3 << nxp.SCB_CPACR_CP10_Pos) & nxp.SCB_CPACR_CP10_Msk) |
|
||||
((nxp.SCB_CPACR_CP11_CP11_3 << nxp.SCB_CPACR_CP11_Pos) & nxp.SCB_CPACR_CP11_Msk))
|
||||
|
||||
enableTimerClocks() // activate GPT/PIT clock gates
|
||||
initSysTick() // enable SysTick
|
||||
initRTC() // enable real-time clock
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"device/arm"
|
||||
"device/nrf"
|
||||
"machine"
|
||||
"runtime/interrupt"
|
||||
@@ -18,6 +19,9 @@ func postinit() {}
|
||||
|
||||
//export Reset_Handler
|
||||
func main() {
|
||||
if nrf.FPUPresent {
|
||||
arm.SCB.CPACR.Set(0) // disable FPU if it is enabled
|
||||
}
|
||||
systemInit()
|
||||
preinit()
|
||||
run()
|
||||
|
||||
@@ -75,7 +75,6 @@ func initSystem() {
|
||||
nxp.SIM.SCGC3.Set(nxp.SIM_SCGC3_ADC1 | nxp.SIM_SCGC3_FTM2 | nxp.SIM_SCGC3_FTM3)
|
||||
nxp.SIM.SCGC5.Set(0x00043F82) // clocks active to all GPIO
|
||||
nxp.SIM.SCGC6.Set(nxp.SIM_SCGC6_RTC | nxp.SIM_SCGC6_FTM0 | nxp.SIM_SCGC6_FTM1 | nxp.SIM_SCGC6_ADC0 | nxp.SIM_SCGC6_FTF)
|
||||
nxp.SystemControl.CPACR.Set(0x00F00000)
|
||||
nxp.LMEM.PCCCR.Set(0x85000003)
|
||||
|
||||
// release I/O pins hold, if we woke up from VLLS mode
|
||||
|
||||
Reference in New Issue
Block a user