Skip to content

Commit fd39672

Browse files
authored
Feature/debugger support (#65)
* wip: esp32-c3-devkit-rust add probe-rs configuration * wip: add OpenOCD configuration for esp32-c3 * wip: add Connect to Wokwi GDB * use custom chip simulation on Wokwi * Wokwi - switch to release to run in the simulator
1 parent 4fb44ba commit fd39672

File tree

6 files changed

+138
-40
lines changed

6 files changed

+138
-40
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# esp32-spooky-maze-game
22

3+
[![Wokwi](https://img.shields.io/endpoint?url=https%3A%2F%2Fwokwi.com%2Fbadge%2Fclick-to-simulate.json)](https://wokwi.com/projects/380658681618693121)
4+
35
Spooky Maze is simple game where ghost is located in the maze. The goal is to collect 100 coins.
46
The ghost can find artifact "Walker" which allows him to pass throght the wall for limited period of time.
57
The ghost can use dynamite to clear wall in the vicinity. The ghost can use also Teleport spell to move to random place in the maze.

esp32-c3-devkit-rust/.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[target.riscv32imac-unknown-none-elf]
22
runner = "espflash flash --monitor"
3+
#runner = "probe-rs run --chip esp32c3 --format idf"
4+
35
rustflags = [
46
"-C", "link-arg=-Tlinkall.x",
57
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "probe-rs-debug",
6+
"request": "launch",
7+
"name": "Flash & Debug with probe-rs",
8+
"cwd": "${workspaceFolder}",
9+
"chip": "esp32c3",
10+
"flashingConfig": {
11+
"flashingEnabled": true,
12+
"resetAfterFlashing": true,
13+
"haltAfterReset": true,
14+
"formatOptions": {
15+
"format": "idf"
16+
}
17+
},
18+
"coreConfigs": [
19+
{
20+
"coreIndex": 0,
21+
"programBinary": "${workspaceFolder}/target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3",
22+
"rttEnabled": true,
23+
"rttChannelFormats": [
24+
{
25+
"channelNumer": "0",
26+
"dataFormat": "String",
27+
"showTimestamp": true
28+
}
29+
]
30+
}
31+
]
32+
},
33+
{
34+
"type": "probe-rs-debug",
35+
"request": "attach",
36+
"name": "Attach to probe-rs debugger",
37+
"cwd": "${workspaceFolder}",
38+
"chip": "esp32c3",
39+
"coreConfigs": [
40+
{
41+
"coreIndex": 0,
42+
"programBinary": "${workspaceFolder}/target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3",
43+
"rttEnabled": true,
44+
"rttChannelFormats": [
45+
{
46+
"channelNumer": "0",
47+
"dataFormat": "String",
48+
"showTimestamp": true,
49+
}
50+
]
51+
}
52+
]
53+
},
54+
{
55+
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
56+
"name": "Attach to OpenOCD",
57+
"type": "cortex-debug",
58+
"request": "attach",
59+
"cwd": "${workspaceRoot}",
60+
"executable": "${workspaceFolder}/target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3",
61+
"servertype": "openocd",
62+
"interface": "jtag",
63+
"toolchainPrefix": "riscv32-esp-elf",
64+
"openOCDPreConfigLaunchCommands": ["set ESP_RTOS none"],
65+
"serverpath": "openocd",
66+
"configFiles": ["board/esp32c3-builtin.cfg"],
67+
"gdbPath": "${userHome}/.espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb",
68+
"overrideAttachCommands": [
69+
"set remote hardware-watchpoint-limit 2",
70+
"mon halt",
71+
"flushregs"
72+
],
73+
"overrideRestartCommands": ["mon reset halt", "flushregs", "c"]
74+
},
75+
{
76+
"name": "Attach to Wokwi GDB",
77+
"type": "cppdbg",
78+
"request": "launch",
79+
"program": "${workspaceFolder}/target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3",
80+
"cwd": "${workspaceFolder}",
81+
"MIMode": "gdb",
82+
"miDebuggerPath": "${userHome}/.espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb",
83+
"miDebuggerServerAddress": "localhost:3333"
84+
}
85+
]
86+
}
87+

esp32-c3-devkit-rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ hal = { package = "esp32c3-hal", version = "0.13.0" }
1010
esp-backtrace = { version = "0.9.0", features = [
1111
"esp32c3",
1212
"panic-handler",
13-
"print-uart",
13+
"print-rtt",
1414
] }
15-
esp-println = { version = "0.7.0", features = [ "esp32c3" ] }
15+
esp-println = { version = "0.7.0", default-features = false, features = [ "esp32c3", "rtt" ] }
1616

1717
[dependencies]
1818
esp-alloc = "0.3.0"

esp32-c3-devkit-rust/diagram.json

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
{
2-
"version": 1,
3-
"author": "Juraj Michálek",
4-
"editor": "wokwi",
5-
"parts": [
6-
{
7-
"type": "board-esp32-c3-rust-1",
8-
"id": "esp",
9-
"top": -494.32,
10-
"left": -455.03,
11-
"attrs": { "builder": "rust-std-esp32" }
12-
},
13-
{
14-
"type": "wokwi-ili9341",
15-
"id": "lcd1",
16-
"top": -546.22,
17-
"left": -134.92,
18-
"rotate": 90,
19-
"attrs": { "flipVertical": "1" }
20-
}
21-
],
22-
"connections": [
23-
[ "esp:21", "$serialMonitor:RX", "", [] ],
24-
[ "esp:20", "$serialMonitor:TX", "", [] ],
25-
[ "esp:3V3", "lcd1:VCC", "green", [] ],
26-
[ "esp:GND.1", "lcd1:GND", "black", [] ],
27-
[ "esp:0", "lcd1:SCK", "blue", [] ],
28-
[ "esp:6", "lcd1:MOSI", "orange", [] ],
29-
[ "esp:5", "lcd1:CS", "red", [] ],
30-
[ "esp:4", "lcd1:D/C", "magenta", [] ],
31-
[ "esp:3", "lcd1:RST", "yellow", [] ],
32-
[ "lcd1:LED", "esp:3V3", "white", [] ]
33-
],
34-
"serialMonitor": {
35-
"display": "terminal",
36-
"newline": "lf",
37-
"convertEol": true
2+
"version": 1,
3+
"author": "Juraj Michálek",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-c3-rust-1",
8+
"id": "esp",
9+
"top": -494.32,
10+
"left": -455.03,
11+
"attrs": { "builder": "rust-nostd-esp" }
3812
},
39-
"dependencies": {}
40-
}
13+
{
14+
"type": "wokwi-ili9341",
15+
"id": "lcd1",
16+
"top": -541.8,
17+
"left": -132.7,
18+
"rotate": 90,
19+
"attrs": { "flipVertical": "1" }
20+
},
21+
{ "type": "chip-icm42670p", "id": "imu1", "top": -248.58, "left": -302.4, "attrs": {} }
22+
],
23+
"connections": [
24+
[ "esp:21", "$serialMonitor:RX", "", [] ],
25+
[ "esp:20", "$serialMonitor:TX", "", [] ],
26+
[ "esp:3V3", "lcd1:VCC", "green", [] ],
27+
[ "esp:GND.1", "lcd1:GND", "black", [] ],
28+
[ "esp:0", "lcd1:SCK", "blue", [] ],
29+
[ "esp:6", "lcd1:MOSI", "orange", [] ],
30+
[ "esp:5", "lcd1:CS", "red", [] ],
31+
[ "esp:4", "lcd1:D/C", "magenta", [] ],
32+
[ "esp:3", "lcd1:RST", "yellow", [] ],
33+
[ "lcd1:LED", "esp:3V3", "white", [] ],
34+
[ "imu1:SDA", "esp:10", "green", [ "v0" ] ],
35+
[ "imu1:SCL", "esp:8.2", "green", [ "v0" ] ],
36+
[ "imu1:VCC", "esp:3V3", "red", [ "v0" ] ],
37+
[ "imu1:GND", "esp:GND", "black", [ "v-192", "h-211.12" ] ]
38+
],
39+
"serialMonitor": { "display": "terminal", "newline": "lf", "convertEol": true },
40+
"dependencies": {
41+
"chip-icm42670p": "github:SergioGasquez/[email protected]"
42+
}
43+
}

esp32-c3-devkit-rust/wokwi.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22

33
[wokwi]
44
version = 1
5+
#elf = "target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3"
6+
#firmware = "target/riscv32imac-unknown-none-elf/debug/spooky-esp32-c3"
7+
#gdbServerPort = 3333
8+
59
elf = "target/riscv32imac-unknown-none-elf/release/spooky-esp32-c3"
610
firmware = "target/riscv32imac-unknown-none-elf/release/spooky-esp32-c3"

0 commit comments

Comments
 (0)