# ESP32 開發環境建立(Ubuntu) **作業系統:Ubuntu 18.04** ## 目標:安裝v4.0版本 1. 安裝需要的相關套件 ```bash sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools libffi-dev libssl-notify_data_task ``` 2. 設定存放esp-idf的資料夾**esp** ```bash= mkdir -p ~/esp cd ~/esp ``` 3. 下載SDK(v4.0)和安裝相關套件 ```bash= git clone -b release/v4.0 --recursive https://github.com/espressif/esp-idf.git cd esp-idf ./install.sh ## 安裝相關套件,會在$HOME底下看到目錄.espressif ``` 4. 加入需要的環境變數 ```bash= export IDF_PATH=~/esp/esp-idf source $IDF_PATH/export.sh ``` ## 執行範例程式 1. 進入hello-world的目錄 ```bash= cd ~/esp/esp-idf/examples/get-started/hello_world/ idf.py build ##插入uart to usb dongle,在上電的時候gpio0接地進入燒錄模式 # 設定device file的權限讓它能讓後面的燒錄指令可以順利進行 chmod 777 /dev/ttyUSB0 idf.py -p /dev/ttyUSB0 flash ``` 成功畫面如下 ![](https://i.imgur.com/xBgVeN0.png) [1. Standard Setup of Toolchain for Linux ](https://docs.espressif.com/projects/esp-idf/en/release-v3.3/get-started/linux-setup.html) [2. 快速入门](https://docs.espressif.com/projects/esp-idf/zh_CN/release-v4.0/get-started/index.html#get-started-set-up-tools) ## 額外狀況排除 1. 如果在esp idf進行git pull重新編譯專案無法成功,可以在esp idf目錄底下下以下指令 ```bash git submodule update --init --recursive ``` ###### tags: `esp32`