Skip to content

Commit

Permalink
enhancements to DAP psize/cnt configuration and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrr committed Feb 22, 2025
1 parent 875e54e commit 225d45e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 43 deletions.
51 changes: 33 additions & 18 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ Finally there is **Y**et **A**nother **Picoprobe** around, the YAPicoprobe.
NOTE: Pico2 / RP2350 can also be used as probe hardware.
This is an experimental feature.

WARNING: Pico2 / RP2350 targets are currently not supported.

WARNING: Pico2 target is only working at <= 300kHz reliably. +
``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;"``
WARNING: Pico2 / RP2350 targets are under development and experimental.


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


[[dap-optimization]]
#### Parameter Optimization

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

Both parameters are also user settable, see <<runtime-configuration>>.


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

## Configuration

[[runtime-configuration]]
### Runtime Configuration of Probe Parameters

Several parameters can be configured via the Debug CDC of the probe. These parameters include
Expand All @@ -351,26 +352,40 @@ Following procedure applies:
* connect with a terminal program to the Debug CDC of the probe
* unlock configuration thru hitting <enter>, this works as long there is no `pwd`
* commands: `<cmd>`
** `lock` - lock the configuration parameters
** `killall` - kill all current configuration parameters
** `reset` - restart the probe
** `show` - shows the current configuration (initially empty)
+
[%autowidth]
|====
| `help` | show available variables/cmds
| `lock` | lock the configuration parameters
| `killall` | kill all current configuration parameters
| `reset` | restart the probe
| `show` | show the current configuration (initially empty)
|====
* variables: `<variable>=<value>`
** `f_cpu` - set CPU frequency in MHz
** `f_swd` - set SWD frequency in kHz
** `net` - set the net of the probes IP address `192.168.<net>.1`
** `nick` - set nickname of the probe. Use this with care because it also changes
the USB serial number (which might be intended)
** `pwd` - set a password for locking the configuration. Unlocking is done subsequently
with `pwd:<your-pwd>`
** `r_start` / `r_end` - RAM start/end for generic target to override default 0x20000000..0x20040000.
** `rtt` - enable/disable RTT access, default is RTT enabled (0: disable, 1:enable).
+
[%autowidth]
|====
| `f_cpu` | set CPU frequency in MHz
| `f_swd` | set SWD frequency in kHz
| `net` | set the net of the probes IP address `192.168.<net>.1`, defaults to "14"
| `nick` | set nickname of the probe. Use this with care because it also changes
the USB serial number (which might be intended)
| `pwd` | set a password for locking the configuration. Unlocking is done subsequently with `pwd:<your-pwd>`
| `ram_start` +
`ram_end` | RAM start/end for generic target to override default 0x20000000..0x20040000. This is mainly for
RTT detection
| `rtt` | enable/disable RTT access, default is RTT enabled (0: disable, 1:enable)
| `dap_psize` +
`dap_pcnt`| set `DAP_PACKET_SIZE` and `DAP_PACKET_COUNT`, see <<dap-optimization>>. If only one of those values
is set, the other goes to a default (64/1)
|====
* special characters:
** CR/LF - end the line
** BS - backspace one character
* unknown commands / variables are ignored
* unknown commands / variables are ignored and lock configuration
* if configuration is locked, all commands are ignored (except `pwd:<your-pwd>`)
[NOTE]
====
* the interface is far from perfect
Expand Down
21 changes: 11 additions & 10 deletions include/picoprobe_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,19 @@
//
// minIni definitions
//
#define MININI_VAR_NET "net"
#define MININI_VAR_NICK "nick"
#define MININI_VAR_FCPU "f_cpu"
#define MININI_VAR_FSWD "f_swd"
#define MININI_VAR_RSTART "r_start"
#define MININI_VAR_REND "r_end"
#define MININI_VAR_PWD "pwd"
#define MININI_VAR_RTT "rtt"
#define MININI_VAR_DPSIZE "d_psize"
#define MININI_VAR_NET "net"
#define MININI_VAR_NICK "nick"
#define MININI_VAR_FCPU "f_cpu"
#define MININI_VAR_FSWD "f_swd"
#define MININI_VAR_RSTART "ram_start"
#define MININI_VAR_REND "ram_end"
#define MININI_VAR_PWD "pwd"
#define MININI_VAR_RTT "rtt"
#define MININI_VAR_DAP_PSIZE "dap_psize"
#define MININI_VAR_DAP_PCNT "dap_pcnt"

#define MININI_VAR_NAMES MININI_VAR_NET, MININI_VAR_NICK, MININI_VAR_FCPU, MININI_VAR_FSWD, \
MININI_VAR_RSTART, MININI_VAR_REND, MININI_VAR_PWD, MININI_VAR_RTT, \
MININI_VAR_DPSIZE
MININI_VAR_DAP_PSIZE, MININI_VAR_DAP_PCNT

