PlatformIO upload to a CH9102 chip?

I want to upload code to a ESP32 Wroom module. For that I have bought a Programmer Board where I can clip in the module for uploading the code. On the board ist the CH9102 chip. Unfortunately this doesn´t work in PlatformIO. I only get Exidcode 1. Other dev boards are working properly. I tried it in Arduino IDE with success. What have I to do to get it working? Sure something in platformio.ini.

Then PlatformIO must be capable of the same if you configure it correctly.

Go to File → Preferences and set the tickmark next to “Verbose Upload”. Press the upload button again. Copy paste the command that is shown in the log when the Arduino IDE tries to upload.

This is what Arduino UI says: v4.5.1
Serial port /dev/ttyCH343USB0
Failed to get PID of a device on /dev/ttyCH343USB0, using standard reset sequence.
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 3c:71:bf:10:90:6c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000e1fff...
Compressed 18992 bytes to 13112...
Writing at 0x00001000... (100 %)
Wrote 18992 bytes (13112 compressed) at 0x00001000 in 0.4 seconds (effective 357.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.0 seconds (effective 501.5 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 676.3 kbit/s)...
Hash of data verified.
Compressed 860112 bytes to 564096...
Writing at 0x00010000... (2 %)
Writing at 0x00015906... (5 %)
Writing at 0x000198ea... (8 %)
Writing at 0x0001d8e5...

I already set the upload_port in Platformio.ini to /dev/ttyCH343USB0 but this changed nothing

PlatformIO should use the exact same esptoolpy version.

Can you post the logs of “PlatformIO Upload”? is the same

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 (6.4.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 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)

  • 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-xtensa-esp32 @ 8.4.0+2021r2-patch5
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 36 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- ESP Async WebServer @ 1.2.3
    |-- AsyncElegantOTA @ 2.2.8
    |-- AsyncTCP @ 1.1.1
    |-- WiFi @ 2.0.0
    Building in release mode
    Linking .pio/build/recommended_specification/firmware.elf
    /home/uli/.platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld: .pio/build/recommended_specification/lib2b1/libESP Async WebServer.a(WebAuthentication.cpp.o):(.literal._ZL6getMD5PhtPc+0x4): undefined reference to mbedtls_md5_starts' /home/uli/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/recommended_specification/lib2b1/libESP Async WebServer.a(WebAuthentication.cpp.o): in function getMD5(unsigned char*, unsigned short, char*)‘:
    /home/uli/Dropbox/VSCode/ElegantOTA/.pio/libdeps/recommended_specification/ESP Async WebServer/src/WebAuthentication.cpp:73: undefined reference to `mbedtls_md5_starts’
    collect2: error: ld returned 1 exit status
    *** [.pio/build/recommended_specification/firmware.elf] Error 1
    ============================================================================ [FAILED] Took 17.43 seconds ============================================================================
  • Der Terminalprozess “platformio ‘run’, ‘–target’, ‘upload’, ‘–upload-port’, ‘/dev/ttyCH343USB0’” wurde mit folgendem Exitcode beendet: 1.
  • Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.

See → Update espressif 32 Version >4.1.0 leads to Error: collect2.exe: error: ld returned 1 exit status - #4 by maxgerhardt

I found the Solution / the Solutions.

Problem 1 is that Platformio don´t find the CH9201/CH343 chip on the USB Port. I had to force the upload_port in platformio.ini. To read the serial console I had to set the monitor port in addition. But it worked only when I set the monitor port in advance bevor I uploaded the code.
Problem 2 was the ElegantOTA library. In the log I only got yellow comments. I thought this are only warnings and not failures, but this made an error.
Solution 1 was to force platformio to use an older platform (espressiv32 → espressiv32@something older)
Solution 2 was to use a newer/different ElegantOTA Version (AsyncElegantOTA@2.2.8 → ElegantOTA@3.1.0)

Many things learned!!

1 Like