Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GPIO interrupt for ESP32C3 #2598

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

zdima
Copy link
Contributor

@zdima zdima commented Jan 31, 2022

I have stumble upon compiler issue related to interrupts.
This is a test branch with working pininterrupt test.
If you uncomment one case (5) in switch statement the tinygo will start failing in link with missing symbols.
And if you uncomment more cases (like 1-5) in switch statement the tinygo will just crash.
I am using LLVM13 build with make make llvm-build and make to build tinygo:

arm64:pininterrupt zdima$ tinygo version
tinygo version 0.23.0-dev-a7a69d38 darwin/arm64 (using go version go1.17.3 and LLVM version 13.0.0)
$ tinygo flash -x -target=esp32c3-12f pininterrupt.go 
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0xe61e1d679400 pc=0x1034d2428]

runtime stack:
runtime.throw({0x10376119a, 0x2a})
	/usr/local/go/src/runtime/panic.go:1198 +0x54
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:719 +0x230

goroutine 52 [syscall]:
runtime.cgocall(0x10044a65c, 0x1400674f538)
	/usr/local/go/src/runtime/cgocall.go:156 +0x50 fp=0x1400674f4f0 sp=0x1400674f4b0 pc=0x1000ffc40
tinygo.org/x/go-llvm._Cfunc_LLVMIsAConstantInt(0xe61e1d6793f0)
	_cgo_gotypes.go:7424 +0x44 fp=0x1400674f530 sp=0x1400674f4f0 pc=0x1002f5ae4
tinygo.org/x/go-llvm.Value.IsAConstantInt.func1({0xe61e1d6793f0})
	/Users/zdima/go/pkg/mod/tinygo.org/x/[email protected]/ir.go:739 +0x50 fp=0x1400674f570 sp=0x1400674f530 pc=0x100300e00
tinygo.org/x/go-llvm.Value.IsAConstantInt({0xe61e1d6793f0})
	/Users/zdima/go/pkg/mod/tinygo.org/x/[email protected]/ir.go:739 +0x28 fp=0x1400674f590 sp=0x1400674f570 pc=0x100300d88
github.com/tinygo-org/tinygo/transform.LowerInterrupts({0x149f31850})
	/Users/zdima/WorkFolder/tinygo-test/transform/interrupt.go:78 +0x65c fp=0x1400674fa70 sp=0x1400674f590 pc=0x1003e1bbc

@@ -74,7 +114,70 @@ func handleInterrupt() {
riscv.MSTATUS.SetBits(0x8)

// Call registered interrupt handler(s)
esp.HandleInterrupt(int(interruptNumber))
switch interruptNumber {
// case IRQNUM_1:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aykevl
tinygo crash when uncommenting cases 1-5
tinygo failing in link when uncommenting case 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant