What causes Error 1? | ESP32S2 Error 1

When uploading a script to an esp32-s2 it will upload correctly to the board (i can tell because it’s only a blink script) but I get an error 1 reported with verbose upload:

Processing custom-esp32 (platform: espressif32; board: ESP32-S2-SOLO-2-N4; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/ESP32-S2-SOLO-2-N4.html
PLATFORM: Espressif 32 (6.4.0) > ESP32-S2-SOLO-2-N4
HARDWARE: ESP32S2 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.20011.230801 (2.0.11) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
<lambda>(["checkprogsize"], [".pio/build/custom-esp32/firmware.elf"])
MethodWrapper(["checkprogsize"], [".pio/build/custom-esp32/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.4% (used 14560 bytes from 327680 bytes)
Flash: [==        ]  17.2% (used 225390 bytes from 1310720 bytes)
.pio/build/custom-esp32/firmware.elf  :
section                                                                                size         addr
.rtc.text                                                                                 0   1074200576
.rtc.dummy                                                                                0   1073340416
.rtc.force_fast                                                                           0   1073340416
.rtc_noinit                                                                              16   1342177280
.rtc.force_slow                                                                           0   1342177296
.iram0.vectors                                                                         1027   1073889280
.iram0.text                                                                           45736   1073890308
.dram0_reserved_for_iram                                                              46764   1073430528
.dram0.data                                                                            9976   1073477296
.noinit                                                                                   0   1073487272
.ext_ram.bss                                                                              0   1062207488
.dram0.bss                                                                             4584   1073487272
.flash.appdesc                                                                          256   1056964640
.flash.rodata                                                                         45020   1056964896
.flash.rodata_noload                                                                      0   1057009916
.flash.text                                                                          123631   1074266144
.iram0.text_end                                                                           0   1073936044
.dram0.heap_start                                                                         0   1073491856
.xt.prop                                                                             141396            0
.xt.lit                                                                                4160            0
.xtensa.info                                                                             56            0
.comment                                                                                102            0
.xt.lit._ZN3nvs4Lock4initEv                                                               0            0
.xt.prop._ZN3nvs4Lock4initEv                                                             72            0
.xt.lit._ZN14intrusive_listIN3nvs7Storage14NamespaceEntryEE17clearAndFreeNodesEv          0            0
.xt.prop._ZN14intrusive_listIN3nvs7Storage14NamespaceEntryEE17clearAndFreeNodesEv       108            0
.xt.prop._ZN14intrusive_listIN3nvs7Storage14NamespaceEntryEE9push_backEPS2_              60            0
.xt.lit._ZN3nvs12NVSPartitionD5Ev                                                         0            0
.xt.prop._ZN3nvs12NVSPartitionD5Ev                                                        0            0
.xt.prop._ZN3nvs12NVSPartitionD2Ev                                                       36            0
.xt.prop._ZN3nvs12NVSPartitionD0Ev                                                       36            0
.xt.prop._ZTVN3nvs12NVSPartitionE                                                        12            0
.xt.lit._ZN3nvs19NVSPartitionManagerD5Ev                                                  0            0
.xt.prop._ZN3nvs19NVSPartitionManagerD5Ev                                                 0            0
.xt.prop._ZN3nvs19NVSPartitionManagerD2Ev                                                36            0
.xt.prop._ZN3nvs19NVSPartitionManagerD0Ev                                                36            0
.xt.prop._ZN14intrusive_listIN3nvs12NVSPartitionEE5eraseENS2_8iteratorE                  84            0
.xt.prop._ZTVN3nvs19NVSPartitionManagerE                                                 12            0
.xt.prop._ZN14intrusive_listIN3nvs8HashList13HashListBlockEE5eraseENS3_8iteratorE        84            0
.xt.lit._ZN3nvs4ItemC5EhNS_8ItemTypeEhPKch                                                0            0
.xt.prop._ZN3nvs4ItemC5EhNS_8ItemTypeEhPKch                                               0            0
.xt.prop._ZN3nvs20isVariableLengthTypeENS_8ItemTypeE                                     48            0
.xt.prop._ZN3nvs4ItemC2EhNS_8ItemTypeEhPKch                                              60            0
.xt.prop._ZNK19CompressedEnumTableIN3nvs4Page10EntryStateELj2ELj126EE3getEjPS2_          48            0
.xt.lit._ZN14intrusive_listIN3nvs4PageEE5clearEv                                          0            0
.xt.prop._ZN14intrusive_listIN3nvs4PageEE5clearEv                                        60            0
.xt.prop._ZN14intrusive_listIN3nvs4PageEE9push_backEPS1_                                 60            0
.xt.prop._ZN14intrusive_listIN3nvs4PageEE5eraseENS2_8iteratorE                           84            0
.xt.lit._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv                                   8            0
.xt.lit._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv                                 8            0
.xt.lit._ZN9__gnu_cxx24__concurrence_lock_errorD5Ev                                       8            0
.xt.lit._ZN9__gnu_cxx26__concurrence_unlock_errorD5Ev                                     8            0
.xt.lit._ZN9__gnu_cxx7__mutex4lockEv                                                      8            0
.xt.lit._ZN9__gnu_cxx13__scoped_lockD5Ev                                                  8            0
.xt.prop._ZNK9__gnu_cxx24__concurrence_lock_error4whatEv                                 48            0
.xt.prop._ZNK9__gnu_cxx26__concurrence_unlock_error4whatEv                               48            0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD5Ev                                     12            0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD5Ev                                   12            0
.xt.prop._ZN9__gnu_cxx7__mutex4lockEv                                                    48            0
.xt.prop._ZN9__gnu_cxx13__scoped_lockD5Ev                                                12            0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD2Ev                                     36            0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD2Ev                                   36            0
.xt.prop._ZN9__gnu_cxx24__concurrence_lock_errorD0Ev                                     36            0
.xt.prop._ZN9__gnu_cxx26__concurrence_unlock_errorD0Ev                                   36            0
.xt.prop._ZN9__gnu_cxx13__scoped_lockD2Ev                                                72            0
.xt.prop._ZTISt9exception                                                                12            0
.xt.prop._ZTIN9__gnu_cxx24__concurrence_lock_errorE                                      12            0
.xt.prop._ZTIN9__gnu_cxx26__concurrence_unlock_errorE                                    12            0
.xt.prop._ZTVN9__gnu_cxx24__concurrence_lock_errorE                                      12            0
.xt.prop._ZTVN9__gnu_cxx26__concurrence_unlock_errorE                                    12            0
.xt.prop._ZTISt9bad_alloc                                                                12            0
.xt.prop._ZTVN10__cxxabiv120__si_class_type_infoE                                        12            0
.xt.prop._ZTVN10__cxxabiv117__class_type_infoE                                           12            0
.debug_frame                                                                          55920            0
.debug_info                                                                         2857992            0
.debug_abbrev                                                                        237394            0
.debug_aranges                                                                        22440            0
.debug_ranges                                                                         62776            0
.debug_line                                                                         1062719            0
.debug_str                                                                           263963            0
.debug_loc                                                                           465140            0
Total                                                                               5452544
<lambda>(["upload"], [".pio/build/custom-esp32/firmware.bin"])
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
BeforeUpload(["upload"], [".pio/build/custom-esp32/firmware.bin"])
Auto-detected: /dev/cu.usbmodem01
"/Users/freddy/.platformio/penv/bin/python" "/Users/freddy/.platformio/packages/tool-esptoolpy/esptool.py" --chip esp32s2 --port "/dev/cu.usbmodem01" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 "/Users/freddy/Library/Mobile Documents/com~apple~CloudDocs/Code/Arduino/Test-Blink/.pio/build/custom-esp32/bootloader.bin" 0x8000 "/Users/freddy/Library/Mobile Documents/com~apple~CloudDocs/Code/Arduino/Test-Blink/.pio/build/custom-esp32/partitions.bin" 0xe000 /Users/freddy/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 .pio/build/custom-esp32/firmware.bin
esptool.py v4.5.1
Serial port /dev/cu.usbmodem01
Connecting....
Chip is ESP32-S2 (revision v1.0)
Features: WiFi, No Embedded Flash, No Embedded PSRAM, ADC and temperature sensor calibration in BLK2 of efuse V2
Crystal is 40MHz
MAC: a0:76:4e:8c:57:56
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00047fff...
Compressed 14720 bytes to 10221...
Writing at 0x00001000... (20 %)
Writing at 0x00001c5a... (40 %)
Writing at 0x000027ac... (60 %)
Writing at 0x000032d6... (80 %)
Writing at 0x00003c4c... (100 %)
Wrote 14720 bytes (10221 compressed) at 0x00001000 in 0.2 seconds (effective 523.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 472.4 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 753.3 kbit/s)...
Hash of data verified.
Compressed 225760 bytes to 127079...
Writing at 0x00010000... (1 %)
- [TRUNCATED]
Writing at 0x00046500... (98 %)
Writing at 0x00047147... (100 %)
Wrote 225760 bytes (127079 compressed) at 0x00010000 in 2.1 seconds (effective 877.2 kbit/s)...
Hash of data verified.

Leaving...
WARNING: ESP32-S2 (revision v1.0) chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually.
To suppress this note, set --after option to 'no_reset'.
*** [upload] Error 1

Is this simply because the board is in boot mode?
What does error 1 mean?
How can I resolve this error?

Is there a specific reason for this outdated version and does the error also occur with the current version (6.7.0)?

No specific reason, I never realised it was outdated. I updated to 6.7.0 and got the same behaviour

Please share your platformio.ini and a basic sketch to reproduce this.
Also perform a full clean.

Performed full clean and got the same result. I am using environment [env:custom-esp32]

platformio.ini

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

[env:esp32-S2]
platform = espressif32
# platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#esp32s2
board = esp32-s2-saola-1
board_build.f_cpu = 240000000L
framework = arduino
board_build.mcu = esp32s2
debug_tool = esp-prog

[env:custom-esp32]
platform = espressif32
board = ESP32-S2-SOLO-2-N4
framework = arduino

Custom board .json

{
    "build": {
        "f_cpu": "240000000L",
        "f_flash": "80000000L",
        "hwids": [
            [
                "0x303A",
                "0x0002"
            ]
        ],
        "core": "esp32",
        "extra_flags": "-DARDUINO_ESP32S2_DEV",
        "flash_mode": "qio",
        "mcu": "esp32s2",
        "variant": "esp32s2"
    },
    "debug": {
        "openocd_target": "esp32s2.cfg"
    },
    "frameworks": [
        "arduino",
        "espidf"
    ],
    "name": "ESP32-S2-SOLO-2-N4",
    "upload": {
        "flash_size": "4MB",
        "maximum_ram_size": 327680,
        "maximum_size": 4194304,
        "require_upload_port": true,
        "speed": 460800
    },
    "url": "https://www.espressif.com/sites/default/files/documentation/esp32-s2-solo-2_esp32-s2-solo-2u_datasheet_en.pdf",
    "vendor": "Espressif"
}

Simple header include/ESP32-S2-SOLO-2-N4.hpp

#define LED_BUILTIN_1 1
#define LED_BUILTIN_2 2

main.cpp

#include <Arduino.h>
#include "ESP32-S2-SOLO-2-N4.hpp"

// the setup function runs once when you press reset or power the board
void setup()
{
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN_1, OUTPUT);
  pinMode(LED_BUILTIN_2, OUTPUT); // Second built in LED
}

// the loop function runs over and over again forever
void loop()
{
  digitalWrite(LED_BUILTIN_1, HIGH); // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN_2, LOW);

  delay(1000); // wait for a second

  digitalWrite(LED_BUILTIN_1, LOW); // turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN_2, HIGH);

  delay(1000);
}

I’ve just swapped to using an esp-prog to upload the code via jtag. It does everything I need and it returns a success code.