-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support resetting Picoprobe board using USB RESET interface (RP2040) #108
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,13 @@ | |
#include "tusb_edpt_handler.h" | ||
#include "DAP.h" | ||
|
||
#include "usb_reset_interface.h" | ||
#include "pico/bootrom.h" | ||
#include "hardware/watchdog.h" | ||
|
||
|
||
|
||
|
||
// UART0 for Picoprobe debug | ||
// UART1 for picoprobe to target device | ||
|
||
|
@@ -153,6 +160,20 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ | |
// nothing to with DATA & ACK stage | ||
if (stage != CONTROL_STAGE_SETUP) return true; | ||
|
||
#if PICOPROBE_RESET_CAPABLE | ||
if (request->wIndex == 3) { | ||
if (request->bRequest == RESET_REQUEST_BOOTSEL) { | ||
reset_usb_boot(0, (request->wValue & 0x7f) | 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous bitwise OR with zero |
||
return true; | ||
} | ||
if (request->bRequest == RESET_REQUEST_FLASH) { | ||
watchdog_reboot(0, 0, 100); | ||
return true; | ||
} | ||
return false; | ||
} | ||
#endif | ||
|
||
switch (request->bmRequestType_bit.type) | ||
{ | ||
case TUSB_REQ_TYPE_VENDOR: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the reset interface definitions be included with a Cmake library linkage instead of a repeat inclusion of the sdk header? |
||
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef _PICO_USB_RESET_INTERFACE_H | ||
#define _PICO_USB_RESET_INTERFACE_H | ||
|
||
/** \file usb_reset_interface.h | ||
* \defgroup pico_usb_reset_interface pico_usb_reset_interface | ||
* | ||
* Definition for the reset interface that may be exposed by the pico_stdio_usb library | ||
*/ | ||
|
||
// VENDOR sub-class for the reset interface | ||
#define RESET_INTERFACE_SUBCLASS 0x00 | ||
// VENDOR protocol for the reset interface | ||
#define RESET_INTERFACE_PROTOCOL 0x01 | ||
|
||
// CONTROL requests: | ||
|
||
// reset to BOOTSEL | ||
#define RESET_REQUEST_BOOTSEL 0x01 | ||
// regular flash boot | ||
#define RESET_REQUEST_FLASH 0x02 | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer disabled by default. I would guess that for other users the feature would aid remote development of the probe firmware itself, but the vast majority will be doing uf2 drag-and-drop with a Pico or a Debug Probe and a standard release.
So, please move this definition to include/board_example_config.h with a suitable description.