#tinyusb

1 messages ยท Page 8 of 1

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

@wiredopposite The fixes you mention probably helped with plug and unplug when the device is connected to the host directly. When the device is connected through a hub, the first transfer to the hub after a failed IN or OUT transfer to a device disconnected from the hub fails. At around line 297, I printed the return value from usb_in_transaction().

            if (ep->ep_num & EP_IN) {
              int ok = usb_in_transaction(pp, ep);
              if (ok != 0) {
                print...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Describe the PR
Add CMake presets for easier build.

Now examples can be built in one line, such as cmake --workflow --preset stm32c071nucleo or cmake --build --preset stm32c071nucleo -t audio_4_channel_mic-jlink for flashing.

Additional context
IAR now has a dropdown preset menu for quick board switching.

fallow birchBOT
fallow birchBOT
#

@nevvkid Can you please describe where the performance problems from application drivers come from, and what advanced stuff you are doing that suffers when you use application drivers?

As far as I understand it, the USB host code accesses external driver functions using function pointers; same as built-in drivers. External application driver function pointers are stored in an array; built-in driver function pointers are stored in a different array. To get a pointer to the function pointers...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Windows 11

Board

RP2040 (Any Board)

Firmware

N/A

What happened ?

When CFG_TUD_HID_EP_BUFSIZE is set to 64, and a host (Such as Windows) sends a 64 byte packet as an OUTPUT report to the HID endpoint, the data is never received.

How to reproduce ?

As described

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

N/A

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • [x] I confirm I have checked existi...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

When I try to use the tiny usb cdc-acm for input and output (in my case, the esp-idf cli), the I get a task watch dog on the repl task (see stack dump below)
Any ideas what I'm doing wrong?
I took the esp-idf example of tusb console and added the esp-idf console, I can upload the changes I made

PS C:\dev\ESP\tusb_console> xtensa-esp32s3-elf-addr2line -pfiaC -e build/tusb_console.elf 0x42014FAF:0x3FC93CB0 0x420153CC:0x3FC93CD0 0x403770E9:0x3FC93D00 0x400559DD:0x3FC9CC50 0x4037D00E:0x3FC9CC60...

fallow birchBOT
fallow birchBOT
#

thank you for your PR and patient, I was off for TET (Lunar New Year).

Welcome back, and I hope your time off was all that you hoped!

I think we may just cast TOTAL_DRIVER_COUNT to uint8_t instead. To ensure TOTAL_DRIVER_COUNT is less than 255, we can do an TU_ASSERT() in tud_init() so that we only run the check once.

#define TOTAL_DRIVER_COUNT    ((uint8_t) (_app_driver_count + BUILTIN_DRIVER_COUNT))

Could you help me understand the proposed assertion, whi...

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-2923-alt
#

@hathach wow that is incredible news thank you! I would love to see some Arduino examples sketches. Is there an issue at Arduino-ESP32 I can follow to know when your updates get compiled into core?

I haven't paid attention to arduino-esp32 lately, but It is moving fast. My CI HIL pool actually test esp32-p4 host function each PR https://github.com/hathach/tinyusb/blob/master/test/hil/tinyusb.json#L10 same dwc2 as s3 (with different usbip configuration). You ca...

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: rtos-house-keeping
fallow birchBOT
#
[hathach/tinyusb] New branch created: update-iar-cloud-lms
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Thank you very much of your PR. It has been a quite and I really appreciate your effort and patient. I have been wanting to review/merge this but keep getting pulled by other works and kind of forgot sometimes. Adding an new host driver is significant works, and reviewing it may take a bit longer. Though I have sync it up with master, also fix some out of sync naming/signature/make changes. I run the example and it works well (great work).

We will need to migrate the endpoint to use the n...

fallow birchBOT
#

I made more changes to update the driver to use the new endpoint stream API (similar to cdc host). I have only tested with midi_rx example, didn't test with tx at all. I will try to look up what the string doing with midi and continue to make more update, I think we should also need to make some driver API changes as well. Hopefully we could wrap this up and merge this soon enough.

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

look good thank you. In the future, I would hope we could merge this driver to chipidea fullspeed making it easier to maintain driver.

You're welcome. But merging the driver with the general purpose ChipIdea FS driver could be difficult because the 16-bit PICs have a unique BDT layout. The 8-bit PICs could have a third BDT layout.

That is what I hope if we could manage to solve these technical differences, we solve some of them with other usbip. However, I haven't actually run t...

fallow birchBOT
#

@hathach Set CFG_MIDI_HOST_DEVSTRINGS to 1 to process the virtual cable names of the attached device for MIDI IN and MIDI OUT from the MIDI configuration descriptors and the string descriptors during enumeration and to enable the API for applications to read the strings. For example, on my Arturia KeyLab Essential 88 keyboard, virtual cable 0 is labeled "MIDI" and virtual cable 1 is labeled "DAW" for both MIDI IN and MIDI OUT.

fallow birchBOT
#

@hathach Set CFG_MIDI_HOST_DEVSTRINGS to 1 to process the virtual cable names of the attached device for MIDI IN and MIDI OUT from the MIDI configuration descriptors and the string descriptors during enumeration and to enable the API for applications to read the strings. For example, on my Arturia KeyLab Essential 88 keyboard, virtual cable 0 is labeled "MIDI" and virtual cable 1 is labeled "DAW" for both MIDI IN and MIDI OUT.

Thank you for explanation

@hathach I recommend that yo...

fallow birchBOT
fallow birchBOT
#

@hathach Yes, CFG_MIDI_HOST_DEVSTRINGS is for displaying labels for virtual cables. Enabling the setting requires slightly more RAM and code space. Enabling it slows enumeration slightly because the driver needs to parse the Jack Descriptors. The setting does not change run-time behavior after enumeration. Applications with no UI do not need it.

Many MIDI devices do not implement Jack Descriptor strings. Some implement them, but do it poorly. An example RP2040 device that uses Jack Descr...

fallow birchBOT
#

Default is still high speed, but setting
SPEED=high|full work as expected.

make BOARD=same70_xplained SPEED=full

Tested with examples/device/cdc_msc

lsusb -v

...

  TinyUSB Device:

    Product ID: 0x4003
    Vendor ID: 0xcafe
    Version: 1.00
    Serial Number: 0123456789ABCDEF
    Speed: Up to 12 Mb/s   <------ full speed here
    Manufacturer: TinyUSB
    Location ID: 0x03142130 / 12
    Current Available (mA): 500
    Current Required (mA): 100...
fallow birchBOT
#
[hathach/tinyusb] New branch created: enhance-hub
fallow birchBOT
fallow birchBOT
#

Operating System

MacOS

Board

ESP32-s3 devkit

Firmware

Any firmware using ESP32-s3 usb device, I worked on usb audio.

What happened ?

Look like there is a bug in calculation of available FIFO RAM for esp32-s3 (and also for P4 as I can see).

In file dwc2_esp32.h we can find this definition:
static const dwc2_controller_t _dwc2_controller[] = {
{ .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 }
};

...

fallow birchBOT
#

I understand that the topic has already been examined, and that the usage of a common DWC2 driver seems the best to limit effort, but in file dcd_esp32sx.c it's clear that things are different:

- first there is the following:
// FIFO size in bytes
#define EP_FIFO_SIZE 1024

so it's clear that 1024 is in bytes

- then this map:
// "USB Data FIFOs" section in reference manual
// Peripheral FIFO architecture
//
// --------------- 320 or 1024 ( 1280 or 4096 bytes )
// | IN F...

fallow birchBOT
fallow birchBOT
#

OK, thank you , I had seen this ... and it's incoerent with the image in the technical reference ...

Image

Moreover I was examing the fork of Tinyusb by expressif ...
https://github.com/espressif/tinyusb/blob/82a7a644ccbe5a38c725517ca3baf0703f90b2fb/src/portable/espressif/esp32sx/dcd_esp32sx.c

I don't have access to more detailed info, but trying to understand the code and reasoning on everything I believe...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

Fruit Jam

Firmware

CircuitPython using enhance-hub branch.

What happened ?

An assert is hit. Code would crash without it due to a null pointer.

How to reproduce ?

Plug in more HID devices than TinyUSB is configured for. It tries to open all of the HID interfaces found. If it tries to open more than it's been configured for, then it hits an assert. Instead, it should fail to open the device using the HID driver but still make it availab...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

It's been a couple months since I worked on this. If I understand your PR, you are trying to explicitly keep that macro to type uint8_t, and chose to use TU_ASSERT() to cause the firmware to hang at runtime if this is exceeded.

If this reduces the CodeQL warnings, then I'm OK with your alternate method, and you can close this PR.

thanks, I am always working on something and got pending PR. the _app_driver_count is only assigned when initialization with tud_init() and the sum...

fallow birchBOT
#

Thank you very much everyone for putting time and effort for this PR. Especially @atoktoto and @rppicomidi for getting most of the work done. I am sorry for being super late, I have to constant switching works and haven't worked much with rp2040 until now.

Though since there is lots of changes since this PR is created, I have update and also make lots of changes, notably:

  • lost of API rename and signature changes to match other class driver consistency e.g num_rx_cables --> rx_cable_cou...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

Fruit Jam

Firmware

CircuitPython with PICO PIO USB Host

What happened ?

Device fails to enumerate.

How to reproduce ?

Enumerate a thrustmaster joystick full speed device connected through a ch334 hub. Also seen with an 8bitdo controller.

When setting the device address the device correctly sees the pack and acks. However if the host doesn't read the ack correctly, the transfer fails and is retried. It perpetually fails because the d...

fallow birchBOT
#

The midi_rx example does not build. I tried the build with VS Code using the Raspberry Pi pico-examples project and pico-sdk 2.1.1. The reasons the build failed are likely out of scope for this pull request. I am writing them here because I do not know where else to file them.

It does not build for two reasons:

  1. The pico-sdk file src/rp2_common/tinyusb/CMakeLists.txt sets BOARD to pico-sdk, which does not work with the latest TinyUSB code. Even the develop branch of the `pico...
fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-rp2-picosdk-board
fallow birchBOT
#

I am sorry to argue. I do not love VS Code IDE either. However, the Raspberry Pi documentation instructs most of their users to use VS Code. The average Raspberry Pi Pico C/C++ application developer pool will encounter this issue as I described it. It is good to try Raspberry Pi Pico example code using VS Code. Same reason I try the Arduino IDE, too.

But from the command line, to build the device_info example:

export PICO_SDK_PATH=[your path to the pico-sdk]
export PICO_BOARD=pico
export...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-8bitdo-enum
fallow birchBOT
fallow birchBOT
#

I should note that this patch has saved the day on a big project, as it is the difference between working and not working for me as well.

It seems that the hw_endpoint_init() call is what is missing from the main repo. Adding it back as follows seems to work for me as well.

// New API: Configure and enable an ISO endpoint according to descriptor
bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc) {
  (void) rhport;
  const uint8_t ep_addr = ep_desc-...
fallow birchBOT
#

Since you are working on usbh, I found at least on NUCLEO-H7S3L8 speed detection is more stable by putting tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS); at the start of enum_new_device().

hmm that is weird, delay before port_reset() shouldn't make a difference since port got reset anyway, and the delay afterwards is rather generous ~450ms. Thank you for the hint, I will check this out next time I test with h7rs.

fallow birchBOT
#
[hathach/tinyusb] New branch created: add-metro-rp2350
fallow birchBOT
#

Using the dcd_edpt_iso_activate() from current main repo, setting ep size to 448 did not change anything. No playback.

Using the snippet above with the hw_endpoint_reset_transfer() call, ep size to 448, WORKS!

Using LOG=2 output, the massive load of output messages breaks the audio playback, here is the LOG=1 output with your new snippet:

ep_desc->wMaxPacketSize: 448
ep_desc->wMaxPacketSize: 4
USB Streaming
USB Mount
Clock set current freq: 48000
ep_desc->wMaxPacketSize: 448...
fallow birchBOT
#

In midi_host.c, lines 173-176

    if (xferred_bytes) {
      tu_edpt_stream_read_xfer_complete(&p_midi_host->ep_stream.rx, xferred_bytes);
      tuh_midi_rx_cb(idx, xferred_bytes);
    }

Many MIDI devices, especially from Korg, will always respond to an IN transfer request from the host with 64 bytes of data. If they have no data to send, they will send back all 64-bytes of zero instead of NAK. If they have only a single message to send, they will send back the first 4 bytes ...

#

A question about the example program: Why does it not also demonstrate MIDI TX? For example, see https://github.com/rppicomidi/usb_midi_host/blob/main/examples/C-code/usb_midi_host_example/usb_midi_host_example.c

The example will either light up the transport LEDs on MIDI controller devices that support play and record transport buttons, or it will play musical notes on sound generating MIDI devices. If the issue is you have no commercial MIDI hardware to test this, perhaps just hooking it...

fallow birchBOT
#

There are some MIDI devices, especially guitar pedals, that are designed for high speed USB 2.0 instead of full speed. They also do not provide an alternate descriptor when the host is full speed. As a result, their bulk endpoint descriptor max transfer sizes are always 512 bytes. That is too large for chips like the RP2040 that only support full speed USB. The code in the usb_midi_host application driver limits the endpoint sizes to the maximum that the hardware supports before opening the...

fallow birchBOT
fallow birchBOT
#

Many MIDI devices, especially from Korg, will always respond to an IN transfer request from the host with 64 bytes of data. If they have no data to send, they will send back all 64-bytes of zero instead of NAK. If they have only a single message to send, they will send back the first 4 bytes encoded as a MIDI message packet and the remaining 60 bytes all zero. And so on.

Ah sorry, I didn't pay attention to this, I just did a quick check to see if all zeroes is a valid packet to make sure...

fallow birchBOT
#

@rppicomidi which changes you need to make to the CMakeLists.txt. I have tried but it seems to compile the pico-examples just fine with current master (already added board.h to bsp/rp2040/pico_sdk)

cmake -DBOARD='raspberry_pi_pico' -DFAMILY='rp2040' ..
Using PICO_SDK_PATH from environment ('/home/hathach/code/pico/pico-sdk')
PICO_SDK_PATH is /home/hathach/code/pico/pico-sdk
Initializing PICO_BOARD from environment ('pico')
Initializing PICO_PLATFORM from environment ('rp2040')
Target bo...
fallow birchBOT
#

thank you for the detail, I got what is really missing from my testing. I only test with the configuraation wherre it is either streaming or off entirely. Wehereaas you switch to very low bitrate 4 <-> 384 back and forth. Look like the issue happen when switching and the iso transfer is not complete yet (therefore you got the warning previously). Let me revise this, and I think we can update and get this merge.

fallow birchBOT
spare badge
fallow birchBOT
fallow birchBOT
#

@HiFiPhile it is weird, there is ENUM_RESET_DELAY_MS which is 50ms per USB specs, it should be enough for dwc2 to detect the link speed, the ENUM_DEBOUNCING_DELAY_MS is mostly waiting for device to bootup/clock init before we start talking to it iirc. I will check again later.

    hcd_port_reset(_dev0.rhport);

    // Since we are in middle of rhport reset, frame number is not available yet.
    // need to depend on tusb_time_millis_api()
    tusb_time_delay_ms_api(ENUM_RESE...
fallow birchBOT
#

it is weird, there is ENUM_RESET_DELAY_MS which is 50ms per USB specs,

I think some devices need extra time to power on (DP is pulled high but not ready to communicate), in which case ENUM_RESET_DELAY_MS is not enough. Speed detection is done once hcd_port_reset_end(_dev0.rhport); is called but the device is not ready yet. Then we wait for ENUM_DEBOUNCING_DELAY_MS but since the detection is already done it's not very useful.

fallow birchBOT
#

@rppicomidi I made more changes to addres 2 of your reviewed issues

  • all zero response: it is special case, I think we can just simply check if all rx bytes are zeroes instead of doing it in 4 bytes which is quicker. I guess there is no device that has zero packet between meanningful packets in the same response ?
  • force bulk 512 -> 64 bytes is done in tu_edpt_validate() which will help other drivers using bulk/stream ep API as well.

Other issues can be resolved in follow-up PR, pleas...

fallow birchBOT
#

Operating System

Windows 10

Board

MSP-EXP432E401Y

Firmware

examples/device/audio_test - master branch (commit 6bba41045a4224abb68256dcf2fce893da47a743)

What happened ?

I was tweaking the audio_test example to play back a raw PCM audio file and noticed that the sound seemed noisy. I went back and tried playing the audio from the unmodified audio_test example and it sounded noisy as well. I'm running this test on Windows so I wasn't able to get plot_audio_samples.py worki...

fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-dwc2-host-conflict-max3421e
#

My issue was the script wouldn't get passed import sounddevice as sd. I'm not sure where I saw it but there is a software library (not just a python one) that I need to install on my Windows PC. The link for it pointed to a page that no longer had a reference to sounddevice for Windows.

No logging was used for my test or screenshot. I just use "make BOARD=msp_exp432e401y" to build the binary without modifying any sources.

fallow birchBOT
#

Related area

Host API

Hardware specification

RP2 PIO usb host code

Is your feature request related to a problem?

In CircuitPython we open endpoints before we use them. We only track what we use for a small period of time while the VM is running. If a second VM run opens an endpoint it will call open a second time. On PIO USB host code, this causes a second allocation for the open endpoint and basically leaks the memory of the first. Eventually the endpoint opening will fail b...

fallow birchBOT
fallow birchBOT
#

Operating System

Windows 11

Board

rp2040 with usb host

Firmware

exemple hid_mouse_log_filter mouse not scrolling up and down. not picking up mouse scroll up and down and move it up.tested from oldest to newest mouses.

What happened ?

exemple hid_mouse_log_filter mouse not scrolling up and down. not picking up mouse scroll up and down and move it up.tested from oldest to newest mouses.

How to reproduce ?

exemple hid_mouse_log_filter mouse not scrolling up and down....

fallow birchBOT
#

While there is a define for the port, the clock enable is hardcoded for GPIOA, so setting a different port than GPIOA doesn't work. This fixes it by adding a define for enabling the port clock.

It also adds a define for the pin mode, because not all boards have the LED connected in a way that open drain works with it.

Describe the PR
A clear and concise description of what this PR solve.

Additional context
If applicable, add any other context about the PR and/or screenshots...

fallow birchBOT
#

Describe the PR

This MR changes the following (listed in commit order):

  • Turn docs/contributing/code_of_conduct.rst and docs/info/contributors.rst into proper files (previously were symbolic links)
  • Fixed code formatting in .rst files
    • Ensure all references to symbols (functions/variables etc) are displayed as inline literals (wrapped with double back ticks)
    • Ensure that all code blocks have language specific syntax highlighting (if highlighting for that language i...
fallow birchBOT
#

Ok. I think the issue is with the musb dcd layer. For some reason writing 32 bit values to the fifo is causing this corruption issue. Only doing 16 bit or 8 bit writes to the fifo appears to work and leads to the packets received on the PC matching what is expected.

Here are the changes I made.
Image

The packets I receive now matches exactly what I expect.

![Image](https://github.com/user-attachments/asse...

fallow birchBOT
#

Operating System

MacOS

Board

stm32l412nucleo

Firmware

examples/device/hid_composite

What happened ?

Not able to compile examples

How to reproduce ?

  1. Clone the repo
  2. Checkout to master branch
  3. cd /examples/device/hid_composite
  4. add CMSIS device drivers to the inclusion path and build files
  5. make board=stm32l412nucleo SPEED=full all

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

[shell]$ make board=stm32l412nucleo SPEED=full all
make: *** tinyusb/hw/bs...

fallow birchBOT
#

Nice analyze, but the reason is something else.

Even if 32bit values are stored unaligned in FIFO, doing reg->u32 = *(uint32_t const *)addr; will first load the value into CPU register with a LDR instruction, since Cortex-M4 support unaligned memory access it should be ok, then the value is written into USB fifo.

You can test tu_unaligned_read32() for 32bit read loop https://github.com/hathach/tinyusb/blob/334ac8072650e3b18278042c2c2b402db73c7359/src/portable/synopsys/dwc2/dwc2_common...

fallow birchBOT
#

Your correct. Since none of my workarounds were working I did feel like something else was going on. Using the above function you mentioned didn't resolve the issue.

Looking at the FIFO register in the MSP432E TRM it seems like for a single packet mixing 32 bit, 16 bit and 8 bit writes are not allowed.

Image

Taking a look at another device with the same Mentor IP it seems like they purely stick with 8 bit w...

fallow birchBOT
#

For a single packet read and write operations must pick either 32-bit, 16-bit or 8-bit read or write operations. Mixing and matching can cause corruption of data.

This becomes a bigger issue when using TinyUSB fifo that has to deal with wrapping since read/write operations may be split between multiple transfers of different sizes.

Therefore, create a function that will determine which operation can be used for transfer the entire buffer of data. Then read and write operations can use a...

#

So although 96 bytes need to be written its possible that only 34 bytes are written initially and then 62 bytes are written. So I can see within 1 packet this mix match causing a problem.

Just read the DS, me too I think it should be the issue.

In fact (3) is already implemented by audio class (the only one who use fifo based transfer) as half of MCUs doesn't support fifo based transfer.

You can test with define TUD_AUDIO_PREFER_RING_BUFFER=0

We can either fix or remove fifo support...

fallow birchBOT
#

Still seems to be an issue. I have installed the Pico-PIO-USB project using the script.

~/projects/pico/pico-sdk$ git status
HEAD detached at 2.1.0
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
	modified:   lib/btstack (new commits)
	modified:   lib/tinyusb (new commits, untracked content)

no changes a...
fallow birchBOT
fallow birchBOT
#

I will attempt to integrate this driver with some of my applications after you merge it. Any issues I encounter will result in smaller pull requests that should be simpler to review and manage.

Thank you very much for the effort and patient so far. Feel free to submit more follow-up PRs, I will try to review them as soon as I could.

fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-pico-examples-build
fallow birchBOT
#

minor fix on calculation of desc_end in vendord_open( ) for descriptor prasing

Describe the PR

fix desc_end calculation
In vendor device class, function vendord_open()

Additional context

In vendor_device.c, original code
https://github.com/hathach/tinyusb/blob/master/src/class/vendor/vendor_device.c

  const uint8_t* p_desc = tu_desc_next(desc_itf);
  const uint8_t* desc_end = p_desc + max_len;

desc_end is calaulated by p_desc + max_len which is `u_d...

spare badge
#

i dont understand why hathach keep updating tinyusb but not Adafruit_TinyUSB_Arduino.

robust walrus
#

I assume the arduino library is only updated on releases of tinyusb

#

you could ask them to in an issue if you like

fallow birchBOT
fallow birchBOT
#

Operating System

Others

Board

iMXRT1052EVB

Firmware

Currently high speed is disabled for iMXRT family CPUs USB host, as mentioned in the comment:
https://github.com/hathach/tinyusb/blob/master/src/portable/chipidea/ci_hs/hcd_ci_hs.c#L99

When will it be fixed?

What happened ?

When the host in high speed:

  1. Have issue when plug/unplug devices.
  2. Does not detect disconnection

How to reproduce ?

  1. Override full speed mode by commenting out statement
    https://githu...
fallow birchBOT
fallow birchBOT
#

Describe the PR
Add Media Transfer Protocol (MTP) device class support

Additional context
Feature request reference: https://github.com/hathach/tinyusb/issues/1079

The implementation has been tested and found functional at prototype level. We provide an example tested on STM32F3. It makes use of blulk and interrupt EPs only, so it should be supported by most platforms.

The class supports a single session only, but it allows multiple objects and nested associations (i.e. fil...

fallow birchBOT
#

Operating System

Others

Board

ESP32-S3

Firmware

Probably the most relevant example is uac2_headset.

What happened ?

After the 0.18.0 release, certain platforms such as iOS fail to record the microphone because the endpoint stalls. This was root caused to missing 4 byte alignment on ctrl_buf_1. It seems that this changed in #2865 but it is unclear why it was changed, probably a mistake.

How to reproduce ?

Record microphone in a USB audio class 2.0 example. The orig...

fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

raspberry pi pico

Firmware

examples/host/midi_rx except modified tusb_config.h to add the line

#define  CFG_TUH_MIDI_STREAM_API 0

What happened ?

Build failed.

pico-sdk/lib/tinyusb/src/class/midi/midi_host.c:156:24: error: 'midih_interface_t' has no member named 'stream_read'
[build]   156 |       tu_memclr(&p_midi->stream_read, sizeof(p_midi->stream_read));
pico-sdk/lib/tinyusb/src/class/midi/midi_host.c:157:53: error: 'midih_...
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

rp2040

Firmware

https://github.com/Cpasjuste/uGamePad

What happened ?

Hi,

In my (rp2040/rp2350) project, i did update tinyusb to be up to date. But since then, i have a device which is not working anymore in host mode. This is the "Neo Geo Mini USB-C Gamepad".

The problem comes from the addition of the "newly added" enumerations in [usbh.c](https://github.com/hathach/tinyusb/blob/5333d042f9384ec1cc0663a2708c0ca7cb5cdc32/src/host/usbh.c#L1...

fallow birchBOT
#

Related area

The midi_host driver addresses the attached device by index. Device string get functions need the device address.

Hardware specification

Is hardware independent. I am testing on Raspbery Pi Pico

Is your feature request related to a problem?

I want to be able to fetch Manufacturer, Product and other device strings without blocking the code. The host API that supports that requires the device address. The mount callback returns the device address within the callbac...

fallow birchBOT
fallow birchBOT
#

Tried the uac2_headset example in pico2040 with linux, and the device is not showing up and this the output from dmesg. Any help would be appreciated


[  +0.093643] usb 3-2.2: USB disconnect, device number 10
[  +0.434362] usb 3-2.2: new full-speed USB device number 11 using xhci_hcd
[  +0.109792] usb 3-2.2: New USB device found, idVendor=cafe, idProduct=4010, bcdDevice= 1.00
[  +0.000004] usb 3-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0.000003] usb 3-2.2: Produ...
fallow birchBOT
#

Operating System

Linux

Board

pico

Firmware

examples/host/midi_rx

What happened ?

Each virtual cable in a USB MIDI device consumes at least one internal jack and one external jack. Although devices with more than a total of 8 virtual cables are not common, they do exist. For example plugging a MOTU MIDI Express 128 would cause https://github.com/hathach/tinyusb/blob/5333d042f9384ec1cc0663a2708c0ca7cb5cdc32/src/class/midi/midi_host.c#...

fallow birchBOT
#

@WerWolv thank you for sharing!
I am giving some context here, asย it might be beneficial for review.ย I had a short look at your code, the implementation is not that far from the one we're suggesting. Since you already have a hands-on experience on how the MTP class works, it would be great if you could take a look at our code too (feel free to add comments or propose corrections) and maybe perform a test on a physical device (since now, we tested it on STM32F3 and on a custom PSoC5LP port, o...

fallow birchBOT
#
[hathach/tinyusb] New branch created: ctrl_fix
fallow birchBOT
#

Merged the latest changes in master branch.

Current problems (and I need help):

  • The communication to LowSpeed device via external HUB sometimes fails. (ex: cannot get the device descriptor, tuh_mount_cb() not called)
    • Plugging to the Root Port doesn't cause the problem with same device.
    • In my test, USB keyboards are often causing this problem.
  • Plugging the external HUB sometimes causes the resetting MCU.
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

Firmware

.

What happened ?

Seems like cmake on my system was installed by Visual Studio, and default generator was Visual Studio 17. As a person not really familiar with cmake it took some time to understand it and fix it with env variables. Maybe it make sense to enforce needed generator to avoid this problem?

How to reproduce ?

.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

.

Screenshots

No response

I have checke...

fallow birchBOT
#

Operating System

MacOS

Board

STM32F411 Blackpill

Firmware

examples/host/midi_rx

What happened ?

I can't seem to get tuh_umount_cb/tuh_midi_umount_cb to be called when the device is unmounted, even if I use the stock example.

How to reproduce ?

Just build any example, I use examples/host/midi_rx and upload it to blackpill. Plug in and unplug device.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

[debug.txt](https://github.com/user-attachments/files/1927...

fallow birchBOT
#

Operating System

Linux

Board

pico

Firmware

I am trying to build a project that uses this library.
yet it constantly fails.
I do not have the dcd_pio_usb.c and hcd_pio_usb.c files. I am missing the pio_usb directory (inside ~/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi there is only an rp2040 folder).
I tried to manually create the folder and put the files in manually, from this repo, however, the build still fails.

I am suspecting I have an older version of ...

fallow birchBOT
#
[hathach/tinyusb] New branch created: update-pio-usb
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Related area

IOS apple support

Hardware specification

rp2040

Is your feature request related to a problem?

No this will allow the embedded devices to connect to IOS device and open a whole new avenue of innocative IOT project that work with apple ecosystem

Describe the solution you'd like

A usb host example to communicate with usbmuxd library to interact with IOS devices

I have checked existing issues, dicussion and documentation

  • [x] I confirm I have checked exi...
fallow birchBOT
#

Operating System

Linux

Board

RP2040

Firmware

N/A

What happened ?

There's a discrepancy in how TinyUSB and PICO_SDK check if stdio to UART is enabled.

From https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_stdlib/stdlib.c

void setup_default_uart(void) {
#if LIB_PICO_STDIO_UART
    stdio_uart_init();
#elif defined(PICO_DEFAULT_UART_BAUD_RATE) && defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN)
...
#endif

while TinyUSB...

fallow birchBOT
fallow birchBOT
#

Hello everyone, and thank you all for the effort of speeding up USB host on the Raspberry Pi Pico! Unfortunalely, after testing the proposed re-implementation of the RP2xxx HCD, I've found a couple of bugs and potentional issues that would be nice to have fixed:

fallow birchBOT
fallow birchBOT
#

Thanks for the answer. Sorry for annoying you again, but I do not have such a file inside /tinyusb/

~/pico/pico-sdk/lib/tinyusb/tools$ ls -la
total 52
drwxrwxr-x  4 user1 user1 4096 ฮœฮฑฯ  18 21:20 .
drwxrwxr-x 10 user1 user1 4096 ฮœฮฑฯ  18 21:20 ..
-rw-rw-r--  1 user1 user1 4415 ฮœฮฑฯ  18 21:20 build_board.py
-rw-rw-r--  1 user1 user1 3586 ฮœฮฑฯ  18 21:20 build_esp32sx.py
-rw-rw-r--  1 user1 user1 5456 ฮœฮฑฯ  18 21:20 build_family.py
-rw-rw-r--  1 user1 user1 2321 ฮœฮฑฯ  18 21:20 iar_gen.py
-rw-r...
fallow birchBOT
fallow birchBOT
#

Once again, thank you for the comment.
Sorry if I am being a noob, but since I do not have recent experience in this (it's been some time since I played with the pico), and I am afraid of messing things up, what is the reccomended way to update the sdk and the tinyusb library?

I have been trying to update the tinyusb, but I guess this doesn't work since the sdk is old. Does tinyusb come with the sdk?

Is there a guy somewhere?

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: update-max3421e-atomic
fallow birchBOT
#
[hathach/tinyusb] New branch created: hcd-close-ep
fallow birchBOT
fallow birchBOT
#

@wbcbz7 Thank you for taking the time to review this in detail.

This code assumes that there can be only one USB hub attached

Yes, that is because multiple hub support is a relatively new feature. I will address that.

During my tests of simultaneous USB Mass Storage and HID devices, it turns out control transfers can get sometimes corrupted by current EPx transfer control structures, and vice versa

Can you post evidence of that happening? For example, a USB sniffer trace, ...

fallow birchBOT
#

Can you post evidence of that happening? For example, a USB sniffer trace, a log, or a file diff? It will help me root cause the issues you are seeing.
I'll try to hook an logic analyzer and dump a trace at weekends, so far you can try to reproduce a bug this way:

  • Clone a host_cdc_msc_hid example from Pico-SDK, then add a simple routine to msc_app.c which will repeatedly read or write data from the mass storage device (i.e. from [this gist](https://gist.github.com/wbcbz7/95ce4c1aa03...
fallow birchBOT
#

@wbcbz7 Thank you for the additional information. I will try your experiment.

By design, the HCD first tries pending Control transfers, then pending Interrupt transfers, and only if there is any time left in the frame does it try pending Bulk transfers. If you are seeing large bulk transfers slowing down HID interrupt polling rate, then there is a problem. Control transfers that NAK for a long time could potentially slow down the polling interval because RP2040 auto-retry cannot be disable...

fallow birchBOT
#

@wbcbz7 I have addressed the hub issue and have done a git merge with the latest TinyUSB and pushed it up. I am trying your test code now and find no evidence of issues yet. I am using a powered 4-port hub, a USB mouse plus 2 USB flash drives. Is there a particular block size or blocks per transfer number that causes issues in your testing? Is it possible that the merged code you created introduced some other issue?

fallow birchBOT
#

@rppicomidi, I've just libked the test application with your latest commit, and while it seems to bie slightly more stable, it still appears to occasionally hang during bulk transfers if control transfers are executed concurrently. I've tried usb-sniffer-lite to capture USB frame data but even with an external trigger it seems to not have enough buffer memory to capture the exact moment of hang, so I had to revert back to my logic analyzer. Attached there are two PulseView sessions with bulk ...

fallow birchBOT
#

Operating System

Windows 11

Board

M5stack cardputer with espressif esp32-s3

Firmware

FREETOS

What happened ?

I am trying to use cardputer with esp3-s3 microcontroller in USB host mode.
The 1st hurdle is that for ESP32-S3 code for USB PHY initialization is missing in tinyusb. This can be circumvented by using a function from the espressif usb component (usb_new_phy).
After calling usb_new_phy the call to tusb_init will succeed.
tusb_init is followed by tuh_task.
We wait ...

fallow birchBOT
fallow birchBOT
#

`static usb_phy_handle_t phy_hdl;

/**

  • @brief Main entry point for the ESP-IDF application.
  • Initializes TinyUSB in host mode and continuously polls for USB events.
  • When the device descriptor is received, it is printed to the console.
    */
    extern "C" void app_main(void)
    {
    // Configure USB PHY
    usb_phy_config_t phy_conf = {
    .controller = USB_PHY_CTRL_OTG,
    .target = USB_PHY_TARGET_INT,
    .otg_mode = USB_OTG_MODE_HOST,
    .otg_speed = USB_PHY_SPEED_UND...
fallow birchBOT
#

@HiFiPhile .. thank you for pointing me to this. If I had known earlier, it would have saved me 2 days of debugging. I took the usb_init code that you pointed me to. It does the same stuff that I figured out myself the hard way.. but the code looks a lot nicer now.

Unfortunately it does not resolve the crash problem with CFG_TUH_DWC2_SLAVE_ENABLE.
I managed to create the debug log with log level 3 now. However, I had to "manually" terminate the logfile in the channel_xfer_start function as o...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Stacksize does not seem to play a role here. I noticed something else. We dont seem to be able to get out of an interrupt signalling state. I did some debugging around hcd_int_handler. We hit GINTSTS_CONIDSTSCHNG, then GINTSTS_HPRTINT and then > 30 x GINTSTS_NPTX_FIFO_EMPTY without ever receiving something. This is strange.. IIRC the 1st packet has 8 bytes max.. so even when sending each byte individually, we should have received something in the meantime. Will have a closer look to handle_tx...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

I tried exmaples/host/device_info. Had to rewrite the code a bit as I dont have a board with LED. I am facing the same behavior. I will keep debugging with my original project.

  • you can skip the led, just define a dummy pin. That will make sure we test on the same software (I also prefer to test with stock example as well).
  • Also please provide the LOG=2 output
  • Does the issue occurs with other device or only with 1 specific ? what is the device specific make/model and its configurat d...
fallow birchBOT
fallow birchBOT
#

Unfortunately I just have 1 device and it is not a developer board. This means: no LEDs, just one USB connector. When USB is used by code, I am loosing the builtin JTAG capability as there is some "hardwiring" to the USB port. I had to add code, that redirects printf to a file that will be stored on a microSD card. In addition I had to close the file before freeRTOS reboots.. otherwise it will have 0 content. I logged with LOG level 3. Here is what I get when using the FIFO (before reset):

U...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

@torsts Could you try to comment these lines and try again please?

diff --git a/src/portable/synopsys/dwc2/hcd_dwc2.c b/src/portable/synopsys/dwc2/hcd_dwc2.c
index b13479b02..723d1169b 100644
--- a/src/portable/synopsys/dwc2/hcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/hcd_dwc2.c
@@ -814,9 +814,9 @@ static bool handle_txfifo_empty(dwc2_regs_t* dwc2, bool is_periodic) {
 
         // skip if there is not enough space in FIFO and RequestQueue.
         // Packet's last word written to FIFO...
fallow birchBOT
#

I have the same thing on S3 with device_info example and default config (CFG_TUH_DWC2_SLAVE_ENABLE=1).

With CFG_TUH_DWC2_DMA_ENABLE=1 all works.

Seems that something changed after adding the DMA support.

Was it working in single mode before adding the DMA?

I forgot, I think hcd dwc2 are mostly tested on P4. Slave and DMA are added pretty much same time. I will try to pul out a S3 to test with and maybe added that to the hil pool as well. Btw, does the issue occurs with...

#

Dont have an S2. ;) .. I commented out the lines as requested.. The behavior changes. No watchdog reset anymore. However, I still dont seem to receive the descriptor (at least on the top application level). One thing I can already confirm, with this change I get further and receive a GINTSTS_HCINT -> handle_channel_irq. This is where my current debug centers.

As a sidenote, espressif itself uses the dma in host mode. Will eventually try to force slave mode on them in case I figure out a coup...

#

Dont have an S2. ;) .. I commented out the lines as requested.. The behavior changes. No watchdog reset anymore. However, I still dont seem to receive the descriptor (at least on the top application level). One thing I can already confirm, with this change I get further and receive a GINTSTS_HCINT -> handle_channel_irq. This is where my current debug centers. ... and afterwards we get GINTSTS_RXFLVL as well.

As a sidenote, espressif itself uses the dma in host mode. Will eventually try...

fallow birchBOT
#

@roma-jam I dont have a developer board.. so just the one (1) builtin USB. From my understanding, jtag and serial print gets lost as soon as I switch the controller into host mode. How exactly would I retrieve the log from esp_rom_printf ?

I in a state where "something (process_enumeration) worked once"... but not stable. Now it feels like a race condition.
I am working on getting a LOG but I likely have to pick a different approach than esp_rom_printf.

#

@torsts
Ah, I didn't get that you use the custom board.

How exactly would I retrieve the log from esp_rom_printf ?

This macros redefine the printf implementation and (in case printf is being called from ISR) prevent the exception. But this is not our case, I also read that you already redirected it to the SD card.

In case, you commented out the lines, what is the last line in the log?
Before it was

Get 8 byte of Device Descriptor
[0:0] Get Descriptor: 80 06 00 01 00 00 08 00
```...
fallow birchBOT
#

@roma-jam .. ok.. took a bit .. here the last lines of the log
/--
...
Device configured
Parsing Configuration descriptor (wTotalLength = 32)
Device mounted, address: 1
[0:1] Get Descriptor: 80 06 00 01 00 00 12 00
on EP 00 with 8 bytes: OK
on EP 80 with 18 bytes: OK
[0:1] Control data:
0000: 12 01 10 02 00 00 00 40 1C 1B 0E 1A 00 01 02 03 |.......@........|
0010: 01 01 |..|
on EP 00 with 0 bytes: OK

--- Device Descriptor for device 1 ---
...

fallow birchBOT
fallow birchBOT
#

I am able to reproduce the issue with S3 and host slave mode while it works with dma mode. As discussioned, it is probably an forever blocking while() in the driver. Will try to troubleshoot this next time I got to work with hcd dwc2.

TinyUSB Device Info Example
[0:] USBH Device Attach
I (346) main_task: Returned from app_main()
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
PC      : 0x4200c069  PS      : 0x00060034  A0      : 0x8200c...
fallow birchBOT
#

Related area

CH32V307 is supported by tinyusb, is it possible to support CH32V303 and CH32V305?

Hardware specification

CH32V303

Is your feature request related to a problem?

I've tried to run CH32V307 porting on CH32V303. But it doesn't work.

Describe the solution you'd like

Support CH32V303 and CH32V305.

I have checked existing issues, dicussion and documentation

  • [x] I confirm I have checked existing issues, dicussion and documentation.
fallow birchBOT
#

Took me almost the day.. but looks like I finally figured it out. We seem to face an architectural problem that the compiler is hiding from us. Below you will find some code that I wrote do to demonstrate the issue. I had to do the system_abort as I cannot debug my custom board without a coredump.
`// Define a volatile pointer to the register
volatile uint32_t *reg_ptr = (volatile uint32_t *)0x6008002C;

// Read the register value
uint32_t reg_value = 0;

value2_4 = txsts_bm->fifo_available;
...

fallow birchBOT
#

Hello,

I'm trying to port to the STM32H747XIH using the STM32H747-DISCO board, using only HS host for CDC, MSC and HID, for three days, and no matter what I do, I always get stuck at:
while (dwc2->grstctl & GRSTCTL_CSRST) {}

  • I have already tried an empty project, just simple porting.
  • Then, I adapted the STM32H743 example.
  • Added HAL_PWREx_EnableVddUSB during initialization.
  • Added @static void reset_core(dwc2_regs_t* dwc2):
    while (!(dwc2->grstctl & GRSTCTL_AHBIDL)) { }

Can anyb...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Others

Board

STM32H747I-DISCO

Firmware

examples/host/cdc_msc_hid

What happened ?

I am trying to use STM32H747I-DISCO as Host to plug USB HUB
In this hub I will conect a CDC, HID and MSC.
I solved many problems, but this last one I need help.

The USB3320 CPEN pin controls VBUS and I cant turn this pin on.

How to reproduce ?

Just run the STM32Cube project
https://github.com/eng-software/TestTinyUSB.git

Debug Log as txt file (LOG/CFG_TUSB_DEB...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Others

Board

RP2040 Custom board

Firmware

/*

  • The MIT License (MIT)
  • Copyright (c) 2019 Ha Thach (tinyusb.org)
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Softwar...
fallow birchBOT
#

This commit breaks USB High Speed on my Renesas Vision Board RA8D1 chip. I was applying patches one by one from a working High Speed
version (however with a bug that sometimes drops a single byte on reception). When reached this commit, all sorts of bad things start to appear. like failed asserts and when replacing with the new /portable/renesas/rusb2/dcd_rusb2.c still worse.

I am going to take a finer grained approach (since this is a huge commit) to detect what is wrong with it. But w...

fallow birchBOT
#

Now its working.

  • I fixed my hardware startup
  • Removed the option

Sugestion:
USB disconnection is not working verywell, so I suggest the change above:

static void handle_hprt_irq(uint8_t rhport, bool in_isr) {
  dwc2_regs_t* dwc2 = DWC2_REG(rhport);
  uint32_t hprt = dwc2->hprt & ~HPRT_W1_MASK;
  const dwc2_hprt_t hprt_bm = dwc2->hprt_bm;

  if (dwc2->hprt & HPRT_CONN_DETECT) {
    // Port Connect Detect
    hprt |= HPRT_CONN_DETECT;

    if (hprt_bm.conn_status) {
      hcd_event_d...
fallow birchBOT
#

Related area

driver

Hardware specification

rp2040

Is your feature request related to a problem?

When I was using the example about the mouse, I found that it seemed there was no use of the absolute position of the mouse, but all were using the relative position.

Describe the solution you'd like

I hope to add relevant functions or provide other solutions to enable the use of absolute positions.

I have checked existing issues, dicussion and documentation

  • [x] I con...
fallow birchBOT
#
[hathach/tinyusb] New branch created: update-endpoint-open
fallow birchBOT
fallow birchBOT
#

Thank you for the PR, I think you missed APB1 and APB2.

CI failed with:

In file included from /home/circleci/project/hw/bsp/ch32v20x/family.c:21:
/home/circleci/project/hw/bsp/ch32v20x/family.c: In function 'board_init':
/home/circleci/project/hw/bsp/ch32v20x/boards/nanoch32v203/board.h:16:47: error: 'RCC_APB1Periph_GPIOA' undeclared (first use in this function); did you mean 'RCC_APB2Periph_GPIOA'?
   16 | #define LED_CLOCK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_GPIOA, EN...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Describe the PR
Fix gcc-riscv issue about volatile bitfields are incorrectly accessed using an access width not appropriate to the type of its container.

Tested on espressif_s3_devkitm with device_info and cdc_msc_freertos examples.

For the host I've tested an usb key and an FTDI usb-uart.

Device 1: ID 0403:6001 SN FT1ZK9MQ
Device Descriptor:
  bLength             18
  bDescriptorType     1
  bcdUSB              0200
  bDeviceClass        0
  bDeviceSubClass     ...
fallow birchBOT
fallow birchBOT
#

Do you want me to remove hcd_event_device_remove in handle_hprt_irq as well

Yes please, just double checked ST's HAL code.

and merge this PR first ?

@hathach is busy atm, since dwc2 is widely used it's better wait for Espressif @roma-jam for a double check.
Personally I tested with ESP32-S3-DevKitM and NUCLEO-H7S3L8.


Out of topic: Have you experienced any bouncing issue doing quickly connection/disconnection like in #2960 ?

fallow birchBOT
#

Hi,
Has anyone tried porting the TinyUSB host stack to Zephyr, or can someone provide some pointers on how to get started with porting TinyUSB host stack support in Zephyr?"

There are some commits about zephyr support, but it's still not supported fully. Look at osal_zephyr.h file and corresponding portable files.

fallow birchBOT
#

@HiFiPhile

  • I've updated the PR. I have also removed hcd_event_device_remove(rhport, in_isr); from handle_hprt_irq() now
  • About the "bouncing": if I manually connect/disconnect very quickly, the USB port crashes indeed.
    It crashes in usbh.c in function process_enumeration() in case ENUM_ADDR0_DEVICE_DESC:
          TU_ASSERT(tuh_descriptor_get_device(addr0, _usbh_epbuf.ctrl, 8,
                                            process_enumeration, ENUM_SET_ADDR),);
    
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

I am thinking, maybe we just remove the struct/bitfield in the register typedef i.e leaving only uint32_t. bitfield struct can be use with local variable only

Yes we can do let this. Adding a macro makes the thing complicate and losing the interest of bitfields.

sure, I will do this later if you are busy. I need to fix an racing issue with pio-usb when overclocking rp2350 to 264mhz first :)

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

STM32F7

Firmware

tinyUSB master, USB host on STM32F7 w/ DWC USB IP Core

What happened ?

When connecting a HS device with an interrupt endpoint with bInterval = 1 (1 microframe, 125us), it is being polled only at 2 microframe interval (250us), in case of a NAK.

How to reproduce ?

Connected a device with bInterval = 1 on it's interrupt endpoint

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

Debug log not relevant, I think.

The i...

fallow birchBOT
#

What I am seeing is this alternating interval of:

  • the channel IRQ finding a NAK (+HALTED), then deferring issuing a new IN token to the SOF handler. (every 250us)
  • then 1 microframe later: the SOF IRQ re-scheduling the IN token, (so also every 250us, but with 125us offset to the channel IRQ)

Image

It seems to me that the channel IRQ handler should immediately re-issue a new IN token (submit URB) after rec...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Describe the PR

When connecting a HS device with an interrupt endpoint with bInterval = 1 (1 microframe, 125us), it was being polled only at 2 microframe interval (250us), in case of a NAK. This is because the retry was deferred to the next SOF, basically wasting a full microframe.

The fix is to re-send the IN token as soon as we get the NAK, in base bInterval = 1. In other cases, we still rely on the existing polling interval calculations in the SOF IRQ handler.

Addition...

fallow birchBOT
#

Operating System

Linux

Board

Fruit Jam

Firmware

CircuitPython using TinyUSB commit: 60e6d53d1

What happened ?

An assertion occurred when TinyUSB ran out of device numbers.

How to reproduce ?

Plug in the LS mouse from the Adafruit shop: https://www.adafruit.com/product/2025 into the Fruit Jam.

For some reason, the onboard hub detects brief USB device disconnects. It emits the port connection change each time it does. By the time the status is read the connection s...

fallow birchBOT
fallow birchBOT
#

Describe the PR
HFIR register for SOF timing was programmed with an off-by-one value (it needs a -1 applied).

#

Describe the PR
DWC2 host can generate a lot of HPRTINT interrupt when a device is attached, due to electrical contact bounce.
All of these events were being forwarded to the TinyUSB host stack as new HCD_EVENT_DEVICE_ATTACH events, causing many issues:

  • rapid succession of ATTACH and REMOVE events, occurring in the middle of device enumeration
  • queue exhaustion because more events were generated than could be swallowed by the tuh_task()
  • many other weird combinations of cod...
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Describe the PR
Fix xfer complete event of previous enumeration mess with next enumeration.

[1:1] Get Descriptor: 80 06 03 03 09 04 00 01 
on EP 00 with 8 bytes: OK
on EP 80 with 40 bytes: OK
[1:1] Control data:
  0000:  28 03 4D 00 61 00 73 00 73 00 20 00 53 00 74 00  |(.M.a.s.s. .S.t.|
  0010:  6F 00 72 00 61 00 67 00 65 00 20 00 44 00 65 00  |o.r.a.g.e. .D.e.|
  0020:  76 00 69 00 63 00 65 00                          |v.i.c.e.|
[1:0:0] USBH DEVICE REMOVED
[1:0:0] unplu...
fallow birchBOT
fallow birchBOT
#

Indeed doing the debouncing at DCD layer is much simpler.

I was testing break down the 450ms debouncing delay into smaller chunks in order to let the event queue processed in time.
22ea6ee67a4f545409b9290ef57c51e3d02d797a

_dev0.enumerating = 0 is trying to stop ongoing control transfer once the device is unplugged, then normally _ctrl_xfer will end up in idle state. However in some cases control transfer state get stuck.

I think a good fix is instead of _dev0.enumerating = 0 ...

fallow birchBOT
#

This adds tud_cdc_reset_cb(), which can be implemented to receive notifications when the CDC driver is reset.

Additional context
My application use a writer thread that goes to sleep when the the TX fifo is full, and is woken up by the tud_cdc_tx_complete_cb() callback. However, if there is a usb reset, then it gets hung since any pending writes are discarded. It would be useful to have a callback so that the writer thread can also wake up when there has been a usb reset.

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Hi, thanks for your response. I also looked into using tud_mount_cb(), but it seemed like there are some cases that that doesn't cover. For example, if I do a reset in Linux using something like:

int fd = open("/dev/bus/usb/001/005", USBDEVFS_RESET);
ioctl(fd, USBDEVFS_RESET, 0);
close(fd);

Then the CDC class driver gets reset, but I don't get a notification from either tud_cdc_tx_complete_cb() or tud_mount_cb(). Do you have any other suggestions?

fallow birchBOT
fallow birchBOT
#

While I can see the issue described here, it seems to me this is not the proper fix, but rather a workaround - with it's own side-effects.
Why wasn't this xfer cleared? And what if is currently ongoing?

There seem to be some race conditions between handling some stuff in the interrupt handler, and deferring some stuff to the tuh_task(). This is probably the root of (some of) these problems...

#

You are wrong in open permission, should be fd = open(filename, O_WRONLY);

You're right, I copy pasted it incorrectly into my comment.

Any reason why you are doing USB reset ? A part from some buggy WiFi chips whos get stuck there is no benefit.

I've been trying to debug an issue where my embedded device gets stuck a weird state, and I'm 80% sure it is because the host is doing a usb reset at some point (I've been using the C code above to try to reproduce it). What I'm seeing i...

fallow birchBOT
#

After a USB reset the host will do the whole enumeration process, when the device is ready (set configuration request ok) tud_mount_cb() is called, I've also verified it on Arch Linux kernel 6.13 with USBDEVFS_RESET . While the reset itself doesn't guarantee anything.

On Linux tud_cdc_line_state_cb() is pretty reliable, if I remember correctly DTR is set to ON automatically when the device is opened.

fallow birchBOT
#
[hathach/tinyusb] New branch created: usbh-enum-get-string-desc-first
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

I want to apologize, because I was really sure that my previous testing showed that tud_mount_cb() was not being called durring USBDEVFS_RESET. However, I tested it again tonight, and confirmed that tud_mount_cb() is indeed being called after reset, just as you said. I'm not sure what happened the first time (maybe I accidentally implemented tud_unmount_cb() instead?).

To close this out, I ended up using tud_cdc_line_state_cb() and tud_mount_cb(), which I think robustly cover...

fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

ch32v203c_r0_1v0

Firmware

examples/host/device_info

What happened ?

I'm writing USB host support for the CH32V203, and have identified ep_desc structures passed in to hcd_edpt_open() randomly being modified by observing ep_desc->wMaxPacketSize changing to nonsensical values due to the structure being allocated on the stack inside usbh_edpt_control_open():

static bool usbh_edpt_control_open(uint8_t dev_addr, uint8_t max_packet_si...
fallow birchBOT
fallow birchBOT
#

Thank you for the clarification. Iโ€™ll add some comments to the HCD template about this to make it clearer for other new contributors, and send a PR soon.ย Unrelated, the CH32V203 HCD driver Iโ€™m writing is coming along nicely now, getting past assigning the device ID and starting enumeration!--ย jpmOn 16 Apr 2025, at 18:21, HiFiPhile @.***> wrote:๏ปฟ
Hi, it is by design, hcd driver need to maintain EP and transfer status internally since different HCDs behaves differently.
You can look a...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: ci-add-s3-host
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: ci-add-picow-host
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

thank you for your PR. PING is indeed missing, I have

  • rename to next_do_ping for clearer meaning
  • I found that in case of transfer complete with NYET, we didn't do ping e.g msc out 31 bytes command
  • simply use channel->hcchar |= HCCHAR_CHENA; to continue transfer with existing meta data. Note channel.hctsiz.do_ping is cleared by host controller when interrupt trigger (in my testing with stm32f769), but we clear it anyway since dwc2 has too many variants :)
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Related area

port support

Hardware specification

all hardware with several ports

Is your feature request related to a problem?

Unable to init stack on two ports simultaneously.

Relates to:

Describe the solution you'd like

Possibility to run TinyUSB (device) stack on several peripherals (ports) simultaneously.

In the code that would be like:

tusb_rhport_init_t dev_init = {
  .role = TUSB_R...
fallow birchBOT
#

made an improvement from just a flag enumerating to actual enumerating_daddr to make it easier to clean up when device unplugged while enumerating not completed yet. @HiFiPhile please let me know if this make sense to you. after this merged, I will make the https://github.com/hathach/tinyusb/pull/3075 ignoring attach/detach on the same rhport/hub/port while debouncing to usbh to make it generic for all host controller. This seems to work rathe well.

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: refactor-usbh-bus-info
fallow birchBOT
#

Related area

New port support

Hardware specification

CH32 variant with USBFS, eg CH32V203C8T6 as used on the currently supported board ch32v203c_r0_1v0

Is your feature request related to a problem?

CH32 supports USB Host mode in the USBFS peripheral, but TinyUSB does not support it (yet)

Describe the solution you'd like

I have started writing support for the CH32 USBFS host mode, and it's now at the point where the USB host will enumerate some devices using the host/dev...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: usbh-improve-hub
#

Describe the PR

  • refactor hub driver and move port reset on connection change to usbh.
  • hub: add hub_port_get_status_local(), ignore resp in hub_port_get_status(pot != 0)
  • usbh properly deboucning with hub/rootport accordingly to usb specs, also add 10ms of reset recovery

image

This pull request introduces several updates to improve USB host functionality, enhance clarity in the codebase, and...

fallow birchBOT
fallow birchBOT
#

Operating System

Windows 11

Board

esp32-s3

Firmware

void usb_start(void){
    ESP_LOGI(TAG, "USB Composite initialization");
    const tinyusb_config_t tusb_cfg = {
        .device_descriptor = NULL,
        .string_descriptor = NULL,
        .string_descriptor_count = 0,
        .external_phy = false,
        .configuration_descriptor = NULL,
    };
    ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));

    tinyusb_config_cdcacm_t acm_cfg = {
        .usb_dev = TINYUSB...
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

custom STM32F746 -> USB3300 -> USB2507 -> USB2507 board

Firmware

Relevant code

#define TUSB_STACK_SIZE (4096) * (CFG_TUSB_DEBUG ? 2 : 1)
static osThreadId_t usbd_task_handle;
static const osThreadAttr_t usbd_task_attributes = {
    .name = "usbd_task",
    .stack_size = TUSB_STACK_SIZE,
    .priority = (osPriority_t)osPriorityAboveNormal7,
};

static osThreadId_t usbh_task_handle;
static const osThreadAttr_t usbh_task_attributes = {
    ...
fallow birchBOT
#

I was preparing to do work on the nxp/mcx bsps and noticed some of the dependices could not be fetch on a fresh clone:

This is a patch to make sure we fetch the commit for a dep, they checkout head before doing any checks. I added some prints for when a new folder / repo is initialized.

Everything worked ok on my test cases (mcx, lpc55 and lpc43) once this fix was in place.

C:\ELI\tinyusb_dev\tinyusb-dev\tools> .\get_deps.py mcx
cloning lib/FreeRTOS-Kernel with https://github.c...
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

Affects Local Development and the CI

Firmware

Happens with b5d4d0f6237ecaf78b2548e5c4a08810e0957066 but I think this has more to do with the dependency repos and how "HEAD" is handled.

What happened ?

I was preparing to do work on the nxp/mcx bsps to add more boards and noticed some of the dependencies could not be fetched on a fresh clone

I have a patch here:

https://github.com/hathach/tinyusb/pull/3100

That enables builds to work a...

fallow birchBOT
#

I will be porting tinyuf2 to MCXA156 and N947 and need this work in place.

This is the 1st step before bringing in support for other MCX devices.

We had previous patched https://github.com/hathach/mcux-sdk.git' for MCX support as it was not pulically available

I updated get_deps to point to the mcux-sdk version 2.16.10 from NXP. I repointed the entry in the get_deps script to use NXP MCU repo. The existing current code couldn't build as the MCUXpresso SDK was old.

  • For now, I p...
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: usbh-attach-debounce
fallow birchBOT
#

Describe the PR
usbh skip attach/remove event on the same roothub port while in debouncing delay. For hub since we don't poll the interrupt endpoint before debouncing, it should be good enough
remove the old logic detecting duplicated attach event, which should be filtered by the new debouncing.
remove dwc2 debouncing logic (which is now is done at usbh layer)

fallow birchBOT
#

@hathach

FYI: This is the PR for the NXP MCX work. It points to the upstream repo (and I added another board). It is the 1st step before added more mcx support

Also, the codespell keeps failing on the github ci. There is a driver in the upstream nxp repo with some spelling mistakes. Since the ci does a clone of that repo I am not sure how to bypass it. The .codespellrc say to ignore the hw.mcu folder but it doesn't look like the ci system is following it.

Lastly, there i...

fallow birchBOT
fallow birchBOT
#

@hathach

FYI: This is the PR for the NXP MCX work. It points to the upstream repo (and I added another board). It is the 1st step before addin more mcx support

The codespell keeps failing on the github ci. There is a driver in the upstream nxp repo with some spelling mistakes. Since the ci does a clone of that repo I am not sure how to bypass it. The .codespellrc say to ignore the hw/mcu folder but it doesn't look like the ci system is following it.

codespell faailed with b...

fallow birchBOT
#

Operating System

Windows 10

Board

STM32F427VIT6 demo board

Firmware

tinyusb_min_struct.zip
we pulled the code from your master branch on Apr 4, 2025.

What happened ?

Tested plaftform:
STM32F427VIT6๏ผŒUSB-FS(PA11/PA12), FS Mode, Host
HUB IC: CH334P
Mouse: Logitech G502(set to 1000hz and 500hz)

issue 1:
tested board: STM32F427VIT6 -> CH334P(USB HUB) -> HID MOUSE(1000hz)

What happened:
po...

fallow birchBOT
fallow birchBOT
#

Related area

I would like to have tinyUSB support USB Host on ESP32-P4

Hardware specification

ESP32-P4

Is your feature request related to a problem?

ESP-IDF provide is own usb host stack but it only support HS with no STT support for FS or LS device connected on HUB.

It would be benefical if tinyusb support esp32p4 as tinyusb support LS FS and HS device on hub.

Describe the solution you'd like

Add host support for the P4, and ideally an example.

I have checked e...

fallow birchBOT
fallow birchBOT
#

TinyUSB does not provide any locking means to protect the DCD variables. This can lead to race conditions when the user is trying to submit a transfer while the device is being disconnected. This can cause the device to be in an inconsistent state, leading to a crash or undefined behavior.

This commit adds a spin-lock to protect the DCD variables during device disconnect.

fallow birchBOT
#

Flyby comment: This has been sitting for over a year. Would an additional reviewer help? Is there some test suite it needs to pass? Would someone updating it to $head help? What would it take to get unstuck? (I have extensive serial tty and USB experience, albeit not with this code. I may be uninvolved in the project, but I can back up running my mouth as a bystander. :-)

fallow birchBOT
#

Operating System

Linux

Board

Raspberry Pi Pico RP2040

Firmware

examples/device/audio_test

What happened ?

I can't get any of the audio examples to work on Raspberry Pi Pico RP2040 platform connected to the Linux (Debian 12) host. I expected the board LED to start blinking and the audio device to appear after connecting the board to the host. However, the board hangs almost immediately after connection, the LED randomly remains on or off, new audio device does not appear...

fallow birchBOT
#

Would an additional reviewer help? Is there some test suite it needs to pass? Would someone updating it to $head help? What would it take to get unstuck? (I have extensive serial tty and USB experience, albeit not with this code. I may be uninvolved in the project, but I can back up running my mouth as a bystander. :-)

More reviewers will definitely help especially for large PR like this one. @hathach spends most time for Adafruit, I've some free time after work but I'm much less famili...

fallow birchBOT
#
[hathach/tinyusb] New branch created: ci_vbus
fallow birchBOT
#

FWIW, I picked through it last night. (GitHub kept crashing while reviewing it, including during my review submission, which I've just retriggered.) The actual changes are pretty small and are surely non-contentious.

This PR looks large because it takes the sin of changing C comments to C++, reformatting, moving code (the main contributor to the size of this being so large as to blow up github's web review), and actual development all in one PR. After I realized that, I quit fussing abo...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Board

STM32WB55

Firmware

Master branch with following examples:

examples/device/uac2_headset
examples/device/audio_test
examples/device/uac2_speaker_fb

What happened ?

Recently I tried to run audio examples on my dev board STM32WB55 and figured out that host is unable to enumerate the device properly. I checked previous versions of the library and figure out that on tag 0.16.0 for audio_test example problem don't exist so I went through changes i...

fallow birchBOT
#
[hathach/tinyusb] New branch created: fix-sigma-mouse-multiple-attach
fallow birchBOT
#

Describe the PR
fix #3073 occured with https://www.adafruit.com/product/2025. The mouse is sensible with physical connection. It got reset easily even though SE0 is not hold long enough and generate a few attach event (without detach event). The device itself actually got reset and need to go through the whole enumeration. The solution is forcing removal of the device with the same bus info (rhport, hub addr, hub port) before SET_ADDR.

Also include other chores and hub clean up as well

fallow birchBOT
#

Describe the PR
This PR add support for vendor-spicific command messages to the usbtmc_device

Additional context
Bevore messages with MsgID = REQUEST_VENDOR_SPECIFIC_IN and VENDOR_SPECIFIC_OUT where ignored. Now the vendor_specific messages are handled similar to normal ones, except that the MsgId is set to REQUEST_DEV_DEP_MSG_IN for the response of vendor-specific commands

fallow birchBOT
fallow birchBOT
#

Not saying that all out of bounds vulnerabilities are removed from TinyUSB, but the 4 explicitly mentioned in this issue are resolved at this point.

hidd_control_xfer_cb

The min value of the HID buffer size and the request size reduce the vulnerability to just the contents of the HID buffer:
https://github.com/hathach/tinyusb/blob/542e5b4550a01d034b78308d77c408ed89427513/src/class/hid/hid_device.c#L301-L323

Similar fix:
https://github.com/hathach/tinyusb/blob/542e5b45...

fallow birchBOT
#

I had looked at other DFU's at the time, as my company had a nonstandard DFU tool as well that had custom extensions.

From what I saw, DFU 1.1a is quite popular, given how popular ST is as a platform, but DFU 1.1a, is more like DFU 2.0, as it is not compatible with DFU 1.1 devices. The main problematic part is the overloading of DFU_DNLOAD and DFU_UPLOAD. Additionally, many of their custom commands are for specific bootloaders, and thus they have many different versions.

It just so happen...

fallow birchBOT
fallow birchBOT
#

Can you please elaborate a bit more please ?

For most of people USB is a bit complicated, and most people on esp32.com argue that tinyusb do not support host mode on the P4. (all idf exemples with tinyusb are for usb device only, the host examples are made with the espressif host stack ( which is limited, and do not support LS ans FS device on a FS HUB)).

There seems to be a discrepancy between the TinyUSB documentation and the advice provided on the ESP32 forum. I saw on the main page o...

fallow birchBOT
#

Hi @RoxerRN ,

all idf exemples with tinyusb are for usb device only

In esp-idf we use the tinyUSB for device examples only, as we don't have our own device stack. But that doesn't mean, that tinyUSB doesn't support host stack.

host examples are made with the espressif host stack ( which is limited, and do not support LS ans FS device on a FS HUB)

Currently, the limitation for Full-speed USB peripheral was solved (https://github.com/espressif/esp-idf/issues/15683) and now there is a ...

fallow birchBOT
#

Operating System

Linux

Board

rp2040

Firmware

webusb_serial example in picosdk_v2.1.0 compiled with LOG=2
Developement setup: ubuntu24.04 host computer, Windows10 guest in virtualbox.

What happened ?

Enumeration fails when usb device is assigned to virtualbox guest.

How to reproduce ?

Once the device get connected to the host computer it enumerates as normal device accessible from host applications. Now assigning the device to virtualbox guest system the enumeratio...

fallow birchBOT
fallow birchBOT
#

Related area

vendor device, documentation

Hardware specification

not specific hardware

Is your feature request related to a problem?

Tinyusb is a great library. However I am wondering if there could be better documentation on the structure? Especially I am confused about the way it is written when trying to implement custom vendor devices. What is the proper way to use endpoint vs endpoint streams? It seems I can use usbd_edpt_xfer, but I do not want to break anything. It see...

fallow birchBOT
#

Hi @roma-jam Thank you very much for your answers,

So, with tinyUSB host stack you are able to attach the Low- or Full-speed devices to USB High-speed peripheral on P4.

I definitely want to give it a try, my board is built this way. I managed to compile TinyUSB with the P4 but I cannot manage to compile family.c because #include "bsp/board_api.h" #include "board.h" are not found. I use idf-esp to compile so I think i cannot use family.cmake and so one.

Do you know the proper way to com...

fallow birchBOT
fallow birchBOT
#

This fixes 2 issues with the parsing of descriptors inside vendord_open().

  1. The code was calcing 'desc_end' as being after the actual end of descriptors due to doing: desc_end = tu_desc_next(desc_itf) + max_len instead of desc_end = desc_itf + max_len.

  2. The code did not handle an interface that finished with non-endpoint descriptors. The code should skip over all descriptors that are part of the interface, but it only skips over endpoint descriptors. So if there are othe...

fallow birchBOT
fallow birchBOT
#

Hi,

The code was calcing 'desc_end' as being after the actual end of descriptors due to doing: desc_end = tu_desc_next(desc_itf) + max_len instead of desc_end = desc_itf + max_len.

That's not true, const uint8_t* desc_end = (uint8_t const*)desc_itf + max_len;, actually fiex by #3020

ah ok - i was working with an older version of the code, so when i copied it into the current version of the code i must have missed that

fallow birchBOT
#

I think a cleaner fix is simplify the loop, what do you think ?


  while (desc_end - p_desc > 0) {
    if (TUSB_DESC_ENDPOINT == tu_desc_type(p_desc)) {
      const tusb_desc_endpoint_t* desc_ep = (const tusb_desc_endpoint_t*) p_desc;
      TU_ASSERT(usbd_edpt_open(rhport, desc_ep));

      if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN) {
        tu_edpt_stream_open(&p_vendor->tx.stream, desc_ep);
        tud_vendor_n_write_flush((uint8_t)(p_vendor - _vendord_itf)...
fallow birchBOT
#

Each call to vendord_open() should "consume" all descriptors until the next interface descriptor, or until the end of all descriptors. So you need to check for whether the "next" descriptor is an interface descriptor, and if it is then you need to return at that point. So a check for desc type being interface needs to be added to your proposed loop.

You are right. should be while (TUSB_DESC_INTERFACE != tu_desc_type(p_desc) && (desc_end - p_desc > 0)) {

fallow birchBOT
#

Operating System

Linux

Board

STM32F746 Discovery

Firmware

examples/device/midi_rx

What happened ?

I get this error when I try to compile the host/midi_rx example using GCC 14.1

[...]/tinyusb/src/host/usbh.c: In function 'process_enumeration':
[...]/tinyusb/src/host/usbh.c:1529:11: error: 'BIT_FIELD_REF ' may be used uninitialized [-Werror=maybe-uninitialized]
 1529 |       if (!port_status.status.connection) {
      |           ^

I used `CFLAGS += -Wno-error=m...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

I can confirm that DCD_EVENT_UNPLUGGED is not triggered for STM32F0 (uses FSDEV instead of DWC2). I've tried some of the hacks above unsuccessfully.

Polling tud_connected() is not really reliable as sometimes when the cable is disconnected, still returns true.
STM32F0 doesn't have a VBUS, so I guess my only chance here is to change my hardware and manually read voltage from the USB connection.

fallow birchBOT
#

Operating System

Linux

Board

raspberry pi pico (rp2040)

Firmware

Just simpliest test:

#include 
int main() {
  stdio_init_all();
  uint32_t cnt = 0;
  while (1) stdio_printf(format: "!!! %d\n", cnt++);
}

What happened ?

When compiled by clang with LTO enabled, it outputs exactly one line per second.
Interchangingprintf and stdio_printf makes no difference.
std::cout << "!!! " << cnt++ << std::endl; outputs exactly one symbol per second
With LTO disabl...

fallow birchBOT
#
[hathach/tinyusb] New branch created: bump-gcc14
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

can we use the osal_mutex instead https://github.com/hathach/tinyusb/blob/master/src/osal/osal_freertos.h#L152, there is an osal API for that ?

I decided for critical section instead of OS primitives because many of these sections are in ISRs

  • ISR must not block. So calling osal_mutex_lock() is not acceptable
  • With critical section we get minimal latency and overhead
  • Intention and simplicity: We really just need an atomic access to xfer_ctl_t.
fallow birchBOT
fallow birchBOT
#

Since DMA can't access DTCM on H7 and H7RS. Might it be worth also defining the idiomatic ST noncacheable_buffer region in here?

It could be grabbed from symbols something like:

extern int __NONCACHEABLEBUFFER_BEGIN;
extern int __NONCACHEABLEBUFFER_END;

uint32_t *start = (uint32_t*)&__NONCACHEABLEBUFFER_BEGIN;
uint32_t *end = (uint32_t*)&__NONCACHEABLEBUFFER_END;

Since noncacheable_buffer should be set as non-cacheable in MPU configuration, I imagine the MPU probabl...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Been testing this on NUCLEO-H7S3L8 along with some of your DWC2 changes in separate PRs.

I left some review comments on those other PRs, just minor things, but I wanted to also comment on this one and say thank you so much for the great work on H7S3L8 and DWC2.

With a few tweaks for my specific requirements, it's working flawlessly and my basic CDC HS single endpoint setup is already hitting 18MB/s in a super quick benchmark task I wrote, with the only real optimisation I've had to do b...

fallow birchBOT
#

Hi Roma,

It is my topic on the esp32 forum you mentioned, as explained in the post I actually managed to compile tinyusb with esp-idf. It works like a charm and in the end it's not so difficult when you understand how to compile it with the module provided by espressif.

I don't know if the post is sufficient to help others to get it compile on the p4, or if it's can be useful if I provide somewhere a full working example ? ( if you know a good place to store such example I can provide a sa...

fallow birchBOT
fallow birchBOT
#

I looked into src/common/tusb_common.h and the use of stdio.h.

It seems that stdio.h is included unconditionally, but from reviewing the codebase, most of TinyUSB's core functionality does not actually depend on it. The only potential usages appear to be in debugging macros (e.g., TU_ASSERT, TU_VERIFY) which rely on tu_printf() when CFG_TUSB_DEBUG is enabled.

To improve compatibility with custom embedded environments โ€” especially those providing their own lightweight `printf(...

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: follow-up-pr3118
fallow birchBOT
#
[hathach/tinyusb] New branch created: fix/dcd_race_condition
fallow birchBOT
#

Out of interest, have you happened to run your benchmarks ("cdc_task2" and such from https://github.com/hathach/tinyusb/issues/920#issuecomment-867994863) on this board?

I am primarily interested in the throughput I can get sending data from the board as device to the PC as host. I copied over your functions to expose the FIFOs and wrote something like:

static void USB_CDC_Benchmark2(void* params)
{
  (void) params;

  // 1) prepare ramp-data block
# if 0
//  static uint8_t...
fallow birchBOT
fallow birchBOT
#

Although I'm surprised it can even access the regular cached memory at all, is it first being memcopied into TUSB's FIFO (which is in noncacheable buffer), and then via DMA from that point onwards?

Yes cdc driver always copy the data so the source data variable doesn't need to be static. If you need more throughput you can copy the driver (or vendor class driver) and make adjustments then register it as a custom driver.
Here is an example:
https://github.com/kkitayam/akiprobe/blob/c3...

fallow birchBOT
#

Describe the PR

Thank you for this awesome project, very enjoyable to work with!

I've been integrating TinyUSB using custom firmware on the STM32F723E-DISCOVERY board and got stuck in reset_core when initializing the HS port. Waiting 2ms after PLL enablement fixes this issue.

Additional context

The solution for this was already discovered in https://github.com/hathach/tinyusb/issues/2074#issuecomment-2597894247, where the CubeHAL waits 2ms, since there's no USB_HS_PHYC_P...

fallow birchBOT
#

I think the same race condition can happen on single core MCUs too.
For example

  1. Code from main app is modifying xfer_ctl_t and is interrupted
  2. Content of xfer_ctl_t is now inconsistent
  3. The ISR modifies xfer_ctl_t again
  4. Main app continues

In steps 3 and 4 we can access inconsistent xfer_ctl_t which can lead to undefined behavior (division by zero in the cases I've seen)

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Hi, I'm having some issues testing the features from https://github.com/ennebi/tinyusb/tree/mtp, copying or creating files in Windows 10 doesn't work properly.
I printed some logs and found that the mtpd_handle_cmd_send_object_info function was called when the file was created, and the mtpd_handle_dto_send_object_info function was not called to write after that.
How do I solve the problem? These are my test environments:
Hardware: RP2040 SDK2.1.1

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: max3421-use-spinlock
fallow birchBOT
#

I printed some logs and found that the mtpd_handle_cmd_send_object_info function was called when the file was created, and the mtpd_handle_dto_send_object_info function was not called to write after that.<

Hi @diancity025.
Is the example code (read only FS) working?

Can you check if the bulk endpoints are numbered and opened correctly in the initialization sequence? The command phase is supposed to be followed by a data phase on bulk EP, unless there is an issue with the sequence.
...

fallow birchBOT
#

this should be fixed by current latest, please pull and try again. tested with

arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 14.2.1 20241119
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

fallow birchBOT
#

Ah, wellโ€ฆ at first I also couldn't reproduce this issue with the tinyusb examples, until I power cycled the board:

cd tinyusb
python3 tools/get_deps.py stm32f7
cd examples/device/cdc_msc
rm -rf _build; \
    make BOARD=stm32f723disco RHPORT_DEVICE=1 LOG=2 all && \
    openocd -f board/stm32f7discovery.cfg -c "program _build/stm32f723disco/cdc_msc.elf verify reset exit"

*power cycle board*

picocom --imap lfcrlf -b 115200 /dev/tty.usbmodem103

*reset board*...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Related area

UAC2

Hardware specification

Any

Is your feature request related to a problem?

I'd like to make some major changes to UAC2 class:

Describe the solution you'd like

  • Remove support FIFO

The UAC code is pretty complex and difficult for new comers to contribute. An obvious way to simplify is to remove support FIFO as the only use is channel muxing/demuxing, which can be (should be IMO) done in application layer.
At first it was planned to allow decoding for...

fallow birchBOT
fallow birchBOT
#

In general I like the idea, due to strict timing requirements, keeping isochronous in ISR would make sense.

Fortunately the application I've been developing had almost no other transfers in play so putting tinyUSB on highest prio task in the system was enough to keep the audio running smooth.

What I came across is that with multi-channel(up to 32ch 32bit) probably host is not capable of filling the transfers properly anymore as I've seen discontinuity in audio data without any under/over r...

fallow birchBOT
fallow birchBOT
#

Operating System

Windows 10

Commit SHA

Not sure what "Commit SHA" means..

Board

ESP32S3 Dev Module

Firmware

Latest USB Core installed and latest version of the TinyUSB library.
USB Mode set to "USB-OTG (TinyUSB)"
USB DFU on Boot "Enabled"
Flash Size "8MB 64Mb)"
Partition Scheme "8M with Spiffs (3Mb APP / 1.5MB SPIFFS)"

What happened ?

Flashed the "midi_test.ino" example but the ESP32-S3 doesn't appear on the PC as a Midi device, but as "COM 17 (ESP32 Family Devic...

fallow birchBOT
fallow birchBOT
#

Summary

NOTE: This is a DRAFT PR - the code has not yet been tested on hardware.

This PR adds the ability to control the link state of USB NCM (Network Control Model) interfaces, allowing applications to simulate "ethernet cable unplugged/plugged" events.

Changes

Core NCM Driver ():

  • Add state tracking to NCM interface
  • Modify notification system to support dynamic link state changes
  • Add function to send link state notifications
  • Change hardcoded "connected" notific...
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: update-max32
fallow birchBOT
fallow birchBOT
#

That would be great, I also think the audio driver is a bit complicated at the moment. The example's descritpor can also be simplified by using app-level struct like uvc https://github.com/hathach/tinyusb/blob/master/examples/device/video_capture/src/usb_descriptors.c#L174 . I think both audio and video are too complicated for pre-defined macros, maybe we can have macro with simplest form. I plan to do the same with audio examples but haven't manage the time yet. And yes, isochronous can use ...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Hi, developer of Pico-ASHA here.

I know it's a little off-topic, but I was wondering if there would be an opportunity to provide basic UAC1 support? Many applications don't require anything more than basic (at max) 24 bit 96 KHz stereo audio, so UAC2 is a bit overkill. For example, Pico-ASHA only requires 16-bit 16KHz stereo audio.

The downsides of UAC2 is compatibility. While UAC2 works on modern Windows/Mac/Linux systems, the chances of it working el...

fallow birchBOT
#

I know it's a little off-topic, but I was wondering if there would be an opportunity to provide basic UAC1 support?

There are already request to support UAC1, mainly because feedback compatibility issue between Windows and OS X. However UAC1 and UAC2 descriptors and controls are pretty different, it will be a mess to support both of them in one driver.

fallow birchBOT
#

Describe the PR

This PR adds support for the STM32N6, and BSP for the STM32N657 Nucleo Board.

Additional context

  • This has been heavily based off @HiFiPhile's STM32H7RSxx port. The TCPP0203 code is directly copied from their port.
  • Currently the FreeRTOS examples do not run. I haven't had the time to actually analyse what isn't working, and I probably won't get the time as I will be using Zephyr.
  • USB Host ha...
fallow birchBOT
#

I've added initial support for the WCH CH32X035 MCU to the TinyUSB library.

Here's a summary of the key changes:

  1. Core TinyUSB Modifications:
    • I added OPT_MCU_CH32X035 to src/tusb_option.h.
    • I added CH32X035-specific definitions (e.g., TUP_USBIP_WCH_USBFS,
      TUP_DCD_ENDPOINT_MAX) to src/common/tusb_mcu.h.
    • I created a skeleton register header src/portable/wch/ch32x035_usbfs_reg.h.
      You'll need to manually populate this file with ...
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Linux

Commit SHA

86ad6e56c

Board

Raspberry Pi Pico

Firmware

uac2_headset

What happened ?

build this project. sound card did not appear. I work under Ubuntu.
https://github.com/hathach/tinyusb/tree/master/examples/device/uac2_headset

alsamixer shows nothing. :(

[ 184.366820] usb 1-4: Product: TinyUSB headset
[ 184.366822] usb 1-4: Manufacturer: TinyUSB
[ 184.366824] usb 1-4: SerialNumber: E6605838835DC22F
[ 184.453661] mc: Linux media inte...

fallow birchBOT
#

Thank for your PR, it does indeed resolve the ZLP issue in #2632.

However I've some issues on Chrome 136 Windows 10:

  • Disconnect button has no UI update, although sending and receiving is stopped
  • Sometimes ASCII get translated to hex, entering aaaaa returns 6/9/2025, 4:07:29 PM 97,97,97,97,97 on serial console
  • Serial console get stuck on 1st connection, 2nd connection returns Failed to execute 'open' on 'SerialPort': The port is already open., needs to refresh the page on 3...
fallow birchBOT
#

TUH_EPSIZE_BULK_MPS should be set based on TUH_OPT_HIGH_SPEED, not TUD_OPT_HIGH_SPEED

Describe the PR

I'm trying to debug tinyusb a stm32h7 board with a full speed device (TUD) and high speed host (TUH).
The high speed CDC code doesn't work small 64-byte buffers.
My code is not yet working, but I think this is an obvious fix.

fallow birchBOT
#

@fcooperti, please test my last commit.

After checking kernel source code, the access width change is not limited to the latest operation, for example 32b+16b+8b is allowed for 7 bytes I/O (not limited to 3*16b+8b).

https://github.com/torvalds/linux/blob/19272b37aa4f83ca52bdf9c16d5d81bdd1354494/drivers/usb/musb/musb_core.c#L329

I've updated the logic to make access width limit only applied to wrapped fifo part while keeping normal transfer and linear fifo part untouched.

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

That's an odd one.
I will try to reproduce that on the weekend.
Did this happen with the stock webusb_serial example?

Yeah I'm not tricking you :) Tested on STM32L053 and STM32F723.

I just recorded a video demonstration on my home PC with Chrome 137 Windows 10, the symptome is a little different

  • At 00:10 when I connect to serial, the input box is grayed out until something is received
  • For the hex ...
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: refactor-maxim-bsp
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Hi @roundby, thanks very much for this!

I have encountered the same thing as @diancity025. I've extended the read-only example to allow adding new objects to the list (while ignoring the file contents for now). Without @diancity025's changes, I just get a progress bar stuck at 0% while copying a file to the device. With their changes everything works as expected. I'm running this on an RP2350 connected to a Windows machine (it's also sort of working on Linux using android-file-transfer, an...

fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Windows 11

Commit SHA

Version bundled in framework-arduinoespressif32 version 3.20017.241212+sha.dcc1105b, "a0e5626bc" mentioned in docs

Board

Custom ESP32-S2 design, wifi inactive

Firmware

Custom firmware in PlatformIO env, sending 2x 64-byte raw HID packets every second. I haven't created a new minimal test case project yet, but I will try do so shortly.

What happened ?

Periodic HID output reports (from device to host PC) are sent in sets of 2, ...

fallow birchBOT
#

Hi @marchingband,

there is a big refactoring in esp_tinyusb component on the way: https://github.com/espressif/esp-usb/pull/178

It will unlock the possibility to define user behavior on the tud mount/unmount callbacks as well as use the previous default internal logic (mount/umount on the callbacks).

With the already available option to re-install tinyusb driver from esp_tinyusb component, this could help you to achieve the initial goal:

it needs to change into a MSC device for a ...

fallow birchBOT
fallow birchBOT
#

@hathach I just rebased on master and did some cleanup. CFG_TUD_MEM_ALIGN introduce a breaking change, but without this I don't know how to extract numeric value.

How about adding the CFG_TUD_MEM_ALIGN_BYTE/SIZE instead, CFG_TUD_MEM_ALIGN if not defined will be defined using that. That way people will have time to migrate (or just leave it if they don't need it). Btw, why you need the numeric value (haven't do review yet).

#

Operating System

Others

Commit SHA

e95973d3462cdacd165a4057632d46248ded7b8a

Board

GP2040-CE Development Kit (RP2040 with USB-Host Connected to Pins 23/24)

Firmware

Current main compilation of GP2040-CE from 'main' of https://github.com/OpenStickCommunity/GP2040-CE/

UF2 is flashed to an RP2040 based development board for GP2040-CE

What happened ?

After updating our project updated to Pico SDK 2.1.1, I am getting multiple failures in the USB host code using the lat...

fallow birchBOT
fallow birchBOT
#

Please open the issue in corresponding repo, Complete but not empty: 0/6 or TUSB:DCD is not covered here.

I'm more than happy to do this, but can you point me towards the right repo? I feel dumb asking, but this was my best guess based on my understanding of the TinyUSB implementation for the ESP32/Arduino framework, and the log tag found here:

https://github.com/hathach/tinyusb/blob/e95973d3462cdacd165a4057632d46248ded7b8a/src/portable/espressif/esp32sx/dcd_esp32sx.c#L76

fallow birchBOT
#

Describe the PR
2nd part of #3133, ISO transfer management is moved into USB ISR to avoid timing conflict with other classes.

Tested on NUCLEO-H7S3L8 and NUCLEO-C071RB with all audio examples.

Demo

  1. Take audio_test_freertos example, add some processing delay to volume change request
diff --git a/examples/device/audio_test_freertos/src/main.c b/examples/device/audio_test_freertos/src/main.c
index 0a6cdfd4f..67d56b640 100644
--- a/examples/device/audio_test_...
fallow birchBOT
#

I was trying to implement a minimal USB HCI bridge driver for a rtl8761 based Bluetooth 5.3 Dongle and use with BTStack. I surprisingly worked well until I realized that the ACL endpoints (especially Bulk In transfers) are limited to 64KB/s, while playing with the a2dp sink demo. I scratched my head for days as it worked perfectly with libusb port on linux PC, finally got my answers in here.

This PR works great with the MSC demos but as the HCI driver required a lot of control and interrup...

fallow birchBOT
solemn crest
#

Im running the MIDI sketch on my ESP32-S3, but I can't get the device to show up on my Mac or PC. Attached are my settings.

Any ideas what could be the issue? I saw folks had similar issues on Github, but i don't see a definitive solution.

Im running 3.2.0 of the Espressif board

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

@hathach
I try to get my head around this.

Can a simple matrix explain the possibly combinations in a system with multiple USB ports ?
Also the dual-role, possibilities if you tear down the interface completely.
With USB-C there is also the CC pins and some chips have CC-pin-handling built in, and for others we need to use external chip over I2C, is there some docs on dealing with DRD switching ?
I see there is a way to assign a pin for binary identification of the VBUS power.
I would also ...

fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: update-buildsystem
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

Operating System

Others

Commit SHA

latest git pull on pico-sdk v 2.1.1

Board

RPi pico (RP2040) - pico-sdk 2.1.1 on vscode pico plugin

Firmware

when used in the midi2usbhost project (https://github.com/rppicomidi/midi2usbhost) simple MIDI devices like the Korg NanoKontrol2 are discovered correctly, but Line6 Pod Go is not discovered. usb descriptor and debug output from tinyUSB lib attached below.

What happened ?

when used in the midi2usbhost project (https://githu...

fallow birchBOT
fallow birchBOT
#

When a device it supports both Audio Streaming and MIDI Streaming, the TinyUSB driver expect it to publish descriptors like this:

  1. Audio Control
  2. MIDI Streaming
  3. Audio Streaming
    Lines 225-228 of the TinyUSB MIDI Host driver stops parsing the descriptor if the the MIDI Streaming descriptor does not immediately follow the Audio Control descriptor.

The POD Go device descriptor attached to this issue publishes descriptors like this:

  1. Audio Control
  2. Audio Streaming
  3. MIDI Streaming
    Th...
fallow birchBOT
fallow birchBOT
fallow birchBOT
#

My idea is to control DCache alignment not only by CFG_TUD_MEM_DCACHE_ENABLE but by the necessity:

  • I set CFG_TUD_MEM_DCACHE_ENABLE_DEFAULT=1 for MCUs with internal cache so CFG_TUD_MEM_DCACHE_ENABLE doesn't need to be set by the user, especially during family migration it could be forgot.

  • DCache alignment is only needed when DMA is enabled, without TUD_EPBUF_DCACHE_ALIGNED it will be aligned by default even not needed.

  • User imposed alignment CFG_TUD_MEM_ALIGN always ...

fallow birchBOT
fallow birchBOT
#

Hi @diancity025.
Thank you for your tests. I checked directly on a RBPI Pico2 and investigated the issue. It is caused by the way mtpd_xfer_cb is implemented, as it was not expecting xferred_bytes to be more than CFG_MTP_EP_SIZE, but the call to usbd_edpt_xfer was requiring the whole remaining data size and the library does not enforce a limit if the hardware supports a larger endpoint buffer.

We tested the fix together with some corrections along with other refinements, a better e...

fallow birchBOT
#

Hi @f-hoepfinger-hr-agrartechnik

littlefs must work for us, to be useful.
i guess it will be hard with littlefs. easier to make 1 FAT Partition, and copy the stuff over to littlefs later.

Lately, I am replying to this.

We used this change in an internal test project, specifically designed to expose files from an SPI memory managed by littlefs. I can confirm that this setup is perfectly feasible, though there are some limitations depending on platform constraints.

You can ima...

fallow birchBOT
#

Hi @roundby, thanks very much for this!
I recently had an issue where I couldn't store large files when I was using RP2040 to test mtp docking with littlefs, I saved the file handle via the LFS_TYPE_USERATTR attribute of the littlefs file. At the moment it is normal when reading and writing small files. But when I write to a relatively large file (368k), I have the problem that the transfer timeout cannot be completed. Can you help with that? Thank you.
Here are the logs I scraped.

fallow birchBOT
fallow birchBOT
#

perfect, thank you very much for this great PR. Sorry for the delay, I have tested with simple host/device_info and dual/host_info_to_device_cdc and it can enumerate device just well. haven't done more in-depth testing. Any issues can be resolved as follow-up PR later.

I have made some changes

  • always add CFG_TUH_WCH_USBIP_USBFS=1 by default for ch32v20x since that is the only port that support host mode. Manual setting it isn't required.
fallow birchBOT
fallow birchBOT
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: readd-max32666
fallow birchBOT
#
[hathach/tinyusb] New branch created: codex/find-and-fix-a-codebase-bug
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: hil-skip-passed-board-in-rerun
fallow birchBOT
#

@HiFiPhile I think I fixed all the issues. Maybe you can give it one more look. Tell me if there is anything you want changed or a feature that you think is missing.

  • Serial console get stuck on 1st connection, 2nd connection returns Failed to execute 'open' on 'SerialPort': The port is already open., needs to refresh the page on 3rd attempt to make it work

I don't have a windows pc to test. Can you still reproduce that issue? I can set one up to reproduce though if need be.

fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: add-define-build-script
fallow birchBOT
fallow birchBOT
#
[hathach/tinyusb] New branch created: feature/add_tusb_teardown
#

Hi @hathach,

the original idea was to allow the possibility to use pre-defined TUD_OPT_RHPORT or TUH_OPT_RHPORT to teardown the tinyusb and to call the API without any arguments:

tusb_init();
tusb_teardown();

After your changes it is no longer possible, so the idea is to call deinit for the device like this tud_deinit(TUD_OPT_RHPORT), am I right?

#

@hathach ,

tusb_init() should be called with rhport and arguments.

I think that the macros tusb_init() is still available for usage: https://github.com/hathach/tinyusb/blob/master/src/tusb.h#L153

So it is possible to use it to init the tinyusb, which leads to the default call: tusb_rhport_init(0, NULL)

So, either we need to deprecate the macros completely (which would break the backward compatibility) or to provide another macros for tusb_deinit() which when called without...

#

Something like that:

bool tusb_rhport_deinit(uint8_t rhport);

#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
  #define _tusb_deinit_arg0()        tusb_rhport_deinit(0)
#else
  #define _tusb_deinit_arg0()        TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
#endif

#define _tusb_deinit_arg1(_rhport)         tusb_rhport_deinit(_rhport)
#define tusb_deinit(...)                   TU_FUNC_OPTIONAL_ARG(_tusb_deinit_arg1, ...
fallow birchBOT
#

Describe the PR

In some cases, like when implementing a truly read-only MSC disk, the TinyUSB's built-in MSC SCSI commands may need to be overridden.

This is a small, fully backwards-compatible change that adds a new weak callback, tud_msc_scsi_pre_cb. If defined, this callback allows the user code to override also those SCSI commands that TinyUSB handles by default in its static proc_builtin_scsi function.

Additional context

An example how this new callback is need...

fallow birchBOT
#

I pushed another commit here, now changing the sematics slightly. This is needed to make a difference between two cases: the pre-callback wants to fall back to the default behaviour vs. the pre-callback wants to return an error.

This may not be the best way of implementing this, though. So, I presume some careful thought is needed.

And, if this PR is accepted as such, the two commits should probably be squashed together.

fallow birchBOT
#

Hi @f-hoepfinger-hr-agrartechnik

littlefs must work for us, to be useful.
i guess it will be hard with littlefs. easier to make 1 FAT Partition, and copy the stuff over to littlefs later.

Lately, I am replying to this.

We used this change in an internal test project, specifically designed to expose files from an SPI memory managed by littlefs. I can confirm that this setup is perfectly feasible, though there are some limitations depending on platform constraints....

fallow birchBOT
#

Operating System

Others

Commit SHA

current master branch tested on ESP-IDF 5.4

Board

ESP32-P4-Function-EV-Board

Firmware

examples/host/hid_controller

What happened ?

Output transfers on interrupt endpoint fail after several successful transfers.

How to reproduce ?

Just compile standard hid_controller example from tinyusb and attach DualShock 4 controller.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

Typical log with DualShock4 (logging for IN endpoints...

fallow birchBOT
#

Related area

USB PTP Device Class

Hardware specification

esp32s3

Is your feature request related to a problem?

Already has USB MSC device which works. When USB plugged in, storage is unmount from internal and mounted to USB device. It mounts back to ESP internal when USB disconnected. But I have an application which needed to read the files when device USB plugged into USB host. The best protocol id PTP. File system is managing inside the ESP and candle any requests using spi...

fallow birchBOT
#
[hathach/tinyusb] New branch created: msc-inquiry2-cb
fallow birchBOT
fallow birchBOT
#

@AndyDevLat ,

right now I don't think that mixing fifo settings from esp-idf and hcd_dwc2 from tinyusb somehow can help.

But the issue could be related to the way, how we access the resisters.
The one issue was on S3 (yes, not RISC-V, as P4 but stll): https://github.com/hathach/tinyusb/issues/3047#issuecomment-2759331873

Could you check the discussion from the link above and compare the description and the output with your case?

fallow birchBOT
#

In my case device enumeration is always succesful, so no problem with control transfers. Only interupt OUT transfers exhibit problems. Also it does not matter if DMA is enabled or not, so it seems issue is a bit different, but maybe it is because of different architecture. If it is related to some registers or compilation issues, as mentioned in the above post, wouldn't it always fail immediately and not after some time? To me it looks more like some FIFO overflow or whatever, maybe somethin...

fallow birchBOT
#

Describe the PR
Replace #3115 since it can't be pushed

This PR add support for vendor-spicific command messages to the usbtmc_device

Additional context
Bevore messages with MsgID = REQUEST_VENDOR_SPECIFIC_IN and VENDOR_SPECIFIC_OUT where ignored. Now the vendor_specific messages are handled similar to normal ones, except that the MsgId is set to REQUEST_DEV_DEP_MSG_IN for the response of vendor-specific commands

fallow birchBOT
#

Thank you for your update, but it didn't get better in my side.

With auto connect checked

  • Once I tape something it returns Attempting to auto-reconnect... then Send error: Failed to execute 'transferOut' on 'USBDevice': The specified endpoint is not part of a claimed and selected alternate interface.
  • Any following sends are failed
  • Date receiving works

https://github.com/user-attachments/assets/845cafd2-ac05-4bf5-9a6d-3023c8300144

With auto connect unchecked

...