From f72b8c90ebc193ba0baf418758288749fd127b85 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 21 Jun 2026 17:54:05 +0200 Subject: [PATCH] machine: optimize RTT initialization This converts the heap allocation to a statically allocated string. This is useful for me, since it reduces binary size and makes it possible to use `-gc=none` (which would previously result in a linker error). --- src/machine/serial-rtt.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/machine/serial-rtt.go b/src/machine/serial-rtt.go index c258ccd258..50a5b978a2 100644 --- a/src/machine/serial-rtt.go +++ b/src/machine/serial-rtt.go @@ -71,16 +71,18 @@ type rttSerial struct { rttControlBlock } +var terminalByteString = []byte("Terminal\x00") + func (s *rttSerial) Configure(config UARTConfig) error { s.maxNumUpBuffers = rttMaxNumUpBuffers s.maxNumDownBuffers = rttMaxNumDownBuffers - s.buffersUp[0].name = &[]byte("Terminal\x00")[0] + s.buffersUp[0].name = &terminalByteString[0] s.buffersUp[0].buffer = &rttBufferUpData[0] s.buffersUp[0].bufferSize = rttBufferSizeUp s.buffersUp[0].flags = rttModeNoBlockSkip - s.buffersDown[0].name = &[]byte("Terminal\x00")[0] + s.buffersDown[0].name = &terminalByteString[0] s.buffersDown[0].buffer = &rttBufferDownData[0] s.buffersDown[0].bufferSize = rttBufferSizeDown s.buffersDown[0].flags = rttModeNoBlockSkip