EPS32+Platform+Arduino 跑马灯

软硬件平台

硬件使用ESP32 D0WQ6,是在淘宝上购买的一个核心功能板,用做simplFOC的核心控制板。

软件平台使用Arduino,Arduino-ESP32有详细介绍ESP32针对arduino平台做的library和API接口

IDE软件采用PlatformIO,主要因为这个IDE比Arduino IDE的编译速度快很多。Arduino IDE简单易用,但是编译上传实在太慢,忍无可忍才找到了PlatforIO来替换

环境搭建

platformIO整个环境的搭建和使用已经有很多文章了,可以参考VSCode + PlatformIO + STM32/ESP32 ARDUINO。这里主要记录下测试跑马灯时的问题。具体程序可以看下节跑马灯程序及配置。

新建工程后,首次编译没有问题,首次点击 upload 提示Tool Manager: Installing platformio/tool-mkspiffs @ ~2.230.0,这里需要安装一系列的upload工具套件,必须关闭网络加速/代理,否则会一直停在这里,超时后会报错:终端将被任务重用 按任意键关闭。
在这里插入图片描述
我的环境需要安装的套件:

Installing platformio/tool-mkspiffs @ ~2.230.0
Installing platformio/tool-mklittlefs @ ~1.203.0
Installing platformio/tool-mkfatfs @ ~2.0.0

跑马灯程序及配置

跑马灯程序代码如下:

#include <Arduino.h>

#define LED 22
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED as an output.
  pinMode(LED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(LED, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                       // wait for a second
}

配置文件platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

upload_port = COM10

如下图点击上传后,platformio会进行编译,上传,过程提示如下
在这里插入图片描述

 *  正在执行任务: C:\Users\49196\.platformio\penv\Scripts\platformio.exe run --target upload --environment esp32dev 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.0.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20003.220626 (2.0.3)
 - tool-esptoolpy @ 1.30300.0 (3.3.0)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 32 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Linking .pio\build\esp32dev\firmware.elf
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.9% (used 16148 bytes from 327680 bytes)
Flash: [==        ]  16.2% (used 212701 bytes from 1310720 bytes)
Building .pio\build\esp32dev\firmware.bin
esptool.py v3.3
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Using manually specified: COM10
Uploading .pio\build\esp32dev\firmware.bin
esptool.py v3.3
Serial port COM10
Connecting.....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 78:21:84:79:43:2c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00044fff...
Compressed 17088 bytes to 11848...
Writing at 0x00001000... (100 %)
Wrote 17088 bytes (11848 compressed) at 0x00001000 in 0.5 seconds (effective 286.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 586.7 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 656.9 kbit/s)...
Hash of data verified.
Compressed 213088 bytes to 115386...
Writing at 0x00010000... (12 %)
Writing at 0x0001dcac... (25 %)
Writing at 0x0002334b... (37 %)
Writing at 0x000285ed... (50 %)
Writing at 0x0002e68a... (62 %)
Writing at 0x00038862... (75 %)
Writing at 0x0003e351... (87 %)
Writing at 0x00043c6c... (100 %)
Wrote 213088 bytes (115386 compressed) at 0x00010000 in 2.9 seconds (effective 592.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
================================================= [SUCCESS] Took 14.34 seconds =================================================
 *  终端将被任务重用,按任意键关闭。 

看到[SUCCESS] 提示,耗时14.34 seconds。下载运行成功

参考

  1. 使用VScode开发ESP32,PlatformIO开发ESP32
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值