My musings with STM32

Posted on Wed, Aug 28, 2019 IoT

Technical Specifications

Get Started

Linux driver installation: http://padcom13.blogspot.com/2015/12/getting-started-with-stm32-on-ubuntu.html

Windows
  1. Set up STM32CubeMX: https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html
  2. Set up TrueSTUDIO: https://atollic.com/truestudio/
  3. Download and install other drivers through intermediate prompts
  4. End to end video tutorial to set up the development environment and getting started with a Blinky project:

  5. Tutorial video to help connect the ST-Link programming unit to the STM32 MCU:

    Pinout diagram of the ST-LINK programming unit
  6. Debug to upload the code (.hex file) to STM32 and Resume to actually execute the code on the MCU.
💡

Note that in the programming unit, we connect to the pins 2, 4, 6, 8. The pins are respectively SWCLK, SWDIO, GND, 3.3V. Corresponding are connected in the STM32.

Debugging

Connecting STM32 to PC using Serial Adapter (or Arduino)

Use an Arduino and connect the RESET and GND pins together

Custom Bootloader (Windows App)

https://whuangpro.wordpress.com/2017/10/29/custom-bootloader/

Setup [using Arduino] (DID NOT WORK OUT!!)

Connecting pin2pin
Connecting through breadboard (some incorrect GND connections here)

Points to note while connecting

This method did NOT work out!! Neither did removing the Atmel IC of the Arduino help.

Setup [using Serial Adapter / USB2TTL]

Setup [using ST-LINK Programming Unit]

Things to Remember

  • While programming and testing the STM32 using the serial adapter, it is important to set the boot pins correctly, otherwise results are not correct. Pinout diagram here.
    • Programming mode: Boot Pin 0 set to HIGH, Boot Pin 1 set to LOW
    • Operation mode: Boot Pin 0 set to LOW, Boot Pin 1 set to LOW

Talking to STM32 through commands

We can directly send commands through a Serial Terminal (Arduino default, CuteCom etc) and upon sending the correct commands, the STM32 will respond correctly.

Commands

PurposeCommand sentACK receivedExplanation
Init (must send this first)0x7F0x79 (y)y means success of the operation
Bootloader version0x01 0xFE0x79 (y) 0x22 (")" means 0x22 however this might change according to the bootloader version