aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-06-01 13:27:58 +0200
committerRon Evans <[email protected]>2021-06-25 17:58:39 +0200
commit96e863f0f37cef0e8f36cb0d5f1c94fe062bc03d (patch)
treef4044fca721e0d1f58f64e7a312b6fb92215f64f
parent75298bb84bcb966998ca00f3cc5506a9757a5038 (diff)
downloadtinygo-96e863f0f37cef0e8f36cb0d5f1c94fe062bc03d.tar.gz
tinygo-96e863f0f37cef0e8f36cb0d5f1c94fe062bc03d.zip
all: add a flag to the command line to select the serial implementation
This can be very useful for some purposes: * It makes it possible to disable the UART in cases where it is not needed or needs to be disabled to conserve power. * It makes it possible to disable the serial output to reduce code size, which may be important for some chips. Sometimes, a few kB can be saved this way. * It makes it possible to override the default, for example you might want to use an actual UART to debug the USB-CDC implementation. It also lowers the dependency on having machine.Serial defined, which is often not defined when targeting a chip. Eventually, we might want to make it possible to write `-target=nrf52` or `-target=atmega328p` for example to target the chip itself with no board specific assumptions. The defaults don't change. I checked this by running `make smoketest` before and after and comparing the results.
-rw-r--r--Makefile2
-rw-r--r--compileopts/config.go14
-rw-r--r--compileopts/options.go11
-rw-r--r--compileopts/target.go1
-rw-r--r--main.go2
-rw-r--r--src/machine/board_arduino_mkr1000.go2
-rw-r--r--src/machine/board_arduino_zero.go2
-rw-r--r--src/machine/board_atsamd21.go2
-rw-r--r--src/machine/board_atsame54-xpro.go2
-rw-r--r--src/machine/board_bluepill.go2
-rw-r--r--src/machine/board_circuitplay_bluefruit.go2
-rw-r--r--src/machine/board_clue_alpha.go5
-rw-r--r--src/machine/board_esp32-coreboard-v2.go2
-rw-r--r--src/machine/board_feather-m4-can.go2
-rw-r--r--src/machine/board_feather-m4.go2
-rw-r--r--src/machine/board_feather-nrf52840.go5
-rw-r--r--src/machine/board_feather-stm32f405.go2
-rw-r--r--src/machine/board_grandcentral-m4.go2
-rw-r--r--src/machine/board_hifive1b.go2
-rw-r--r--src/machine/board_itsybitsy-m4.go2
-rw-r--r--src/machine/board_itsybitsy-nrf52840.go5
-rw-r--r--src/machine/board_lgt92.go2
-rw-r--r--src/machine/board_maixbit.go2
-rw-r--r--src/machine/board_metro-m4-airlift.go2
-rw-r--r--src/machine/board_microbit-v2.go2
-rw-r--r--src/machine/board_microbit.go2
-rw-r--r--src/machine/board_nicenano.go5
-rw-r--r--src/machine/board_nodemcu.go2
-rw-r--r--src/machine/board_nrf52840-mdk-usb-dongle.go3
-rw-r--r--src/machine/board_nrf52840-mdk.go3
-rw-r--r--src/machine/board_nucleof103rb.go2
-rw-r--r--src/machine/board_nucleof722ze.go2
-rw-r--r--src/machine/board_nucleol031k6.go2
-rw-r--r--src/machine/board_nucleol432kc.go2
-rw-r--r--src/machine/board_nucleol552ze.go2
-rw-r--r--src/machine/board_particle_argon.go2
-rw-r--r--src/machine/board_particle_boron.go2
-rw-r--r--src/machine/board_particle_xenon.go2
-rw-r--r--src/machine/board_pca10031.go2
-rw-r--r--src/machine/board_pca10040.go2
-rw-r--r--src/machine/board_pca10056.go2
-rw-r--r--src/machine/board_pca10059.go5
-rw-r--r--src/machine/board_pinetime-devkit0.go2
-rw-r--r--src/machine/board_pybadge.go2
-rw-r--r--src/machine/board_pygamer.go2
-rw-r--r--src/machine/board_pyportal.go2
-rw-r--r--src/machine/board_reelboard.go2
-rw-r--r--src/machine/board_stm32f4disco.go2
-rw-r--r--src/machine/board_teensy36.go2
-rw-r--r--src/machine/board_teensy40.go6
-rw-r--r--src/machine/board_wioterminal.go2
-rw-r--r--src/machine/board_x9pro.go2
-rw-r--r--src/machine/machine_atmega.go2
-rw-r--r--src/machine/machine_esp32.go2
-rw-r--r--src/machine/machine_esp8266.go2
-rw-r--r--src/machine/machine_generic.go12
-rw-r--r--src/machine/machine_rp2040.go2
-rw-r--r--src/machine/serial-none.go6
-rw-r--r--src/machine/serial-uart.go6
-rw-r--r--src/machine/serial-usb.go6
-rw-r--r--src/machine/serial.go46
-rw-r--r--src/machine/uart.go6
-rw-r--r--targets/arduino-mkr1000.json1
-rw-r--r--targets/arduino-zero.json1
-rw-r--r--targets/atmega1280.json1
-rw-r--r--targets/atmega1284p.json1
-rw-r--r--targets/atmega2560.json1
-rw-r--r--targets/atmega328p.json1
-rw-r--r--targets/atsamd21e18a.json1
-rw-r--r--targets/atsamd21g18a.json1
-rw-r--r--targets/atsame54-xpro.json1
-rw-r--r--targets/bluepill.json1
-rw-r--r--targets/circuitplay-bluefruit.json1
-rw-r--r--targets/clue-alpha.json1
-rw-r--r--targets/esp32.json1
-rw-r--r--targets/feather-m4-can.json1
-rw-r--r--targets/feather-m4.json1
-rw-r--r--targets/feather-nrf52840.json1
-rw-r--r--targets/feather-stm32f405.json1
-rw-r--r--targets/grandcentral-m4.json1
-rw-r--r--targets/hifive1-qemu.json1
-rw-r--r--targets/hifive1b.json1
-rw-r--r--targets/itsybitsy-m4.json1
-rw-r--r--targets/itsybitsy-nrf52840.json1
-rw-r--r--targets/lgt92.json1
-rw-r--r--targets/maixbit.json1
-rw-r--r--targets/metro-m4-airlift.json1
-rw-r--r--targets/microbit-v2.json1
-rw-r--r--targets/microbit.json1
-rw-r--r--targets/nicenano.json1
-rw-r--r--targets/nodemcu.json3
-rw-r--r--targets/nrf52840-mdk-usb-dongle.json1
-rw-r--r--targets/nrf52840-mdk.json1
-rw-r--r--targets/nucleo-f103rb.json1
-rw-r--r--targets/nucleo-f722ze.json1
-rw-r--r--targets/nucleo-l031k6.json1
-rw-r--r--targets/nucleo-l432kc.json1
-rw-r--r--targets/nucleo-l552ze.json1
-rw-r--r--targets/particle-3rd-gen.json1
-rw-r--r--targets/pca10031.json1
-rw-r--r--targets/pca10040.json1
-rw-r--r--targets/pca10056.json1
-rw-r--r--targets/pca10059.json1
-rw-r--r--targets/pico.json1
-rw-r--r--targets/pinetime-devkit0.json1
-rw-r--r--targets/pybadge.json1
-rw-r--r--targets/pygamer.json1
-rw-r--r--targets/pyportal.json1
-rw-r--r--targets/reelboard.json1
-rw-r--r--targets/stm32f4disco.json1
-rw-r--r--targets/teensy36.json1
-rw-r--r--targets/teensy40.json1
-rw-r--r--targets/wioterminal.json1
-rw-r--r--targets/x9pro.json1
114 files changed, 185 insertions, 104 deletions
diff --git a/Makefile b/Makefile
index 6abdc261d..1d6cac87f 100644
--- a/Makefile
+++ b/Makefile
@@ -436,6 +436,8 @@ endif
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1
@$(MD5SUM) test.hex
+ $(TINYGO) build -size short -o test.hex -target=pca10040 -serial=none examples/echo
+ @$(MD5SUM) test.hex
$(TINYGO) build -o test.nro -target=nintendoswitch examples/serial
@$(MD5SUM) test.nro
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=0 ./testdata/stdlib.go
diff --git a/compileopts/config.go b/compileopts/config.go
index 821aa8313..a60f778e0 100644
--- a/compileopts/config.go
+++ b/compileopts/config.go
@@ -55,7 +55,7 @@ func (c *Config) GOARCH() string {
// BuildTags returns the complete list of build tags used during this build.
func (c *Config) BuildTags() []string {
- tags := append(c.Target.BuildTags, []string{"tinygo", "gc." + c.GC(), "scheduler." + c.Scheduler()}...)
+ tags := append(c.Target.BuildTags, []string{"tinygo", "gc." + c.GC(), "scheduler." + c.Scheduler(), "serial." + c.Serial()}...)
for i := 1; i <= c.GoMinorVersion; i++ {
tags = append(tags, fmt.Sprintf("go1.%d", i))
}
@@ -113,6 +113,18 @@ func (c *Config) Scheduler() string {
return "coroutines"
}
+// Serial returns the serial implementation for this build configuration: uart,
+// usb (meaning USB-CDC), or none.
+func (c *Config) Serial() string {
+ if c.Options.Serial != "" {
+ return c.Options.Serial
+ }
+ if c.Target.Serial != "" {
+ return c.Target.Serial
+ }
+ return "none"
+}
+
// OptLevels returns the optimization level (0-2), size level (0-2), and inliner
// threshold as used in the LLVM optimization pipeline.
func (c *Config) OptLevels() (optLevel, sizeLevel int, inlinerThreshold uint) {
diff --git a/compileopts/options.go b/compileopts/options.go
index 10c143b80..7e7bfcafc 100644
--- a/compileopts/options.go
+++ b/compileopts/options.go
@@ -9,6 +9,7 @@ import (
var (
validGCOptions = []string{"none", "leaking", "extalloc", "conservative"}
validSchedulerOptions = []string{"none", "tasks", "coroutines"}
+ validSerialOptions = []string{"none", "uart", "usb"}
validPrintSizeOptions = []string{"none", "short", "full"}
validPanicStrategyOptions = []string{"print", "trap"}
validOptOptions = []string{"none", "0", "1", "2", "s", "z"}
@@ -22,6 +23,7 @@ type Options struct {
GC string
PanicStrategy string
Scheduler string
+ Serial string
PrintIR bool
DumpSSA bool
VerifyIR bool
@@ -59,6 +61,15 @@ func (o *Options) Verify() error {
}
}
+ if o.Serial != "" {
+ valid := isInArray(validSerialOptions, o.Serial)
+ if !valid {
+ return fmt.Errorf(`invalid serial option '%s': valid values are %s`,
+ o.Serial,
+ strings.Join(validSerialOptions, ", "))
+ }
+ }
+
if o.PrintSizes != "" {
valid := isInArray(validPrintSizeOptions, o.PrintSizes)
if !valid {
diff --git a/compileopts/target.go b/compileopts/target.go
index 4fb62fce3..ba5f73826 100644
--- a/compileopts/target.go
+++ b/compileopts/target.go
@@ -31,6 +31,7 @@ type TargetSpec struct {
BuildTags []string `json:"build-tags"`
GC string `json:"gc"`
Scheduler string `json:"scheduler"`
+ Serial string `json:"serial"` // which serial output to use (uart, usb, none)
Linker string `json:"linker"`
RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt)
Libc string `json:"libc"`
diff --git a/main.go b/main.go
index 24d943624..7c3ee96df 100644
--- a/main.go
+++ b/main.go
@@ -1009,6 +1009,7 @@ func main() {
gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative)")
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
scheduler := flag.String("scheduler", "", "which scheduler to use (none, coroutines, tasks)")
+ serial := flag.String("serial", "", "which serial output to use (none, uart, usb)")
printIR := flag.Bool("printir", false, "print LLVM IR")
dumpSSA := flag.Bool("dumpssa", false, "dump internal Go SSA")
verifyIR := flag.Bool("verifyir", false, "run extra verification steps on LLVM IR")
@@ -1081,6 +1082,7 @@ func main() {
GC: *gc,
PanicStrategy: *panicStrategy,
Scheduler: *scheduler,
+ Serial: *serial,
PrintIR: *printIR,
DumpSSA: *dumpSSA,
VerifyIR: *verifyIR,
diff --git a/src/machine/board_arduino_mkr1000.go b/src/machine/board_arduino_mkr1000.go
index 863faeeb6..30ad48e90 100644
--- a/src/machine/board_arduino_mkr1000.go
+++ b/src/machine/board_arduino_mkr1000.go
@@ -47,8 +47,6 @@ const (
LED = D6
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN Pin = PA24
diff --git a/src/machine/board_arduino_zero.go b/src/machine/board_arduino_zero.go
index 773515c99..651eea821 100644
--- a/src/machine/board_arduino_zero.go
+++ b/src/machine/board_arduino_zero.go
@@ -35,8 +35,6 @@ const (
LED3 Pin = PB03 // RX LED
)
-var Serial = USB
-
// ADC pins
const (
AREF Pin = PA03
diff --git a/src/machine/board_atsamd21.go b/src/machine/board_atsamd21.go
index 800c4cb30..3b11b452a 100644
--- a/src/machine/board_atsamd21.go
+++ b/src/machine/board_atsamd21.go
@@ -74,5 +74,3 @@ const (
PB30 Pin = 62
PB31 Pin = 63
)
-
-var Serial = USB
diff --git a/src/machine/board_atsame54-xpro.go b/src/machine/board_atsame54-xpro.go
index 01ae282c1..c61324b64 100644
--- a/src/machine/board_atsame54-xpro.go
+++ b/src/machine/board_atsame54-xpro.go
@@ -15,8 +15,6 @@ const (
BUTTON = PB31
)
-var Serial = USB
-
const (
// https://ww1.microchip.com/downloads/en/DeviceDoc/70005321A.pdf
diff --git a/src/machine/board_bluepill.go b/src/machine/board_bluepill.go
index ce925025f..bbfdac8bb 100644
--- a/src/machine/board_bluepill.go
+++ b/src/machine/board_bluepill.go
@@ -17,7 +17,7 @@ const (
BUTTON = PA0
)
-var Serial = UART1
+var DefaultUART = UART1
// UART pins
const (
diff --git a/src/machine/board_circuitplay_bluefruit.go b/src/machine/board_circuitplay_bluefruit.go
index 967672495..a65861b27 100644
--- a/src/machine/board_circuitplay_bluefruit.go
+++ b/src/machine/board_circuitplay_bluefruit.go
@@ -57,8 +57,6 @@ const (
UART_RX_PIN = P0_30 // PORTB
)
-var Serial = USB
-
// I2C pins
const (
SDA_PIN = P0_05 // I2C0 external
diff --git a/src/machine/board_clue_alpha.go b/src/machine/board_clue_alpha.go
index b421dccce..67c2ad7ef 100644
--- a/src/machine/board_clue_alpha.go
+++ b/src/machine/board_clue_alpha.go
@@ -104,11 +104,6 @@ const (
UART_TX_PIN = D1
)
-// Serial is the USB device
-var (
- Serial = USB
-)
-
// I2C pins
const (
SDA_PIN = D20 // I2C0 external
diff --git a/src/machine/board_esp32-coreboard-v2.go b/src/machine/board_esp32-coreboard-v2.go
index b1d61d87e..0145fe4ea 100644
--- a/src/machine/board_esp32-coreboard-v2.go
+++ b/src/machine/board_esp32-coreboard-v2.go
@@ -68,8 +68,6 @@ const (
ADC3 Pin = IO39
)
-var Serial = UART0
-
// UART0 pins
const (
UART_TX_PIN = IO1
diff --git a/src/machine/board_feather-m4-can.go b/src/machine/board_feather-m4-can.go
index 7911f5561..a954ce9cb 100644
--- a/src/machine/board_feather-m4-can.go
+++ b/src/machine/board_feather-m4-can.go
@@ -47,8 +47,6 @@ const (
WS2812 = D8
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_feather-m4.go b/src/machine/board_feather-m4.go
index 394191366..86158ed64 100644
--- a/src/machine/board_feather-m4.go
+++ b/src/machine/board_feather-m4.go
@@ -40,8 +40,6 @@ const (
WS2812 = D8
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_feather-nrf52840.go b/src/machine/board_feather-nrf52840.go
index 641a9de81..488d9608b 100644
--- a/src/machine/board_feather-nrf52840.go
+++ b/src/machine/board_feather-nrf52840.go
@@ -76,11 +76,6 @@ const (
UART_TX_PIN = D1
)
-// Serial is the USB device
-var (
- Serial = USB
-)
-
// I2C pins
const (
SDA_PIN = D22 // I2C0 external
diff --git a/src/machine/board_feather-stm32f405.go b/src/machine/board_feather-stm32f405.go
index 4bf1744b9..ebba9edc8 100644
--- a/src/machine/board_feather-stm32f405.go
+++ b/src/machine/board_feather-stm32f405.go
@@ -141,7 +141,7 @@ var (
TxAltFuncSelector: AF7_USART1_2_3,
RxAltFuncSelector: AF7_USART1_2_3,
}
- Serial = UART1
+ DefaultUART = UART1
)
func initUART() {
diff --git a/src/machine/board_grandcentral-m4.go b/src/machine/board_grandcentral-m4.go
index 014eda801..c1b629c9e 100644
--- a/src/machine/board_grandcentral-m4.go
+++ b/src/machine/board_grandcentral-m4.go
@@ -142,8 +142,6 @@ const (
WS2812 = NEOPIXEL_PIN
)
-var Serial = USB
-
// UART pins
const (
UART1_RX_PIN = D0 // (PB25)
diff --git a/src/machine/board_hifive1b.go b/src/machine/board_hifive1b.go
index 7ce225ccf..d16225a68 100644
--- a/src/machine/board_hifive1b.go
+++ b/src/machine/board_hifive1b.go
@@ -35,7 +35,7 @@ const (
LED_BLUE = P21
)
-var Serial = UART0
+var DefaultUART = UART0
const (
// TODO: figure out the pin numbers for these.
diff --git a/src/machine/board_itsybitsy-m4.go b/src/machine/board_itsybitsy-m4.go
index 282f9087a..099ceed46 100644
--- a/src/machine/board_itsybitsy-m4.go
+++ b/src/machine/board_itsybitsy-m4.go
@@ -37,8 +37,6 @@ const (
LED = D13
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_itsybitsy-nrf52840.go b/src/machine/board_itsybitsy-nrf52840.go
index 64aeed506..fc9b23f25 100644
--- a/src/machine/board_itsybitsy-nrf52840.go
+++ b/src/machine/board_itsybitsy-nrf52840.go
@@ -70,11 +70,6 @@ const (
UART_TX_PIN = D1
)
-// Serial is the USB device
-var (
- Serial = USB
-)
-
// I2C pins
const (
SDA_PIN = D21 // I2C0 external
diff --git a/src/machine/board_lgt92.go b/src/machine/board_lgt92.go
index 97e1fa2ab..e043dcd77 100644
--- a/src/machine/board_lgt92.go
+++ b/src/machine/board_lgt92.go
@@ -54,7 +54,7 @@ const (
I2C0_SDA_PIN = PA10
)
-var Serial = UART0
+var DefaultUART = UART0
var (
diff --git a/src/machine/board_maixbit.go b/src/machine/board_maixbit.go
index 766054d0d..e2c551b0e 100644
--- a/src/machine/board_maixbit.go
+++ b/src/machine/board_maixbit.go
@@ -52,7 +52,7 @@ const (
LED_BLUE = D14
)
-var Serial = UART0
+var DefaultUART = UART0
// Default pins for UARTHS.
const (
diff --git a/src/machine/board_metro-m4-airlift.go b/src/machine/board_metro-m4-airlift.go
index 276defa92..4aa248150 100644
--- a/src/machine/board_metro-m4-airlift.go
+++ b/src/machine/board_metro-m4-airlift.go
@@ -41,8 +41,6 @@ const (
WS2812 = D40
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_microbit-v2.go b/src/machine/board_microbit-v2.go
index a034e2ef8..38a9dad50 100644
--- a/src/machine/board_microbit-v2.go
+++ b/src/machine/board_microbit-v2.go
@@ -12,7 +12,7 @@ const (
BUTTONB Pin = P11
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins
const (
diff --git a/src/machine/board_microbit.go b/src/machine/board_microbit.go
index 5b0ac2bff..b4af49f8d 100644
--- a/src/machine/board_microbit.go
+++ b/src/machine/board_microbit.go
@@ -12,7 +12,7 @@ const (
BUTTONB Pin = 26
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins
const (
diff --git a/src/machine/board_nicenano.go b/src/machine/board_nicenano.go
index 213fdb339..94511bf9f 100644
--- a/src/machine/board_nicenano.go
+++ b/src/machine/board_nicenano.go
@@ -54,11 +54,6 @@ const (
UART_TX_PIN = P0_08
)
-// Serial is the USB device
-var (
- Serial = USB
-)
-
// I2C pins
const (
SDA_PIN = P0_17 // I2C0 external
diff --git a/src/machine/board_nodemcu.go b/src/machine/board_nodemcu.go
index 4177f80c4..f9f1af4f9 100644
--- a/src/machine/board_nodemcu.go
+++ b/src/machine/board_nodemcu.go
@@ -20,8 +20,6 @@ const (
// Onboard blue LED (on the AI-Thinker module).
const LED = D4
-var Serial = UART0
-
// SPI pins
const (
SPI0_SCK_PIN = D5
diff --git a/src/machine/board_nrf52840-mdk-usb-dongle.go b/src/machine/board_nrf52840-mdk-usb-dongle.go
index e4923f4e9..57a3d1976 100644
--- a/src/machine/board_nrf52840-mdk-usb-dongle.go
+++ b/src/machine/board_nrf52840-mdk-usb-dongle.go
@@ -23,9 +23,6 @@ const (
UART_RX_PIN Pin = NoPin
)
-// Serial is the USB device
-var Serial = USB
-
// I2C pins (unused)
const (
SDA_PIN = NoPin
diff --git a/src/machine/board_nrf52840-mdk.go b/src/machine/board_nrf52840-mdk.go
index d9dc41305..fbc42861b 100644
--- a/src/machine/board_nrf52840-mdk.go
+++ b/src/machine/board_nrf52840-mdk.go
@@ -18,9 +18,6 @@ const (
UART_RX_PIN Pin = 19
)
-// Serial is the USB device
-var Serial = USB
-
// I2C pins (unused)
const (
SDA_PIN = NoPin
diff --git a/src/machine/board_nucleof103rb.go b/src/machine/board_nucleof103rb.go
index 6fa0c27c7..22580e20b 100644
--- a/src/machine/board_nucleof103rb.go
+++ b/src/machine/board_nucleof103rb.go
@@ -34,7 +34,7 @@ var (
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
}
- Serial = UART2
+ DefaultUART = UART2
)
func init() {
diff --git a/src/machine/board_nucleof722ze.go b/src/machine/board_nucleof722ze.go
index 003e8fc75..41d3f2849 100644
--- a/src/machine/board_nucleof722ze.go
+++ b/src/machine/board_nucleof722ze.go
@@ -38,7 +38,7 @@ var (
TxAltFuncSelector: UART_ALT_FN,
RxAltFuncSelector: UART_ALT_FN,
}
- Serial = UART1
+ DefaultUART = UART1
)
func init() {
diff --git a/src/machine/board_nucleol031k6.go b/src/machine/board_nucleol031k6.go
index a758ba932..fe85f276b 100644
--- a/src/machine/board_nucleol031k6.go
+++ b/src/machine/board_nucleol031k6.go
@@ -76,7 +76,7 @@ var (
TxAltFuncSelector: 4,
RxAltFuncSelector: 4,
}
- Serial = UART1
+ DefaultUART = UART1
// I2C1 is documented, alias to I2C0 as well
I2C1 = &I2C{
diff --git a/src/machine/board_nucleol432kc.go b/src/machine/board_nucleol432kc.go
index d44e0f4fd..bfebd1eed 100644
--- a/src/machine/board_nucleol432kc.go
+++ b/src/machine/board_nucleol432kc.go
@@ -78,7 +78,7 @@ var (
TxAltFuncSelector: 7,
RxAltFuncSelector: 3,
}
- Serial = UART1
+ DefaultUART = UART1
// I2C1 is documented, alias to I2C0 as well
I2C1 = &I2C{
diff --git a/src/machine/board_nucleol552ze.go b/src/machine/board_nucleol552ze.go
index 98e2d5c1f..a0d3ee522 100644
--- a/src/machine/board_nucleol552ze.go
+++ b/src/machine/board_nucleol552ze.go
@@ -38,7 +38,7 @@ var (
TxAltFuncSelector: UART_ALT_FN,
RxAltFuncSelector: UART_ALT_FN,
}
- Serial = UART1
+ DefaultUART = UART1
)
const (
diff --git a/src/machine/board_particle_argon.go b/src/machine/board_particle_argon.go
index 1130eaf82..9427029f4 100644
--- a/src/machine/board_particle_argon.go
+++ b/src/machine/board_particle_argon.go
@@ -41,7 +41,7 @@ const (
// UART
var (
- Serial = UART0
+ DefaultUART = UART0
)
const (
diff --git a/src/machine/board_particle_boron.go b/src/machine/board_particle_boron.go
index 6c2f70a80..b6a2c3e54 100644
--- a/src/machine/board_particle_boron.go
+++ b/src/machine/board_particle_boron.go
@@ -41,7 +41,7 @@ const (
// UART
var (
- Serial = UART0
+ DefaultUART = UART0
)
const (
diff --git a/src/machine/board_particle_xenon.go b/src/machine/board_particle_xenon.go
index a6e48ae0a..0b25f373b 100644
--- a/src/machine/board_particle_xenon.go
+++ b/src/machine/board_particle_xenon.go
@@ -41,7 +41,7 @@ const (
// UART
var (
- Serial = UART0
+ DefaultUART = UART0
)
const (
diff --git a/src/machine/board_pca10031.go b/src/machine/board_pca10031.go
index fbddfb232..122c00d20 100644
--- a/src/machine/board_pca10031.go
+++ b/src/machine/board_pca10031.go
@@ -19,7 +19,7 @@ const (
LED_BLUE Pin = 23
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins
const (
diff --git a/src/machine/board_pca10040.go b/src/machine/board_pca10040.go
index 10e2ab2ed..f425ca37c 100644
--- a/src/machine/board_pca10040.go
+++ b/src/machine/board_pca10040.go
@@ -23,7 +23,7 @@ const (
BUTTON4 Pin = 16
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins for NRF52840-DK
const (
diff --git a/src/machine/board_pca10056.go b/src/machine/board_pca10056.go
index 824bd3f01..783629465 100644
--- a/src/machine/board_pca10056.go
+++ b/src/machine/board_pca10056.go
@@ -22,7 +22,7 @@ const (
BUTTON4 Pin = 25
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins
const (
diff --git a/src/machine/board_pca10059.go b/src/machine/board_pca10059.go
index 5079534aa..7f6167913 100644
--- a/src/machine/board_pca10059.go
+++ b/src/machine/board_pca10059.go
@@ -34,11 +34,6 @@ const (
UART_RX_PIN Pin = NoPin
)
-// Serial is the USB device
-var (
- Serial = USB
-)
-
// I2C pins (unused)
const (
SDA_PIN = NoPin
diff --git a/src/machine/board_pinetime-devkit0.go b/src/machine/board_pinetime-devkit0.go
index 5222010bd..b9669c84d 100644
--- a/src/machine/board_pinetime-devkit0.go
+++ b/src/machine/board_pinetime-devkit0.go
@@ -17,7 +17,7 @@ const (
LED3 = LCD_BACKLIGHT_LOW
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins for PineTime. Note that RX is set to NoPin as RXD is not listed in
// the PineTime schematic 1.0:
diff --git a/src/machine/board_pybadge.go b/src/machine/board_pybadge.go
index 3ff24a160..e175da683 100644
--- a/src/machine/board_pybadge.go
+++ b/src/machine/board_pybadge.go
@@ -67,8 +67,6 @@ const (
BUTTON_B_MASK = 128
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_pygamer.go b/src/machine/board_pygamer.go
index 890c3d3d9..f537f8529 100644
--- a/src/machine/board_pygamer.go
+++ b/src/machine/board_pygamer.go
@@ -70,8 +70,6 @@ const (
BUTTON_B_MASK = 128
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_pyportal.go b/src/machine/board_pyportal.go
index 7e28de44a..ff2fcb7fe 100644
--- a/src/machine/board_pyportal.go
+++ b/src/machine/board_pyportal.go
@@ -95,8 +95,6 @@ const (
LED = D13
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
diff --git a/src/machine/board_reelboard.go b/src/machine/board_reelboard.go
index 70eb70539..7fd715bb7 100644
--- a/src/machine/board_reelboard.go
+++ b/src/machine/board_reelboard.go
@@ -29,7 +29,7 @@ const (
BUTTON Pin = 7
)
-var Serial = UART0
+var DefaultUART = UART0
// UART pins
const (
diff --git a/src/machine/board_stm32f4disco.go b/src/machine/board_stm32f4disco.go
index 49f5650fd..cc3711a19 100644
--- a/src/machine/board_stm32f4disco.go
+++ b/src/machine/board_stm32f4disco.go
@@ -38,7 +38,7 @@ var (
TxAltFuncSelector: AF7_USART1_2_3,
RxAltFuncSelector: AF7_USART1_2_3,
}
- Serial = UART1
+ DefaultUART = UART1
)
// set up RX IRQ handler. Follow similar pattern for other UARTx instances
diff --git a/src/machine/board_teensy36.go b/src/machine/board_teensy36.go
index 0808b4b35..8fa71f6e9 100644
--- a/src/machine/board_teensy36.go
+++ b/src/machine/board_teensy36.go
@@ -87,6 +87,8 @@ var (
TeensyUART5 = UART4
)
+var DefaultUART = UART0
+
const (
defaultUART0RX = D00
defaultUART0TX = D01
diff --git a/src/machine/board_teensy40.go b/src/machine/board_teensy40.go
index 54ae4e6b4..289edadd8 100644
--- a/src/machine/board_teensy40.go
+++ b/src/machine/board_teensy40.go
@@ -136,9 +136,9 @@ const (
)
var (
- Serial = UART1
- UART1 = &_UART1
- _UART1 = UART{
+ DefaultUART = UART1
+ UART1 = &_UART1
+ _UART1 = UART{
Bus: nxp.LPUART6,
Buffer: NewRingBuffer(),
txBuffer: NewRingBuffer(),
diff --git a/src/machine/board_wioterminal.go b/src/machine/board_wioterminal.go
index abbe55500..57bbff1b5 100644
--- a/src/machine/board_wioterminal.go
+++ b/src/machine/board_wioterminal.go
@@ -325,8 +325,6 @@ const (
OUTPUT_CTR_3V3 = PC15
)
-var Serial = USB
-
// USBCDC pins
const (
USBCDC_DM_PIN = PIN_USB_DM
diff --git a/src/machine/board_x9pro.go b/src/machine/board_x9pro.go
index 63d7257a5..111dcf5fd 100644
--- a/src/machine/board_x9pro.go
+++ b/src/machine/board_x9pro.go
@@ -27,4 +27,4 @@ const (
const HasLowFrequencyCrystal = true
-var Serial = UART0
+var DefaultUART = UART0
diff --git a/src/machine/machine_atmega.go b/src/machine/machine_atmega.go
index fe6536e7f..6e2b59cf1 100644
--- a/src/machine/machine_atmega.go
+++ b/src/machine/machine_atmega.go
@@ -122,7 +122,7 @@ func (i2c *I2C) readByte() byte {
}
// Always use UART0 as the serial output.
-var Serial = UART0
+var DefaultUART = UART0
// UART
var (
diff --git a/src/machine/machine_esp32.go b/src/machine/machine_esp32.go
index ee3f61de1..b5f801b49 100644
--- a/src/machine/machine_esp32.go
+++ b/src/machine/machine_esp32.go
@@ -251,6 +251,8 @@ func (p Pin) mux() *volatile.Register32 {
}
}
+var DefaultUART = UART0
+
var (
UART0 = &_UART0
_UART0 = UART{Bus: esp.UART0, Buffer: NewRingBuffer()}
diff --git a/src/machine/machine_esp8266.go b/src/machine/machine_esp8266.go
index e8a9ecf64..72c672066 100644
--- a/src/machine/machine_esp8266.go
+++ b/src/machine/machine_esp8266.go
@@ -139,6 +139,8 @@ func (p Pin) PortMaskClear() (*uint32, uint32) {
return &esp.GPIO.GPIO_OUT_W1TC.Reg, 1 << p
}
+var DefaultUART = UART0
+
// UART0 is a hardware UART that supports both TX and RX.
var UART0 = &_UART0
var _UART0 = UART{Buffer: NewRingBuffer()}
diff --git a/src/machine/machine_generic.go b/src/machine/machine_generic.go
index 98dca2df8..70551e27a 100644
--- a/src/machine/machine_generic.go
+++ b/src/machine/machine_generic.go
@@ -11,6 +11,12 @@ var (
USB = &UART{100}
)
+// The Serial port always points to the default UART in a simulated environment.
+//
+// TODO: perhaps this should be a special serial object that outputs via WASI
+// stdout calls.
+var Serial = UART0
+
const (
PinInput PinMode = iota
PinOutput
@@ -118,12 +124,6 @@ type UART struct {
Bus uint8
}
-type UARTConfig struct {
- BaudRate uint32
- TX Pin
- RX Pin
-}
-
// Configure the UART.
func (uart *UART) Configure(config UARTConfig) {
uartConfigure(uart.Bus, config.TX, config.RX)
diff --git a/src/machine/machine_rp2040.go b/src/machine/machine_rp2040.go
index f7580967a..297c92e3b 100644
--- a/src/machine/machine_rp2040.go
+++ b/src/machine/machine_rp2040.go
@@ -108,7 +108,7 @@ var (
}
)
-var Serial = UART0
+var DefaultUART = UART0
func init() {
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
diff --git a/src/machine/serial-none.go b/src/machine/serial-none.go
new file mode 100644
index 000000000..22e94cc90
--- /dev/null
+++ b/src/machine/serial-none.go
@@ -0,0 +1,6 @@
+// +build baremetal,serial.none
+
+package machine
+
+// Serial is a null device: writes to it are ignored.
+var Serial = NullSerial{}
diff --git a/src/machine/serial-uart.go b/src/machine/serial-uart.go
new file mode 100644
index 000000000..d3edf832f
--- /dev/null
+++ b/src/machine/serial-uart.go
@@ -0,0 +1,6 @@
+// +build baremetal,serial.uart
+
+package machine
+
+// Serial is implemented via the default (usually the first) UART on the chip.
+var Serial = DefaultUART
diff --git a/src/machine/serial-usb.go b/src/machine/serial-usb.go
new file mode 100644
index 000000000..476d4b0cf
--- /dev/null
+++ b/src/machine/serial-usb.go
@@ -0,0 +1,6 @@
+// +build baremetal,serial.usb
+
+package machine
+
+// Serial is implemented via USB (USB-CDC).
+var Serial = USB
diff --git a/src/machine/serial.go b/src/machine/serial.go
new file mode 100644
index 000000000..fd02d6ca0
--- /dev/null
+++ b/src/machine/serial.go
@@ -0,0 +1,46 @@
+package machine
+
+import "errors"
+
+var errNoByte = errors.New("machine: no byte read")
+
+// UARTConfig is a struct with which a UART (or similar object) can be
+// configured. The baud rate is usually respected, but TX and RX may be ignored
+// depending on the chip and the type of object.
+type UARTConfig struct {
+ BaudRate uint32
+ TX Pin
+ RX Pin
+}
+
+// NullSerial is a serial version of /dev/null (or null router): it drops
+// everything that is written to it.
+type NullSerial struct {
+}
+
+// Configure does nothing: the null serial has no configuration.
+func (ns NullSerial) Configure(config UARTConfig) error {
+ return nil
+}
+
+// WriteByte is a no-op: the null serial doesn't write bytes.
+func (ns NullSerial) WriteByte(b byte) error {
+ return nil
+}
+
+// ReadByte always returns an error because there aren't any bytes to read.
+func (ns NullSerial) ReadByte() (byte, error) {
+ return 0, errNoByte
+}
+
+// Buffered returns how many bytes are buffered in the UART. It always returns 0
+// as there are no bytes to read.
+func (ns NullSerial) Buffered() int {
+ return 0
+}
+
+// Write is a no-op: none of the data is being written and it will not return an
+// error.
+func (ns NullSerial) Write(p []byte) (n int, err error) {
+ return len(p), nil
+}
diff --git a/src/machine/uart.go b/src/machine/uart.go
index 701fb9797..8fbac8711 100644
--- a/src/machine/uart.go
+++ b/src/machine/uart.go
@@ -23,12 +23,6 @@ const (
ParityOdd UARTParity = 2
)
-type UARTConfig struct {
- BaudRate uint32
- TX Pin
- RX Pin
-}
-
// To implement the UART interface for a board, you must declare a concrete type as follows:
//
// type UART struct {
diff --git a/targets/arduino-mkr1000.json b/targets/arduino-mkr1000.json
index a5abfca52..89d7bfa69 100644
--- a/targets/arduino-mkr1000.json
+++ b/targets/arduino-mkr1000.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd21g18a"],
"build-tags": ["arduino_mkr1000"],
+ "serial": "usb",
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
"flash-1200-bps-reset": "true"
}
diff --git a/targets/arduino-zero.json b/targets/arduino-zero.json
index 50483512e..045bb8c05 100644
--- a/targets/arduino-zero.json
+++ b/targets/arduino-zero.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd21g18a"],
"build-tags": ["arduino_zero"],
+ "serial": "usb",
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
"flash-1200-bps-reset": "true"
}
diff --git a/targets/atmega1280.json b/targets/atmega1280.json
index 21324a36d..2b0bfde7b 100644
--- a/targets/atmega1280.json
+++ b/targets/atmega1280.json
@@ -2,6 +2,7 @@
"inherits": ["avr"],
"cpu": "atmega1280",
"build-tags": ["atmega1280", "atmega"],
+ "serial": "uart",
"cflags": [
"-mmcu=atmega1280"
],
diff --git a/targets/atmega1284p.json b/targets/atmega1284p.json
index 2c2d29e18..3fbecd4b7 100644
--- a/targets/atmega1284p.json
+++ b/targets/atmega1284p.json
@@ -2,6 +2,7 @@
"inherits": ["avr"],
"cpu": "atmega1284p",
"build-tags": ["atmega1284p", "atmega"],
+ "serial": "uart",
"cflags": [
"-mmcu=atmega1284p"
],
diff --git a/targets/atmega2560.json b/targets/atmega2560.json
index f460c9c89..9caa088cf 100644
--- a/targets/atmega2560.json
+++ b/targets/atmega2560.json
@@ -2,6 +2,7 @@
"inherits": ["avr"],
"cpu": "atmega2560",
"build-tags": ["atmega2560", "atmega"],
+ "serial": "uart",
"cflags": [
"-mmcu=atmega2560"
],
diff --git a/targets/atmega328p.json b/targets/atmega328p.json
index 7a10eceba..24a272147 100644
--- a/targets/atmega328p.json
+++ b/targets/atmega328p.json
@@ -2,6 +2,7 @@
"inherits": ["avr"],
"cpu": "atmega328p",
"build-tags": ["atmega328p", "atmega", "avr5"],
+ "serial": "uart",
"cflags": [
"-mmcu=atmega328p"
],
diff --git a/targets/atsamd21e18a.json b/targets/atsamd21e18a.json
index 0fcf50675..92b671c9f 100644
--- a/targets/atsamd21e18a.json
+++ b/targets/atsamd21e18a.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m0plus"],
"build-tags": ["atsamd21e18a", "atsamd21e18", "atsamd21", "sam"],
+ "serial": "usb",
"linkerscript": "targets/atsamd21.ld",
"extra-files": [
"src/device/sam/atsamd21e18a.s"
diff --git a/targets/atsamd21g18a.json b/targets/atsamd21g18a.json
index 956afba54..db46c9628 100644
--- a/targets/atsamd21g18a.json
+++ b/targets/atsamd21g18a.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m0plus"],
"build-tags": ["atsamd21g18a", "atsamd21g18", "atsamd21", "sam"],
+ "serial": "usb",
"linkerscript": "targets/atsamd21.ld",
"extra-files": [
"src/device/sam/atsamd21g18a.s"
diff --git a/targets/atsame54-xpro.json b/targets/atsame54-xpro.json
index 631df8cfb..1ab7c4eea 100644
--- a/targets/atsame54-xpro.json
+++ b/targets/atsame54-xpro.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsame54p20a"],
"build-tags": ["atsame54_xpro"],
+ "serial": "usb",
"flash-method": "openocd",
"openocd-interface": "cmsis-dap",
"default-stack-size": 4096
diff --git a/targets/bluepill.json b/targets/bluepill.json
index 9f1e4b004..752261f4d 100644
--- a/targets/bluepill.json
+++ b/targets/bluepill.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m3"],
"build-tags": ["bluepill", "stm32f103", "stm32f1", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32.ld",
"extra-files": [
"src/device/stm32/stm32f103.s"
diff --git a/targets/circuitplay-bluefruit.json b/targets/circuitplay-bluefruit.json
index 24bf5577f..0c1f6ae3b 100644
--- a/targets/circuitplay-bluefruit.json
+++ b/targets/circuitplay-bluefruit.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["circuitplay_bluefruit","nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8045", "acm:239a:45"],
diff --git a/targets/clue-alpha.json b/targets/clue-alpha.json
index e2594ea7d..ebe83f79d 100644
--- a/targets/clue-alpha.json
+++ b/targets/clue-alpha.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["clue_alpha","nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "CLUEBOOT",
diff --git a/targets/esp32.json b/targets/esp32.json
index 3559e8920..ded861624 100644
--- a/targets/esp32.json
+++ b/targets/esp32.json
@@ -3,6 +3,7 @@
"cpu": "esp32",
"build-tags": ["esp32", "esp"],
"scheduler": "tasks",
+ "serial": "uart",
"linker": "xtensa-esp32-elf-ld",
"default-stack-size": 2048,
"cflags": [
diff --git a/targets/feather-m4-can.json b/targets/feather-m4-can.json
index 190d4d8f9..22222622f 100644
--- a/targets/feather-m4-can.json
+++ b/targets/feather-m4-can.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsame51j19a"],
"build-tags": ["feather_m4_can"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FTHRCANBOOT",
diff --git a/targets/feather-m4.json b/targets/feather-m4.json
index ccf06ec54..408946297 100644
--- a/targets/feather-m4.json
+++ b/targets/feather-m4.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51j19a"],
"build-tags": ["feather_m4"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FEATHERBOOT",
diff --git a/targets/feather-nrf52840.json b/targets/feather-nrf52840.json
index f0b706186..c334f7065 100644
--- a/targets/feather-nrf52840.json
+++ b/targets/feather-nrf52840.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["feather_nrf52840","nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "FTHR840BOOT",
diff --git a/targets/feather-stm32f405.json b/targets/feather-stm32f405.json
index d3bb1dc9c..3d824d1ed 100644
--- a/targets/feather-stm32f405.json
+++ b/targets/feather-stm32f405.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m4"],
"build-tags": ["feather_stm32f405", "stm32f405", "stm32f4", "stm32"],
+ "serial": "uart",
"automatic-stack-size": false,
"linkerscript": "targets/stm32f405.ld",
"extra-files": [
diff --git a/targets/grandcentral-m4.json b/targets/grandcentral-m4.json
index 4545dfd9f..7b374c98e 100644
--- a/targets/grandcentral-m4.json
+++ b/targets/grandcentral-m4.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51p20a"],
"build-tags": ["grandcentral_m4"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "GCM4BOOT",
diff --git a/targets/hifive1-qemu.json b/targets/hifive1-qemu.json
index 9a50cee64..60fe27a4d 100644
--- a/targets/hifive1-qemu.json
+++ b/targets/hifive1-qemu.json
@@ -1,6 +1,7 @@
{
"inherits": ["fe310"],
"build-tags": ["hifive1b", "qemu"],
+ "serial": "uart",
"linkerscript": "targets/hifive1-qemu.ld",
"emulator": ["qemu-system-riscv32", "-machine", "sifive_e", "-nographic", "-kernel"]
}
diff --git a/targets/hifive1b.json b/targets/hifive1b.json
index bd561ae0b..1084531b3 100644
--- a/targets/hifive1b.json
+++ b/targets/hifive1b.json
@@ -1,6 +1,7 @@
{
"inherits": ["fe310"],
"build-tags": ["hifive1b"],
+ "serial": "uart",
"linkerscript": "targets/hifive1b.ld",
"flash-method": "msd",
"msd-volume-name": "HiFive",
diff --git a/targets/itsybitsy-m4.json b/targets/itsybitsy-m4.json
index 9c7a634ba..af4027a4a 100644
--- a/targets/itsybitsy-m4.json
+++ b/targets/itsybitsy-m4.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51g19a"],
"build-tags": ["itsybitsy_m4"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:802b", "acm:239a:002b"],
diff --git a/targets/itsybitsy-nrf52840.json b/targets/itsybitsy-nrf52840.json
index b8637fd00..aab873c18 100644
--- a/targets/itsybitsy-nrf52840.json
+++ b/targets/itsybitsy-nrf52840.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["itsybitsy_nrf52840","nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "ITSY840BOOT",
diff --git a/targets/lgt92.json b/targets/lgt92.json
index 82c603a9b..23bc84dd2 100644
--- a/targets/lgt92.json
+++ b/targets/lgt92.json
@@ -5,6 +5,7 @@
"build-tags": [
"lgt92"
],
+ "serial": "uart",
"linkerscript": "targets/stm32l072czt6.ld",
"flash-method": "openocd",
"openocd-interface": "stlink-v2",
diff --git a/targets/maixbit.json b/targets/maixbit.json
index 21322072a..8f6216162 100644
--- a/targets/maixbit.json
+++ b/targets/maixbit.json
@@ -1,6 +1,7 @@
{
"inherits": ["k210"],
"build-tags": ["maixbit"],
+ "serial": "uart",
"linkerscript": "targets/maixbit.ld",
"flash-command": "kflash -p {port} --noansi --verbose {bin}"
}
diff --git a/targets/metro-m4-airlift.json b/targets/metro-m4-airlift.json
index a282ac55a..5783a4336 100644
--- a/targets/metro-m4-airlift.json
+++ b/targets/metro-m4-airlift.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51j19a"],
"build-tags": ["metro_m4_airlift"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "METROM4BOOT",
diff --git a/targets/microbit-v2.json b/targets/microbit-v2.json
index 33a9392eb..c8c7461c3 100644
--- a/targets/microbit-v2.json
+++ b/targets/microbit-v2.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52833"],
"build-tags": ["microbit_v2"],
+ "serial": "uart",
"flash-method": "msd",
"openocd-interface": "cmsis-dap",
"msd-volume-name": "MICROBIT",
diff --git a/targets/microbit.json b/targets/microbit.json
index 1b677c5d3..a890100da 100644
--- a/targets/microbit.json
+++ b/targets/microbit.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf51"],
"build-tags": ["microbit"],
+ "serial": "uart",
"flash-method": "msd",
"openocd-interface": "cmsis-dap",
"msd-volume-name": "MICROBIT",
diff --git a/targets/nicenano.json b/targets/nicenano.json
index 3a406ea5c..b18a0c1ca 100644
--- a/targets/nicenano.json
+++ b/targets/nicenano.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["nicenano","nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "NICENANO",
diff --git a/targets/nodemcu.json b/targets/nodemcu.json
index c1fdbec06..c8c6c4039 100644
--- a/targets/nodemcu.json
+++ b/targets/nodemcu.json
@@ -1,4 +1,5 @@
{
"inherits": ["esp8266"],
- "build-tags": ["nodemcu"]
+ "build-tags": ["nodemcu"],
+ "serial": "uart"
}
diff --git a/targets/nrf52840-mdk-usb-dongle.json b/targets/nrf52840-mdk-usb-dongle.json
index fa4c72256..34e76b779 100644
--- a/targets/nrf52840-mdk-usb-dongle.json
+++ b/targets/nrf52840-mdk-usb-dongle.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["nrf52840_mdk_usb_dongle", "nrf52840_reset_uf2", "softdevice", "s140v6"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "MDK-DONGLE",
diff --git a/targets/nrf52840-mdk.json b/targets/nrf52840-mdk.json
index 244b3d96d..03528e501 100644
--- a/targets/nrf52840-mdk.json
+++ b/targets/nrf52840-mdk.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["nrf52840_mdk"],
+ "serial": "usb",
"flash-method": "openocd",
"openocd-interface": "cmsis-dap"
}
diff --git a/targets/nucleo-f103rb.json b/targets/nucleo-f103rb.json
index 1c12af847..723c5eef9 100644
--- a/targets/nucleo-f103rb.json
+++ b/targets/nucleo-f103rb.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m3"],
"build-tags": ["nucleof103rb", "stm32f103", "stm32f1","stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32f103rb.ld",
"extra-files": [
"src/device/stm32/stm32f103.s"
diff --git a/targets/nucleo-f722ze.json b/targets/nucleo-f722ze.json
index 25a388b9e..f426b332d 100644
--- a/targets/nucleo-f722ze.json
+++ b/targets/nucleo-f722ze.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m7"],
"build-tags": ["nucleof722ze", "stm32f7x2", "stm32f7", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32f7x2zetx.ld",
"extra-files": [
"src/device/stm32/stm32f7x2.s"
diff --git a/targets/nucleo-l031k6.json b/targets/nucleo-l031k6.json
index 928dd43dc..eed8f38f0 100644
--- a/targets/nucleo-l031k6.json
+++ b/targets/nucleo-l031k6.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m0"],
"build-tags": ["nucleol031k6", "stm32l031", "stm32l0x1", "stm32l0", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32l031k6.ld",
"extra-files": [
"src/device/stm32/stm32l0x1.s"
diff --git a/targets/nucleo-l432kc.json b/targets/nucleo-l432kc.json
index f13c8bde4..028b034b0 100644
--- a/targets/nucleo-l432kc.json
+++ b/targets/nucleo-l432kc.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m4"],
"build-tags": ["nucleol432kc", "stm32l432", "stm32l4x2", "stm32l4", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32l4x2.ld",
"extra-files": [
"src/device/stm32/stm32l4x2.s"
diff --git a/targets/nucleo-l552ze.json b/targets/nucleo-l552ze.json
index 56e286ab5..044b58371 100644
--- a/targets/nucleo-l552ze.json
+++ b/targets/nucleo-l552ze.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m33"],
"build-tags": ["nucleol552ze", "stm32l552", "stm32l5x2", "stm32l5", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32l5x2xe.ld",
"extra-files": [
"src/device/stm32/stm32l552.s"
diff --git a/targets/particle-3rd-gen.json b/targets/particle-3rd-gen.json
index 2229319e7..ef39a7340 100644
--- a/targets/particle-3rd-gen.json
+++ b/targets/particle-3rd-gen.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["particle_3rd_gen"],
+ "serial": "uart",
"flash-method": "openocd",
"openocd-interface": "cmsis-dap"
}
diff --git a/targets/pca10031.json b/targets/pca10031.json
index cccae828a..8af365cc8 100644
--- a/targets/pca10031.json
+++ b/targets/pca10031.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf51"],
"build-tags": ["pca10031"],
+ "serial": "uart",
"flash-command": "nrfjprog -f nrf51 --sectorerase --program {hex} --reset",
"openocd-interface": "cmsis-dap"
}
diff --git a/targets/pca10040.json b/targets/pca10040.json
index 7685be427..b751b3bd6 100644
--- a/targets/pca10040.json
+++ b/targets/pca10040.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52"],
"build-tags": ["pca10040"],
+ "serial": "uart",
"flash-method": "openocd",
"flash-command": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset",
"openocd-interface": "jlink",
diff --git a/targets/pca10056.json b/targets/pca10056.json
index fc0acaa0a..b604624cf 100644
--- a/targets/pca10056.json
+++ b/targets/pca10056.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["pca10056"],
+ "serial": "uart",
"flash-method": "command",
"flash-command": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset",
"msd-volume-name": "JLINK",
diff --git a/targets/pca10059.json b/targets/pca10059.json
index 5a8eb8265..b5286e989 100644
--- a/targets/pca10059.json
+++ b/targets/pca10059.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["pca10059"],
+ "serial": "usb",
"linkerscript": "targets/pca10059.ld",
"binary-format": "nrf-dfu",
"flash-command": "nrfutil dfu usb-serial -pkg {zip} -p {port} -b 115200"
diff --git a/targets/pico.json b/targets/pico.json
index 011d5110f..36e3ba30e 100644
--- a/targets/pico.json
+++ b/targets/pico.json
@@ -3,6 +3,7 @@
"rp2040"
],
"build-tags": ["pico"],
+ "serial": "uart",
"linkerscript": "targets/pico.ld",
"extra-files": [
"targets/pico-boot-stage2.S"
diff --git a/targets/pinetime-devkit0.json b/targets/pinetime-devkit0.json
index adbe874ae..8655769ee 100644
--- a/targets/pinetime-devkit0.json
+++ b/targets/pinetime-devkit0.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52"],
"build-tags": ["pinetime_devkit0"],
+ "serial": "uart",
"flash-method": "openocd",
"flash-command": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset",
"openocd-interface": "jlink",
diff --git a/targets/pybadge.json b/targets/pybadge.json
index b76b32469..15af8f8a9 100644
--- a/targets/pybadge.json
+++ b/targets/pybadge.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51j19a"],
"build-tags": ["pybadge"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8033", "acm:239a:33"],
diff --git a/targets/pygamer.json b/targets/pygamer.json
index 63dc34a18..03147e08a 100644
--- a/targets/pygamer.json
+++ b/targets/pygamer.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51j19a"],
"build-tags": ["pygamer"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "PYGAMERBOOT",
diff --git a/targets/pyportal.json b/targets/pyportal.json
index a26d82f08..abda3ab18 100644
--- a/targets/pyportal.json
+++ b/targets/pyportal.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51j20a"],
"build-tags": ["pyportal"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"serial-port": ["acm:239a:8035", "acm:239a:35", "acm:239a:8036"],
diff --git a/targets/reelboard.json b/targets/reelboard.json
index 60aeb1cfd..b6da0a449 100644
--- a/targets/reelboard.json
+++ b/targets/reelboard.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52840"],
"build-tags": ["reelboard"],
+ "serial": "uart",
"flash-method": "msd",
"msd-volume-name": "reel-board",
"msd-firmware-name": "firmware.hex",
diff --git a/targets/stm32f4disco.json b/targets/stm32f4disco.json
index 622c5b0d6..4485c41d3 100644
--- a/targets/stm32f4disco.json
+++ b/targets/stm32f4disco.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m4"],
"build-tags": ["stm32f4disco", "stm32f407", "stm32f4", "stm32"],
+ "serial": "uart",
"linkerscript": "targets/stm32f407.ld",
"extra-files": [
"src/device/stm32/stm32f407.s"
diff --git a/targets/teensy36.json b/targets/teensy36.json
index c341511ec..253e39704 100644
--- a/targets/teensy36.json
+++ b/targets/teensy36.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m4"],
"build-tags": ["teensy36", "teensy", "mk66f18", "nxp"],
+ "serial": "uart",
"linkerscript": "targets/nxpmk66f18.ld",
"extra-files": [
"src/device/nxp/mk66f18.s",
diff --git a/targets/teensy40.json b/targets/teensy40.json
index d08b8d1dd..c530003b3 100644
--- a/targets/teensy40.json
+++ b/targets/teensy40.json
@@ -1,6 +1,7 @@
{
"inherits": ["cortex-m7"],
"build-tags": ["teensy40", "teensy", "mimxrt1062", "nxp"],
+ "serial": "uart",
"automatic-stack-size": false,
"default-stack-size": 4096,
"linkerscript": "targets/mimxrt1062-teensy40.ld",
diff --git a/targets/wioterminal.json b/targets/wioterminal.json
index 093947e16..1f81b928f 100644
--- a/targets/wioterminal.json
+++ b/targets/wioterminal.json
@@ -1,6 +1,7 @@
{
"inherits": ["atsamd51p19a"],
"build-tags": ["wioterminal"],
+ "serial": "usb",
"flash-1200-bps-reset": "true",
"flash-method": "msd",
"msd-volume-name": "Arduino",
diff --git a/targets/x9pro.json b/targets/x9pro.json
index a9ecc0c83..9b966b4b9 100644
--- a/targets/x9pro.json
+++ b/targets/x9pro.json
@@ -1,6 +1,7 @@
{
"inherits": ["nrf52"],
"build-tags": ["x9pro"],
+ "serial": "uart",
"flash-method": "openocd",
"flash-command": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset",
"openocd-interface": "jlink",