Skip to content

Commit 58ad2ab

Browse files
committed
partial documentation of openocd support
1 parent 4ca469e commit 58ad2ab

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

Readme.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Video of work: https://youtu.be/M7RBQsq5_lc
99
3) cmake
1010
4) clang
1111
5) st-link https://github.com/texane/stlink
12+
6) (optional) openocd
1213
//5) https://github.com/SL-RU/STM32CubeMX_cmake
1314

1415
### Install:
@@ -19,9 +20,11 @@ Video of work: https://youtu.be/M7RBQsq5_lc
1920
4) add to your init file (require 'stm32)
2021
5) install cmake-ide and [configure](https://syamajala.github.io/c-ide.html)
2122

22-
### Commentary:
23+
### How to use:
2324

2425
WORK IN PROGRESS!!!
26+
27+
#### GDB and st-link
2528
1) Create STM32CubeMx project and generate it for SW4STM32
2629
2) M-x stm32-new-project RET *select CubeMX project path*
2730
3) open main.c
@@ -32,6 +35,26 @@ WORK IN PROGRESS!!!
3235
8) in gdb) "load" to upload file to MC and "cont" to run.For more see https://github.com/texane/stlink
3336
9) good luck!
3437

38+
#### Openocd
39+
40+
Openocd requieres a .cfg file to properly function you need to provide the file in this case it must be
41+
called board.cfg, and example file is provided (board.cfg) the file needs to be located in your project root.
42+
43+
##### FreeRTOS support
44+
45+
Openocd can
46+
47+
1) Create STM32CubeMx project and generate it for SW4STM32
48+
2) M-x stm32-new-project RET *select CubeMX project path*
49+
3) put the board.cfg in your proyect root(an example file named board.cfg is provided in this repo)
50+
3) open main.c
51+
4) C-c . C to compile
52+
5) connect stlink to your PC
53+
6) stm32-run-openocd to start openocd server
54+
7) start GDB debugger with stm32-start-openocd-gdb
55+
56+
after this you shold be in the debugger window and you can debug your program, but the default gdb window acts like a terminal and is not very helpful in regards of context and data, so its a good idea to use gdb in many windows mode you can acativate it in your startup config file or with M-x gdb-many-windows
57+
3558

3659
After CubeMx project regeneration or adding new libraries or new sources you need to do M-x stm32-cmake-build
3760

@@ -43,5 +66,5 @@ If you have error in cmsis_gcc.h do ```M-x stm32-fix-vfpcc```. It will change so
4366
# License:
4467

4568
This program is distributed under the terms of GNU General
46-
Public License, version 3 or any later version. See COPYING
69+
Public License, version 3 or any later version. See COPYING
4770
for details.

board.cfg

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# openocd requires a .cfg file to use the debuger/programer openocd can work with
2+
# many devices including stm but i have only tested stm microcontrollers
3+
# this file was made with the help of this post
4+
# https://www.shortn0tes.com/2017/10/the-most-detailed-guide-on-programming.html
5+
# my contribtion to this file is the freertos flag which enables gdb and as a
6+
# consequence emacsto view the thasks as threads
7+
source [find interface/stlink-v2.cfg]
8+
9+
#set WORKAREASIZE 0x5000
10+
11+
transport select "hla_swd"
12+
13+
set CHIPNAME STM32F103CBTx
14+
15+
# Enable debug when in low power modes
16+
set ENABLE_LOW_POWER 1
17+
18+
# Stop Watchdog counters when halt
19+
set STOP_WATCHDOG 1
20+
21+
# STlink Debug clock frequency
22+
set CLOCK_FREQ 4000
23+
24+
# We do not connect RESET line to stlink, that's why reset is disabled.
25+
reset_config none
26+
27+
source [find target/stm32f1x.cfg]
28+
# Enable FreeRTOS support
29+
$_TARGETNAME configure -rtos FreeRTOS
30+
31+
#Enable Trace output in open OCD
32+
#Not tested yet
33+
#tpiu config external uart off 72000000 2000000

0 commit comments

Comments
 (0)