Is it possible to program an STM32 with an Arduino?

Through JTAG, it's practically impossible. Your best bet is using the embedded bootloader that ships factory installed in every STM32 chip. This bootloader uses the USART1 peripheral of the STM32 to interface with a computer or other device. However, the most useful tool to interface to this bootloader is a USB to serial converter, using e.g. an FT232 chip, which you can connect to your computer. You could then install the ST Flash Loader Demonstrator app to upload code to your board using the bootloader.

A few important points to make:

  • to use the bootloader, you need to pull BOOT1 low (connect to GND) and BOOT0 high (connect to VDD) before powering up the board. Then, when running the code you just looaded, pull BOOT0 low back. See section 3.4 of the STM32F10x reference manual.
  • a commercial USB to serial converter would include a voltage level translator, since RS-232 voltage levels are much higher than the 3.3 V used in the STM32 (usually \$\pm\$12V). You'd need to hack such a converter to get TX and RX signals straight from the FT232, otherwise you're going to let out the magic smoke from the STM32. If you don't have one, you might just find it in your local computer store for sale. Another option would be to search for some Arduino code that emulates a USB to serial converter (it'd be far too much work to write one yourself). Note that even if your converter uses 5.0 V signaling, that's OK to use with the STM32 since the USART1 pins needed for the bootloader are 5V-tolerant.
  • finally, you must be aware that this is no substitute for a real JTAG programmer. Using the bootloader, you can only load and run the program. It's impossible to debug it (i.e. insert breakpoints, read and modify register and memory values, step through the code, etc.) Using the bootloader is fine if you just want to see a few LEDs flash on your shiny new board, but for serious work, a real debugger makes you orders of magnitude more productive. Do order a JTAG now, if you haven't already. The ST-Link/V2 is a nice one and not too expensive ($29.75 from Digi-Key as of this writing).

Yes, using an Arduino Sketch - see “Poor-man’s boot loader upload” in: https://git.jeelabs.org/jcw/embello/src/branch/master/projects/ask/stm32f1init/stm32f1init.ino

See more on https://jeelabs.org/book/1546c/index.html

Tags:

Ttl

Arduino

Stm32