1. 概述
本文着重描述基于VsCode搭建ESP32产品线开发环境,系统环境为WIN10。
2. 安装操作步骤
2.1 安装VsCode
下载地址:VsCode官方网站 安装过程:略,无脑下一步即可。
2.2 安装espressif idf扩展
2.3 配置espressif idf插件
- 在VsCode界面下,可以按【F1】键或选择【查看->命令面板】打开命令选择器,选择【ESP-IDF:配置ESP-IDF插件】
- 在出现的界面上选择【Express】快速配置选项,如图 - 选择后,配置如下,点击INSTALL,需要等一段时间,要装很多东西。
- 安装界面如图:
- 安装成功,提示如下:
3. 跑通第一个Demo
前提条件:需要有ESP32开发板,我手里的开发板为ESP32-DevKitM-1 v1.0
- 在VsCode界面下,选择【查看】->【命令面板】->选择【ESP-IDF:展示示例项目】
- 创建示例工程 - VsCode IDE工具简述 - 工程配置步骤
- 选择目标芯片ESP32
- 点击左下角的齿轮图标,打开工程配置界面,如图,这里功能简单,无需配置。
- 编译工程
编译成功如图: - 烧写固件到ESP32开发板 - 程序烧写日志如下:
> Executing task: d:\110_Work_ProductsResearch\111-Router\ESP32Work\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe d:\110_Work_ProductsResearch\111-Router\ESP32Work\esp-idf\components\esptool_py\esptool\esptool.py -p COM70 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 hello_world.bin 0x1000 bootloader/bootloader.bin 0x8000 partition_table/partition-table.bin <
esptool.py v3.2-dev
Serial port COM70
Connecting.......
Chip is ESP32-U4WDH (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 44:17:93:b4:c4:3c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00010000 to 0x00039fff...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 169776 bytes to 89623...
Wrote 169776 bytes (89623 compressed) at 0x00010000 in 2.4 seconds (effective 555.1 kbit/s)...
Hash of data verified.
Flash params set to 0x0220
Compressed 25280 bytes to 15790...
Wrote 25280 bytes (15790 compressed) at 0x00001000 in 0.7 seconds (effective 291.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.1 seconds (effective 446.8 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM70 instead...
--- idf_monitor on \\.\COM70 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6612
load:0x40078000,len:14780
load:0x40080400,len:3792
0x40080400: _init at ??:?
entry 0x40080694
I (28) boot: ESP-IDF v4.4-dirty 2nd stage bootloader
I (28) boot: compile time 17:10:47
I (28) boot: chip revision: 3
I (31) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (38) boot.esp32: SPI Speed : 40MHz
I (43) boot.esp32: SPI Mode : DIO
I (47) boot.esp32: SPI Flash Size : 4MB
I (52) boot: Enabling RNG early entropy source...
I (57) boot: Partition Table:
I (61) boot: ## Label Usage Type ST Offset Length
I (68) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (83) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 3, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0778ch ( 30604) map
I (122) esp_image: segment 1: paddr=000177b4 vaddr=3ffb0000 size=02340h ( 9024) load
I (125) esp_image: segment 2: paddr=00019afc vaddr=40080000 size=0651ch ( 25884) load
I (140) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=14a40h ( 84544) map
I (171) esp_image: segment 4: paddr=00034a68 vaddr=4008651c size=04c8ch ( 19596) load
I (179) esp_image: segment 5: paddr=000396fc vaddr=50000000 size=00010h ( 16) load
I (185) boot: Loaded app from partition at offset 0x10000
I (185) boot: Disabling RNG early entropy source...
I (200) cpu_start: Pro cpu up.
I (200) cpu_start: Starting app cpu, entry point is 0x40080fe8
0x40080fe8: call_start_cpu1 at D:/110_Work_ProductsResearch/111-Router/ESP32Work/esp-idf/components/esp_system/port/cpu_start.c:156
I (0) cpu_start: App cpu up.
I (214) cpu_start: Pro cpu start user code
I (214) cpu_start: cpu freq: 160000000
I (214) cpu_start: Application information:
I (219) cpu_start: Project name: hello_world
I (224) cpu_start: App version: 1
I (228) cpu_start: Compile time: Mar 29 2022 17:08:37
I (234) cpu_start: ELF file SHA256: 26a64d18e8b652d0...
I (240) cpu_start: ESP-IDF: v4.4-dirty
I (246) heap_init: Initializing. RAM available for dynamic allocation:
I (253) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (259) heap_init: At 3FFB2C28 len 0002D3D8 (180 KiB): DRAM
I (265) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (271) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (278) heap_init: At 4008B1A8 len 00014E58 (83 KiB): IRAM
I (285) spi_flash: detected chip: generic
I (289) spi_flash: flash io: dio
I (294) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Hello world!
This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision 3, 4MB embedded flash
Minimum free heap size: 293268 bytes
Restarting in 10 seconds...
Restarting in 9 seconds...
Restarting in 8 seconds...
Restarting in 7 seconds...
Restarting in 6 seconds...
Restarting in 5 seconds...
Restarting in 4 seconds...
至此,ESP32开发环境搭建完毕。
参考链接:
关注博主,可看到博主最新相关博文!
|