picotool icon indicating copy to clipboard operation
picotool copied to clipboard

Add stdio_usb reset interface detection for custom VendorID / ProductID setups

Open tomas-pecserke opened this issue 1 year ago • 5 comments

It would be really nice to use picotool with projects using custom VID/PID as well.

With the new Pico SDK 1.5.0 having improved compatibility of stdio_usb with TinyUSB it's easy to implement stdio_usb reset feature with custom USB setup.

With this patch I am able to reboot the Pico running a TinyUSB stack into BOOTSEL mode and upload new firmware automatically.

That been said I still have several issues I'd like some feedback on:

  1. With non-standard VID / PID supported, it would be helpful to add device filters based on (at least) these attributes:
    • Vendor ID - PR #85
    • Product ID - PR #85
    • Serial ID - PR #84
  2. User might want to have the CLI option to enable/disable this feature. :heavy_check_mark: Implemented
  3. UDEV rule based on VENDOR interface and stdio_usb reset interface subclass and protocol might be nice, but the attributes required seem to be very distribution dependent. This prevents definition of reliable rule to apply in all situations. As this is advanced use case anyway, additional step required to allow specific user's device is acceptable. :x: Will not implement

Example use case: I would like to create automated upload cmake target for a Pico project:

# Custom command to upload firmware to Raspberry Pi Pico
add_custom_target(upload_firmware
    COMMAND ${PICOTOOL_EXECUTABLE} load -x ${TARGET_NAME}.uf2 --detect-reset-interface -f
    DEPENDS ${TARGET_NAME}
    COMMENT "Uploading firmware to Raspberry Pi Pico"
)

I also implemented a tiny library that simplyfies the implementation of custom TinyUSB reset interface - pico_tusb_reset_interface.

tomas-pecserke avatar May 24 '23 14:05 tomas-pecserke

Just to "keep the dots connected", #54 is also requesting filtering by Serial ID.

lurch avatar May 24 '23 16:05 lurch

@lurch if you are interested, pls have a look at a companion library implementing the reset interface for custom TinyUSB stack: https://github.com/tomas-pecserke/pico_tusb_reset_interface

tomas-pecserke avatar Jun 05 '23 17:06 tomas-pecserke

I'm not the picotool maintainer (that's @kilograham ), I just try to leave helpful comments for the little problems that I happen to spot :slightly_smiling_face:

lurch avatar Jun 05 '23 17:06 lurch

@lurch if you are interested, pls have a look at a companion library implementing the reset interface for custom TinyUSB stack: https://github.com/tomas-pecserke/pico_tusb_reset_interface

Hmmm, not sure if it's wise to say "picotool supports custom devices with compatible reset interface with use of --detect-reset-interface or -i option.", if this picotool PR hasn't even been merged yet? Probably best to just add a link to this PR for the time being? :thinking:

lurch avatar Jun 05 '23 17:06 lurch

Sorry about that. I did not mean to impose on you. I appreciate any effort you choose to put in. But I'd hate for you to feel pressured or obligated in any way.

Thank you for your input. I find it very helpful. And you are quite correct, I have definitely jumped the gun on this one.

tomas-pecserke avatar Jun 05 '23 17:06 tomas-pecserke