Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hathach/tinyusb into rx_fb
Browse files Browse the repository at this point in the history
  • Loading branch information
HiFiPhile committed Apr 1, 2024
2 parents b20640a + 82dfe95 commit b98ffac
Show file tree
Hide file tree
Showing 62 changed files with 2,109 additions and 2,144 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/build_esp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Upload Artifacts for Hardware Testing
if: matrix.board == 'espressif_s3_devkitc' && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.board }}
path: |
Expand Down Expand Up @@ -86,19 +86,25 @@ jobs:
# USB bus on rpi4 is not stable, reset it before testing
- name: Reset USB bus
run: |
for port in $(lspci | grep USB | cut -d' ' -f1); do
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
sleep 0.1;
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
done
lsusb
lsusb -t
# reset VIA Labs 2.0 hub
sudo usbreset 001/002
# legacy code
#for port in $(lspci | grep USB | cut -d' ' -f1); do
# echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
# sleep 0.1;
# echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
#done
- name: Checkout test/hil
uses: actions/checkout@v4
with:
sparse-checkout: test/hil

- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.board }}
path: cmake-build/cmake-build-${{ matrix.board }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
language: c++
fuzz-seconds: 600
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/cmake_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ jobs:

- name: Upload Artifacts for Hardware Testing (rp2040)
if: matrix.family == 'rp2040' && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: raspberry_pi_pico
path: |
cmake-build/cmake-build-raspberry_pi_pico/*/*/*.elf
- name: Upload Artifacts for Hardware Testing (nRF)
if: matrix.family == 'nrf' && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: feather_nrf52840_express
path: |
cmake-build/cmake-build-feather_nrf52840_express/*/*/*.elf
- name: Upload Artifacts for Hardware Testing (samd51)
if: matrix.family == 'samd51' && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: itsybitsy_m4
path: |
Expand Down Expand Up @@ -141,19 +141,25 @@ jobs:
# USB bus on rpi4 is not stable, reset it before testing
- name: Reset USB bus
run: |
for port in $(lspci | grep USB | cut -d' ' -f1); do
echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
sleep 0.1;
echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
done
lsusb
lsusb -t
# reset VIA Labs 2.0 hub
sudo usbreset 001/002
# legacy code
#for port in $(lspci | grep USB | cut -d' ' -f1); do
# echo -n "0000:${port}"| sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind;
# sleep 0.1;
# echo -n "0000:${port}" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind;
#done
- name: Checkout test/hil
uses: actions/checkout@v4
with:
sparse-checkout: test/hil

- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.board }}
path: cmake-build/cmake-build-${{ matrix.board }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
category: "/language:${{matrix.language}}"

- name: Archive CodeQL results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Labeler

on:
issues:
types: [opened]
pull_request:
types: [opened]

jobs:
label-priority:
runs-on: ubuntu-latest

steps:
- name: Label New Issue or PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let label = '';
let username = '';
let issueOrPrNumber = 0;
if (context.eventName === 'issues') {
username = context.payload.issue.user.login;
issueOrPrNumber = context.payload.issue.number;
} else if (context.eventName === 'pull_request') {
username = context.payload.pull_request.user.login;
issueOrPrNumber = context.payload.pull_request.number;
}
// Check for Adafruit membership
const adafruitResponse = await github.rest.orgs.checkMembershipForUser({
org: 'adafruit',
username: username
});
if (adafruitResponse.status === 204) {
console.log('Adafruit Member');
label = 'Prio Urgent';
} else {
// Check if the user is a contributor
const collaboratorResponse = await github.rest.repos.checkCollaborator({
owner: context.repo.owner,
repo: context.repo.repo,
username: username
});
if (collaboratorResponse.status === 204) {
console.log('Contributor');
label = 'Prio Higher';
} else {
console.log('Not a contributor or Adafruit member');
}
}
if (label !== '') {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueOrPrNumber,
labels: [label]
});
}
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/runConfigurations/stlink.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 36 additions & 11 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,69 @@ Reference

.. figure:: ../assets/stack.svg
:width: 1600px
:alt: stackup
:alt: TinyUSB

::

.
├── docs # Documentation
├── examples # Examples with make and cmake build system
├── hw
│ ├── bsp # Supported boards source files
│ └── mcu # Low level mcu core & peripheral drivers
├── lib # Sources from 3rd party such as freeRTOS, fatfs ...
├── src # All sources files for TinyUSB stack itself.
├── test # Tests: unit test, fuzzing, hardware test
└── tools # Files used internally

