Newbie cannot get DTR reset working on standard Blue Pill

STM32duino bootloader aka Maple bootloader
Post Reply
EvAndyB
Posts: 3
Joined: Wed Jul 07, 2021 5:31 pm

Newbie cannot get DTR reset working on standard Blue Pill

Post by EvAndyB »

New to STM32duino. Not new to Arduinos generally. Apologies if this is an FAQ but I did not find it in the "Please read first" or the "FAQs" pages.
Can anyone here help me ?

Windows 10 21H1 Intel x64.
Everything works fine using standard ST-LinkV2 so my board is definitely alive.
Board is a pretty standard looking Blue Pill with a F103C8T6. I've also checked it has the correct 1.5K pullup on USBD-/A12.

I flashed Roger's generic_boot20_pc13.bin from github binaries dir into it at 0x08000000 using ST-Link with BOOT0 and BOOT1 both jumpered to gnd.

Arduino IDE is 1.8.13 been installed for a while, other (not STM32 things but AVR and SAMD stuff) all working fine.
All the arduino bits installed OK.
Opening a Terminal Window in Arduino gives me Roger's default message that the bootloader installed OK.

Settings in Tools menu are :-
Board: Generic STM32F1 series
Board Part Number: "BluePill F103C8"
USART Support: Disabled
USB Support: CDC supercedes USART
USB Speed: Low/Full
Upload method: Maple DFU Bootloader2.0
Port: COM16 (identified using device manager)

I think those are right (anyone confirm?). It's hard to be sure as there are older versions of the instructions about that don't quite match what options I see.

So, I tried to build and download the standard BLINK sketch but I get this error :-

Sketch uses 10860 bytes (16%) of program storage space. Maximum is 65536 bytes.
Global variables use 824 bytes (4%) of dynamic memory, leaving 19656 bytes for local variables. Maximum is 20480 bytes.
maple_loader v0.1
Resetting to bootloader via DTR pulse
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000007110b5db, pid=5128, tid=0x00000000000031ac
#
# JRE version: Java(TM) SE Runtime Environment (8.0_291-b10) (build 1.8.0_291-b10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.291-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
#
# An error report file with more information is saved as:
# C:\Users\andy\AppData\Local\Arduino15\packages\STMicroelectronics\tools\STM32Tools\2.0.0\win\hs_err_pid5128.log
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by stevestrong »

I think you should update Java on your computer.
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by ag123 »

use java 1.8 if things 'don't work, later java versions changed lots of things
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by fpiSTM »

This is a known issue:
https://github.com/stm32duino/Arduino_Tools/issues/67

I plan to remove the .jar to avoid such issue. Same issue has been met with libmaple core a fix has been merged anyway it does not cover all cases.
EvAndyB
Posts: 3
Joined: Wed Jul 07, 2021 5:31 pm

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by EvAndyB »

I currently have Java 1.8.0 build 192 installed.

Thanks fpiSTM. Adding the path-mod line to maple_upload.bat fixed the wrong java version exception however the COM port now disappears for good when the maple_loader sends the DTR pulse. The board then sits there flashing PC13 but it's not my download doing it. COM16 only re-appears when i press the reset button on the board. COM16 (when it is there) VID:PID is 1EAF:0004, not 0003 mentioned in text below.

Output (after fresh board reset) now looks like this :-

Sketch uses 23504 bytes (35%) of program storage space. Maximum is 65536 bytes.
Global variables use 3552 bytes (17%) of dynamic memory, leaving 16928 bytes for local variables. Maximum is 20480 bytes.
maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

dfu-util - (C) 2007-2008 by OpenMoko Inc.
Couldn't find the DFU device: [1EAF:0003]
This program is Free Software and has ABSOLUTELY NO WARRANTY


timeout waiting for COM16 serial
EvAndyB
Posts: 3
Joined: Wed Jul 07, 2021 5:31 pm

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by EvAndyB »

Ah, OK, my bad.
Now that the java exception thing is sorted I realised that my remaining problem is because I have not installed the drivers.

Same problem as here :-
https://stm32duinoforum.com/forum/viewt ... _3904.html

So, I picked up the drivers from here (in drivers subdir)

https://github.com/rogerclarkmelbourne/Arduino_STM32

and ran the install_drivers.bat file. That took quite a surprisingly long time (like a minute maybe) with nothing happening but after that everything works. I do get the error after download but ignoring that it seems OK.

error resetting after download: usb_reset: could not reset device, win error: A device which does not exist was specified.
(Full output copied below)

Thanks all.
------------

Sketch uses 20956 bytes (31%) of program storage space. Maximum is 65536 bytes.
Global variables use 3276 bytes (15%) of dynamic memory, leaving 17204 bytes for local variables. Maximum is 20480 bytes.
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]...
Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=424
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: A device which does not exist was specified.


state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Newbie cannot get DTR reset working on standard Blue Pill

Post by ag123 »

that 'error resetting' message can be ignored. press reset manually

ok here is a little blurb about that DTR reset thingy, since the 'old' libmaple days, the designers built in a 'magic' sequence.
DTR '1' 'E' 'A' 'F', when usb serial sees this, it triggers a software reset so that it goes to the boot loader.
this is the same as if you press that reset button.

on the pc side, it is 'triggered' by a java (possibly processing derived) app the source is there
https://github.com/rogerclarkmelbourne/ ... ple_loader
https://github.com/rogerclarkmelbourne/ ... .java#L139
the thing is all is good till java 1.8, then in java 9 and above, Oracle introduced java modules, various api are deprecated. and further down, things like JavaFX is no longer bundled for free.
i'd think it is still possible to rebuild this on your own platform (e.g. windows) from source say with java >= 11 etc, but that it uses some serial libraries that depends on JNI calls to os functions. this is partly where the problem is, other than java there are also c codes that link to os (this is mainly bundled in the serial library e.g. jsse) and is likely where it'd break. as the c codes that link to the os needs to be recompiled if in case the underlying dll has changed.
and the jni part in java may need to be rebuilt. java also made it more difficult for 'security updates' that breaks hacks to load dll libraries directly embedded in jar files in java > 1.8.

for now i mostly make do with running dfu-util manually from command line like
http://dfu-util.sourceforge.net/

Code: Select all

dfu-util -a 2 -RD sketch.bin
pressing reset on the board before download. it is normally fuss free and 'just works'
for stm32f4xx with dfu built-in, it is hold boot0, press and release reset, then release boot0 2 secs later.
then dfu-util command looks like

Code: Select all

dfu-util -a 0 -s 0x8000000 -RD sketch.bin
press reset manually after that
you can literally compile the binary for 'st-link' all it takes is for the begin address to be 0x8000000

dfu-uilt is public open sourced utility it has various dependencies. the more formal solution is stm32cube programmer
Post Reply

Return to “USB bootloader”