From ElectroDragon
Jump to: navigation, search

STM32 Toolchain

Hardware Interface

Stm32 serial wiring 02.jpg


  • In arduino IDE install arduino SAM board first ("for arduino zero"), so toolchain "arm-none-eabi-g++ " installed
  • Git clone into arduino\hardware folder
Github Support hardward Support software
STM32 Arduino F1, F3, F4
Arduino_Core_STM32 F0~F7, L0~L4
  • Hardware programmer use ST-LINK, install driver, you can find it here
  • Connect with our STM32F103C8T6 board, upload blink sketch onto PB12 pin.
  • Support arduino library - here


  • Install MDK-ARM lastest version
  • Install software pack for platform, for example STM32F030xxx
  • Install STM32Cube
  • Follow the following animation, open to watch

Code add this two lines for blinking IO in user code 1 area:



  • Default frequency is 8Mhz
  • Choose to output hex compilied file.
  • In STM32Cube, only copy necessary files, otherwise will be very big project folder

STM32 Linux

Debugger OpenOCD

  • Help page.
  • Use either ST-LINK or OpenOCD, can work with ST-LINK2
  • For example OpenOCD, run command as follow to install
  1. install openocs: sudo apt-get install openocd
  2. setup up for usbdevice: sudo vi /etc/udev/rules.d/99-stlink.rules
  3. add conent: ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0666"
  4. reload setup: sudo udevadm control --reload-rules
  5. open board: openocd -f /usr/share/openocd/scripts/board/stm32f3discovery.cfg
  6. or use: /usr/share/openocd/scripts# openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg
  • If well connected, result will show:

Open On-Chip Debugger 0.7.0 (2013-05-15-17:44) Licensed under GNU GPL v2 For bug reports, read
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Info : STLINK v2 JTAG v16 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : Target voltage: 2.915198
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoint
  • Run another terminal and telnet to the board: telnet localhost 4444
  • halt it into debug mode: reset halt or: reset init
  • Reflash bin into board:
flash write_image erase maple_mini_boot.bin 0x08000000
flash write_image erase /media/sf_VM_XP_share/LED.hex
  • Finall reset it to start up again: reset run


  • Install: sudo apt-get install gcc-arm-none-eabi

Firmware libopencm3 and test code

  • git clone the firmware and try stm32f103 demo blink code, the firmware works like arduino
git clone
cd libopencm3-examples
git submodule init // 
git submodule update
  • enter into board folder like: cd libopencm3-examples/examples/stm32/f3/stm32f3-discovery/miniblink
  • for STM32F1x board, enter into /libopencm3-examples/examples/stm32/f1/stm32-h103//miniblink/
  • firmware support openocd, can run make flash directory
  • Or manually telnet to openocd: telnet localhost 4444
reset halt
flash write_image erase miniblink.elf




  • STLink Utility
  • Flash_Loader_Demonstrator_V2.1.0_Setup


Development Schematic





Application Schematic


Type Core Memory
STM32F405 168Mhz M4 32bit 1MB Flash
STM32F401 84 MHz 512 Kb Flash
STM32F103 72MHz 64K or 128K bytes, 20K bytes of SRAM


  • Boot0 connect via 10K to GND for normal mode, to 3.3V for upload mode.

STM32 F103 Features

Core: ARM 32-bit Cortex ™ -M3 CPU

  • Up to 72MHz operating frequency
  • Single cycle multiplication and hardware division


  • from 64K or 128K bytes of Flash program memory
  • up to 20K bytes of SRAM

Clock, reset and power management

  • 2.0 to 3.6 V supply and I / O pins
  • Power on / off reset (POR / PDR), programmable voltage monitoring (PVD)
  • 4 ~ 16MHz crystal oscillator
  • Built-in factory-calibrated 8MHz RC oscillator
  • Built-in calibrated 40kHz RC oscillator
  • PLL that generates the CPU clock
  • 32 kHz RTC oscillator with calibration function

Low power consumption

  • Sleep, Standby and Standby modes
  • V BAT supplies power to the RTC and the back-up registers

2 of 12-bit analog-to-digital converters, 1us conversion time (up to 16)

  • Conversion range: 0 to 3.6V
  • Double sampling and hold function
  • Temperature sensor


  • 7-channel DMA controller
  • Peripherals supported: timers, ADC, SPI, I 2 C and USART

Up to 80 Fast I / O ports

  • 26/37/51/80 I / O ports, all I / O ports can be mapped to 16 external interrupts; almost all ports can tolerate 5V letter number

Debug mode

  • Serial single-wire debugging (SWD) and JTAG interfaces

Up to 7 timers

  • Three 16-bit timers, up to four for each timer / Input Capture / Output Compare / PWM or Pulse Count channels and incremental encoder inputs
  • One 16-bit with dead zone control and emergency brake for motors
  • Control the PWM Advanced Control Timer
  • Two Watchdog Timers (Standalone and Windowed)
  • System time timer: 24-bit self-decrementing counter

Up to 9 communication interfaces

  • Up to 2 I 2 C interfaces (Supports SMBus / PMBus)
  • Up to 3 USART interfaces (supports ISO7816 interface,

IN, IrDA interface and modem control)

  •  Up to 2 SPI interfaces (18 Mbit / s)
  • CAN interface (2.0B active)
  • USB 2.0 full speed interface

CRC computing unit, 96-bit chip unique code


  • FSMC = flexible static memory controller


2018-07-23 000209.png
Type Header text FSMC Speed
STM32F030F4P6 2.15 X 48
STM32F030C8T6 3.35 X 48
STM32F103C8T6 4.7 Y 72
STM32F429IGT6 34 180