Skip to content

Commit

Permalink
update esp idf template
Browse files Browse the repository at this point in the history
  • Loading branch information
ing03201 committed Mar 24, 2024
1 parent b0e59d3 commit a49ffa5
Showing 1 changed file with 43 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Understanding `esp-idf-template`
# `esp-idf-template`의 이해

Now that we know how to [generate a `std` project][generate-std], let's inspect what the generated project contains and try to understand every part of it.
이제 우리는 [`std` 프로젝트를 생성하는 방법][generate-std]을 알았으니, 생성된 프로젝트에 무엇이 포함되어 있는지 검사하고 그것의 모든 부분을 이해하려고 노력합시다.

[generate-std]: ./index.md

## Inspecting the Generated Project
## 생성된 프로젝트 점검

When creating a project from [`esp-idf-template`][esp-idf-template] with the following answers:
- Which MCU to target? · `esp32c3`
- Configure advanced template options? · `false`
다음과 같은 답변으로 [`esp-idf-template`][esp-idf-template]에서 프로젝트를 만들 때:

For this explanation, we will use the default values, if you want further modifications, see the [additional prompts][prompts] when not using default values.
- 어떤 MCU를 타겟으로 하시나요? · `esp32c3`
- 고급 템플릿 옵션들을 설정하겠습니까? · `false`

It should generate a file structure like this:
이 설명을 위해, 우리는 디폴트값을 사용할 것입니다. 추가 수정을 원한다면, 디폴트 값을 사용하지 않을 때 [additional prompts][prompts]를 참조하십시오.

다음과 같은 파일 구조를 생성해야 합니다:

```text
├── .cargo
Expand All @@ -26,33 +27,33 @@ It should generate a file structure like this:
└── sdkconfig.defaults
```

Before going further, let's see what these files are for.
더 나아가기 전에, 이 파일들이 무엇을 위한 것인지 봅시다.

- [`.cargo/config.toml`][config-toml]
- The Cargo configuration
- Contains our target
- Contains `runner = "espflash flash --monitor"` - this means you can just use `cargo run` to flash and monitor your code
- Contains the linker to use, in our case, [`ldproxy`][ldproxy]
- Contains the unstable `build-std` Cargo feature enabled
- Contains the `ESP-IDF-VERSION` environment variable that tells [`esp-idf-sys`][esp-idf-sys] which ESP-IDF version the project will use
- Cargo 구성설정
- 타겟 포함
- `runner = "espflash flash --monitor"` - `cargo run` 으로 코드를 플래시하고 모니터를 할 수 있게합니다.
- 사용할 링커를 포함합니다. 위 케이스는 [`ldproxy`][ldproxy]를 포함합니다.
- 활성화된 불안정한 `build-std` Cargo 기능이 포함되어 있습니다.
- 프로젝트가 사용할 ESP-IDF 버전을 [`esp-idf-sys`][esp-idf-sys]에 알려주는 `ESP-IDF-VERSION` 환경 변수를 포함합니다.
- `src/main.rs`
- The main source file of the newly created project
- For details, see the [Understanding `main.rs`][main-rs] section below
- 새로 생성된 프로젝트의 주요 소스 파일
- 자세한 내용은 아래의 [ `main.rs`의 이해][main-rs] 섹션을 참조하십시오.
- [`.gitignore`][gitignore]
- Tells `git` which folders and files to ignore
- 어떤 폴더와 파일을 무시해야 하는지 `git`에게 알려줍니다.
- [`build.rs`][build-rs]
- Propagates linker arguments for `ldproxy`
- `ldproxy`에 대한 링커 인수를 전파합니다.
- [`Cargo.toml`][cargo-toml]
- The usual Cargo manifest declaring some meta-data and dependencies of the project
- 프로젝트의 일부 메타 데이터와 종속성을 선언하는 일반적인 Cargo 매니페스트
- [`rust-toolchain.toml`][rust-toolchain-toml]
- Defines which Rust toolchain to use
- The toolchain will be `nightly` or `esp` depending on your target
- 사용할 Rust 툴체인을 정의합니다.
- 툴체인은 당신의 목표에 따라 `nightly` 또는 `esp` 될 것입니다.
- [`sdkconfig.defaults`][sdkconfig-defaults]
- Contains the overridden values from the ESP-IDF defaults
- ESP-IDF 기본값에서 재정의된 값을 포함합니다.

[esp-idf-template]: https://github.com/esp-rs/esp-idf-template
[prompts]: https://github.com/esp-rs/esp-idf-template#generate-the-project
[main-rs]:#understanding-mainrs
[main-rs]:#mainrs의-이해
[config-toml]: https://doc.rust-lang.org/cargo/reference/config.html
[ldproxy]: https://github.com/esp-rs/embuild/tree/master/ldproxy
[esp-idf-sys]: https://github.com/esp-rs/esp-idf-sys
Expand All @@ -62,7 +63,7 @@ Before going further, let's see what these files are for.
[rust-toolchain-toml]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
[sdkconfig-defaults]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#custom-sdkconfig-defaults

### Understanding `main.rs`
### `main.rs`의 이해

```rust,ignore
1 use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
Expand All @@ -75,28 +76,29 @@ Before going further, let's see what these files are for.
8 }
```

The first line is an import that defines the ESP-IDF entry point when the root crate is a binary crate that defines a main function.
첫 번째 줄은 루트 크레이트가 주 함수를 정의하는 바이너리 상자일 때 ESP-IDF 진입점이 정의된 것을 가져오기입니다.

그런 다음, 우리는 몇 줄이 있는 일반적인 주요 기능을 가지고 있습니다:

Then, we have a usual main function with a few lines on it:
- A call to `esp_idf_sys::link_patches` function that makes sure that a few patches to the ESP-IDF which are implemented in Rust are linked to the final executable
- We print on our console the famous "Hello, world!"
- Rust에서 구현된 ESP-IDF에 대한 몇 가지 패치가 최종 실행 파일과 연결되도록 하는 `esp_idf_sys::link_patches` 함수에 대한 호출

## Running the Code
우리는 콘솔에 유명한 "Hello, world!"를 인쇄합니다.

Building and running the code is as easy as
## 코드 실행하기

코드를 빌드하고 실행하는 것은 어렵지 않습니다.

```shell
cargo run
```

This builds the code according to the configuration and executes [`espflash`][espflash] to flash the code to the board.
이렇게 하면 configuration에 따라 코드가 빌드되고 [`espflash`](https://github.com/esp-rs/espflash/tree/main/espflash)를 실행하여 코드를 보드에 플래시합니다.

Since our [`runner` configuration][runner-config] also passes the `--monitor` argument to [`espflash`][espflash], we can see what the code is printing.
우리의 [`runner` configuration](https://doc.rust-lang.org/cargo/reference/config.html#targettriplerunner)[`espflash`](https://github.com/esp-rs/espflash/tree/main/espflash)`--monitor` 인수도 있기때문에, 우리는 코드출력을 볼수있습니다.

Make sure that you have [`espflash`][espflash] installed, otherwise this step will fail. To install [`espflash`][espflash]:
`cargo install espflash`
[`espflash`](https://github.com/esp-rs/espflash/tree/main/espflash) 를 설치했는지 확인하세요,그렇지 않으면 이 단계가 fail 하게됩니다. [`espflash`](https://github.com/esp-rs/espflash/tree/main/espflash) 설치방법은 다음과 같습니다.: `cargo install espflash`

You should see something similar to this:
이와 유사한 내용을 확인해야 합니다:

```text
[2023-04-18T08:05:09Z INFO ] Connecting...
Expand All @@ -121,11 +123,13 @@ I (344) cpu_start: Starting scheduler.
Hello, world!
```

As you can see, there are messages from the first and second-stage bootloader and then, our "Hello, world!" is printed.
여기에 표시되는 것은 1단계 및 2단계 부트로더의 메시지와 "Hello world" 메시지입니다!

이것은 실제 코드가 동작하는 것입니다

You can reboot with `CTRL+R` or exit with `CTRL+C`.
재부팅 단축키는 `CTRL+R` , exit 단축키는 `CTRL+C` 입니다.

If you encounter any issues while building the project, please, see the [Troubleshooting][troubleshooting] chapter.
프로젝트를 빌드하는 동안 문제가 발생하면 [문제 해결](https://ing03201.github.io/rust-on-esp-book-ko-kr/troubleshooting/index.html) 장을 참조하십시오.

[espflash]: https://github.com/esp-rs/espflash/tree/main/espflash
[runner-config]: https://doc.rust-lang.org/cargo/reference/config.html#targettriplerunner
Expand Down

0 comments on commit a49ffa5

Please sign in to comment.