Skip to content

Commit

Permalink
Merge pull request #4 from Song-aff/feature/translate_tooling
Browse files Browse the repository at this point in the history
feat: 翻译工具部分
  • Loading branch information
Narukara authored Sep 14, 2023
2 parents a0c85b6 + 39117e9 commit 71f1251
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 157 deletions.
20 changes: 10 additions & 10 deletions src/tooling/debugging/index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Debugging
# 调试

Debugging Rust applications is also possible using different tools that will be covered in this chapter.
在本章中,我们将介绍使用不同工具进行调试 Rust 应用程序的方法。

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** | | | |
| **ESP32** ||||
| **ESP32-C2** ||||
| **ESP32-C3** ||||
| **ESP32-C6** ||||
| **ESP32-H2** ||||
| **ESP32-S2** ||||
| **ESP32-S3** ||||
10 changes: 5 additions & 5 deletions src/tooling/debugging/openocd.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

# 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.
[`probe-rs`][probe-rs]类似,OpenOCD 不支持`Xtensa`架构。然而,Espressif [espressif/openocd-esp32][espressif-openocd-esp32]下维护了一个 OpenOCD 的分支,该分支支持 Espressif 的芯片。

Instructions on how to install `openocd-esp32` for your platform can be found in [the Espressif documentation][espressif-documentation].
有关如何在你的平台上安装`openocd-esp32`的说明可以在[Espressif 文档][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
## Espressif 芯片的设置

<!-- 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:
安装完成后,只需使用正确的脚本运行`openocd`即可。对于具有内置 USB JTAG 的芯片,通常有一个可以直接使用的配置,例如在 ESP32-C3 上:

```shell
openocd -f board/esp32c3-builtin.cfg
```

For other configurations it may require specifying the chip and the interface, for example, ESP32 with a J-Link:
对于其他配置,可能需要指定芯片和接口,例如,使用 J-Link 的 ESP32:

```shell
openocd -f interface/jlink.cfg -f target/esp32.cfg
Expand Down
40 changes: 20 additions & 20 deletions src/tooling/debugging/probe-rs.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# `probe-rs`

The [`probe-rs`][probe-rs] project is a set of tools to interact with embedded MCU's using various debug probes. It is similar to [OpenOCD][openocd], [pyOCD][pyocd], [Segger tools][segger-tools], etc. There is support for `ARM` & `RISC-V` architectures along with a collection of tools, including but not limited to:
[`probe-rs`][probe-rs]项目是一组工具,用于使用各种调试探针与嵌入式 MCU 进行交互。它类似于[OpenOCD][openocd][pyOCD][pyocd][Segger 工具][segger-tools]等。支持`ARM``RISC-V`架构以及一系列工具,包括但不限于:

- Debugger
- GDB support.
- CLI for interactive debugging.
- VS Code extension.
- Real Time Transfer (RTT)
- Similar to app_trace component of IDF.
- Flashing algorithms
- 调试器
- GDB 支持。
- 用于交互式调试的 CLI。
- VS Code 扩展。
- 实时传输(RTT
- 类似于 IDF 的 app_trace 组件。
- 烧录算法

More info about probe-rs & how to set up a project can be found on the [probe-rs] website.
有关 probe-rs 及如何设置项目的更多信息,请参见[probe-rs]网站。

[probe-rs]: https://probe.rs/
[openocd]: https://openocd.org/
[pyocd]: https://pyocd.io/
[segger-tools]: https://www.segger.com/

## `USB-JTAG-SERIAL` Peripheral for ESP32-C3
## ESP32-C3 的`USB-JTAG-SERIAL`外设

Starting from `probe-rs` v0.12, it is possible to flash and debug the ESP32-C3 with the built-in `USB-JTAG-SERIAL` peripheral, no need for any external hardware debugger. More info on configuring the interface can be found in the [official documentation][official-documentation].
`probe-rs` v0.12 开始,可以使用内置的`USB-JTAG-SERIAL`外设对 ESP32-C3 进行烧录和调试,无需任何外部硬件调试器。有关配置接口的更多信息,请参见[官方文档][official-documentation]

[official-documentation]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/configure-builtin-jtag.html

## Support for Espressif Chips
## Espressif 芯片的支持

`probe-rs` currently only supports `ARM` & `RISC-V`, therefore this limits the number of Espressif chips that can be used at the moment.
`probe-rs`目前仅支持`ARM``RISC-V`,因此目前限制了可以使用的 Espressif 芯片数量。

| Chip | Flashing | Debugging |
| :------: | :------: | :-------: |
| ESP32-C3 | | ⚠️ |
| 芯片 | 烧录 | 调试 |
| :------: | :--: | :--: |
| ESP32-C3 || ⚠️ |

> ⚠️ **Note**: _Items marked with ⚠️ are currently work in progress, usable but expect bugs._
> ⚠️ **注意**_标有 ⚠️ 的项目目前正在进行中,可用但可能存在错误。_
## Permissions - Linux
## 权限 - Linux

On Linux, you may run into permission issues trying to interact with Espressif probes. Installing the following `udev` rules and reloading should fix that issue.
Linux 上,可能会遇到与 Espressif 探针交互时的权限问题。安装以下`udev`规则并重新加载应该可以解决此问题。

```text
# Espressif dev kit FTDI
Expand All @@ -48,4 +48,4 @@ ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE="660", GROUP="plugdev",
ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1002", MODE="660", GROUP="plugdev", TAG+="uaccess"
```

<!-- TODO: when probe-rs can actually debug at least a C3 with decent back traces etc, add a section here with an example config: see https://github.com/probe-rs/probe-rs/issues/877 -->
<!-- TODO: 当probe-rs可以实际调试至少具有良好回溯等功能的C3时,在此处添加一个示例配置:参见https://github.com/probe-rs/probe-rs/issues/877 -->
94 changes: 47 additions & 47 deletions src/tooling/debugging/vscode.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# Debugging in Visual Studio Code
# Visual Studio Code 中进行调试

There is also a possibility to debug with graphical output directly in Visual Studio Code.
Visual Studio Code 中,还可以直接进行可视化的调试。

## ESP32

### Configuration
### 配置

1. Connect an external JTAG adapter: [ESP-Prog][esp-prog] can be used.
1. 连接外部 JTAG 适配器:可以使用[ESP-Prog][esp-prog]

| ESP32 Pin | JTAG Signal |
| :---------: | :---------: |
| MTDO/GPIO15 | TDO |
| MTDI/GPIO12 | TDI |
| MTCK/GPIO13 | TCK |
| MTMS/GPIO14 | TMS |
| 3V3 | VJTAG |
| GND | GND |
| ESP32 引脚 | JTAG 信号 |
| :---------: | :-------: |
| MTDO/GPIO15 | TDO |
| MTDI/GPIO12 | TDI |
| MTCK/GPIO13 | TCK |
| MTMS/GPIO14 | TMS |
| 3V3 | VJTAG |
| GND | GND |

> ⚠️ **Note**: On Windows `USB Serial Converter A 0403 6010 00` driver should be WinUSB.
> ⚠️ **注意**:在 Windows 上,`USB Serial Converter A 0403 6010 00`驱动程序应为 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.
2. 设置 VSCode
1. 安装 VS Code 的[Cortex-Debug][cortex-debug]扩展。
2. 在要调试的项目树中创建`.vscode/launch.json`文件。
3. 更新`executable``svdFile``serverpath`路径和`toolchainPrefix`字段。

```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
// 使用IntelliSense了解可能的属性。
// 悬停以查看现有属性的描述。
// 有关更多信息,请访问: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
// 更多信息请参见:https://github.com/Marus/cortex-debug/blob/master/package.json
"name": "Attach",
"type": "cortex-debug",
"request": "attach", // attach instead of launch, because otherwise flash write is attempted, but fails
"request": "attach", // 使用 attach 而不是 launch,避免因为尝试写入 flash 导致运行失败
"cwd": "${workspaceRoot}",
"executable": "target/xtensa-esp32-none-elf/debug/.....",
"servertype": "openocd",
Expand All @@ -61,50 +61,50 @@ There is also a possibility to debug with graphical output directly in Visual St

## ESP32-C3

The availability of built-in JTAG interface depends on the ESP32-C3 revision:
内置 JTAG 接口的可用性取决于 ESP32-C3 版本:

- Revisions older than 3 **don't** a have built-in JTAG interface.
- Revisions 3 (and newer) **do** have a built-in JTAG interface, and you don't have to connect an external device to be able to debug.
- 早于 3 的版本**没有**内置 JTAG 接口。
- 版本 3(及更高版本)**具有**内置 JTAG 接口,无需连接外部设备即可进行调试。

To find your ESP32-C3 revision, run:
要查找 ESP32-C3 版本,请运行:

```shell
cargo espflash board-info
# or
# 或者
espflash board-info
```

### Configuration
### 配置

1. (**Only for revisions older than 3**) Connect an external JTAG adapter, [ESP-Prog][esp-prog] can be used.
1.**仅适用于早于 3 的版本**)连接外部 JTAG 适配器,可以使用[ESP-Prog][esp-prog]

