Upload_speed not respected

Hi, i’ve just started using platformio on visual studio code on Mac OS Ventura, but when changing the upload_speed value inside the ini file is not respected.

It fails uploading to an LILYGO TTGO ESP32-Paxcounter LoRa32 .

extract from .ini:

[env:usb]
upload_protocol = esptool
upload_speed = 115200
monitor_speed = 115200

the log displays:

Building in release mode
Retrieving maximum program size .pio/build/usb/firmware_ttgov21new_v3.6.1.elf
Checking size .pio/build/usb/firmware_ttgov21new_v3.6.1.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [== ] 19.9% (used 65248 bytes from 327680 bytes)
Flash: [======= ] 65.3% (used 1283321 bytes from 1966080 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…
Using manually specified: /dev/cu.usbserial-56750049631
Uploading .pio/build/usb/firmware_ttgov21new_v3.6.1.bin
esptool.py v4.5.1
Serial port /dev/cu.usbserial-56750049631
Connecting…
Chip is ESP32-PICO-D4 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d4:d4:da:9e:ae:84
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 921600
Changed.

A fatal error occurred: Unable to verify flash chip connection (Packet content transfer stopped (received 7 bytes)).
*** [upload] Error 2

What is the full platformio.ini?

; ---> SELECT ONE TARGET BOARD FROM FOLLOWING ROWS <---
;
; Note: For "LILYGO TTGO ESP32-Paxcounter LoRa32 V2.1 1.6.1" select board ttgov21new.h
; Note: For "LILYGO TTGO ESP32-Paxcounter LoRa32 V2.0 1.6.0" select board ttgov2.h and add bodge wire from LORA_IO1 to GPIO33
;
;
[board]
;halfile = generic.h
;halfile = ebox.h
;halfile = eboxtube.h
;halfile = ecopower.h
;halfile = heltec.h
;halfile = heltecv2.h
;halfile = heltecv21.h
;halfile = ttgov1.h
;halfile = ttgov2.h
;halfile = ttgov21old.h
halfile = ttgov21new.h
;halfile = ttgofox.h
;halfile = ttgobeam.h
;halfile = ttgobeam10.h
;halfile = ttgotdisplay.h
;halfile = ttgotwristband.h
;halfile = fipy.h
;halfile = lopy.h
;halfile = lopy4.h
;halfile = lolin32litelora.h
;halfile = lolin32lora.h
;halfile = lolin32lite.h
;halfile = wemos32oled.h
;halfile = wemos32matrix.h
;halfile = octopus32.h
;halfile = tinypico.h
;halfile = tinypicomatrix.h
;halfile = m5core.h
;halfile = m5fire.h
;halfile = olimexpoeiso.h

[platformio]
; upload firmware to board with usb cable
default_envs = usb
; upload firmware to a paxexpress repository
;default_envs = ota
; use upstream version of arduino-espressif32 framework
;default_envs = dev
description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around.

[common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 3.6.1
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 0
extra_scripts = pre:shared/build.py
otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@6.3.2
monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_lora =
    mcci-catena/MCCI LoRaWAN LMIC library @ ^4.1.1
lib_deps_display =
    bitbank2/OneBitDisplay @ ^2.3.1
    bitbank2/bb_spi_lcd @ ^2.4.1
    ricmoo/QRCode @ ^0.0.1
lib_deps_ledmatrix =
    seeed-studio/Ultrathin_LED_Matrix @ ^1.0.0
lib_deps_rgbled =
    fastled/FastLED @ ^3.6.0
lib_deps_gps =
    mikalhart/TinyGPSPlus @ ^1.0.3
lib_deps_sensors =
    adafruit/Adafruit Unified Sensor @ ^1.1.11
    adafruit/Adafruit BME280 Library @ ^2.2.2
    adafruit/Adafruit BMP085 Library @ ^1.2.2
    boschsensortec/BSEC Software Library @ 1.8.1492
    lewapek/Nova Fitness Sds dust sensors library @ ^1.5.1
lib_deps_basic =
    https://github.com/dbSuS/libpax.git
    https://github.com/SukkoPera/Arduino-Rokkit-Hash.git
    bblanchon/ArduinoJson @ ^6.21.3
    makuna/RTC @ ^2.4.2
    mathertel/OneButton @ ^2.0.3
    lewisxhe/XPowersLib @ ^0.1.7
    256dpi/MQTT @ ^2.5.1
lib_deps_all =
    ${common.lib_deps_basic}
    ${common.lib_deps_lora}
    ${common.lib_deps_display}
    ${common.lib_deps_rgbled}
    ${common.lib_deps_gps}
    ${common.lib_deps_sensors}
    ${common.lib_deps_ledmatrix}
build_flags_all =
    -include "shared/paxcounter.conf"
    '-D CORE_DEBUG_LEVEL=${common.debug_level}'
    '-D LOG_LOCAL_LEVEL=${common.debug_level}'
    '-D PROGVERSION="${common.release_version}"'
    '-D LIBPAX_WIFI'
    '-D LIBPAX_BLE'
    '-D LIBPAX_ARDUINO'
    '-D USE_ESP_IDF_LOG'
    '-D TAG=__FILE__'
    '-U BOARD_HAS_PSRAM'

[env]
framework = arduino
board = esp32dev
board_build.partitions = min_spiffs.csv
build_type = release
upload_speed = ${common.upload_speed}
;upload_port = COM12
platform = ${common.platform_espressif32}
lib_deps = ${common.lib_deps_all}
build_flags =
    -include "shared/hal/${board.halfile}"
    ${common.build_flags_all}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
monitor_filters = time, esp32_exception_decoder, default

[env:ota]
upload_protocol = custom

[env:usb]
upload_protocol = esptool
upload_speed = 115200
monitor_speed = 115200
; necessary for macos - adjust devicename accordingly
;upload_port = /dev/cu.usbserial-56750049631
;monitor_port = /dev/cu.usbserial-56750049631

[env:dev]
upload_protocol = esptool
platform = https://github.com/platformio/platform-espressif32.git#develop
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

[env:ci]
build_flags =
    -include "shared/hal/${sysenv.CI_HALFILE}" ; set by CI
    ${common.build_flags_all}
upload_protocol = esptool

PlatformIO definitely respects upload_speed by passing the wanted value into the esptool.py invocation. For example,

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

When doing a verbose upload (project tasks → Advanced → Verbose Upload), it prints

“/home/xxxxxxx/.platformio/penv/bin/python” “/home/xxxxxxx/.platformio/packages/tool-esptoolpy/esptool.py” --chip esp32 --port “/dev/ttyACM0” --baud 74880 […]

Do the same in your project. Does it pass 921600 or 115200? In the first case, another extra_script may have overwritten your upload_speed directive, such as

In the second case (esptool.py gets passed 115200 but stil uses 921600), it’s an esptool.py issue, not PlatformIO.

ok I see baud at 921600 in command.

/Users/neogene/.platformio/packages/tool-esptoolpy/esptool.py" --chip esp32 --port "/dev/cu.usbserial-56750049631" --baud **921600** --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /Users/neogene/Downloads/Safari/ESP32-Paxcounter-3.6.1/.pio/build/usb/bootloader.bin 0x8000 /Users/neogene/Downloads/Safari/ESP32-Paxcounter-3.6.1/.pio/build/usb/partitions.bin 0xe000 /Users/neogene/.platformio/packages/framework-arduinoespressif32@3.20009.0/tools/partitions/boot_app0.bin 0x10000 .pio/build/usb/firmware_ttgov21new_v3.6.1.bin

Looking build.py it uses:

myboard = mykeys["board"]
myuploadspeed = mykeys["upload_speed"]
env.Replace(BOARD=myboard)
env.Replace(UPLOAD_SPEED=myuploadspeed)
print('\033[94m' + "Target board: " + myboard + " @ " + myuploadspeed + "bps" + '\033[0m')

ok found: the related file has a comment in the first lines which declare the value of the upload speed, and it parse that file getting the speed (never seen used a comment as a param but now i manage to upload). Thank you for the support.

Thank you.

// clang-format off

// upload_speed 115200

// board esp32dev

#ifndef _TTGOV21NEW_H

#define _TTGOV21NEW_H

#include <stdint.h>