Programming stm32 with a pro micro

I'm a total newbie, to the whole arduino thing, and I wanted to build a midi controller for myself, so I ordered a chinese pro micro (it's recognised as a leonardo), and a cheap stm32f103c8t6 board.
The problem is, when I ordered them, I didn't know, that the stm32 board has no bootloader in it, which should be uploaded via the serial port on the board.
The question is:
Is it possible, to use the pro micro, as an usb to serial converter to burn the bootloader on the stm32 board?
I barely found any information on that. I found a wiring diagram, where I saw that I should put 1k resistors between the source, and target RX and TX pins (I didn't found any information why, but I assume it's due to different voltage levels (the pro micro is 5V and the stm32 is 3,3V), but I'm just guessing here, as I said I'm a newbie to the whole microcontrollers topic.
My wiring goes like
Pro micro STM32
RX--1k-------TX
TX--1k-------RX
VCC----------5V
GND---------GND

The STM32 can be flashed via a USB-to-Serial converter by using the built-in DFU bootloader. I understand, though I've never done so, that the Pro Micro can be programmed to act as a USB-to-Serial, but I believe this requires setting fuses which means it must be programmed with an ISP.

While you might find an ISP to be a useful thing to add to your toolbox, it makes more sense just to get a USB-to-Serial or a STM programmer (STlink V2) to program the STM32 directly.

Maybe you can use this thread for help.

https://arduino.stackexchange.com/questions/21166/trying-to-verify-that-arduino-pro-micro-isp-is-working

You don't need the voltage divider because the pins you are using are 5v tolerant on the STM32F103. http://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif

Another tip: When you managed to flash the bootloader on the STM32F103 and you cannot get the usb port to work (unknown device descriptor error):

The USB standard requires a 1.5 kΩ pullup resistor on D+, but this board is known to have a wrong value (R10 on the board). It ships with either a 10 kΩ resistor or a 4.7 kΩ resistor, but it should be replaced with a 1.5 kΩ resistor, or put an appropriate resistor value (e.g 1.8 kΩ) in between PA12 and 3.3V. It is also true that some PCs are tolerant of incorrect value so, before you change the resistance, you can try if it works in your case.

Thank your for your answers!
It's a good lead.
Btw If I can solve the problem, without an actual usb-serial, or STlink, I'll post it! If I can't, then I'll just fight off my greediness and buy one :slight_smile:

MrMark:
I understand, though I've never done so, that the Pro Micro can be programmed to act as a USB-to-Serial, but I believe this requires setting fuses which means it must be programmed with an ISP.

You don't have to set any fuses, just forward all bytes on one serial port to the other:

#define BAUD 115200

void setup() {
  Serial.begin(BAUD);  // USB CDC (Virtual COM)
  Serial1.begin(BAUD); // Hardware UART
}

void loop() {
  if(Serial.available()){
    Serial1.write(Serial.read());
  }
  if(Serial1.available()){
    Serial.write(Serial1.read());
  }
}

I've used this to program ESP8266's, but never tried it with an STM32.

Pieter

PieterP:
You don't have to set any fuses, just forward all bytes on one serial port to the other:

#define BAUD 115200

void setup() {
  Serial.begin(BAUD);  // USB CDC (Virtual COM)
  Serial1.begin(BAUD); // Hardware UART
}

void loop() {
  if(Serial.available()){
    Serial1.write(Serial.read());
  }
  if(Serial1.available()){
    Serial.write(Serial1.read());
  }
}



I've used this to program ESP8266's, but never tried it with an STM32.

Pieter

I can confirm that this method works. I tried it with a STM32F407 and uploading worked. However I am able to upload once to this board using this method. After that I have to reflash the chip using another method. I didn't have time to do more extensive testing.

I know that the board of eti8 is a STM32F103, but that should work as well.

It doesn't work for me, the bootloader says: "no response from the device..."
I've tried changing the echo mode to echo, than changing back (I've read it in some tutorial, that this could work), but nothing, than I've changed rhe RX-TX pin connections, but that didn't work also.
Maybe my stm32 hasn't got a bootloader, and can't be programmed via UART, so maybe I need an STlink device.
Any suggestions on that?

Until that I think, I'll just use multiplexers to extend the number of buttons, and potentiometers I can use with my pro micro.
Maybe I'll just buy another pro micro for my second midicontroller, It's much better for my total newbiness.

eti8:
It doesn't work for me, the bootloader says: "no response from the device..."
I've tried changing the echo mode to echo, than changing back (I've read it in some tutorial, that this could work), but nothing, than I've changed rhe RX-TX pin connections, but that didn't work also.
Maybe my stm32 hasn't got a bootloader, and can't be programmed via UART, so maybe I need an STlink device.
Any suggestions on that?

Until that I think, I'll just use multiplexers to extend the number of buttons, and potentiometers I can use with my pro micro.
Maybe I'll just buy another pro micro for my second midicontroller, It's much better for my total newbiness.

You should explain more in detail what you tried to do, what files you tried to flash, what core you are using. What pins did you connect? This post has to little information to help you.

Jumpers:

BOOT0 = 1
BOOT1 = 0

RX > PA9
TX > PA10
GND > GND
5v > 5v

In the Arduino IDE you select upload method > Serial.

It's even better to flash the "stm32duino bootloader".

I've tried to use a chinese pro micro as the usb to serial converter, with the above posted code:
#define BAUD 115200

void setup() {
Serial.begin(BAUD); // USB CDC (Virtual COM)
Serial1.begin(BAUD); // Hardware UART
}

void loop() {
if(Serial.available()){
Serial1.write(Serial.read());
}
if(Serial1.available()){
Serial.write(Serial1.read());
}
}

I connected, the pins, and moved the jumpers, as you mentioned.
I tried to do this tutorial:

But I've stuck at the flash loaders first step. I get the "No response from the target..." error, and none of the solutions work for it.

Subbing to the topic,.. I just got an STM32F407 board as well so this is interesting to me.

To be clear I'm by no means an expert on any of this and am just conveying information I've gathered while researching setting up my Alibaba special - STM32 dev board (comonly refered to as the "blue pill".
I think anything accomplished on the STM32F4 devices is mostly irrelevant to the STM32F103 devices as from what I've read they don't ship with similar bootloaders as far as what they can and can't do out of the box.
Also, I really can't say what problem You're running into without basically being there physically, but you should be fine to program your board via USB to UART, though it seems the common consensus is that it's incredibly difficult to program a blue pull using an Arduino board with USB capability. On the plus side, a board like the ch340T or G boards you can get on AliExpress for under a dollar should work a lot easier (though some do require a minor modification), or just splurge a bit and get a Chinese ST Link v2 for $1.70 - probably less than the pro micro was.
This is the website I used to figure out how to do it with a 60 cent CH340G board: Programming an STM32F103 board using its USB port (Blue Pill) | by Param Aggarwal | Medium