1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/stm32
bors[bot] 6f0ac0c092
Merge #19460
19460: cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments r=gschorcht a=dylad

### Contribution description
This PR provides two fixes for the `usbdev_fs` driver:

- Fix endpoints registration
- Fix assignment of toggleable bits in EP_REG(x) registers

These bugs were encountered with the USBUS MSC implementation.

Regarding the endpoints registration:

For the `usbdev_fs` peripheral, IN and OUT endpoints of the same index must have the same type.
For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous.
With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken.
Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP.

and for the second fix:

EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect
This commit fixes all the access to these registers to prevent from modifying these bits when not needed.
Without this patch, the endpoint status (VALID / NACK / STALL) can be erroneously modify because bits are not cleared when assigning the new content to the register and thus make the bits toggle and change values.

### Testing procedure
This can be tested with tests/usbus_msc on any board using this `usbdev_fs` driver.
It is easier to test this PR with #19443 alongside. Then the following would be enough:
`CFLAGS='-DSECTOR_COUNT=64' USEMODULE='mtd_emulated' make -j8 BOARD=p-nucleo-wb55 -C tests/usbus_msc flash`

Otherwise this can also be tested by attaching a SPI<->SDCARD adapter.

### Issues/PRs references
None.

Co-authored-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2023-04-09 16:03:55 +00:00
..
bootloader cpu/stm32: implement reset to bootloader 2020-06-05 18:41:06 +02:00
dist treewide/stm32: Make CLOCK_HS* configurable 2022-11-03 11:37:28 +01:00
include Merge #19397 #19416 #19418 #19419 2023-03-24 08:38:06 +00:00
kconfigs cpu/stm32: Implement GPIO LL IRQ support for STM32F1 2023-03-22 10:40:25 +01:00
ldscripts cpu/{cortexm_common, stm32}: add support for backup RAM 2022-01-21 15:53:18 +01:00
periph Merge #19460 2023-04-09 16:03:55 +00:00
stmclk treewide/stm32: Make CLOCK_HS* configurable 2022-11-03 11:37:28 +01:00
vectors cpu/stm32: Add Kconfig dependency modeling 2021-07-02 15:11:05 +02:00
cpu_common.c cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
cpu_init.c cpu: call early_init() 2023-01-08 22:26:12 +01:00
doc.txt treewide/stm32: Make CLOCK_HS* configurable 2022-11-03 11:37:28 +01:00
Kconfig cpu/stm32/kconfig: rework clock tree 2022-11-03 11:37:33 +01:00
Makefile cpu/stm32: only build bootloader when the module is loaded 2020-09-28 21:07:01 +02:00
Makefile.cmsis pkg: Move versions to dedicated line 2022-09-26 17:45:54 +02:00
Makefile.default cpu: make pm_layered a DEFAULT_MODULE 2021-01-27 13:21:20 +01:00
Makefile.dep cpu/stm32: improvement of USB driver selection 2022-11-03 13:52:01 +01:00
Makefile.features cpu/stm32: Implement GPIO LL IRQ support for STM32F1 2023-03-22 10:40:25 +01:00
Makefile.include cpu/stm32: extend RAM with SRAM4 2022-01-02 15:43:37 +01:00
stm32_info.mk cpu/stm32: add initial support for stm32u5 family 2021-12-23 11:04:41 +01:00
stm32_line.mk cpu/stm32: Add STM32_LINE cases for STM32L1xxx6 2022-03-01 17:20:16 +01:00
stm32_mem_lengths.mk cpu/stm32: fix RAM_LEN for F427, F429, F437, F439 models 2022-11-15 22:29:34 +01:00
stm32_riotboot.mk cpu/stm32: introduce CPU_FAM_SHORT variable 2020-05-26 12:27:12 +02:00
stm32.config cpu/stm32: Add Kconfig dependency modeling 2021-07-02 15:11:05 +02:00