# Betaflight

## 韌體編譯

### 0. 前置條件

作業系統為Ubuntu或Windows WSL

### 1. 構建 Betaflight 開發環境

Betaflight 是一個開源的飛控韌體，主要用於無人機和遙控飛行器。以下是構建 Betaflight 開發環境的步驟：

### 2. 複製Betaflight Github儲存庫

1. 開啟終端。
2. 執行以下命令以複製 Betaflight 儲存庫：

   ```bash
   git clone --recursive https://github.com/betaflight/betaflight.git
   ```
3. 進入代碼庫目錄：

   ```bash
   cd betaflight
   ```
4. 安裝必要工具：`sudo apt install curl`
5. 安裝 GCC 工具鏈：

   <pre class="language-bash"><code class="lang-bash"><strong>make arm_sdk_install
   </strong></code></pre>

### 3. 編譯 Betaflight 韌體

1. 執行以下命令進行代碼編譯：

   ```bash
   make <Board Name, Ex: MATEKF405AIO>
   ```

   *將* Board Name*替換為飛控板的具體名稱。*
2. 編譯成功後會出現以下訊息

   <figure><img src="/files/2tfC8sRervaEnh2ZmthK" alt=""><figcaption></figcaption></figure>
3. 編譯的韌體位置在betaflight/obj底下的hex檔案

   <figure><img src="/files/2HHtX63Qhvh8fILDWvc7" alt=""><figcaption></figcaption></figure>

## 韌體燒錄

1. 飛控版開啟DFU模式，USB 連接到電腦。

   <figure><img src="/files/52dufBIBeC05iZkX2ox2" alt=""><figcaption></figcaption></figure>

2. 使用 Betaflight Configurator 燒錄編譯好的韌體。

   <figure><img src="/files/c4GyT1cmjvRk2aCHpksc" alt=""><figcaption></figcaption></figure>

3. Betaflight韌體位置(hex檔案)

   <figure><img src="/files/YLaSMNVdSKimk34WCh2K" alt=""><figcaption></figcaption></figure>

4. 開始燒錄Betaflight韌體

   <figure><img src="/files/KJUMImF0psJ4HXe09O76" alt=""><figcaption></figcaption></figure>

5. 燒錄中

   <figure><img src="/files/o1nhY1aemnNlNaQA69bl" alt=""><figcaption></figcaption></figure>

6. 燒錄完成

   <figure><img src="/files/iMzcW2PBW4B9qjM9rhFd" alt=""><figcaption></figcaption></figure>

***

## 自定義韌體編譯

**如何編譯自定義的飛控板**

1. 複製已經存在的飛控板定義，重新命名資料夾，EX:KAKUTEF4V2\_ICM42688P

   <figure><img src="/files/IfzuIwFoDnThzwChq6KR" alt=""><figcaption></figcaption></figure>

2. 修改config.h

   <figure><img src="/files/KSOqs7Lfq3EcBLKKWMEv" alt=""><figcaption></figcaption></figure>

3. 開啟終端，切換到betaflight資料夾，編譯新飛控板的韌體:&#x20;

   `make KAKUTEF4V2_ICM42688P`

4. 編譯完的韌體將位於`betaflight/V4.5.0/betaflight/obj/`資料夾中

   <figure><img src="/files/1xqIpVdoaqg8wBdEfWsJ" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://taiphoon-com.gitbook.io/taiphoon.com-docs/developer-guides/compile-flash/betaflight.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
