Your reading is correct, that should be exactly how it works now: if you don't instantiate a machine.USBDevice object then soft reset should continue to work exactly the same as previous MicroPython versions with no USB disconnect. If you've got a series of steps where that doesn't seem to be the case, please let me know.So; don't use dynamic USB and there's no pain, no change from previous behaviour, use dynamic USB and you have to live with the consequences.
That seems a fair and equitable compromise to me, how it should be. Having to suffer the pain even if not creating your own USB devices is what I find objectionable.
But my reading of the documentation is that it should be this way already. So is it simply a bug, oversight in implementation, enacting tear-down when it shouldn't ?
For sure, I hope you're able to not just co-exist but find a way to use the dynamic device support.That's correct. Initially I was simply replacing 'tusb_config.h' and 'tusb_port.c' of the port, then creating those and forcing the build to use those rather than the default MicroPython versions.
I can keep doing that but I would like to find some way of being able to co-exist with 'machine.USBDevice' as that gives me the best of both worlds.
I'll think some more and also talk to Damien about the possibility to add some kind of USBDevice.persist(True) function call that keeps USB active over a reset even when a dynamic device is loaded. The contract for the user will have to be "I pinky swear that the same device configuration will come back immediately after reset, and I know that the device will lose any state that the host has previously set". This makes me nervous as the potential for weird and opaque bugs is high. However I can also see it being workable for some device types.
The trade-off is, as always, binary size. That's why we're keen on the drivers being written in Python so you don't have to build a custom MicroPython firmware to compile in a particular USB driver.If MicroPython had some way to define built-in devices beyond just a single CDC and optional MSC I wouldn't need to do any of this but I am not in a position to influence changes there.
FWIW, if you're doing a custom build with different USB drivers then it might be most logical to simply turn the dynamic USB device config option off. Most of these latest changes will be irrelevant then. If you do run into any problems beyond updating your patch to apply against the new version then please let me know.Currently I am having to subvert MicroPython to support that and that's become a lot harder to do with dynamic USB support having been added.
Statistics: Posted by projectgus — Fri Mar 22, 2024 3:35 am