Skip to content

Commit 225d45e

Browse files
committed
enhancements to DAP psize/cnt configuration and documentation
1 parent 875e54e commit 225d45e

File tree

5 files changed

+83
-43
lines changed

5 files changed

+83
-43
lines changed

README.adoc

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ Finally there is **Y**et **A**nother **Picoprobe** around, the YAPicoprobe.
2121
NOTE: Pico2 / RP2350 can also be used as probe hardware.
2222
This is an experimental feature.
2323

24-
WARNING: Pico2 / RP2350 targets are currently not supported.
25-
26-
WARNING: Pico2 target is only working at <= 300kHz reliably. +
27-
``time /home/hardy/.pico-sdk/openocd/0.12.0+dev/openocd.exe -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s /home/hardy/.pico-sdk/openocd/0.12.0+dev/scripts -f /home/hardy/.vscode/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl -f interface/cmsis-dap.cfg -f target/rp2350.cfg -c "adapter speed 349" -c "program {pio_blink.elf} verify reset; shutdown;"``
24+
WARNING: Pico2 / RP2350 targets are under development and experimental.
2825

2926

3027
## Features
@@ -125,6 +122,7 @@ NOTE: For best RP2040 support, OpenOCD bundled with PlatformIO is recommended.
125122
See <<platformio>>
126123

127124

125+
[[dap-optimization]]
128126
#### Parameter Optimization
129127

130128
YAPicoprobe tries to identify the connecting tool and sets some internal parameters for best performance.
@@ -157,6 +155,8 @@ DAP_PACKET_SIZE=64
157155
DAP_PACKET_SIZE=64
158156
|===
159157

158+
Both parameters are also user settable, see <<runtime-configuration>>.
159+
160160

161161
#### SWD Adapter Speed
162162
The tools above allow specification of the adapter speed. This is the clock frequency between probe and target device.
@@ -339,6 +339,7 @@ The Pico Debug Probe has four additional LEDs. Assignment is as follows:
339339

340340
## Configuration
341341

342+
[[runtime-configuration]]
342343
### Runtime Configuration of Probe Parameters
343344

344345
Several parameters can be configured via the Debug CDC of the probe. These parameters include
@@ -351,26 +352,40 @@ Following procedure applies:
351352
* connect with a terminal program to the Debug CDC of the probe
352353
* unlock configuration thru hitting <enter>, this works as long there is no `pwd`
353354
* commands: `<cmd>`
354-
** `lock` - lock the configuration parameters
355-
** `killall` - kill all current configuration parameters
356-
** `reset` - restart the probe
357-
** `show` - shows the current configuration (initially empty)
355+
+
356+
[%autowidth]
357+
|====
358+
| `help` | show available variables/cmds
359+
| `lock` | lock the configuration parameters
360+
| `killall` | kill all current configuration parameters
361+
| `reset` | restart the probe
362+
| `show` | show the current configuration (initially empty)
363+
|====
358364
* variables: `<variable>=<value>`
359-
** `f_cpu` - set CPU frequency in MHz
360-
** `f_swd` - set SWD frequency in kHz
361-
** `net` - set the net of the probes IP address `192.168.<net>.1`
362-
** `nick` - set nickname of the probe. Use this with care because it also changes
363-
the USB serial number (which might be intended)
364-
** `pwd` - set a password for locking the configuration. Unlocking is done subsequently
365-
with `pwd:<your-pwd>`
366-
** `r_start` / `r_end` - RAM start/end for generic target to override default 0x20000000..0x20040000.
367-
** `rtt` - enable/disable RTT access, default is RTT enabled (0: disable, 1:enable).
365+
+
366+
[%autowidth]
367+
|====
368+
| `f_cpu` | set CPU frequency in MHz
369+
| `f_swd` | set SWD frequency in kHz
370+
| `net` | set the net of the probes IP address `192.168.<net>.1`, defaults to "14"
371+
| `nick` | set nickname of the probe. Use this with care because it also changes
372+
the USB serial number (which might be intended)
373+
| `pwd` | set a password for locking the configuration. Unlocking is done subsequently with `pwd:<your-pwd>`
374+
| `ram_start` +
375+
`ram_end` | RAM start/end for generic target to override default 0x20000000..0x20040000. This is mainly for
376+
RTT detection
377+
| `rtt` | enable/disable RTT access, default is RTT enabled (0: disable, 1:enable)
378+
| `dap_psize` +
379+
`dap_pcnt`| set `DAP_PACKET_SIZE` and `DAP_PACKET_COUNT`, see <<dap-optimization>>. If only one of those values
380+
is set, the other goes to a default (64/1)
381+
|====
368382
* special characters:
369383
** CR/LF - end the line
370384
** BS - backspace one character
371-
* unknown commands / variables are ignored
385+
* unknown commands / variables are ignored and lock configuration
372386
* if configuration is locked, all commands are ignored (except `pwd:<your-pwd>`)
373387
388+
374389
[NOTE]
375390
====
376391
* the interface is far from perfect