#endif
24 changes: 20 additions & 4 deletions src/cdc/cdc_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ static void cdc_debug_command_if(uint8_t ch)
}
}
else if (unlocked) {
static const char *minini_varnames[] = {MININI_VAR_NAMES, NULL};

p = strchr(cmd, '=');
if (p != NULL) {
static const char *minini_varnames[] = {MININI_VAR_NAMES, NULL};

*p = '\0';
++p;

Expand All @@ -245,7 +245,8 @@ static void cdc_debug_command_if(uint8_t ch)
}
}
else {
picoprobe_error("unknown var: '%s'\n", cmd);
picoprobe_error("unknown var: '%s' -> locked\n", cmd);
unlocked = false;
}
}
else if (strcmp(cmd, "lock") == 0) {
Expand All @@ -268,8 +269,23 @@ static void cdc_debug_command_if(uint8_t ch)
for (;;) {
}
}
else if (strcmp(cmd, "help") == 0) {
printf("------------- commands\n");
printf(" help - show available variables/cmds\n");
printf(" lock - lock the configuration parameters\n");
printf(" killall - kill all current configuration parameters\n");
printf(" reset - restart the probe\n");
printf(" show - show the current configuration (initially empty)\n");
printf(" <var>=<value> set a variable <var> to <value>\n (probe resets after every change)\n");
printf("------------- ini variables\n");
for (uint32_t ndx = 0; minini_varnames[ndx] != NULL; ++ndx) {
printf(" %s\n", minini_varnames[ndx]);
}
printf("-------------\n");
}
else {
picoprobe_error("unknown cmd: '%s'\n", cmd);
picoprobe_error("unknown cmd: '%s' (use 'help') -> locked\n", cmd);
unlocked = false;
}
}
else {
Expand Down
17 changes: 12 additions & 5 deletions src/cmsis-dap/dap_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,19 @@ void dap_task(void *ptr)
//
if (tool == E_DAPTOOL_UNKNOWN) {
uint32_t psize;
uint32_t pcnt;

psize = ini_getl(MININI_SECTION, MININI_VAR_DPSIZE, 0, MININI_FILENAME);
if (psize != 0)
psize = ini_getl(MININI_SECTION, MININI_VAR_DAP_PSIZE, 0, MININI_FILENAME);
pcnt = ini_getl(MININI_SECTION, MININI_VAR_DAP_PCNT, 0, MININI_FILENAME);
if (psize != 0 || pcnt != 0)
{
dap_packet_count = 1;
dap_packet_size = psize;
dap_packet_count = (pcnt != 0) ? pcnt : _DAP_PACKET_COUNT_UNKNOWN;
dap_packet_size = (psize != 0) ? psize : _DAP_PACKET_SIZE_UNKNOWN;
dap_packet_size = MIN(dap_packet_size, PACKET_MAXSIZE);
if (dap_packet_count * dap_packet_size > BUFFER_MAXSIZE) {
dap_packet_size = MIN(dap_packet_size, BUFFER_MAXSIZE);
dap_packet_count = BUFFER_MAXSIZE / dap_packet_size;
}
tool = E_DAPTOOL_USER;
}
else
Expand Down Expand Up @@ -215,7 +222,7 @@ void dap_task(void *ptr)
(tool == E_DAPTOOL_OPENOCD) ? "OpenOCD" :
(tool == E_DAPTOOL_PYOCD) ? "pyOCD" :
(tool == E_DAPTOOL_PROBERS) ? "probe-rs" :
(tool == E_DAPTOOL_USER) ? "user" : "UNKNOWN", dap_packet_count, dap_packet_size);
(tool == E_DAPTOOL_USER) ? "user-set" : "UNKNOWN", dap_packet_count, dap_packet_size);
led_state(LS_DAPV2_CONNECTED);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/lib/minIni/minGlue-Flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ int ini_init(void)

static void PrintDataStatus(MinIniFlashFileHeader *hp, const unsigned char *dataName)
{
picoprobe_info("magic 0x%08x\n", hp->magicNumber);
printf("magic 0x%08x\n", hp->magicNumber);
if (hp->magicNumber == MININI_FLASH_MAGIC_DATA_NUMBER_ID) {
picoprobe_info(" name: %s\n", hp->dataName);
picoprobe_info(" size: %d\n", hp->dataSize);
printf(" name: %s\n", hp->dataName);
printf(" size: %d\n", hp->dataSize);
}
else {
picoprobe_info(" <not valid>\n");
printf(" <not valid>\n");
}
} // PrintDataStatus

Expand All @@ -389,15 +389,16 @@ void ini_print_all(void)
MinIniFlashFileHeader *hp;
const unsigned char *p;

printf("------------- ini status\n");
hp = (MinIniFlashFileHeader*)MININI_CONFIG_FLASH_NVM_ADDR_START;
PrintDataStatus(hp, (const unsigned char*)MININI_FILENAME);
picoprobe_info("------------- device configuration\n");
printf("------------- device configuration\n");
if (hp->magicNumber == MININI_FLASH_MAGIC_DATA_NUMBER_ID) {
p = (const unsigned char*)hp + sizeof(MinIniFlashFileHeader);
for (size_t i = 0; i < hp->dataSize; i++) {
printf("%c", *p);
p++;
}
}
picoprobe_info("-------------\n");
printf("-------------\n");
} // ini_print_all

0 comments on commit 225d45e

Please sign in to comment.