Skip to content

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Apr 7, 2023

Contribution description

This PR fixes the EP data sizes for the bulk endpoints of USB HS peripherals and the buffer alignment required in DMA mode.

The fixes are required to get USBUS MSC working with USB HS peripherals.

Testing procedure

The test requires PR #19459.

Connect a SPI SD Card interface with a STM32 board with USB HS port and HS PHY and use tests/usbus_msc to test, for example:

USEMODULE='sdcard_spi mtd_sdcard_default periph_usbdev_hs_ulpi' \
CFLAGS='-DSDCARD_SPI_PARAM_CLK=GPIO_PIN\(PORT_I,1\) -DSDCARD_SPI_PARAM_MISO=GPIO_PIN\(PORT_B,14\) -DSDCARD_SPI_PARAM_MOSI=GPIO_PIN\(PORT_B,15\) -DSDCARD_SPI_PARAM_CS=GPIO_PIN\(PORT_A,8\)' \
BOARD=stm32f746g-disco make -j8 -C tests/usbus_msc flash

SD card should work with this PR.

Issues/PRs references

@github-actions github-actions bot added Area: sys Area: System Area: USB Area: Universal Serial Bus labels Apr 7, 2023
@gschorcht gschorcht added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 7, 2023
@riot-ci
Copy link

riot-ci commented Apr 7, 2023

Murdock results

✔️ PASSED

44e9db8 sys/usbus/msc: fix EP sizes and buffer alignment for HS in DMA-mode

Success Failures Total Runtime
6882 0 6882 09m:36s

Artifacts

@dylad dylad added the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Apr 7, 2023
@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 7, 2023

Hm, xtensa-esp32s3-elf doesn't know posix_memalign.

@gschorcht gschorcht force-pushed the sys/usbus/fix_msc_ep_buffers branch from f433fb3 to 6ae3d50 Compare April 7, 2023 13:59
@gschorcht gschorcht force-pushed the sys/usbus/fix_msc_ep_buffers branch from 6ae3d50 to 44e9db8 Compare April 7, 2023 17:07
Copy link
Member

@dylad dylad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.
Tested alongside with #19459 and #19443 on stm32f429i-disco
MSC is now working as expected.
Thanks for these patches !

@dylad
Copy link
Member

dylad commented Apr 7, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Apr 7, 2023

Build succeeded:

@bors bors bot merged commit ec4f2ea into RIOT-OS:master Apr 7, 2023
@gschorcht gschorcht deleted the sys/usbus/fix_msc_ep_buffers branch April 11, 2023 10:20
bors bot added a commit that referenced this pull request Apr 11, 2023
19459: drivers/usbus_synopsys_dwc2: fix interrupt handling in DMA mode r=dylad a=gschorcht

### Contribution description

This PR fixes the interrupt handling for IN endpoints in DMA mode.

In DMA mode, both the `XFRC` (Transfer Complete) interrupt and the `TXFE` (TX FIFO Empty) interrupt for IN EP1 ... EPn were used to generate the `USBDEV_EVENT_TR_COMPLETE`. This led to problems with USBUS MSC. With this fix, the `TXFE` interrupt is used only in non-DMA mode or only for IN EP0 in DMA mode while the `XFRC` (Transfer Complete) is used only in DMA mode for IN EP1 ... EPn.

### Testing procedure

This PR should work together with PR #19458 for SD Card interface for a board with USB HS port, for example:
```
USEMODULE='sdcard_spi mtd_sdcard_default periph_usbdev_hs_ulpi' \
CFLAGS='-DSDCARD_SPI_PARAM_CLK=GPIO_PIN\(PORT_I,1\) -DSDCARD_SPI_PARAM_MISO=GPIO_PIN\(PORT_B,14\) -DSDCARD_SPI_PARAM_MOSI=GPIO_PIN\(PORT_B,15\) -DSDCARD_SPI_PARAM_CS=GPIO_PIN\(PORT_A,8\)' \
BOARD=stm32f746g-disco make -j8 -C tests/usbus_msc flash
```
It should still work for CDC ECM for such a board:
```
USEMODULE='periph_usbdev_hs_ulpi stdio_cdc_acm' BOARD=stm32f746g-disco make -j8 -C tests/usbus_cdc_ecm flash
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
bors bot added a commit that referenced this pull request Apr 17, 2023
19472: drivers/usbus_synopsys_dwc2: fix interrupt handling in DMA mode [backport 2023.04] r=dylad a=MrKevinWeiss

# Backport of #19459

### Contribution description

This PR fixes the interrupt handling for IN endpoints in DMA mode.

In DMA mode, both the `XFRC` (Transfer Complete) interrupt and the `TXFE` (TX FIFO Empty) interrupt for IN EP1 ... EPn were used to generate the `USBDEV_EVENT_TR_COMPLETE`. This led to problems with USBUS MSC. With this fix, the `TXFE` interrupt is used only in non-DMA mode or only for IN EP0 in DMA mode while the `XFRC` (Transfer Complete) is used only in DMA mode for IN EP1 ... EPn.

### Testing procedure

This PR should work together with PR #19458 for SD Card interface for a board with USB HS port, for example:
```
USEMODULE='sdcard_spi mtd_sdcard_default periph_usbdev_hs_ulpi' \
CFLAGS='-DSDCARD_SPI_PARAM_CLK=GPIO_PIN\(PORT_I,1\) -DSDCARD_SPI_PARAM_MISO=GPIO_PIN\(PORT_B,14\) -DSDCARD_SPI_PARAM_MOSI=GPIO_PIN\(PORT_B,15\) -DSDCARD_SPI_PARAM_CS=GPIO_PIN\(PORT_A,8\)' \
BOARD=stm32f746g-disco make -j8 -C tests/usbus_msc flash
```
It should still work for CDC ECM for such a board:
```
USEMODULE='periph_usbdev_hs_ulpi stdio_cdc_acm' BOARD=stm32f746g-disco make -j8 -C tests/usbus_cdc_ecm flash
```

### Issues/PRs references


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System Area: USB Area: Universal Serial Bus CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants