#tinyusb
1 messages ยท Page 17 of 1
Describe the PR
1st part of #926.
- Add xfer_fifo support, fifo must aligned to 4k boundary and size must be multiple of 4k.
- Add dcd_edpt_close and iso xfer.
[hathach/tinyusb] Pull request opened: #1063 UAC2: Add ring buffer support for dcd\_transdimension\.
Describe the PR
#2nd part of #926
- UAC2: Add ring buffer support for dcd_transdimension.
- Add ring buffer ON/OFF switch.
Maybe we can use a better name than TUD_AUDIO_PREFER_RING_BUFFER.
Describe the PR
3rd part of #926
- Add xfer_fifo to CDC class like UAC2.
- Export tu_fifo_buffer_info_t for DMA support.
tud_cdc_rx_wanted_cb is WIP, it needs backward write pointer.
This commit broke my k32l2 port. The drive does not appear in windows.
@nxf58843 do you happen to know which specific changes that break the K32L2 port. Any info would help to narrow the issue. Each port can be a bit different. I am on the way to test each port compliance, will test with Freescale Kinetic sooner or later.
[hathach/tinyusb] New branch created: rp2040\-compliance
Describe the PR
update dcd rp2040 to pass all compliance test mentioned in #1059
please also pull and try master, there is a few followup PRs to get other often used mcu to pass the test as well. Which may help with K32L2. thanks
I started with master (on Aug 31) and tracked it down to this commit where it broke. I have not root caused the specific change that did it yet. I don't know that there has been much evaluation with the khci port yet. I still need to check KL25Z.
Hi there @kasjer and @hathach! I'm excited to see tinyusb has a definition for the STM32L4R5nucleo board under hw/bsp. Can anyone confirm that they have seen this board function correctly with the cdc_msc example? Our board is very similar to this one, but I am not able to get the usb functioning. It would be great to know if this board is expected to work or not with tinyusb.
If not, any pointers greatly appreciated before I go diving in!
there is yet another new update, please try it out, i may fix this issue.
No it does not work, tinyusb does not support L4 just yet. that is why this thread is still open.
Operating System
RaspberryPi OS
Board
RP2040
Firmware
examples/host/hid_controller
What happened ?
assertion "ep->active" failed: file "/path/to/tinyusb/src/portable/raspberrypi/rp2040/hcd_rp2040.c", line 164, function: hw_trans_complete
Workaround: comment out the assert [dirty]
How to reproduce ?
mkdir ~/tmp ; cd ~/tmpcmake -DFAMILY=rp2040 -DCMAKE_BUILD_TYPE=Debug /path/to/tinyusb/examples/host/hid_controller/make- Attach
minicom(or s...
Operating System
Linux
Board
RP2040
Firmware
/examples/host/hid_controller
What happened ?
hid_controller does not build ...because /examples/host/CMakeLists.txt lacks the line family_add_subdirectory(hid_controller)
How to reproduce ?
mkdir ~/tmp ; cd ~/tmpcmake -DFAMILY=rp2040 /path/to/tinyusb/examples
...note that hid_controller is not built
Debug Log
n/a
Screenshots
No response
Thank you for confirming that. I will dig in deeper today!
since you already know how to fix it, would you mind making an PR to fix this ?
This (?obviously?) does not happen with debug DISabled.
what do you mean by this ? Can you confirm if the issue occur when debug is disabled ??
BTW, hid controller is for mounting game controller only, and currently only tested with Sony PS4. If you want to test keyboard please use the cdc_msc_hid example.
This (?obviously?) does not happen with debug DISabled.
what do you mean by this ? Can you confirm if the issue occur when debug is disabled ??
If you do NOT use -DCMAKE_BUILD_TYPE=Debug then the HID code (seemingly) works well... You can connect/disconnect a keyboard and the PID/VID are shown as expected ...Enable debug, and the driver just crashes :/
BTW, hid controller is for mounting game controller only, and currently only tested with Sony PS4. If you want to test keyb...
I am trying to write two new class host drivers (by reverse engineering the existing driver code) ...When I have done that, I will need to learn how Git PRs work ...So my answer is: Yes, but give me time ;)
@hathach The same issue occurs on Spresense with this commit.
Describe the PR
After https://github.com/hathach/tinyusb/commit/be98cd56c7ac3bbd8b8762e42f752c9cec7c92f0, MSC on Spresense stopped working. This was because the if condition (p_cbw->total_bytes > p_msc->xferred_len) was true: https://github.com/hathach/tinyusb/blob/831a45f14bcc833d536cab39bef61cc67533fa73/src/class/msc/msc_device.c#L604
I think p_msc->total_len should be here, not p_cbw->total_bytes.
I made a PR #1070 to fix it on Spresense.
Describe the PR
Add IAR project connection files, which can be used to automatically import tusb stack & example into IAR project.
Since SDKs in hw\mcu only have GCC's cstartup file (and there are too much MCUs for me...), a buildable IAR project need to be created before import tusb.
Example's source files (main.c, tusb_config.h, etc.) will be copied to project's directory, os they can be edited safely.
tools/iar.ipcf only contains the stack, *.ipcf inside examples ...
I've updated code snippet. Now it should be C compatible and also not dependent on the rest of my code.
Just use examples/device/cdc_dual_ports/src/main.c example and replace main function block with that snippet.
Adjust coreFrequency according to your MCU frequency.
it is not an bug, it is due to print log in the ISR with slow channel like uart will mess up the usb timing. You could try to reduce the debug level CFG_TUSB_DEBUG to 2 or 1 instead of 3.
Please attached your example folder here, that makes sure we are testing the same piece of code.
yeah, spot-on, thank you, the naming is too similar, I really need to rename these
thank you @kamtom480 for the fix, I am about to testing out all the ports. It is my bad since the naming variable is similar (got to rename them).
@kamtom480 hmm, I take this back, seem like i really meant to use total_bytes according to comment there. Please give me time to pull out Spresense to test.
This is great and I am sure IAR user will find it helpful. However, as you mentioned ipcf only add source files as they appear in the actual file system and not buildable. Therefore it is not too useful IMHO.
To be honest, I have a mixed feeling about adding these file. I don't use IAR at all therefore cannot and won't be able to maintain these project file in the future. My experience with IDE is that they are super nice with specific project on specific MCUs with all of its great deb...
@kamtom480 the stall condition (before PR logic) is indeed correct here, according to the MSC BOT 13 cases. this particular if is for case 5 when Host expect more data than Device could send. In this particular case is Read Format Capacity command, where host expect 252 bytes, and we only send 12 bytes in response. Device really need to send an STALL first, then resume to send SCSI status afterwards when received clearing stall request https://github.com/hathach/tinyusb/blob/master/src/class/...
@kamtom480 hmm seem like the dcd didn't notice the stack when setup packet of the next CLEAR STALL request. Therefore the msc couldn't continue. I haven't looked too closed at dcd_cxd56.c so far, I will try to see if I could get any clues
Here is the log level 2 from cp210x from make BOARD=spresense LOG=2
USBD Xfer Complete on EP 05 with 31 bytes
MSC xfer callback ...
I see spresense has its own usb stack under nuttx system, and it Doesn't forward the Clear Feature (Endpoint) request toward tinyusb. https://github.com/sonydevworld/spresense-nuttx/blob/2ffe58b6dcb8ca7e83a4d2acec5622276f7c6f5d/arch/arm/src/cxd56xx/cxd56_usbdev.c#L1367
It is quite troublesome, since most of the msc recover is based on the Clear Stall request. I will try to figure an way. In general the setup seem to be conditionally forwards (most but not all), and Status stage can als...
Describe the PR
It adds the first DualShock4 revision, Hori FC4 and ASW Xrd limited edition controller vid/pid combinations to is_sony_ds4 after having confirmed them working with the current example code (when in ps4 mode).
This may help others to see that at least adding different ps4 compatible devices is rather trivial.
You can also add Hori PS4 mini (wired), SKU PS4-099U, with ID 0f0d:00ee (tested by me)
look good, thank you. I didn't know There are other controller with compatible report layout as DS4
You can also add Hori PS4 mini (wired), SKU PS4-099U, with ID 0f0d:00ee (tested by me)
That would be great if you could make an PR for this addition.
[hathach/tinyusb] New branch created: fix\-cxd56\-msc
Describe the PR
Revert changes in #1070 , fix the root cause of the issue with cxd56. Following is the explanation (copied from other pr)
@kamtom480 the stall condition (before PR logic) is indeed correct here, according to the MSC BOT 13 cases. this particular if is for case 5 when Host expect more data than Device could send. In this particular case is Read Format Capacity command, where host expect 252 bytes, and we only send 12 bytes in response. Device really need to send an ST...
@hathach Thank you for this PR! I tested it and it works on Spresense.
Is adding $(PYTHON) necessary here?
yeah I got following issue without explicitly invoked with python under ubuntu 20.04
/usr/bin/env: โpython3\rโ: No such file or directory
Hmm.. I am also using Ubuntu 20.04 and I don't have this issue. Have you upgraded your Ubuntu from a previous version or have you installed a new Ubuntu 20.04?
If you change PYTHON = python to PYTHON = python3 will it work for you?
For the example ipcf, maybe just let user to generate those on their own. That way we don't have to maintain those files.
Yes it's easier to maintain less files... I've removed examples and added doc.
yeah, it will work since my default python is to python3 (it used to be python2 though) unitl I upgrade my ubuntu 20.04 to 5.10.0. I will update it python3 on Linux and simply python on windows
$ uname -a
Linux hathach-itx 5.10.0-1044-oem #46-Ubuntu SMP Wed Aug 11 09:50:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.8.10
$ python3 --version
Python 3.8.10
$ python2 --version
Python 2.7.18
Why not use
python3for Windows too?
Windows only has python.exe there is no python3.exe even though you install 3.9x
Describe the PR
Implement dcd_edpt_close_all() for Renesas RX family
Additional context
I have confirmed that the hid_composite example passes Chapter 9 test on a RX65N Target Board.
Please find Chapter 9 Tests - USB 2 - Passed - 2021-09-08 00-07-50.zip
[hathach/tinyusb] New branch created: st\-synopsy\-compliance
Describe the PR
make synopsys usbcv compliance
- implement dcd_edpt_close_all()
- reset dtoggle when open endpoint
- correct dev interrupt mask on bus reset
- also implement remote wakeup for stm synopsys with nop delay() based on SystemCoreClock
This is tested on stm32f411disco which passed all the compliance test (chapter 9, hid, msc) more detail in #1059
Describe the PR
Add support for additional PS4-compatible controller
Additional context
Add log message indicating scope of output.
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
some time mcu need to get file from sd card and also usb host need get file from sd card.
MTP is for this solution.
thank you for your great PR as usual. Though can you explain a bit for the usage of ptr wrap in the qtd_init_fifo()
I don't quite understand these lines, are you trying to queue both linear and wrap buffer into one TD ? Which I don't think is possible, we probably need 2 TDs for this.
Superb ! Thank you very much for your PR. I have tested it as well. And it pass both the chapter9 and hid test.
PS: MSC test still needs a tweak to set data toggle to 0 when open endpoint to pass though. MSC test suite assume all endpiont is reset with set configuration.
[hathach/tinyusb] New branch created: rx\-msc\-compliance
Describe the PR
This changes allow rx6Xn to pass MSC compliance test suite. The test sequence from "Error REcovery Test" --> "Case 1 Test" relies on SET_CONFIGURATION() request to reset all endpoints including data toggle to DATA0. With the changes cdc_msc can pass the test suite easily.
Yes I'm trying to queue both parts in 5*4kB TDs. Fifo need to be 4k aligned and has a size of multiple of 4K, for a max of 20K.
TD[0] can start at a arbitrary address and TD[1]-TD[4] must start at 4k boundary.
Take an example of a 8k fifo filled between 2000-100:

TD[0] is set to offset of fifo->ptr_lin, then each TD is aligned to 4k until len_lin is finished.
Then it wra...
Thank you for your review
I think you mis-understand the TD specs, within this function, it only preps 1 TD. The buffer[] page array is only used when the total bytes is large enough and memory cross the 4k boundary e.g when total bytes is 20 KB.
within this function, it only preps 1 TD
You're right.
In fact I mean 5 pointers within the same TD, sorry for the confusion.

we probably need 2 TDs for this.
I've tried 2 TDs, one for linear and one for wrapped part. In this case it cut the data into 2 separate transfers, for example cdc will receive half data.
we can transfer 1 TD after another instead of using 2 TDs at once. Can you update the above code to initialize the buffer page correctly. It should only affected by ptr_lin, and is mostly identical to existing qtd_init(). In fact, I think we should just use the qtd_init(ptr_lin, len) instead of having additional qtd_init_fifo()
It won't work when you need continuous data, for example in UAC2.
And host will think the transfer is finished since len_lin can be a short length packet.
At the beginning I've already tried using 2 TDs since it's easier to implement, doesn't work at all.
The current TD buffer setup is not correct in general, the requirement with 4K aligned is too specific to make its way into the buffer page array set up. And this does not work with other MCU dcd.
For ISO, you have to understand this limit and need to declare the fifo depth to be multiple of ISO frame. Re-config the fifo length to even smaller depth than its buffer when needed when the ISO packet size is changed is better implementation. E.g fifo buffer is 4x1024, but should be changed to...
the requirement with 4K aligned is too specific to make its way into the buffer page array set up. And this does not work with other MCU dcd.
Yes it is specific, so I've introduced a on/off switch in #1063 to not enable fifo_xfer by default, except explicitly.
For ISO, you have to understand this limit and need to declare the fifo depth to be multiple of ISO frame.
That's won't work since sample length could be +-1, wrapped part has to be always considered.
Yes it is specific, so I've introduced a on/off switch in #1063 to not enable fifo_xfer by default, except explicitly.
I don't like the TUD_AUDIO_PREFER_RING_BUFFER, it is only temporarily solution, we will eventual remove that.
That's won't work since sample length could be +-1, wrapped part has to be always considered.
Apparently, I am not aware of this issue. In this case, can you modify to make it more generic. xfer_fifo() will make use of qtd_init() with the linear part fi...
Then update the buffer pagep[] with wrapped
you mean modify buffer pagep[] inside xfer_fifo() and remove qtd_init_fifo() ?
it is mostly to reduce code duplication, for now, just keep it as it is if it is too confused. Only set up the buffer page only above 2 condition are met. currently wrapped part is always set up.
@HiFiPhile to clarify: not all edpt_xfer_fifo() need to combine linear + wrapped part, e.g CDC should have no issue breaking these into 2 sub transfers (one after another when USB complete ISR). Therefore not all fifo buffer need to be 4K. It is mostly for ISO applcation/driver, so having a 4K check would fit both.
I'll have a go at documenting the TUSB_DESC_ENDPOINT decsriptor in src/class/raw/raw_host.c #116
I've add the switch, should be good but haven't tested. (better to have a macro bool is_aligned_4k(x))
Describe the PR
- Implement
dcd_edpt_close_all()function. - Fix
dcd_edpt_close_all()function. This function worked for endpoint 0 but others.
Additional context
- Chapter 9 tests pass with the exception of four tests regarding suspend/resume/remote-wakeup. frdm_kl25z does not have any switches, so these tests cannot be tried.
- All HID tests pass.
- The MSC tests pass with the exception of five tests: error-recovery/case 4,8,10/required-command. Not investigated yet.
NUC126 passed chapter 9 tests with custom vendor class.
Chapter 9 Tests - USB 2 - Passed - 2021-09-09 20-35-38.zip
NUC126 passed chapter 9 tests with custom vendor class.
Chapter 9 Tests - USB 2 - Passed - 2021-09-09 20-35-38.zip
Thank for the testing, though, did you test with the hid composite, one of the chapter9 is remote wakeup which is only tested with hid example due to TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP
yeah, the condition look good, you can use the !tu_offset4k() as is_aligned_4k(), which make it easier to read.
Thank for the testing, though, did you test with the hid composite, one of the chapter9 is remote wakeup which is only tested with hid example due to TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP
It didn't work.
There is a typo of |= but still something more.
https://github.com/hathach/tinyusb/blob/d66d817c38d3da25198dbef90e8e0cd516f4508e/src/portable/nuvoton/nuc121/dcd_nuc121.c#L258
HID test passed.
USB3CV.zip
Describe the PR
- Fix remote-wakeup on NUC126.
Tested OK.
Chapter 9 Tests - USB 2 - Passed - DEBUG - 2021-09-10 13-00-45.zip
Without 22571ec with cdc_msc disk won't show up, but with this commit it fails strangely:
USBD Xfer Complete on EP 83 with 13 bytes
MSC xfer callback
SCSI Status = 0
Queue EP 03 with 31 bytes ...
USBD Xfer Complete on EP 03 with 31 bytes
MSC xfer callback
SCSI Command: Read10
Queue EP 83 with 512 bytes ...
USBD Xfer Complete on EP 83 with 512 bytes
CDC xfer callback
cdcd_xfer_cb 431: ASSERT FAILED
[hathach/tinyusb] New branch created: imxrt\-compliance
Describe the PR
Update NXP TDI (transdimension) dcd to fully pass USBCV test #1059 following is changes
- add other speed descriptor callback tud_descriptor_other_speed_configuration_cb()
- implement device qualifier and other speed configuration descriptor for high speed device which is required by USBCV e.g to work with full speed host
- Enhance plugged/ unplugged detection
- Enhance/implement suspend, resume, remote wakeup
- implement dcd edpt close all
- Fix and enhance dc...
@HiFiPhile I am doing resolving conflict and refactor this pr just now. Please hold on a bit if you plan to work more on this
@HiFiPhile I do some refactoring and happy with the refactored code. However, the xfer_fifo is not complete yet. In case where total_bytes > than linear length and the buffer is not 4K. DCD must
- make an td with linear length
- when td is complete, continue to submit another TD with the rest.
In short, The dcd must transfer all requested bytes by usbd/class driver, depending on the driver, breaking it into 2 sub transfer may still be acceptable e.g with stream/buffered endpoint such ...
Address possible buffer overflow in bth_device.c as described in issue #880 (btd_control_xfer_cb).
Passing size of _btd_itf.hci_cmd as len parameter to tud_control_xfer so that actual _ctrl_xfer.data_len will be set to minimum of buffer size and request wLength.
we should clear the Data PID first before clear stall to prevent possible race condition. Could you move this before the clear stall.
Thank you for another great PR, look good, The NUC manual doesn't explicitly say how to use the remote wake-up bit, but this seem to be the case. Though I think we should clear the PID before clear stall to prevent possible race condition.
could you explain why should we OR enabled_irqs with 0xffffff00 here
I have pushed update to correct this.
Superb ! Thank you very much for the update. For frdm_kl25z, we could pick one of its header pin and use wire jumper for input. Though we could always do it later.
For the MSC test, it is the most tricky test, have you tried to explicitly reset the PID of endpoint to DATA0 when dcd_edpt_open() is called. Since one of the msc test sequence is reset by simply Set Config(0) then SetConfig(1), and expect all the endpoints to be reset.
thank you for your PR, look good to me. Though let's wait for @kasjer feedback since he is original author of bth driver.
For frdm_kl25z, we could pick one of its header pin and use wire jumper for input
For boards without I/O, I think we can make bsp functions 'weak' to make it easier to override for testing purposes while keeping git workflow clean.
For example my nuc126 board has a button and I could push the wrong file.
@HiFiPhile I have changed my mind again, since xfer fifo isn't used by other driver just yet (though there is a plan for it to be used more in other drivers). It is best to not write code that aren't run yet. I just added an TODO note, we can merge this now once you verified that the refactored code work well with your ISO setup.
Thank you for your effort adding the xfer_fifo. I am happy with the refactored code now, please verify if it works with your ISO setup. Once it is confirmed, we could merge it and resolve other case (total > len and buffer is not 4k aligned) later on when needed.
I would also consider adding similar size check in call to tud_bt_hci_cmd_cb() in line 224, as not to deceive BT stack about size of command buffer if wLength can not be trusted.
if (tud_bt_hci_cmd_cb) tud_bt_hci_cmd_cb(&_btd_itf.hci_cmd,
tu_min16(sizeof(_btd_itf.hci_cmd), request->wLength));
For frdm_kl25z, we could pick one of its header pin and use wire jumper for input
For boards without I/O, I think we can make bsp functions 'weak' to make it easier to override for testing purposes while keeping git workflow clean.
For example my nuc126 board has a button and I could push the wrong file.
It is not necessary, pin/port is fixed on individual board, If you have an custom nuc126 board, you should add your own board file that correctly reflect your hardware.
Thank you very much for your PR and @kasjer for helping with the review. Will merge when ci passed.
enabled_irqs cover only DCD itself's irqs, 0xffffff00 allows EP's irqs to occur.
in that case, we should use this instead
uint32_t status = USBD->INTSTS & USBD->INTEN
In USBD->INTEN there is no EPEVTx


