From df3d7099df5416f1ad37dc7140abf77a629f791d Mon Sep 17 00:00:00 2001 From: Scott Feldman Date: Sat, 18 Jan 2025 00:51:52 -0800 Subject: [PATCH 1/3] add support for Elecrow Pico rp2040 W5 boards https://www.elecrow.com/pico-w5-microcontroller-development-boards-rp2040-microcontroller-board-support-wifi-2-4ghz-5ghz-bluetooth5.html Just the basics to get several test to work (blinky1, flash). This board has an rtl8720d Wifi/bluetooth chip wired to UART1, but the rtl8720d firmware installed is the AT cmd set, not the RPC interface used by the rtl8720dn driver, so no wifi support at the moment. --- src/machine/board_elecrow-rp2040-w5.go | 94 ++++++++++++++++++++++++++ targets/elecrow-rp2040.json | 12 ++++ 2 files changed, 106 insertions(+) create mode 100644 src/machine/board_elecrow-rp2040-w5.go create mode 100644 targets/elecrow-rp2040.json diff --git a/src/machine/board_elecrow-rp2040-w5.go b/src/machine/board_elecrow-rp2040-w5.go new file mode 100644 index 0000000000..1ea0181d1f --- /dev/null +++ b/src/machine/board_elecrow-rp2040-w5.go @@ -0,0 +1,94 @@ +//go:build elecrow_rp2040 + +// This file contains the pin mappings for the Elecrow Pico rp2040 W5 boards. +// +// Elecrow Pico rp2040 W5 is a microcontroller using the Raspberry Pi RP2040 +// chip and rtl8720d Wifi chip. +// +// - https://www.elecrow.com/wiki/PICO_W5_RP2040_Dev_Board.html +package machine + +// GPIO pins +const ( + GP0 Pin = GPIO0 + GP1 Pin = GPIO1 + GP2 Pin = GPIO2 + GP3 Pin = GPIO3 + GP4 Pin = GPIO4 + GP5 Pin = GPIO5 + GP6 Pin = GPIO6 + GP7 Pin = GPIO7 + GP8 Pin = GPIO8 + GP9 Pin = GPIO9 + GP10 Pin = GPIO10 + GP11 Pin = GPIO11 + GP12 Pin = GPIO12 + GP13 Pin = GPIO13 + GP14 Pin = GPIO14 + GP15 Pin = GPIO15 + GP16 Pin = GPIO16 + GP17 Pin = GPIO17 + GP18 Pin = GPIO18 + GP19 Pin = GPIO19 + GP20 Pin = GPIO20 + GP21 Pin = GPIO21 + GP22 Pin = GPIO22 + GP26 Pin = GPIO26 + GP27 Pin = GPIO27 + GP28 Pin = GPIO28 + + // Onboard LED + LED Pin = GPIO25 + + // Onboard crystal oscillator frequency, in MHz. + xoscFreq = 12 // MHz +) + +// I2C Default pins on Raspberry Pico. +const ( + I2C0_SDA_PIN = GP4 + I2C0_SCL_PIN = GP5 + + I2C1_SDA_PIN = GP2 + I2C1_SCL_PIN = GP3 +) + +// SPI default pins +const ( + // Default Serial Clock Bus 0 for SPI communications + SPI0_SCK_PIN = GPIO18 + // Default Serial Out Bus 0 for SPI communications + SPI0_SDO_PIN = GPIO19 // Tx + // Default Serial In Bus 0 for SPI communications + SPI0_SDI_PIN = GPIO16 // Rx + + // Default Serial Clock Bus 1 for SPI communications + SPI1_SCK_PIN = GPIO10 + // Default Serial Out Bus 1 for SPI communications + SPI1_SDO_PIN = GPIO11 // Tx + // Default Serial In Bus 1 for SPI communications + SPI1_SDI_PIN = GPIO12 // Rx +) + +// UART pins +const ( + UART0_TX_PIN = GPIO0 + UART0_RX_PIN = GPIO1 + UART1_TX_PIN = GPIO4 // Wired to rtl8720d UART1_Tx + UART1_RX_PIN = GPIO5 // Wired to rtl8720n UART1_Rx + UART_TX_PIN = UART0_TX_PIN + UART_RX_PIN = UART0_RX_PIN +) + +var DefaultUART = UART0 + +// USB identifiers +const ( + usb_STRING_PRODUCT = "Pico" + usb_STRING_MANUFACTURER = "Raspberry Pi" +) + +var ( + usb_VID uint16 = 0x2E8A + usb_PID uint16 = 0x000A +) diff --git a/targets/elecrow-rp2040.json b/targets/elecrow-rp2040.json new file mode 100644 index 0000000000..07391a6ee0 --- /dev/null +++ b/targets/elecrow-rp2040.json @@ -0,0 +1,12 @@ +{ + "inherits": ["rp2040"], + "build-tags": ["elecrow_rp2040"], + "serial-port": ["2e8a:000a"], + "default-stack-size": 8192, + "ldflags": [ + "--defsym=__flash_size=8M" + ], + "extra-files": [ + "targets/pico-boot-stage2.S" + ] +} From 918757e1bb15ac9982c399ddebd6a56f39d148cf Mon Sep 17 00:00:00 2001 From: Scott Feldman Date: Sat, 18 Jan 2025 23:44:50 -0800 Subject: [PATCH 2/3] add elecrow_rp2040 target to smoke tests --- GNUmakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 099aab0ced..ed1678d10a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -861,6 +861,8 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=tkey examples/blinky1 @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=elecrow_rp2040 examples/blinky1 + @$(MD5SUM) test.hex ifneq ($(WASM), 0) $(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/export $(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/main From 0d8f5482af01fef80421d63047c476a2fd783a4d Mon Sep 17 00:00:00 2001 From: Scott Feldman Date: Sun, 19 Jan 2025 00:04:44 -0800 Subject: [PATCH 3/3] fix elecrow-rp2040 target name in smoke tests --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index ed1678d10a..91e4f215b0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -861,7 +861,7 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=tkey examples/blinky1 @$(MD5SUM) test.hex - $(TINYGO) build -size short -o test.hex -target=elecrow_rp2040 examples/blinky1 + $(TINYGO) build -size short -o test.hex -target=elecrow-rp2040 examples/blinky1 @$(MD5SUM) test.hex ifneq ($(WASM), 0) $(TINYGO) build -size short -o wasm.wasm -target=wasm examples/wasm/export