Add support for resetting RP2040 via the USB connection when using pi… #197

Merged
kilograham merged 1 commit from stdio-usb-reset-to-bootsel into develop 2021-03-01 08:36:29 -06:00
kilograham commented 2021-02-27 19:08:56 -06:00 (Migrated from github.com)

…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

…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
Wren6991 (Migrated from github.com) reviewed 2021-02-27 19:08:56 -06:00
kilograham commented 2021-02-27 19:16:39 -06:00 (Migrated from github.com)

fixes #112

fixes #112
lurch (Migrated from github.com) reviewed 2021-02-28 03:45:14 -06:00
@ -45,0 +72,4 @@
// 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
#endif
lurch (Migrated from github.com) commented 2021-02-28 03:45:14 -06:00

PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE here should be PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE

`PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE` here should be `PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE`
liamfraser (Migrated from github.com) approved these changes 2021-03-01 02:58:23 -06:00
liamfraser commented 2021-03-01 02:59:39 -06:00 (Migrated from github.com)

Looks good. I didn't realise you could implement your own vendor driver like that!

Looks good. I didn't realise you could implement your own vendor driver like that!
lurch (Migrated from github.com) reviewed 2021-03-01 03:51:23 -06:00
lurch (Migrated from github.com) commented 2021-03-01 03:51:22 -06:00

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)

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`)
lurch (Migrated from github.com) reviewed 2021-03-01 03:57:42 -06:00
@ -45,0 +64,4 @@
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL 1
#endif
// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT, If vendor reset interface is included allow rebooting with regular flash boot, type=bool, default=1, group=pico_stdio_usb
lurch (Migrated from github.com) commented 2021-03-01 03:57:41 -06:00

Does it definitely make sense to enable-this-by-default, given your comments in #112 about "the OS is understandably not keen on you trying to talk CDC commands directly to a serial device it has claimed"? 🤷‍♂️

Does it definitely make sense to enable-this-by-default, given your comments in #112 about "the OS is understandably not keen on you trying to talk CDC commands directly to a serial device it has claimed"? :man_shrugging:
lurch (Migrated from github.com) reviewed 2021-03-01 04:08:06 -06:00
@ -0,0 +41,4 @@
if (request->wValue & 0x100) {
gpio_mask = 1u << (request->wValue >> 9u);
}
reset_usb_boot(gpio_mask, request->wValue & 0x7f);
lurch (Migrated from github.com) commented 2021-03-01 04:08:06 -06:00

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?

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?
kadamski commented 2021-03-01 04:51:22 -06:00 (Migrated from github.com)

Is there a related change to picotool that make use of this vendor interface? Or some other simple test script?

Is there a related change to picotool that make use of this vendor interface? Or some other simple test script?
kilograham (Migrated from github.com) reviewed 2021-03-01 09:05:21 -06:00
kilograham (Migrated from github.com) commented 2021-03-01 09:05:21 -06:00

the probably don't, but no harm in creating a define since I picked an arbitrary value

the probably don't, but no harm in creating a define since I picked an arbitrary value
kilograham (Migrated from github.com) reviewed 2021-03-01 09:06:08 -06:00
@ -45,0 +64,4 @@
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL 1
#endif
// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT, If vendor reset interface is included allow rebooting with regular flash boot, type=bool, default=1, group=pico_stdio_usb
kilograham (Migrated from github.com) commented 2021-03-01 09:06:08 -06:00

that referred to trying to talk to a CDC device via libusb while the OS has it claime; you can use OS level things to set the baud rate just fne

that referred to trying to talk to a CDC device via libusb while the OS has it claime; you can use OS level things to set the baud rate just fne
kilograham commented 2021-03-01 09:06:34 -06:00 (Migrated from github.com)

Looks good. I didn't realise you could implement your own vendor driver like that!

I didn't either until I found out the default one forced you to use endpoints (also this way pulls in much less code)

> Looks good. I didn't realise you could implement your own vendor driver like that! I didn't either until I found out the default one forced you to use endpoints (also this way pulls in much less code)
kilograham commented 2021-03-01 09:08:02 -06:00 (Migrated from github.com)

Is there a related change to picotool that make use of this vendor interface? Or some other simple test script?

not public yet; i tested it locally within picotool, so i could release this, but the picotool changes will come soon separately

> Is there a related change to picotool that make use of this vendor interface? Or some other simple test script? not public yet; i tested it locally within picotool, so i could release this, but the picotool changes will come soon separately
lurch (Migrated from github.com) reviewed 2021-03-03 06:17:33 -06:00
@ -45,0 +72,4 @@
// 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
#endif
lurch (Migrated from github.com) commented 2021-03-03 06:17:33 -06:00

(this was fixed in #206 )

(this was fixed in #206 )
laf0rge commented 2023-05-18 13:01:52 -05:00 (Migrated from github.com)

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?

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?
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!197
No description provided.