Commit Graph

22850 Commits (b3dec25ceb0e7636b97d34ceccebc700c2f39c66)

Author SHA1 Message Date
TomoYamanaka b3dec25ceb Renesas : Implement USB Device feature
I implemented USB Device feature for Renesas mbed boards.
The code referenced the following code as a starting point and is implemented it by inheritting USBPhy same as other boards.
(mbed-os\features\unsupported\USBDevice\targets\TARGET_RENESAS)
2019-02-22 10:53:22 -06:00
Filip Jagodzinski 1ec448dbd0 Tests: USB: Add a README for Linux users
Explain how to overcome xHCI limitations in kernels prior to v4.17 and
successfully run USB tests.
2019-02-22 10:53:22 -06:00
bcostm 7354eb2779 STM32F4 USB: enable USB Device in targets.json
tests-usb_device-basic are OK on the following platforms:

NUCLEO_F412ZG
NUCLEO_F413ZH
NUCLEO_F429ZI
NUCLEO_F446ZE
DISCO_F413ZH
DISCO_F469NI
2019-02-22 10:53:22 -06:00
bcostm becb32061d STM32F4 USB: remove useless macro 2019-02-22 10:53:22 -06:00
bcostm 1e807a305e STM32F4 USB: add patch in CubeF4 hal driver 2019-02-22 10:53:22 -06:00
Filip Jagodzinski 7db3a8a34a Tests: USB: DTR fix for Linux hosts
A DTR line is used to signal that the host has configured a terminal and
is ready to transmit and receive data from the USB CDC/Serial device.
When this test suite is run with the use of a Linux host, a workaround has
to be used to overcome some platform specific DTR line behavior.
Every time the serial port file descriptor is opened, the DTR line is
asserted until the terminal attributes are set.
As a consequence, the device receives a premature DTR signal with a
duration of 200-500 us before the correct, long-lasting DTR signal set by
the host-side test script. (tested on the Linux kernel 4.15.0)

The solution is to wait for the first DTR spike, ignore it, and wait for
the correct DTR signal again.
2019-02-22 10:53:21 -06:00
Russ Butler a4a3b3d429 Remove USB disconnect delay from Serial test
Remove the USB disconnect delay since there is no reason this is
needed. Failures which occur without this indicate a device or host
problem.
2019-02-22 10:53:21 -06:00
Russ Butler 930b29dd83 Tests: USB: Increase serial open retries
Double the number of attempts that are made to open a serial port.
This makes tests run more reliably on Windows.
2019-02-22 10:53:21 -06:00
Russ Butler 96154b577a Tests: USB: Remove TX_DELAY_MS from serial test
Remove TX_DELAY_MS and all the places it was called since it is not
needed when DTR flow control is used.
2019-02-22 10:53:21 -06:00
Russ Butler 8f72f314d7 Tests: USB: Use DTR to make Serial tests reliable
Update the serial host test to set DTR low before opening a serial
port. Set DTR high once the serial object is ready. This ensures that
no data is sent by the device until the host is ready.
2019-02-22 10:53:21 -06:00
Filip Jagodzinski 31fe3ee11e Tests: USB: Increas the size of RX CDC test data
This ensures the flow control is tested.
2019-02-22 10:53:21 -06:00
Filip Jagodzinski 53f7cd5561 Tests: USB: Fix Windows USB SN handling 2019-02-22 10:53:21 -06:00
Filip Jagodzinski 3d4d10191c Tests: USB: Update code comments 2019-02-22 10:53:21 -06:00
Filip Jagodzinski edf360d2fc Tests: USB: Use SN generated by the host machine 2019-02-22 10:53:21 -06:00
Filip Jagodzinski fc366291a2 Tests: USB: Correct reconnect delay
Setting to 1 ms to be on the safe side. The USB spec defines this delay
to be at least 200 us.
2019-02-22 10:53:21 -06:00
Filip Jagodzinski 2d4d111445 Tests: USB: Wait before transmitting data to host
Despite having ECHO and ECHOCTL POSIX lflags disabled by default by
pyserial, a delay is needed for host to properly handle data received
from USB serial/CDC device.
With no delay host would echo 0x00-0x31 characters prefixed with '^'.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski dbfd43a098 Tests: USB: Wait before closing host's port
This delay eliminates the possibility of the device detecting the port
being closed when still waiting for data.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski 7b80cb6586 Tests: USB: Add Serial test for line coding change 2019-02-22 10:53:20 -06:00
Filip Jagodzinski bf3aa29e0b Tests: USB: Use the serial number to find device
Use the USB device SN instead of VID & PID to find the device port name
on the host system.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski 07ffcb4269 Tests: USB: Fix USB reconnect tests for Win hosts 2019-02-22 10:53:20 -06:00
Filip Jagodzinski 7a4b36c37f Tests: USB: Add tests for Serial class. 2019-02-22 10:53:20 -06:00
Filip Jagodzinski 3ed7d8139b Tests: USB: Add tests for CDC class. 2019-02-22 10:53:20 -06:00
Russ Butler 468df713fc Ignore disabled Kinetis USB endpoint interrupts
Ignore interrupts on disabled USB endpoints. This prevents handling
interrupts when in the wrong state.

