安信可ESP-12K模塊採用的是樂鑫ESP32-S2晶片,"閹割版ESP32"雖然去掉了藍牙,但依然比 ESP8266 性能更強,有43個可編程 GPIO。模組特性如下:
完整的 802.11b/g/n Wi-Fi SoC 模塊,數據速率高達 150Mbps;內置 ESP32-S2 晶片,Xtensa® 單核 32 位 LX7 微處理器,支持高達 240 MHz 的時鐘頻率,擁有 128KB ROM,320KB SRAM,16KB RTC SRAM;支持 UART/GPIO/ADC/PWM/SPI/I2C/LCD/I2S/Camera/IR/USB/DAC 接口,支持觸摸傳感器、溫度傳感器、脈衝計數器;集成 Wi-Fi MAC/ BB/RF/PA/LNA;支持安卓、IOS 的 Smart Config(APP)/AirKiss(微信) 一鍵配網;由於ESP32S2 為 ESP32 的閹割版,去掉了藍牙的單核版,所以此晶片是沒有藍牙協議棧的,但是二次開發與 ESP32 類似。
目前我們推薦使用的是 Linux 環境開發,因此本文教程也是圍繞使用 window 自帶的 Linux 子系統進行的環境搭建。當然了,你也可以用虛擬機實現!
因此,根據下面文檔,搭建最新的 ** ESP32** 即可支持 ESP32S2 啦!
Bash on Ubuntu on Windows 是通過 Windows Subsystem for Linux(WSL)這一 Windows 10 的最新特性實現的,使用此功能,你可以在 Windows 中原生運行 Linux 的大多數命令行程序。
啟用 WSL 功能之後,如果使用 Bash,則 Windows 10 作業系統會下載一個由 Canonical 創建的 Ubuntu用戶模式鏡像Ubuntu user-mode image,然後 Bash 程序以及其他的 Linux 二進位程序就可以運行於該 Ubuntu 鏡像上。此外,微軟也承諾未來會提供更多 Linux 發行版以供選擇。
Bash on Ubuntu on Windows 功能主要是面向於開發者,我們可以在 Windows 中使用一些 Linux 生態鏈的開發工具。
由於這個面向的是開發者,所以安裝的window系統務必是專業版,你可以去某寶自行購買一個激活碼。
準備材料:window 專業版,不能是家庭版 ;
window 應用商店:Microsoft store;
2.1 啟用「適用於Linux的Windows子系統(WSL)」通過Win10任務欄中的Cortana搜索框搜索打開「啟用或關閉Windows功能」,向下滾動列表,即可看到「適用於Linux的Windows子系統」項。
勾選它,確定,然後按提示操作重啟系統:
2.2 啟用開發人員模式然後進入「設置 - 更新和安全 - 針對開發人員」設置頁面,選中「開發人員模式」。如圖:
2.3 下載並安裝 Ubuntu(可通過微軟商店獲取)微軟後來把Ubuntu、openSUSE、SLES和Fedora分發上架到了Microsoft Store(微軟商店),你可以很方便地下載安裝這些Linux發行版。如圖:
以下載安裝Ubuntu分發為例,點擊 Ubuntu 打開詳情頁面,然後點擊獲取。如圖:
2.4 點擊啟動:
首次安裝,會提示您輸入帳號和密碼,務必記住!
之後,任意地方,shift + 滑鼠右擊 --> 「在此處打開 linux shell」 ,即可連接到了 Linux;
3.1 安裝常見的軟體我們需要安裝幾個常用的軟體 :
sudo apt-get install vim
sudo apt install git
sudo apt-get install git wget flex bison gperf python python-pip python-setuptools python-serial python-click python-cryptography python-future python-pyparsing python-pyelftools cmake ninja-build ccache libffi-dev libssl-dev
眾所周知,樂鑫的開放源碼都放在GitHub,而GitHub又被微軟收購了,這一年的訪問下載速度慢得烏龜一樣,哈哈!所以,我克隆一份放在了國內的碼雲網站,這樣就保證我們拉取代碼非常快!
首先,我們先拉取源碼,先不拉取子模塊!
git clone https://gitee.com/xuhongv/esp-idf.git
沒有拉取子模塊的是不完整的代碼,看了下子模塊源路徑是不規範的,這裡,我們再修改為碼雲上的:
記事本打開 .gitmodules ,全部替換為下面這個內容!
然後再更新子模塊 , 你會發現快的一匹 : git submodule update --init --recursive
[submodule "components/esptool_py/esptool"]
path = components/esptool_py/esptool
url = https://gitee.com/xuhongv/esptool.git
[submodule "components/bt/controller/lib"]
path = components/bt/controller/lib
url = https://gitee.com/xuhongv/esp32-bt-lib.git
[submodule "components/bootloader/subproject/components/micro-ecc/micro-ecc"]
path = components/bootloader/subproject/components/micro-ecc/micro-ecc
url = https://gitee.com/xuhongv/micro-ecc.git
[submodule "components/coap/libcoap"]
path = components/coap/libcoap
url = https://gitee.com/xuhongv/libcoap.git
[submodule "components/nghttp/nghttp2"]
path = components/nghttp/nghttp2
url = https://gitee.com/xuhongv/nghttp2.git
[submodule "components/libsodium/libsodium"]
path = components/libsodium/libsodium
url = https://gitee.com/xuhongv/libsodium.git
[submodule "components/spiffs/spiffs"]
path = components/spiffs/spiffs
url = https://gitee.com/xuhongv/spiffs.git
[submodule "components/json/cJSON"]
path = components/json/cJSON
url = https://gitee.com/xuhongv/cJSON.git
[submodule "components/mbedtls/mbedtls"]
path = components/mbedtls/mbedtls
url = https://gitee.com/xuhongv/mbedtls.git
[submodule "components/asio/asio"]
path = components/asio/asio
url = https://gitee.com/xuhongv/asio.git
[submodule "components/expat/expat"]
path = components/expat/expat
url = https://gitee.com/xuhongv/libexpat.git
[submodule "components/lwip/lwip"]
path = components/lwip/lwip
url = https://gitee.com/xuhongv/esp-lwip.git
[submodule "components/mqtt/esp-mqtt"]
path = components/mqtt/esp-mqtt
url = https://gitee.com/xuhongv/esp-mqtt.git
[submodule "components/protobuf-c/protobuf-c"]
path = components/protobuf-c/protobuf-c
url = https://gitee.com/xuhongv/protobuf-c.git
[submodule "components/unity/unity"]
path = components/unity/unity
url = https://gitee.com/xuhongv/Unity.git
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
url = https://gitee.com/xuhongv/tinyxml2.git
[submodule "components/bt/host/nimble/nimble"]
path = components/bt/host/nimble/nimble
url = https://gitee.com/xuhongv/esp-nimble.git
[submodule "components/cbor/tinycbor"]
path = components/cbor/tinycbor
url = https://gitee.com/xuhongv/tinycbor.git
[submodule "components/esp_wifi/lib"]
path = components/esp_wifi/lib
url = https://gitee.com/xuhongv/esp32-wifi-lib.git
[submodule "components/tinyusb/tinyusb"]
path = components/tinyusb/tinyusb
url = https://gitee.com/xuhongv/tinyusb.git
[submodule "examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib"]
path = examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib
url = https://gitee.com/xuhongv/esp-cryptoauthlib.git
帶子模塊遞歸方式拉取GitHub,此時需要稍等一下!
git clone https://gitee.com/xuhongv/esp-idf.git
這裡就簡單很多,就設置變量即可!先拿到上述的SDK路徑即為IDF路徑!
以我的環境為例:
export IDF_PATH=/home/xuhongv/ESPRESSIF/ESP32/esp-idf
之後按下 i 表示嵌入代碼: vim ~/.bashrc
任意一處添加 表示嵌入上面代碼!
按下esc 再 :wq 表示寫入保存: source ~/.bashrc
IDF_PATH 路徑測試是否設置成功: echo $IDF_PATH
除了 ESP-IDF 本身,您還需要安裝 ESP-IDF 使用的各種工具,比如編譯器、調試器、Python 包等!
cd/home/xuhongv/ESPRESSIF/ESP32/esp-idf
./install.sh
出現這個 , 表示 安裝成功!
此時,您剛剛安裝的工具尚未添加至 PATH 環境變量,無法通過「命令窗口」使用這些工具。因此,必須設置一些環境變量,這可以通過 ESP-IDF 提供的另一個腳本完成。
注意下面命令2個小數點中間有一個空格!
. ./export.sh
成功後,便這樣提示:
打開 IDF/esp-idf/examples/get-started下面的hello_world工程;
idf.py set-target esp32s2 menuconfig : 配置編譯晶片為esp32s2,並配置面板;
idf.py build : 編譯代碼;
idf.py flash : 燒錄程序進去設備裡面;
idf.py erase_flash : 擦除設備裡面的程序;
Q1:運行install.sh 運行報錯$'\r': command not found ?
Q2:編譯報錯 No certificate found?
Q3:在下載或安裝依賴時候,有時候會突然卡住?
Q4:如何掛載串口?
原價:24.9元 現價:21.9元
快速購買
精彩回顧