representation of the TinyUSB stack.

Device Stack
============

Supports multiple device configurations by dynamically changing usb descriptors. Low power functions such like suspend, resume, and remote wakeup. Following device classes are supported:
Supports multiple device configurations by dynamically changing USB descriptors, low power functions such like suspend, resume, and remote wakeup. The following device classes are supported:

- Audio Class 2.0 (UAC2)
- Bluetooth Host Controller Interface (BTH HCI)
- Communication Class (CDC)
- Device Firmware Update (DFU): DFU mode (WIP) and Runtinme
- Communication Device Class (CDC)
- Device Firmware Update (DFU): DFU mode (WIP) and Runtime
- Human Interface Device (HID): Generic (In & Out), Keyboard, Mouse, Gamepad etc ...
- Mass Storage Class (MSC): with multiple LUNs
- Musical Instrument Digital Interface (MIDI)
- Network with RNDIS, CDC-ECM (work in progress)
- USB Test and Measurement Class (USBTMC)
- Network with RNDIS, Ethernet Control Model (ECM), Network Control Model (NCM)
- Test and Measurement Class (USBTMC)
- Video class 1.5 (UVC): work in progress
- Vendor-specific class support with generic In & Out endpoints. Can be used with MS OS 2.0 compatible descriptor to load winUSB driver without INF file.
- `WebUSB <https://github.com/WICG/webusb>`__ with vendor-specific class

If you have special need, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how RPi team add their reset interface `raspberrypi/pico-sdk#197 <https://github.com/raspberrypi/pico-sdk/pull/197>`__
If you have a special requirement, `usbd_app_driver_get_cb()` can be used to write your own class driver without modifying the stack. Here is how the RPi team added their reset interface `raspberrypi/pico-sdk#197 <https://github.com/raspberrypi/pico-sdk/pull/197>`_

Host Stack
==========

- Human Interface Device (HID): Keyboard, Mouse, Generic
- Mass Storage Class (MSC)
- Hub currently only supports 1 level of hub (due to my laziness)
- Communication Device Class: CDC-ACM
- Vendor serial over USB: FTDI, CP210x
- Hub with multiple-level support

Similar to the Device Stack, if you have a special requirement, `usbh_app_driver_get_cb()` can be used to write your own class driver without modifying the stack.

TypeC PD Stack
==============

- Power Delivery 3.0 (PD3.0) with USB Type-C support (WIP)
- Super early stage, only for testing purpose
- Only support STM32 G4

OS Abstraction layer
====================

TinyUSB is completely thread-safe by pushing all ISR events into a central queue, then process it later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as CDC FIFO. Therefore the stack needs to use some of OS's basic APIs. Following OSes are already supported out of the box.
TinyUSB is completely thread-safe by pushing all Interrupt Service Request (ISR) events into a central queue, then processing them later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as Communication Device Class (CDC) FIFO. Therefore the stack needs to use some of the OS's basic APIs. Following OSes are already supported out of the box.

- **No OS**
- **FreeRTOS**
- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its `own repo <https://github.com/hathach/mynewt-tinyusb-example>`__
- `RT-Thread <https://github.com/RT-Thread/rt-thread>`_: `repo <https://github.com/RT-Thread-packages/tinyusb>`_
- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its `own repo <https://github.com/hathach/mynewt-tinyusb-example>`_

License
=======
Expand Down
12 changes: 9 additions & 3 deletions examples/build_system/cmake/toolchain/arm_gcc.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
set(CMAKE_SYSTEM_NAME Generic)

set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
if (NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
endif ()

if (NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
endif ()

set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})

set(CMAKE_SIZE "arm-none-eabi-size" CACHE FILEPATH "")
set(CMAKE_OBJCOPY "arm-none-eabi-objcopy" CACHE FILEPATH "")
Expand Down
4 changes: 3 additions & 1 deletion examples/build_system/make/toolchain/arm_gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ LDFLAGS += -Wl,--print-memory-usage
endif

# from version 12
ifeq ($(shell expr $(CC_VERSION_MAJOR) \>= 12),1)
ifeq ($(strip $(if $(CMDEXE),\
$(shell if $(CC_VERSION_MAJOR) geq 12 (echo 1) else (echo 0)),\
$(shell expr $(CC_VERSION_MAJOR) \>= 12))), 1)
LDFLAGS += -Wl,--no-warn-rwx-segment
endif
Loading

0 comments on commit b98ffac

Please sign in to comment.