include/picoprobe_config.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,19 @@
9393
//
9494
// minIni definitions
9595
//
96-
#define MININI_VAR_NET "net"
97-
#define MININI_VAR_NICK "nick"
98-
#define MININI_VAR_FCPU "f_cpu"
99-
#define MININI_VAR_FSWD "f_swd"
100-
#define MININI_VAR_RSTART "r_start"
101-
#define MININI_VAR_REND "r_end"
102-
#define MININI_VAR_PWD "pwd"
103-
#define MININI_VAR_RTT "rtt"
104-
#define MININI_VAR_DPSIZE "d_psize"
96+
#define MININI_VAR_NET "net"
97+
#define MININI_VAR_NICK "nick"
98+
#define MININI_VAR_FCPU "f_cpu"
99+
#define MININI_VAR_FSWD "f_swd"
100+
#define MININI_VAR_RSTART "ram_start"
101+
#define MININI_VAR_REND "ram_end"
102+
#define MININI_VAR_PWD "pwd"
103+
#define MININI_VAR_RTT "rtt"
104+
#define MININI_VAR_DAP_PSIZE "dap_psize"
105+
#define MININI_VAR_DAP_PCNT "dap_pcnt"
105106

106107
#define MININI_VAR_NAMES MININI_VAR_NET, MININI_VAR_NICK, MININI_VAR_FCPU, MININI_VAR_FSWD, \
107108
MININI_VAR_RSTART, MININI_VAR_REND, MININI_VAR_PWD, MININI_VAR_RTT, \
108-
MININI_VAR_DPSIZE
109+
MININI_VAR_DAP_PSIZE, MININI_VAR_DAP_PCNT
109110

110111
#endif

