gdb-ocdif 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gdb_ocdif-0.1.0/LICENSE +20 -0
- gdb_ocdif-0.1.0/PKG-INFO +257 -0
- gdb_ocdif-0.1.0/README.md +240 -0
- gdb_ocdif-0.1.0/gdb_ocdif/__init__.py +58 -0
- gdb_ocdif-0.1.0/gdb_ocdif/commands.py +162 -0
- gdb_ocdif-0.1.0/gdb_ocdif/gdbif.py +243 -0
- gdb_ocdif-0.1.0/gdb_ocdif/model.py +174 -0
- gdb_ocdif-0.1.0/gdb_ocdif/prettyprint.py +59 -0
- gdb_ocdif-0.1.0/gdb_ocdif/probe_openocd.py +111 -0
- gdb_ocdif-0.1.0/gdb_ocdif/scrollback.py +49 -0
- gdb_ocdif-0.1.0/gdb_ocdif/serverprocess.py +135 -0
- gdb_ocdif-0.1.0/gdb_ocdif.egg-info/PKG-INFO +257 -0
- gdb_ocdif-0.1.0/gdb_ocdif.egg-info/SOURCES.txt +15 -0
- gdb_ocdif-0.1.0/gdb_ocdif.egg-info/dependency_links.txt +1 -0
- gdb_ocdif-0.1.0/gdb_ocdif.egg-info/top_level.txt +1 -0
- gdb_ocdif-0.1.0/pyproject.toml +39 -0
- gdb_ocdif-0.1.0/setup.cfg +4 -0
gdb_ocdif-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2026 Max Sikström
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
20
|
+
|
gdb_ocdif-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gdb_ocdif
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python module for GDB manage OCD servers
|
|
5
|
+
Author-email: Max Sikström <max@pengi.se>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pengi/gdb_ocdif
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# GDB OCD-interface
|
|
19
|
+
|
|
20
|
+
Tool for managing on-chip debugger interfaces/servers from within GDB
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Normally, when developing for embedded devices, like ARM Cortex-M
|
|
24
|
+
microcontrollers, it is required for setting up a debugging session to:
|
|
25
|
+
|
|
26
|
+
- Start two terminals
|
|
27
|
+
- In terminal 1 - start ocd interface, for example `openocd`
|
|
28
|
+
- In terminal 2 - start gdb instance, for example `gdb-multiarch`
|
|
29
|
+
- In terminal 2 - Connect to openocd, using `target remote localhost:1234`, or
|
|
30
|
+
variant thereof
|
|
31
|
+
|
|
32
|
+
Then on every reset, it may be required to reconnect to the OCD instance
|
|
33
|
+
|
|
34
|
+
This makes a lot of overhead for each update and reprogramming.
|
|
35
|
+
|
|
36
|
+
This tool manages the OCD sessions as subprocesses from within `gdb` itself,
|
|
37
|
+
and also has convenience macros for rebuilding and reprogramming automatically.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Install `gdb_ocdif`, so it's available from gdb environment.
|
|
43
|
+
|
|
44
|
+
### Install from pypi:
|
|
45
|
+
```sh
|
|
46
|
+
pip install --user gdb_ocdif
|
|
47
|
+
```
|
|
48
|
+
Make sure the install path, usually `~/.local` is available for python search
|
|
49
|
+
path
|
|
50
|
+
|
|
51
|
+
### Install from git:
|
|
52
|
+
pick a directory to clone this repo from
|
|
53
|
+
```sh
|
|
54
|
+
git clone https://github.com/pengi/gdb_ocdif.git /path/to/where/to/put/gdb_ocdif
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
In your normal environment, or before starting gdb, update `PYTHONPATH`
|
|
58
|
+
environment variable
|
|
59
|
+
|
|
60
|
+
Run, or add to `~/.bashrc`, `~/.zshrc` or similar:
|
|
61
|
+
```sh
|
|
62
|
+
export PYTHONPATH=/path/to/where/to/put/gdb_ocdif:$PYTHONPATH
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Configure gdb
|
|
66
|
+
|
|
67
|
+
It is recommended to autoload gdb_ocdif into gdb on each startup, and also add
|
|
68
|
+
default configuration and aliases
|
|
69
|
+
|
|
70
|
+
Add following to `~/.gdbinit`, and update to your liking.
|
|
71
|
+
|
|
72
|
+
None of the lines below will affect the target, but only setup the enviornment
|
|
73
|
+
```ini
|
|
74
|
+
|
|
75
|
+
# Load gdb_ocdif
|
|
76
|
+
python import gdb_ocdif
|
|
77
|
+
|
|
78
|
+
# Define available probes
|
|
79
|
+
#
|
|
80
|
+
# `ocdif openocd` - command to register an openocd probe
|
|
81
|
+
# `nrf1` - defines the name of the probe within gdb_ocdif
|
|
82
|
+
# `jlink` - the interface to use in openocd.
|
|
83
|
+
# Loads the interface file interface/jlink.cfg
|
|
84
|
+
# `nrf52` - the target to use in openocd.
|
|
85
|
+
# Loads the interface file target/nrf52.cfg
|
|
86
|
+
# `123456789` - Serial number of the probe, to identify multiple. Optional.
|
|
87
|
+
# `swd` - Transport to use, `swd` or `jtag`, defaults to `swd`
|
|
88
|
+
#
|
|
89
|
+
# can be followed by an integer defining debug_level for openocd, defaults to 1
|
|
90
|
+
#
|
|
91
|
+
# Note that this does not actually connect to the probes. To connect, use
|
|
92
|
+
# - `ocdif connect nrf1`
|
|
93
|
+
# or:
|
|
94
|
+
# - `ocdif select nrf1`
|
|
95
|
+
# - `ocdif connect`
|
|
96
|
+
ocdif openocd nrf1 jlink nrf52 123456789 swd
|
|
97
|
+
ocdif openocd nrf2 jlink nrf52 123456790 swd
|
|
98
|
+
|
|
99
|
+
# To make connection to the probe more convenient, it is trecommended to add
|
|
100
|
+
# aliases to select the current probe
|
|
101
|
+
alias nrf1 = ocdif select nrf1
|
|
102
|
+
alias nrf2 = ocdif select nrf2
|
|
103
|
+
|
|
104
|
+
# Two convenience commands are recommended to make more accessible:
|
|
105
|
+
# - ocdif reset - Reset the target to a halted state, using the command
|
|
106
|
+
# specified by the probe implementation. For example
|
|
107
|
+
# `monitor reset halt`
|
|
108
|
+
# - ocdif reload - Reconnects to target, builds application with make, loads
|
|
109
|
+
# and resets target
|
|
110
|
+
alias reload = ocdif reload
|
|
111
|
+
alias res = ocdif reset
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
When configured as above, recompiling and reloading can be done within gdb:
|
|
117
|
+
|
|
118
|
+
### Selection and connecting
|
|
119
|
+
|
|
120
|
+
To use gdb_ocdif only to manage OCD connections, but don't invoke make, it is
|
|
121
|
+
possible to use, given configuration above:
|
|
122
|
+
- `(gdb) nrf1`
|
|
123
|
+
- `(gdb) ocdif connect`
|
|
124
|
+
|
|
125
|
+
(Output is cut down for clarity)
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
$ gdb-multiarch myapp.elf
|
|
129
|
+
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
Reading symbols from myapp.elf...
|
|
133
|
+
(gdb) nrf1
|
|
134
|
+
(gdb) ocdif connect
|
|
135
|
+
Reset_Handler () at vendor/nrf/nrfx/bsp/stable/mdk/gcc_startup_nrf52840.S:231
|
|
136
|
+
231 ldr r1, =__data_start
|
|
137
|
+
openocd Calling:
|
|
138
|
+
openocd openocd
|
|
139
|
+
openocd -c 'debug_level 1'
|
|
140
|
+
openocd -c 'source [find interface/jlink.cfg]'
|
|
141
|
+
openocd -c 'transport select swd'
|
|
142
|
+
openocd -c 'source [find target/nrf52.cfg]'
|
|
143
|
+
openocd -c 'gdb_port 15618'
|
|
144
|
+
openocd -c 'tcl_port disabled'
|
|
145
|
+
openocd -c 'telnet_port disabled'
|
|
146
|
+
openocd -c '$_TARGETNAME configure -rtos auto'
|
|
147
|
+
openocd -c 'echo "session started"'
|
|
148
|
+
openocd -c 'adapter serial 683479168'
|
|
149
|
+
openocd > Open On-Chip Debugger 0.12.0
|
|
150
|
+
openocd > Licensed under GNU GPL v2
|
|
151
|
+
openocd > For bug reports, read
|
|
152
|
+
openocd > http://openocd.org/doc/doxygen/bugs.html
|
|
153
|
+
openocd > debug_level: 1
|
|
154
|
+
openocd >
|
|
155
|
+
openocd > swd
|
|
156
|
+
openocd # session started
|
|
157
|
+
openocd > undefined debug reason 8 - target needs reset
|
|
158
|
+
(nrf1 gdb)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Resuling in `openocd` started in background, and gdb is connected.
|
|
162
|
+
|
|
163
|
+
Port number is randomized, to manage multiple debugging instances in paralell
|
|
164
|
+
to different boards.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
### reload - automatic rebuilds and reprogramming
|
|
168
|
+
|
|
169
|
+
It is also, and recommended, to use ocdif to trigger rebuilds and reloads. This
|
|
170
|
+
makes it possible to keep breakpoints and state between rebuilds.
|
|
171
|
+
|
|
172
|
+
This requires the target (in this case `myapp.elf`) to be build using `make` as:
|
|
173
|
+
`make myapp.elf`
|
|
174
|
+
|
|
175
|
+
If that is possible (which is recommeneded), it is possible to:
|
|
176
|
+
|
|
177
|
+
- select target - `(gdb) ocdif select nrf1`
|
|
178
|
+
- rebuild, reload and reset - `(gdb) ocdif reload`
|
|
179
|
+
|
|
180
|
+
`(gdb) ocdif reload` can then be repeated on code change.
|
|
181
|
+
|
|
182
|
+
...or use the aliases defined in `.gdbinit`:
|
|
183
|
+
- `(gdb) nrf1`
|
|
184
|
+
- `(gdb) reload`
|
|
185
|
+
|
|
186
|
+
for example:
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
$ gdb-multiarch myapp.elf
|
|
190
|
+
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
|
|
191
|
+
|
|
192
|
+
[...]
|
|
193
|
+
|
|
194
|
+
Reading symbols from myapp.elf...
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
(gdb) nrf1
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
(gdb) reload
|
|
201
|
+
make Calling:
|
|
202
|
+
make make
|
|
203
|
+
make -j32 myapp.elf
|
|
204
|
+
make >
|
|
205
|
+
make > ... proper make output cut out from example output ...
|
|
206
|
+
make > LINK myapp.elf
|
|
207
|
+
make >
|
|
208
|
+
make Process 'make' exited with code 0
|
|
209
|
+
Reset_Handler () at vendor/nrf/nrfx/bsp/stable/mdk/gcc_startup_nrf52840.S:231
|
|
210
|
+
231 ldr r1, =__data_start
|
|
211
|
+
[nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
212
|
+
xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
213
|
+
Loading section .vectors, size 0x200 lma 0x0
|
|
214
|
+
Loading section .rodata, size 0x118 lma 0x200
|
|
215
|
+
Loading section .ARM.exidx, size 0x8 lma 0x318
|
|
216
|
+
Loading section .text, size 0x4690 lma 0x320
|
|
217
|
+
Loading section .copy.table, size 0x30 lma 0x49b0
|
|
218
|
+
Loading section .zero.table, size 0x18 lma 0x49e0
|
|
219
|
+
Loading section .data, size 0x8 lma 0x49f8
|
|
220
|
+
Start address 0x00003e48, load size 18944
|
|
221
|
+
Transfer rate: 9 KB/sec, 2368 bytes/write.
|
|
222
|
+
[nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
223
|
+
xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
224
|
+
make closed
|
|
225
|
+
openocd Calling:
|
|
226
|
+
openocd openocd
|
|
227
|
+
openocd -c 'debug_level 1'
|
|
228
|
+
openocd -c 'source [find interface/jlink.cfg]'
|
|
229
|
+
openocd -c 'transport select swd'
|
|
230
|
+
openocd -c 'source [find target/nrf52.cfg]'
|
|
231
|
+
openocd -c 'gdb_port 11047'
|
|
232
|
+
openocd -c 'tcl_port disabled'
|
|
233
|
+
openocd -c 'telnet_port disabled'
|
|
234
|
+
openocd -c '$_TARGETNAME configure -rtos auto'
|
|
235
|
+
openocd -c 'echo "session started"'
|
|
236
|
+
openocd -c 'adapter serial 123456789'
|
|
237
|
+
openocd > Open On-Chip Debugger 0.12.0
|
|
238
|
+
openocd > Licensed under GNU GPL v2
|
|
239
|
+
openocd > For bug reports, read
|
|
240
|
+
openocd > http://openocd.org/doc/doxygen/bugs.html
|
|
241
|
+
openocd > debug_level: 1
|
|
242
|
+
openocd >
|
|
243
|
+
openocd > swd
|
|
244
|
+
openocd # session started
|
|
245
|
+
openocd > undefined debug reason 8 - target needs reset
|
|
246
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
247
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
248
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
249
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
250
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
251
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
252
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
253
|
+
(nrf1 gdb) continue
|
|
254
|
+
...
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
When connected, current probe name is shown in the prompt
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# GDB OCD-interface
|
|
2
|
+
|
|
3
|
+
Tool for managing on-chip debugger interfaces/servers from within GDB
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Normally, when developing for embedded devices, like ARM Cortex-M
|
|
7
|
+
microcontrollers, it is required for setting up a debugging session to:
|
|
8
|
+
|
|
9
|
+
- Start two terminals
|
|
10
|
+
- In terminal 1 - start ocd interface, for example `openocd`
|
|
11
|
+
- In terminal 2 - start gdb instance, for example `gdb-multiarch`
|
|
12
|
+
- In terminal 2 - Connect to openocd, using `target remote localhost:1234`, or
|
|
13
|
+
variant thereof
|
|
14
|
+
|
|
15
|
+
Then on every reset, it may be required to reconnect to the OCD instance
|
|
16
|
+
|
|
17
|
+
This makes a lot of overhead for each update and reprogramming.
|
|
18
|
+
|
|
19
|
+
This tool manages the OCD sessions as subprocesses from within `gdb` itself,
|
|
20
|
+
and also has convenience macros for rebuilding and reprogramming automatically.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
Install `gdb_ocdif`, so it's available from gdb environment.
|
|
26
|
+
|
|
27
|
+
### Install from pypi:
|
|
28
|
+
```sh
|
|
29
|
+
pip install --user gdb_ocdif
|
|
30
|
+
```
|
|
31
|
+
Make sure the install path, usually `~/.local` is available for python search
|
|
32
|
+
path
|
|
33
|
+
|
|
34
|
+
### Install from git:
|
|
35
|
+
pick a directory to clone this repo from
|
|
36
|
+
```sh
|
|
37
|
+
git clone https://github.com/pengi/gdb_ocdif.git /path/to/where/to/put/gdb_ocdif
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
In your normal environment, or before starting gdb, update `PYTHONPATH`
|
|
41
|
+
environment variable
|
|
42
|
+
|
|
43
|
+
Run, or add to `~/.bashrc`, `~/.zshrc` or similar:
|
|
44
|
+
```sh
|
|
45
|
+
export PYTHONPATH=/path/to/where/to/put/gdb_ocdif:$PYTHONPATH
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Configure gdb
|
|
49
|
+
|
|
50
|
+
It is recommended to autoload gdb_ocdif into gdb on each startup, and also add
|
|
51
|
+
default configuration and aliases
|
|
52
|
+
|
|
53
|
+
Add following to `~/.gdbinit`, and update to your liking.
|
|
54
|
+
|
|
55
|
+
None of the lines below will affect the target, but only setup the enviornment
|
|
56
|
+
```ini
|
|
57
|
+
|
|
58
|
+
# Load gdb_ocdif
|
|
59
|
+
python import gdb_ocdif
|
|
60
|
+
|
|
61
|
+
# Define available probes
|
|
62
|
+
#
|
|
63
|
+
# `ocdif openocd` - command to register an openocd probe
|
|
64
|
+
# `nrf1` - defines the name of the probe within gdb_ocdif
|
|
65
|
+
# `jlink` - the interface to use in openocd.
|
|
66
|
+
# Loads the interface file interface/jlink.cfg
|
|
67
|
+
# `nrf52` - the target to use in openocd.
|
|
68
|
+
# Loads the interface file target/nrf52.cfg
|
|
69
|
+
# `123456789` - Serial number of the probe, to identify multiple. Optional.
|
|
70
|
+
# `swd` - Transport to use, `swd` or `jtag`, defaults to `swd`
|
|
71
|
+
#
|
|
72
|
+
# can be followed by an integer defining debug_level for openocd, defaults to 1
|
|
73
|
+
#
|
|
74
|
+
# Note that this does not actually connect to the probes. To connect, use
|
|
75
|
+
# - `ocdif connect nrf1`
|
|
76
|
+
# or:
|
|
77
|
+
# - `ocdif select nrf1`
|
|
78
|
+
# - `ocdif connect`
|
|
79
|
+
ocdif openocd nrf1 jlink nrf52 123456789 swd
|
|
80
|
+
ocdif openocd nrf2 jlink nrf52 123456790 swd
|
|
81
|
+
|
|
82
|
+
# To make connection to the probe more convenient, it is trecommended to add
|
|
83
|
+
# aliases to select the current probe
|
|
84
|
+
alias nrf1 = ocdif select nrf1
|
|
85
|
+
alias nrf2 = ocdif select nrf2
|
|
86
|
+
|
|
87
|
+
# Two convenience commands are recommended to make more accessible:
|
|
88
|
+
# - ocdif reset - Reset the target to a halted state, using the command
|
|
89
|
+
# specified by the probe implementation. For example
|
|
90
|
+
# `monitor reset halt`
|
|
91
|
+
# - ocdif reload - Reconnects to target, builds application with make, loads
|
|
92
|
+
# and resets target
|
|
93
|
+
alias reload = ocdif reload
|
|
94
|
+
alias res = ocdif reset
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
When configured as above, recompiling and reloading can be done within gdb:
|
|
100
|
+
|
|
101
|
+
### Selection and connecting
|
|
102
|
+
|
|
103
|
+
To use gdb_ocdif only to manage OCD connections, but don't invoke make, it is
|
|
104
|
+
possible to use, given configuration above:
|
|
105
|
+
- `(gdb) nrf1`
|
|
106
|
+
- `(gdb) ocdif connect`
|
|
107
|
+
|
|
108
|
+
(Output is cut down for clarity)
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
$ gdb-multiarch myapp.elf
|
|
112
|
+
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
Reading symbols from myapp.elf...
|
|
116
|
+
(gdb) nrf1
|
|
117
|
+
(gdb) ocdif connect
|
|
118
|
+
Reset_Handler () at vendor/nrf/nrfx/bsp/stable/mdk/gcc_startup_nrf52840.S:231
|
|
119
|
+
231 ldr r1, =__data_start
|
|
120
|
+
openocd Calling:
|
|
121
|
+
openocd openocd
|
|
122
|
+
openocd -c 'debug_level 1'
|
|
123
|
+
openocd -c 'source [find interface/jlink.cfg]'
|
|
124
|
+
openocd -c 'transport select swd'
|
|
125
|
+
openocd -c 'source [find target/nrf52.cfg]'
|
|
126
|
+
openocd -c 'gdb_port 15618'
|
|
127
|
+
openocd -c 'tcl_port disabled'
|
|
128
|
+
openocd -c 'telnet_port disabled'
|
|
129
|
+
openocd -c '$_TARGETNAME configure -rtos auto'
|
|
130
|
+
openocd -c 'echo "session started"'
|
|
131
|
+
openocd -c 'adapter serial 683479168'
|
|
132
|
+
openocd > Open On-Chip Debugger 0.12.0
|
|
133
|
+
openocd > Licensed under GNU GPL v2
|
|
134
|
+
openocd > For bug reports, read
|
|
135
|
+
openocd > http://openocd.org/doc/doxygen/bugs.html
|
|
136
|
+
openocd > debug_level: 1
|
|
137
|
+
openocd >
|
|
138
|
+
openocd > swd
|
|
139
|
+
openocd # session started
|
|
140
|
+
openocd > undefined debug reason 8 - target needs reset
|
|
141
|
+
(nrf1 gdb)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Resuling in `openocd` started in background, and gdb is connected.
|
|
145
|
+
|
|
146
|
+
Port number is randomized, to manage multiple debugging instances in paralell
|
|
147
|
+
to different boards.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### reload - automatic rebuilds and reprogramming
|
|
151
|
+
|
|
152
|
+
It is also, and recommended, to use ocdif to trigger rebuilds and reloads. This
|
|
153
|
+
makes it possible to keep breakpoints and state between rebuilds.
|
|
154
|
+
|
|
155
|
+
This requires the target (in this case `myapp.elf`) to be build using `make` as:
|
|
156
|
+
`make myapp.elf`
|
|
157
|
+
|
|
158
|
+
If that is possible (which is recommeneded), it is possible to:
|
|
159
|
+
|
|
160
|
+
- select target - `(gdb) ocdif select nrf1`
|
|
161
|
+
- rebuild, reload and reset - `(gdb) ocdif reload`
|
|
162
|
+
|
|
163
|
+
`(gdb) ocdif reload` can then be repeated on code change.
|
|
164
|
+
|
|
165
|
+
...or use the aliases defined in `.gdbinit`:
|
|
166
|
+
- `(gdb) nrf1`
|
|
167
|
+
- `(gdb) reload`
|
|
168
|
+
|
|
169
|
+
for example:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
$ gdb-multiarch myapp.elf
|
|
173
|
+
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
|
|
174
|
+
|
|
175
|
+
[...]
|
|
176
|
+
|
|
177
|
+
Reading symbols from myapp.elf...
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
(gdb) nrf1
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
(gdb) reload
|
|
184
|
+
make Calling:
|
|
185
|
+
make make
|
|
186
|
+
make -j32 myapp.elf
|
|
187
|
+
make >
|
|
188
|
+
make > ... proper make output cut out from example output ...
|
|
189
|
+
make > LINK myapp.elf
|
|
190
|
+
make >
|
|
191
|
+
make Process 'make' exited with code 0
|
|
192
|
+
Reset_Handler () at vendor/nrf/nrfx/bsp/stable/mdk/gcc_startup_nrf52840.S:231
|
|
193
|
+
231 ldr r1, =__data_start
|
|
194
|
+
[nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
195
|
+
xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
196
|
+
Loading section .vectors, size 0x200 lma 0x0
|
|
197
|
+
Loading section .rodata, size 0x118 lma 0x200
|
|
198
|
+
Loading section .ARM.exidx, size 0x8 lma 0x318
|
|
199
|
+
Loading section .text, size 0x4690 lma 0x320
|
|
200
|
+
Loading section .copy.table, size 0x30 lma 0x49b0
|
|
201
|
+
Loading section .zero.table, size 0x18 lma 0x49e0
|
|
202
|
+
Loading section .data, size 0x8 lma 0x49f8
|
|
203
|
+
Start address 0x00003e48, load size 18944
|
|
204
|
+
Transfer rate: 9 KB/sec, 2368 bytes/write.
|
|
205
|
+
[nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
206
|
+
xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
207
|
+
make closed
|
|
208
|
+
openocd Calling:
|
|
209
|
+
openocd openocd
|
|
210
|
+
openocd -c 'debug_level 1'
|
|
211
|
+
openocd -c 'source [find interface/jlink.cfg]'
|
|
212
|
+
openocd -c 'transport select swd'
|
|
213
|
+
openocd -c 'source [find target/nrf52.cfg]'
|
|
214
|
+
openocd -c 'gdb_port 11047'
|
|
215
|
+
openocd -c 'tcl_port disabled'
|
|
216
|
+
openocd -c 'telnet_port disabled'
|
|
217
|
+
openocd -c '$_TARGETNAME configure -rtos auto'
|
|
218
|
+
openocd -c 'echo "session started"'
|
|
219
|
+
openocd -c 'adapter serial 123456789'
|
|
220
|
+
openocd > Open On-Chip Debugger 0.12.0
|
|
221
|
+
openocd > Licensed under GNU GPL v2
|
|
222
|
+
openocd > For bug reports, read
|
|
223
|
+
openocd > http://openocd.org/doc/doxygen/bugs.html
|
|
224
|
+
openocd > debug_level: 1
|
|
225
|
+
openocd >
|
|
226
|
+
openocd > swd
|
|
227
|
+
openocd # session started
|
|
228
|
+
openocd > undefined debug reason 8 - target needs reset
|
|
229
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
230
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
231
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
232
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
233
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
234
|
+
openocd > xPSR: 0x01000000 pc: 0x00003e48 msp: 0x20004008
|
|
235
|
+
openocd > [nrf52.cpu] halted due to debug-request, current mode: Thread
|
|
236
|
+
(nrf1 gdb) continue
|
|
237
|
+
...
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
When connected, current probe name is shown in the prompt
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright © 2026 Max Sikström
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the “Software”), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
|
11
|
+
# all copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
from .gdbif import ArgCommand, gdb_call, commandlist
|
|
22
|
+
from .model import OCDIFModel
|
|
23
|
+
from .probe_openocd import OCDIFOpenOCDCommand
|
|
24
|
+
from .commands import (
|
|
25
|
+
OCDIFListCommand,
|
|
26
|
+
OCDIFSelectCommand,
|
|
27
|
+
OCDIFConnectCommand,
|
|
28
|
+
OCDIFDisonnectCommand,
|
|
29
|
+
OCDIFResetCommand,
|
|
30
|
+
OCDIFReloadCommand,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
from typing import Set, Dict
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class OCDIFTools(ArgCommand):
|
|
37
|
+
"""Tools for managing On-Board Debugger server instances"""
|
|
38
|
+
|
|
39
|
+
state: OCDIFModel
|
|
40
|
+
|
|
41
|
+
def __init__(self, state: OCDIFModel) -> None:
|
|
42
|
+
super().__init__("ocdif", True)
|
|
43
|
+
self.state = state
|
|
44
|
+
|
|
45
|
+
def call(self, flags: Set[str], args: Dict[str, str]) -> None:
|
|
46
|
+
gdb_call("help ocdif")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
model = OCDIFModel()
|
|
50
|
+
|
|
51
|
+
OCDIFTools(model)
|
|
52
|
+
OCDIFOpenOCDCommand(model)
|
|
53
|
+
OCDIFListCommand(model)
|
|
54
|
+
OCDIFSelectCommand(model)
|
|
55
|
+
OCDIFConnectCommand(model)
|
|
56
|
+
OCDIFDisonnectCommand(model)
|
|
57
|
+
OCDIFResetCommand(model)
|
|
58
|
+
OCDIFReloadCommand(model)
|