Uploading Issue with STM32F103C8T6 Varient(Bluepill) via USB

Board

STM32F103C8T6 Varient(Bluepill)

Operation System

Windows 10

IDE

PlatformIO Core 6.1.13

Framework

Arduino

Discription

The PIO terminal said upload success but clearly it’s not (LED not blinking)

Sketch

#include "Arduino.h"

#define LED PC13

void setup()
{
  pinMode(LED, OUTPUT);
}

void loop()
{
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}

Debug Message

Processing genericSTM32F103C8 (platform: ststm32; board: genericSTM32F103C8; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103C8.html
PLATFORM: ST STM32 (17.2.0) > STM32F103C8 (20k RAM. 64k Flash)
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.20701.0 (2.7.1)
 - framework-cmsis @ 2.50900.0 (5.9.0)
 - tool-dfuutil @ 1.11.0
 - tool-openocd @ 3.1200.0 (12.0)
 - tool-stm32duino @ 1.0.2
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\genericSTM32F103C8\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.5% (used 1132 bytes from 20480 bytes)
Flash: [==        ]  16.6% (used 10872 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, serial, stlink
CURRENT: upload_protocol = dfu
Looking for upload port...
Auto-detected: COM12
Uploading .pio\build\genericSTM32F103C8\firmware.bin
'java' \xa4\xa3\xacO\xa4\xba\xb3\xa1\xa9Υ~\xb3\xa1\xa9R\xa5O\xa1B\xa5i\xb0\xf5\xa6檺\xb5{\xa6\xa1\xa9Χ妸\xc0ɡC
========================= [SUCCESS] Took 2.16 seconds =========================

Other Steps to Reproduce

I unsolder ESP8226 on WEMOS’s D1 mini for USB to TTL.
This is working cuz STM32 Flash Loader can read and flash it properly
stm32 bootloader

platform.ini

[env:genericSTM32F103C8]

platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = dfu

I tried both genericSTM32F103C8 and bluepill_f103c8 but both of them show same result.
It’s even worse if I specified port in .ini the terminal sort of break itself (the result [SUCCESS] appeared on weird place)

[env:genericSTM32F103C8]

platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = dfu
upload_port = \\.\COM12

image

Any advice is greatly appreciated.
Best,

This Java DFU (Maple) uploader has always been problematic.

Open a terminal (Windows + R → cmd.exe) and execute

java -jar C:\Users\Max\.platformio\packages\tool-stm32duino\maple_loader.jar COM12 2 1EAF:0003 test.bin

While you adapt the path for the username. What does that output?

1 Like

Hi,Thanks for your reply
it show the following error

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=28868, tid=0x0000000000006b54
#
# JRE version: Java(TM) SE Runtime Environment (8.0_401) (build 1.8.0_401-b10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.401-b10 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [jSSC-2.8_x86_64.dll+0xb5db]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

It seems like a known java issue
I saw someone mention that enabling coredump by running the following command can solve this:
java -jar crasher.jar -XX:+CreateCoredumpOnCrash
Since I’m not familiar with Java, would you recommend me doing this?

Interesting, when I execute such a command I get

C:\Users\Max\.platformio\packages\tool-stm32duino>java -jar C:\Users\Max\.platformio\packages\tool-stm32duino\maple_loader.jar COM12 2 1EAF:0003 test.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

Searching for DFU device [1EAF:0003]...

and not a crash. My Java version is

>java --version
java 17.0.7 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

You may want to try that exact version for fun?

https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html or similiar.

I tried it, but no luck. It shows the same error as last time

If I’m tied to using USB for uploading, are there other uploader options?

same here, but in another computer it works.
I did the trick, and maybe solved for others too:

  1. download from Releases · java-native/jssc · GitHub the source.
  2. rename jssc.dll to jSSC-2.8_x86_64.dll
  3. copy c:\users\username.jssc\jSSC-2.8_x86_64.dll

done.