you are right, the nuc inten isn't same mapping as intsts as other mcu. Though, the value 0xffffff00 isn't quite correct, 0xffff0000 would be more precise (to also take wken into account, innaken is never used).
[hathach/tinyusb] New branch created: esp32sx\-compliance
Describe the PR
Get esp32sx to fully compliant to USBCV #1059, changes mostly follow #1077 since esp32sx also use synopsys controller.
- implement dcd_edpt_close_all()
- reset PID to DATA0 when open endpoint
- implement dcd_remote_wakeup() and temporarily enable SOF for bus resume detection.
Support for Nucleo F412ZG from STMicroelectronics.
Thank you for your comments. I will try to test with a jumper wire.
Addressed two issues in hidd_control_xfer_cb as reported in #880.
update: ah I see, 0xffffff00 since wken and innaken is not present on the INTSTS :facepalm:
thank you very much for your PR. everything looks great.
Now UAC2 is broken with no transfer, maybe forget to reset EP busy flag in usbd_edpt_close ?
USBD Setup Received 01 0B 03 00 01 00 00 00
Set Interface
AUDIO control request
Set itf: 1 - alt: 3
Open EP 01 with Size = 776
Queue EP 01 with 776 bytes ...
Open EP 81 with Size = 4
Set interface 1 alt 3
Queue EP 81 with 4 bytes ...
Queue EP 80 with 0 bytes ...
USBD Xfer Complete on EP 80 with 0 bytes
USBD Setup Received 01 0B 00 00 01 00 00 00
Set Interface
...
@HiFiPhile which audio example you are running
which audio example you are running
I've tested both uac2_headset and my own config.
Somehow EP flags are not reset when closed.
With xfer_fifo enabled it fails for the same reason:
USBD Setup Received A1 01 01 01 00 02 01 00
AUDIO control request
Get channel 1 mute 0
Queue EP 80 with 1 bytes ...
USBD Xfer Complete on EP 80 with 1 bytes
AUDIO control complete
Queue EP
USBD Setup Received 01 0B 01 00 01 00 00 00
Set Interface
AUDIO control request
Set...
@HiFiPhile yeah, I think this is the right fix, closing endpoint should also reset its state. Please make the commit if possible
void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
{
TU_ASSERT(dcd_edpt_close, /**/);
TU_LOG2(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const dir = tu_edpt_dir(ep_addr);
dcd_edpt_close(rhport, ep_addr);
+ _usbd_dev.ep_status[epnum][dir].stalled = false;
+ _usbd_dev.ep_s...
just want to say, since I don't use Keil, hopefully some people would know how to fix.
I think it's better to contact keil support for this compiler issue.
Based on my experience of IAR & Segger SES they are quite helpful.
@HiFiPhile let me know if the rest of your testing is going well enough
I have tried this out with cdc_msc example but seems still be issue with stall/clear stall. kl25z doesn't seem to clear stall correctly. As captured in the bus, the device continue to response with STALL after a clear stall attempt from host, and cause it to issue bus reset for recovery. And it loops over again, until host driver give up and doesn't issue the MODE SENSE command.
transaction 7883 + 7941 is clear stall control request and ack. Afterward the msc bulk in still response with...
It goes well in my side, you can merge it.
It goes well in my side, you can merge it.
great, thank you very much for the PR and testing
Thank you very much for your comments and checking the patch!
It is very helpful for me. I check the patch again.
When USBCV was run, no other USB devices would work, so I did not get testing logs.
Thank you very much for your comments and checking the patch!
It is very helpful for me. I check the patch again.When USBCV was run, no other USB devices would work, so I did not get testing logs.
You only need to tested with normal operation (now confirmed on windows) The side-effect would be a decent delay before the device show up. The log with LOG=2 LOGGER=rtt will show the issue (around the stall -> clear stall -> bus reset). There is an hidden (no-log) transaction as c...
@kkitayam I merged from master since the current state has build error with LOG=2. Also take the chance to push minor clean up for the dcd. Mostly for adding volatile (_IO) to the bd filed that could be changed by controller. It does not help with this issue, but would still be better to add.
@hathach
Thank you for your help. I found that a issue regarding stall interrupt handling.
When dcd set a stall response by setting bdt_stall = 1, it set ENDPOINT[epn].EPSTALL. I found we need to clear the bit in process_stall().
I wasn't expecting ENDPOINT[epn].EPSTALL to be set!
I confirmed MSC test pass with fbe1bf3. But, Chapter 9 regarding suspend/resume/remote wakeup fail still.
I'll check these issues
@hathach
Thank you for your help. I found that a issue regarding stall interrupt handling.
When dcd set a stall response by settingbdt_stall = 1, it setENDPOINT[epn].EPSTALL. I found we need to clear the bit inprocess_stall().I wasn't expecting
ENDPOINT[epn].EPSTALLto be set!
Superb !!! I confirmed it passed the MSC test suite. Yeah, I have read the KL25z manual back and forth and didn't see any mentioned about controller will set this bit and the need to clear ...
do we need to return here, I mean yeah, this ISR is fired when an endpoint response with STALL, but it could potentially has multiple STALL response from different class driver of multiple class drivers. It is probably no harm to just go all the loop to clear.
@kkitayam I confirmed that we couldn't detect the RESUME signal currently, suspend detection is fine. Btw, i found an new usb tool HSETT https://www.usb.org/compliancetools#anchor_usbxhsett is very useful to manipulate the bus manually. After too tired of pressing power button on my windows machine to put it on suspend and resume. This can be done by using HSETT
<img width="428" alt="Screenshot 2021-09-16 172209" src="https://user-images.githubusercontent.com/249515/133595933-83bde6cc-e...
@kkitayam Update: I found and fixed the issue, just in case you are troubleshooting it, please wait for my next push :)
@hathach Great! Thank you for your work. I am ready for your next push.
You are right. We should remove the return statement for the better.
OK, i make it as part of the next push as well :+1:
@kkitayam I have pushed the new commit, it passed all the suspend/resume/remote-wakeup test now. The issue is due to the RESUME detection, it seems the ISTATW RESUME is never triggered. possibly used for host. The tranceiver resume_int is correct way to detect bus activity. Also it will be triggered when the USB_USBTRC0_USBRESMEN_MASK is set regardless of the INTEN.
Describe the PR
DA146xx are Bluetooth devices that may be battery
powered and when not connected to USB host there
is no need for USB peripheral to be running.
This change allows to enable USB peripheral when
VBUS is present otherwise USB is down reducing
power consumption.
tud_vsub_changed() function must be called
whenever VBUS change was detected.
For bus-powered devices this function should be called
at startup since VBUS must be present while device
is working.
Tw...
@hathach Thank you for your commit. I have confirmed all Chapter 9 test pass. And, all modifications look good for me. Great!
BTW, dcd_mm32f327x_otg.c is almost the same code. We should apply this patch to the dcd.
@kkitayam Thank you for your testing. oh, I didn't know that mcu also use the same controller as khci. It is submitted by mcu vendor https://github.com/hathach/tinyusb/pull/869 . And I am unaware of the driver is based on yours. The license should name yours instead. I will correct that. Ideally, it should be the same common dcd file though, I am really bad of naming, I wish I know the USB IP name (like synopsys) to make it spot-on, but I will try.
I haven't run tested on the mcu just yet,...
Thank you for your PR. I agree that we need an unified API for managing vbus/power. The nrf implementation is a good candidate with an API(vbus_state) which is detected/ready/removed. These can be useful for port that does not have built-in vbus detect (required external gpio) such as esp32s2. For those vbus detection is only way to distinguish between Suspend vs Disconnection. Do you need to merge this right away, else give me a few days, I will try to review all the dcd and try to finaliz...
I prefer to merge and you can take more time to rethink it. It will not be a problem if API will slightly change later on.
I can also implement dcd_edpt_close_all() for Dialog in spare time. Do you have any scenario that this function can be tested?
The code looks great, I haven't tested it on the hardware, last time I have some difficulties with flashing bin to external flash or something (kind of forgot). Will do a overall test later on.
I prefer to merge and you can take more time to rethink it. It will not be a problem if API will slightly change later on.
Yeah, I prefer to merge this as well. Since I can be late on the API revising --> merged
I can also implement dcd_edpt_close_all() for Dialog in spare time. Do you have any scenario that this function can be tested?
The close_all() is quite similar to bus_reset(), except it does not reset control endpoints. It is used when host switching from active configura...
While trying to figure out the IP name of this controller, I just found out that this USB IP is also used by
- PIC32 family https://ww1.microchip.com/downloads/en/DeviceDoc/61126F.pdf
- DSTni-EX https://www.lantronix.com/products/dstni-ex/

Operating System
Windows 7
Board
nrf52840
Firmware
\tinyusb\examples\device\hid_boot_interface\src\main.c
What happened ?
Execution fails forever on \tinyusb\examples\device\hid_boot_interface\src\main.c๏ผline 216.
report_type is always equal to 0
How to reproduce ?
empty
Debug Log
No response
Screenshots
No response
It is very interesting! I've also looked into PIC18F2455 too. It looks that this MCU has a similar USB IP. The IP has PPB(Ping-Pong Buffer) instead of BDT. And it seems that PPB had been applied as a patent in 2004.
BDT may be an upgraded version of PPB by microchip.
I found that the USB IP seems to be called as [VUSB](https://doc.hcc-embedded.com/hcc-documentation/usb-device-sta...
Describe the PR
Unconditionally disables all endpoints except EP0.
Related to #1059
Additional context
Not tested yet with USBCV
@kkitayam I spent several hours to do a bit of research on this, here is my findout.
- PIC32 uses ChipIdea Fullspeed OTG core, because at that time, chipidea is part of MIPS. https://www.design-reuse.com/news/17724/analog-and-processor-ip.html
The Chipidea Full Speed USB 2.0 OTG Controller is a highly optimized, low gate count IP core that allows system developers to implement compact, cost-effective, low-power USB-based SoC solutions.
- ChipIdea previously bought this IP from ...
could you provide
- how you test and steps to reproduce the issue
- the debug log with
LOG=3around the time the incident occur.
The type definitions for pipe_handle_t were removed in #449 for all class drivers except for class Vendor_Host (/class/vendor_host.h and /class/vendor_host.c).
The Class Vendor_Device also does not use the type pipe_handle_t so it seems Vendor_Host should follow a similar pattern.
I want to simply define,
#define CFG_TUH_VENDOR 1
and then simply be able to use these functions for bulk data transfer.
`
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, ui...
yes, vendor host is lacking behind the migration/upgrade and currently I don't have plan/time to work on it.
we should also reset the xfer_ctl_t xfer_status[EP_MAX][2]; (except EP0) as well. Since the new configure may have less endpoint than the one we are closing.
Note: for multiple configuration , SET_CONFIG can be set without an bus_reset.
Look great, thank you for your PR.
@hathach thanks for input, I will update PR.
But before this I will make another PR that will remake power state handling. Bus reset and sleep related code was only testes on live systems. Now when I've used USB3CV, I see that more changes are needed in that area.
But since you are on this, let me ask about something that prevents USB3CV tests to pass on this board.
EP0 size is 8 for this chip family, when code below is NOT removed tests fail.
// Only send up to EP0 P...
@kasjer this is really an edge case. This particular code is added since it is needed when testing with actual host driver such linux/windows with 8-byte control endpoint e.g msp430. The host driver won't bother getting the 2nd packet EP0 and will send ZLP as status right after the 1st packet. Maybe the USBCV has different expectation, I will try to test it later on.
You can try to comment it out to run the USBCV, but you may have issue with normal enumeration.
Describe the PR
Button on board has 1k resistor to ground when pressed.
When not pressed pin 6 is floating.
This forces MCU pull-up for this pin for correct behavior.
Additional context
look good, will merge when ci is passed.
Describe the PR
Unlike da1469x_dk_pro, K1 pin (6) is connected to VCC when active.
This adds required pull down and reverses active logic state.
Additional context
Describe the PR
So far bus reset was handled (with some holes in it).
Sleep and remote wake-up were not really tested and did not work.
With this change:
- bus reset is reworked
- remote wakeup works
- bus signal sleep is handled
- in some cases register modification (read/update/write) was change to just writes.
- FRAME interrupt is used for bus reset end condition and for delay needed in remote wakeup condition.
Additional context
While it work with Windows and Linux s...
condition seems to be overkill (only right side of && makes a difference) or wrong (&& where || should be)
@hathach I decided to make dcd_edpt_close_all() look very simple.
This PR will be followed by next change that will take into account what should be done when endpoint is closed so basically I will update dcd_edpt_close() as well.
@hathach about USB3CV and Windows/Linux enumeration difference.
For me behavior of USB3CV is more reasonable, but then I also understand what was done in Windows/Linux.
It could be fixed in TinyUSB if we had EP0 OUT endpoint ready not just after expected length of DATA STAGE, but (for example) after first packet or from the beginning. Then STATUS STAGE could just stop control request.
But there is simpler solution that can make USB3CV and Windows happy.
We could slightly...
@hathach I decided to make dcd_edpt_close_all() look very simple.
This PR will be followed by next change that will take into account what should be done when endpoint is closed so basically I will update dcd_edpt_close() as well.
The previous edpt_close_all() is actually simpler since it is used when expecting a full reconfiguration. The edpt_close() is currently meant for ISO only, in the future, I plan to retire/remove it to prefer and better API e.g edpt_resize() due to the fact t...
I looked simpler but it was missing stuff that you mentioned in previous comment.
dcd_edpt_close() is still missing that part but I already have code ready for PR that does xfer cleanup there.
@kasjer the new condition look great. IMHO, It is really OS host driver fault, getting the 1st 8bytes to get EP0 size is common approach similar to getting first 9 bytes of configuration descriptor. I did this as well in the host stack https://github.com/hathach/tinyusb/blob/master/src/host/usbh.c#L712
Back to your suggestion, I think it is great, could you made an PR for it along with the comment to explain the different between the 2 cases
- Host only want to receive only 1 packet with...
I looked simpler but it was missing stuff that you mentioned in previous comment.
dcd_edpt_close() is still missing that part but I already have code ready for PR that does xfer cleanup there.
Look good, thank you for your PRs.
Describe the PR
Windows and Linux host during enumeration requests device
descriptor with request size set to 64 bytes when device
was in default state (no address).
Those systems do not want 64 bytes though since usb descriptors is
only 18 bytes long so they silently expect that only one packet
will be received possibly 18 bytes for EPS > 16 or 8 or 16 bytes
for smaller EP0.
For devices with CFG_TUD_ENDPOINT0_SIZE size 8 or 16 there was
workaround that reduced request size to ...
Describe the PR
xfer_ctl_t structure keeps all dynamic data connected with transfer.
It used to have pointer to register set that was constant and was there
for convenience only.
Removing register pointer from structure makes cleanup easier as whole
structure can be erased with memset-like function.
In many cases functions were using local variable regs and xfer->regs which
were same, that could be confusing so this part is unified.
Few macros were added for easy conversion ...
I am in the middle of esp32s2 work. Give me a bit of time to pull out the da146xx usb to test and review this.
look great, thank you for your PR. Test with MP430 port, but it seems to break somewhere.
Operating System
Linux
Board
msp_exp430f5529lp
Firmware
examples/device/cdc_msc
What happened ?
Failed to enumerate on both Linux and Windows. The root cause is msp430 responses with incorrect data, basically using the control request instead of the device descriptor payload.
How to reproduce ?
- Run cdc_msc
- PC will complain with read device descriptor error
[89841.141609] usb 3-2.1: new full-speed USB device number 45 using xhci_hcd
[89846.329389] u...
It is probably buffer overflow and/or mis-management somewhere. Could try to do some checkout and bisect to narrow down the changes.
@hathach Would you be willing to handle this for me? If not, I'll take a look in the coming days.
Is that screenshot first transaction that happens after bus reset (i.e. beginning of enumeration)? If so, that looks somewhat (see italics) normal to me.
MSP430 is hardcoded for control endpoint to xfer 8 bytes at a time. I know the first xfer an OS will send should be 64 bytes, and the OS should notice that the MSP430 only responded w/ 8 bytes. _MSP430 responding by echoing the setup pack...
@cr1901 no worries, I will try to fix this whenever I got time (currently I am focusing on esp32 work). This issue is discovered when testing #1102 (for ref https://github.com/hathach/tinyusb/pull/1096#issuecomment-926547381) , and is reminder for me since I have a bad memory :)
dcd msp430 isnโt modified for a while. It is probably recent changes since it work flawlessly previously.
Assure division by zero is not attempted (block_sz) and add lba validation to address msc issues in #880.
This adapt the Nov 2020 era CDC NCM driver from @j4cbo to be compatible with the TinyUSB network API.
The big difference between this PR and PR #550 is that instead of the user having to craft a new user application to use the NCM driver, the existing net_lwip_webserver example just works, regardless of which network driver is used. Similarly, anyone who is writing their own TinyUSB-based network application can switch between the two drivers, using the same API, to choose which works best...
[hathach/tinyusb] New branch created: minor\-changes
Describe the PR
make freertos example header more explicit for user
Thank you for your PR, but all of these scenarios are already addressed. Actually it is part of the USB certification verification #1059 MSC test suite. The block_sz == 0 when either block_count = 0 and/or total_bytes = 0, both are checked when command is received before proc_read10/write10_cmd() is invoked
https://github.com/hathach/tinyusb/blob/master/src/class/msc/msc_device.c#L158
Thank you for your PR, to be honest I don't entirely like the solution. Since I want to refactor the iso and its buffer usage. Though I could merge this as it is to make it easier for you (without keeping local changes in your fork), but keep in mind that TUD_AUDIO_PREFER_RING_BUFFER is subject to changed/refactored in the future.
Operating System
Windows 10
Board
STM32F103
Firmware
tinyusb 0.11.0 with CDC and MSC option set runs without OS on STM32F103 board.
What happened ?
The program runs quite normal until the CDC and MSC idle for hours.If you open a file in the tinyusb disk with Windows 10 file explorer,it will stuck for a long time and you will see the disk usage in task manager which is 100%,in the mean time if you send data to the cdc COM port,it will resume normal.
How to reproduc...
Could you please verify that validation for the case when cbw->total_bytes = 0 and block_count = 0 is correct. From what I can see rdwr10_validate_cmd will return MSC_CSW_STATUS_PASSED thus proc_read10 will be called. This will lead to a division by zero in proc_read10_cmd.
Describe the PR
Add support for this very affordable board:
https://www.aliexpress.com/item/1005003173783268.htm
Could you please verify that validation for the case when cbw->total_bytes = 0 and block_count = 0 is correct. From what I can see rdwr10_validate_cmd will return MSC_CSW_STATUS_PASSED thus proc_read10 will be called. This will lead to a division by zero in proc_read10_cmd.
status is passed, but the total_bytes = 0, will skip the data phase, go straight to status and didn't invoke the proc_read10 https://github.com/hathach/tinyusb/blob/master/src/class/msc/msc_device.c#L425
Also rdw...
could you provide a bit more info
- Which exact firmware you are using, if possible please check with the examples/cdc_msc, otherwise, please attached your firmware similar to how stock firmware for reproducing.
- Instead of
Leave the device for hours, can you try to sleep/suspend pc, then resume to see if it is sleep/suspend related issue - Build example with
make LOG=3 BOARD=your boardthen attached the the log file here around the incident occur for analyzing.
update: for people that want to order the board, the link is https://www.aliexpress.com/item/1005003173783268.html (OP htm missing l)
I altered the PR to make sure that the total_bytes division by block_count is not zero in rdwr10_validate_cmd.
Thank you for your feedback and please let me know if any additional amendments are required.
It depends on your planning.
If you are too busy I prefer to let it merged and revisit later with iso refactor, or if you are going to refactor iso soon then no need to merge.
In case total_bytes divided by block_count evaluates to zero a division by zero may happen in proc_read10_cmd leading to a crash.
I could track down the problem with the bitfield "wMaxPacketSize" in the file "usb_types.h"
https://github.com/hathach/tinyusb/blob/32bdf3b79d27ed9f0851440df35b6a72bcd8bff8/src/common/tusb_types.h#L352-L361
and the CCRX toolchain building in big endian mode. The problem does not occurs if the CCRX toolchain is building in little endian mode.
The bitfield "wMaxPacketSize" is a member of the "tusb_desc_endpoint_t" struct definition, which is used to make the access to the USB descriptor ...
[hathach/tinyusb] New branch created: zhangslice\-master
Describe the PR
replace #897 to
- Add mindmotion mm32 board support
- Use hathach/mm32sdk as submodule due to lack of response from official sdk to fix file name case sensitive issue
Describe the PR
Add Video class driver and a video capture example. #908
This version is experimental and has many limitations. I have only implemented a minimum number of features.
- Support only uncompressed format.
- Support only isochronous IN. No support isochronous OUT and bulk.
- Support only Full speed. So, the maximum bitrate is 1Mbps.
- Support only input-terminal and output-terminal. No support any other unit.
- No support dynamic streaming settings modification.
- No...
Is your feature request related to a problem? Please describe.
XCore supports TinyUSB. We have support that exists in our sdk, built on top of the FreeRTOS kernel modified for SMP, that is now being maintained by Amazon. Between the SMP kernel and some build requirements unique to our platform, we opted to test the example applications within our SDK.
**D...
Hi @xmos-jmccarthy ,
sdk, built on top of the FreeRTOS kernel modified for SMP, that is now being maintained by Amazon. Between the SMP kernel and some build requirements unique to our platform, we opted to test the example applications within our SDK.
Describe the solution you'd like I want to get XCore support into the supported devices, but do not wa...
AMAZING!!! brilliant PR :+1: :+1: , thank you very much for making this. UVC along with UAC are 2 most complicated classes. This awesome PR with testable examples will greatly help further development (iso out, highspeed), and I have no doubt that we could pull this off together in the next several PRs.
Since the changes are huge, please give me a bit of time to digest it. I will also take the chance to test it with other ports as well. We will probably make an separated issue to keep tra...
Thank you @Wini-Buh for detail breakout, I think I understand the issue, indeed the bitfield doesn't work well when swapping the endian. USB descriptors are always in endian --> need swap, which will cause incorrect mapping of bitfield. I think the best solution is just drop the bitfield within multi-byte field such as wMaxPacketSize entirely. The highspeed mult isn't used much anyway, in case of usage, it could be done simply by bitwise operation. I will make any PR to rename/change it, alth...
Thank you for your comments.
If you find any issues or questions, please let me know.
Thank you very much for the PR. I take a look back at the MSC BOT specs, the case where total bytes < block num is actually counted as
- READ10: case 7 Hi < Di host read less than device want to send or
- WRITE10 (we need this check for write as well): case 13 Ho < Do, host send less than device would like to receive
In both cases, the specs say we must response with phase error. Therefore, I made a bit of changes and push the update
 but haven't got the time to do so.
@hathach Ok, I agree with you to replace the bitfield wMaxPacketSize as a normal unsigned short field. A simple solution is always the best. I let this draft PR open until the modifications is done (as a reminder).
@hathach Ok, I agree with you to replace the bitfield
wMaxPacketSizeas a normal unsigned short field. A simple solution is always the best. I let this draft PR open until the modifications is done (as a reminder).
will do it after PRs adding video and cdc-ncm, since it can complicate those on-going PR.
Describe the PR
Mostly house keeping work
- Update ISO endpoint for nrf5x to be 8 for audio example
- fix #1067
- correct drivers interface binding for MIDI and BTH, where it have 2 interfaces but does not use IAD.
- clean up usbh configuration parser a bit
- Make vendor driver more flexible with varies of custom descriptors between Interfaces and Endpoints. Also can have 0-2 endpoints (previously fixed 2 endpoints).
I believe this PR is superseded by #1058 . Configuration can be de-configure (0) and switch back and forth to other configure state. Thank you very much for the PR.
Superceded by #1062 #1063 #1064
So, I've been using the pre-rebased version of this (5a1a6ba5c3526e822e060745be8e643e24537c3c) for about a month now on several RPi Picos. I'm perfectly happy with it and didn't have any issues yet.
I'm running a DHCP server over it, an HTTP server and I have quite a bit UDP traffic (unicast and multicast) host -> board.
So, I've been using the pre-rebased version of this (5a1a6ba) for about a month now on several RPi Picos. I'm perfectly happy with it and didn't have any issues yet. I'm running a DHCP server over it, an HTTP server and I have quite a bit UDP traffic (unicast and multicast) host -> board.
EDIT: And I'm using the "Microsoft OS 2.0 USB descriptors" so Microsoft actually loads its NCM driver: https:/...
I have similar issue.
I use STM32F103 BLUEPILL board, Win10-PC-Host send usb packet ๏ผ 80 06 00 01 00 00 12 00 ๏ผmeans descriptor length is 18 bytes. in tiny usb code, the descriptor is prepared by desc_device, and the length is 18bytes exactly.
However, I use another MCU IC manufacture by Chinese facturary ( they said it is as the same as the STM32F103C8T6). after power on, usb enumeration ๏ผWin10-PC-Host send usb packet ๏ผ 80 06 00 01 00 00 40 00 ๏ผ. my board still response 18bytes.
then is...
I have similar issue.
I use STM32F103 BLUEPILL board, Win10-PC-Host send usb packet ๏ผ 80 06 00 01 00 00 12 00 ๏ผmeans descriptor length is 18 bytes. in tiny usb code, the descriptor is prepared by desc_device, and the length is 18bytes exactly.
However, I use another MCU IC manufacture by Chinese facturary ( they said it is as the same as the STM32F103C8T6). after power on, usb enumeration ๏ผWin10-PC-Host send usb packet ๏ผ 80 06 00 01 00 00 40 00 ๏ผ. my board still response 18bytes.
then is...
@maemoKKK it is not the same issue, please open your own one with detailed information to troubleshoot, And don't spam on others.
Operating System
Windows 10
Board
CH32F103C8T6
Firmware
webusb-serial
What happened ?
CH32F103C8T6 is very similar to STM32F103C8T6. I use "make BOARD=stm32f103_bluepill all" to compile and flash image.
after power on, windows host send 80 06 00 01 00 00 40 00๏ผ but device send 18 bytes.
How to reproduce ?
- CH32F103C8T6 have USB pull up resistant inside. during board_init, enable USB pull up resistant after GIPO init and before USB clock enabel.
- compile...
MIDI Host - work in progress
Includes descriptor decoding routines (I'm learning USB as I go)
Some commits can be included immediately as they are generic "bug fixes" ...these commits are flagged "**" because I have no idea how to use git properly (yet)
The MIDI Engine code (~3kloc) [see MIDI folder at root level] cannot be properly integrated, tested, and debugged until I get the basic driver going - which is not going well :( ...but it at least compiles in a test harness :)
This changes definition from Audio 2 specification section 4.7.2 to version 1.0 section 4.3.2 with limitation to 1 interface.
Maybe better way to handle this is to have 1.0 version separated and not change just one structure to different specification version.
While experimenting with HID devices, I found that one of my controllers failed to report anything (a 3rd-party Switch pro controller). It turned out that this device lists its OUT endpoint first and the HID host code was opening that instead of the IN endpoint.
lsusb -v for the device:
Bus 001 Device 093: ID 20d6:a711 Core (Plus) Wired Controller
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0...
Thanks.
Closing for now while I wait for some things to happen on my end. Will reopen and PR when ready.
Ah. Yes. I didn't realise that was the root of the problem!
I would suggest the v1 be called audio_desc_cs_ac_interface_t and v2 audio_desc_cs_ac_interface_v2_t ...but I guess that might be seen as an undesirable breaking-change :/
Do you have any ideas for the best/right way to do this?
Excellent work :+1: :tada: , I have tried it and it works perfectly on Linux. On windows it requires ncm driver (skip for now) and will test with windows later on when adding MS OS 2.0 descriptors. But I am sure it works as well. Thank you @majbthrd and @j4cbo for making this driver possible.
@majbthrd I rename the CFG_TUD_NET to CFG_TUD_ECM_RNDIS, although they both implement network, they are independent, therefore I think it make more sense for each to has its own macro feature. T...
Spot-on and look great, thank you for the PR.
@kkitayam I need help with the testing, I have tried this on both KL25z and pico with windows. However, I couldn't get the logo displayed. It could be me since I am not familiar with virtualdub. I am on windows 10 with virtualDub 1.10.4 amd64. What I have done:
- Launch virtualDub, File -> Capture AVI ...
- Device -> select TinyUSB UVC
- Didn't see anything
- Try to change Video -> Set custom format, but vb doesn't allow me to set to anything else.
<img width="293" alt="Screenshot 202...
@hathach Could you try following steps. I had tested the followings. Please note that it is not possible to preview by VirtualDub with this patch. We can record a video stream into a file after that play the video file.
- Launch virtualDub, File -> Capture AVI ...
- File -> Set capture file...

Input a file path to save captured video stream. - Device -> USB (Direct Show)
![i...
I ran into a similar situation, and the Wireshark capture was enlightening. So including that would be quite helpful.
Here's basically what I did:
- (tinyUSB) Device connected to (Linux PC) host, terminal app not running
- Device sends a series of lines (short string ended with CRLF) that get stuck in the TX buffer
- Open terminal app on the host
- First line gets echoed from the host back to the device, one character per USB message.
- Terminal app receives the rest of the lines normal...
Is your feature request related to a problem? Please describe.
USB CDC does not appear to provide a reliable way of knowing when there is a user application on the host that's actually connected to the device. At best there's the DTR flag, but it cannot always be trusted. As such, the only way to know if you're transmitting data to nowhere is to check after the fact. (Either by getting a 0 response after successive calls to tud_cdc_write_flush() or by waiting on `tud_cdc_tx_complete_c...
Operating System
Others
Board
Adafruit MacroPad RP2040
Firmware
circuitpython (post 7.0.0, PR under development) using TinyUSB commit 43aac707
I'm testing this in the BIOS screen on a Dell Latitude E4310, which requires a boot keyboard,, and sends a SET_PROTOCOL. Interestingly, some later Dell BIOS'es no longer require a boot keyboard. I also see this problem on an older MSI motherboard.
What happened ?
I'm implementing boot protocol support in CircuitPython. I set u...
thanks @dhalbert for a detail issue, I will do my own test. meanwhile can you provide following detail, to see if I could spot any isue in the configuration.
- the branch/code for cpy you are working on along with code.py for reproducing purpose.
- your configuration descriptor via command
lsusb -v -d 239a: - hid descriptor via command
sudo usbhid-dump -d 239a | grep -v : | xxd -r -p | hidrd-convert -o spec
looking forward to your PR, if you are unsure, just make it as a draft, I will try to help with
@dkonigsberg thanks for the issue, it seems like you want to reset endpoints for CDC. Could you
- Explain more about its use case,
- what is the issue you are dealing with and how to reproduce it
@kkitayam bravoss !!! it works, sorry, I am new to this vd and didn't figure out the right way to test it. Proceeding with further tests now :+1: :+1: . Display tinyusb log is super nice, however, if size is an issue, we could change to good old color bar pattern or pattern that could be generated without having a huge flash. That would make the example more accessible to other MCUs.
Here's a patch file of the instrumentation of src/class/hid/hid_device.c. I just add an extern float indicator, and then set it to various values at various points in the code:
instrumentation.hid_device.c.patch.txt
CircuitPython changes are here:
https://github.com/dhalbert/circuitpython/tree/hid-boot-protocol. There are two commits on this branch.
What I'm seeing with the hid_device.c instrumentation:
On a regular host which does not try to enable boot protocol, I see 77.0 in the output prints. This indicates it did get into hidd_control_xfer_cb().
On the BIOS host, I only see 0.1. This is the static initial value of indicator, and indicates that it never got into hidd_control_xfer_cb().
The use case is wanting to make data sent out through a USB CDC device go to the bitbucket if that device is connected to a host, but that host isn't actually listening. (e.g. device plugged into a PC, but no terminal app has actually opened the resulting serial device on that PC) As far as I can tell, FTDI FT232 devices (which aren't CDC) behave that way, and the CDC device in one of my embedded debug probes does too.
There are two things that need to happen to gracefully deal with this...
To confirm this is not port-specific, I tried the same test (with a slightly different code.py) on a SAMD51 PyGamer, and saw the same issue. I see 0.1 printed as the only indicator value, showing that hidd_control_xfer_cb() was not entered.
Note that because the keyboard report descriptor in use has no report id and is very standard, it is possible to send keyboard reports, and the BIOS will respond. But the callback is not happening.
@dhalbert I have just tested with one my simple hid_boot_interface here with 1 boot keyboard + 1 boot mouse. Everything works just fine. The issue with your case is the host driver does not follow the specs, the HID is at bInterfaceNumber=3 however, wIndex in its SET_PROTOCOL does not correct set this value. TinyUSB interpreter this as invalid request toward CDC and stall in response.
<img width="672" al...
Thanks, I was afraid of something like that. I think I could make sure that the HID interface was always interface 0. I will check into that. Older BIOS's are probably all too simple. I saw this with two different manufacturers' motherboards.
@dhalbert that could cause issue with windows machine that already mounted our board before. I am not sure if windows change their way, but last time I tested: Windows stored binding drivers for interfaces using vid_pid (and probably bcd version), to skip re-analyze the configuration afterwards.
E.g once mounted, windows take notes that this metro board has interface 0 is cdc, next time, it will auto load the cdc driver (usbser) for interface0 without re-analyze the configuration descript...
@dhalbert Changing the bcd device number when changing driver combo is a good way to keep the same vid/pid. Though you still need to do a further research. Since my info could be obsolete.
Anyway, I think you should just go ahead with it, just to try to see we could quickly get the boot interface working first. Then we could decide how we walkaround this later on.
Currently, with dynamic USB, the interface numbers are assigned sequentially, depending on which devices are enabled (MIDI on/off, MSC on off/ ,etc.). So they already vary. I have never seen a blue screen! But sometimes I have to use Uwe Seiber's device cleanup tool to prevent Windows from getting confused or reporting an issue with the device.
Apparently, Microsoft fixed their hardfault with better error handling. Then I think it is safe to go ahead to re-arrange the interface :)
RIght now our Windows 7 and 8.x drivers require that CDC is at interface 0 (https://github.com/adafruit/Adafruit_Windows_Drivers/pull/5). They have entries like
"%CIRCUIT_PLAYGROUND_EXPRESS% UF2 Bootloader (0018:00)"=DriverInstall, USB\VID_239A&PID_0018&MI_00
Note the MI_00. However, I think I might be able to imitate what Windows 10 does to select a class driver for usbser.sys: https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-driver-installation-based-on-c...
@hathach Thank you for confirming this patch on the several boards. That's great it works on your boards!
if size is an issue, we could change to good old color bar pattern or pattern that could be generated without having a huge flash.
Yeah, I am agree with you on the size issue. This weekend I'm going to try to change the video to the generated pattern or somethings to reduce rom size.
Actually, I was going to implement a color bar display but I didn't. Because there were many t...
Actually, I was going to implement a color bar display but I didn't. Because there were many things to consider like as followings, I got tired of doing.
How do I generate color bar patterns? Should I implement BT.2111 or other specification? How do I move color bars? Panning? Zooming? Etc.
@kkitayam wow, color bar actually has more problems than I thought. Actually It is perfectly OK with currently logo implementation. If the color bar take more of your time, we could do it as follow u...
@majbthrd if you have time, please let me know if you are ok with the rename from CFG_TUD_NET to CFG_TUD_ECM_RNDIS I am open to all suggestion. Otherwise, I think the PR is ready to merge :tada: :+1:
- If you want to load Usbser.sys automatically, set the class code to 02 and subclass code to 02 in the Device Descriptor. For more information, see USB communications device class. With this approach, you are not required to distribute INF files for your device because the system uses Usbser.inf.
- If your device specifies class code 02 but a subclass code value other than 02, Usbser.sys does not load automatically. Pnp Manager tries to find a driver. If a suitable driver is not found, ...
@kkitayam I really want to try this on ESP32-S2+camera. Unfortunately, outputting 12bit YUV is not an output option for the sensors. Could you link me to some docs to see how should I go about changing the format to MJPEG? It could actually make for a somewhat decent webcam :)
@me-no-dev Thank you for your comment. I am happy that you are interested in this PR!
Could you link me to some docs to see how should I go about changing the format to MJPEG?
Unfortunately, in current status this PR has no support for motion JPEG. To add support for motion JPEG, we need to modify at least _update_streaming_parameters() and _negotiate_streaming_parameters() to handle motion JPEG.
Motion JPEG is a frame-based format, so it should not be too difficult to add supp...
@hathach What I will test is to install a usbser .inf file that uses class and subclass to specify when to load the driver, instead of the current .inf which identifies the device by VID, PID, and interface. So you'll still need to install the driver package, but I hope to stop having to list all the boards in it indvidually. I also should be able to stop having to specify the interface (MI).
@majbthrd if you have time, please let me know if you are ok with the rename from
CFG_TUD_NETtoCFG_TUD_ECM_RNDISI am open to all suggestion. Otherwise, I think the PR is ready to merge tada +1
@hathach, I'm fine with the rename, and agree that the PR is ready to merge. Thanks!
@hathach
I have changed the video data to scrolling EBU color bars and stream format to YUY2 at b6d09ca.
@hathach I myself was a bit confused elsewhere by HID_REPORT_TYPE_INVALID sometimes meaning: "there's a report id a at the front, remove it and try again."
@hathach
I have changed the video data to scrolling EBU color bars and stream format to YUY2 at b6d09ca.
Superb! I will do more tests with the new format (couldn't do in the weekend since there is lots of house work to be done :smile: )
@dhalbert yeah, totally understand your point, according to MS doc above
- We need to set the class and subclass in device descriptor to CDC for this to work
- it won't work with win8 and win7
@qingliyu you didn't provide answer to my 2 questions above, especially how do you reproduce the issue.
@dhalbert yeah, it is what it means at current state of the device stack when receiving report via OUT interrupt endpoint. device stack doesn't attempt to parse the report descriptor, and have no idea if report ID is present or not. Therefore, it will present the SET report as it is with report id as 1st byte. When receiving report via control endpoints, the report id and type is explici...
@majbthrd thank you very much for your feedback and effort. I did once more commit with ncm.h to hold magic number. It is perfect now, will merge when ci passed. Thank you again for this brilliant PR.
Tested and continue to work great with the color bar. I missed the logo however, the color bar shrink the size from 73KB to 24KB with either RAM or ROM via CFG_EXAMPLE_VIDEO_READONLY is a huge save. It will allow example to run on lots of smaller MCUs. Also the color bar generated code is short and straightforward, which can make it easier for user to do their own customization is a plus.
PS: still doing code review, will merge soon once complete. Only minor changes so far :)
this seems to be an typo, both case return invalid request. if successfully _find_desc_entity() we should return as no error.
I tried a device id like:
"USB Serial"=DriverInstall, USB\Class_02&SubClass_02
This does not work because a third-party driver cannot be a class driver: it cannot recognize a device solely by its class (its "Compatible ID"). The .cat file creator complains and throws an error on the above. Instead, a device must be recognized by its complete hardware ID, e.g. USB\VID_0239a&PID_1234. It's not possible to wildcard the PID either.
So I am going to give up on this for now. We ...
@kkitayam I made an PR to your PR that includes the fix for this along with other minor renaming and clean up https://github.com/kkitayam/tinyusb/pull/1 . Please check it out and let me know your feedback.
@dhalbert I could add an extra callback for unsupported requests for cdc, which circupython can use for this scenario. However, it does add a bit of confusion in normal (non-bios) usage. Let me know if you think that worth the hassle to support it
@hathach
ๆฐๅปบๆไปถๅคน.zip
reproduce ๏ผPress num after USB is connected normallyใ
โreport_type == HID_REPORT_TYPE_OUTPUTโ(tusb_main.c๏ผ221) never succeedใ
Use โreport_type == HID_REPORT_TYPE_INVALIDโ(tusb_main.c๏ผ222) ."kbd_leds = %02X\n" can be output normally.
I totally missed this as well, even gcc miss this, it should try to throw some warnings :smile:
Brilliant work, this PR lays a great base work for more video improvement in the future. Along with UAC, UVC is one of the most complicated class driver. I have no doubt that this will absolutely help to spark lots of great application for lots of users. Thank you very much for this amazing work.
- linkermap target is added for size analysis, require to install https://github.com/hathach/linkermap
- ci also include linkermap output for quick and convenient check. Example output is
- Note
-fltocan merged all the codes and symbol and mess up the result, thereforeNO_LTO=1should best be used when analyzing size locally.
File | .text .data .bss Total
-------------------------------------------------------------------...
nice catch, it is my typo
please remove these since it will break entire stack. MIDI (audio v1) is the only class that has these extra 2 field. MIDI driver should handle it locally.
Thank you for your PR and sorry for late response, I have been busy with other work. The PR is still WIP therefore I converted it to draft. Could you update:
- remove unnecessary files from the PR such as one in
_MIDIH.tmp/, and other local used only such as dbg-tusbh.h - revert the changes to endpoint (mentioned in review) and audio cs interface (by kasjer)
Note: rp2040 host stack does not work with bulk endpoint just yet, due to the chip limitation that can only carry out 1 bulk tra...
please revert the change, audio v1 is only used by MIDI, all other class moves to audio v2. MIDI driver could handle this locally within its driver
Sorry for late response, have been busy with other works. To be honest, I still haven't pull out my DA146xx USB board to test with, since I had an issue with flashing its bin previously. Anyway, the changes look good, it mostly to fine tune the bus event handling with precise reset, suspend & resume detection. Therefore I don't think I could do anything better than yours.
PS: If you tested with USCV and has its result, please let me know so that we could update DA146xx status in #1059
I will re-run test. I assume USCV has some log that can be send to you (or to #1059) or it's just screen shot?
If it is clear what needs to be sent in #1059 (which I have not read to carefully) just ignore this comment I will follow what others did.
@kasjer it output an html result in its working directory (click on view result will bring you there), you could upload it here for reference
[hathach/tinyusb] New branch created: release\-0\.12\.0
Describe the PR
update doc and version for 0.12.0 release
Here are test results from running USCV, Chapter 9, HID and MSC. Let me know it MSC failure is due to driver not working as expected or cdc_msc example limitation.
USB3CV.zip
@kasjer I just re-run the MSC test on nrf52840, it seems to be fine. From the log, device seems to stop response to the Test Unit Ready after BOT MSC Reset. Sometimes a random failure can occur, could you
- Re-run the suite to see if still continue to fail
- Switch USBCV "Select Test Mode" to
Debugand run the only failed test to see if it still fail when running alone.
I am not entirely sure what is wrong, sometime it can be caused by Data toggle mismatched when unstall. Also make s...
Thanks for confirmation that application is fine and should work without problems.
I tried to run it on LPC55S69 (that I'm not familiar at all) and pyocd filed so I gave up.
I do have access to nrf52840 so I will compare behavior if needed and find the problem soon.
@kasjer no problem at all, I am glad that I could help. Btw, for chapter9 test suite, it is best to test with hid_composite example, since that has remote wakeup attribute set, and the example will attempt to wake system up when suspended while cdc_msc example does not https://github.com/hathach/tinyusb/blob/master/examples/device/hid_composite/src/main.c#L215 . There are 2 tests for this: one host enabled the remote wakeup, another it disables to test if device respect that.
Ups, I could have added Chapter 9 test on HID instead of MSC, that did ask for wake up button activation. It work on pro-dk and usb-dk.
I will attach this file once I have MSC tests fully working.
@kasjer no need to attach it for proof, your words is enough. Just want to mention since it can be easily missed :) . I have updated your DA146xx result to #1059 as reminder. Later on if you (or me) manage to figure it out, feel free to post it here or there (whichever is more convenient to you).
it is not the bug of this library (convert to discussion), Since stm32f103 work just fine. Each mcu has their own special thing to port so that I could work with the stack. Similar mcu within a same vendor's family has their difference as well,
I don't have the mcu, therefore I don't think I could help. It just an porting question for a new MCU.
remove unnecessary files
Absolutely! When it is working & tested, you WILL get a CLEAN pull request .
The files in .TMP will ultimately be the MIDI host /examples/, but I want to see the class driver working before I try to use it as a player or synth.
The final version will also NOT contain abominations like : https://github.com/hathach/tinyusb/pull/1122/commits/62b1529f27f694cdd672b64542a92e70cf4c390a#diff-e7025ce0e682cf4e30670612dd559328a733bb6a3ec53e449e51fb7088ef9155R40
.....
I'm working on adding TinyUSB support for the DWC USB controller from Synopsys in the Broadcom chips on the Raspberry Pi board (BCM2835, BCM2836, BCM2837 and BCM2711). I've haven't managed to get it working so I wanted to open this issue in case others wanted to help get it going.
My working branch is here: https://github.com/tannewt/tinyusb/tree/rpi I'm targeting the compute module 4 on an IO board first because it has a USB micro B plug on it for device mode.
I've modeled the init seq...
...I'm a n00b to "the git(hub) way", and mostly just wanted to make sure I exposed everything here - in case someone else wants to help, or 'steal' some code. [I also need to add MIT headers to all my files]
No problem at all, I am not git expert either, just use some GUI, that make adding file, commit and push easier. I uses git-cola on Linux, but any should do the work.
@qingliyu I see you didn't use the hid_boot_interface as it is, but a custom firmware. It is what confuse me, please make sure you specify it exactly as it is in the bug report. The reason for HID_REPORT_TYPE_INVALID, is lacking of hid parser as mentioned above. For now when encounter this, you need to process the data as how you specify it in the report descriptor i.e read the first byte as report ID if you use report ID for output report. I will try to implement an simple hid parser later ...
Is your feature request related to a problem? Please describe
UVC is added by #1118 This issue is used to keep track of current status of video class driver on each DCD ports. Once it is all passed, we could close this.
| MCU | Video Capture | Note |
|---|---|---|
| nRF52840 | :heavy_check_mark: | |
| rp2040 | :heavy_check_mark: | |
| KL25z | :heavy_check_mark: | |
| SAMD21 | :heavy_check_mark: | |
| ... |
Hi @hathach :) I tried UVC last night and found errors in the example descriptor. For one the UUID of the format is wrong (can be seen in dmesg on Linux). Then there are more complaints from the kernel. It is not at all working on Mac and on Windows it shows the camera but fails to init. I will do some more looking into if someone does not do it before me :)
@me-no-dev yeah, I saw my Linux machine complaining about the format as well. haven't tried to find the cause just yet. Please let me know if you could figure out why.
[45883.869206] usb 3-4: Product: TinyUSB Device
[45883.869208] usb 3-4: Manufacturer: TinyUSB
[45883.869209] usb 3-4: SerialNumber: 123456
[45883.877143] uvcvideo: Unknown video format 3231564e-0000-0010-0080-719b3800aa00
[45883.877147] uvcvideo: Found UVC 1.50 device TinyUSB Device (cafe:4020)
[45883.877150] uvc...
The UUID thing is easy. For example this line should become (swap some bytes). Same for the rest.
//#define TUD_VIDEO_GUID_YUY2 0x59,0x55,0x59,0x32,0x00,0x00,0x10,0x00,0x00,0x80,0x71,0x9B,0x38,0x00,0xAA,0x00
#define TUD_VIDEO_GUID_YUY2 0x59,0x55,0x59,0x32,0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
@me-no-dev
Thank you for finding the bug! I was misunderstand byte ordering of GUID.
Describe the PR
GUID for uncompressed formats were wrong.
Additional context
The bug is mentioned by https://github.com/hathach/tinyusb/issues/1142#issuecomment-943285226
Variable used for logging only produces unused variable warning when logging is off
sorry, ci failed due to me messing up one of the tool for analyze the linker map. will fix it asap
sorry, ci failed due to me messing up one of the tool for analyze the linker map. will fix it asap
just tested, linux does not complain about the format anymore. Thank you for the PR. Still haven't tried to find an app to test with, will do later on.
[149825.252622] usb 3-3: Product: TinyUSB Device
[149825.252623] usb 3-3: Manufacturer: TinyUSB
[149825.252624] usb 3-3: SerialNumber: 123456
[149825.260633] uvcvideo: Found UVC 1.50 device TinyUSB Device (cafe:4020)
[149825.260637] uvcvideo: No valid video chain found.
thank you for the PR.
Consumers of TinyUSB in the RP2040 (or via our stdio support) who wish to set higher warning levels for their project along with -Werror are forced to manually suppress warnings. This change makes life much easier for them
- physically suppress warnings in TinyUSB headers using pragmas so they don't break -Werror compilation of external C/C++ source files that include them directly or indirectly
- fix all compiler warnings in rp2040 port
- add cmake method to rp2040 port to allow an e...
note i didn't go as far as actually fixing all the warnings in TinyUSB itself, though that is something to consider for later
๏ผ hathachใI seem to understand what you mean๏ผUsing TUD_HID_DESCRIPTOR, the ๏ฝ๏ฝ will use the control endpoint to transmit. Using TUD_HID_INOUT_DESCRIPTOR, the ๏ฝ๏ฝ will use the ๏ผฏ๏ผต๏ผด interruptใendpoint for transmission๏ผ
@hathach I seem to understand what you mean๏ผUsing TUD_HID_DESCRIPTOR, the ๏ฝ๏ฝ will use the control endpoint to transmit. Using TUD_HID_INOUT_DESCRIPTOR, the ๏ฝ๏ฝ will use the ๏ผฏ๏ผต๏ผด interruptใendpoint for transmission๏ผ
note i didn't go as far as actually fixing all the warnings in TinyUSB itself, though that is something to consider for later
What is the rest of the warnings, I didn't see any with existing build. I normally only run make BOARD=raspberry_pi_pico all maybe I miss some compiler flag ?
examples/device/cdc_msc$ make BOARD=raspberry_pi_pico all
../../rules.mk:154: warning: overriding recipe for target 'clean'
/home/hathach/Dropbox/tinyusb/tinyusb/hw/bsp/rp2040/family.mk:15: warni...
@hathach I seem to understand what you mean๏ผUsing TUD_HID_DESCRIPTOR, the ๏ฝ๏ฝ will use the control endpoint to transmit. Using TUD_HID_INOUT_DESCRIPTOR, the ๏ฝ๏ฝ will use the ๏ผฏ๏ผต๏ผด interruptใendpoint for transmission๏ผ
Yeah, it is the case, the device stack does not include an hid parser for now. I will reopen this as reminder to write the parser later on.
Describe the PR
This resolves to problems that prevent USB3CV compliance test to pass for DA146xx devices.
- interrupt for EP IN STALL send notification was filling TXFIFO with ZLP that resulted in first command
wrong response after endpoint was un-stalled. - If more data arrived in RX FIFO then were scheduled for reception in dcd_edpt_xfer(), extra bytes were
left for next read. It resulted in compliance test failure for MSC device.
Now TX FIFO is not filled for stalled endpoint ...
Here are test results:
This time Chapter 9 tests were run on HID with remote wake up tested.
USB3CV.zip
For reference behavior I used STM32F407 board that was working as test expected.
For some reason when MSC tests were run on PCA10056 it was failing almost all tests I'm not sure if this was just my board or some regression snicked in.
Describe the PR
USB3CV tool complains about too short serial number being used
in MSC device.
This just extends serial number to 12 characters, it makes it
easier to analyze USB3CV logs where this unnecessary warning
made output red.
Additional context
Offending warning:

