Skip to content

Commit cb5670d

Browse files
Merge pull request #365 from Dzarda7/chore/fix_msc_terminology
Fix MSC terminology and add Markdown formatter (IEC-469)
2 parents 6e3106f + a520148 commit cb5670d

45 files changed

Lines changed: 346 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE/new_component.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
- [ ] CI passing
1111

1212
# Change description
13+
1314
_Please describe your change here_

.github/PULL_REQUEST_TEMPLATE/update_component.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
- [ ] CI passing
77

88
# Change description
9+
910
_Please describe your change here_

.pre-commit-config.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,29 @@ repos:
3131
exclude: '.*\.uxf'
3232
- id: check-yaml
3333

34-
- repo: https://github.com/espressif/esp-idf-kconfig.git
35-
rev: v2.5.0
36-
hooks:
37-
- id: check-kconfig-files
38-
- id: check-deprecated-kconfig-options
34+
- repo: https://github.com/espressif/esp-idf-kconfig.git
35+
rev: v2.5.0
36+
hooks:
37+
- id: check-kconfig-files
38+
- id: check-deprecated-kconfig-options
3939

40-
- repo: local
41-
hooks:
42-
- id: cmake-lint
40+
- repo: https://github.com/executablebooks/mdformat
41+
rev: 0.7.22
42+
hooks:
43+
- id: mdformat
44+
exclude: 'CHANGELOG\.md$'
45+
args: [--number]
46+
additional_dependencies:
47+
- mdformat-gfm # GitHub Flavored Markdown support
48+
- mdformat-ruff # Python code block formatting
49+
50+
- repo: local
51+
hooks:
52+
- id: cmake-lint
4353
name: Check CMake Files Format
4454
entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
4555
language: python
4656
additional_dependencies:
47-
- cmakelint==1.4.1
57+
- cmakelint==1.4.1
4858
files: 'CMakeLists.txt$|\.cmake$'
4959
exclude: '\/third_party\/'

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
2-
[![Build and Run Test Application](https://github.com/espressif/esp-usb/actions/workflows/build_and_run_test_app_usb.yml/badge.svg?branch=master)](https://github.com/espressif/esp-usb/actions/workflows/build_and_run_test_app_usb.yml)
3-
[![Clang-Tidy](https://github.com/espressif/esp-usb/actions/workflows/clang-tidy.yml/badge.svg?branch=master)](https://github.com/espressif/esp-usb/security/code-scanning?query=is%3Aopen+branch%3Amaster)
1+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![Build and Run Test Application](https://github.com/espressif/esp-usb/actions/workflows/build_and_run_test_app_usb.yml/badge.svg?branch=master)](https://github.com/espressif/esp-usb/actions/workflows/build_and_run_test_app_usb.yml) [![Clang-Tidy](https://github.com/espressif/esp-usb/actions/workflows/clang-tidy.yml/badge.svg?branch=master)](https://github.com/espressif/esp-usb/security/code-scanning?query=is%3Aopen+branch%3Amaster)
42

53
# Espressif ESP-USB
64

7-
This repository aims to store [ESP-IDF](https://github.com/espressif/esp-idf) USB host and device class drivers
8-
which have been separated and uploaded into [IDF Component Manager](https://components.espressif.com/).
5+
This repository aims to store [ESP-IDF](https://github.com/espressif/esp-idf) USB host and device class drivers which have been separated and uploaded into [IDF Component Manager](https://components.espressif.com/).
96

107
## Important note
8+
119
This repository is used only for Espressif components, it is not mean to store third party components.
1210

1311
## Resources

device/esp_tinyusb/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ menu "TinyUSB Stack"
8888
Name of the MSC device.
8989
endmenu # "Descriptor configuration"
9090

91-
menu "Massive Storage Class (MSC)"
91+
menu "Mass Storage Class (MSC)"
9292
config TINYUSB_MSC_ENABLED
9393
bool "Enable TinyUSB MSC feature"
9494
default n
@@ -111,7 +111,7 @@ menu "TinyUSB Stack"
111111
default "/data"
112112
help
113113
MSC Mount Path of storage.
114-
endmenu # "Massive Storage Class"
114+
endmenu # "Mass Storage Class"
115115

116116
menu "Communication Device Class (CDC)"
117117
config TINYUSB_CDC_ENABLED

device/esp_tinyusb/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ Configure the Device Stack using `menuconfig`:
4242

4343
This component is distributed via [IDF component manager](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html). Just add `idf_component.yml` file to your main component with the following content:
4444

45-
``` yaml
45+
```yaml
4646
## IDF Component Manager Manifest File
4747
dependencies:
4848
esp_tinyusb: "~2.0.0"
4949
```
5050
5151
Or simply run:
52+
5253
```
5354
idf.py add-dependency esp_tinyusb~2.0.0
5455
```
@@ -187,8 +188,7 @@ Configure USB descriptors using the `tinyusb_config_t` structure:
187188
- `descriptor.high_speed_config`
188189
- `descriptor.qualifier`
189190
190-
If any descriptor field is set to `NULL`, default descriptor will be assigned during installation.
191-
Values of default descriptors could be configured via `menuconfig`.
191+
If any descriptor field is set to `NULL`, default descriptor will be assigned during installation. Values of default descriptors could be configured via `menuconfig`.
192192
193193
```c
194194
#include "tinyusb_default_config.h"
@@ -226,6 +226,7 @@ For self-powered devices, monitoring the VBUS voltage is required. To do this:
226226
tinyusb_driver_install(&tusb_cfg);
227227
}
228228
```
229+
229230
If external PHY is used:
230231
231232
```c
@@ -369,10 +370,10 @@ void main(void)
369370
}
370371
```
371372

372-
373373
**Storage callback**
374374

375375
Storage event callback is called, when one of the following events occurred:
376+
376377
- `TINYUSB_MSC_EVENT_MOUNT_START`: Start mount from APP to USB or from USB to APP
377378
- `TINYUSB_MSC_EVENT_MOUNT_COMPLETE`: Complete mount from USB to APP or from APP to USB
378379
- `TINYUSB_MSC_EVENT_FORMAT_REQUIRED`: Filesystem not found, format needed
@@ -437,26 +438,27 @@ void main(void)
437438
**Performance Table (ESP32-S3):**
438439

439440
| FIFO Size | Read Speed | Write Speed |
440-
|-----------|------------|-------------|
441+
| --------- | ---------- | ----------- |
441442
| 512 B | 0.566 MB/s | 0.236 MB/s |
442443
| 8192 B | 0.925 MB/s | 0.928 MB/s |
443444

444445
**Performance Table (ESP32-P4):**
445446

446447
| FIFO Size | Read Speed | Write Speed |
447-
|-----------|------------|-------------|
448+
| --------- | ---------- | ----------- |
448449
| 512 B | 1.174 MB/s | 0.238 MB/s |
449450
| 8192 B | 4.744 MB/s | 2.157 MB/s |
450451
| 32768 B | 5.998 MB/s | 4.485 MB/s |
451452

452453
**Performance Table (ESP32-S2, SPI Flash):**
453454

454455
| FIFO Size | Write Speed |
455-
|-----------|-------------|
456+
| --------- | ----------- |
456457
| 512 B | 5.59 KB/s |
457458
| 8192 B | 21.54 KB/s |
458459

459460
**Note:** Internal SPI flash is for demonstration only; use SD cards or external flash for higher performance.
460461

461462
## Examples
463+
462464
You can find examples in [ESP-IDF on GitHub](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/device).

device/esp_tinyusb/test_apps/README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# CI target runner setup
22

3-
To allow a Docker container, running on a CI target runner, to access USB devices connected to the CI target runner, some modifications must be made.
4-
In our case, it's an `RPI` target runner.
3+
To allow a Docker container, running on a CI target runner, to access USB devices connected to the CI target runner, some modifications must be made. In our case, it's an `RPI` target runner.
54

65
The main idea comes from this response on [stackoverflow](https://stackoverflow.com/a/66427245/19840830). The same approach is also recommended in the official Docker [documentation](https://docs.docker.com/reference/cli/docker/container/run/#device-cgroup-rule)
76

8-
97
### Following changes shall be made on a CI target runner
108

119
- [`UDEV rules`](#udev-rules)
@@ -21,7 +19,7 @@ The main idea comes from this response on [stackoverflow](https://stackoverflow.
2119
- Location: `/etc/udev/rules.d/99-docker-tty.rules`
2220
- `99-docker-tty.rules` file content:
2321

24-
``` sh
22+
```sh
2523
ACTION=="add", SUBSYSTEM=="tty", RUN+="/usr/local/bin/docker_tty.sh 'added' '%E{DEVNAME}' '%M' '%m'"
2624
ACTION=="remove", SUBSYSTEM=="tty", RUN+="/usr/local/bin/docker_tty.sh 'removed' '%E{DEVNAME}' '%M' '%m'"
2725
```
@@ -32,7 +30,7 @@ ACTION=="remove", SUBSYSTEM=="tty", RUN+="/usr/local/bin/docker_tty.sh 'removed'
3230
- Location: `/usr/local/bin/docker_tty.sh`
3331
- `docker_tty.sh` file content:
3432

35-
``` sh
33+
```sh
3634
#!/usr/bin/env bash
3735

3836
# Log the USB event with parameters
@@ -59,7 +57,8 @@ fi
5957
### Making the script executable
6058

6159
Don't forget to make the created script executable:
62-
``` sh
60+
61+
```sh
6362
root@~$ chmod +x /usr/local/bin/docker_tty.sh
6463
```
6564

@@ -82,17 +81,18 @@ USB event: removed /dev/ttyACM1 166 1
8281

8382
### Check Major and Minor numbers of connected devices
8483

85-
Check the Major and Minor numbers assigned by the Linux kernel to devices that you want the Docker container to access.
86-
In our case, we want to access `/dev/ttyUSB0`, `/dev/ttyACM0` and `/dev/ttyACM1`
84+
Check the Major and Minor numbers assigned by the Linux kernel to devices that you want the Docker container to access. In our case, we want to access `/dev/ttyUSB0`, `/dev/ttyACM0` and `/dev/ttyACM1`
8785

8886
`/dev/ttyUSB0`: Major 188, Minor 0
89-
``` sh
87+
88+
```sh
9089
peter@BrnoRPIG007:~ $ ls -l /dev/ttyUSB0
9190
crw-rw-rw- 1 root dialout 188, 0 Nov 12 11:08 /dev/ttyUSB0
9291
```
9392

9493
`/dev/ttyACM0` and `/dev/ttyACM1`: Major 166, Minor 0 (1)
95-
``` sh
94+
95+
```sh
9696
peter@BrnoRPIG007:~ $ ls -l /dev/ttyACM0
9797
crw-rw---- 1 root dialout 166, 0 Nov 13 10:26 /dev/ttyACM0
9898
peter@BrnoRPIG007:~ $ ls -l /dev/ttyACM1
@@ -102,17 +102,19 @@ crw-rw---- 1 root dialout 166, 1 Nov 13 10:26 /dev/ttyACM1
102102
### Run a docker container
103103

104104
Run a Docker container with the following extra options:
105-
``` sh
105+
106+
```sh
106107
docker run --device-cgroup-rule='c 188:* rmw' --device-cgroup-rule='c 166:* rmw' --privileged ..
107108
```
109+
108110
- `--device-cgroup-rule='c 188:* rmw'`: allow access to `ttyUSBx` (Major 188, all Minors)
109111
- `--device-cgroup-rule='c 166:* rmw'`: allow access to `ttyACMx` (Major 166, all Minors)
110112

111113
## GitHub CI target runner setup
112114

113115
To apply these changes to a GitHub target runner a `.yml` file used to run a Docker container for pytest must be modified. The Docker container is then run with the following options:
114116

115-
``` yaml
117+
```yaml
116118
container:
117119
image: python:3.11-bookworm
118120
options: --privileged --device-cgroup-rule="c 188:* rmw" --device-cgroup-rule="c 166:* rmw"
@@ -124,7 +126,7 @@ To apply these changes to a GitLab runner the `config.toml` file located at `/et
124126

125127
According to GitLab's [documentation](https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnersdocker-section) the `[runners.docker]` section of the `config.toml` file should include the `device_cgroup_rules` parameter:
126128

127-
``` toml
129+
```toml
128130
[runners.docker]
129131
...
130132
device_cgroup_rules = ["c 188:* rmw", "c 166:* rmw"]

0 commit comments

Comments
 (0)