###### tags: `FM623A` `MicroPython` # 旗標 FM623A 客製化韌體的編譯程序 旗標客製版韌體使用 3.3.1 版的 esp-idf 以及 1.2 版的 MicroPython, 必須配合 Python 2.7 與 Python3 運作, 以下是編譯步驟。 ## 安裝必要的套件 1. 安裝 ESP-IDF 工具鏈執行所需的額外工具以及 Python 模組 (使用 Python 2.7): ```bash sudo apt-get install git wget libncurses-dev flex bison gperf python3 python3-pip python2 cmake ninja-build ccache libffi-dev libssl-dev libdb-dev python-is-python2 ``` 2. 安裝 python2-pip: ```bash curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py ``` 取得安裝 pip 的 Python 程式後, 執行以下步驟安裝 pip: ```bash sudo python2 get-pip.py ``` 1. 安裝 ESP-IDF 工具鏈需要的 virtualenv 套件, 版本不能太新, 請安裝舊版本: ```bash pip2 install virtualenv==16.7.9 ``` 1. 韌體建置會使用到 Python3 下的 pyparsing 模組, 且 pyparsing 模組必須是 2.4 版以下: ```bash pip3 install 'pyparsing<2.4' ``` ## 下載 MicroPython 1. 下載 MicroPython 韌體原始檔: ```bash git clone https://github.com/micropython/micropython.git ``` 2. 檢出到客製版韌體使用的版本 (以下是 1.12 版): ```bash cd micropython git checkout b16990425 ``` ## 準備 ESP-IDF 工具鏈 1. 下載 ESP-IDF 工具鏈: ```bash cd .. git clone https://github.com/espressif/esp-idf.git ``` 2. 檢出到 3.3.1 版的 ESP-IDF: ```bash cd esp-idf git checkout v3.3.1 ``` 1. 更新工具鏈中的所有模組: ```bash git submodule update --init --recursive ``` 1. 進行 ESP-IDF 工具的安裝: ```bash ./install.sh ``` :::warning 如果遇到以下錯誤: ```bash virtualenv: error: unrecognized arguments: --no-site-packages ``` 表示 virtualenv 的版本太新, 可以先移除後再改裝比較舊的版本: ```bash pip uninstall virtualenv pip install virtualenv==16.7.9 ``` ::: 1. 設定環境變數: ```bash source ./export.sh ``` 如果關閉目前的終端機或是 shell, 就必須重新執行一次 export.sh。 ## 加入客製版的 ulab 自訂模組 如果要加入客製版的 ulab 模組到韌體中: 1. 下載 ulab 模組原始碼: ```bash cd .. git clone https://github.com/FlagTech/ulab.git ``` ## 加入額外的 Python 模組 此版韌體需要額外的 Python 模組, 請從 [FM623A 的範例檔](https://github.com/FlagTech/Python_AIoT_FM623A)中將[程式庫](https://github.com/FlagTech/Python_AIoT_FM623A/tree/master/%E7%94%A8Python%E5%AD%B8AIoT%E6%99%BA%E6%85%A7%E8%81%AF%E7%B6%B2/%E7%A8%8B%E5%BC%8F%E5%BA%AB)資料夾下的檔案放入 ports/esp32 的 modules 資料夾下就可以了: ```bash git clone https://github.com/FlagTech/Python_AIoT_FM623A.git cp -r Python_AIoT_FM623A/用Python學AIoT智慧聯網/程式庫/* micropython/ports/esp32/modules/ ``` ## 建置 MicroPython 韌體 1. 建置交叉編譯器: ```bash cd micropython/ make -C mpy-cross ``` 1. 建置 ESP32 的子模組: ```bash cd ports/esp32/ make submodules ``` 1. 建置 ESP32 韌體: ```bash make USER_C_MODULES=../../../ulab all ``` 建置成功後, 韌體會在 build-GENERIC 下的 firware.bin, 這就是你可以燒錄到 ESP32 控制板的 MicroPython 韌體。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up