Skip to content

Commit

Permalink
feat: Update openOCD section
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioGasquez committed Nov 3, 2023
1 parent 63069de commit 6669604
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 76 deletions.
1 change: 0 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- [Debugging](./tooling/debugging/index.md)
- [probe-rs](./tooling/debugging/probe-rs.md)
- [OpenOCD](./tooling/debugging/openocd.md)
- [Debugging in Visual Studio Code](./tooling/debugging/vscode.md)
- [Simulating](./tooling/simulating/index.md)
- [Wokwi](./tooling/simulating/wokwi.md)
- [QEMU](tooling/simulating/qemu.md)
Expand Down
19 changes: 9 additions & 10 deletions src/tooling/debugging/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Debugging Rust applications is also possible using different tools that will be

Refer to the table below to see which chip is supported in every debugging method:

| | **probe-rs** | **OpenOCD** | **VS Code** |
| :----------: | :----------: | :---------: | :---------: |
| **ESP32** ||||
| **ESP32-C2** ||||
| **ESP32-C3** ||||
| **ESP32-C6** ||||
| **ESP32-H2** ||||
| **ESP32-S2** ||||
| **ESP32-S3** ||||
| | **probe-rs** | **OpenOCD** |
| :----------: | :----------: | :---------: |
| **ESP32** |||
| **ESP32-C2** |||
| **ESP32-C3** |||
| **ESP32-C6** |||
| **ESP32-H2** |||
| **ESP32-S2** |||
| **ESP32-S3** |||

## `USB-JTAG-SERIAL` Peripheral

Expand All @@ -28,7 +28,6 @@ Some of our recent products contain the `USB-JTAG-SERIAL` peripheral that allows
# or
espflash board-info
```

- [ESP32-C6][esp32c6-docs]
- [ESP32-H2][esp32h2-docs]
- [ESP32-S3][esp32s3-docs]
Expand Down
67 changes: 57 additions & 10 deletions src/tooling/debugging/openocd.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@

# OpenOCD

Similar to [`probe-rs`][probe-rs], OpenOCD doesn't have support for the `Xtensa` architecture. However, Espressif does maintain a fork of OpenOCD under [espressif/openocd-esp32][espressif-openocd-esp32] which has support for Espressif's chips.
Similar to [`probe-rs`][probe-rs], OpenOCD doesn't have support for the `Xtensa` architecture. However, Espressif does maintain a fork of OpenOCD under [`espressif/openocd-esp32`][espressif-openocd-esp32] which has support for Espressif's chips.

Instructions on how to install `openocd-esp32` for your platform can be found in [the Espressif documentation][espressif-documentation].

[probe-rs]: ./probe-rs.md
[espressif-openocd-esp32]: https://github.com/espressif/openocd-esp32
[espressif-documentation]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/index.html#setup-of-openocd

## Setup for Espressif Chips

<!-- how to choose interface & chip -->

Once installed, it's as simple as running `openocd` with the correct scripts. For chips with the built-in USB JTAG, there is normally a config that will work out of the box, for example on the ESP32-C3:
Once installed, it's as simple as running `openocd` with the correct arguments. For chips with the built-in [`USB-JTAG-SERIAL` peripheral][usb-jtag-serial], there is normally a config file that will work out of the box, for example on the ESP32-C3:

```shell
openocd -f board/esp32c3-builtin.cfg
Expand All @@ -24,3 +16,58 @@ For other configurations it may require specifying the chip and the interface, f
```shell
openocd -f interface/jlink.cfg -f target/esp32.cfg
```

[probe-rs]: ./probe-rs.md
[espressif-openocd-esp32]: https://github.com/espressif/openocd-esp32
[espressif-documentation]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/index.html#setup-of-openocd
[usb-jtag-serial]: index.md#usb-jtag-serial-peripheral

## VS Code Extension

OpenOCD can be used in VS Code via the [`cortex-debug`][cortex-debug] extension to debug Espressif products.

[cortex-debug]: https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug

### Configuration

1. If required, connect the external JTAG adapter.
1. See Configure Other JTAG Interfaces section of ESP-IDF Programming Guide. Eg: [Section for ESP32][jtag-interfaces-esp32]
> ⚠️ **Note**: On Windows, `USB Serial Converter A 0403 6010 00` driver should be WinUSB.
2. Set up VSCode
1. Install [Cortex-Debug][cortex-debug] extension for VS Code.
2. Create the `.vscode/launch.json` file in the project tree you want to debug.
3. Update `executable`, `svdFile`, `serverpath` paths, and `toolchainPrefix` fields.

```json
{
// 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": [
{
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
"name": "Attach",
"type": "cortex-debug",
"request": "attach", // launch will fail when attempting to download the app into the target
"cwd": "${workspaceRoot}",
"executable": "target/xtensa-esp32-none-elf/debug/.....", //!MODIFY
"servertype": "openocd",
"interface": "jtag",
"toolchainPrefix": "xtensa-esp32-elf", //!MODIFY
"openOCDPreConfigLaunchCommands": ["set ESP_RTOS none"],
"serverpath": "C:/Espressif/tools/openocd-esp32/v0.11.0-esp32-20220411/openocd-esp32/bin/openocd.exe", //!MODIFY
"configFiles": ["board/esp32-wrover-kit-3.3v.cfg"], //!MODIFY
"overrideAttachCommands": [
"set remote hardware-watchpoint-limit 2",
"mon halt",
"flushregs"
],
"overrideRestartCommands": ["mon reset halt", "flushregs", "c"]
}
]
}
```

[jtag-interfaces-esp32]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/jtag-debugging/configure-other-jtag.html

4 changes: 2 additions & 2 deletions src/tooling/debugging/probe-rs.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ There is a `probe-rs` extension in VS Code, see `probe-rs` [VS Code documentatio
[cargo-embed]: https://probe.rs/docs/tools/cargo-embed/
[cargo-embed-config]: https://probe.rs/docs/tools/cargo-embed/#configuration

## Using `probe-rs` as an OpenOCD Replacement
## GDB Integration

`probe-rs` has a `gdb` command that runs a GDB server, by default in port, `1337`
`probe-rs` includes a GDB stub to integrate into your usual workflow with common tools. The `gdb` command runs a GDB server, by default in port, `1337`.
53 changes: 0 additions & 53 deletions src/tooling/debugging/vscode.md

This file was deleted.

0 comments on commit 6669604

Please sign in to comment.