src/cdc/cdc_debug.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ static void cdc_debug_command_if(uint8_t ch)
216216
}
217217
}
218218
else if (unlocked) {
219+
static const char *minini_varnames[] = {MININI_VAR_NAMES, NULL};
220+
219221
p = strchr(cmd, '=');
220222
if (p != NULL) {
221-
static const char *minini_varnames[] = {MININI_VAR_NAMES, NULL};
222-
223223
*p = '\0';
224224
++p;
225225

@@ -245,7 +245,8 @@ static void cdc_debug_command_if(uint8_t ch)
245245
}
246246
}
247247
else {
248-
picoprobe_error("unknown var: '%s'\n", cmd);
248+
picoprobe_error("unknown var: '%s' -> locked\n", cmd);
249+
unlocked = false;
249250
}
250251
}
251252
else if (strcmp(cmd, "lock") == 0) {
@@ -268,8 +269,23 @@ static void cdc_debug_command_if(uint8_t ch)
268269
for (;;) {
269270
}
270271
}
272+
else if (strcmp(cmd, "help") == 0) {
273+
printf("------------- commands\n");
274+
printf(" help - show available variables/cmds\n");
275+
printf(" lock - lock the configuration parameters\n");
276+
printf(" killall - kill all current configuration parameters\n");
277+
printf(" reset - restart the probe\n");
278+
printf(" show - show the current configuration (initially empty)\n");
279+
printf(" <var>=<value> set a variable <var> to <value>\n (probe resets after every change)\n");
280+
printf("------------- ini variables\n");
281+
for (uint32_t ndx = 0; minini_varnames[ndx] != NULL; ++ndx) {
282+
printf(" %s\n", minini_varnames[ndx]);
283+
}
284+
printf("-------------\n");
285+
}
271286
else {
272-
picoprobe_error("unknown cmd: '%s'\n", cmd);
287+
picoprobe_error("unknown cmd: '%s' (use 'help') -> locked\n", cmd);
288+
unlocked = false;
273289
}
274290
}
275291
else {

src/cmsis-dap/dap_server.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,19 @@ void dap_task(void *ptr)
179179
//
180180
if (tool == E_DAPTOOL_UNKNOWN) {
181181
uint32_t psize;
182+
uint32_t pcnt;
182183

183-
psize = ini_getl(MININI_SECTION, MININI_VAR_DPSIZE, 0, MININI_FILENAME);
184-
if (psize != 0)
184+
psize = ini_getl(MININI_SECTION, MININI_VAR_DAP_PSIZE, 0, MININI_FILENAME);
185+
pcnt = ini_getl(MININI_SECTION, MININI_VAR_DAP_PCNT, 0, MININI_FILENAME);
186+
if (psize != 0 || pcnt != 0)
185187
{
186-
dap_packet_count = 1;
187-
dap_packet_size = psize;
188+
dap_packet_count = (pcnt != 0) ? pcnt : _DAP_PACKET_COUNT_UNKNOWN;
189+
dap_packet_size = (psize != 0) ? psize : _DAP_PACKET_SIZE_UNKNOWN;
190+
dap_packet_size = MIN(dap_packet_size, PACKET_MAXSIZE);
191+
if (dap_packet_count * dap_packet_size > BUFFER_MAXSIZE) {
192+
dap_packet_size = MIN(dap_packet_size, BUFFER_MAXSIZE);
193+
dap_packet_count = BUFFER_MAXSIZE / dap_packet_size;
194+
}
188195
tool = E_DAPTOOL_USER;
189196
}
190197
else
@@ -215,7 +222,7 @@ void dap_task(void *ptr)
215222
(tool == E_DAPTOOL_OPENOCD) ? "OpenOCD" :
216223
(tool == E_DAPTOOL_PYOCD) ? "pyOCD" :
217224
(tool == E_DAPTOOL_PROBERS) ? "probe-rs" :
218-
(tool == E_DAPTOOL_USER) ? "user" : "UNKNOWN", dap_packet_count, dap_packet_size);
225+
(tool == E_DAPTOOL_USER) ? "user-set" : "UNKNOWN", dap_packet_count, dap_packet_size);
219226
led_state(LS_DAPV2_CONNECTED);
220227
}
221228
}

src/lib/minIni/minGlue-Flash.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,13 @@ int ini_init(void)
372372

373373
static void PrintDataStatus(MinIniFlashFileHeader *hp, const unsigned char *dataName)
374374
{
375-
picoprobe_info("magic 0x%08x\n", hp->magicNumber);
375+
printf("magic 0x%08x\n", hp->magicNumber);
376376
if (hp->magicNumber == MININI_FLASH_MAGIC_DATA_NUMBER_ID) {
377-
picoprobe_info(" name: %s\n", hp->dataName);
378-
picoprobe_info(" size: %d\n", hp->dataSize);
377+
printf(" name: %s\n", hp->dataName);
378+
printf(" size: %d\n", hp->dataSize);
379379
}
380380
else {
381-
picoprobe_info(" <not valid>\n");
381+
printf(" <not valid>\n");
382382
}
383383
} // PrintDataStatus
384384

@@ -389,15 +389,16 @@ void ini_print_all(void)
389389
MinIniFlashFileHeader *hp;
390390
const unsigned char *p;
391391

392+
printf("------------- ini status\n");
392393
hp = (MinIniFlashFileHeader*)MININI_CONFIG_FLASH_NVM_ADDR_START;
393394
PrintDataStatus(hp, (const unsigned char*)MININI_FILENAME);
394-
picoprobe_info("------------- device configuration\n");
395+
printf("------------- device configuration\n");
395396
if (hp->magicNumber == MININI_FLASH_MAGIC_DATA_NUMBER_ID) {
396397
p = (const unsigned char*)hp + sizeof(MinIniFlashFileHeader);
397398
for (size_t i = 0; i < hp->dataSize; i++) {
398399
printf("%c", *p);
399400
p++;
400401
}
401402
}
402-
picoprobe_info("-------------\n");
403+
printf("-------------\n");
403404
} // ini_print_all

0 commit comments

Comments
 (0)