Skip to content

Commit ab50f82

Browse files
parasquidaykevlniaow
authored andcommitted
arduino: fix avr hex not working when flashed
An optimization introduced in tinygo-org@a04db67 seems to have broken arduino uno compiled hex. Setting optimzation flags to 1, 2, or s builds proper hex binaries though. These patches have been the result of troubleshooting over slack: > @aykevl > that preinit also doesn't look right. Can you try this variant, > with 8-bit stores instead of 32-bit stores? > There might be some alignment issue: the _ebss might not be > aligned resulting in ptr != unsafe.Pointer(&_ebss) never being true. Co-authored-by: Ayke van Laethem <aykevanlaethem@gmail.com> Co-authored-by: Jaden Weiss <jadr2ddude@gmail.com>
1 parent 3fa926c commit ab50f82

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/runtime/runtime_avr.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ const (
3131
)
3232

3333
//go:extern _sbss
34-
var _sbss unsafe.Pointer
34+
var _sbss [0]byte
3535

3636
//go:extern _ebss
37-
var _ebss unsafe.Pointer
37+
var _ebss [0]byte
3838

3939
//go:export main
4040
func main() {
@@ -49,8 +49,8 @@ func preinit() {
4949
// Initialize .bss: zero-initialized global variables.
5050
ptr := unsafe.Pointer(&_sbss)
5151
for ptr != unsafe.Pointer(&_ebss) {
52-
*(*uint32)(ptr) = 0
53-
ptr = unsafe.Pointer(uintptr(ptr) + 4)
52+
*(*uint8)(ptr) = 0
53+
ptr = unsafe.Pointer(uintptr(ptr) + 1)
5454
}
5555
}
5656

0 commit comments

Comments
 (0)