From 55582c675aa7a2a46c2edfd946733696756a1607 Mon Sep 17 00:00:00 2001 From: Song-aff <281218023@qq.com> Date: Mon, 11 Sep 2023 12:33:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E7=BF=BB=E8=AF=91=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tooling/debugging/index.md | 20 +++---- src/tooling/debugging/openocd.md | 11 ++-- src/tooling/debugging/probe-rs.md | 40 ++++++------- src/tooling/debugging/vscode.md | 96 ++++++++++++++++--------------- src/tooling/espflash.md | 28 ++++----- src/tooling/index.md | 9 +-- src/tooling/simulating/index.md | 24 ++++---- src/tooling/simulating/qemu.md | 20 ++++--- src/tooling/simulating/wokwi.md | 35 +++++------ src/tooling/visual-studio-code.md | 26 ++++----- 10 files changed, 156 insertions(+), 153 deletions(-) diff --git a/src/tooling/debugging/index.md b/src/tooling/debugging/index.md index 4b4046c..a1be005 100644 --- a/src/tooling/debugging/index.md +++ b/src/tooling/debugging/index.md @@ -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** | ❌ | ✅ | ✅ | diff --git a/src/tooling/debugging/openocd.md b/src/tooling/debugging/openocd.md index 1aef190..2be72b9 100644 --- a/src/tooling/debugging/openocd.md +++ b/src/tooling/debugging/openocd.md @@ -1,25 +1,24 @@ - # 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 芯片的设置 -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 diff --git a/src/tooling/debugging/probe-rs.md b/src/tooling/debugging/probe-rs.md index a09234b..6e625a2 100644 --- a/src/tooling/debugging/probe-rs.md +++ b/src/tooling/debugging/probe-rs.md @@ -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 @@ -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" ``` - + diff --git a/src/tooling/debugging/vscode.md b/src/tooling/debugging/vscode.md index aeaef2d..b7bbcd8 100644 --- a/src/tooling/debugging/vscode.md +++ b/src/tooling/debugging/vscode.md @@ -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", // 附加而不是启动,因为否则会尝试写入flash,但会失败 "cwd": "${workspaceRoot}", "executable": "target/xtensa-esp32-none-elf/debug/.....", "servertype": "openocd", @@ -61,50 +61,52 @@ 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 | -> ⚠️**Note**: On Windows `USB Serial Converter A 0403 6010 00` driver should be WinUSB. +| MTCK/GPIO6 | TCK | +| MTMS/GPIO4 | TMS | +| 3V3 | VJTAG | +| GND | GND | + +> ⚠️ **注意**:在 Windows 上,`USB串行转换器A 0403 6010 00`驱动程序应为 WinUSB。 + +2. 设置 VSCode + 1. 安装 VS Code 的[Cortex-Debug][cortex-debug]扩展。 + 2. 在要调试的项目树中创建`.vscode/launch.json`文件。 + 3. 更新`executable`、`svdFile`、`serverpath`路径和`toolchainPrefix`字段。 -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 + // 使用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", // 附加而不是启动,因为否则会尝试写入flash,但会失败 "cwd": "${workspaceRoot}", "executable": "target/riscv32imc-unknown-none-elf/debug/examples/usb_serial_jtag", // "servertype": "openocd", diff --git a/src/tooling/espflash.md b/src/tooling/espflash.md index 5faf48f..fa3da5e 100644 --- a/src/tooling/espflash.md +++ b/src/tooling/espflash.md @@ -1,58 +1,60 @@ # `espflash` -`espflash` is a serial flasher utility, based on [esptool.py][esptool], for Espressif SoCs and modules. +`espflash`是一个基于[esptool.py][esptool]的 Espressif SoCs 和模块的串行闪存工具。 -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]。 + +通过将以下内容添加到项目的`.cargo/config.toml`文件中,可以将`espflash`用作 Cargo 运行程序: -`espflash` can be used as a Cargo runner by adding the following to your project's `.cargo/config.toml` file: ```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 diff --git a/src/tooling/index.md b/src/tooling/index.md index 0f31262..e4b3d95 100644 --- a/src/tooling/index.md +++ b/src/tooling/index.md @@ -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,并深入探讨当前可用的仿真和调试方法。 diff --git a/src/tooling/simulating/index.md b/src/tooling/simulating/index.md index dd3ff13..6fe727c 100644 --- a/src/tooling/simulating/index.md +++ b/src/tooling/simulating/index.md @@ -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. +仿真项目可能很方便。它允许用户在没有可用硬件的情况下测试项目、尝试项目以及许多其他场景。 -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 diff --git a/src/tooling/simulating/qemu.md b/src/tooling/simulating/qemu.md index 2fd7768..8a7b27c 100644 --- a/src/tooling/simulating/qemu.md +++ b/src/tooling/simulating/qemu.md @@ -1,31 +1,33 @@ # QEMU -Espressif maintains a fork of QEMU in [espressif/QEMU][espressif-qemu] with the necessary patches to make it work on Espressif chips. -See the [QEMU wiki][qemu-wiki] for instructions on how to build QEMU and emulate projects with it. +Espressif 维护了一个 QEMU 的分支,位于[espressif/QEMU][espressif-qemu],其中包含了必要的补丁,使其能够在 Espressif 芯片上运行。 +请参考[QEMU wiki][qemu-wiki]以了解如何构建 QEMU 并使用它来仿真项目。 -Once you have built QEMU, you should have the `qemu-system-xtensa` file. +构建完成 QEMU 后,您应该有`qemu-system-xtensa`文件。 [espressif-qemu]: https://github.com/espressif/qemu [qemu-wiki]: https://github.com/espressif/qemu/wiki -## Running Your Project Using QEMU +## 使用 QEMU 运行您的项目 -> ⚠️ **Note**: Only ESP32 is currently supported, so make sure you are compiling for `xtensa-esp32-espidf` target. +> ⚠️ **注意**: 目前只支持 ESP32,因此请确保您正在编译`xtensa-esp32-espidf`目标。 -For running our project in QEMU, we need a firmware/image with bootloader and partition table merged in it. -We can use [`cargo-espflash`][cargo-espflash] to generate it: +要在 QEMU 中运行我们的项目,我们需要一个固件/镜像,其中包含引导加载程序和分区表的合并。 +我们可以使用[`cargo-espflash`][cargo-espflash]来生成它: ```shell cargo espflash save-image --chip esp32 --merge --release ``` -If you prefer to use [`espflash`][espflash], you can achieve the same result by building the project first and then generating image: +如果您想使用[`espflash`][espflash],您可以先构建项目,然后生成镜像来实现相同的结果: + ```shell cargo build --release espflash save-image --merge ESP32 target/xtensa-esp32-espidf/release/ ``` -Now, run the image in QEMU: +现在,在 QEMU 中运行镜像: + ```shell /path/to/qemu-system-xtensa -nographic -machine esp32 -drive file=,if=mtd,format=raw ``` diff --git a/src/tooling/simulating/wokwi.md b/src/tooling/simulating/wokwi.md index 7d2f899..41b585e 100644 --- a/src/tooling/simulating/wokwi.md +++ b/src/tooling/simulating/wokwi.md @@ -1,10 +1,10 @@ # Wokwi -[Wokwi][wokwi] is an online simulator that supports simulating Rust projects (both `std` and `no_std`) in Espressif Chips. -See [wokwi.com/rust][wokwi-rust] for a list of examples and a way to start new projects. +[Wokwi][wokwi]是一个在线模拟器,支持在 Espressif 芯片上模拟 Rust 项目(包括`std`和`no_std`)。 +请参考[wokwi.com/rust][wokwi-rust]以获取示例列表和开始新项目的方法。 -Wokwi offers Wi-Fi simulation, Virtual Logic Analyzer, and [GDB debugging][gdb-debugging] among many other features, see -[Wokwi documentation][wokwi-documentation] for more details. For ESP chips, there is a table of [simulation features][wokwi-simulation-features] that are currently supported. +Wokwi 提供了 Wi-Fi 仿真、虚拟逻辑分析仪和[GDB 调试][gdb-debugging]等许多功能,请参考[Wokwi 文档][wokwi-documentation]以获取更多详细信息。 +对于 ESP 芯片,有一个[仿真功能][wokwi-simulation-features]表格,列出了当前支持的功能。 [wokwi]: https://wokwi.com/ [wokwi-rust]: https://wokwi.com/rust @@ -12,33 +12,34 @@ Wokwi offers Wi-Fi simulation, Virtual Logic Analyzer, and [GDB debugging][gdb-d [wokwi-documentation]: https://docs.wokwi.com/ [wokwi-simulation-features]: https://docs.wokwi.com/guides/esp32#simulation-features -## Using Wokwi for VS Code extension -Wokwi offers a VS Code extension that allows you to simulate a project directly in the code editor by only adding a few files. -For more information, see [Wokwi documentation][wokwi-vscode]. -You can also debug your code using the VS Code debugger, see [Debugging your code][wokwi-debugging]. +## 使用 Wokwi VS Code 扩展 -When using any of the [templates][templates] and not using the default values, there is a prompt (`Configure project to support Wokwi simulation with Wokwi VS Code extension?`) that generates the required files to use Wokwi VS Code extension. +Wokwi 提供了一个 VS Code 扩展,允许您通过添加几个文件直接在代码编辑器中模拟项目。 +更多信息,请参考[Wokwi 文档][wokwi-vscode]。 +您还可以使用 VS Code 调试器调试代码,请参考[调试您的代码][wokwi-debugging]。 -![Wokwi VS Code example](../../assets/wokwi-vscode.png) +当使用任何[模板][templates]并且不使用默认值时,会有一个提示(`Configure project to support Wokwi simulation with Wokwi VS Code extension?`),生成所需的文件以使用 Wokwi VS Code 扩展。 + +![Wokwi VS Code示例](../../assets/wokwi-vscode.png) [wokwi-vscode]: https://docs.wokwi.com/vscode/getting-started [wokwi-debugging]: https://docs.wokwi.com/vscode/debugging [templates]: ./../../writing-your-own-application/generate-project/index.md -## Using `wokwi-server` +## 使用`wokwi-server` -[`wokwi-server`][wokwi-server] is a CLI tool for launching a Wokwi simulation of your project. I.e., it allows you -to build a project on your machine, or in a container, and simulate the resulting binary. +[`wokwi-server`][wokwi-server]是一个 CLI 工具,用于启动您的项目的 Wokwi 仿真。也就是说,它允许您在本地或容器中构建项目,并模拟生成的二进制文件。 -[`wokwi-server`][wokwi-server] also allows simulating your resulting binary on other Wokwi projects, with more hardware parts other than the chip itself. See the corresponding [section of the `wokwi-server`][wokwi-server-custom] README for detailed instructions. +[`wokwi-server`][wokwi-server]还允许在其他 Wokwi 项目上模拟您的二进制文件,除了芯片本身外还有更多的硬件部件。请参考[`wokwi-server`][wokwi-server-custom] README 的相应部分以获取详细说明。 [wokwi-server]: https://github.com/MabezDev/wokwi-server [wokwi-server-custom]: https://github.com/MabezDev/wokwi-server#simulating-your-binary-on-a-custom-wokwi-project -## Custom Chips -Wokwi allows generating custom chips that let you program the behavior of a component not supported in Wokwi. For more details, see the official [Wokwi documentation][wokwi-custom-chip]. +## 自定义芯片 + +Wokwi 允许生成自定义芯片,让您编程不受 Wokwi 支持的组件的行为。更多详情,请参考官方[Wokwi 文档][wokwi-custom-chip]。 -Custom chips can also be written in Rust! See [Wokwi Custom Chip API][rust-chip-api] for more information. For example, custom [inverter chip][custom-chip-example] in Rust. +自定义芯片也可以用 Rust 编写!请参考[Wokwi Custom Chip API][rust-chip-api]以获取更多信息。例如,使用 Rust 编写的自定义[反相器芯片][custom-chip-example]。 [wokwi-custom-chip]: https://docs.wokwi.com/chips-api/getting-started [rust-chip-api]: https://github.com/wokwi/wokwi_chip_ll diff --git a/src/tooling/visual-studio-code.md b/src/tooling/visual-studio-code.md index fc9b743..9bc14df 100644 --- a/src/tooling/visual-studio-code.md +++ b/src/tooling/visual-studio-code.md @@ -1,15 +1,15 @@ # Visual Studio Code -One of the more common development environments is Microsoft's [Visual Studio Code][vscode] text editor along with the [Rust Analyzer][rust-analyzer], also known as RA, extension. +Microsoft 的[Visual Studio Code][vscode]文本编辑器以及[Rust Analyzer][rust-analyzer]扩展,也称为 RA,是较常见的开发环境之一。 -Visual Studio Code is an open-source and cross-platform graphical text editor with a rich ecosystem of extensions. The [Rust Analyzer extension][rust-analyzer-extension] provides an implementation of the [Language Server Protocol][language-server-protocol] for Rust and additionally includes features like autocompletion, go-to definition, and more. +Visual Studio Code 是一个开源的跨平台图形化文本编辑器,具有丰富的扩展生态系统。[Rust Analyzer 扩展][rust-analyzer-extension]为 Rust 提供了[语言服务器协议][language-server-protocol]的实现,并包括自动完成、跳转到定义等功能。 -Visual Studio Code can be installed via the most popular package managers, and installers are available on the official website. The [Rust Analyzer extension][rust-analyzer-extension] can be installed in Visual Studio Code via the built-in extension manager. +Visual Studio Code 可以通过最流行的软件包管理器安装,也可以在官方网站上获得安装程序。[Rust Analyzer 扩展][rust-analyzer-extension]可以通过内置的扩展管理器在 Visual Studio Code 中安装。 -Alongside Rust Analyzer there are other extensions that might be helpful: +除了 Rust Analyzer 之外,其他扩展也可能有所帮助: -- [Even Better TOML][even-better-toml] for editing TOML-based configuration files -- [crates][crates] to help manage Rust dependencies +- [Even Better TOML][even-better-toml]用于编辑基于 TOML 的配置文件 +- [crates][crates]用于帮助管理 Rust 依赖项 [vscode]: https://code.visualstudio.com/ [rust-analyzer]: https://rust-analyzer.github.io/ @@ -18,11 +18,11 @@ Alongside Rust Analyzer there are other extensions that might be helpful: [even-better-toml]: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml [crates]: https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates -## Tips and Tricks +## 技巧和诀窍 -### Using Rust Analyzer with `no_std` +### 在`no_std`下使用 Rust Analyzer -If you are developing for a target that doesn't have `std` support, Rust Analyzer can behave strangely, often reporting various errors. This can be resolved by creating a `.vscode/settings.json` file in your project and populating it with the following: +如果您正在为不支持`std`的目标开发,Rust Analyzer 可能会表现出奇怪的行为,通常会报告各种错误。这可以通过在项目中创建`.vscode/settings.json`文件并填充以下内容来解决: ```json { @@ -30,9 +30,9 @@ If you are developing for a target that doesn't have `std` support, Rust Analyze } ``` -### Cargo Hints When Using Custom Toolchains +### 在使用自定义工具链时使用 Cargo 提示 -If you are using a custom toolchain, as you would with `Xtensa` targets, you can provide some hints to `cargo` via the `rust-toolchain.toml` file to improve the user experience: +如果您正在使用自定义工具链,就像在`Xtensa`目标中一样,您可以通过`rust-toolchain.toml`文件向`cargo`提供一些提示,以改善用户体验: ```toml [toolchain] @@ -41,9 +41,9 @@ components = ["rustfmt", "rustc-dev"] targets = ["xtensa-esp32-none-elf"] ``` -## Other IDEs +## 其他 IDE -We chose to cover VS Code because it has good support for Rust and is popular among developers. There are also other IDEs available that have comparable Rust support, such as [CLion][clion] and [vim][vim], but these are outside of this book's scope. +我们选择覆盖 VS Code,因为它对 Rust 有很好的支持,并且在开发人员中很受欢迎。还有其他可用的 IDE 具有相当的 Rust 支持,例如[CLion][clion]和[vim][vim],但这些超出了本书的范围。 [clion]: https://www.jetbrains.com/clion/ [vim]: https://www.vim.org/ From 39117e90434559b294f7b98f505a271f3d620e4e Mon Sep 17 00:00:00 2001 From: Song-aff <281218023@qq.com> Date: Wed, 13 Sep 2023 22:07:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tooling/debugging/openocd.md | 3 ++- src/tooling/debugging/probe-rs.md | 2 +- src/tooling/debugging/vscode.md | 20 +++++++++----------- src/tooling/espflash.md | 16 +++++++--------- src/tooling/simulating/index.md | 4 ++-- src/tooling/simulating/qemu.md | 12 +++++------- src/tooling/simulating/wokwi.md | 21 ++++++++++----------- src/tooling/visual-studio-code.md | 12 ++++++------ 8 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/tooling/debugging/openocd.md b/src/tooling/debugging/openocd.md index 2be72b9..039d77f 100644 --- a/src/tooling/debugging/openocd.md +++ b/src/tooling/debugging/openocd.md @@ -1,8 +1,9 @@ + # OpenOCD 与[`probe-rs`][probe-rs]类似,OpenOCD 不支持`Xtensa`架构。然而,Espressif 在[espressif/openocd-esp32][espressif-openocd-esp32]下维护了一个 OpenOCD 的分支,该分支支持 Espressif 的芯片。 -有关如何在您的平台上安装`openocd-esp32`的说明可以在[Espressif 文档][espressif-documentation]中找到。 +有关如何在你的平台上安装`openocd-esp32`的说明可以在[Espressif 文档][espressif-documentation]中找到。 [probe-rs]: ./probe-rs.md [espressif-openocd-esp32]: https://github.com/espressif/openocd-esp32 diff --git a/src/tooling/debugging/probe-rs.md b/src/tooling/debugging/probe-rs.md index 6e625a2..34c3479 100644 --- a/src/tooling/debugging/probe-rs.md +++ b/src/tooling/debugging/probe-rs.md @@ -35,7 +35,7 @@ ## 权限 - Linux -在 Linux 上,您可能会遇到与 Espressif 探针交互时的权限问题。安装以下`udev`规则并重新加载应该可以解决此问题。 +在 Linux 上,可能会遇到与 Espressif 探针交互时的权限问题。安装以下`udev`规则并重新加载应该可以解决此问题。 ```text # Espressif dev kit FTDI diff --git a/src/tooling/debugging/vscode.md b/src/tooling/debugging/vscode.md index b7bbcd8..188941b 100644 --- a/src/tooling/debugging/vscode.md +++ b/src/tooling/debugging/vscode.md @@ -1,6 +1,6 @@ # 在 Visual Studio Code 中进行调试 -还有一种可能性是直接在 Visual Studio Code 中进行图形输出进行调试。 +在 Visual Studio Code 中,还可以直接进行可视化的调试。 ## ESP32 @@ -35,7 +35,7 @@ // 更多信息请参见:https://github.com/Marus/cortex-debug/blob/master/package.json "name": "Attach", "type": "cortex-debug", - "request": "attach", // 附加而不是启动,因为否则会尝试写入flash,但会失败 + "request": "attach", // 使用 attach 而不是 launch,避免因为尝试写入 flash 导致运行失败 "cwd": "${workspaceRoot}", "executable": "target/xtensa-esp32-none-elf/debug/.....", "servertype": "openocd", @@ -64,7 +64,7 @@ 内置 JTAG 接口的可用性取决于 ESP32-C3 版本: - 早于 3 的版本**没有**内置 JTAG 接口。 -- 版本 3(及更高版本)**具有**内置 JTAG 接口,您无需连接外部设备即可进行调试。 +- 版本 3(及更高版本)**具有**内置 JTAG 接口,无需连接外部设备即可进行调试。 要查找 ESP32-C3 版本,请运行: @@ -82,19 +82,17 @@ espflash board-info | :-----------: | :-------: | | MTDO/GPIO7 | TDO | | MTDI/GPIO5 | TDI | +| MTCK/GPIO6 | TCK | +| MTMS/GPIO4 | TMS | +| 3V3 | VJTAG | +| GND | GND | -| MTCK/GPIO6 | TCK | -| MTMS/GPIO4 | TMS | -| 3V3 | VJTAG | -| GND | GND | - -> ⚠️ **注意**:在 Windows 上,`USB串行转换器A 0403 6010 00`驱动程序应为 WinUSB。 +> ⚠️ **注意**:在 Windows 上,`USB Serial Converter A 0403 6010 00`驱动程序应为 WinUSB。 2. 设置 VSCode 1. 安装 VS Code 的[Cortex-Debug][cortex-debug]扩展。 2. 在要调试的项目树中创建`.vscode/launch.json`文件。 3. 更新`executable`、`svdFile`、`serverpath`路径和`toolchainPrefix`字段。 - ```json { // 使用IntelliSense了解可能的属性。 @@ -106,7 +104,7 @@ espflash board-info // 更多信息请参见:https://github.com/Marus/cortex-debug/blob/master/package.json "name": "Attach", "type": "cortex-debug", - "request": "attach", // 附加而不是启动,因为否则会尝试写入flash,但会失败 + "request": "attach", // 使用 attach 而不是 launch,避免因为尝试写入 flash 导致运行失败 "cwd": "${workspaceRoot}", "executable": "target/riscv32imc-unknown-none-elf/debug/examples/usb_serial_jtag", // "servertype": "openocd", diff --git a/src/tooling/espflash.md b/src/tooling/espflash.md index fa3da5e..07bf232 100644 --- a/src/tooling/espflash.md +++ b/src/tooling/espflash.md @@ -1,6 +1,6 @@ # `espflash` -`espflash`是一个基于[esptool.py][esptool]的 Espressif SoCs 和模块的串行闪存工具。 +`espflash`是一个基于[esptool.py][esptool]的 Espressif SoC 和模块的串口下载工具。 [`espflash`][espflash]仓库包含两个 crate,`cargo-espflash`和`espflash`。有关这些 crate 的更多信息,请参见下面的各自部分。 @@ -11,7 +11,7 @@ ## `cargo-espflash` -为`cargo`提供一个子命令,处理交叉编译和闪存。 +为`cargo`提供一个子命令,处理交叉编译和下载。 要安装,请运行: @@ -19,7 +19,7 @@ cargo install cargo-espflash ``` -此命令必须在 Cargo 项目中运行,即包含`Cargo.toml`文件的目录。例如,要构建名为“blinky”的示例,将生成的二进制文件闪存到设备中,然后随后启动串行监视器: +此命令必须在 Cargo 项目中运行,即包含`Cargo.toml`文件的目录。例如,要构建名为“blinky”的示例,将生成的二进制文件下载到设备中,然后随后启动串行监视器: ```shell cargo espflash flash --example=blinky --monitor @@ -31,7 +31,7 @@ cargo espflash flash --example=blinky --monitor ## `espflash` -提供一个独立的命令行应用程序,将 ELF 文件闪存到设备中。 +提供一个独立的命令行应用程序,将 ELF 文件下载到设备中。 要安装,请运行: @@ -39,7 +39,7 @@ cargo espflash flash --example=blinky --monitor cargo install espflash ``` -假设您已经通过其他方式构建了 ELF 二进制文件,`espflash`可以用于将其下载到设备并监视串行端口。例如,如果您已经使用`idf.py`从[ESP-IDF][esp-idf]构建了名为“getting-started/blinky”的示例,您可以运行类似以下的命令: +假设你已经通过其他方式构建了 ELF 二进制文件,`espflash`可以用于将其下载到设备并监视串行端口。例如,如果你已经使用`idf.py`从[ESP-IDF][esp-idf]构建了名为“getting-started/blinky”的示例,可以运行类似以下的命令: ```shell espflash flash build/blinky --monitor @@ -47,14 +47,12 @@ espflash flash build/blinky --monitor 有关更多信息,请参见[`espflash` README][espflash-readme]。 -通过将以下内容添加到项目的`.cargo/config.toml`文件中,可以将`espflash`用作 Cargo 运行程序: - +`espflash`可以通过在你的项目的`.cargo/config.toml`文件中添加以下内容,作为 Cargo runner 来使用: ```toml [target.'cfg(any(target_arch = "riscv32", target_arch = "xtensa"))'] runner = "espflash flash --monitor" ``` - -使用此配置,您可以使用`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 diff --git a/src/tooling/simulating/index.md b/src/tooling/simulating/index.md index 6fe727c..dccd7b8 100644 --- a/src/tooling/simulating/index.md +++ b/src/tooling/simulating/index.md @@ -1,8 +1,8 @@ # 仿真 -仿真项目可能很方便。它允许用户在没有可用硬件的情况下测试项目、尝试项目以及许多其他场景。 +仿真可能很方便。它允许用户使用 CI(持续集成)来测试项目、在没有可用硬件的情况下尝试项目,还有许多其他使用场景。 -目前,有几种方法可以在 Espressif 芯片上仿真 Rust 项目。每种方法都有一些限制,但它们正在迅速发展,并且每天都在变得更好。 +目前,有多种方法可以在 Espressif 芯片上仿真 Rust 项目。每种方法都有一些限制,但它们正在迅速发展,并且每天都在变得更好。 在本章中,我们将讨论当前可用的仿真工具。 diff --git a/src/tooling/simulating/qemu.md b/src/tooling/simulating/qemu.md index 8a7b27c..620286d 100644 --- a/src/tooling/simulating/qemu.md +++ b/src/tooling/simulating/qemu.md @@ -3,31 +3,29 @@ Espressif 维护了一个 QEMU 的分支,位于[espressif/QEMU][espressif-qemu],其中包含了必要的补丁,使其能够在 Espressif 芯片上运行。 请参考[QEMU wiki][qemu-wiki]以了解如何构建 QEMU 并使用它来仿真项目。 -构建完成 QEMU 后,您应该有`qemu-system-xtensa`文件。 +构建完成 QEMU 后,应该有`qemu-system-xtensa`文件。 [espressif-qemu]: https://github.com/espressif/qemu [qemu-wiki]: https://github.com/espressif/qemu/wiki -## 使用 QEMU 运行您的项目 +## 使用 QEMU 运行项目 -> ⚠️ **注意**: 目前只支持 ESP32,因此请确保您正在编译`xtensa-esp32-espidf`目标。 +> ⚠️ **注意**: 目前只支持 ESP32,因此请确保正在编译`xtensa-esp32-espidf`目标。 -要在 QEMU 中运行我们的项目,我们需要一个固件/镜像,其中包含引导加载程序和分区表的合并。 +要在 QEMU 中运行我们的项目,我们需要一个固件(firmware)/镜像(image),其中包含引导加载程序(bootloader)和分区表的合并。 我们可以使用[`cargo-espflash`][cargo-espflash]来生成它: ```shell cargo espflash save-image --chip esp32 --merge --release ``` -如果您想使用[`espflash`][espflash],您可以先构建项目,然后生成镜像来实现相同的结果: - +如果想使用[`espflash`][espflash],可以先构建项目,然后生成镜像来实现相同的结果: ```shell cargo build --release espflash save-image --merge ESP32 target/xtensa-esp32-espidf/release/ ``` 现在,在 QEMU 中运行镜像: - ```shell /path/to/qemu-system-xtensa -nographic -machine esp32 -drive file=,if=mtd,format=raw ``` diff --git a/src/tooling/simulating/wokwi.md b/src/tooling/simulating/wokwi.md index 41b585e..14e7504 100644 --- a/src/tooling/simulating/wokwi.md +++ b/src/tooling/simulating/wokwi.md @@ -8,36 +8,35 @@ Wokwi 提供了 Wi-Fi 仿真、虚拟逻辑分析仪和[GDB 调试][gdb-debuggin [wokwi]: https://wokwi.com/ [wokwi-rust]: https://wokwi.com/rust -[gdb-debugging]: https://docs.wokwi.com/gdb-debugging -[wokwi-documentation]: https://docs.wokwi.com/ -[wokwi-simulation-features]: https://docs.wokwi.com/guides/esp32#simulation-features +[gdb-debugging]: https://docs.wokwi.com/zh-CN/gdb-debugging +[wokwi-documentation]: https://docs.wokwi.com/zh-CN/ +[wokwi-simulation-features]: https://docs.wokwi.com/zh-CN/guides/esp32#simulation-features ## 使用 Wokwi VS Code 扩展 - -Wokwi 提供了一个 VS Code 扩展,允许您通过添加几个文件直接在代码编辑器中模拟项目。 +Wokwi 提供了一个 VS Code 扩展,允许通过添加几个文件直接在代码编辑器中模拟项目。 更多信息,请参考[Wokwi 文档][wokwi-vscode]。 -您还可以使用 VS Code 调试器调试代码,请参考[调试您的代码][wokwi-debugging]。 +还可以使用 VS Code 调试器调试代码,请参考[调试你的代码][wokwi-debugging]。 当使用任何[模板][templates]并且不使用默认值时,会有一个提示(`Configure project to support Wokwi simulation with Wokwi VS Code extension?`),生成所需的文件以使用 Wokwi VS Code 扩展。 ![Wokwi VS Code示例](../../assets/wokwi-vscode.png) -[wokwi-vscode]: https://docs.wokwi.com/vscode/getting-started -[wokwi-debugging]: https://docs.wokwi.com/vscode/debugging +[wokwi-vscode]: https://docs.wokwi.com/zh-CN/vscode/getting-started +[wokwi-debugging]: https://docs.wokwi.com/zh-CN/vscode/debugging [templates]: ./../../writing-your-own-application/generate-project/index.md ## 使用`wokwi-server` -[`wokwi-server`][wokwi-server]是一个 CLI 工具,用于启动您的项目的 Wokwi 仿真。也就是说,它允许您在本地或容器中构建项目,并模拟生成的二进制文件。 +[`wokwi-server`][wokwi-server]是一个 CLI 工具,用于启动项目的 Wokwi 仿真。也就是说,它允许在本地或容器中构建项目,并模拟生成的二进制文件。 -[`wokwi-server`][wokwi-server]还允许在其他 Wokwi 项目上模拟您的二进制文件,除了芯片本身外还有更多的硬件部件。请参考[`wokwi-server`][wokwi-server-custom] README 的相应部分以获取详细说明。 +[`wokwi-server`][wokwi-server]还允许在其他 Wokwi 项目上模拟二进制文件,除了芯片本身外还有更多的硬件部件。请参考[`wokwi-server README` 的相应部分][wokwi-server-custom] 以获取详细说明。 [wokwi-server]: https://github.com/MabezDev/wokwi-server [wokwi-server-custom]: https://github.com/MabezDev/wokwi-server#simulating-your-binary-on-a-custom-wokwi-project ## 自定义芯片 -Wokwi 允许生成自定义芯片,让您编程不受 Wokwi 支持的组件的行为。更多详情,请参考官方[Wokwi 文档][wokwi-custom-chip]。 +Wokwi 允许生成自定义芯片,让你对 Wokwi 不支持的组件的行为进行编程。更多详情,请参考官方[Wokwi 文档][wokwi-custom-chip]。 自定义芯片也可以用 Rust 编写!请参考[Wokwi Custom Chip API][rust-chip-api]以获取更多信息。例如,使用 Rust 编写的自定义[反相器芯片][custom-chip-example]。 diff --git a/src/tooling/visual-studio-code.md b/src/tooling/visual-studio-code.md index 9bc14df..b64cb41 100644 --- a/src/tooling/visual-studio-code.md +++ b/src/tooling/visual-studio-code.md @@ -2,9 +2,9 @@ Microsoft 的[Visual Studio Code][vscode]文本编辑器以及[Rust Analyzer][rust-analyzer]扩展,也称为 RA,是较常见的开发环境之一。 -Visual Studio Code 是一个开源的跨平台图形化文本编辑器,具有丰富的扩展生态系统。[Rust Analyzer 扩展][rust-analyzer-extension]为 Rust 提供了[语言服务器协议][language-server-protocol]的实现,并包括自动完成、跳转到定义等功能。 +Visual Studio Code 是一个开源的跨平台图形化文本编辑器,具有丰富的扩展生态系统。[Rust Analyzer 扩展][rust-analyzer-extension]为 Rust 提供了[Language Server Protocol(语言服务器协议][language-server-protocol]的实现,并包括自动完成、跳转到定义等功能。 -Visual Studio Code 可以通过最流行的软件包管理器安装,也可以在官方网站上获得安装程序。[Rust Analyzer 扩展][rust-analyzer-extension]可以通过内置的扩展管理器在 Visual Studio Code 中安装。 +Visual Studio Code 可以通过大多数流行的软件包管理器安装,也可以在官方网站上获得安装程序。[Rust Analyzer 扩展][rust-analyzer-extension]可以通过内置的扩展管理器在 Visual Studio Code 中安装。 除了 Rust Analyzer 之外,其他扩展也可能有所帮助: @@ -18,11 +18,11 @@ Visual Studio Code 可以通过最流行的软件包管理器安装,也可以 [even-better-toml]: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml [crates]: https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates -## 技巧和诀窍 +## 实用建议 ### 在`no_std`下使用 Rust Analyzer -如果您正在为不支持`std`的目标开发,Rust Analyzer 可能会表现出奇怪的行为,通常会报告各种错误。这可以通过在项目中创建`.vscode/settings.json`文件并填充以下内容来解决: +如果为不支持`std`的目标开发,Rust Analyzer 可能会表现出奇怪的行为,通常会报告各种错误。这可以通过在项目中创建`.vscode/settings.json`文件并填充以下内容来解决: ```json { @@ -32,7 +32,7 @@ Visual Studio Code 可以通过最流行的软件包管理器安装,也可以 ### 在使用自定义工具链时使用 Cargo 提示 -如果您正在使用自定义工具链,就像在`Xtensa`目标中一样,您可以通过`rust-toolchain.toml`文件向`cargo`提供一些提示,以改善用户体验: +如果正在使用自定义工具链,就像在`Xtensa`目标中一样,可以通过`rust-toolchain.toml`文件向`cargo`提供一些提示,以改善用户体验: ```toml [toolchain] @@ -43,7 +43,7 @@ targets = ["xtensa-esp32-none-elf"] ## 其他 IDE -我们选择覆盖 VS Code,因为它对 Rust 有很好的支持,并且在开发人员中很受欢迎。还有其他可用的 IDE 具有相当的 Rust 支持,例如[CLion][clion]和[vim][vim],但这些超出了本书的范围。 +选择介绍 VS Code 是因为它对 Rust 有很好的支持,并且在开发者中很受欢迎。还有其他一些 IDE 也有相当的 Rust 支持,如 CLion 和 vim,但这些不在本书的讨论范围内。 [clion]: https://www.jetbrains.com/clion/ [vim]: https://www.vim.org/