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> |
||
---|---|---|
.cargo | ||
.github | ||
.vscode | ||
boards | ||
bootloaders | ||
core | ||
cpu | ||
dist | ||
doc | ||
drivers | ||
examples | ||
fuzzing | ||
kconfigs | ||
makefiles | ||
pkg | ||
sys | ||
tests | ||
.bandit | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.murdock | ||
.murdock.yml | ||
bors.toml | ||
CITATION.cff | ||
CODE_OF_CONDUCT.md | ||
CODEOWNERS | ||
CODING_CONVENTIONS_C++.md | ||
CODING_CONVENTIONS.md | ||
CONTRIBUTING.md | ||
doc.txt | ||
Kconfig | ||
LICENSE | ||
LOSTANDFOUND.md | ||
MAINTAINING.md | ||
Makefile | ||
Makefile.base | ||
Makefile.dep | ||
Makefile.features | ||
Makefile.include | ||
README.md | ||
release-notes.txt | ||
SECURITY.md | ||
uncrustify-riot.cfg | ||
Vagrantfile |
The friendly Operating System for IoT!
RIOT is a real-time multi-threading operating system that supports a range of devices that are typically found in the Internet of Things (IoT): 8-bit, 16-bit and 32-bit microcontrollers.
RIOT is based on the following design principles: energy-efficiency, real-time capabilities, small memory footprint, modularity, and uniform API access, independent of the underlying hardware (this API offers partial POSIX compliance).
RIOT is developed by an international open source community which is independent of specific vendors (e.g. similarly to the Linux community). RIOT is licensed with LGPLv2.1, a copyleft license which fosters indirect business models around the free open-source software platform provided by RIOT, e.g. it is possible to link closed-source code with the LGPL code.
FEATURES
RIOT provides features including, but not limited to:
- a preemptive, tickless scheduler with priorities
- flexible memory management
- high resolution, long-term timers
- MTD abstraction layer
- File System integration
- support 200+ boards based on AVR, MSP430, ESP8266, ESP32, RISC-V, ARM7 and ARM Cortex-M
- the native port allows to run RIOT as-is on Linux and BSD. Multiple instances of RIOT running on a single machine can also be interconnected via a simple virtual Ethernet bridge or via a simulated IEEE 802.15.4 network (ZEP)
- IPv6
- 6LoWPAN (RFC4944, RFC6282, and RFC6775)
- UDP
- RPL (storing mode, P2P mode)
- CoAP
- OTA updates via SUIT
- MQTT
- USB (device mode)
- Display / Touchscreen support
- CCN-Lite
- LoRaWAN
- UWB
- Bluetooth (BLE) via NimBLE
GETTING RIOT
The most convenient way to get RIOT is to clone it via Git
$ git clone https://github.com/RIOT-OS/RIOT
this will ensure that you get all the newest features and bug fixes with the caveat of an ever changing work environment.
If you prefer things more stable, you can download the source code of one of our quarter annual releases via Github as ZIP file or tarball. You can also checkout a release in a cloned Git repository using
$ git pull --tags
$ git checkout <YYYY.MM>
For more details on our release cycle, check our documentation.
GETTING STARTED
- You want to start the RIOT? Just follow our quickstart guide or try this tutorial. For specific toolchain installation, follow instructions in the getting started page.
- The RIOT API itself can be built from the code using doxygen. The latest version of the documentation is uploaded daily to doc.riot-os.org.
FORUM
Do you have a question, want to discuss a new feature, or just want to present your latest project using RIOT? Come over to our forum and post to your hearts content.
CONTRIBUTE
To contribute something to RIOT, please refer to our contributing document.
MAILING LISTS
- RIOT commits: commits@riot-os.org
- Github notifications: notifications@riot-os.org
LICENSE
- Most of the code developed by the RIOT community is licensed under the GNU Lesser General Public License (LGPL) version 2.1 as published by the Free Software Foundation.
- Some external sources, especially files developed by SICS are published under a separate license.
All code files contain licensing information.
For more information, see the RIOT website: