飞书文档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 监视器。