Problem programming Blue Pill using an Arduino Mega

FreD
Posts: 6
Joined: Mon Sep 04, 2017 7:20 pm

Problem programming Blue Pill using an Arduino Mega

Post by FreD » Wed Sep 06, 2017 2:59 pm

Hi, I am not being able to flash my blue pill.

My setup is:
-Blue Pill stm32f103c8
-arduino mega as usb to serial converter (it works Ok to flash an arduino pro mini)
-Arduino IDE 1.8.4
-downloaded the last zip from https://github.com/rogerclarkmelbourne/Arduino_STM32 and added to arduino/hardware directory
-tried with the stm3dflash that came in the zip(0.4) and downloaded the 0.5 version from sourceforge
-Windows 7 64bits
I am getting this error:

Failed to init device.
stm32flash 0.5

http://stm32flash.sourceforge.net/

Using Parser : Raw BINARY
Interface serial_w32: 19200 8E1


I tried changing the baud rate on the .bat file tried 57600, 9600, 115200, 19200, no success.

Am I missing something?

Thanks!

User avatar
Rick Kimball
Posts: 1056
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Blue Pill - Error trying to program

Post by Rick Kimball » Wed Sep 06, 2017 3:05 pm

Does your arduino mega as a usb work properly with parity?

Do you have an FTDI usb dongle you could use instead?
-rick

FreD
Posts: 6
Joined: Mon Sep 04, 2017 7:20 pm

Re: Blue Pill - Error trying to program

Post by FreD » Wed Sep 06, 2017 3:52 pm

I don't have one, I am going to buy an ftdi and a st-link just to be safe.

I don't know how to check if it does support parity, in device manager driver config for it I can choose parity to be none, even, odd... should I change it somewhere in the arduino folder?
Does STM32flash has an option for it?

User avatar
Rick Kimball
Posts: 1056
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Blue Pill - Error trying to program

Post by Rick Kimball » Wed Sep 06, 2017 4:45 pm

Use a wire to connect the TX to the RX on the arduino mega, then use a terminal program that lets you set the parity, (say something like putty) and see if it works properly. Try 8-E-1.
-rick

FreD
Posts: 6
Joined: Mon Sep 04, 2017 7:20 pm

Re: Blue Pill - Error trying to program

Post by FreD » Wed Sep 06, 2017 6:50 pm

I did this test, and something weird happens, as far as I know the stm32flash should send 7F to the stm micro.
When I send it trough the terminal program using 8 bits word, the signal on the scope looks different than what stm32flash sends.

I also so in some posts here in the forum that some people have version 0.9 of the stm32flash, is that only available for non windows system?
does version 0.4 and 0.5 have bugs?

My ST-link and ftdi adapter should be here in 1 or 2 weeks, lets see if I can make it work with one of this...

FreD
Posts: 6
Joined: Mon Sep 04, 2017 7:20 pm

Re: Blue Pill - Error trying to program

Post by FreD » Wed Sep 06, 2017 7:26 pm

Infact I misinterpreted the scope reading.
Image

FreD
Posts: 6
Joined: Mon Sep 04, 2017 7:20 pm

Re: Blue Pill - Error trying to program

Post by FreD » Wed Sep 06, 2017 7:27 pm

It is sending the correct 7F after 2 start bits that is when it opens the COM4, but the stm32 do not answer

dannyf
Posts: 167
Joined: Wed May 11, 2016 4:29 pm

Re: Blue Pill - Error trying to program

Post by dannyf » Wed Sep 06, 2017 9:12 pm

With the money you spend on a serial adapter you could have gotten a stlink, gaining debug capabilities and saving yourself a dollar or so.

I buy (avr) Arduino or stm32 Arduino boards to use avr or stm32 boards. Much more robust.

zmemw16
Posts: 1484
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Blue Pill - Error trying to program

Post by zmemw16 » Wed Sep 06, 2017 9:17 pm

another is that the fails in programming via st-link that i've had, have been cured with a reset or power cycle on the board. i think i've had a connect under reset issue maybe once.
stephen

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: Blue Pill - Error trying to program

Post by martinayotte » Wed Sep 06, 2017 9:27 pm

Did you attached STM on the same serial port of the of the USB ?
If so, did you upload in the Mega a small sketch that turn Mega TX pin as an input ?
If not, you have 2 TXs (the one from Mega and the one from STM) fighting each other ... :ugeek:

Post Reply