ARDUINO USB 2 serial converter to program STM32 ?

Post Reply
kosmo
Posts: 5
Joined: Sat May 30, 2020 10:29 pm

ARDUINO USB 2 serial converter to program STM32 ?

Post by kosmo »

Dear everybody,

I am trying to program through ARDUINO IDE 1.8.12 a STM32F103C8T6 using the ARDUINO USB to serial convert on a MacBook pro, but I am not having success.

The error message is:

Failed to init device.
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1

An error occurred while uploading the sketch

Is there someone who has experience on that?
Thnx!
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by mrburnette »

The subject is addressed here:
https://forum.arduino.cc/index.php?topic=138832.0

And Google gives more results.

Of course, I have done this, but not on a Mac.

Ray
kosmo
Posts: 5
Joined: Sat May 30, 2020 10:29 pm

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by kosmo »

Hi Ray thanks for your reply!
I maybe did not explain clear enough, sorry.
I am not trying to use an ARDUINO UNO board as a converter.
I would like to use the ARDUINO USB 2 serial converter which I had purchased to program an ARDUINO ETHERNET board while ago.
Mine is the previous version of >>
https://www.arduino.cc/en/Main.USBSerial
It is featuring an Atmega8U2 as a USB2serial converter.
kosmo
Posts: 5
Joined: Sat May 30, 2020 10:29 pm

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by kosmo »

thanks Steve.
the issue might be I am trying to use Atmega8u2 on the usb2serial converter to program the STM32. Apparently majority of people is doing it with FTDI. I will try to understand root causes and keep you posted.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by ag123 »

you can get some hints from here
https://medium.com/@paramaggarwal/progr ... 3cec0dbc86
make sure it is a 3.3v uart dongle.
there are also some quite cost effective usb-uart dongles e.g.
https://www.aliexpress.com/wholesale?ca ... ext=cp2102
there are some subtle protocol differences which may result in getting stalled.
e.g. stm32 is expecting 8E1 line discipline (i've once noted that 8N1 works, but it may not be always that lucky, some arduino sketches don't set line disciplines, i.e. default to 8N1 in the sketch. and that specified on the command line at the pc is ignored)
https://www.st.com/resource/en/applicat ... ronics.pdf
and you need to set BOOT0
https://www.st.com/resource/en/applicat ... ronics.pdf
there are fake blue pills circulating in the market hence be wary of that too
and you'd need to see that it is after all the right 'upload method' that should be 'Serial'
normally for libmaple core the tool that interface with the com port is stm32loader, i think, i'm not sure about it too.
https://github.com/jsnyder/stm32loader
you can try using that app itself on the command line to see if you are able to achieve some success flashing the bin / firmware file.
you can try flashing one of the bins e.g. the usb dfu boot loader if you are after all using a blue pill board.
https://github.com/rogerclarkmelbourne/ ... r/binaries
the binary for blue pill normally is generic_boot20_pc13.bin
or generic_boot20_pc13_fastboot.bin
after installing the boot loader, press reset, and the led should keep blinking.

once you have this boot loader installed, you can try installing the sketch with simply a usb cable. i.e. select the upload method 'stm32duino bootloader', if you still hit issues installing a sketch, you can try setting boot1 (after you have successfully flashed the boot loader mentioned above) and try again. note, when you are using the usb cable for flashing, you should *not* set BOOT0

if you are still struggling with the atmega? uart dongle you may want to try getting a st-link v2
https://www.st.com/en/development-tools/st-link-v2.html
https://www.adafruit.com/product/2548
this is more than just a programming dongle, it is a jtag/swd dongle, hence at some point you can play with debug if you want.
kosmo
Posts: 5
Joined: Sat May 30, 2020 10:29 pm

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by kosmo »

thanks a lot ag123, i will dig into each and every point you suggested and keep you posted.
Easiest thing to check first was the 3V3.
Indeed the ARDUINO USB 2 serial is a 5V device
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by ag123 »

the main thing you need to do is set BOOT0, and make sure the pins that you are connecting to is correct, see 1st link in previous post
i.e. the PA9 TX and PA10 RX on the stm32f103 pill board should be hooked correctly to the uart dongle.
PA9 and PA10 is 5v tolerant if i remember it correctly, check the specs if unsure.
https://www.st.com/en/microcontrollers- ... 103c8.html
i.e. 5v still works, but normally it should be 3.3v

and try flashing that bootloader with the stm32loader utility
https://github.com/jsnyder/stm32loader
try working it on the command line, that way you get a better feel of how the binary gets flashed
the stm32duino libmaple USB DFU boot loaders firmware are as described in the previous post
https://github.com/rogerclarkmelbourne/ ... bootloader

when you are done programming, you should restore BOOT0 to the original unset state and press reset
after you have successfully flashed the boot loader, the next thing is to flash your own sketch e.g a blinky over USB DFU stm32duino bootloader.
e.g.

Code: Select all

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

void loop() {
  digitalWite(LED_BUILTIN,0); //on blue pill it is active low !
  delay(100);
  digitalWite(LED_BUILTIN,1);
  delay(100);
}
after that if you have more bluepills around, there is a sketch in the libmaple examples which can make your blue pill another usb-uart dongle
https://github.com/rogerclarkmelbourne/ ... -w-signals
and you can try using that as a usb-uart dongle to flash the stm32duino boot loader on the rest of them ;)
kosmo
Posts: 5
Joined: Sat May 30, 2020 10:29 pm

Re: ARDUINO USB 2 serial converter to program STM32 ?

Post by kosmo »

Hey ag123 I got to test some bluepills from different vendor + FTDI chip USB to serial converter (took a bit of time with all delays).
Remind you I was trying to use an old ARDUINO USB to Serial converter to program STM32 (on macOS Mojave).
Flashing code on bluepill through FTDI USB to serial worked.
I could not succeed in my initial goal, but never mind.
Thanx for support!
Post Reply

Return to “USB to Serial adaptors”