-
Notifications
You must be signed in to change notification settings - Fork 937
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
Add support for resetting RP2040 via the USB connection when using pi… #197
Conversation
…co_stdio_usb - setting baud rate to magic value (default=1200) will cause a reset to BOOTSEL mode - a VENDOR interface along side the CDC interface can be used to reset via refular flash boot, or into BOOTSEL mode with control for the reset_usb_boot parameters for the latter either method can be configured/enabled/disabled via #define
329ec28
to
ed45e8a
Compare
fixes #112 |
#define PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE 1200 | ||
#endif | ||
|
||
// PICO_CONFIG: PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE, Enable/disable resetting into BOOTSEL mode via an additional VENDOR USB interface - enables picotool based reset, type=bool, default=1, group=pico_stdio_usb |
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.
PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE
here should be PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
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.
(this was fixed in #206 )
Looks good. I didn't realise you could implement your own vendor driver like that! |
|
||
// PICO_CONFIG: PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS, delays in ms before rebooting via regular flash boot, default=100, group=pico_stdio_usb | ||
#ifndef PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS | ||
#define PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS 100 |
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.
Just out of curiosity, why would somebody ever need/want to change this?
(especially given that there's no similar "reset delay" for RESET_TO_BOOTSEL
)
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.
the probably don't, but no harm in creating a define since I picked an arbitrary value
if (request->wValue & 0x100) { | ||
gpio_mask = 1u << (request->wValue >> 9u); | ||
} | ||
reset_usb_boot(gpio_mask, request->wValue & 0x7f); |
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.
Does there need to be some comments about what request->wValue
can be set to, or will that be covered by the picotool source-code?
Is there a related change to picotool that make use of this vendor interface? Or some other simple test script? |
I didn't either until I found out the default one forced you to use endpoints (also this way pulls in much less code) |
not public yet; i tested it locally within picotool, so i could release this, but the picotool changes will come soon separately |
The big question with this is now: How can the actual application (i.e. what I as a user of the SDK write) implement custom class drivers in my application? It looks like the pico SDK is using this feature of tiny-usb for internal purposes? |
…co_stdio_usb
either method can be configured/enabled/disabled via #define