Operating System
Windows 10
Board
Curiosity Nano (ATSAMD21G17D)
Firmware
examples/device/cdc_dual_ports
What happened ?
The CDC dual port example is supposed to 'echo' received characters from either port to both ports (lower case to one port, upper case to other port).
When I connect my 'curiosity nano' board (ATSAMD21G17D) to a Windows 10 PC, two additional Comm ports are visible after it enumerates. I open two instances of 'TeraTerm', one attached to each port. Tera...
uvcvideo: No valid video chain found.
This message is here. I guess the message indicates no input terminal connects with the streaming interface on the chain.
This may be related to the Media Controller API.
The configuration descriptor of video_capture has a input terminal as a [COMPOSITE_CONNECTOR](https://github.com/hathach/tinyusb/blob/4d0cf6135a352f966...
Hi,
This PR based on #637 by supporting RT-Thread RTOS. TinyUSB has been registered to the RT-Thread software packages center. Developers can use TinyUSB more easily by installing the TinyUSB package in package manager center.
This PR includes two SConscript files. RT-Thread uses Scons to organize files rather than CMake or Makefile, so it will not cause any conflicts with existing Makefiles. Meanwhile, this PR also conta...
Describe the PR
Update the configuration descriptor of video_capture example to change input terminal type to camera from external.
Additional context
It may be Linux has no support for external input terminal.
@hathach
If you don't mind, could you confirm this PR on your Linux environment? I guess that Linux has no support for an external input terminal type.
UPDATE: I see, adding those -W option, I will try to fix these warnings within the stack.
yeah gcc is being a bit weird with uint16_t ... so some of them are slightly spurious
(note we don't by default build with higher warnings, however we do test our SDK with them, because some users (and some projects) use higher warning levels by default) (and -Werror)
(void) rhport; should already suppress the warnings. Does it still throw the warning, or just you prefer to use the __unused macro. It is nice, but I tend to use non-compiler specific if possible. Though since this is rp2040 specific, it is up for you to decide.
yeah gcc is being a bit weird with
uint16_t... so some of them are slightly spurious
(note we don't by default build with higher warnings, however we do test our SDK with them, because some users (and some projects) use higher warning levels by default) (and -Werror)
the more compiler flag, the better, I am making an PR to addrss the -Wcasl-qual after the release https://github.com/hathach/tinyusb/tree/fix-warnings . The warning make sense and worth the effort to resolve. `-Wredu...
Here are test results: This time Chapter 9 tests were run on HID with remote wake up tested. USB3CV.zip
Superb !! great effort to get DA146xx fully passed the USBCV.
For reference behavior I used STM32F407 board that was working as test expected. ~For some reason when MSC tests were run on PCA10056 it was failing almost all tests I'm not sure if this was just my board or some regression snicked in.~ I used Pr...
@kkitayam it has improvement, linux now attempt to GET_DEF(PROBE), I have no idea what that means now, but definitely better pre-PR
[207416.877205] usb 3-4: new full-speed USB device number 87 using xhci_hcd
[207417.043275] usb 3-4: New USB device found, idVendor=cafe, idProduct=4020, bcdDevice= 1.00
[207417.043279] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[207417.043280] usb 3-4: Product: TinyUSB Device
[207417.043281] usb 3-4: Manufacturer: TinyUSB
[2...
yeah, thanks. I notice this as well, and intend to do this myself but keep forgetting.
Thanks for your PR to improve the rt-thread port. I am not familiar with SConscript, but I will give a try whenever I could. However, there is a few changes I would like to make
- the rt-thread/README.md is very helpful, but it should be added to the docs/ instead https://github.com/hathach/tinyusb/tree/master/docs/reference
- all the
*.candtusb_congifg.hunder rt-thread must be removed. These are application specific files in the usb stack point of view and shouldn't be placed u...
The most surprising thing for me was that the cdc_dual_ports example was echoing data from one port to the other when only the 'tud_task()' was called in a loop.
This is 100% not the case, could you check
- how did you compile the code, ?make sure you
make cleanfirst when modify the code and - double check the flashing process or flash contents.
The problem turned out to be a broken installation of 'com0com' I had installed long ago. The two com ports created by com0com don't appear in the list of ports in device manager (Win10/64bit), but do appear in the TeraTerm serial port list. Somehow (because Win10 doesn't list them in device manager?) windows sees them as 'free to allocate' (although they were still serviced by com0com... very odd).
I fixed this temporarily by pushing the TinyUSB serial ports to different port numbers, and...
@mws-rmain You may find the Device Cleanup Tool and COM Name Arbiter tools here: https://www.uwe-sieber.de/misc_tools_e.html to be useful to clean up the COM ports.
Thanks, Dan.
Seems like some interesting & useful utilities at that link. I'll be bookmarking it for general reference, and I've downloaded the cleanup tool to help me clean up ports right now.
In my case, I found the installation program for com0com I used & used it to 'de-install'. The build was old (circa 2016), so that may have played a part in Win10-64b not properly/fully recognizing it's ports. I think it was prudent to use this specific tool to un-install, then clean up generally, gi...
@hathach Thank you for confirming and logging!
Update: confirmed that the GET_DEF() is not currently handled.
Ahh, I did not implemented handling for the request. Other requests(GET_RES, GET_LEN) were not implemented, too. I add support for these.
@hathach I have a bit of a strange situation here. Trying to get UVC to work on a Mac (that is the only computer currently available to me) and for some reason the ESP32S2 is stalling on SET_CONFIG?
<img width="2032" alt="Screen Shot 2021-10-19 at 11 44 25" src="https://user-images.githubusercontent.com/12663778/137875340-9f203db6-cc81-4395-be78-3d27afbecd55.png">
@me-no-dev I haven't tested with esp32s2. One note that although using the same synopsys dwc as stm32, stm32 driver receive more update and implementation to support ISO transfer and other improvement by other contributors. I have an plan to sync the driver of esp32s2 and/or unify the synopsys dwc2 ( since it is very common) but haven't got time to do so. I will try to pull out the esp32s2 to test with uvc/uac later on. It probably needs to have some fifo allocation update etc ...
@hathach it's not an S2 driver problem. I am using BULK endpoints (grabbed a descriptor from a working camera). It's something that TinyUSB does not like about the descriptor, because other devices work fine (and SET_CONFIG is ACKed).
Question is more, do you have any idea what TinyUSB might not like in the descriptor (it is parsed OK by the OS and all... working camera descriptor)
@hathach it's not an S2 driver problem. I am using BULK endpoints (grabbed a descriptor from a working camera). It's something that TinyUSB does not like about the descriptor, because other devices work fine (and SET_CONFIG is ACKed). Question is more, do you have any idea what TinyUSB might not like in the descriptor (it is parsed OK by the OS and all... working camera descriptor)
if the config parser spot something unusual, it will normally output through the uart log. Could you enable...
I doubt this is chip specific :) here is the descriptor:
const uint8_t jpeg_cam_descriptor[] = {
// Interface Association Video/Interface Collection
0x08, // bLength
0x0B, // bDescriptorType (Interface Association Descriptor)
0x00, // bFirstInterface 0
0x02, // bInterfaceCount 2
0x0E, // bFunctionClass 14 (Video)
0x03, // bFunctionSubClass 3 (Interface Collection)
0x00, // bFunctionProtocol 0
...
@me-no-dev can you enable the CFG_TUSB_DEBUG = 3 then check its out put /
It came out to be that the video driver is expecting interface protocol 1 for some reason: https://github.com/hathach/tinyusb/blob/master/src/class/video/video_device.c#L972
@kkitayam can you comment on this requirement?
@me-no-dev
UVC 1.5 spec. describes that bInterfaceProtocol must be set to PC_PROTOCOL_15(=1). So, I added the condition at that statements.


[207417.053259] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
b3b6b4f adds these requests handlings. It suppresses probably the warning.
net_lwip_webserver and ./lib/networking/ code is tweaked to allow the user to enable LWIP_IP6 if desired.
To allow legacy code to compile, lwip's ip_addr_t maps into the newer ip4_addr_t type when LWIP_IP4 is enabled but LWIP_IP6 is not enabled. However, if both LWIP_IP4 and LWIP_IP6 are enabled, ip_addr_t maps to a struct with a union for both ip4_addr_t and ip6_addr_t. Since the ./lib/networking/ code was written for IPv4 only and presumes IP4-only lwip, the previous code breaks. Some...
RT-Thread is not just a kernel. RT-Thread contents a device driver framework layer which will provide a uniform API for users. These *.c files port for device driver framework rather than a specific application.
RT-Thread is not just a kernel. RT-Thread contents a device driver framework layer which will provide a uniform API for users. These
*.cfiles port for device driver framework rather than a specific application.
If it's not appropriate to place them inosal/rt-thread, where should I place them?
yes, and device driver framework should be placed on top of the usb stack not inside it. I am not familiar enough with rt-thread to give suggestion.
Thank you for your patience in explaining. So I move them out of the tinyusb/src and make a new folder sys/rt-thread to place them. Please review.
Operating System
Linux
Board
pca10095 should be same for pca10056 or other NRF
Firmware
TinyUSB 0.12.0
What happened ?
Board initialization for NRF5x (board_init() or equivalent) enables VBUS interrupt.
Later USB stack is initialized in tusb_init().
If VBUS interrupt fires before tusb_init() finishes, it can enable normal USB interrupt before tusb_init() would do it.
Then normal USB interrupt tries to post BUS RESET event and _usbd_q may not be ready yet and that...
Thank you for your patience in explaining. So I move them out of the
tinyusb/srcand make a new foldersys/rt-threadto place them. Please review.
No problems, however this is still not correct way to add these, in fact we cannot put these in this repo. Sorry if I am not making it clear enough. Files such as descriptors, msc device which implement callbacks are application scope. Although you tried to make it easier for rt-thread user, those still belongs to application and canno...
[207417.053259] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
b3b6b4f adds these requests handlings. It suppresses probably the warning.
@kkitayam I am in the middle of other work with pi4, will test this out as soon as I could.
Just tested and it works great. Linux no longer complains about unsupported request. I still haven't found an application similar to virtualdub but this PR is already great enough to merge
[ 253.418744] usb 3-2: new full-speed USB device number 11 using xhci_hcd
[ 253.595921] usb 3-2: New USB device found, idVendor=cafe, idProduct=4020, bcdDevice= 1.00
[ 253.595922] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 253.595923] usb 3-2: Product: TinyUSB Device...
@hathach
Thank you for confirmation! I am happy to hear fix the warning.
@hathach Thank you for confirmation! I am happy to hear fix the warning.
no problems, I am the one to say thanks :)
thank you for the report, yeah, I think I did see this once a while ago. I will try to put up some work to prevent this race condition.
Describe the PR
Increase compiler warnings flags to compile with -Wcast-qual -Wnull-dereference as pointed out by #1145 (-Wconversion is not supported since it produce many false positive with any arithmetic expression with non-32 bit variables).
Thank you for your effort
I believe this issue can be closed. The above code was included in PR #1107.
โฆmenting past unsent data. Closes #1105.
This does seem to be resolved on the latest master. Webserver is functional and original problem can't be reproduced.
[ 1518.835363] usb 1-1.1.1: new full-speed USB device number 15 using xhci_hcd
[ 1518.949582] usb 1-1.1.1: New USB device found, idVendor=cafe, idProduct=4020, bcdDevice= 1.01
[ 1518.949585] usb 1-1.1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1518.949586] usb 1-1.1.1: Product: TinyUSB Device
[ 1518.949587] usb 1-1.1.1: Manufacturer: TinyUSB
[ 1...
[hathach/tinyusb] New branch created: rm\-ep\-size\-bitfield
Describe the PR
Detailed explanation can be found here #1114 . In sum up, there is issue with compiler and bit-field order when compiling with big endian and different bit-order. It is best to just use uint16_t for wMaxPacketSize and use bitmask op. Helper tu_edpt_packet_size() extract the max packet size with endian consideration.
@Wini-Buh bit-field in the wMaxPacketSize is removed by #1161 , please check it out to see if that works for you.
Superb ! Thank you for looking at this, this is my bad, I didn't pay attention enough to variable queued_len (got changes).
Yeah, you are right, msp430 does not support ISO transfer. Though the dcd_edpt_xfer_fifo()` can still be useful, it allows the driver such as cdc to interact directly using fifo rather than an continuous linear buffer as a middle-man. I haven't got time to make use of that, but we could optimize that later on.
Describe the PR
MIDI Program Change and Channel Aftertouch messages are not currently handled. They are sent correctly by accident, depending on leniency of host OS version and if tud_midi_n_stream_write() is called with a buffer containing a whole message buffer and not byte-by-byte. These types of MIDI messages are 2-bytes long (instead of the common 3-bytes) and tud_midi_n_stream_write() doesn't have case to handle them. This PR adds that case.
Additional context
See issu...
[hathach/tinyusb] New branch created: generalize\-synopsys\-dwc2
Describe the PR
Generalize Synopsys DWC2 driver, implement #382 . New driver is at synopsys/dwc2 For the time being, application can still pick the existing driver e.g st/synopsys/dcd_synopsys.c for stm32. Using this generalized driver is user choice until proven reliably.
MCUs that use DWC2
- ST STM32 (F4, F7, H7 etc ..) OTG
- Espressif ESP32 S2/S3
- Giga GDVF103
- Silabs EFM32
- Broadcom bcm28/27 on RPi
Ref: linux driver for dwc https://github.com/torvalds/linux/tree/mast...
Describe the PR
A tiny minor update. dcd_esp32sx.c doesn't use any APIs in periph_ctrl.h but the USB interrupt source number listed in soc/periph_defs.h.
Thank you very much for your PR. Look great, I only has a minor request to use the enum instead of magic number (I know existing code use magic, will change later on).
may be using the enum MIDI_CIN_PROGRAM_CHANGE and MIDI_CIN_CHANNEL_PRESSURE would be better. I know others are using magic number. We will change it later on to a switch to prevent missing case like this.
Yes, the if statements above and below should also be enums (0x8, 0xE, 0xF) but I was trying to match style.
Thanks! I can do a separate PR that changes all the magic numbers to enums.
Thanks! I can do a separate PR that changes all the magic numbers to enums.
Don't worry about it if you don't have time. I will do that refactor work later on next time I need to do something with midi. The PR is good to merge now.
Not sure if anyone but bots live here, but does anyone have suggestions for reliably compiling tinyusb on MacOS? Out of the box TinyUSB doesn't compile because MacOS ships with rather ancient 2006 version of GNU Make 3.81 and TinyUSB's makefile uses newer features. I can install Make 4.3 as "gmake" with homebrew and build for SAMD21 with gmake BOARD=itsybitsy_m0 but I cannot gmake BOARD=raspberrypi_pico. It gives the error:
bok4bok3:~/projects/adafruit/tinyusb-todbot/examples/device/midi_test/
% gmake BOARD=raspberry_pi_pico
../../rules.mk:154: warning: overriding recipe for target 'clean'
/Users/tod/projects/adafruit/tinyusb-todbot/hw/bsp/rp2040/family.mk:15: warning: ignoring old recipe for target 'clean'
gmake -C _build/raspberry_pi_pico
gmake[1]: Entering directory '/Users/tod/projects/adafruit/tinyusb-todbot/examples/device/midi_test/_build/raspberry_pi_pico'
gmake[1]: *** No targets specified and no makefile found. Stop.
gmake[1]: Leaving directory '/Users/tod/projects/adafruit/tinyusb-todbot/examples/device/midi_test/_build/raspberry_pi_pico'
gmake: *** [/Users/tod/projects/adafruit/tinyusb-todbot/hw/bsp/rp2040/family.mk:12: all] Error 2
I can build with the pico-sdk otherwise just fine. I'm cool with MacOS being an unsupported build platform for TinyUSB but it seems so close!
can you just install it as make, so it hides the old one in your path?
I thought homebrew would just do that
In general, Homebrew does not over-ride system-provided tools as that can cause side-effects for other programs or system updates. I could add 'gnubin' it to my path so "make" would be the newer one (and I've tried that), but that doesn't fix the issue I'm seeing.
and yes, that is the make I have installed
yes, thanks, but that is not my problem. I am running the latest make
I should not have brought it up
it does not appear to be. I've added latest make to the top of my path and I still get the same error when doing make BOARD=raspberry_pi_pico
oh no wait...
doing a make clean and it seems to be working now that newer make is at top of path. SIGH. thanks Dan for getting me to check that for the 30th time ๐
np ๐ my attempts at the past to try to develop on the Mac (only out of necessity) have always led to hair-pulling.
case-insensitive filesystems, etc.
that was my experience several years ago, but it's been pretty good lately. And yeah, both Windows & Mac are guilty of the case-presevering-but-insensitive silliness ๐
at least Homebrew has made the Python install situation so much better than it was five or so years ago
Operating System
Others
Board
RP2040
Firmware
https://forums.raspberrypi.com/viewtopic.php?t=322460
What happened ?
I have forked picoprobe firmware for RP2040, added a 2nd CDC UART Bridge and a SUMP-Logic analyser, but the 3rd CDC Endpoint won't work.
How to reproduce ?
Compile firmware mentioned in Link, upload, try picocom on ttyACM0, ttyACM1, ttyACM2. The ACM on endpoint 3 will make the computer hang.
Debug Log
No response
Screenshots
No response
Hi,
TinyUSB works fine with three CDC ports. I've created a gist that is a light editing of the examples/device/cdc_dual_ports in current TinyUSB, located here: https://gist.github.com/todbot/d4f4e0111c7829fd55b0c3b68114d9a5
Tested it on a Raspberry Pi Pico connected to a MacOS laptop, all three ports work as expected.
Which version of TinyUSB are you using? I know the pico-sdk used an older fork awhile back.
yeah, please provide:
- the git hash of tinyusb you are compiling with. If it matches current git master and issue still exists
- provide the project file to compile with in the format similar to this repo's example (whole .c + .h for code and descriptors), you could base your example on the existing dual cdc one here https://github.com/hathach/tinyusb/tree/master/examples/device/cdc_dual_ports
I tried to run hid_composite_freertos on esp32s2 but it results in a fatal fault
Any in my other project with TinyUSB on esp32s2, tud_task(); just hangs
My log told me it stopped between line 485 and line 494 which makes no sense to me
yeah, please provide:
- the git hash of tinyusb you are compiling with. If it matches current git master and issue still exists
- provide the project file to compile with in the format similar to this repo's example (whole .c + .h for code and descriptors), you could base your example on the existing dual cdc one here https://github.com/hathach/tinyusb/tree/master/examples/device/cdc_dual_ports
- The TinyUSB in my pico-sdk is at d49938d0.
- The source is at https://gitlab....
- your tinyusb version is too old, please use the one in the github
- your example need to be more simplified to reduce as much application-code so that we are sure it is stack bug and not app's one. Please modify the stock example to have similar config to see if it has the same issue with 3 cdcs.
1. your tinyusb version is too old, please use the one in the github 2. your example need to be more simplified to reduce as much application-code so that we are sure it is stack bug and not app's one. Please modify the stock example to have similar config to see if it has the same issue with 3 cdcs.
- Will do asap and try again.
- I can do that - the problem seems to be with the 3rd descriptor, because if i put cdc_uart or my logic analyzer code on descriptor 2, then i...
I have take a quick look at your descriptors:
- using latest code will fix this. Early tinyusb port of rp2040 limit highest endpoint number to 8, therefore your descriptors does not work. Or
- you can change your endpoint numbering. You don't have to increase their base number each endpoint. Both 0x01 and 0x81 can exist together.
I've tried on HEAD, but compile / link errors are rising - got to sort it out first.
/usr/local/Cellar/arm-none-eabi-gcc/10.3-2021.07/gcc/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/picoprobe.dir/Users/x/dev/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c.obj: in function `_hw_endpoint_start_next_buffer':
rp2040_usb.c:(.text._hw_endpoint_start_next_buffer+0x5c): undefined reference to `tu_u32_low16'
/usr/local/Cellar/arm-none-ea...
It would be good to open an issue in the TinyUSB repo if you feel it is a bug. Also check the current list of issues to see if it's been reported already, and checked the closed issues to see if someone else found something similar but it was solved.
I did check existing issues and I canโt find something relevant. I want to make sure where the issue is originally from before I make an issue report.
We don't do a lot of TinyUSB support in this channel, so go ahead and open an issue. Thanks.
no problem, please close the issue if everything works out
This just adds a simple config for the board, I've tested that it's usable with a fork of https://github.com/greatscottgadgets/apollo
Since this board doesn't have a standard LED or BUTTON I've made those optional
Adds support for Adafruit's Trinket M0 board.
Also adds initial support for UART for the board family.
since we always defined uart_init(), why would we use weak function here. Are you planning to allow application to overwrite this ? Otherwise I think we could just simply remove the weak attribute
Yes, exactly. The Trinket M0 only has very few pins / pads available for external hardware components.
In fact, I would argue it would make sense to make board_init() a weak function so users can easily replace it if need to.
it only makes sense if this repo providing board abstraction for application. Unfortunately, I have no intention to do so. The whole bsp and examples in this repo is only used to demonstrate how tinyusb API is used, and prove and test that it works on hardware. These can be changed completely without any notices.
Sum up application and user should write their own bsp init code for their own board. Therefore please remove the weak attribute in the function.
Hi @hathach Will you consider this quick MR? Some API like periph_ctrl.h is going to be private, thus the including path will slightly change in the future. This MR can make the DCD driver stay work.
Hi @hathach Will you consider this quick MR? Some API like periph_ctrl.h is going to be private, thus the including path will slightly change in the future. This MR can make the DCD driver stay work.
while working on generalizing DWC2 driver, I find out that L4 indeed use an different revision 3.10a vs 2.81a on F407. This revision or at least on L4, both SETUP and XFRC bit is also set on DOEPINT when new set up received (while the on other mcu only SETUP bit is set). This cause dcd to register 2 events for the setup recived (1 for setup, 1 for 0 byte data). which confuse the usbd.
Note; on F7 with revision 3.20a, only SETUP is set, so it is not sure this only happens on L4 with 3.10a,...
[hathach/tinyusb] Pull request review submitted: #1164 update dcd\_esp32sx with correct include list
look good. thank you for the pr.
Update: this is indeed a bug (or feature) of the dwc2 3.10a where it will set both OUT transfer Complete ISR first, then Setup Complete ISR afterwards in one single setup packet. confirmed in the ST hal code https://github.com/STMicroelectronics/STM32CubeL4/blob/master/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c#L2213
I tested with L4P5, which use 3.30a and does not has the same issue. That explain why some could get it running in some variants of L4 mcu.
Some debug logging i...
When using FreeRTOS, with the SysTick being active, there is a race condition between the elapsing of the first tick and execution of vTaskStartScheduler().
[hathach/tinyusb] Pull request review submitted: #1176 samd21: enable SysTick only if running w/o OS
Yeah, this should be done for all ports. I have done to most but still forget to do it all. Thank you for the pr
On this paritcular L476 rev 3.10a (or maybe based on actual configuration), additional transfer complete ISR is triggered in 2 event
- setup received
- control write data complete.
This has been addressed by following commit, this could be closed when generic dwc2 branch is merged.
https://github.com/hathach/tinyusb/pull/1163/commits/aa682d730123a1191782b1a160ce25ea20580ee6#diff-1f2490fb8ceeb23801391e207e1972f09dd6a7fbbe431154211cc1896dc363a0R1003-R1023
somehow the example (cdc_msc) does not work with latest broadcom peripherals since commit
I have tried poking around and making modification where I think it could help. It seems usb phy is initialized but IRQ is not triggered. This proves to be too much knowledge for me digest.
From what I can tell this is a caching issue, not an interrupt one. The first gig of memory is marked as cachable now. If I change it to non-cacheable then the problem goes away. Does the DWC write to or read from any memory directly? It would need to be invalidated or cleaned if so.
diff --git a/broadcom/mmu.c b/broadcom/mmu.c
index 098c728..3eefaac 100644
--- a/broadcom/mmu.c
+++ b/broadcom/mmu.c
@@ -24,7 +24,7 @@ void setup_mmu_flat_map(void) {
for (uint64_t i = 1; i ...
thanks @tannewt for looking into this, I thought of the cache as well, did a quick check but didn't see any shared memory between cpu and usb. I could miss something, will poke more at that direction. thanks for looking into this +1 +1
Thanks to Scott hint, I have narrowed it down to
- Adding ISB() after
BP_EnableIRQ(USB_IRQn);fix interrupt not triggered with caching. https://github.com/hathach/tinyusb/pull/1163/commits/b51d038b656688b6150470d23752a306ee150da3#diff-da707f06ba279521a02d7034a0c505b4de440ad706f28c00c4f0cb411ec56373R50 - However while adding Timer1 for LED blinky, I figure out that enable TIMER1 IRQ will auto fix the issue with caching & USB IRQ (above fix is not needed anymore :confused: :confused: ). Th...
I have tested with sltb009a and didn't notice this issue, please give it a try again with the new dwc2 driver.
Thanks for testing, I will try again later today
Thanks for testing, I will try again later today.
and good job with the generalization of the driver
Describe the PR
dcd_synopsys.c included broadcom/interrupts.h before
preprocessor check whether file should be used.
Since mynewt build does not include all folders it resulted in build
error.
Now offending include is moved few lines after preprocessor check.
Additional context
No change in logic.
No build should be negatively affected by this change.
Why also guard the common include and the USE_SOF define?
The issue is in fact fixed! good job.
I didn't investigate much, so I don't know what was causing it, just confirmed it was still present, and it's fixed as of the dwc2 merge
my system: Linux 5.14.12-zen1-1-zen x86_64 just for reference, I never tested this on windows or mac
[hathach/tinyusb] New branch created: perigoso\-patch\-1
remove known issue #750 from silabs EFM32GG table entry
thank you for testing it out
Thank you for the PR. IMO, We should only put unfixable hardware issue here. All software issue should just use github issue
Why also guard the common include and the USE_SOF define?
newt build system and other build system with auto-generate makefile such as arduino include all (dcd) sources files by default. When BCM2711 is not its target mcu, the include path of broadcom peripherals is not set and not even checkout. It is typical for dcd driver to check for mcu supported before including its peripheral header.
I don't disagree, having this hardcoded in the docs is just another thing to maintain.
BTW that table is largely incomplete, someone needs to correct it, i dont mind doing the pr if you made me a rough list
[hathach/tinyusb] New branch created: add\-xmc4500
Describe the PR
- Add support for Infineon XMC4500 which also use synopsys dwc2 controller
- Add initial bsp support for stm32g4, though g474 nucleo does not has usb connector and requires more clock/pin setup for usb (do later if have time).
yeah, we don't really have time to maintain that table every time we found or fixed any issues. There is issue list, and label, which is far more ideal for this job.
Yeah, the table is WIP, please do update if you have time. I don't have any list, I will spend more time with docs when I think the code is OK.
RP2040 HCD: Move invalid ep->active assert in hw_trans_complete. The ep->active should only happen if a setup packet was just sent. Otherwise the transaction is handled in hw_handle_buff_status. Fixes https://github.com/raspberrypi/pico-sdk/issues/649
Describe the PR
IAD was missing from BT interface descriptor macro.
This in itself did not matter much but it is in the specification so descriptor is updated now.
With missing IAD BT driver handled open separately for both interfaces.
For some time now BT is assumed to have 2 associated interfaces even when IAD is missing.
This inferred association resulted in only one call to btd_open() and second interface was no
handled at all.
This in turn resulted in assertion f...
I have an G474 nucleo and add bsp support for it (blinky and button work fine)
However, the board does not has usb connector and need to use usb breakout cable similar to the nucleo070 board. I tried a bit but couldn't get usb clock/pin set up probably. At the moment, I don't have time to go through its datasheet. If anyone could get the hardware side correct, I could get the rest running.
I did put a TODO for IAD here as well :smile:
Thank you, I notice this as well and put the TODO note for this :+1: . IAD in general is preferred since it allow device to be *composite and able to add more class such as DFU runtime etc ...
thank you for your PR, apparently I never run with DEBUG build with pico-sdk. I mostly just run make LOG=2 all as I did with other mcu. Will try to set the build to debug when LOG > 0 in the cmake later on.
Describe the PR
Add support for MSP-EXP432E401Y as a DCD.
This patch has no support for followings.
- Handling the dedicated DMA for USB
- Handling ULPI for high speed PHY
I have checked that following examples work with Windows 10.
- cdc_msc
- cdc_msc_freertos
- net_lwip_webserver
- uac2_headset
- video_capture
And I did the USB3CV test for CH.9, HID and MSC. CH.9 and HID passed, but MSC failed.
Additional context
This d...
Brilliant work, indeed, this mentor graphic is used widely on most of TI arm mcu. A quick google show that other TI also use this
- TMS320F28069
- Stellaris LM3S
- TM4C (tiva C), the msp432E is actually a re-branded from tm4c-129x
I have an TM4c123x launchpad board and could help to test it out, give me a bit of time to get its bsp set up. Btw the core is called "USB 2.0 MULTI-POINT DUAL-ROLE CONTROLLER". Databook for is actually downloadable online by googling musbmhdrc
no worry about DMA, FIFO based actually can help to reduce the interim buffer from class driver e.g CDC. Although it is less idea on mcu with large SRAM, it give option to run it more efficiently on smaller mcu. I have an plan to drop class driver interim EP Buffer on supported DCD later on (selectable).
For ULPI, not really an issue as well, those requires board with external PHY and the software setup/config is pretty straightforward from my exp with stm32h743. Those can wait :)
Thank you for your comments. After https://github.com/hathach/ti_driver/pull/4 is merged, I will update the submodule for TI driver and status to ready for review.
FIFO based actually can help to reduce the interim buffer from class driver e.g CDC. Although it is less idea on mcu with large SRAM, it give option to run it more efficiently on smaller mcu. I have an plan to drop class driver interim EP Buffer on supported DCD later on (selectable).
Yeah, I agree and that's good.
Actu...
Thank you for your comments. After hathach/ti_driver#4 is merged, I will update the submodule for TI driver and status to ready for review.
merged !!
Actually, I didn't have boards with support for high speed, so I bought the board. But, I had not been know an optional board needed. disappointed After implement this patch, I have know it...
Yeah, I totally understand your feeling from my own experience. They didn't make it very clear from the feature page.
Thank you for merging. I have updated the submodule for TI driver.
Superb!! Although I don't have an msp432e to test with, but the dcd musb work flawlessly with tiva-C tm4c123 testing with cdc_msc and net_lwip_webserver (bsp is cherry-picked from #670). I did push the changes and enable ci for both msp432e & tm4c123. So please pull first if you still plan to push more code
I haven't looked at the code thoroughly, but it looks great as usual. Except the hacking generalized code I just added for tm4c. This PR is great enough for the merge. @kkitayam please ...
Thank you for your comments. I have no more changes regarding this PR. I am ready for merge!
I have an MSP432E board, and if I get a chance this week I will test the code on it.
Thank you for your comments. I have no more changes regarding this PR. I am ready for merge!
Superb !! Thank you for the great pr. Merged now
I have an MSP432E board, and if I get a chance this week I will test the code on it.
Looking forward to hear from your result. Please let us know if you find out any issues.
@robust walrus here i am ๐
i can find the usb related config files in micropython, but i cant find anything (even with search) in the circuitpython repo. what am i missing?
@faint nexus most of our interfacing code is here: https://github.com/adafruit/circuitpython/tree/main/supervisor/shared/usb
what OS are you on?
wireshark can sometimes help with getting descriptors setup
k, I'm on linux too
here is my lsbusb -v output for my pro micro which i succesfully use with hid-project library as hid and serial device at the same time
we do have newer configurable composite descriptors but the static bits shouldn't be too weird
it all looks relatively simple, it's just so much new at the same time ๐
haha
mh, i just tried to jerry rig the cdc component into my already working (and copied) hid code
so now its not really connecting and lsusb tells me it cant read the usb descriptors
no not yet. let me install it
I usually have a beagle usb sniffer to help debug as well
๐
we should look at the USB descriptor definitions in your C code
This is very useful: http://eleccelerator.com/usbdescreqparser/
aha! i found my mistake
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN) -> #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN)
now probably have something missing in my code, because the usb "handshake" is not really working now.
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
thank you very much for your effort. Tiva-C dcd support is implemented by #1183 . Although this pr is superseded, the ek-tm4c123gxl bsp is cherry picked :+1: :+1:
for anybody stumbling upon this: i also needed to up my usb_bcd from 0x0200 to 0x0210
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
Hello, that's really some good news, I'm sorry I couldn't do it before, wasn't keeping well until recently. Great to hear that the implementation was added! Thank you!
@robust walrus sorry to ping you again
i got the serial communication working and i am already debugging through it. now my hid commands are doing nothing. do you have a tip for me on how to debug it? Could/should i debug that with wireshark?
lsusb seems to report everything correctly now
dan has done our HID stuff
danh?
yup
@glacial stratus hey ๐ sorry to bother you this directly. do you mind helping me out?
np. do the HID devices show up on the host?
what is the host computer? is it linux?
yes
can you get the raw hex descriptors? Then paste them into http://eleccelerator.com/usbdescreqparser/. I find that easier to read than lsusb output
ok. give me a sec
can you turn off the CDC descriptors for now, so you can just see the bad HID descriptors?
the hid alone worked, so i believe that i do something wrong when using both togehter
let me try that real quick
ok, i need to comment out all the hid stuff, or it wont compile. thats a bit much now because i have to go to the gym in 15mins.
can i come back to you later?
before i leave @glacial stratus ```
0x09, // bLength
0x02, // bDescriptorType (Configuration)
0x64, 0x00, // wTotalLength 100
0x03, // bNumInterfaces 3
0x01, // bConfigurationValue
0x00, // iConfiguration (String Index)
0xA0, // bmAttributes Remote Wakeup
0x32, // bMaxPower 100mA
0x08, // bLength
0x0B, // bDescriptorType (Unknown)
0x00, 0x02, 0x02, 0x02, 0x00, 0x00,
0x09, // bLength
0x04, // bDescriptorType (Interface)
0x00, // bInterfaceNumber 0
0x00, // bAlternateSetting
0x01, // bNumEndpoints 1
0x02, // bInterfaceClass
0x02, // bInterfaceSubClass
0x00, // bInterfaceProtocol
0x04, // iInterface (String Index)
0x05, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x00, 0x20, 0x01,
0x05, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x01, 0x00, 0x01,
0x04, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x02, 0x02,
0x05, // bLength
0x24, // bDescriptorType (Dependant on Type)
0x06, 0x00, 0x01,
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x81, // bEndpointAddress (IN/D2H)
0x03, // bmAttributes (Interrupt)
0x08, 0x00, // wMaxPacketSize 8
0x10, // bInterval 16 (unit depends on device speed)
0x09, // bLength
0x04, // bDescriptorType (Interface)
0x01, // bInterfaceNumber 1
0x00, // bAlternateSetting
0x02, // bNumEndpoints 2
0x0A, // bInterfaceClass
0x00, // bInterfaceSubClass
0x00, // bInterfaceProtocol
0x00, // iInterface (String Index)
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x02, // bEndpointAddress (OUT/H2D)
0x02, // bmAttributes (Bulk)
0x40, 0x00, // wMaxPacketSize 64
0x00, // bInterval 0 (unit depends on device speed)
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x82, // bEndpointAddress (IN/D2H)
0x02, // bmAttributes (Bulk)
0x40, 0x00, // wMaxPacketSize 64
0x00, // bInterval 0 (unit depends on device speed)
0x09, // bLength
0x04, // bDescriptorType (Interface)
0x02, // bInterfaceNumber 2
0x00, // bAlternateSetting
0x01, // bNumEndpoints 1
0x03, // bInterfaceClass
0x00, // bInterfaceSubClass
0x00, // bInterfaceProtocol
0x00, // iInterface (String Index)
0x09, // bLength
0x21, // bDescriptorType (HID)
0x11, 0x01, // bcdHID 1.11
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType[0] (HID)
0x5C, 0x00, // wDescriptorLength[0] 92
0x07, // bLength
0x05, // bDescriptorType (Endpoint)
0x81, // bEndpointAddress (IN/D2H)
0x03, // bmAttributes (Interrupt)
0x10, 0x00, // wMaxPacketSize 16
0x05, // bInterval 5 (unit depends on device speed)
// 100 bytes
is this better for you to analyze?
it's easier to look over. I can compare it with our own similar descriptors
are you away for a while?
yeah sorry :/ max 3 hours. going to the gym+groceries with my wife
@glacial stratus i just compared the usb report of my working freedeck with my pi pico. there are some sublte changes
sorry, i was interrupted by a bunch of things and didn't get to look at this yet
also you can see the lsusb if you install CircuitPython on the Pi Pico. That will be similar
This should not be "unknown":
0x08, // bLength
0x0B, // bDescriptorType (Unknown)
0x00, 0x02, 0x02, 0x02, 0x00, 0x00,
i am out for the evening in a few minutes, sri
im comparing it against circuitpython right now!
circuitpython has midi also, but that should be straightfoward
left -> circuitPython
ok, I thought that was fishy, but apparently not ๐
im currently changing the usb_descriptor.c step by step and copying the hex dump from wireshark to compare it ๐
i got it working by copying this: https://github.com/dairequinlan/mechware/tree/main/src
its feels kinda wrong, because its not really obvious to me why it works, because he has no report there for cdc
i slowly changed my code to his code until i came to thid define #define EPNUM_HID 0x84
in my code it was 0x81. and i also have this defined in my code #define EPNUM_CDC_NOTIF 0x81 #define EPNUM_CDC_OUT 0x02 #define EPNUM_CDC_IN 0x82
so i upped the number to 0x84 and then it worked also with my code. i could even lower it to 0x83. makes kinda sense now ๐
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
Hello, that's really some good news, I'm sorry I couldn't do it before, wasn't keeping well until recently. Great to hear that the implementation was added! Thank you!
No problems at all, thank you very much for your PR & effort.
Operating System
Windows 10
Board
Raspberry Pi Pico RP2040 and Adafruit Macropad RP2040
Firmware
Pico C SDK Firmware Examples (and the same in Arduino IDE)
What happened ?
Set up
Standard Raspberry Pi Pico RP2040 and also Adafruit Macropad RP2040
Windows 10 Pro with Pico SDK, Recommended ARM GCC and additionally Arduino IDE
Windows 10 Pro Runtime OS Device Manager and additionally Windows 10 on ARM with the same universal device behaviour
Describe the bug...
Discussed in https://github.com/hathach/tinyusb/discussions/1185
Originally posted by mastupristi November 11, 2021
hi,
I'm using tinyUsb 0.12.0, on i.MX RT1051.
I'm successfully using the tud_cdc_line_state_cb() callback to be notified when on the PC I connect/disconnect to the ttyACM0 (on PC I use minicom).
The scenario is: with the usb cable plugged in I run minicom and the tud_cdc_line_state_cb() is called with dtr=1. In the moment I quit minicom the `tud_cdc_li...
Solution with enabling XCVRDLY in DCFG register worked great with STM32H743ZIT and USB3370B PHY by setting this bit in set_speed function. Thanks!
@tin- I have no issue with H743 tested on stm32h743 evaluation board (as well as other openh743 + phy add-ons). This issue probably does not affect the H743
This issue happens with USB33xx phys and synopsys usb core.
Operating System
Others
Board
raspberry pi pico (rp2040)
Firmware
examples/host/cdc_msc_hid/ master branch commit 6f59a2c
I am developing in Visual Studio Code and using a picoprobe for debug and serial console display.
What happened ?
The first time you plug a keyboard to the pico board, the keyboard works fine. The second time, the host fails to request a report and the keyboard does not work.
I did some digging on this and have two commits that seem to fix the ...
This pull request resolves issue #1192 in my testing.
When I was debugging the issue, I found that the host could not send report requests because the endpoint was claimed already. The first commit implements hcd_device_close() more completely so the hardware does not think the endpoints are doing anything and the second commit clears the claimed and busy flags for the device endpoints.
I am very new to this project. Is directly clearing the claimed and busy flags safe?
@diggit I have no problem getting stm32h743eval running with highspeed with on-board USB3320 PHY. It appear only has issue with more recent PHY. I will test to see if setting XCVRDLY still work with currently-working 3320 PHY. If not, then we can safely always set it to 1.

[hathach/tinyusb] New branch created: fix\-dwc2\-XCVRDLY
Describe the PR
Fix #496 by setting DCFG_XCVRDLY when using with external ULPI phy. It has no impact with H743 and currently-working older phy USB3320 (probably a fraction of ms delay). So I guess it is safe to just set it in all cases.
#1195 is up to fix this, please try it out since I don't have this combination to test with. The fix is applied to the new synopys/dwc2 driver (old stm/synopsys will be fading out in the future).
Thanks for reporting the issue, seems like host stack does not clean up all its state nicely. I will try to reproduce the issue and checkout your Pr #1193 as soon as I could.
For some reason my tud_task() is blocking my code
I'm in ESP32S3 with FreeRTOS. ESP-IDF 4.4. Latest TinyUSB master branch
I spent last 8hrs tring to figure this out but got no luck
Operating System
Windows 10
Board
ESP32-S3-DevKitC-1
Firmware
examples\device\cdc_msc_freertos
What happened ?
tud_task() caused a crash in examples\device\cdc_msc_freertos
How to reproduce ?
Compile the example for espressif_addax_1. (I know it's not the same board, but I can't tell any difference)
Debug Log
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4201ee3e
0x4201ee3e: esp_pm_imp...
I tried to compile the example because I run into issues with my custom firmware, tud_task() simply hangs my code.
@vital oracle I think the expectation is that tud_task runs in its own freertos task on esp. that's the case in circuitpython
So should I run it in itโs on task or in main (app_main) task?
I believe I tried both and both are not working but I will have to double check
circuitpython runs it off of app_main
Official examples runs it in itโs own task (Well the example doesnโt work for me, soโฆ.)
So it does run in itโs own task
ya
This did not result in a crash
But "TUSB Task" debug log only printed once
For some reason
This is a crash
After change #define USBD_STACK_SIZE (3configMINIMAL_STACK_SIZE/2) to (3configMINIMAL_STACK_SIZE) there no longer is a crash
I manage to fix it by change the
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE/2)
to
#define USBD_STACK_SIZE (3*configMINIMAL_STACK_SIZE)
I guess during the development, the stack size increased and no longer fits inside the original static stack
For some reason, my ESP_LOGI() doesn't want to print again inside the task if followed by tud_task(). What could be the cause of this?

currently, the tud_task() won't return, it will pend until there is new event. I have been thinking to tweak this behavior a bit, may do it later on. This issue is now closed, since it is not bug but a stack overflow.
currently, the tud_task() won't return, it will pend until there is new event. I have been thinking to tweak this behavior a bit, may do it later on. This issue is now closed, since it is not bug but a stack overflow.
I guess it is a bug for the examples but not the stack.
currently, the tud_task() won't return, it will pend until there is new event. I have been thinking to tweak this behavior a bit, may do it later on. This issue is now closed, since it is not bug but a stack overflow.
I guess it is a bug for the examples but not the stack.
yeah, you are right, I don't have any esp3s3 now for testing, will update it later one when testing with one.
yeah, you are right, I don't have any esp3s3 now for testing, will update it later one when testing with one.
I replicated the same issue with ESP32S2.
what is the value of configMINIMAL_STACK_SIZE? When printing inside a task, more stack is required. To be on the safe side, I would suggest 4KB as good value on ESP chips
@me-no-dev configMINIMAL_STACK_SIZE probably 128 or something, I always set the buffer size to smallest in example to prevent RAM buffer on smaller mcu. Since there is already an #if for ESP, I will push an update to bump it up to 4k
Can we make it configurable? Maybe from Kconfig or something like that?
Currently esp-idf is optimized and 3kB is enough for tasks with logs printing, and tinyusb not always will require to print logs.
Just idea, not requirement.
@chegewara it's an example, so setting it to the safe 4K should be enough. If it was a library feature, then maybe it would have made sense to be configurable.
@chegewara this is only for simple example for demonstration only. There is no way they will use all sram on the esp32sx, there is really no need to make it configurable from kconfig. The issue is with smaller mcu with limited sram.
Operating System
Others
Board
all
Firmware
hid gamepad
What happened ?
Sorry for complaining, but this comment is a bit old and misleading and HID gamepad descriptor does not match it.
Currently descriptor is built for 32 buttons.
How to reproduce ?
https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid_device.h#L313-L314
Debug Log
No response
Screenshots
No response
right, it is out dated, would you mind making an PR to correct it ?
hey, can anybody help me with putting my tud_task in a seperate thread? im running it on a pi pico
what are you using to manage threads? in CP we don't have it in a separate thread
Operating System
Windows 10
Board
STM32F405
Firmware
examples/device/hid_generic_inout
F405RG1.zip
What happened ?
I tested tinyUSB example on a STM32F405 board with OTG_HS full speed port. It works fine the first time plugged in, when i hot pluged, tud_hid_report() can't send report decause of failure of tud_hid_ready().
How to reproduce ?
Increase the sending interval.
Debug Log
_No response...
thanks for your answer. i already solved it quiet easily. instead of running the usb stuff on the second core, i just run my main logic on the second core using multicore_launch_core1(main_loop);
works like a charm
@robust walrus
but now i got a py-serial problem ๐
i programmed a serial api wrapper which completely works with the arduino version of my code.
also the web-serial code i have for the webapp still works just fine. using echo, stty and cat also works as before. but py serial just does not want to read the serial input
glad you got it working!
thx
I've tested #1195 and it solves this issue for my current HW setup (STM32H730 + USB3343)
thank you very much for your confirmation.
Operating System
Linux
Board
Pi Zero 2W
Firmware
CircuitPython: https://github.com/tannewt/circuitpython/tree/rpi/
What happened ?
usb_init hangs
How to reproduce ?
Run CircuitPython on the Zero 2W (BCM2837). It's USB is at a different address than the BCM2711. I think it's that address for the BCM2836 as well. How do you want to manage the different locations? Should the client code set it instead of having TinyUSB do it?
diff --git a/src/portable/sy...
We should use the USB_OTG_GLOBAL_BASE defined by broadcom peripheral repo. I hardcoded it since initially there is some macro naming conflict, plan to change it later but kind of forget.
its me again!
๐
i have found (some time ago) some unexpected behaviour with tinyusb.
when i write (from pc to pico) to cdc, i also have to have the read channel open (on pc) or else my serial data is ignored
this is not really good, because i cant send a big data set in one command with pyserial
@glacial stratus maybe you have some input for me again
Yes, data will be discarded if no one is reading on the host side. Are you expecting it to buffer before you open the serial port on the host side?
no
im expecting it to still read data from the pc
while the pc is not reading
because the pico isnt even writing anything in this timeframe
Could you explain the scenario in more detail? I don't think I understand.
i have the pc, with a library written in python (which uses pyserial)
i have a pico with c++ and tinyusb.
The pico has an ssd1306 oled attached.
Now i want to send data through serial with the library to the pico (which displays it on the oled).
its 1KB + some header bytes.
its perfectly working if i use
echo -e ".......data here........." > /dev/ttyACM0
and stty ....config here... /dev/ttyACM0 && cat /dev/ttyACM0 in another terminal
the echo and stty_cat method does not work if i dont open the /dev/ttyACM0 with cat.
then the pico ignores the data send by the pc
do you have a clearer picture now? i can give you more details if you want
so if you used pyserial directed to /dev/ttyACM0, it would still not work unless you did cat /dev/ttyACM0 in another window (which opens the input side)?
what is in your stty ... command?
stty -F /dev/ttyACM0 cs8 4000000 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts && cat /dev/ttyACM0
pyserial script does also not work correctly while i have cat running, dunno if that has something to do with exclusive mode or so
the stty command is copied from arduino docu iirc
so if you just use pyserial, without any of the other stuff, then the pico does not receive anything?
are you using Arduino or the SDK with raw tinyusb?
sdk with raw tiny
does it work with pyserial if you use Arduino or CircuitPython?
could you point to your program?
sure thing, give me a sec
more specifically this line
this o_debug command just outputs to my oled. and in the not working case i get -286331154
where is the odebug output going: back on the serial port, or to some uart
ah ok
The loop in read_serial_binary() is going to try to combine_bytes(buf, available), even if it reads fewer bytes than the available amount. do you mean combine_bytes(buf, i)?
also if you send, say "123\r\n", it will eat the "123\r", and not process the \n, and then process that the next time around.
Here is the current status of uac2_headset on the latest pico-sdk with the latest tinyusb:

I play a low frequency sine wave through it just so you can see the digital artifacts that seem to be occurring at random intervals.
It is almost as if extraneous data is being written to the same USB endpoint, or it needs to be buffered again to reduce jitter.
...
Operating System
Linux
Board
custom rp2040 board
Firmware
this will stop receiving or writing data after 20 seconds when being put under stress using cat /dev/urandom | pv > /dev/ttyACM1 or cat /dev/urandom | pv -L 14400 > /dev/ttyACM1 to limit the throughput
main.c
#include
#include
#include
uint32_t get_time_ms(){
return to_ms_since_boot(get_absolute_time());
}
int main (void) {
tusb_init();
char buf[200];
while (1) {
...
I believe extracting these addresses from DeviceTree is the most portable way of handling it? But that might be a whole different kettle of fish...?
[hathach/tinyusb] New branch created: bcm\-dwc2\-address
Describe the PR
- update broadcom peripheral
- fix #1201
@lurch yeah, it is already done by https://github.com/adafruit/broadcom-peripherals which generate the header for peripherals and USB_OTG_GLOBAL_BASE https://github.com/adafruit/broadcom-peripherals/blob/main-build/broadcom/gen/bcm2837_lpa.h#L3558
TinyUSB simply picks that up
[hathach/tinyusb] New branch created: update\-issue\-tempate
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 here.
Please provide details on
- How to Reproduce must have Exact steps in chronological order, details should be specific e.g if you use a command/script to test with, please post it as well.
- Also which exact board of stm32f405
the code is preferably compiled like one in example folder and re-viewable for people to comment on. The easiest way is
- Fork this repo, checkout a new branch
- Add your-own-example based on stock one
- Push and post it here.
thank you for the issue
- can this be reproduced with the stock example
/examples/device/cdc_mscorcdc_dual_ports? If not, then please add an example based on those with minimal changes so that the example is readily for compiling and testing. (it is how I normally test/develop the stack). Also that makes it easier to review/comment on your specific line of code. The easiest way is- Fork this repo, checkout a new branch
- Add your-own-example based on stock one
- Push and...
Thanks for opening the issue, UAC2 is tricky, and there is still lots of work to get it working flawlessly. To make the issue reproducible for me and others, can you
- Provide the compile-ready example based on one of the audio example.
adapt the example to create "audio_2i2o"can have lots of variants. While we want to make sure to test with the same firmware on the same hardware as much as possible. The code should be reviewable so that other can comment on specific line of code as well ...
I have made the following fork of TinyUSB combined with Pico-SDK: https://github.com/TheMindVirus/tinyusb
It's actually Pico-SDK but the fork is TinyUSB for tracking it here. It is a snapshot, no Pull Request is to come from it.
It is also not an archival fork/branch but it should almost be treated as such. I have versions of Pico-SDK and TinyUSB
which are completely different but the version numbers says they're identical. (Cached vs. Non-Cached Version Hashing?)
GitHub was a nightmare...
Describe the PR
- Fix nRF race condition with easyDMA, checkout https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/127 for detail and reproducing steps.
- [tested] Correct the inconsistent behavior in video_capture as well
- [tested] also help with https://github.com/adafruit/circuitpython/issues/3152
I still don't get how to reproduce your issue
- Which example firmware I should compile, please provide link to your fork example
- Why do you need to fork the pico-sdk, did you make any changes to the sdk.
- Can you provide audio tool and steps to reproducing the capture
Note: all the info should be posted directly here.
Please let me know if there are updates to Audio/Video for RP2040 at a later stage.
just follow the development on this repo or checkout the release note.
The issue mainly seems to relate to Audio Formats in the USB Descriptor and what's expected by apps.
ASIO issues have occurred but the jitter has occurred with non-ASIO apps and ASIO has sometimes worked.
It may have something to do with the mic interleaving 1 channel from 2 but that's usually a normal case.
It may also have something to do with extra buffering when it does work, but will also temperamentally
throw device exclusivity and sharing errors (not very conducive to the audio wor...
ok after some tests I was able to reproduce the issue here https://github.com/nikisalli/tinyusb/commit/92152ccdb5dcef8636f957a8659cd247efb1ed2a
just run this two commands in two terminals:
cat /dev/ttyACM0
cat /dev/urandom | dd of=/dev/ttyACM1 status=progress
it halts after a couple seconds and never reads a packet again until reset
It might be RP2040 specific since I can't reproduce on STM32L053.

I found out now that the bug occurs only when the program is loaded in RAM using a debugger. I've tried running again all the programs that crashed when loaded in ram using a picoprobe and it didn't crash not even one time. At this point I think the problem might lay in picoprobe's firmware so I'm closing the issue as clearly tinyusb isn't what's causing the problem
thanks for confirmation, sometime running in debug mode can cause some issue. It is normally a race. Feel free to re-open the issue if you figure out other way to reproduce it. Thanks @HiFiPhile for testing it out.
Describe the PR
Update iar project template due to path changes.
Describe the PR
This PR add an example for the use of multiple interface (CDC, Vendor and two HIDs). It also helps to clarify a bit about the difference between the interface number and the instance number (See https://github.com/hathach/tinyusb/discussions/1202)
Please verify that I didn't make a mistake while numbering ep nums for the LPC and SAM mcus as I don't have one to test it with
Thank you for the PR, however we can't have all class combination as example. Most of this example is already covered by other such as webusb, cdc, hid respectively.
@noodlefighter I didn't follow up tinyusb for long time, it's a great work you've done! I didn't test a real sine wave when tried esp32-s2, can you also raise a PR to submit uac2_headset_freertos? So it will be easy to test for everyone.
OK, no worries, I think it would be a good idea to have a section in the docs about the difference between interface number, and instance numbers as it wasn't really clear reading the existing examples, the discussion clarified it tho.
Hi @hathach out of curiosity I ran the MSC demo again with the latest changes to master and...
[Sa Nov 27 12:25:14 2021] sdc:
[Sa Nov 27 12:25:14 2021] sd 9:0:0:0: [sdc] Attached SCSI removable disk
[Sa Nov 27 12:26:27 2021] usb 3-4.3.4: USB disconnect, device number 20
[Sa Nov 27 12:26:28 2021] usb 3-4.3.4: new full-speed USB device number 21 using xhci_hcd
[Sa Nov 27 12:26:28 2021] usb 3-4.3.4: New USB device found, idVendor=cafe, idProduct=4003, bcdDevice= 1.00
[Sa Nov 27 12:...
This works with the new dcd_dwc2 and "old" dcd_synopsys driver.
I guess this is why the folks at the Raspberry Pi Foundation told me to raise the issue in Thachโs repo:
#tinyusb message
So this is what youโve been doing all alongโฆ
Also, later in the same comment Iโve attached a zip file of my audio test which partially worked:
https://github.com/hathach/tinyusb/files/7589177/PicoTinyUSBAudioTest.zip
The audio_2i2o source is similar to uac2_headset with an extra mic channel, ideally with stereo separation (phase inversion) or maybe reverb. It may one day make a useful โ2i2oโ or โusbioโ module for circuitpythonโฆ
Describe the PR
Add a HCD driver for MSP-EXP432E401Y.
This patch supports only for low and full speed devices.
Additional context
I have tested cdc_msc_hid with only a low speed mouse.
@KarlK90 great to hear that works, actually I did test it out with gd32 when doing new dwc2 driver. The msc drive does show up, so thing is definitely improved. However, there is still issue here and there. It may not work as well as other ports and I haven't got time to look further at this port. Let me know if you see any issue with gd32
another great port, thank you very much, please give me a bit of time to test this out.
[hathach/tinyusb] New branch created: fix\-gamepad\-comment
Describe the PR
fix #1199
Describe the PR
resolve #1196, give 4k stack size for esp32s2/3 in freertos example
I have found an issue with the handling of the HUB. I will let you know the issue is fixed.
[hathach/tinyusb] New branch created: update\-doc
Describe the PR
update supported list
I have found an issue with the handling of the HUB. I will let you know the issue is fixed.
You could skip the hub port for now if that is too troublesome. I have my own temp code to handle hub as well like blocking delay and some hack here and there within enumeration code.
Thank you very much for the PR. I have been busy with other works, and only have time to review this now. It is a great fix. host stack apparently needs more dev time. Though I found the while() with find_first loop is not sufficient. We are better with just 1 for loop to close endpoint.
Therefore I have update the PR (also rebased since master has several updates).
this loop is not sufficient, we should do only 1 for loop to close endpoint with matched address
I have updated this patch for handling a HUB. However, the enumeration process with a HUB still fails.
I guess some race condition occur on a control transfer. Current hcd_musb.c assumes that a new transaction will not be requested(calling hcd_setup_send/hcd_edpt_xfer) until the previous transaction has been completed in a control transfer. However, it does appear to be requested.
I'm not familiar with USB host processing and EHCI/OHCI. It seems that ehci.c and ohci.c has a some...
Thanks, it takes me too much time to edit the table with retext app. Which app do you use to edit rst file ?
In the table LPC43xx missed highspeed support :)
Thanks, it takes me too much time to edit the table with retext app. Which app do you use to edit rst file ?
I have some restructuredtext extensions on vscode, i made the table in csv and one of the extensions formated it to rst, i honestly dont know which did what
To edit Is a bit harder, never had to deal with a big table like this so never really looked into it, usually just do it by hand (this one is too big to be dealing with that though)
There are other supported table formats, maybe CSV would be good here, very simple.
I chose this because it allowed some fancier things like joined rows for the same manufacturer (which i think works great)
There are other supported table formats, maybe CSV would be good here, very simple. I chose this because it allowed some fancier things like joined rows for the same manufacturer (which i think works great)
yeah, I agree, this format look great, though editing it is a bit of a pain. though I get used to it already.
In the table LPC43xx missed highspeed support :)
right, will correct it next
@kkitayam yeah, the enumeration via hub is still work in progress. No worries at all if it doesn't work out especially the usbh control flow isn't final just yet. We could come back to this later on.
Describe the PR
This pull request adds MIDI host functionality to tinyusb.
Additional context
This code is a work in progress and should be treated as a draft. I am submitting it as a pull request in hopes it will be helpful.
Working now
- Compiles and loads on a RP2040 board in the Visual Studio Code IDE
- Both devices I have tried enumerate correctly (Yamaha Reface CS, Korg nanoKONTROL Studio)
- The code will correctly format a MIDI message and send it to the device ...
Allwinner F1Cx00s family is a series of SoCs with Mentor MUSB controller and HS phy. It comes with a slightly different register space layout, and some quirks, so it's not multiplexed with the existing musb support library.
This porting currently requires to be compiled with https://github.com/hongxuyao/F1C100s_with_Keil_RTX4_emWin5 . Support for Keil RTX4 is also added in this pull request.
There is a working CDC loopback demo project at https://github.com/t123yh/F1C100s_RTX4_USB .
Superb !! Thank you very muhc, this is great PR. This would be great option to run TinyUSB on another popular SOC besides rpi broadcom. As required for maintaining the driver, could you please:
- Tell which board you are testing with, I am planning to order and Sipeed Lichee Nano to test with your PR.
- Add mcu and bsp files so that existing example could run on the actual hardware. This is actually very important, it not only provides proof of concept but also ease the maintaining/dev...
Hi hathach,
Thanks very much for your response!
I'm indeed testing with a Lichee Pi Nano, but it's more convenient to use a Widora V200 (Now called MangoPi-R3c). MangoPi-R3c have two USB ports for OTG and UART and comes with dedicated RESET and BOOT button, which brings a lot convenience to development.
Now a basic example is provided here: https://github.com/t123yh/F1C100s_RTX4_USB, which requires Keil to be compiled. I'll try to port it to the BSPs in TinyMCU later.
I forgot to ...
@t123yh thank you for the tip, I just placed an order for the MangoPi R3 from aliexpress instead of Lichee Pi nano. It probably takes a couple of weeks for it to deliver. Meanwhile we could try to get familiar with the chip and the PR finalized :+1: :+1:
BTW, currently I have only tried Keil RTX on F1C100s, but I believe RT-Thread will also work. I'll try later.
Describe the PR
When NRF5x device is reset by software (after DFU for example),
power event is ready from the beginning.
When power interrupt is triggered before tud_init() finished
USBD_IRQn is enabled before it would be enabled in tud_init().
This in turn may result in BUS RESET event being sent from
USB interrupt to USB task when queue is not initialized yet.
This scenario often happens in Mynewt build where queue creation
takes more time.
To prevent this scenario USBD_IRQn ...
Describe the PR
Remove errors when compiling with LOGGER=swo.
All arguments of sys_read() must be used in function, otherwise it triggers "unused-parameter" errors.
Additional context
Before this patch, error was:
hw/bsp/board.c: In function '_read':
hw/bsp/board.c:126:44: error: unused parameter 'buf' [-Werror=unused-parameter]
126 | TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
| ~~~~^
compilation terminat...
[hathach/tinyusb] New branch created: chipidea\-controller
[hathach/tinyusb] New branch created: fix\-s3\-ci
Describe the PR
Temporarily skip S3 in ci build since it has strange issue
CMakeFiles/cdc_msc_freertos.elf.dir/project/src/device/usbd_control.c.obj: in function `usbd_control_reset':
usbd_control.c:(.text+0x1fe): dangerous relocation: call8: call target out of range: memset
CMakeFiles/cdc_msc_freertos.elf.dir/project/src/device/usbd_control.c.obj: in function `usbd_control_set_request':
usbd_control.c:(.text+0x231): dangerous relocation: call8: call target out of range: memcp...
Describe the PR
controller used by lpc18,43 and imxrt is more commonly known as chipidea (highspeed) in linux project. Rename transdimension to chipidea (still keeping the old file for compatible with warnings).
acquisition history: --> means bought.
ARC vusb fs/hs core --> Transdimension --> Chipidea CI13210 (fsotg), CI13410 (hsotg) --> MIPS --> Synopsys
This is still something I want and have to do, but I don't have time right now (due to new job) so If anyone can pick this up for me I would appreciate it (should be only needed to write the header with the registers)
Signed-off-by: Rafael Silva
Describe the PR
A clear and concise description of what this PR solve.
commit: eae4132
look good, thank you for your PR. Unicode is much easier to maintain the table with text editor. It is also displayed nicely with github web viewer. The only downside is it is not displayed as nicely on the generated doc. But easy to maintain take the priority.
PS: Chipidea CI13210 (fsotg) known as ARC vusb is implemented by #1086 for kinetis (and pic32)
@hathach
Thank you for your comment.
I will stop investigating the issue regarding enumeration with HUB for now.
In addition I have confirmed hid_controller works with my PS4 DS2 gamepad. So far, I confirmed interrupt IN transfers only work properly. This weekend I'm going to run bulk transfers.
Describe the PR
Fix the bug of buffer overrun at pipe_read_packet() in dcd_musb.c.
Additional context
Cast operations for the left side symbols were wrong. So, when packet length is not 4 bytes unit, it occurs buffer overrun and corrupts some buffers.
I converted this pull request to draft because the bulk IN endpoint for the RP2040 is not working yet.
**Is your feature request related to the problem? Please describe. **
A clear and concise description of the problem. predecessor. I always feel frustrated when [...]
Hello, I am currently using esp32s3 as a DAPLink debugger, it works normally when using HID, but I want to use WIFI as a wireless debugger, but when using HID with WIFI TCP, it is very slow because of the 1ms limit of HID , So I thought of the winusb daplink, I tried to modify the webusb_serial example, but win10 cannot recogn...
First of all, thanks for TinyUSB! It's an awesome little library.
I'm implementing a sound card using the RP2040. The device provides an asynchronous output endpoint and an explicit feedback endpoint to manage the data rate.
The feedback method is described in 5.12.4.2 of the USB 2.0 spec:
To generate the desired data rate Ff, the device must measure its actual sampling rate Fs, referenced to the USB notion of time, i.e., the USB (micro)frame frequency. [...] A sink can determin...
Proposal: Declare a weak callback in dcd_rp2040.c. If available, the callback is to be triggered on SOF. For minimal jitter, dcd_rp2040_irq should be declared __not_in_flash_func, and USB_INTS_DEV_SOF_BITS should be checked first.
If this sounds ok, please let me know and I'll submit a pull request.
Operating System
Others
Board
Raspberry Pi Pico
Firmware
What happened ?
The dcd_edpt_close() implementation in dcd_rp2040.c is incomplete. It was probably meant to call hw_endpoint_close, but that code remains commented out.
With USB audio playback it's common for the endpoints to close and reopen as needed. During silence, the driver selects alternate setting 0 to conserve bandwidth and the endpoint is closed. Then it's reopened when playback starts.
Bec...
Describe the PR
Close endpoints and reclaim buffer space on RP2040.
Additional context
Proposed fix for https://github.com/hathach/tinyusb/issues/1232.
Pull request submitted. A couple of notes:
- To keep is simple, buffer space is only reclaimed after all non-control endpoints have closed.
- If a transfer event gets delivered late, after closing the endpoint, it will be ignored. This never happened in my testing.
The Windows driver for USB Audio 2.0 seems to disregard the spec and expects 16.16 format instead of 10.14 on my full-speed device. Interestingly, on Linux the ALSA driver supports either format. So for now I'm calling tud_audio_n_fb_set(feedback << 2) to force 16.16 format everywhere. This works but is a bit hacky.
Could we have a config flag to disable the format conversion in tud_audio_n_fb_set()?
For future reference: this blog describes how to get logs from the Windows driver. The driver complains after the feedback value being out of range when in 10.14 format.
That's interesting, though I don't remember I had issue testing full-speed.
I've implemented a 32bit/384kHz sound card on LPC4357 which runs perfectly without glitch at about 10% CPU usage.
In fact the way of feedback calculation in the spec is not optimal, as you said the jitter of 1-2 us was causing audio glitchs.
What I'm using and proved reliable is measure the sample count of the out buffer in every tud_audio_rx_done_pre_read_cb, and use this count to calculate feedback value.
Here is my snippet:
bool tud_audio_rx_done_pre_read_cb(uint8_t rhport, ...
Thanks! This looks viable provided you have the magic constants figured out (min, max, threshold). It's the sort of code I was hoping for in the device examples. :)
That said, the SOF way definitely works once you mitigate the jitter. It's running glitch-free with a small TinyUSB patch on the Raspberry Pi Pico.
To be clear, the project I'm working on is for my own entertainment - to learn and see how far I can push cheap hardware. I'm aiming for low audio latency, and the advantage of t...
That's interesting, though I don't remember I had issue testing full-speed.
It happens on the Raspberry Pi Pico. I'd be interested to learn if it's specific to this device.
To be clear, the project I'm working on is for my own entertainment
Me too :)
I've uploaded my repo, you can find more details in audio_callbacks.c
I've uploaded my repo, you can find more details in audio_callbacks.c
Awesome, thank you!
I have confirmed bulk transfers work by connecting cdc_msc_hid to msc_dual_lun running on a raspberry pi pico.
[hathach/tinyusb] New review comment on pull request #1220: Add support for Allwinner F1C100s family
Please let me know why this operation is needed. I would like to know if there is a bug in dcd_musb.c
I had designed dcd_msub.c that EPIDX register must be written when accessing the registers for FIFO settings(TXFIFOSZ, RXFIFOSZ, TXFIFOADD, and RXFIFOADD). My understanding is EPIDX effects only these registers. So, there is no need to keep the EPIDX value for a long time. If the EPIDX value needs to save and restore, I missed something condition.
[hathach/tinyusb] New review comment on pull request #1220: Add support for Allwinner F1C100s family
Hi Koji,
In my design, I didn't use the addressed endpoint registers. EPIDX is used in all places. In dcd_edpt_open, after calling find_free_memory, if current EP index is not restored, the following adjustments to FIFO addr and size will go to the wrong endpoints. In your code however, you adjusted EPIDX after find_free_memory, so you are not affected here.
@PanRe haven't see you for awhile, do you remember something about this ?
[hathach/tinyusb] New review comment on pull request #1220: Add support for Allwinner F1C100s family
Thank you for your reply.
Ah, I see, you moved the statement of assigning a value to EPIDX register to before calling find_free_memory.
After fixing a stupid mistake, the cdc_msc example is now working.
Just played with the msc. It seems that there're a few STALLs before the disk is properly detected. Seems that the cause is the code below. I'm not familiar with msc, so I don't know what's happening.
if ( p_msc->stage == MSC_STAGE_STATUS )
{
// skip status if epin is currently stalled, will do it when received Clear Stall request
if ( !usbd_edpt_stalled(rhport, p_msc->ep_in) )
{
if ( (p_cbw->total_bytes > p_msc->xferred_len) && is_data_in(p_cbw->dir) )
...
@HiFiPhile yeah it has been a while true! How are you all good?
@vmilea The driver can not know in advance if it is operated in full or high speed mode. Hence, the driver was designed such that the feedback value is always formatted in 16.16 format and in case of full speed mode, the driver takes care of reforamting the value to the specified 10.14 format. This way, the user does not need to care about the format with respect to the speed setting, just always set the value in 16.16 format....
Great, thank you for your PR.
No, we cannot have an example for every user scenario or class driver combination. I don't have enough time to maintain them all. Besides webusb example already did exactly binding winUSB driver. If you have issue problem to get it work, you could open an discussion providing all your setup/code and what is your issue/finding, maybe people that already done that could help.
@PanRe The API design is fine, it's just that the reformatting to 10.14 sometimes gets in the way. I'm proposing something like CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION so it can be disabled if needed.
This is to work around a bug in the actual Windows driver. When passing 10.14 format on my full-speed device it refuses the value:
[USBAudio2]feedback value 0x000b0651 is out of range [0x002c0000,0x002d0000], ignoring value
The driver is expecting instead a 16.16 val...
@vmilea Ah yeah now i see. Would you file a PR therefore? However, it is up to @hathach to decide if the PR is accepted. I would say it would be reasonable to do as you proposed. But i would prefer CFG_TUD_AUDIO_DISABLE_FEEDBACK_FORMAT_CORRECTION since this renders to enable a non-default setting in the driver. And please explicitly describe in the comments what it is good for (as you did above).
By the way, do you have a working minimal speaker example which can be used to test for this ...
BSP support is now added. No RTOS is required.
Please see README.md for details.
Currently tested with
audio_testandhid_generic_inoutandcdc_msc.audio_testis working.cdc_mscis not working, only echoing the first character.
Superb !! That is great, too bad, my tiny200 haven't shipped to me just yet for trying this out. This will make things super easy to support and maintain F1C in the...
I've a guess but doesn't have a board to test with for the moment.
In XMOS's lib they use 3 bytes feedback for FS and 4 bytes for HS.
if (busSpeed == XUD_SPEED_HS)
{
XUD_SetReady_In(ep_aud_fb, fb_clocks, 4);
}
else
{
XUD_SetReady_In(ep_aud_fb, fb_clocks, 3);
}
Maybe Windows use the byte length to decide coding format.
@vmilea Could you try to change 4 to 3 to see what happens ?
https://github.com/hathach/tinyusb/blob/f8288be03f28ad7b944e6925f494...
Now there's one thing that's to be solved: if we want to build a flashable bin file to run on SPI Flash, we must use mksunxi tool to process the output bin file. I'm not sure where can I insert this into our build flow, could you please help me?
@HiFiPhile Good guess. Unfortunately it doesn't work:
[USBAudio2](0x01): buf 1 feedback packet 0 has invalid packet length 3, ignoring packet
I also tried setting wMaxPacketSize=3 on the feedback endpoint which the driver didn't accept:
[USBAudio2](0x0101): feedback endpoint MaxPacketSize=3 is invalid
Would you file a PR therefore?
Done.
By the way, do you have a working minimal speaker example which can be used to test for this bug? If yes, it would be really nice if you could file a PR with such. I think other people would be glad for support!
I don't right now. It's not too difficult to create one with dummy output and fixed feedback value, but without real audio output the bug can only be checked through Windows driver logs.
yeah, adding user sof make sense for this case. SOF callback isn't used yet (on purpose) since it is triggered too often (1ms for FS). I will try to see what would be the best way to add it.
@t123yh in general, tool should be installed separately by user and added to PATH similarly to gcc toolchain or openocd. You could also make it as makefile variable to pass through command line e.g we can put it in the board/family readme doc.
# default to mksunxi is in PATH
MKSUNXI ?= mksunxi
if user need to, it can be passed to makefile as make MKSUNXI=path-to-tool. Let me know if that make sense to you.
superb! thank you very much for another great PR. The changes look perfect, I have tried to test it with tm4c123 board, however that board seems to need an a bit of extra works to set up as host mode (will implement later as separate PR).
PS: I did push some minor changes to get host example build msp432e4 in ci and other minor changes.
I have confirmed bulk transfers work by connecting
cdc_msc_hidtomsc_dual_lunrunning on a raspberry pi pico.
The msc example isn't good yet, previously I have an running example that could do some basic file navigation with fatfs such as mkdir, cd, list, cat but it is out of date with latest fatfs. I will try to get it updated to have an more fancy msc host example :)
@rppicomidi thank you very much for your PR, sorry for late response. I am bit busy and lagging behind PRs. I will try to test and help with bulk IN later as soon as I could.
ah right, thank you for your PR. I was planning to add the SWO read, but then I realize swo is output only :D and kind of forgot to fix this.
Thank you for your comment and for merging this PR!
Thank you for your comment and for merging this PR!
I am the one to say thanks :+1: :+1:
Here is my current implementation: https://github.com/vmilea/tinyusb/commit/bf617028f90d87475a3864dac9bb7a09311563d7. The SOF interrupt is unmasked only when dcd_sof_cb() is defined, so there is zero overhead unless used.
as far as I understand, this happens when an in-progress transfer complete on a newly closed endpoint. Though I think we need to return true instead to notify transfer complete to usbd.
Thank you for your PR, all changes look great, except for the one with hw_endpoint_xfer_continue(). I think we should return true instead to notify actual happened event previously, even though endpoint is closed now (it probably doesn't make any difference with ISO endpoint). Though I am open to all suggestion.
PS: On a side note, I actually have an plan to remove dcd_edpt_close() since it causes quite a bit of trouble with other dcd. It is better with just reserving the highest bandwid...
I don't remember to that in-progress event will be ignored after close(). In fact, i think it should still be processed if data successfully travel through usb bus.
I've written a Python version to avoid the need of installing mksunxi. Now it will build a flashable image that you can write to SPI. README.md is updated to reflect the changes.
Here is my current implementation: vmilea@bf61702. The SOF interrupt is enabled only when
dcd_sof_cb()is defined, so there is zero overhead unless used.
thanks, IMHO, sof interrupt must be actively enabled/disabled e.g when going into low power like wfi/wfe or when audio interface is not active. We don't want to have SOF triggered on every 1 ms in those scenario. This should be an tud_ API that applie...
Returning true here would call driver->xfer_cb() with the closed EP, not sure if driver supports that.
My understanding is endpoints are closed in response to a control transfer on EP0, by which time all transfers on the endpoint being closed should have completed. So handling USB_INTS_BUFF_STATUS before USB_INTS_SETUP_REQ in the IRQ should prevent the transfer-after-close situation.
If data is actually transferred via bus, it should be submitted to higher layer usbd/class driver. It would be their choice to whether process or ignore data. dcd shouldn't assume that.
My understanding is endpoints are closed in response to a control transfer on EP0, by which time all transfers on the endpoint being closed should have completed. So handling USB_INTS_BUFF_STATUS before USB_INTS_SETUP_REQ in the IRQ should prevent the transfer-after-close situation.
Yes, but since ...
It's a difficult topic. I've never seen a transfer event being delivered after the EP was closed. This change was a precaution based on the comment from usb.c. Do you agree to roll back to original panic()? If it comes up in practice, then it will be loud and clear and easier to deal with.
I propose also updating IRQ to handle buff_status before setup_req. This should take care of transfer completing immediately before EP close, even if there's still a chance for races like you said.
thank you @vmilea for the issue and @HiFiPhile and @PanRe for helpful input. PR #1235 look good, though I would like to get more info with your example and set up for reproducing purpose, specially with descriptor. Which could potentially cause windows driver confusion. Would you mind provide
- your windows build version
- Your minimal code that cause the issue (best to be on github for other to comment on line of code). It is best to modify one of stock audio examples if possible, otherw...
Ok, I'll come up with a minimal example tomorrow.
I have an g474 eval with a similar clock setup.
Here are the rcc settings that should work:
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PL...
It's a difficult topic. I've never seen a transfer event being delivered after the EP was closed. This change was a precaution based on the comment from usb.c. Do you agree to roll back to original panic()? If it comes up in practice, then it will be loud and clear and easier to deal with.
yeah sure, if you haven't run into this scenario. It is best to leave it as it is. I have an tendency to not write code for event that isn't happened yet (to avoid having code that isn't run).
I p...
I've written a Python version to avoid the need of installing mksunxi. Now it will build a flashable image that you can write to SPI. README.md is updated to reflect the changes.
great works, do you have a need to merge it asap ? my board from aliexpress could take 2 more weeks to arrive. I would like to have hand-on testing and could make some cosmetic changes if needed. But we could merge it earlier if this blocks your work.
[hathach/tinyusb] New branch created: g4\-nucleo
@atdicapf thank you for your input, I give it a quick try, but it still doesn't seem to work. There is probably something more as well https://github.com/hathach/tinyusb/commit/cd76193f3c82a4d1cd870f91e5538bebd147e710
[hathach/tinyusb] New review comment on pull request #1221: nrf5x: Fix race condition during startup
maybe we should just use the tud_inited(). Although dcd shouldn't call higher layer API, i guess it is not that much of dependency. That would be one less variable to worry about.
great work, thank you for the fix. Though maybe we should use tud_inited() . nrf dcd use usbd_defer_func() API to schedule/defer function call anyway :smile:
great works, do you have a need to merge it asap ?
No need, it's better to merge after you have tested the whole thing. I don't think it's currently stable enough to be merged. I can just work on my own repo before merging.
BTW, after fixing a bug (commit 527036b) that causes MMU and cache not initialized when executing from FEL, serial performance test reaches 15.7MB/s, which is a lot better than previous tests.
No need, it's better to merge after you have tested the whole thing. I don't think it's currently stable enough to be merged. I can just work on my own repo before merging.
great, I prefer to have some local testing as well.
BTW, after fixing a bug (commit 527036b) that causes MMU and cache not initialized when executing from FEL, serial performance test reaches 15.7MB/s, which is a lot better than...
[hathach/tinyusb] New review comment on pull request #1221: nrf5x: Fix race condition during startup
I did missed that, update is coming...
[hathach/tinyusb] New review comment on pull request #1221: nrf5x: Fix race condition during startup
Easy way for me to trigger this race (and then verify that solution work) is to have
#define CFG_TUSB_DEBUG 1
look great, thank you for the fix
[hathach/tinyusb] New review comment on pull request #1221: nrf5x: Fix race condition during startup
thanks for the hint, in this case, the code proves itself :+1:
PS: github ci seesm to have network issue, need to re-run the build. will merge when it complete.
Describe the PR
Add support for the Bridgetek FT90x and FT93x devices.
The FT90x and FT93x series are complete System-On-Chip 32-bit RISC microcontrollers for embedded applications featuring a high level of integration and low power consumption.
Additional context
Documentation is available at https://brtchip.com/ft90x/ and https://brtchip.com/ft93x/
The port requires to be compiled by the GNU ft32-elf- Toolchain which downloaded from http://brtchip.com/ft9xx-toolchain/
C...
Hi all
@atdicapf Thanks a lot :)
Your version works for me to.
@hathach on cd76193 you forget to take something:
- board.h l 91: RCC_USBCLKSOURCE_HSI48 not RCC_USBCLKSOURCE_PLL
family.c: __HAL_RCC_USB_CLK_ENABLE(); is the important
Thanks all you for the great solutions :)
Something i wondering about: with HSE it works but same settings with HSI not...Idk why, both generated with cubemx...
your windows build version
Windows 10 Version 21H2 (OS Build 19044.1348).
Your minimal code that cause the issue
Here is the test code. It's based on uac2_headset, tested on RP2040 and should work on other MCUs. The audio sink runs at 44100Hz, it discards incoming samples and sends a slightly skewed feedback rate of 44.125.
Follow these instructions to capture driver logs: https://matthewvaneerde.wordpress.com/2017/10/23/how-to-gather-and-read-logs-for-microsofts-usb-audi...
@philippgurtner I am glad it works for you, I have updated the BSP though It stills does not work for me. https://github.com/hathach/tinyusb/commit/51acc3e1b90f42ebb80881a143fe36a4ce45821c . Would you mind telling Which board you are using. It could be hardware setup on my side since g4 nucleo don't have usb and I have to use break out cable https://www.adafruit.com/product/4448 Green is D+, white is D-
 is D+ (green)
PA11 (CN10 p 14) is D- (white)
Schematic
I found my "flag" :D
In board_init() we need to call HAL_InitTick(TICK_INT_PRIORITY); or at least set uwTickPrio = TICK_INT_PRIORITY;
Inside HAL_RCC_OscConfig(&RCC_OscInitStruct); in board_clock_init(): HAL_InitTick(uwTickPrio); get called and it needs uwTickPrio, otherwise systick is not...
@hathach I am making progress again and have the IN endpoint working with the OUT endpoint disabled. I am about to push a change. Once that is done I will see if both can work together.
@hathach I am making progress again and have the IN endpoint working with the OUT endpoint disabled. I am about to push a change. Once that is done I will see if both can work together.
great thanks, I am also looking at bullk-iso endpoint host as well
@philippgurtner ah right, silly me, I did mixed up D+ and D-. IT works now with HSE, g4nucleo has 24 mhz one, HSE is always more accurate than HSI.
I pushed changes that show the Raspberry Pi Pico as MIDI host supporting both IN and OUT endpoints at the same time. It's showing proof of life, but after a short while the system gets in a state where it will neither send nor receive until I unplug and re-plug the MIDI device. I am investigating.
@kkitayam Hi,
I am playing with gud on F1C100s today. I doubt if there's a bug in the logic of musb dcd driver around TU_LOG1("Drop CONTROL_STAGE_ACK\n");.
Consider the following situation:
- Host sent a CONTROL SETUP IN (req1) with wLength > 0;
- Device responds with wLength = 0 DATA OUT in respond to req1;
- Host responds with STATUS OUT (musb handles this automatically);
- Another CONTROL SETUP IN (req2) is sent immediately by host, s...
@t123yh
Thank you for your comments!
I am playing with gud on F1C100s today. I doubt if there's a bug in the logic of musb dcd driver around TU_LOG1("Drop CONTROL_STAGE_ACK\n");.
Consider the following situation:
I will get back to you on that after I will understand the sequence shown by you.
I feel CONTROL IN transfer is very complex because MUSB has no feature to respond with NAK for STATUS OUT requested by HOST. It takes time to understand.
@t123yh
I have understood that the logic flow you said. Please find attached sequence diagram. I illustrated this problem.

In addition, I think we need to consider following conditions.
- A) Normal transfer

- B) STATUS OUT request comes before TUD calls...
Make some adjustments to process_ep0 so that if _dcd.status_out is 1 when entering process_ep0 -> USB_CSRL0_RXRDY, send a dcd_event_xfer_complete immediately to notify the stack;
I guess this way is good. I would consider whether the way works for other conditions.
If this adjustments are applied, after the step 24 of C) The next SETUP request comes before TUD calls dcd_xfer() for current STATUS OUT , DCD will enqueue DCD_EVENT_XFER_COMPLETE to event queue. Therefore DCD g...
Commit 5e4364f fixed what appears to me to be a timing issue in the rp2040. I believe now that bulk endpoints are working. I have some cleanup and testing to do and will then take this pull request out of draft. Not sure when that will be.
Did anyone tried TinyUSB with NeoPixel on ESP32S2?
I'm getting some artifact for some reason
All I can tell is that this happens while USB is communlicating
I checked the RMT signal generated with logic analyzer, some packet is corrupted and the signal has some extra data at the end
Describe the PR
Add G4 nucleo support
thank you for the update, I will test it out as soon as I could, please be patient.
This PR adds support for a new KUIIC board.
I quite like @vmilea's implementation. I actually needed this for a project as well and ported it over to the stm32 synopsys driver and it works great!
I do think adding in proper support for low power modes would be preferred however.
I feel like we have been working on a similar project...I fought with this a week or 2 ago.
I use an stm32f411 core.
The issue is windows actually ignores the speed of the device and checks the bcdUSB field.
When the bcdUsb field says we are a USB2.X the UAC2 driver assumes we are a high speed device and uses a 16.16 format.
When setting bcdUSB to 1.X, it uses the 10.14 format expected on a Full Speed device.
My solution was to just make a separate function that took in boolean to s...
look great, can you also add link to the board in the supported.rst for reference as well https://github.com/hathach/tinyusb/blob/master/docs/reference/supported.rst#kinetis
@kkitayam the diagram is super useful, though I haven't tried to look closely at musb so far. Please give me a bit of time to catch up with this.
@vmilea Thanks for the effort!
@geekbozu Thanks for this idea! I actually like it as it would fix the Microsoft bug and other users would not get bothered by it. Once the Microsoft-bug was fixed, we could revert this patch. What would do you think @hathach ?
It's by no means "perfect" but in my test case of every PC/device in my home it seems to get the job done and select the appropriate format.
I should mention thats being called in the tud_audio_rx_done_pre_read_cb function.
I added it to the supported boards list.
Initial support for Portenta H7.
Very easy and simple additions to get the Portenta H7 up and running. I put it into its own folder, not sure if thats correct but between the two cores of diff archs and the weirdness the dual cores seem to bring compared to single core brothers thought it made sense. The i2c pmic gets written to very early init by arduino/mbed I added ruff initial and untested code for that in family.c, but its not tested/trustworth atm. Everything seems ok, the examples ...
is there any plan to add chip ch32v307 support
