Skip to content

Commit c37a753

Browse files
authored
Merge pull request #187 from rgrr/feature/999-hunting-bugs
* DAP server reworked, taken from original debugprobe * now all tools can use 16 packets with 64 bytes length, have to investigate larger buffers * packet cnt/size no longer user settable * rp2040 wake up sequence can now handle stale DP (at least I'm hoping so) * rp2350 wake up reworked * try to start target (more) reliable * lot of minor stuff
2 parents 38c2537 + 209d987 commit c37a753

File tree

14 files changed

+913
-391
lines changed

14 files changed

+913
-391
lines changed

Makefile

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
VERSION_MAJOR := 2
66
VERSION_MINOR := 2
7-
VERSION_PATCH := 3
7+
VERSION_PATCH := 4
88

99
BUILD_DIR := _build
1010
BUILDEE_DIR := _buildee
@@ -41,7 +41,7 @@ endif
4141
#
4242
ifeq ($(PICO_BOARDEE),)
4343
# pico|pico_w|pico_debug_probe|pico2
44-
PICO_BOARDEE := pico
44+
PICO_BOARDEE := pico2
4545
endif
4646

4747
PICO_CHIPEE := rp2040
@@ -221,7 +221,7 @@ show-options:
221221
# - most work is done in the debuggEE
222222
#
223223
DEBUGGER_SERNO ?= 2739E00F30FE67E7
224-
OPENOCD_R := /home/hardy/.pico-sdk/openocd/0.12.0+dev
224+
OPENOCD_R := ~/.pico-sdk/openocd/0.12.0+dev
225225
OPENOCD := $(OPENOCD_R)/openocd
226226
OPENOCD_S := $(OPENOCD_R)/scripts
227227
#DEBUGGEE_CLIB := picolibc
@@ -244,18 +244,23 @@ all-debuggEE:
244244
.PHONY: debuggEE-flash
245245
debuggEE-flash:
246246
$(MAKE) all-debuggEE
247-
pyocd flash -f 6M --probe $(DEBUGGER_SERNO) -e auto $(BUILDEE_DIR)/$(PROJECT).hex
247+
pyocd flash -t $(PICO_CHIPEE) -f 6M --probe $(DEBUGGER_SERNO) -e auto $(BUILDEE_DIR)/$(PROJECT).hex
248+
# pyocd flash -t $(PICO_CHIPEE) -f 6M --probe $(DEBUGGER_SERNO) -e auto -L "pyocd.probe.*=debug" $(BUILDEE_DIR)/$(PROJECT).hex
249+
@echo "ok."
250+
251+
.PHONY: debuggEE-flash-cp
252+
debuggEE-flash-cp:
253+
$(MAKE) all-debuggEE
254+
cp $(BUILDEE_DIR)/$(PROJECT).uf2 /media/picoprobe
248255
@echo "ok."
249256

250257
.PHONY: debuggEE-flash-openocd
251258
debuggEE-flash-openocd:
252259
$(MAKE) all-debuggEE
253260
# openocd does much faster flashing
254-
$(OPENOCD) -s $(OPENOCD_S) -f interface/cmsis-dap.cfg -f target/$(PICO_CHIPEE).cfg \
261+
$(OPENOCD) -s $(OPENOCD_S) -f interface/cmsis-dap.cfg -f target/$(PICO_CHIPEE).cfg \
255262
-c "adapter speed 6000; adapter serial $(DEBUGGER_SERNO)" \
256-
-c "program {$(BUILDEE_DIR)/$(PROJECT).hex} verify; exit;"
257-
# "pyocd reset" required to start
258-
pyocd reset -f 6M --probe $(DEBUGGER_SERNO)
263+
-c "program {$(BUILDEE_DIR)/$(PROJECT).hex} verify reset exit"
259264
@echo "ok."
260265

261266
.PHONY: debuggEE-flash-probe-rs
@@ -277,19 +282,19 @@ debuggEE-flash-erase:
277282
# -c "adapter speed 6000; adapter serial $(DEBUGGER_SERNO)" \
278283
# -c "flash init; flash list; flash banks; init; flash erase_address 0x10000000 0x10000; init; exit;"
279284
# and this one is slow because chip erase is not implemented in the blobs (src/daplink-pico/family/raspberry/flash_blob.c)
280-
pyocd erase --mass
285+
pyocd erase --mass -t $(PICO_CHIPEE) -f 6M --probe $(DEBUGGER_SERNO)
281286
@echo "ok."
282287

283288

284289
.PHONY: debuggEE-reset
285290
debuggEE-reset:
286-
pyocd reset -v -f 6M --probe $(DEBUGGER_SERNO)
291+
pyocd reset -v -t $(PICO_CHIPEE) -f 6M --probe $(DEBUGGER_SERNO)
287292

288293
.PHONY: debuggEE-reset-openocd
289294
debuggEE-reset-openocd:
290295
$(OPENOCD) -s $(OPENOCD_S) -f interface/cmsis-dap.cfg -f target/$(PICO_CHIPEE).cfg \
291296
-c "adapter speed 6000; adapter serial $(DEBUGGER_SERNO)" \
292-
-c "init; exit;"
297+
-c "init; reset run; exit;"
293298

294299
.PHONY: debuggEE-reset-probe-rs
295300
debuggEE-reset-probe-rs:
@@ -302,7 +307,7 @@ cmake-create-debuggEE: clean-build-debuggEE
302307
$(CMAKE_FLAGS) \
303308
-DPICO_CLIB=$(DEBUGGEE_CLIB) \
304309
-DOPT_NET= -DOPT_PROBE_DEBUG_OUT=RTT \
305-
-DOPT_SIGROK=0 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=0 -DOPT_TARGET_UART=1
310+
-DOPT_SIGROK=0 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=1 -DOPT_TARGET_UART=1
306311

307312

308313
.PHONY: cmake-create-debuggEE-clang
@@ -313,7 +318,7 @@ cmake-create-debuggEE-clang: clean-build-debuggEE
313318
-DPICO_CLIB=llvm_libc \
314319
-DPICO_COMPILER=pico_arm_clang \
315320
-DOPT_NET= -DOPT_PROBE_DEBUG_OUT=RTT \
316-
-DOPT_SIGROK=0 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=0 -DOPT_TARGET_UART=1
321+
-DOPT_SIGROK=0 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=1 -DOPT_TARGET_UART=1
317322

318323

319324
.PHONY: cmake-create-debuggEE-release
@@ -322,7 +327,7 @@ cmake-create-debuggEE-release: clean-build-debuggEE
322327
$(CMAKE_FLAGS) \
323328
-DPICO_CLIB=$(DEBUGGEE_CLIB) \
324329
-DOPT_NET= -DOPT_PROBE_DEBUG_OUT=RTT \
325-
-DOPT_SIGROK=1 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=0 -DOPT_TARGET_UART=1
330+
-DOPT_SIGROK=1 -DOPT_MSC=0 -DOPT_CMSIS_DAPV1=0 -DOPT_CMSIS_DAPV2=1 -DOPT_TARGET_UART=1
326331

327332

328333
.PHONY: cmake-create-debugger
@@ -331,3 +336,15 @@ cmake-create-debugger: clean-build
331336
$(CMAKE_FLAGS) \
332337
-DPICO_CLIB=newlib \
333338
-DOPT_NET= -DOPT_SIGROK=0 -DOPT_MSC=0
339+
340+
341+
.PHONY: benchmark-probe-rs
342+
benchmark-probe-rs:
343+
probe-rs benchmark --protocol swd --address 0x20020000 --min-speed 1000 --max-speed 10000 --chip $(PICO_CHIPEE)
344+
345+
346+
# this is actually just a reminder for the probe-rs command line
347+
# "probe-rs gdb" does actually not run well under Eclipse(?)
348+
.PHONY: gdb-server-probe-rs
349+
gdb-server-probe-rs:
350+
probe-rs gdb --chip rp2350 --gdb-connection-string 127.0.0.1:3333 --speed 9000 --protocol swd

README.adoc

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,15 @@ Those settings are:
134134
|===
135135
|Tool | Parameter
136136

137-
|pyOCD / CMSIS-DAPv2
138-
|DAP_PACKET_COUNT=2 +
139-
DAP_PACKET_SIZE=512
140-
141-
|OpenOCD / CMSIS-DAPv2
142-
|DAP_PACKET_COUNT=1 +
143-
DAP_PACKET_SIZE=1024
144-
145-
|probe-rs / CMSIS-DAPv2
146-
|DAP_PACKET_COUNT=2 +
147-
DAP_PACKET_SIZE=1024
148-
149-
|unknown / CMSIS-DAPv2
150-
|DAP_PACKET_COUNT=1 +
137+
|CMSIS-DAPv2
138+
|DAP_PACKET_COUNT=16 +
151139
DAP_PACKET_SIZE=64
152140

153141
|CMSIS-DAPv1 HID
154142
|DAP_PACKET_COUNT=1 +
155143
DAP_PACKET_SIZE=64
156144
|===
157145

158-
For the adventurous both parameters are also user settable, see <<runtime-configuration>>.
159-
160146

161147
#### SWD Adapter Speed
162148
The tools above allow specification of the adapter speed. This is the clock frequency between probe and target device.
@@ -370,9 +356,6 @@ Following procedure applies:
370356
`ram_end` | RAM start/end for generic target to override default 0x20000000..0x20040000. This is mainly for
371357
RTT detection
372358
| `rtt` | enable/disable RTT access, default is RTT enabled (0: disable, 1:enable)
373-
| `dap_psize` +
374-
`dap_pcnt`| set `DAP_PACKET_SIZE` and `DAP_PACKET_COUNT`, see <<dap-optimization>>. If only one of those values
375-
is set, the other goes to a default (64/1)
376359
|====
377360
* special characters:
378361
** CR/LF - end the line

include/DAP_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extern uint16_t dap_packet_size;
107107
/// and CMSIS-DAPv1 works only with "1" (openocd)
108108
/// The __LINE__ test is required to skip the test in DAP.c successfully.
109109
extern uint8_t dap_packet_count;
110-
#define DAP_PACKET_COUNT ((__LINE__ < 50) ? 1 : dap_packet_count)
110+
#define DAP_PACKET_COUNT ((__LINE__ < 50) ? 16 : dap_packet_count)
111111

112112
/// Indicate that UART Serial Wire Output (SWO) trace is available.
113113
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.

include/FreeRTOSConfig.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define configAPPLICATION_ALLOCATED_HEAP 0
8484

8585
/* Hook function related definitions. */
86-
#define configCHECK_FOR_STACK_OVERFLOW 1
86+
#define configCHECK_FOR_STACK_OVERFLOW 2
8787
#define configUSE_MALLOC_FAILED_HOOK 1
8888
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
8989

@@ -97,7 +97,7 @@
9797

9898
#warning "configGENERATE_RUN_TIME_STATS is set"
9999
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while( 0 )
100-
//#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = *((uint32_t *)(TF_TIMER_BASE + TF_TIMER_TIMERAWL_OFFSET)) )
100+
#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = xTickCount )
101101
#define portGET_RUN_TIME_COUNTER_VALUE() (*((uint32_t *)(TF_TIMER_BASE + TF_TIMER_TIMERAWL_OFFSET)))
102102

103103
#undef configUSE_TRACE_FACILITY
@@ -123,9 +123,13 @@
123123

124124
#define configKERNEL_PROVIDED_STATIC_MEMORY 1
125125

126+
/******************************************************************************************
127+
* It seems that the probe runs better with a single core. No clue what the problem is.
128+
******************************************************************************************/
129+
126130
/* SMP port only */
127-
#define configNUMBER_OF_CORES 2
128-
#define configTICK_CORE 1
131+
#define configNUMBER_OF_CORES 1
132+
#define configTICK_CORE 0
129133
#define configRUN_MULTIPLE_PRIORITIES 1
130134
#if configNUMBER_OF_CORES != 1
131135
#define configUSE_CORE_AFFINITY 1

include/picoprobe_config.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@
8989
#define MININI_VAR_REND "ram_end"
9090
#define MININI_VAR_PWD "pwd"
9191
#define MININI_VAR_RTT "rtt"
92-
#define MININI_VAR_DAP_PSIZE "dap_psize"
93-
#define MININI_VAR_DAP_PCNT "dap_pcnt"
9492

9593
#define MININI_VAR_NAMES MININI_VAR_NET, MININI_VAR_NICK, MININI_VAR_FCPU, MININI_VAR_FSWD, \
96-
MININI_VAR_RSTART, MININI_VAR_REND, MININI_VAR_PWD, MININI_VAR_RTT, \
97-
MININI_VAR_DAP_PSIZE, MININI_VAR_DAP_PCNT
94+
MININI_VAR_RSTART, MININI_VAR_REND, MININI_VAR_PWD, MININI_VAR_RTT
9895

9996
#endif

0 commit comments

Comments
 (0)