No automatic upload on ESP32-S3-Minni

Hello,
I am new to platformIO community and try my best to not go against any community rules. After spending a lot of time reading posts on different forums I have not come any close to a solution.

Hardware

I currently work with a custom designed board based on a ESP32-S3-Minni-1 MCN4R2. This unit has 4 MB QSPI Flash and 2 MB QSPI RAM. The board uses a USB connection into pins 23 and 24, has a boot switch and a reset switch. IO 45 is not used and IO46 is tied to GND. Currently IO3 is tied to 3.3V.

Behavior

When I first push the boot switch and then the reset switch the unit moves into bootloading mode as it should and I can upload my firmware. Based on many comments online I was hoping that I would have to do this only for the first upload and consecutive uploads would automatically work.

Unfortunately that is not the case. Not only that, the board also does not reset after a firmware upload. Only after a manual reboot the new code can be used.

Error Messages

Depending on the entries in platformio.ini the error messages differ. I either get:

  • A serial exception error occurred: Write timeout
  • A fatal error occurred: Failed to connect to ESP32-S3: Wrong boot mode detected (0x2b)! The chip needs to be in download mode.
  • Failed to get PID of a device on com12

platformio.exe device list results in:

COM12
-----
Hardware ID: USB VID:PID=303A:1001 SER=E8:06:90:96:EE:18
Description: USB Serial Device (COM12)

Board definitions

I have experimented a lot with the content of platformio.ini and BD612.json. They currently are:

[env:BD612]
board = BD612
framework = arduino
platform = espressif32
;upload_port = COM12
;
; [env:esp32-s3-devkitc-1]
; platform = espressif32
; board = esp32-s3-devkitc-1
; framework = arduino
;
; board_build.arduino.memory_type = qio_qspi
; board_build.flash_mode = qio
; board_build.psram_type = qio
; board_upload.flash_size = 4MB
; board_upload.maximum_size = 4194304
; board_build.partitions = default.csv
; board_build.extra_flags = -DBOARD_HAS_PSRAM

The upload does not change if I use [env:BD612] or [env:esp32-s3-devkitc-1] I have tried both.

The BD612.json file is currently:

{
“build”: {
“arduino”:{
“ldscript”: “esp32s3_out.ld”,
“partitions”: “default.csv”,
“memory_type”: “qio_opi”
},
“core”: “esp32”,
“extra_flags”: [
“-DBOARD_HAS_PSRAM”,
“-DARDUINO_USB_MODE=1”,
“-DARDUINO_USB_CDC_ON_BOOT=1”,
“-DARDUINO_ESP32S3_DEV”
],
“f_cpu”: “240000000L”,
“f_flash”: “80000000L”,
“flash_mode”: “qio”,
“hwids”: [
[
“0X303A”,
“0x1001”
]
],
“mcu”: “esp32s3”,
“variant”: “esp32s3”
},
“connectivity”: [
“wifi”,
“bluetooth”
],
“debug”: {
“default_tool”: “esp-builtin”,
“onboard_tools”: [
“esp-builtin”
],
“openocd_target”: “esp32s3.cfg”
},
“frameworks”: [
“arduino”,
“espidf”
],
“name”: “BD612”,
“upload”: {
“flash_size”: “4MB”,
“maximum_ram_size”: 327680,
“maximum_size”: 4194304,
“require_upload_port”: true,
“speed”: 460800
},
“url”: “https://www.somename.com”,
“vendor”: “Vendorname”
}

On a few occasions the automatic upload worked but I was never able to understand why and how I could make it a regular occurence.

Any help is greatly appreciated.

Thanks

Does it fail in the Arduino IDE too? Then it wouldn’t be PlatformIO specific.

On the Espressif forums, someone might know more.

I have to admit that I am not very familiar with the Arduino environment. Do you by any chance could point me into the direction of a document describing how to set up a custom board?

Kind regards

Try to select “ESP32S3 dev module” and then closely matches your hardware in terms of at least ESP32S3, flash type, size and connection type (e.g. 4MB QIO SPI) through the configuration menu.

The Arduino IDE 2.x can be found at https://www.arduino.cc/en/software/ and the Arduino-ESP32 core documentation at https://docs.espressif.com/projects/arduino-esp32/en/latest/:

Many thanks,
I will try that this evening.

I tried a very simple blinky code on the Arduino IDE and uploaded it to the custom board. The code complies and gets uploaded without any issues. The board resets and executes the code.
Then I created a new project in PIO using the esp32-s3-devkitm-1 as board, copied the simple Arduino code and hit upload. It failed as before.

The first difference I noticed is the difference in version of the esptool. Arduino uses v4.8.1 PIO uses v4.5.1. I found this explanation how to use a different esptool version in pio and installed esptools v4.8.1.

Finally I added the line

platform_packages = tool-esptoolpy@^1.40801.0

to platformio.ini.

Unfortunately the result is that pio complains about a missing module:

ModuleNotFoundError: No module named ‘intelhex’

Based on the platformIO documentation for adding a custom python package. I added the following lines:

platform_packages = tool-esptoolpy@^1.40801.0
extra_scripts = extra_script.py

and a small file extra_script.py with:

Import(“env”)
#
# Install custom packages from the PyPi registry
env.Execute(“$PYTHONEXE -m pip install intelhex”)

Now when I upload the code everything works.

Finally I added these settings to my actual project and that now uploads fine as well.

Many thanks, again for recommending the test on the Arduino IDE. It made me realize that I have to use a newer version of epstool.

If you need a newer esptool.py version, you might want to consider upgrading to the pioarduino version of the espressif32 platform, and not the official PlatformIO provided one. It will give you the latest Arduino-ESP32 3.x core along with a more up-to-date esptoolpy package.

See https://github.com/pioarduino/platform-espressif32

For example, in your platformio.ini, you can explicitly write

platform = https://github.com/pioarduino/platform-espressif32.git

for that updated version, or

platform = espressif32@6.11.0

to get the current latest version of the official platform.

That is a great tip.
Many thanks