Compare commits

..

10 Commits

Author SHA1 Message Date
Jonathan Bell
5ab8c86465 picoprobe version 1.0.3 2023-08-15 11:47:19 +01:00
Jonathan Bell
2a6f9911db probe: hook up reset functionality to DAP commands 2023-08-15 11:23:54 +01:00
Jonathan Bell
5b6eb3e427 Fix debug prints
- The reset pin must move otherwise uart0 tx is squashed
- Don't preempt printf, it doesn't like it
- Set up the UART by default
2023-08-15 11:21:17 +01:00
P33M
6473166494 usb_descriptors: disable remote wake (#91)
see https://github.com/raspberrypi/picoprobe/issues/71
2023-08-09 13:13:36 +01:00
Luke Wren
3a1887ff06 Merge pull request #90 from raspberrypi/lurch-patch-1
Small README tweaks
2023-06-22 16:17:39 +01:00
Andrew Scheller
13b420d34c Small README tweaks 2023-06-22 15:56:45 +01:00
Roger Wolff
eb494103d4 buildsystem improvements to make it easier to build for debugprobe. (#87)
Merge documentation pull request from @rewolff
2023-06-22 13:50:25 +01:00
P33M
7de418cce3 Merge pull request #89 from raspberrypi/fix-deinit-without-init
Don't call probe_read_mode() in deinit() without matching prior init(), fixes #88
2023-06-18 11:00:24 +01:00
Luke Wren
0746b5a844 Don't call probe_read_mode() in deinit() without matching prior init(), fixes #88 2023-06-17 19:59:52 +01:00
P33M
d04ff3b472 Merge pull request #83 from raspberrypi/pio-program-improvements
PIO program improvements
2023-05-30 10:22:02 +01:00
12 changed files with 96 additions and 12 deletions

View File

@@ -44,6 +44,17 @@ target_compile_definitions (picoprobe PRIVATE
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
)
option (DEBUGPROBE "compile for the debugprobe" OFF)
if (DEBUGPROBE)
target_compile_definitions (picoprobe PRIVATE
DEBUGPROBE=1
)
set_target_properties(picoprobe PROPERTIES
OUTPUT_NAME "debugprobe"
)
endif ()
target_link_libraries(picoprobe PRIVATE
pico_multicore
pico_stdlib

View File

@@ -4,6 +4,36 @@ Picoprobe allows a Pico / RP2040 to be used as USB -> SWD and UART bridge. This
# Documentation
Picoprobe documentation can be found in the [Pico Getting Started Guide](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). See "Appendix A: Using Picoprobe".
# Hacking
For the purpose of making changes or studying of the code, you may want to compile the code yourself.
To compile this project firstly initialize and update the submodules:
```
git submodule update --init
```
then create and switch to the build directory:
```
mkdir build
cd build
```
then run cmake and build the code:
```
cmake ..
make
```
Done! You should now have a `picoprobe.uf2` that you can upload to your Pico in the normal way.
If you want to create the version that runs on the Raspberry Pi Debug Probe, then you need to invoke `cmake` in the sequence above with the `DEBUGPROBE=ON` option:
```
cmake -DDEBUGPROBE=ON ..
```
This will build with the configuration for the Debug Probe and call the output program `debugprobe.uf2`, as opposed to `picoprobe.uf2` for the vanilla version.
Note that if you first ran through the whole sequence to compile for the Pico, then you don't need to start back at the top. You can just go back to the `cmake` step and start from there.
# TODO
- TinyUSB's vendor interface is FIFO-based and not packet-based. Using raw tx/rx callbacks is preferable as this stops DAP command batches from being concatenated, which confused openOCD.
- Instead of polling, move the DAP thread to an asynchronously started/stopped one-shot operation to reduce CPU wakeups

View File

@@ -460,7 +460,11 @@ __STATIC_FORCEINLINE void PIN_nTRST_OUT (uint32_t bit) {
\return Current status of the nRESET DAP hardware I/O pin.
*/
__STATIC_FORCEINLINE uint32_t PIN_nRESET_IN (void) {
#ifdef PROBE_PIN_RESET
return probe_reset_level();
#else
return (0U);
#endif
}
/** nRESET I/O pin: Set Output.
@@ -469,7 +473,11 @@ __STATIC_FORCEINLINE uint32_t PIN_nRESET_IN (void) {
- 1: release device hardware reset.
*/
__STATIC_FORCEINLINE void PIN_nRESET_OUT (uint32_t bit) {
;
#ifdef PROBE_PIN_RESET
probe_assert_reset(!!bit);
#else
(void) bit;
#endif
}
///@}

View File

@@ -52,4 +52,4 @@
#define PROBE_PRODUCT_STRING "Debug Probe (CMSIS-DAP)"
#endif
#endif

View File

@@ -38,7 +38,7 @@
/* Include CDC interface to bridge to target UART. Omit if not used. */
#define PROBE_CDC_UART
/* Target reset GPIO (active-low). Omit if not used.*/
#define PROBE_PIN_RESET 0
#define PROBE_PIN_RESET 1
#define PROBE_SM 0
#define PROBE_PIN_OFFSET 12

View File

@@ -35,7 +35,9 @@
#define PROBE_PIN_SWCLK (PROBE_PIN_OFFSET + 0) // 2
#define PROBE_PIN_SWDIO (PROBE_PIN_OFFSET + 1) // 3
// Target reset config
#define PROBE_PIN_RESET 0
#if false
#define PROBE_PIN_RESET 1
#endif
// UART config
#define PICOPROBE_UART_TX 4

View File

@@ -139,7 +139,7 @@ void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* line_coding)
vTaskSuspend(uart_taskhandle);
interval = MAX(1, micros / ((1000 * 1000) / configTICK_RATE_HZ));
debounce_ticks = MAX(1, configTICK_RATE_HZ / (interval * DEBOUNCE_MS));
picoprobe_info("New baud rate %d micros %d interval %u\n",
picoprobe_info("New baud rate %ld micros %ld interval %lu\n",
line_coding->bit_rate, micros, interval);
uart_deinit(PICOPROBE_UART_INTERFACE);
tud_cdc_write_clear();

View File

@@ -99,6 +99,7 @@ int main(void) {
tusb_init();
DAP_Setup();
stdio_uart_init();
led_init();

View File

@@ -26,29 +26,50 @@
#ifndef PICOPROBE_H_
#define PICOPROBE_H_
#include "FreeRTOS.h"
#include "task.h"
#if false
#define picoprobe_info(format,args...) printf(format, ## args)
#define picoprobe_info(format,args...) \
do { \
vTaskSuspendAll(); \
printf(format, ## args); \
xTaskResumeAll(); \
} while (0)
#else
#define picoprobe_info(format,...) ((void)0)
#endif
#if false
#define picoprobe_debug(format,args...) printf(format, ## args)
#define picoprobe_debug(format,args...) \
do { \
vTaskSuspendAll(); \
printf(format, ## args); \
xTaskResumeAll(); \
} while (0)
#else
#define picoprobe_debug(format,...) ((void)0)
#endif
#if false
#define picoprobe_dump(format,args...) printf(format, ## args)
#define picoprobe_dump(format,args...)\
do { \
vTaskSuspendAll(); \
printf(format, ## args); \
xTaskResumeAll(); \
} while (0)
#else
#define picoprobe_dump(format,...) ((void)0)
#endif
// TODO tie this up with PICO_BOARD defines in the main SDK
#ifndef DEBUGPROBE
#include "board_pico_config.h"
//#include "board_debugprobe_config.h"
#else
#include "board_debugprobe_config.h"
#endif
//#include "board_example_config.h"

View File

@@ -76,6 +76,15 @@ void probe_assert_reset(bool state)
#endif
}
int probe_reset_level(void)
{
#if defined(PROBE_PIN_RESET)
return gpio_get(PROBE_PIN_RESET);
#else
return 0;
#endif
}
typedef enum probe_pio_command {
CMD_WRITE = 0,
CMD_SKIP,
@@ -157,8 +166,8 @@ void probe_init() {
void probe_deinit(void)
{
probe_read_mode();
if (probe.initted) {
probe_read_mode();
pio_sm_set_enabled(pio0, PROBE_SM, 0);
pio_remove_program(pio0, &probe_program, probe.offset);
probe.initted = 0;

View File

@@ -46,5 +46,7 @@ void probe_write_mode(void);
void probe_init(void);
void probe_deinit(void);
void probe_assert_reset(bool state);
int probe_reset_level(void);
#endif

View File

@@ -48,7 +48,7 @@ tusb_desc_device_t const desc_device =
.idVendor = 0x2E8A, // Pi
.idProduct = 0x000c, // CMSIS-DAP Debug Probe
.bcdDevice = 0x0101, // Version 01.01
.bcdDevice = 0x0103, // Version 01.03
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
@@ -99,7 +99,7 @@ uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
uint8_t const desc_configuration[] =
{
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0, 100),
// Interface 0
#if (PICOPROBE_DEBUG_PROTOCOL == PROTO_DAP_V1)
// HID (named interface)