raspberrypi / picotool

BSD 3-Clause "New" or "Revised" License
525 stars 86 forks source link

Add stdio_usb reset interface detection for custom VendorID / ProductID setups #83

Open tomas-pecserke opened 1 year ago

tomas-pecserke commented 1 year ago

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:

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.

lurch commented 1 year ago

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

tomas-pecserke commented 1 year ago

@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

lurch commented 1 year ago

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 commented 1 year ago

@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:

tomas-pecserke commented 1 year ago

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.