Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Microcontroller with TinyGo",
"type": "cortex-debug",
"request": "launch",
"servertype": "external",
"cwd": "${workspaceRoot}",
"executable": "${workspaceFolder}/build/devicecode.elf",
"preLaunchTask": "TinyGo Build",
"configFiles": [
"${workspaceFolder}/debug/openocd.cfg"
],
"gdbTarget": "localhost:3060",
"interface": "swd",
"postLaunchCommands": [
"monitor reset"
],
"postDebugTask": "Stop OpenOCD"
}
]
}
"version": "0.2.0",
"configurations": [
{
"name": "Debug Pico (rp2040)",
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/build/devicecode.elf",
"preLaunchTask": "TinyGo Build (rp2040)",
"configFiles": [
"debug/openocd_rp2040.cfg"
],
"interface": "swd",
"postLaunchCommands": ["monitor reset"]
},
{
"name": "Debug Pico 2 (rp2350)",
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/build/devicecode.elf",
"preLaunchTask": "TinyGo Build (rp2350)",
"configFiles": [
"debug/openocd_rp2350.cfg"
],
"interface": "swd",
"postLaunchCommands": ["monitor reset"]
}
]
}
57 changes: 25 additions & 32 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@
"version": "2.0.0",
"tasks": [
{
"label": "Run OpenOCD",
"label": "TinyGo Build (rp2040)",
"type": "shell",
"command": "openocd -f ${workspaceFolder}/debug/openocd.cfg",
"isBackground": true,
"problemMatcher": {
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
// Start checking output as soon as OpenOCD starts
"beginsPattern": ".",
// Adjust this line if your OpenOCD prints a different β€œready” message
"endsPattern": "for telnet connections"
}
}
"command": "tinygo",
"args": [
"build",
"-o", "${workspaceFolder}/build/devicecode.elf",
"-stack-size=3KB",
"-serial=none",
"-target=pico",
"-tags", "pico_bb_proto_1",
"-scheduler=tasks"
],
"problemMatcher": []
},
{
"label": "TinyGo Build",
"label": "TinyGo Build (rp2350)",
"type": "shell",
"command": "tinygo build -o ${workspaceFolder}/build/devicecode.elf -stack-size=3KB -serial=none -target=pico -tags pico_bb_proto_1 -scheduler=tasks",
"problemMatcher": [],
"dependsOn": ["Run OpenOCD"]
},
{
"label": "Stop OpenOCD",
"type": "process",
"command": "pkill",
"args": ["-f", "openocd"],
"problemMatcher": []
"command": "tinygo",
"args": [
"build",
"-o", "${workspaceFolder}/build/devicecode.elf",
"-stack-size=3KB",
"-serial=none",
"-target=pico2",
"-tags", "pico_bb_proto_1",
"-scheduler=tasks"
],
"problemMatcher": []
}
]
}
}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# devicecode-go

## Flashing ISOC Power Board via USB port on Pico
tinygo flash -stack-size=3KB -monitor -scheduler tasks -target=pico -tags "pico_bb_proto_1" main.go

## Flashing ISOC Power Board via USB port on Pico2
tinygo flash -stack-size=3KB -monitor -scheduler tasks -target=pico2 -tags "pico_bb_proto_1" main.go

-------------------

## Debugging instructions

The following instructions set you up debugging the code on an MCU, using a Pico debug module, connected to a Mac (tested on arm64).
Expand All @@ -20,8 +28,11 @@ The Darwin Kernel requires the debugger to have special permissions before it is

### Build and debug from VSCode

- Select target from debug dropdown (Pico or Pico2)
- Press F5 to begin debugging

![alt text](/assets/image.png)

An OpenOCD server will be started, a GDB session started. Then the project will be built with flags specified in .vscode/tasks.json. Next, the compiled .elf file will be flashed to the MCU. The MCU will then be reset and control is handed over to you for the debug session.

