mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 12:04:03 +00:00
arduino: fix avr hex not working when flashed
An optimization introduced in https://github.com/tinygo-org/tinygo/commit/a04db67ea9d882eed9164321bcb503f76a65d2f1 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>
This commit is contained in:
@@ -31,10 +31,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//go:extern _sbss
|
//go:extern _sbss
|
||||||
var _sbss unsafe.Pointer
|
var _sbss [0]byte
|
||||||
|
|
||||||
//go:extern _ebss
|
//go:extern _ebss
|
||||||
var _ebss unsafe.Pointer
|
var _ebss [0]byte
|
||||||
|
|
||||||
//go:export main
|
//go:export main
|
||||||
func main() {
|
func main() {
|
||||||
@@ -49,8 +49,8 @@ func preinit() {
|
|||||||
// Initialize .bss: zero-initialized global variables.
|
// Initialize .bss: zero-initialized global variables.
|
||||||
ptr := unsafe.Pointer(&_sbss)
|
ptr := unsafe.Pointer(&_sbss)
|
||||||
for ptr != unsafe.Pointer(&_ebss) {
|
for ptr != unsafe.Pointer(&_ebss) {
|
||||||
*(*uint32)(ptr) = 0
|
*(*uint8)(ptr) = 0
|
||||||
ptr = unsafe.Pointer(uintptr(ptr) + 4)
|
ptr = unsafe.Pointer(uintptr(ptr) + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user