| ESP32-C3 Pin | JTAG Signal |
| :----------: | :---------: |
| MTDO/GPIO7 | TDO |
| MTDI/GPIO5 | TDI |
| MTCK/GPIO6 | TCK |
| MTMS/GPIO4 | TMS |
| 3V3 | VJTAG |
| GND | GND |
| ESP32-C3 引脚 | JTAG 信号 |
| :-----------: | :-------: |
| MTDO/GPIO7 | TDO |
| MTDI/GPIO5 | TDI |
| MTCK/GPIO6 | TCK |
| MTMS/GPIO4 | TMS |
| 3V3 | VJTAG |
| GND | GND |

> ⚠️**Note**: On Windows `USB Serial Converter A 0403 6010 00` driver should be WinUSB.
> ⚠️ **注意**:在 Windows 上,`USB Serial Converter A 0403 6010 00`驱动程序应为 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.
2. 设置 VSCode
1. 安装 VS Code 的[Cortex-Debug][cortex-debug]扩展。
2. 在要调试的项目树中创建`.vscode/launch.json`文件。
3. 更新`executable``svdFile``serverpath`路径和`toolchainPrefix`字段。
```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
// 使用IntelliSense了解可能的属性。
// 悬停以查看现有属性的描述。
// 有关更多信息,请访问: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
// 更多信息请参见:https://github.com/Marus/cortex-debug/blob/master/package.json
"name": "Attach",
"type": "cortex-debug",
"request": "attach", // attach instead of launch, because otherwise flash write is attempted, but fails
"request": "attach", // 使用 attach 而不是 launch,避免因为尝试写入 flash 导致运行失败
"cwd": "${workspaceRoot}",
"executable": "target/riscv32imc-unknown-none-elf/debug/examples/usb_serial_jtag", //
"servertype": "openocd",
Expand Down
26 changes: 13 additions & 13 deletions src/tooling/espflash.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
# `espflash`

`espflash` is a serial flasher utility, based on [esptool.py][esptool], for Espressif SoCs and modules.
`espflash`是一个基于[esptool.py][esptool]Espressif SoC 和模块的串口下载工具。

The [`espflash`][espflash] repository contains two crates, `cargo-espflash` and `espflash`. For more information on these crates, see the respective sections below.
[`espflash`][espflash]仓库包含两个 crate,`cargo-espflash``espflash`。有关这些 crate 的更多信息,请参见下面的各自部分。

[esptool]: https://github.com/espressif/esptool
[espflash]: https://github.com/esp-rs/espflash

> ⚠️ **Note**: The `espflash` and `cargo-espflash` commands shown below, assume that version `2.0` or greater is used.
> ⚠️ **注意**: 下面显示的`espflash``cargo-espflash`命令,假定使用版本`2.0`或更高版本。
## `cargo-espflash`

Provides a subcommand for `cargo` that handles cross-compilation and flashing.
`cargo`提供一个子命令,处理交叉编译和下载。

To install, run:
要安装,请运行:

```shell
cargo install cargo-espflash
```

This command must be run within a Cargo project, ie. a directory containing a `Cargo.toml` file. For example, to build an example named 'blinky', flash the resulting binary to a device, and then subsequently start a serial monitor:
此命令必须在 Cargo 项目中运行,即包含`Cargo.toml`文件的目录。例如,要构建名为“blinky”的示例,将生成的二进制文件下载到设备中,然后随后启动串行监视器:

```shell
cargo espflash flash --example=blinky --monitor
```

For more information, please see the [`cargo-espflash`][cargo-espflash] README.
有关更多信息,请参见[`cargo-espflash`][cargo-espflash] README

[cargo-espflash]: https://github.com/esp-rs/espflash/blob/master/cargo-espflash/README.md

## `espflash`

Provides a standalone command-line application that flashes an ELF file to a device.
提供一个独立的命令行应用程序,将 ELF 文件下载到设备中。

To install, run:
要安装,请运行:

```shell
cargo install espflash
```

Assuming you have built an ELF binary by other means already, `espflash` can be used to download it to your device and monitor the serial port. For example, if you have built the `getting-started/blinky` example from [ESP-IDF][esp-idf] using `idf.py`, you might run something like:
假设你已经通过其他方式构建了 ELF 二进制文件,`espflash`可以用于将其下载到设备并监视串行端口。例如,如果你已经使用`idf.py`[ESP-IDF][esp-idf]构建了名为“getting-started/blinky”的示例,可以运行类似以下的命令:

```shell
espflash flash build/blinky --monitor
```

For more information, please see the [`espflash` README][espflash-readme].
有关更多信息,请参见[`espflash` README][espflash-readme]

`espflash` can be used as a Cargo runner by adding the following to your project's `.cargo/config.toml` file:
`espflash`可以通过在你的项目的`.cargo/config.toml`文件中添加以下内容,作为 Cargo runner 来使用:
```toml
[target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))']
runner = "espflash flash --monitor"
```
With this configuration, you can flash and monitor your application using `cargo run`.
使用此配置,可以通过`cargo run`下载和监控应用程序。

[esp-idf]: https://github.com/espressif/esp-idf
[espflash-readme]: https://github.com/esp-rs/espflash/blob/master/espflash/README.md
9 changes: 3 additions & 6 deletions src/tooling/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Tooling
# 工具

Now that we have our required dependencies installed, and we know how to generate a
template project, we will cover, in more detail, some tools. These tools will make
developing Rust applications for Espressif chips a lot easier.
现在我们已经安装了所需的依赖项,并知道如何生成模板项目,我们将更详细地介绍一些工具。这些工具将使为 Espressif 芯片开发 Rust 应用程序变得更加容易。

In this chapter, we will present `espflash`/`cargo-espflash`, suggest Visual Studio Code as IDE and, dig into the
currently available simulation and debugging methods.
在本章中,我们将介绍`espflash`/`cargo-espflash`,建议使用 Visual Studio Code 作为 IDE,并深入探讨当前可用的仿真和调试方法。
24 changes: 12 additions & 12 deletions src/tooling/simulating/index.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Simulating
# 仿真

Simulating projects can be handy. It allows users to test projects using CI, try projects without having hardware available, and many other scenarios.
仿真可能很方便。它允许用户使用 CI(持续集成)来测试项目、在没有可用硬件的情况下尝试项目,还有许多其他使用场景。

At the moment, there are a few ways of simulating Rust projects on Espressif chips. Every way has some limitations, but it's quickly evolving and getting better every day.
目前,有多种方法可以在 Espressif 芯片上仿真 Rust 项目。每种方法都有一些限制,但它们正在迅速发展,并且每天都在变得更好。

In this chapter, we will discuss currently available simulation tools.
在本章中,我们将讨论当前可用的仿真工具。

Refer to the table below to see which chip is supported in every simulating method:
请参考下表,以了解每种仿真方法支持哪种芯片:

| | **[Wokwi][wokwi]** | **QEMU** |
| :----------: | :----------------: | :------: |
| **ESP32** | | |
| **ESP32-C2** | | |
| **ESP32-C3** | | |
| **ESP32-C6** | | |
| **ESP32-H2** | | |
| **ESP32-S2** | | |
| **ESP32-S3** | | |
| **ESP32** |||
| **ESP32-C2** |||
| **ESP32-C3** |||
| **ESP32-C6** |||
| **ESP32-H2** |||
| **ESP32-S2** |||
| **ESP32-S3** |||

[wokwi]: https://docs.wokwi.com/guides/esp32#simulation-features
Loading

0 comments on commit 71f1251

Please sign in to comment.