diff --git a/builder/sizes_test.go b/builder/sizes_test.go index f786d9c826..16760218ca 100644 --- a/builder/sizes_test.go +++ b/builder/sizes_test.go @@ -43,8 +43,8 @@ func TestBinarySize(t *testing.T) { tests := []sizeTest{ // microcontrollers {"hifive1b", "examples/echo", 3884, 280, 0, 2268}, - {"microbit", "examples/serial", 2852, 360, 8, 2272}, - {"wioterminal", "examples/pininterrupt", 7337, 1491, 116, 6912}, + {"microbit", "examples/serial", 2844, 360, 8, 2272}, + {"wioterminal", "examples/pininterrupt", 7349, 1491, 116, 6912}, // TODO: also check wasm. Right now this is difficult, because // wasm binaries are run through wasm-opt and therefore the diff --git a/src/runtime/runtime_atsamd21.go b/src/runtime/runtime_atsamd21.go index e0aeb08690..52bedf739f 100644 --- a/src/runtime/runtime_atsamd21.go +++ b/src/runtime/runtime_atsamd21.go @@ -273,6 +273,9 @@ func nanosecondsToTicks(ns int64) timeUnit { func sleepTicks(d timeUnit) { for d != 0 { ticks := uint32(d) + if d > 0xffff_ffff { + ticks = 0xffff_ffff + } if !timerSleep(ticks) { // Bail out early to handle a non-time interrupt. return diff --git a/src/runtime/runtime_atsamd51.go b/src/runtime/runtime_atsamd51.go index 5c8a3d8b2f..f8d46275b5 100644 --- a/src/runtime/runtime_atsamd51.go +++ b/src/runtime/runtime_atsamd51.go @@ -266,6 +266,9 @@ func nanosecondsToTicks(ns int64) timeUnit { func sleepTicks(d timeUnit) { for d != 0 { ticks := uint32(d) + if d > 0xffff_ffff { + ticks = 0xffff_ffff + } if !timerSleep(ticks) { return } diff --git a/src/runtime/runtime_nrf.go b/src/runtime/runtime_nrf.go index a295b99669..5c992ec47b 100644 --- a/src/runtime/runtime_nrf.go +++ b/src/runtime/runtime_nrf.go @@ -78,6 +78,9 @@ func buffered() int { func sleepTicks(d timeUnit) { for d != 0 { ticks := uint32(d) & 0x7fffff // 23 bits (to be on the safe side) + if d > 0x7fffff { + ticks = 0x7fffff + } rtc_sleep(ticks) d -= timeUnit(ticks) } diff --git a/src/runtime/runtime_nrf52840.go b/src/runtime/runtime_nrf52840.go index 4ac7314a24..3c7deb031d 100644 --- a/src/runtime/runtime_nrf52840.go +++ b/src/runtime/runtime_nrf52840.go @@ -81,6 +81,9 @@ func buffered() int { func sleepTicks(d timeUnit) { for d != 0 { ticks := uint32(d) & 0x7fffff // 23 bits (to be on the safe side) + if d > 0x7fffff { + ticks = 0x7fffff + } rtc_sleep(ticks) d -= timeUnit(ticks) }