libopencm3-based software projects for generic stm32f103c8t6 board
- Clone projects repo:
git clone https://github.com/metametaclass/stm32f103_projects
- init libopencm3 submodule:
git submodule init
git submodule update
-
download gcc-arm embedded toolchain: https://launchpad.net/gcc-arm-embedded
-
unpack gcc-arm-XXXX.zip somewhere
-
download and install MSYS: http://www.mingw.org/wiki/MSYS http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe
-
download and install python 2.7: https://www.python.org/ftp/python/2.7/python-2.7.msi (needed for file generation in libopencm3)
-
run MSYS with PATH to python and gcc:
-
create and run script run_msys_gcc_arm.cmd in MSYS folder (where msys.bat is located):
rem change path to installed python and gcc-arm 'bin' folder
set PATH=%PATH%;D:\Programm\Python27;D:\Programm\gcc-arm\bin
call %~dp0msys.bat
- build libopencm3:
In opened MSYS shell cd
to libopencm3 folder and run make
:
cd /c/work/stm32f103_projects/libopencm3/
make
- build projects:
cd
to any project folder and runmake
:
cd ../projects/blink
make
- Wiring
stlink -> board programming pins
8 Vcc(3.3) -> 3.3
2 SWDIO -> SWDIO (PA13, pin 34)
6 SWCLK -> SWDCLK (PA14, pin 37)
4 Ground -> GND
- interactive programming: run openocd
openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f1x_stlink.cfg
- run in separate terminal:
telnet localhost 4444
reset halt; flash write_image erase binary.elf; reset run
- automatic programming from script:
openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg \
-f /usr/share/openocd/scripts/target/stm32f1x_stlink.cfg \
-c init -c "reset halt; flash write_image erase binary.elf; reset run; shutdown"
init
command is imporant, all other commands works only after init call