Skip to content

Instantly share code, notes, and snippets.

@sago35
Created May 22, 2020 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sago35/95c2213093ac3565865be310e5c432a2 to your computer and use it in GitHub Desktop.
Save sago35/95c2213093ac3565865be310e5c432a2 to your computer and use it in GitHub Desktop.
A workaround for crashes when trying to use SAMD5x FPU on windows version of tinygo
// +build atsamd51
// Put this file in the main package directory
// https://github.com/tinygo-org/tinygo/issues/944#issuecomment-597065613
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439b/BEHBJHIG.html
package main
import (
"runtime/volatile"
"unsafe"
)
func init() {
enableCortexM4FPU()
}
func enableCortexM4FPU() {
cpacraddr := (*uint32)(unsafe.Pointer(uintptr(0xE000ED88)))
tmp := *cpacraddr
tmp |= (0xF << 20)
volatile.StoreUint32(cpacraddr, tmp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment