newaetech / sonata-rp2040

rp2040 firmware for Sonata
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Investigate most reliable USB power setting #13

Open colinoflynn opened 1 month ago

colinoflynn commented 1 month ago

Currently RP2040 is set to take 100mA (ref: https://github.com/newaetech/sonata-rp2040/blob/main/usb_msc/usb_descriptors.c#L108)

Investigate if something is more reliable here - suggest maybe ~350mA which means FTDI + RP2040 + USB Hub won't go over 500mA (which might cause devices to disable power?).

Could also just set it to 500mA and see if that works better. Perhaps try 500mA first as a alpha/test release?

GregAC commented 1 month ago

I wonder if we could make this configurable via the config options available over the virtual USB drive? Set it to something like 350 by default and then it can be pushed up for those who still have issues.

Can’t we get more than 500 mA? Certainly it’s possible to charge a phone at 1 or 2 A off many standard USB ports nowadays (without needing proper USB C PD).

alex-dewar commented 1 month ago

We could add a config option, but config options are currently volatile and I'm not sure how easy it is to change settings like that via tinyUSB. I assume just deinit + init should work.

RE: power limits, USB2.0 spec does limit things to 500mA, so trying to do more might introduce issues with certain computers.

I can do builds at 350mA and 500mA to see if that fixes things.

colinoflynn commented 1 month ago

AFAIK the 1A/2A with USB-2.0 is mostly for chargers only, USB hosts are unlikely to support it (some special signaling on the USB lines was used, I never really investigated though if it was allowed).

I didn't think hosts actually changed anything about the power management, just that they disabled the port if the total power draw was going to be too high. Also why I was assuming if it was brown-out related was more about voltage drop or something, but it could be some hosts actually do current limiting!

Alex's 350/500mA tests would be good to run... the 500mA test is interesting as I think it could result in computers being unhappy with one leg of an unpowered USB hub requesting so much.

alex-dewar commented 1 month ago

usb_msc_350mA.zip usb_msc_500mA.zip

Here's the two rebuilds, both untested.