Compare commits
10 Commits
pio-progra
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ab8c86465 | ||
|
|
2a6f9911db | ||
|
|
5b6eb3e427 | ||
|
|
6473166494 | ||
|
|
3a1887ff06 | ||
|
|
13b420d34c | ||
|
|
eb494103d4 | ||
|
|
7de418cce3 | ||
|
|
0746b5a844 | ||
|
|
d04ff3b472 |
@@ -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
|
||||
|
||||
30
README.md
30
README.md
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
@@ -52,4 +52,4 @@
|
||||
|
||||
#define PROBE_PRODUCT_STRING "Debug Probe (CMSIS-DAP)"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -99,6 +99,7 @@ int main(void) {
|
||||
tusb_init();
|
||||
|
||||
DAP_Setup();
|
||||
stdio_uart_init();
|
||||
|
||||
led_init();
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
11
src/probe.c
11
src/probe.c
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user