drivers icon indicating copy to clipboard operation
drivers copied to clipboard

DS1307 real time clock can't compile .hex

Open yevsia opened this issue 5 years ago • 3 comments
trafficstars

TinyGo version 0.14.1 Go version 1.15

package main

import (
	"machine"
	"strconv"
	"time"

	"tinygo.org/x/drivers/ds1307"
)

var (
	uart = machine.UART0
	tx   = machine.UART_TX_PIN
	rx   = machine.UART_RX_PIN
)

func main() {
	machine.I2C0.Configure(machine.I2CConfig{})
	rtc := ds1307.New(machine.I2C0)
	rtc.SetTime(time.Date(2019, 5, 15, 20, 34, 12, 0, time.UTC))

	for {
		t, err := rtc.Time()
		if err != nil {
			uart.Write([]byte("Error reading date!"))
			break
		}

		uart.Write([]byte(strconv.Itoa(t.Second())))

	}

}
Exception 0xc0000005 0x0 0x181 0x2d884d7
PC=0x2d884d7

runtime: unknown pc 0x2d884d7
stack: frame={sp:0x2d84dca0, fp:0x0} stack=[0x0,0x2d84feb0)
000000002d84dba0:  0000000000000000  0000000000000000
000000002d84dbb0:  000005c0fffffb30  000004d0fffffb30
000000002d84dbc0:  00000000000000f0  0000000002d77ea6
000000002d84dbd0:  00000000c0000005  0000000000000000
000000002d84dbe0:  0000000002d884d7  0000000000000002
000000002d84dbf0:  0000000000000000  0000000000000181
000000002d84dc00:  0000000000000000  0000000000000000
000000002d84dc10:  0000000000000000  0000000000000000
000000002d84dc20:  0000000000000000  0000000000000000
000000002d84dc30:  0000000000000000  0000000000000000
000000002d84dc40:  0000000000000000  0000000000000000
000000002d84dc50:  0000000000000000  0000000000000000
000000002d84dc60:  0000000000000000  0000000000000000
000000002d84dc70:  0000000002d884d7  0000000000000000
000000002d84dc80:  00000000041e6a20  000000002d84dca0
000000002d84dc90:  000000002d840000  000000002d84dd70
000000002d84dca0: <000000002ef148f0  0000000000000000
000000002d84dcb0:  000000002f424008  0000000000000000
000000002d84dcc0:  000000002d84dd50  0000000000000002
000000002d84dcd0:  0000000000000005  0000000000000000
000000002d84dce0:  00000000002f0b60  000000002d84dd90
000000002d84dcf0:  000000002f454cd0  0000000000000000
000000002d84dd00:  0000000000000005  0000000000000000
000000002d84dd10:  00000000779f1440  0000000000000000
000000002d84dd20:  0000000000000001  00000000002e0000
000000002d84dd30:  000000002f48a1e0  0000000000000090
000000002d84dd40:  0000000000000004  0000000000000000
000000002d84dd50:  000000002f454cd0  0000000000000000
000000002d84dd60:  000000002f424008  0000000000000000
000000002d84dd70:  000000002d84dd80  0000002000000009
000000002d84dd80:  2f1a5f3000000033  2f454cd000000000
000000002d84dd90:  0000000000000000  000000002f424008
runtime: unknown pc 0x2d884d7
stack: frame={sp:0x2d84dca0, fp:0x0} stack=[0x0,0x2d84feb0)
000000002d84dba0:  0000000000000000  0000000000000000
000000002d84dbb0:  000005c0fffffb30  000004d0fffffb30
000000002d84dbc0:  00000000000000f0  0000000002d77ea6
000000002d84dbd0:  00000000c0000005  0000000000000000
000000002d84dbe0:  0000000002d884d7  0000000000000002
000000002d84dbf0:  0000000000000000  0000000000000181
000000002d84dc00:  0000000000000000  0000000000000000
000000002d84dc10:  0000000000000000  0000000000000000
000000002d84dc20:  0000000000000000  0000000000000000
000000002d84dc30:  0000000000000000  0000000000000000
000000002d84dc40:  0000000000000000  0000000000000000
000000002d84dc50:  0000000000000000  0000000000000000
000000002d84dc60:  0000000000000000  0000000000000000
000000002d84dc70:  0000000002d884d7  0000000000000000
000000002d84dc80:  00000000041e6a20  000000002d84dca0
000000002d84dc90:  000000002d840000  000000002d84dd70
000000002d84dca0: <000000002ef148f0  0000000000000000
000000002d84dcb0:  000000002f424008  0000000000000000
000000002d84dcc0:  000000002d84dd50  0000000000000002
000000002d84dcd0:  0000000000000005  0000000000000000
000000002d84dce0:  00000000002f0b60  000000002d84dd90
000000002d84dcf0:  000000002f454cd0  0000000000000000
000000002d84dd00:  0000000000000005  0000000000000000
000000002d84dd10:  00000000779f1440  0000000000000000
000000002d84dd20:  0000000000000001  00000000002e0000
000000002d84dd30:  000000002f48a1e0  0000000000000090
000000002d84dd40:  0000000000000004  0000000000000000
000000002d84dd50:  000000002f454cd0  0000000000000000
000000002d84dd60:  000000002f424008  0000000000000000
000000002d84dd70:  000000002d84dd80  0000002000000009
000000002d84dd80:  2f1a5f3000000033  2f454cd000000000
000000002d84dd90:  0000000000000000  000000002f424008

goroutine 1 [syscall]:
tinygo.org/x/go-llvm._Cfunc_LLVMTargetMachineEmitToMemoryBuffer(0x3443e0, 0x35fc40, 0x1, 0xc002b97758, 0xc002b97760, 0xc000000000)
        _cgo_gotypes.go:9418 +0x54
tinygo.org/x/go-llvm.TargetMachine.EmitToMemoryBuffer.func1(0x3443e0, 0x35fc40, 0xc000000001, 0xc002b97758, 0xc002b97760, 0x51a0dd)
        C:/Users/VssAdministrator/go/pkg/mod/tinygo.org/x/[email protected]/target.go:273 +0x105
tinygo.org/x/go-llvm.TargetMachine.EmitToMemoryBuffer(0x3443e0, 0x35fc40, 0x1, 0xc000154940, 0x39, 0x32)
        C:/Users/VssAdministrator/go/pkg/mod/tinygo.org/x/[email protected]/target.go:273 +0x8b
github.com/tinygo-org/tinygo/builder.Build(0xc0000a2160, 0x15, 0xc0000a2120, 0x16, 0xc0001e9d40, 0xc002c79c68, 0x0, 0x0)
        D:/a/1/s/builder/build.go:145 +0x659
main.Build(0xc0000a2160, 0x15, 0xc0000a2120, 0x16, 0xc0001ea000, 0x1, 0xffffffffffffffff)
        D:/a/1/s/main.go:97 +0xcc
main.main()
        D:/a/1/s/main.go:888 +0x1cf9
rax     0x2d84df60
rbx     0x2d84df80
rcx     0x2d84df80
rdi     0x3bd9b0
rsi     0x2d84e550
rbp     0x869
rsp     0x2d84dca0
r8      0xbf
r9      0x2d84e380
r10     0x2d84e3a0
r11     0x2f479ef8
r12     0x2d84e380
r13     0x2f542f00
r14     0x2d84df90
r15     0x169
rip     0x2d884d7
rflags  0x10206
cs      0x33
fs      0x53
gs      0x2b

yevsia avatar Oct 11 '20 13:10 yevsia

What target are you trying to compile for? The drivers in this repo are built by the CI system:

https://app.circleci.com/pipelines/github/tinygo-org/drivers/603/workflows/e2cf361d-6c58-45a9-b952-f27932faa401/jobs/612

tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
   code    data     bss |   flash     ram
  11096      36    2212 |   11132    2248
96132885a7b5f2eccd4eaefd7cb58e81  ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
   code    data     bss |   flash     ram
  17344      92    2292 |   17436    2384
864a3d8924113651f22cfa3e116d03b0  ./build/test.hex

deadprogram avatar Oct 18 '20 19:10 deadprogram

Target arduino.

yevsia avatar Oct 23 '20 21:10 yevsia

This is a bug in the AVR backend. I suspect it's the same bug that also prevents the fmt package from being compiled.

Hopefully it'll get fixed eventually. In the meantime, you could try to avoid importing bigger packages like the strconv package that may not yet compile.

aykevl avatar Oct 25 '20 21:10 aykevl