mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
e51d8285f3
19037: sys/usb, pkg/tinyusb: move USB board reset from highlevel STDIO to CDC ACM r=dylad a=gschorcht ### Contribution description The USB board reset function `usb_board_reset_coding_cb` can be used on any CDC-ACM interface, even if the CDC ACM interface is not used as high-level STDIO. Therefore, this PR provides the following changes: - The call of the board reset function `usb_board_reset_coding_cb` from USBUS stack has been moved from the STDIO CDC ACM implementation to the CDC ACM implementation and is thus a feature of any USBUS CDC ACM interface which does not necessarily have to be used as highlevel STDIO. - The call of the board reset function `usb_board_reset_coding_cb` from tinyUSB stack been moved from module `tinyusb_stdio_cdc_acm` to module `tinyusb_contrib` and is compiled in if the `tinyusb_class_cdc` module is used together the `tinyusb_device` module. Thus, it is now a feature of the tinyUSB CDC ACM interface, which does not necessarily have to be used as highlevel STDIO. - The `usb_board_reset` module defines the `usb_board_reset_in_bootloader` function as a weak symbol to be used when reset in bootloader if no real implementation of this function is compiled in and the `riotboot_reset` module is not used. It only prints an error message that the reset in bootloader is not supported. This is necessary if the module `usb_board_reset` is used to be able to restart the board with an application via a USB CDC ACM interface, but the board's bootloader does not support the reset in bootloader feature. - A test application has been added that either uses the highlevel STDIO `stdio_acm_cdc` or creates a CDC-ACM interface to enable board resets via USB. If the `usbus_dfu` module is used, it also initializes the DFU interface to be able to work together with the `riotboot_dfu` bootloader. ### Testing procedure 1. Use a board with a bootloader that supports the reset in bootloader via USB, but don't use the highlevel STDIO to check that it works with `usbus_cdc_acm`, for example: ```python USEMODULE=stdio_uart BOARD=arduino-mkr1000 make -C tests/usb_board_reset flash ``` After reset in application with command ```python stty -F /dev/ttyACM0 raw ispeed 600 ospeed 600 cs8 -cstopb ignpar eol 255 eof 255 ``` command `dmesg` should give an output like the following with RIOT's test VID/PID: ```python dmesg [1745182.057403] usb 1-4.1.2: new full-speed USB device number 69 using xhci_hcd [1745182.160386] usb 1-4.1.2: New USB device found, idVendor=1209, idProduct=7d01, bcdDevice= 1.00 [1745182.160390] usb 1-4.1.2: New USB device strings: Mfr=3, Product=2, SerialNumber=4 [1745182.160392] usb 1-4.1.2: Product: arduino-mkr1000 [1745182.160393] usb 1-4.1.2: Manufacturer: RIOT-os.org [1745182.160395] usb 1-4.1.2: SerialNumber: 6B6C2CA5229020D8 [1745182.170982] cdc_acm 1-4.1.2:1.0: ttyACM0: USB ACM device ``` After reset in bootloader with command ```python stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255 ``` command `dmesg` should give an output like the following with vendor VID/PID: ```python [1746220.443792] usb 1-4.1.2: new full-speed USB device number 70 using xhci_hcd [1746220.544705] usb 1-4.1.2: New USB device found, idVendor=2341, idProduct=024e, bcdDevice= 2.00 [1746220.544708] usb 1-4.1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [1746220.553471] cdc_acm 1-4.1.2:1.0: ttyACM0: USB ACM device ``` 2. Test the same as in 1., but this time use the highlevel STDIO to check that there is no regression and it still works with `stdio_cdc_acm`, for example: ```python BOARD=arduino-mkr1000 make -C tests/usb_board_reset flash ``` 3. Use a board that supports `riotboot_dfu` but doesn't use the highlevel STDIO and flash the `riotboot_dfu` bootloader, for example: ```python BOARD=stm32f429i-disc1 make -C bootloaders/riotboot_dfu flash term ``` Once the bootloader is flashed, command `dfu-util --list` should give something like the following: ```python Found DFU: [1209:7d02] ver=0100, devnum=14, cfg=1, intf=0, path="1-2", alt=1, name="RIOT-OS Slot 1", serial="6591620BCB270283" Found DFU: [1209:7d02] ver=0100, devnum=14, cfg=1, intf=0, path="1-2", alt=0, name="RIOT-OS Slot 0", serial="6591620BCB270283" ``` If the output gives only ```python Found Runtime: [1209:7d00] ver=0100, devnum=123, cfg=1, intf=0, path="1-2", alt=0, name="RIOT-OS bootloader", serial="6591620BCB270283" ``` an application is already running in DFU Runtime mode. Use `dfu-util -e` to restart it in bootloader DFU mode. Then flash the test application, for example: ```python FEATURES_REQUIRED=riotboot USEMODULE='usbus_dfu riotboot_reset' \ BOARD=stm32f429i-disc1 make -C tests/usbus_board_reset PROGRAMMER=dfu-util riotboot/flash-slot0 ``` Once the test application is flashed, command `dfu-util --list` should give: ```python Found Runtime: [1209:7d00] ver=0100, devnum=123, cfg=1, intf=0, path="1-2", alt=0, name="RIOT-OS bootloader", serial="6591620BCB270283" ``` Now, use command ```python stty -F /dev/ttyACM1 raw ispeed 600 ospeed 600 cs8 -cstopb ignpar eol 255 eof 255 ``` to restart the board in application. Command `dfu-util --list` should give again the following: ```python Found Runtime: [1209:7d00] ver=0100, devnum=123, cfg=1, intf=0, path="1-2", alt=0, name="RIOT-OS bootloader", serial="6591620BCB270283" ``` That is, the application is running in DFU Runtime mode. Then use command ```python stty -F /dev/ttyACM1 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255 ``` to restart the board in bootloader DFU mode. Command `dfu-util --list` should now give the following: ```python Found DFU: [1209:7d02] ver=0100, devnum=50, cfg=1, intf=0, path="1-2", alt=1, name="RIOT-OS Slot 1", serial="7D156425A950A8EB" Found DFU: [1209:7d02] ver=0100, devnum=50, cfg=1, intf=0, path="1-2", alt=0, name="RIOT-OS Slot 0", serial="7D156425A950A8EB" ``` That is, the bootloader is in DFU mode and another application can be flash. 4. After a hard reset of the board under 3., try the commands `reboot` and `bootloader`. 5. To check the same for tinyUSB, use the existing tinyUSB application with a CDC ACM interface and add module `usb_board_reset`, for example: ```python USEMODULE=usb_board_reset BOARD=stm32f429i-disc1 make -C tests/pkg_tinyusb_cdc_msc flash term ``` After flashing, it should be possible to restart the application with command: ```python stty -F /dev/ttyACM1 raw ispeed 600 ospeed 600 cs8 -cstopb ignpar eol 255 eof 255 ``` When using command ```python stty -F /dev/ttyACM1 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255 ``` the following error message should be shown in terminal ```python [cdc-acm] reset in bootloader is not supported ``` ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net> |
||
---|---|---|
.. | ||
acd52832 | ||
adafruit-clue | ||
adafruit-itsybitsy-m4 | ||
adafruit-itsybitsy-nrf52 | ||
adafruit-pybadge | ||
airfy-beacon | ||
alientek-pandora | ||
arduino-due | ||
arduino-duemilanove | ||
arduino-leonardo | ||
arduino-mega2560 | ||
arduino-mkr1000 | ||
arduino-mkrfox1200 | ||
arduino-mkrwan1300 | ||
arduino-mkrzero | ||
arduino-nano | ||
arduino-nano-33-ble | ||
arduino-nano-33-iot | ||
arduino-uno | ||
arduino-zero | ||
atmega256rfr2-xpro | ||
atmega328p | ||
atmega328p-xplained-mini | ||
atmega1284p | ||
atxmega-a1-xplained | ||
atxmega-a1u-xpro | ||
atxmega-a3bu-xplained | ||
avr-rss2 | ||
avsextrem | ||
b-l072z-lrwan1 | ||
b-l475e-iot01a | ||
b-u585i-iot02a | ||
bastwan | ||
blackpill-stm32f103c8 | ||
blackpill-stm32f103cb | ||
bluepill-stm32f030c8 | ||
bluepill-stm32f103c8 | ||
bluepill-stm32f103cb | ||
calliope-mini | ||
cc1312-launchpad | ||
cc1350-launchpad | ||
cc1352-launchpad | ||
cc1352p-launchpad | ||
cc2538dk | ||
cc2650-launchpad | ||
cc2650stk | ||
common | ||
derfmega128 | ||
derfmega256 | ||
dwm1001 | ||
e104-bt5010a-tb | ||
e104-bt5011a-tb | ||
e180-zg120b-tb | ||
ek-lm4f120xl | ||
esp32-ethernet-kit-v1_0 | ||
esp32-ethernet-kit-v1_1 | ||
esp32-ethernet-kit-v1_2 | ||
esp32-heltec-lora32-v2 | ||
esp32-mh-et-live-minikit | ||
esp32-olimex-evb | ||
esp32-ttgo-t-beam | ||
esp32-wemos-lolin-d32-pro | ||
esp32-wroom-32 | ||
esp32-wrover-kit | ||
esp32c3-devkit | ||
esp32s2-devkit | ||
esp32s3-devkit | ||
esp8266-esp-12x | ||
esp8266-olimex-mod | ||
esp8266-sparkfun-thing | ||
f4vi1 | ||
feather-m0 | ||
feather-m0-lora | ||
feather-m0-wifi | ||
feather-nrf52840 | ||
firefly | ||
frdm-k22f | ||
frdm-k64f | ||
frdm-kl43z | ||
frdm-kw41z | ||
hamilton | ||
hifive1 | ||
hifive1b | ||
i-nucleo-lrwan1 | ||
ikea-tradfri | ||
im880b | ||
iotlab-a8-m3 | ||
iotlab-m3 | ||
limifrog-v1 | ||
lobaro-lorabox | ||
lora-e5-dev | ||
lsn50 | ||
maple-mini | ||
mbed_lpc1768 | ||
mcb2388 | ||
mega-xplained | ||
microbit | ||
microbit-v2 | ||
microduino-corerf | ||
msb-430 | ||
msb-430h | ||
msba2 | ||
msbiot | ||
mulle | ||
native | ||
nrf51dk | ||
nrf51dongle | ||
nrf52dk | ||
nrf6310 | ||
nrf9160dk | ||
nrf52832-mdk | ||
nrf52840-mdk | ||
nrf52840-mdk-dongle | ||
nrf52840dk | ||
nrf52840dongle | ||
nucleo-f030r8 | ||
nucleo-f031k6 | ||
nucleo-f042k6 | ||
nucleo-f070rb | ||
nucleo-f072rb | ||
nucleo-f091rc | ||
nucleo-f103rb | ||
nucleo-f207zg | ||
nucleo-f302r8 | ||
nucleo-f303k8 | ||
nucleo-f303re | ||
nucleo-f303ze | ||
nucleo-f334r8 | ||
nucleo-f401re | ||
nucleo-f410rb | ||
nucleo-f411re | ||
nucleo-f412zg | ||
nucleo-f413zh | ||
nucleo-f429zi | ||
nucleo-f439zi | ||
nucleo-f446re | ||
nucleo-f446ze | ||
nucleo-f722ze | ||
nucleo-f746zg | ||
nucleo-f767zi | ||
nucleo-g070rb | ||
nucleo-g071rb | ||
nucleo-g431rb | ||
nucleo-g474re | ||
nucleo-l4r5zi | ||
nucleo-l011k4 | ||
nucleo-l031k6 | ||
nucleo-l053r8 | ||
nucleo-l073rz | ||
nucleo-l152re | ||
nucleo-l412kb | ||
nucleo-l432kc | ||
nucleo-l433rc | ||
nucleo-l452re | ||
nucleo-l476rg | ||
nucleo-l496zg | ||
nucleo-l552ze-q | ||
nucleo-wl55jc | ||
nz32-sc151 | ||
olimexino-stm32 | ||
omote | ||
opencm904 | ||
openlabs-kw41z-mini | ||
openlabs-kw41z-mini-256kib | ||
openmote-b | ||
openmote-cc2538 | ||
p-l496g-cell02 | ||
p-nucleo-wb55 | ||
particle-argon | ||
particle-boron | ||
particle-xenon | ||
pba-d-01-kw2x | ||
phynode-kw41z | ||
pinetime | ||
pyboard | ||
qn9080dk | ||
reel | ||
remote-pa | ||
remote-reva | ||
remote-revb | ||
rpi-pico | ||
ruuvitag | ||
samd10-xmini | ||
samd20-xpro | ||
samd21-xpro | ||
same54-xpro | ||
saml10-xpro | ||
saml11-xpro | ||
saml21-xpro | ||
samr21-xpro | ||
samr30-xpro | ||
samr34-xpro | ||
seeedstudio-gd32 | ||
seeeduino_arch-pro | ||
seeeduino_xiao | ||
sensebox_samd21 | ||
serpente | ||
slstk3400a | ||
slstk3401a | ||
slstk3402a | ||
sltb001a | ||
sltb009a | ||
slwstk6000b-slwrb4150a | ||
slwstk6000b-slwrb4162a | ||
slwstk6220a | ||
sodaq-autonomo | ||
sodaq-explorer | ||
sodaq-one | ||
sodaq-sara-aff | ||
sodaq-sara-sff | ||
spark-core | ||
stk3200 | ||
stk3600 | ||
stk3700 | ||
stm32f0discovery | ||
stm32f3discovery | ||
stm32f4discovery | ||
stm32f030f4-demo | ||
stm32f429i-disc1 | ||
stm32f429i-disco | ||
stm32f469i-disco | ||
stm32f723e-disco | ||
stm32f746g-disco | ||
stm32f769i-disco | ||
stm32f7508-dk | ||
stm32g0316-disco | ||
stm32l476g-disco | ||
stm32l0538-disco | ||
stm32mp157c-dk2 | ||
teensy31 | ||
telosb | ||
thingy52 | ||
ublox-c030-u201 | ||
udoo | ||
usb-kw41z | ||
waspmote-pro | ||
waveshare-nrf52840-eval-kit | ||
weact-f401cc | ||
weact-f401ce | ||
weact-f411ce | ||
wemos-zero | ||
xg23-pk6068a | ||
yarm | ||
yunjia-nrf51822 | ||
z1 | ||
zigduino | ||
doc.txt | ||
Kconfig | ||
README.md |
Platform configurations for RIOT-OS
This directory contains existing configuration and initialization files for platforms supported by RIOT-OS.