You'll then be able to add breakpoints, pause, resume and reset the MCU remotely using VsCode debug tools.
Binary file added assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion debug/openocd.cfg β†’ debug/openocd_rp2040.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source [find interface/cmsis-dap.cfg]
source [find target/rp2040.cfg]

# Confugure Ports
gdb_port 3060
# gdb_port 3060 # (Seems to work without this - using cortex-debug default ports)
tcl_port disabled
telnet_port 4060

Expand Down
17 changes: 17 additions & 0 deletions debug/openocd_rp2350.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Source the config file for the Raspberry Pi Debug Probe
source [find interface/cmsis-dap.cfg]

# Source the config file for the RP2350 target MCU
source [find target/rp2350.cfg]

# Confugure Ports
# gdb_port 3060 # (Seems to work without this - using cortex-debug default ports)
tcl_port disabled
telnet_port 4060


# Set Adapter Speed in KHz (Lower speed may be needed for bootloader debugging).
adapter speed 5000

# init terminates the config stage and enters the run stage.
init
24 changes: 24 additions & 0 deletions services/hal/internal/provider/boards/pico2_default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build pico2

package boards

var SelectedBoard = Board{
Name: "raspberrypi_pico2",
GPIOMin: 0,
GPIOMax: 28,
I2C: []string{"i2c0", "i2c1"},
SPI: nil, // add when we expose SPI owners
UART: []string{"uart0", "uart1"},
Defaults: struct {
I2C0_SDA, I2C0_SCL int
I2C1_SDA, I2C1_SCL int
UART0_TX, UART0_RX int
UART1_TX, UART1_RX int
}{
// RP2040 default pins (GPIO numbers)
I2C0_SDA: 4, I2C0_SCL: 5,
I2C1_SDA: 2, I2C1_SCL: 3,
UART0_TX: 0, UART0_RX: 1,
UART1_TX: 8, UART1_RX: 9,
},
}
2 changes: 1 addition & 1 deletion services/hal/internal/provider/resources.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build rp2040
//go:build rp2040 || rp2350

package provider

Expand Down
2 changes: 1 addition & 1 deletion services/hal/internal/provider/rp2_resources.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build rp2040
//go:build rp2040 || rp2350

package provider

Expand Down
2 changes: 1 addition & 1 deletion services/hal/internal/provider/setup_none.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !(pico && (pico_rich_dev || pico_bb_proto_1))
//go:build !((rp2040 || rp2350) && (pico_rich_dev || pico_bb_proto_1))

package provider

Expand Down
2 changes: 1 addition & 1 deletion services/hal/internal/provider/setup_selected.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build pico && (pico_rich_dev || pico_bb_proto_1)
//go:build (rp2040 || rp2350) && (pico_rich_dev || pico_bb_proto_1)

package provider

Expand Down
2 changes: 1 addition & 1 deletion services/hal/internal/provider/setups/pico_bb_proto_1.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build pico && pico_bb_proto_1
//go:build (rp2040 || rp2350) && pico_bb_proto_1

package setups

Expand Down
2 changes: 1 addition & 1 deletion services/hal/internal/provider/setups/pico_rich_dev.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build pico && pico_rich_dev
//go:build (rp2040 || rp2350) && pico_rich_dev

package setups

Expand Down
2 changes: 1 addition & 1 deletion x/fmtx/fmtx_host.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !rp2040
//go:build !(rp2040 || rp2350)

package fmtx

Expand Down
2 changes: 1 addition & 1 deletion x/fmtx/fmtx_mcu.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build rp2040
//go:build rp2040 || rp2350

package fmtx

Expand Down
2 changes: 1 addition & 1 deletion x/strconvx/strconvx_host.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !rp2040
//go:build !(rp2040 || rp2350)

package strconvx

Expand Down
2 changes: 1 addition & 1 deletion x/strconvx/strconvx_mcu.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build rp2040
//go:build rp2040 || rp2350

package strconvx

Expand Down