PaulStoffregen / teensy_loader_cli

Command line Teensy Loader
http://www.pjrc.com/teensy/loader_cli.html
331 stars 152 forks source link

Add options --vid=<VID> --pid=<PID> --serial=<SERIAL> for soft reset with libusb #65

Open jcdr opened 3 years ago

jcdr commented 3 years ago

Hello,

I am aware that this is not the first pull request asking for that critical feature absolutely required to remotely update multiples boards connected to the same computer. The VID and PID options allow to control boards with custom USB descriptor. Tested on Debian 11 with 4 Teensy 4.1 board behind a external hub and each with custom USB composite descriptors (ACM + ACM + HID + HID).

The code only touch the soft reset for libusb. If you like the idea, feel free to extend that to other reset and libraries.

Best regards. Jean-Christian

stapelberg commented 3 years ago

Thank you for sending this PR!

I, too, would love to see this merged.

The https://github.com/kinx-project/kint keyboard controller uses the Teensy, but also specifies a custom USB VID/PID.

It would be very convenient to be able to easily soft reset it when programming.

PaulStoffregen commented 3 years ago

I'm reluctant to add a feature which only works on 1 platform.

jcdr commented 3 years ago

I'm reluctant to add a feature which only works on 1 platform.

Thank you very much for your message.

I perfectly understand that, but soft reset is actually only implemented for libusb anyway. I will not try to extend that feature to others platforms outside of what is actually implemented, and without some confidence that the work will be merged at some point. So this narrow the discussion to extend the proposal to hard reset. Please see this first pull request as the potential beginning of the process.

The --vid and --pid proposed patch is not platform dependent, but the default value depend on the hard or soft reset. A way to manage that is to convert opt_vid / opt_pid later and default them to NULL, then to test the opt_vid and opt_pid at the open_usb_device() call from the hard and soft reset. Like: open_usb_device(opt_vid ? strtoul(opt_vid, NULL, 16) : 0x16C0, opt_pid ? strtoul(opt_pid, NULL, 16) : 0x0477, opt_serial); Is that idea a way forward or should that issue be managed in a other way ?

The --serial proposed patch is very platform dependent. I will not be able to test others platform myself, so the only way forward if to find help from enough peoples to test all the platforms. That said, if you at least agree on the architecture of the patch, this will allow others to more easily implement that feature on others platforms.

Will be happy to read more from you.

Best Regards Jean-Christian

jcdr commented 3 years ago

Last commit propose an other way to manage the default hard and soft vid and pid. I think this is cleaner than the proposal in my last message.

RenaKunisaki commented 2 years ago

Was just coming to request that --device be re-added since it's the only way to reprogram a Teensy with a different VID/PID if you can't reach the button. This seems like the same thing.

Unfortunately it seems to fail to actually perform the soft reset. It says "Soft reset performed" but the board doesn't reset. With the older version I had been using, it works.