Description
Hi everybody,
Failure description:
Usb stop receiving if the cable is disconnected and reconnected to the host and the Arduino is powered also from another source, and then when the USB cable is disconnected the board is not resetted.
Setup description:
- Win7 PC with Arduino IDE 1.8.5 and SAMD package 1.6.19.
- Terminal Application installed on the PC.
- Arduino Zero board with both Native USB and Programming USB connected to the PC.
The programming port is used by the Arduino IDE and the native USB by the
Terminal application.
4)The TestUsbZero.ino sketch is used to reproduce the failure:
// TestUSBZero.ino
uint32_t Millis;
uint32_t Time;
uint16_t Count;
void setup()
{
SerialUSB.begin(0);
Serial.begin(9600);
Time = millis();
Count = 0;
}
//---------------------------------------------------------------------------------------------------------
void loop()
{
Millis = millis(); // every second print out some USB registers
if (Millis - Time >= 1000)
{
Time = Millis;
Serial.print("\nEP_2 EPCFG "); Serial.print(USB->DEVICE.DeviceEndpoint[2].EPCFG.reg, HEX);
Serial.print("\nEP_2 INTSET "); Serial.print(USB->DEVICE.DeviceEndpoint[2].EPINTENSET.reg, HEX);
Serial.print("\nEP_1 EPCFG "); Serial.print(USB->DEVICE.DeviceEndpoint[1].EPCFG.reg, HEX);
Serial.print("\nEP_1 INTSET "); Serial.print(USB->DEVICE.DeviceEndpoint[1].EPINTENSET.reg, HEX);
Serial.print("\n---------------------------------------");
SerialUSB.print("String from native USB "); // and test native USB transmission
SerialUSB.println(Count++);
}
while (SerialUSB.available() > 0) // test native USB reception
{ //
uint8_t RxChar = SerialUSB.read(); //
Serial.write(RxChar); //
} //
}
Procedure description:
-
Connect the Arduino programming port and the native USB to the PC.
-
Run the Arduino Ide and load the TestUsbZero.ino.
-
Set the board to Arduino/Genuino/Zero(programming port) and the port to the COM that matches the programming port.
-
Compile and download the sketch.
-
Open the Arduino monitor.
-
Run the Terminal application and open in it the COM that matches the native USB.
In the Terminal application the test strings sent by the native USB are printed OUT.
In the Arduino monitor some key USB registers are printed out.
If we type something in the Terminal this is received by the native USB and printed out in the Arduino
monitor.Everything is correct.
-
Close the port in the Terminal application to prevent it to hang.
-
Disconnect and reconnect the native USB cable and reopen the matching COM in the Terminal
application.In the Terminal application the test strings sent by the native USB are printed OUT.
In the Arduino monitor some key USB registers are printed out.If we type something in the Terminal this is no more received by the native USB.
Failure analysis:
This behaviour is consistent with the content of the USB registers that are monitored, as the Bulk
Endpoint Out is no more enabled.
I have tracked down this behaviour to the following patch:
Don't reallocate USB buffers if already allocated
Disabling it prevent the failure to show up.
I am not enougth expert in USB and C++ to suggest a safe and clean patch to this issue.
Please can somebody find a solution?
Marco