飛書文檔http://https://x509p6c8to.feishu.cn/docx/doxcnkGhtbxcv8ge5wKFkunsgmm
一、創建工程
cd ~/esp
cp -r esp-idf/examples/get-started/hello_world .
cd ~/esp/hello_world//設置目標板卡相關
idf.py set-target esp32//可配置工程屬性
idf.py menuconfig
工程源碼
(FYI:下方代碼已在idf4.4驗證,如果你使用其它版本idf,可以參考esp-idf/examples/get-started/hello_world中的代碼)
DesktopScreenV3.0.0$ idf.py --version
ESP-IDF v4.4.2-296-g4b8915d7af-dirty
/* Hello World ExampleThis example code is in the Public Domain (or CC0 licensed, at your option.)Unless required by applicable law or agreed to in writing, thissoftware is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES ORCONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"#define CHIP_NAME "ESP32"void app_main(void)
{printf("Hello world!\n");/* Print chip information */esp_chip_info_t chip_info;esp_chip_info(&chip_info);printf("This is %s chip with %d CPU core(s), WiFi%s%s, ",CHIP_NAME,chip_info.cores,(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");printf("silicon revision %d, ", chip_info.revision);printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());while(1){printf("system run ...\n");vTaskDelay(1000 / portTICK_PERIOD_MS);}
}
二、編譯工程
idf.py fullclean
idf.py clean
idf.py build
配置環境
get_idf
配置
idf.py menuconfig
編譯
?idf.py build
清除
idf.py fullclean
三、下載運行
把設備USB口接到電腦后,查看新增設備號,使用ls /dev/ttyU* 查看新增的設備號
查看設備號
Linux 操作系統: 以 /dev/tty 開始/dev/ttyUSB0
下載
idf.py -p /dev/ttyUSB0 flash
監視器
idf.py -p /dev/ttyUSB0 monitor
構建、下載、監視
idf.py -p /dev/ttyUSB0 flash monitor
您可使用快捷鍵 Ctrl+],退出 IDF 監視器。