If I short an Arduino, will Linux detect that something is wrong and dissable the port? The Mabook will display a warning and dissable the device.

  • It shouldn't be the kernel's responsibility. The kernel only sees IRQs, and a short circuit would not send an IRQ interrupt. The hardware should be capable of protecting from a short circuit (although that is often not true with customer grade hardware, you're likely to lose the USB port). – grochmal Sep 17 '16 at 17:25

Short circuit protection is the role of the hardware in the USB interface. USB 2.0 s7.1.1 says

A USB transceiver is required to withstand a continuous short circuit of D+ and/or D- to VBUS, GND, other data line, or the cable shield at the connector, for a minimum of 24 hours without degradation.

Linux will report a short circuit if the USB transceiver hardware reports that condition to Linux. See source/drivers/usb/core/hub.c:port_event(). In this case Linux avoids sending data to the port for 0.1 to 0.5s in order to give a short-term even time to dissipate and disables the port if the over-current condition persists.

If you are developing USB hardware you might choose to use a USB powered hub (with over-current protection, see the USB attribute wHubCharacteristics) as a sacrificial device to protect your more expensive computer, rather than rely upon your computer's USB transceiver operating within specification. Note that in some USB designs overcurrent protection is implemented using a polyfuse and these have a limited number of triggering events and also can take some time to resume operation, presumably time you'd rather spend swapping in another hub and continuing to develop your device.

When a USB device is inserted Linux checks that the USB configurations proposed don't exceed the rated current for the port (see drivers/usb/core/generic.c:usb_choose_configuration()), but that's for non-error conditions where it can be assumed that devices don't draw more current than requested by their software.

  • Personally, I wouldn't use an expensive device like a MacBook for hardware development. Attach the hardware to a RaspberryPi or similar and SSH from the MacBook to the RPi. If you do let out the blue smole then the financial hit isn't much and you still have your development platform intact. – vk5tu Sep 18 '16 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.