Problem programming Blue Pill using an Arduino Mega

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!


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?


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?


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.

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
Wed Sep 06, 2017 7:26 pm
Infact I misinterpreted the scope reading.
Image

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
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
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

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:

RogerClark
Thu Sep 07, 2017 1:04 am
Can you explain how you are using your Arduino Mega as a USB to Serial converter ?

Are you taking the pins (I think D0 and D1) to the STM32 PA9 and PA10
(I’m not sure if D0 goes to PA9 or PA10 as I can’t recall which is which on the Mega etc)


csnol
Thu Sep 07, 2017 8:31 am
I think you should use ST Flash Loader Demonstrator to upload the STM32F103-PC13.bin bootloader first.
Image

csnol
Thu Sep 07, 2017 8:39 am
If still error, maybe some wrong on PA9/PA10 of your BP. or use USB-TTL or STLINK try again.

FreD
Sat Sep 09, 2017 12:46 am
Arduino mega2560 has an 8u2 micro running as usb2serial converter.
I kept the mega2560 IC on reset. and use pins 0 and 1 of arduino as TX and RX, it is marked the other way around on the pcb, because it says what is this pin for the mega and not the 8u2. It works fine to flash the arduino pro mini, also works as loop back.

I am not sure if the 5v on the serial makes any difference for the stm but I found on the datasheet it is 5v tolerant.

I am really curious to understand what my mistake is.


RogerClark
Sat Sep 09, 2017 1:17 am
Which PC software are you using.

STM’s own “Flash Loader Demonstrator” is the most reliable

I think I managed to get it to upload to using a UNO as a USB to Serial converter by running the Multi software serial example sketch

However it would only work at one baud rate (which I think was the fairly slow, e.g. somewhere in the 30k – 60k range)

I think parity can be a problem with the Arduino Uno etc,- it was definitely a problem when I tried using the Multi software serial , but it could be software serial which was the issue in that case


Leave a Reply

Your email address will not be published. Required fields are marked *