Platformio [upload] Error 1

Hi all,

I’ve started diving into the Module API because I want to decode text messages into commands that will trigger one of the GPIO on my Tbeam.

So I got as far as cloning the repo and building the cloned repo successfully but I keep getting an error on step 5 here… This is the output from my terminal:

 *  Executing task: platformio run --target upload 

Processing tbeam (board: ttgo-t-beam; platform: platformio/espressif32@^6.0.0; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/ttgo-t-beam.html
PLATFORM: Espressif 32 (6.0.1) > TTGO T-Beam
HARDWARE: ESP32 240MHz, 1.25MB 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.20006.221224 (2.0.6) 
 - tool-esptoolpy @ 1.40400.0 (4.4.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-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
[nanopb] Installing Protocol Buffers dependencies
Requirement already satisfied: protobuf>=3.19.1 in /Users/me/.platformio/penv/lib/python3.9/site-packages (4.22.0)
[nanopb] No generation needed.
Found 66 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ESP8266 and ESP32 OLED driver for SSD1306 displays @ 4.3.0+sha.da1ede4
|   |-- Wire @ 2.0.0
|-- OneButton @ 2.0.3
|-- arduino-fsm @ 2.2.0+sha.7db3702
|-- TinyGPSPlus @ 1.0.3+sha.127ad67
|-- Thread @ 0.0.0+sha.72921ac
|-- Nanopb @ 0.4.7
|-- ErriezCRC32 @ 1.0.1
|-- RadioLib @ 5.6.0+sha.1afa9470
|   |-- SPI @ 2.0.0
|-- QMC5883LCompass @ 1.1.1
|   |-- Wire @ 2.0.0
|-- NonBlockingRTTTL @ 1.3.0
|-- SparkFun ATECCX08a Arduino Library @ 1.3.0+sha.52b5282
|   |-- Wire @ 2.0.0
|-- PubSubClient @ 2.8.0
|-- NTPClient @ 3.2.1
|-- Syslog @ 2.0.0
|-- Adafruit BusIO @ 1.14.1
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit BMP280 Library @ 2.6.6
|   |-- Adafruit Unified Sensor @ 1.1.7
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|-- Adafruit BME280 Library @ 2.2.2
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit BME680 Library @ 2.0.2
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit MCP9808 Library @ 2.0.0
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit INA260 Library @ 1.5.0
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|-- Adafruit INA219 @ 1.2.1
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|-- Adafruit SHTC3 Library @ 1.0.1
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit LPS2X @ 2.0.4
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|   |-- SPI @ 2.0.0
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit SHT31 Library @ 2.2.0
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|-- Adafruit PM25 AQI Sensor @ 1.0.6
|   |-- Adafruit BusIO @ 1.14.1
|   |   |-- Wire @ 2.0.0
|   |   |-- SPI @ 2.0.0
|   |-- Wire @ 2.0.0
|-- esp32_https_server @ 1.0.0+sha.23665b3
|-- NimBLE-Arduino @ 1.4.1
|-- XPowersLib @ 0.1.4+sha.84b7373
|   |-- Wire @ 2.0.0
|-- ESP32 Codec2 @ 1.0.1
|-- SD @ 2.0.0
|   |-- FS @ 2.0.0
|   |-- SPI @ 2.0.0
|-- SPI @ 2.0.0
|-- WiFi @ 2.0.0
|-- Wire @ 2.0.0
|-- Preferences @ 2.0.0
|-- HTTPClient @ 2.0.0
|   |-- WiFi @ 2.0.0
|   |-- WiFiClientSecure @ 2.0.0
|   |   |-- WiFi @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
|   |-- WiFi @ 2.0.0
|-- WebServer @ 2.0.0
|   |-- WiFi @ 2.0.0
|   |-- FS @ 2.0.0
|-- ESPmDNS @ 2.0.0
|   |-- WiFi @ 2.0.0
|-- LittleFS @ 2.0.0
|   |-- FS @ 2.0.0
Building in release mode
Using meshtastic platformio-custom.py, firmware version 2.0.23.408c555f
Retrieving maximum program size .pio/build/tbeam/firmware.elf
Checking size .pio/build/tbeam/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   7.3% (used 95944 bytes from 1310720 bytes)
Flash: [========  ]  83.4% (used 2021817 bytes from 2424832 bytes)
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...
Auto-detected: /dev/cu.usbserial-54350039291
Uploading .pio/build/tbeam/firmware.bin
esptool.py v4.4
Serial port /dev/cu.usbserial-54350039291
Connecting............
Traceback (most recent call last):
Chip is ESP32-D0WDQ6-V3 (revision v3.0)
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool.py", line 34, in <module>
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
    esptool._main()
Crystal is 40MHz
MAC: 78:21:84:87:f3:3c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 1026, in _main
    main()
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 810, in main
    esp.flash_set_parameters(flash_size_bytes(args.flash_size))
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 1145, in flash_set_parameters
    self.check_command(
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 407, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 376, in command
    p = self.read()
  File "/Users/me/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 308, in read
    return next(self._slip_reader)
StopIteration
*** [upload] Error 1
======================================================================================== [FAILED] Took 26.90 seconds ========================================================================================

Environment    Status    Duration
-------------  --------  ------------
tbeam          FAILED    00:00:26.899
=================================================================================== 1 failed, 0 succeeded in 00:00:26.899 ===================================================================================

 *  The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

I was hoping to just upload the cloned library to test that it works right out of the gate before I go changing any other code but that doesn’t seem to be the case. Any help for a beginner would be greatly appreciated!

Thank you!

Another thing to note is that every time I “upload” and it fails, my Tbeam will become unresponsive to the user button and won’t switch between screens. I have to hit the reset button and then it works as normal. This is the only thing I’ve noticed happens after trying to upload.

Alright, so I solved it myself…

  1. The docker container is using an old version of esptool (4.4) and that never could find the port my radio was on. I activated the platformio penv and did a --force-reinstall of esptool to 4.5.1 and then it was able to start connecting.

  2. Then I was having another “Fatal Error: Invalid head of packet” so I found this troubleshooting link and eventually realized that I needed to specify the baud rate to be 115200. So in the file “variants/tbeam/platformio.ini” I changed the var “upload_speed” to 115200. The docs says to try 9600 but that couldn’t even finish connecting to the device and had its own error.

Hopefully this helps someone else who might be having similar issues to mine. I don’t fully understand why the repo would not be using the latest esptool and why it wouldn’t be using the correct baud rate for the device? I am quite new to this subject and am just trying to learn so if anyone has some insight that could help me understand, I would appreciate getting to know a little more.

Anyways, SOLVED! Cheers