Prior to this patch when running the serial test on a K64F the assert
on line 908 of USBDevice.cpp would sometimes be triggered. This
assert indicates that an endpoint 0 IN interrupt occurred before
the device was ready.

This occurs during the test_cdc_usb_reconnect test when the host sends
a "Set Control Line State" USB request and the device acknowledges it
just before USB is disconnected.
2019-02-22 10:53:20 -06:00
Russ Butler cb6a6dbd20 Fix USB traceback during testing when wrong size
In the pyusb_basic host test check the length of control transfers
before comparing contents for equality.
2019-02-22 10:53:20 -06:00
Russ Butler 130927068c Remove HAL_GetTick from ST USBPhy
Remove the function HAL_GetTick from the ST USBPhy driver. This is no
longer needed as that change has been made on master.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski 1f8bf46f2e Tests: USB: Check ep buffer is released by abort
Validate that endpoint buffer is not used after a transfer has been
aborted.
2019-02-22 10:53:20 -06:00
Filip Jagodzinski 36d4c355a9 Tests: USB: Update endpoint halt test
Wait for a locally created Timer thread to finish before returning.
2019-02-22 10:53:19 -06:00
Filip Jagodzinski c677bf7426 Tests: USB: Decrease the max data size for iso ep
Although the USB spec sets the upper limit on FS isochronous endpoint
payloads to 1023 B, this value is hard to test in practice. Moreover,
not all the targets Mbed OS supports (like NUCLEO_F207ZG) are able to
handle all the endpoints set to max.
2019-02-22 10:53:19 -06:00
Russ Butler 7563a0f03f Update test to restart reads after unstall
After an endpoint is unstalled any pending transfers are terminated.
This patch re-starts any reads that were ongoing.
2019-02-22 10:53:19 -06:00
Filip Jagodzinski 27bd1656b1 Tests: USB: Update ep callbacks
Endpoint callbacks no longer have endpoint as a param. This update was
introduced in #7267.
2019-02-22 10:53:19 -06:00
Filip Jagodzinski c12e2d15f5 Tests: USB: Add data toggle test 2019-02-22 10:53:19 -06:00
Filip Jagodzinski ff8a9b6ae8 Tests: USB: Update endpoint tests
Fix the host script issues present on Windows machines.
Add 0 B payload size to bulk endpoints test.
Update halt and abort tests according to PR comments.
Add an explicit request to start reading on OUT endpoints.
2019-02-22 10:53:19 -06:00
Filip Jagodzinski 62dc95f60a Tests: USB: Generic: Update documentation 2019-02-22 10:53:19 -06:00
Filip Jagodzinski 686126b8ea Tests: USB: Generic: Add basic endpoint tests 2019-02-22 10:53:19 -06:00
Filip Jagodzinski 5a312406c4 USB: EndpointResolver: Add a generic method to get a free endpoint 2019-02-22 10:53:19 -06:00
Russ Butler d08034c9ef Remove OR from ST endpoint activation
When activating an endpoint assign new data rather than ORing
data to it. This ensures that values set from the previous use
do not effect the current configuration.
2019-02-22 10:53:19 -06:00
Russ Butler 6b0e9400b0 Fix ST test failures due to endpoint reconfiguration
Also always use the max endpoint size for SetTxFifo
since re-configuring fifos when endpoints are added or removed
causes tests to fail.
2019-02-22 10:53:18 -06:00
Russ Butler 5fde071509 Implement endpoint_abort for STM32
Make use of the added function HAL_PCD_EP_Abort to implement
endpoint_abort.
2019-02-22 10:53:18 -06:00
Russ Butler 86e1d436e7 Alternate implementation of HAL_PCD_EP_Abort
Update the patch "Create HAL_PCD_EP_Abort" to fix bugs.
This patch adds the low level functions USB_EPStopXfer, USB_EPSetNak,
USB_EPClearNak and the high level function HAL_PCD_EP_Abort so that
transfers can be stopped.

The functions USB_EPSetNak and USB_EPClearNak allow nak to be enabled
or disabled for an endpoint, preventing or allowing further transfers.

The function USB_EPStopXfer stops pending reads and writes started by
USB_EPStartXfer along with clearing and masking any interrupts enabled
by USB_EPStartXfer.

The function HAL_PCD_EP_Abort aborts any transfers on the given
endpoint. When this function completes the transfer interrupt
is guarenteed not to fire for this endpoint. Furthermore, the size
of data transferred during an aborted read can be found by calling
the function HAL_PCD_EP_GetRxCount.

Other notes on this Change:

1.
Prior to this patch the interrupt USB_OTG_DOEPINT_EPDISD was not
handled. When an OUT endpoint was disabled this interrupt occurred
causing the CPU to get stuck repeatedly handling this interrupt. This
is because this interrupt was unmasked but nothing cleared this
interrupt. This patch also adds code to handle and clear this
interrupt to prevent a lockup.

2.
Stopping a transfer on an OUT endpoint requires global nak OUT to
be in effect. Even with this being done, having entries in the rx fifo
prevented an OUT endpoint from being disabled. This behavior is not
mentioned in the Reference Manual.
2019-02-22 10:53:18 -06:00
Russ Butler c4cf19ee3b Revert "Create HAL_PCD_EP_Abort"
Revert the patch "Create HAL_PCD_EP_Abort" in preparation for an
alternate fix.
2019-02-22 10:53:18 -06:00
Russ Butler 0f70912028 Reset data toggle on Kinetis when unstalling
Data toggle must be reset to DATA0 when an endpoint is unstalled.
This patch makes that change.
2019-02-22 10:53:18 -06:00
Russ Butler dbe41c3659 Abort the current USB transfer when stalling
It is undefined behavior if stalling and unstalling clears an ongoing
transfer. Abort any ongoing transfers explicitly when stalling and
unstalling so the behavior is consistent across devices.
2019-02-22 10:53:18 -06:00
Russ Butler c76d80e36e Alternate Kinetis USB stuck sending bug fix
If an IN endpoint is stalled during a transfer then the data being
sent will repeated and flood the USB bus. This patch prevents
endpoints from being stalled in the middle of a transfer by control
requests by keeping USB suspended until the setup phase of the
control request is done.
2019-02-22 10:53:18 -06:00
Russ Butler a75b40a778 Revert "Fix Kinetis bug causing USB to get stuck"
Revert the commit "Fix Kinetis bug causing USB to get stuck sending"
since this change causes stalls to be missed sometimes.
2019-02-22 10:53:18 -06:00
Russ Butler 3657dab5db Update USBMSD to be more consistent with others
Add second constructor and reorder constructor parameters to match
other USB classes. Also remove the ready() function since there
are no calls that can only mbe made from a ready state.
2019-02-22 10:53:18 -06:00
Filip Jagodzinski 79376c6f00 Tests: USB: Add device config files for Zadig
Zadig is a tool used to install generic USB drivers on Windows machines.
These drivers are necessary to run USB device test suite on Windows
hosts.
2019-02-22 10:53:18 -06:00
Russ Butler 799cde0fc3 Remove endpoint parameter from USB callbacks
Remove the endpoint parameter from endpoint callbacks. This
information is redundant because endpoints are known at
construction time because they must be in the configuration
descriptor.
2019-02-22 10:53:18 -06:00
Russ Butler 4284afd297 USBMSD fixes
Make the following fixes:
-deinit in destructor to prevent race conditions
-cancel the reset task before calling it since it may be in progress
-wait for tasks to complete without mutex held
-prevent double connect with _init flag
2019-02-22 10:53:17 -06:00
Russ Butler c08da25aa7 Update USBMSD
Update the USBMSD class for the new API. Add support for passing in
a BlockDevice directly without the need to extend USBMSD.
2019-02-22 10:53:17 -06:00
Russ Butler 33756e2316 Add the PolledQueue implementation of TaskQueue
Add the PolledQueue class which provides a TaskQueue which is run
by calling PolledQueue::process.
2019-02-22 10:53:17 -06:00