Upload to LilyGo T-Display S3 fails with esptool.py v4.4 (Solved)

I’ve been using PlatformIO for some time and successfully used it to create projects based on ESP8266 and ESP32. Not long ago, I did some initial work on a project using LilyGo T-Display (not S3) and that works fine. More recently, however, I’ve obtained a T-Display S3 board and am having real trouble getting the code to upload - I’ve never managed to do this yet with PlatformIO. I’ve even completely removed and reinstalled VSC and PIO to make sure I’m running the latest and greatest. In desperation, I tried uploading a sketch using the Arduino IDE - this works perfectly (as long as I put the chip in Boot mode), so I know the hardware is working OK.

In PIO, I get the failure shown below with the chip in run mode. If I put it into Boot mode, the output stops after detecting COM6 - nothing else happens until I disconnect the ESP32 S3.

This is on a Win11 system with all updates. PIO is using esptool.py 4.4, Arduino IDE is using esptool.exe 4.2.1. I tried replacing esptool.py with v4.2.1 but PIO simply overwrote it with v4.4. I also tried putting ‘platform_packages = tool-esptoolpy@4.2.1’ in platformio.ini but it couldn’t find that version.

I’m stuck and hope someone can give me a pointer or two as to what to try next.

Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, 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: COM6
Uploading .pio\build\esp32-s3-devkitc-1\firmware.bin
esptool.py v4.4
Serial port COM6
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 68:b6:b3:22:d7:2c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0005dfff...
Compressed 14768 bytes to 10149...
Writing at 0x00000000... (100 %)

A fatal error occurred: Packet content transfer stopped (received 1 bytes)
*** [upload] Error 2
============================================ [FAILED] Took 16.22 seconds ============================================

Ok, digging around some more, I found that the version number I used for esptool.py (4.2.1) is not how PIO manages the package number and I should have used ‘platform_packages = tool-esptoolpy@1.40201’ to get v4.2.1. Anyway, I’ve now tried 1.40300 and the upload to the ESP32 S3 works as expected, so there is a problem with v4.4 of esptool.py and the S3 chip (at least in its T-Display S3 form).

Hopefully, this will help someone else.