#tinyusb
1 messages · Page 19 of 1
Describe the PR
If CDC TX buffer size is configured to be less than bulk packet size, the autoflushing condition is never reached.
Changes:
- TX buff is automatically flushed when TX FIFO is full
- Zero-length-package is sent if the whole transfer length is integer multiple of MaxPacketSize defined in EP descriptor (rather than fixed 64/512 bytes)
Additional context
Found out during https://github.com/espressif/esp-idf/issues/9040
This is in great extend reverting this https://github.com/hathach/tinyusb/pull/547
shouldn't the packet size check be kept? the buffer may be larger than the packet size, and in that case, we would want to flush when we have enough to fill said packet
did this not initialize correctly before?
Operating System
Windows 10
Board
raspberry pi pico
Firmware
examples/host/cdc_msc_hid
What happened ?
When trying the msc host example with the fatfs implementation based on the example code, one first runs into the following code at line 97 and 107:
if ( TUSB_ERROR_NONE != tuh_msc_read10(usb_addr, 0, buff, sector, count) ) return RES_ERROR;
Which needs to be correct to:
if ( tuh_msc_read10(usb_addr, 0, buff, sector, count, NULL) ) return RES_ERROR;
in order...
now there is a code block without any condition before it, its redundant
[hathach/tinyusb] New comment on issue #1488: RP2040 host msc example non\-functional \(with fatfs\)
I also tried this example with this fix: https://github.com/hathach/tinyusb/pull/1434 but this didn't change the result.
The buffer size is defined here https://github.com/hathach/tinyusb/blob/master/src/class/cdc/cdc_device.h#L42 , so defining BULK_PACKET_SIZE seems as a redefinition...
But maybe I'm just missing reasons for change inhttps://github.com/hathach/tinyusb/pull/547 , I can change it back if you will :)
I was getting hcd.h:213:3: sorry, unimplemented: non-trivial designated initializers not supported and failing on error.
sure, it's redefined, but I'm actually talking about the logic that triggers a flush, you just using the bufsize, but I'm arguing both the bufsize and the packet size should be considered
this goes for the zero length packet too, we should see if we sent a full packet and there is no more to send, not if we sent a CFG_TUD_CDC_EP_BUFSIZE
[hathach/tinyusb] New comment on issue #1488: RP2040 host msc example non\-functional \(with fatfs\)
Host bulk for rp2040 isn’t supported yet, I will take a look at this (and other related issues/prs) when having time.
@cr1901 right, i am planning to have an simple python script that take argument from DEPS_SUBMODULES and clone it accordingly.
Describe the PR
There were two problems:
- dma_running flag could be checked in USB interrupt (not set yet) then higher priority
interrupt could start transfer, check dma_running (not set yet) set it to true start
DMA; then when USB interrupt continues it starts another DMA that is not allowed - when DMA is started some registers can't be safely accessed, read can yield invalid
values (SIZE.EPOUT, SIZE.EPISO)
current implementation could start DMA for one OUT endpoint then ...
Describe the PR
A number of tweaks and improves to the OHCI usb host backend
Additional context
- Allows configurable root hub ports. I am testing with hardware that has 4 ports. This is working successfully. Fixes for port reset, port speed, port connection status to direct them to the correct rhport.
- Currently we assume cold boot (OHCI is reset state). This may not be the case if we come from a bootloader etc. This handles SMM mode (Ref OHCI spec 5.1.1.3.3) and Bios mode (Re...
Operating System
Others
Board
ESP32-S2
Firmware
Keyboard TinyUSB sample
What happened ?
On some devices, a keyboard press is not being registered, for example, an XBOX. While scanning an input is not detected.
It looks the debouncing time is too short in this case. Where to change the debouncing timing, in which library. I am using the keyboard example.
How to reproduce ?
Scan a button on an Xbox game. The press will not be detected. Normal keyboard inputs work ...
Operating System
Windows 10
Board
STM32L475VET6
Firmware
custom firmware, basically CDC.
What happened ?
During device enumeration, after data stage of SET_LINE_CODING, it won't send ACK packet. After checking the log, I think the XFRC bit should not be cleared when OTEPSPR is set but STPKTRX is cleared.
to `if (doepint...
Btw could you try to introduce the const keyword to see if that help to fix the compiler
The problem still remains if I introduce the const keyword; the fix in this PR seems to be the simplest workaround for now until I can figure out how to report this to the vendor.
thanks for testing out the 'const' keyword, this is bizarre issue. Hopefully TI will fix this in future gcc
Describe the PR
- Enhance configuration for multiple controllers e.g port0 for device, port1 for host and/or allow dynamic switching device/host role (not fully implemented yet). Previously CFG_TUSB_RHPORTx_MODE is used to fix device/host support.
- CFG_TUD_ENABLED/CFG_TUH_ENABLED and CFG_TUD_MAX_SPEED/CFG_TUH_MAX_SPEED can now be used instead of CFG_TUSB_RHPORTx_MODE
- tud_init(rhport), tuh_init(rhport) is used explicitly instead of tusb_init()
- backward compatible, everything that ...
[hathach/tinyusb] New branch created: rp2040\-sof\-fastfunc
Describe the PR
- TU_ATTR_FAST_FUNC is equivalent to __not_in_flash() for rp2040
- add TU_ATTR_FAST_FUNC for sof isr call chain in audio
It may depend on the VBUS sensing, please check your schematic.
It seems that STM32H7B3 is using synopsys dwc2 driver, not use stm32_fsdev driver.
Hi guys, I Also stumbled over missing isoc support on fsdev.
For my current "fist test" I would be fine if there's no dma-support for now, could we split this issue or is it mandatory to support dma in order to get isoc transfers running?
I'm willing to help with implementation and test but maybe I'd need someone to discuss my changes as I'm not that deep into fsdev driver and tinyusb stack up to now.
I'll first try to comment in that untested stuff and to adopt the changed routines.
I...
Hi @Iktek , I believe DMA is not supported on fsdev after reading reference manual and ST driver, I could be wrong.
@HiFiPhile I think that is correct. The stm32f103rc for example doesn't have any way to connect the DMA to the USB. It also doesn't have an internal dma controller.
I also checked the stm32g474re and it's the same in this sense. That one has a much more sophisticated DMA controller, but even that one can't connect to the USB (although I noticed in one of the diagrams there is some extra FIFO, but I didn't read more into that).
As far as I know, there is no stm32 that actually can talk to ...
@HiFiPhile @leptun : Mhh. You may be right, but it could also be that m2m dma is still possible as the pma memory can be accessed from within the normal adressing-space. So for my understanding there only needs to be a dma-connection if requests of an periperal need to be made which would not be the case for pma.
Nevertheless there should also be a way to implement isocronous support without dma.
I'll first try to also add the ff-api support to the driver as already proposed by the "comme...
unfortunately, debouncing is not an usb issue. The example is not perfect, but it mostly works as proof of concept and demonstrate how API is used. There is plenty of tutorial for button debouncing and if you check out the example source I am sure you could find where to add those debouncing snippet
this is mostly tested with my L476 discovery board. These line of codes are done when doing generic dwc2 driver #1163 with tons of testing (trial/error). Maybe I didn't fully resolve this issue with L4 series just yet (possibly an race condition that is less likely to happen on my L476 discovery board due to clock/hw set up etc..). I don't have official dwc2 specs and the stm manual are not very helpful on this particular issue.
I kind of forget the detail, #126 may contain some useful in...
Operating System
Windows 11
Board
OHCI
Firmware
This index is only 4 bits and stores the device address or an index of an endpoint in ed_pool. As soon as the value in index is >15 it will overflow and cause OHCI hardware to crash.
I can see we've had to squeeze it in the reserved area to fit within a gtd, so not sure on a good fix for it. Ive confirmed this is the issue by temporarily increasing the index field size, by reducing the expected_bytes field.
https:/...
One step back: there seems to be an issue with my usb-host driver -> with another notebook the stream stays alive.
It seems that isoc-support is basically running with my minor fixes / additions.. I'll test that further and add an PR for that bit if it's running here.
DMA is on another page and might be tackled in the future.
It seems that STM32H7B3 is using synopsys dwc2 driver, not stm32_fsdev driver.
Dear, thank you for pointing this out.
I have confirmed that I am using the synopsys dwc2 driver.
However, debugging dcd_int_handler function I have confirmed that the following code is not being executed when I unplug the device from the computer:
dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);
I have enabled VBUS sensing in CubeMX and it is directly connected from the USB connector to ...
It seems that half of the audio data is missing for some reason.
Interesting. If you search there is a similar issue for RP2040.
I think you are the first one trying UAC with fsdev. Could you post your descriptors ?
Sure:
#define AUDIO_CTRL_ID_SPK_INPUT_STREAM 0x01
#define AUDIO_CTRL_ID_SPK_FUNIT 0x02
#define AUDIO_CTRL_ID_SPK_OUTPUT 0x03
#define AUDIO_CTRL_ID_MIC_INPUT 0x04
#define AUDIO_CTRL_ID_MIC_FUNIT 0x05
#define AUDIO_CTRL_ID_MIC_OUTPUT_STREAM 0x06
#define AUDIO_CTRL_ID_CLOCK 0x41
#define AUDIO_CTRL_ID_CLOCKSEL 0x40
#define AUDIO_NUM_INTERFACES 0x03
#define AUDIO_NUM_INCHANNELS 0x02
#define AUDIO_NUM_OUTCHANNELS 0x02
#define TUD_AUDIO_CTRL_TOTAL...
Same descriptor is working properly with stm32l4 + dwc2
I'm wondering if the "doublebuffering" is needed in order to support isoc-audio as it seems that maybe every 2nd pice of data is not handled.
I'm also wondering if it's supported by the fsdev that there are 2 isoc-descriptors with 64 byte in each urb. Maybe one of them is not handled properly.
I'm wondering if the "doublebuffering" is needed in order to support isoc-audio as it seems that maybe every 2nd pice of data is not handled.
I don't think it's the cause. As there is no ack or retry for ISO transfer, host will continue to send even device can't handle it properly.
I remember Windows continued to send even if I paused the execution of LPC4337.
In your case host is sending only half of the data.
Seems like feature unit is missing in descriptors.
Mhh.. where do you see that the host is missing to send the data? In the dissection I see that the host is sending about 128bytes every 2 ms which is the correct data amount. I would suggest that the device can't handle every 2nd packet (or e.g the 2nd descriptor in the iso-out-urb)
[hathach/tinyusb] New branch created: add\-tuh\_config\-port\-specific\-setup
Describe the PR
Add new API to allow configure host behavior dynamically and/or port specific params
bool tuh_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param)
Mhh.. where do you see that the host is missing to send the data?
I'm sorry I misread your Wireshark log 😅 I'll take a deeper look after vacation.
Hi @Iktek , I believe DMA is not supported on fsdev after reading reference manual and ST driver, I could be wrong.
The peripheral cannot make DMA requests, but the operating system/tinyusb can periodically initiate "MEM2MEM" transfers as needed (preferably using the double-buffer mode of the USB peripheral). Handling DMA complete interrupts manually shouldn't be so hard to do. Error handling (i.e., when USB disconnects happen) could be complicated if a DMA transfer is in progress in the...
Same descriptor is working properly with stm32l4 + dwc2 I'm wondering if the "doublebuffering" is needed in order to support isoc-audio as it seems that maybe every 2nd pice of data is not handled.
I think stm32_fsdev must use double-buffering, based on the reference manual section 23.4.4 isochronous transfers:
Isochronous endpoints implement double-buffering to ease application software development, using both ‘transmission’ and ‘reception’ packet memory areas to manage buffer ...
The peripheral cannot make DMA requests, but the operating system/tinyusb can periodically initiate "MEM2MEM" transfers as needed
I agree.
I think a busy-loop will not be a solution which would speed up much as irq is still blocked during memcpy.
I don't expect the dma-transfer being much faster then the manual memcpy. I'ts only worth being used if we could make it asyncronous.
I'll have a look these days if double-buffering is doable easy.
I think dma is not mandatory for now b...
Ok, i digged in a bit and things seem even more complicated as thought before:
Double-buffered isoc-endpoints can't be bedirectional. So one would have to use 2 endpoint indices here.
As the driver states endpoint id and ix are mixed up all-over-the-world, so it would be hard to get them devided again.
Unfortunately UAC2 needs the sync endpoint being on the same address ( 0x01 <->0x81 ) as the corresponding data-endpoint.. so we have a no-go here.
In addition my customer phone me he w...
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
[hathach/tinyusb] New branch created: more\-rp2040\-ramfunc
Describe the PR
- either force inline or use __no_inline_not_in_flash_func() for faster irq handling
- result is 1KB of code moved from rom -> ram
This is the first time I heard of this mcu. Short answer is "No" since I have no devkit. Though this may change if the mcu is popular and/or interesting enough.
you are right, I have written this long ago for NXP LPC MCU, and never thought it would need to support more than 16 devices. I actually prefer the solution 2, even though we need a few extra code to access the custom data array (probably 2 bytes per TD), but in general it save lots more SRAM. It may not be a lot but less is better since TinyUSB is expected to run on small MCU as well.
I propose a couple solutions:
- Expand the td struct to include this custom data. To maintain 16...
superb !! thank you very much for the PR, indeed, I have skipped lots of cpu detail and I think cut lots of corner to just get it running on small MCU. It has been awhile since I work with OHCI, give me a bit of time to revise the spec/code and pull out the old nxp devkit to test with.
@mauriciocirelli indeed, the disconnect detection is a bit confusing on dwc2. The specs is a bit fuzzy. dwc2 driver may miss some logic here and there since it is a generic driver which work on all configuration of dwc2. The old stm synopsys driver is very specific to stm configured controller.
I will try to revise and test this out when having time.
I will create a PR for this fix soon
Thanks for your input 👍
I am using 4 ports, 5 hubs and potentially 12 devices so pushing the limits a bit.
@hathach thank you for your reply.
Detecting the disconnection event is important for us, because we have a FATFs running on this device and we need to unmount/re-mount it when connected/disconnected from USB. Otherwise, if our firmware tries to access the FATFs while Windows is accessing it from USB, the file system gets corrupted.
unfortunately, I am currently busy with other works. will check this out when possible. If you manage to get it work, please consider to make an PR to help others.
I can hit issues if we disconnect a device from a hub when we are enumerating another device, the hub status control transfer will begin, then we'll assert in enumeration due to a busy control buffer.
I think there's a few conflicts with hub, enumerating and control buffers to be resolved still for this to be very resilient.
Currently I am using STM32h743x MCU which is powered by battery and i am using TinyUSB with FreeRTOS OS for CDC. If there is no USB when board is powered up, it tries to connect by calling dcd_connect() . By doing this MCU enters in reset and loops between USB connect and reset.
Proposed solution
It should be handled like it is done in one of the PR #1094 . At least if VBUS sensing is enabled.
We should be able to get an interrupt on SRQINT in OTG_GINTSTS.
[hathach/tinyusb] New branch created: revert\-sof\-rename
Describe the PR
- revert sof_isr driver rename since it cause issue with existing code
- also removed commented tud_sof_isr_set() API
No rush at all
I will follow up with proper periodic schedule handling. I may put this in a #ifdef guard so it can be disabled by the users as it uses a bit of RAM, however this will allows transfers to respect bIntervals and spreads transfers across frames to maximise bandwidth.
And I have isochronous support locally, however we need a host isochronous sample to demonstrate :)
[hathach/tinyusb] New branch created: more\-dynamic\-rhport
Describe the PR
better dynamic controller for host
Describe the PR
Adds CH341 USB to serial emulation class.
Additional context
The CDC driver (for windows at-least) is problematic which is probably why all of the USB to serial IC manufacturers use their own proprietary driver. In my case, I was trying to implement an ESP32 programmer with a CDC interface only to discover that the windows CDC driver (usbser.sys) doesn't handle the RTS signal properly so there was no way to get it to work without modifying the esp scripts.
This...
I observed that tub_ready() returns true after tud_disconnect() on ESP32S3
Is this intended behavior?
Is this normal?
Try restarting? I see the GitHub posts
I did its still blank lol
Weird lol
I'm trying to learn how to use the TinyUSB library (If anyone has any good resources for beginners, I'd love that!).
What does CDC mean in this context?
https://gist.github.com/todbot/d4f4e0111c7829fd55b0c3b68114d9a5
Communication device class
Ooohh
I've been hitting my head against the wall for the past months on this project:
Emulating a proprietary arcade machine controller. I have all the lsusb -vv output here:
I'm currently at a point where the endpoint is 'in use' (everything except . I'm using the webusb_serial example as a template)
(the red is what i want to match, the green is what the avr shows)
I'm so close, I just need to get a better understanding of endpoints and how they're made, and used.
I'm not sure if the CDC type is the way I should be going with this... idk what I'm doing
How do I just expose a buffer and not connect to it in tinyusb?
Sorry I should clarify, I just want to make these endpoints:
I see, I’m not super familiar with TinyUSB but you might find help faster by asking in #help-with-projects this channel usually isn’t very trafficked
It’s mostly for core development for TinyUSB
Ah ok, good point
You might also post an issue on their GitHub with what you have so far and how you’re stuck
Oo right theres a discussions tab! Thanks
You’re welcome 🙂
Improvements to RP2040 HCD driver. The main issue this PR fixes is that interrupt endpoints were sometimes sending packets to the tinyusb host stack that the stack had not requested. This would result in hangs / crashes / corrupted data structures.
We now disable interrupt endpoint polling unless the host stack has requested a packet. The other improvements were things noticed while debugging this issue. In particular you should check for a stall received before dealing with any other pen...
Yeah, thanks, I actually build the periodical tree as OHCI specs suggested in early implementation but make it simpler to save footprint. Having it configurable, I think having support 4/8ms (configurable) is better way. Sorry, I am still busy with paid works, will check/test this out whenever I could.
are you running the latest from git, if not please pull and try again. dwc2 all zero is probably clock issue, where the usb controller is not enabled/powered.
just want to chime in, the warning could be suppressed if we initialize all member by their order.
Thats true. I believe for the most part it is in order, just missing the connection struct in hcd_event_t.
So we could add this the mix
.connection =
{
.hub_addr=0,
.hub_port=0,
.speed=0
}
I can push this change or whatever you think is best
no, I think your changes is better, we should only init the one of unioned only.
Superb ! thank you very much for your effort and patience. I have tested with mcb1800 (same chipidea controller as imxrt) and it works like a charm. The recursive call to process unplugged hub device is working but not a great approach in long term IMHO. I make an commit to add FIXME to this and also make an issue for reminder as well. Thanks again for your work.
an recursive call in limited MCU can cause stack overflow. Though I am ok with this initial support. In long run, we should find an way to un-roll the recursive chain. After all, the device loop is rather small (4-10) only.
indeed, for compatibility, usbh only carry 1 control transfer at a time since unlike ehci most custom host is rather limited. Currently there is no control queue and when the control is busy, usbh simply return false for try-again.
Is your feature request related to a problem? Please describe.
PR #1480 add support for multiple-level hub using recursive call of process_device_unplugged()
However in limited MCU, recursive call chain can cause stack overflow. We should find an way to un-roll the recursive chain. After all, the device loop is rather small (4-10) only.
Describe the solution you'd like
It is always possible to un-roll an recursive chain to a loop with/without an queue. We could use a status (d...
Made the changes in commit dd035b0eb optional because stealing 1K of RAM by default seems undesirable.
It is now controlled by PICO_RP2040_USB_FAST_IRQ which is 0 by default.
It is probably worth documenting what use cases the faster IRQ helps/is-required-for.
thank you, making it optional is better approach. It was needed when doing usb bit-banging with pio-usb in device mode since the timing is very strict but less so with hw controller.
In the Pico SDK for stdio over USB, (by default) we call TinyUSB in a low priority IRQ (so the user does not have to have a polling loop).
Currently this IRQ is called every 1ms which is pretty wasteful. This change adds a callback which can be hooked to know when there is something in the queue that needs processing.
Note, i don't know if:
- i called this the right thing
- whether it should be defined somewhere else (if other ports might find it useful)
- it performs the callba...
thank you for the fix, I still have question regarding unscheduled usb transfer on interrupt endpoint. Could you tell more on your setup and how to reproduce the issue.
I have an question though, according to the rp2040 DS, if the buffer is not full and available, there won't be any transfer. This seems to indicate we have an un-scheduled transfer occurred.

ah right, nice fix ! we totally skip the xferred_len for setup
Good point. I implemented this a while ago and rebased it, so maybe it is no longer necessary. In a comment here https://github.com/liamfraser/tinyusb/commit/a38b54d1f2d2b3e756eea475f7114f888ad960fc#commitcomment-68710466 you mention there was an issue with queueing multiple transfers that is now fixed. I remember seeing a race condition at the time so that could have fixed it.
@liamfraser would you mind re-testing it with this specific command along its enabled counterpart when starting new transfer to see if the issue still occurs.
To solve issue #1446. Code does not compile when trying to build with CFG_TUD_AUDIO_ENABLE_DECODING && CFG_TUD_AUDIO_ENABLE_EP_OUT.
After fixing typo it does.
Not having this prevents the device from finishing the mounting process.
Tested on a SAMD51 and didn't seem to need to actually do anything in the close function. Did repeated close/opens of an audio streaming endpoint.
I don't think this is the right way to address the issue with pico stdio. There is other place that use queue API as well. I think the better approach would be having USB IRQ as shared IRQ (currently exclusive) and pico-sdk installed its own irq to detect if there is a new usb event and call tud_task() later in main thread
I have done something similar to th...
[hathach/tinyusb] New branch created: fix\-example\-with\-highspeed
Describe the PR
fix #1457, close #1459
bulk endpoint size must be 512 for highspeed and 64 for FS, dynamic_configuration and usbtmc examples hard coded to 64 and cause an assert in the stack
[ 4949.159993] usb 3-1: USB disconnect, device number 51
[ 4949.484276] usb 3-1: new high-speed USB device number 52 using xhci_hcd
[ 4949.633227] usb 3-1: config 1 interface 0 altsetting 0 bulk endpoint 0x1 has invalid maxpacket 64
[ 4949.633230] usb 3-1: config 1 interface 0 altsetting ...
thank you for your PR, however the root cause and correct fix is described in #1516
Thanks for filing the issue, I put up a test today. The issue is not caused by mis-configured JTAG but rather the example incorrect bulk size of usb descriptor. For Highspeed the bulk endpoint size must be 512, dyanmic_configuration and usbtmc are hard-coded it into 64 (FS). kernel message does show this issue,
[ 4949.159993] usb 3-1: USB disconnect, device number 51
[ 4949.484276] usb 3-1: new high-speed USB device number 52 using xhci_hcd
[ 4949.633227] usb 3-1: config 1 interface...
dcd_edpt_close() is mostly used by audio with ISO endpoint, since SAMD doesn't support/test with ISO, it is left out. Have you manage to get audio example running with samd51 ?
Thanks for filing the issue, I put up a test today. The issue is not caused by mis-configured JTAG but rather the example incorrect bulk size of usb descriptor. For Highspeed the bulk endpoint size must be 512, dyanmic_configuration and usbtmc are hard-coded it into 64 (FS). kernel message does show this issue,
Ah ha! Thanks for the fix.
Excellent! I guess I didn't understand what was going on :-) Thanks again for the amazing library!
yeah, that's a good idea
I will open a separate request to change to use irq_add_shared_handler
no problems, and thanks for the issue and your patience.
By using shared IRQ handlers, the user can add a lower priority handler, and therefore be aware when they might need to poll TinyUSB
Operating System
Linux
Board
SAM V71 Xplained Pro
Firmware
examples/device/cdc_msc @ e0d7c16788f15c72c5a7837656d8b6d3ed28c3e0
What happened ?
Upon building with
$ cd examples/device/cdc_msc
$ make BOARD=same70_xplained LOG=2 all
linking fails with
LINK _build/same70_xplained/cdc_msc.elf
/nix/store/l3rvj8w9ci8wj34kmsvga1ijikmngz0y-gcc-arm-embedded-10.3.1/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /nix/store/l3rvj8w9ci...
Possibly a toolchain issue, but I do not have a non-NixOS system at hand to verify.
I previously removed all the warning suppression in the rp2040 family.cmake, because I thought all the warnings had been fixed, but I must have been testing the wrong thing, as all the -Wconversion are still there.
Re-adding to get clean SDK build with master of TinyUSB
@hathach do you think you could review this? It should be relatively clean, I just don't want to have this become stale and then have to rework it again
@hathach, perhaps you can explain this to me?
Will this cause any issues when a high-speed device is talking to a full-speed host (or using a full-speed hub)?
Since it would be a full-speed connection, the packets shouldn't be more than 64 bytes, but the descriptor will statically report a maxPacketLen of 512?
(I'm not so familiar with high-speed USB...)
I tested under arch (manjaro).
After a bit of tool-chain fiddling I was able to reproduce the error:
LINK _build/same70_xplained/cdc_msc.elf
/usr/lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/lib/thumb/v7e-m+fp/hard/libnosys.a(sbrk.o): in function `_sbrk':
sbrk.c:(.text._sbrk+0x18): undefined reference to `end'
collect2: error: ld returned 1 exit status
make: *** [../../rules.mk:100: _build/same70_xplain...
I got a streaming application working with SAMD51 (audio streaming from computer to device using ISO OUT endpoint). I needed to stub this out though for the calls in audio_device.c / audiod_set_interface to finish correctly.
Tested on SAMD51 in an audio application with ISO OUT endpoint - we can allow more packet sizes by checking that the set size value is greater than the requested packet size instead of exactly the same.
I have build_arm and build_aarch64 workflows fully green lit. Hopefully the others will go through too. I had to setup my own self-hosted runner to get through your workflow maze. You can't even have a printf in the example code. yikes!
thank you for testing out, samd is not tested with ISO yet. Though indeed, this will allow it to enumerate and do a bit more testing.
For complete compatible with FS hub/host, highspeed-capable device must prepare 2 configuration descriptors: fs and hs and return correct one according to the actual link speed. When HS-capable device working in FS link, it may need to answer to the get_other_speed_configuration() from host. I did implement all of this for cdc_msc example sometime ago
PS: I will update the usbtmc example later to also support this scenario :)
PS: I will update the usbtmc example later to also support this scenario :)
Thanks! I didn't want to create more work for you (but on the other hand, I don't have any HS devices to test...)
I unfortunately used USBTMCD_MAX_PACKET_SIZE a bunch of times in the driver, too. These have to be changed to be based on the value in the endpoint descriptor table....
Ah I remembered that bug, it occurs when plugging hub with already-attached multiple devices to rp2040 host and cause multiple control conflicts. It should be resolved, maybe we should revert this change ?
I will test it now without the interrupt endpoint change
@hathach you are right the change is unnecessary as it was fixed correctly in the host stack. I would still like the other tweaks to be merged but not 100% necessary. Just helps if you are debugging any future issues.
No problems at all, you added usbtmc driver before I have sorted this hs/fs thing out. I will double check the example and driver when having time.
I didn't encounter these warnings when building with make BOARD=raspberry_pi_pico, could you add some comment # -Wyour-warning-option in the cmake, maybe I could find a way to fix the source rather than suppressing it.
Yeah; they can certainly be fixed... this file shows what we do a test SDK compile with (which seems to about match the sensible limit of warning options that our users use)
You can reproduce by
- cloning the SDK and
cd pico-sdk - doing a
git submodule update mkdir buildcd buildcmake -DPICO_SDK_TESTS_ENABLED ..makeormake -j<procs>
...
Apparently, the dev board for the CH569 is now available at a reasonable price on LCSC
https://www.lcsc.com/product-detail/Development-Boards-Kits_WCH-Jiangsu-Qin-Heng-CH569W-EVT-R0-1V0_C3001176.html
Operating System
Windows 10
Board
STM32F407 USB HS+USB3300PHY
Firmware
V1.3.0
What happened ?
Does tingusb support STM32 f4+usb3300 high-speed devices? If yes, is there a device qualifier descriptor callback?
How to reproduce ?
I have a new project that needs to use USB high-speed transmission, but it is found that high-speed devices need device qualification descriptors, but tinyusb does not find the corresponding callback function. How can I solve it?
Debug...
look great thank you for the fix.
@hathach you are right the change is unnecessary as it was fixed correctly in the host stack. I would still like the other tweaks to be merged but not 100% necessary. Just helps if you are debugging any future issues.
sure thing
Hi,
Any update on this? We are using this in product and test it extensively.
In long term we would like to avoid having to use our own fork on tinyusb..
The Teensy 4.1 board has an 8MB W25Q64JV as opposed to the 2MB flash
on the Teensy 4.0. This largely doesn't matter for TinyUsb, except
when you attempt to access any memory in the flash above the 2MB
boundary, when it fails with a hard fault.
This patch adds Teensy 4.1 support with the 8MB flash chip.
Operating System
Windows 10
Board
ESP32-S3
Firmware
examples/device/audio_4_channel_mic
I also tried with the freertos like https://github.com/kaspernyhus/tinyusb/tree/audio_test_freertos/examples/device/audio_test_freertos
What happened ?
usb device is well recognise, so I tried it and fill the i2s_dummy_buffer with rand() to make a white noise, but
NO SOUND IS RECORDED onto the computer
I also tried with the tud_audio_write_support_ff , and the tud_audio_wri...
Operating System
Linux
Board
STM32H743x
Firmware
I am using custom FW where FreeRTOS is used and have 2 CDC in device mode. Vbus sensing is enabled.
What happened ?
If I power on the board with USB already connected. Everything is fine. 2 USB com ports get detected on host machine(Linux/Windows) and everything woks fine as intended.
But if I power on our board without USB(as board has a battery as main source of power) and I do not attach USB, STM32H743 resets itself...
I have kind of found the solution to this. so replying here.
Once I have removed this following line in function dcd_init() everything workas as inteneded.
// Clear A override, force B Valid
//dwc2->gotgctl = (dwc2->gotgctl & ~GOTGCTL_AVALOEN) | GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL;
Even-though MCU is powered on and stack BLE is initialized, it does not resets itself anymore. and if i connect an USB , it starts to enumerate and it shows USB device on HOST machine.
I do not kn...
In order to reproduce this bug, it is important to have a board which is powered by a battery instead of USB. and then run any example from example. STM32h7 should reset when it tries to connect to USB after dcd_connect(rhport); command.
can you specify which example to run and on which specific dev board.
Till now I tested on my custom PCB with STM32H743II.
But I did a test on STM32H743ZI nucleo board with cdc_msc_freertos example. It is same , We can see LED(green) blinks(which means MCU is restarting/resets)
Operating System
Windows 10
Board
stm32f070rb
Firmware
master branch (ae8b8f0c93885e3078f12c9ef00d65faa835d507)
Driver is NI VISA for windows v21.5
What happened ?
Summary: Soon after device configuration, the host sends a CLEAR_FEATURE(ENDPOINT_HALT) on the USBTMC bulk-out endpoint, triggering an assertion that a transfer is being started on a busy endpoint (usbd_edpt_xfer:1243).
At configuration, the class driver initiates a bulk-in transfer, so the endpoint ...
Ok, USB 2.0 spec confirms that it's OK to send extra ClearFeature(ENDPOINT_HALT), and in that case, the data toggle should be reset, so that's what I'll do (implement by stalling and then unstalling endpoint):
USB 2.0 spec 9.4.5:
Forendpoints using data toggle, regardless of whether an endpoint has the Halt feature set, a
ClearFeature(ENDPOINT_HALT) request always results in the data toggle being reinitialized to DATA0.
It also states that the DTOG's should be reset if set_configura...
@hathach This is starting to look more like a device stack issue. Would you mind looking into the stack, and then I can fix the USBTMC code in particular?
When clear_feature(endpoint_halt) is requested on an endpoint, usbd_edpt_clear_stall is then called:
But, endpt_clear_stall does nothing when the endpoint is not stalled:
Driver is NI VISA for windows v21.5
Thanks @pigrew , since I am not familiar with usbtmc, can you provide the link to download/install the driver. I will try to reproduce this to have a closer look/fix on the issue.
also, on your custom board, did the reset happen with bare-metal example e.g cdc_msc (without freertos) ?
this is usually missing symbol end/_end in the linker script. The end symbol is used by nanolib for printf().
This updates USBTMC so that it should work with USB high-speed (untested, I don't have a HS device handy...).
It also fixes a few existing bugs:
- Updates python test code to use newer versions of pyvisa
- Manually stalls and unstalls an endpoint when receiving clear_feature(ENDPOINT_HALT), fixes #1529
- Reads the max packet size from the endpoint descriptors, instead of using a compile-time define.
The fix for the endpoint halt clearing likely should be put in the USBD core itse...
I discovered there was an intermittent failure also due to this same issue with the USBTMC interrupt-in endpoint, so I added that to my patch.
One solution would be to modify usbd.c starting at:
to be:
case TUSB_REQ_SET_FEATURE:
{
if ( TUSB_REQ_FEATURE_EDPT_HALT == p_request->wValue )
{
// USB spec requires DTOG to be reset upon clear(EP_HALT),
// and transfer buffers to be cleared.
usbd...
Thinking more, it would be good to have a way to clear the event queue of transfers on the particular endpoint during the clear_feature call, but we can leave that for another day. This patch is a step in the proper direction.
Operating System
Windows 10
Board
STM32
Firmware
4639cac85cf959c3bfed091c02dce1345f067c7a usbtmc example
What happened ?
USB488_bREQUEST_READ_STATUS_BYTE should return USB488_STATUS_INTERRUPT_IN_BUSY when interrupt-in endpoint is busy. Currently, it will trigger an assertion.
I will submit PR once other USBTMC work is merged.
How to reproduce ?
Unsure....
Debug Log as txt file
No response
Screenshots
No response
[hathach/tinyusb] New branch created: hid\-report\-len\-uint16
Describe the PR
since HS interrupt endpoint can be up to 1024, 8-bit is not enough.
affected APIs are:
- tud_hid_n_report() / tud_hid_report()
- tud_hid_report_complete_cb()
- also house keeping with usbd log
thank @kilograham for the detail instructions, I have reproduced the all the warnings with rp2040. The most annoying one is -Wconversion, I am trying to "fix" these altogether. Will make an PR for this soon enough.
Describe the PR
- increase more warnings option, all ports get
-Wnull-dereference -Wuninitialized -Wunused -Wredundant-decls. - rp2040 include an additional
-Wconversion(pretty troublesome on other ports due to mcu driver).example.cmakeis added for holding common examples such as warnings (may move some bsp cmake later on). - dual example for rp2040 is an exception since pio-usb has to fix its warnings first.
- fix freertos build with stm32g4 and stm32wb (also added to ci).
...
tinyusb should have no warnings with -Wconversion after #1534 . Please double check to see if this PR is still needed.
Sadly there are still a large number of -Wconversion errors (at least with gcc 9.2.1) some of them are a bit silly.
Can we please get this workaround PR merged in the interim, as we would like to pick up from master by tomorrow ! :-)
This PR fixes a transmit lock-up, which happens, when data is received
and sent at the sime time at moderate to high speeds, like code
which just echoes incoming data.
In my case, an issue was reported here:
https://github.com/micropython/micropython/issues/8521
It looks like there there's at least one more spot that needs the fix:
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
That's possible. The INTXXX registers should not be set with |=.
Actually that one looks fine. It clears all pending interrupts. So the |= is intional and right.
sadly there still seem to be a huge bunch under gcc 9.2.1 (perhaps they were there before, and it just wasn't in my test matrix).
Anyway, there also turns out to have been a backwards incompatible change in cmake 3.18
Therefore i think it is best to merge this in the short term
that is weird, I tested with gcc 10 and 11 and it seems to be fine. Could you attach the txt file of compile output here for analysis
I have been doing more tests with various gcc version. In sum up gcc 9 and prior will throw incorrect warnings with Wconversion. gcc 10/11 or later fixed this issue. Therefore I just push some more update to the PR with the version check
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0)
In general, all example will skip the Wconversion option with gcc9, also the suppress_tinyusb_warnings() function will do nothing if the gcc is 10 or later. And the "-Wno-stringop-overflow -Wno-array-bound...
thank you for the PR, could you tell which specific board/mcu you are having the issue with
Thank you for the swift response.
It affects SAM21 and SAMD51 boards. Tested (or to better say failed) with Adafruit ItsysBitsy M4 Express, Adafruit ItsysBitsy M0 Express, Adafruit Feather M4 Express, and Seeed XIAO. But the problem will appear on any SAMD21 and SAMD51 board. With the change, it works fine on these boards. And I use these with a MicroPython port.
One thing which is to be considered: the MicroPython port uses tinyusb v0.12.0. The PR is against the recent master, which i...
This is the companion PR #1535 as a branch to version 0.12.0. I'm not sure if that is the right way, but at least it changes the right file.
This PR fixes a transmit lock-up, which happens, when data is received
and sent at the same time at moderate to high speeds, like code
which just echoes incoming data.
In my case, an issue was reported here:
https://github.com/micropython/micropython/issues/8521
Describe the PR
A clear and concise description of what t...
superb! Thank you very much for the PR. So far there have been a few issue with |= on set/clear register across codebase on other ports. These are really difficult to troubleshoot, maybe I should spend sometime to revise all the dcd/hcd ports for this.
this PR is still actually toward the master branch, and have no difference with #1535 . At current stage, tinyusb does not have maintaining branch per release. It will only move forward in single release.
tud_task() can still be used as it previously use (defined as inline function). There is no need to make any changes to application for this regards.
tud_task() can still be used as it previously use (defined as inline function). There is no need to make any changes to application for this regards.
Thank you for merging and the hint. I got an link error using the master branch. tud_task() is part of a common "busy-wait" macro. So probably the #include is missing. Either way the code has to be changed, and the version of the RP2040 lib as well.
So far there have been a few issue with |= on set/clear register across codebase on other ports.
The INTFLAG, INTSET and INTCLR registers have the habit of clearing/setting the respective internal state by writing a '1' value. So writing a 1 causes an action, instead of just storing a value. That's to be checked against the data sheet for the registers.
Sorry. My fault. Is it possible to create a branch for 0.12.0 and change that one?
why don't you just use the latest at master ?
The MicroyPython project uses tinyusb for five different MCU families. All work fine with v0.12.0. I'm taking some care of two of them, mimxrt and samd. The maintainer of MicroPython does not want to have different commits of the same library for different MCU ports. When switching a library version, all ports have to be tested against that and eventually changed. Someone has to do it, and it will take time, in which the fix for SAMD is not available. I can of course use a local copy of the c...
tud_task() can still be used as it previously use (defined as inline function). There is no need to make any changes to application for this regards.
Thank you for merging and the hint. I got an link error using the master branch. tud_task() is part of a common "busy-wait" macro. So probably the #include is missing. Either way the code has to be changed, and the version of the RP2040 lib as well.
probably due to the fact that tud_task() is an inline function. For rp2040, you may...
For rp2040, you may need to udate pico-sdk
Of course. I tried that already. Not a big deal. Tinyusb uses a named constant that is not defined in the currently used version of the lib.
@robert-hh maybe just wait for a bit of time, there is always some latency for big project like micropython when it comes to update to the sub library such as tinyusb. I do have an plan to release tinyusb in upcoming days.
sorry for late response, I will pull out one of my board with HS to test with as soon as I could :) .
Great. Let me know if you have any questions.
Do you use Windows? If not, I believe that Linux comes with a kernel driver for USBTMC, which will operate with python's pyvisa library. On Windows, the driver I mentioned comes with the "NI MAX" software that allows manual interaction with the device. In the tinyusb USBTMC example, I do have a python script that runs a number of testcases using pyvisa (which is how I found this bug, though it is intermittent).
I'm also contemplating creatin...
No problem. It will take anyhow another while until the extended SAMD port is merged, and until then I can live with a workaround.
finally tried running this
when I connected in high speed I got constant bus resets to high speed
USBD init on controller 0
sizeof(usbd_device_t) = 47
CDC init
MSC init
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Speed
USBD Bus Reset : High Spe...
after usb high speed reset it doesnt seem to get any endpoint interrupts, while it does on full
anyone think tthey can help me diagnose this?
The host seems to be requesting more data than expected for config descriptos, 0x8d/141 vs 77 for dual cdc, curiously on hid_composite it enumerated
Full speed HID composite
USBD init on controller 0
sizeof(usbd_device_t) = 47
HID init
USBD Bus Reset : Full Speed
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
!USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Bus Reset : Full Speed
USBD Setup Received 00 05 7D 00 00 00 00 00
Set Address
USBD Xfer Complete on EP 80 with 0 bytes
dcd_edpt0_status_complete: complete set addre...
According to the USB spec, the DTOG of an endpoint should always be reset to DATA0 when receiving CLEAR_FEATURE(ENDPOINT_HALT), regardless of if the endpoint had been stalled (See citations in #1529).
I believe the attached changes should be made to USBD to facilitate this requirement.
However, some issues to discuss are:
- When stalling endpoints (even when not in response to a control request), do we need to purge the event queue from transfers on that endpoint?
- When SET_CONFI...
Describe the PR
- use https://github.com/carlosperate/arm-none-eabi-gcc-action to install arm gcc toolchain
- fix ci build with board without family
- fix end symbol missing for samx7x, fix #1520
this is fixed by adding end symbol to linker of sam 7x in microchip driver submodule
https://github.com/hathach/microchip_driver/commit/9e8b37e307d8404033bb881623a113931e1edf27
and is resolved by #1539
Describe the PR
Cosmetic change to let define serial port speed in CMake
Note also, that lots of code like
# Example common such as compiler warnings
include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
was added to each example CMakeLists.txt, however there was a function call in each, e.g.
# Example common such as compiler warnings
# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
family_configure_device_example(${PROJECT})
which would s...
converting this to a draft as I'm not going to apply this quick fix at the moment
I see that a == was changed to >=. I'm not so familiar with SAMD, but I figure this could cause issues with INT IN endpoints:
- Class defines INT IN endpoint with
wMaxPacketSize=10 - Driver sets hardware to use
wMaxPacketSize=16 - Class starts transfer of 25 bytes.
- Peripheral transmits packet of size 10 which would confuse the host since it expects a max packet size of 10 bytes.
which would seem like a better place to have allowed each port to specify warnings if it wanted to
Yeah, I agree, it is a better place to add warnings. Though since family.cmake is also used by pico-sdk for and I am not sure if the family_configure_device_example/family_configure_host_example() function are used by other sdk examples and/or user projects. I play a bit safe by only introducing these warnings to tinyusb's examples only, we can refactor this later on.
[hathach/tinyusb] New branch created: fix\-rp2040\-remote\-wakeup
Describe the PR
fix #1416
Update: when build with LOG eanbled e.g make BOARD=raspberry_pi_pico LOG=2 I got
error: "CFG_TUSB_DEBUG" redefined [-Werror]
due to the macro are defined in 2 places
more update: hardware in the loop may be possible with github self-hosted
https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners
basically, we will have to setup and local machine and install an github self-host app to connect to github. It will run as an ci instance, we could attach physical device then check the enumeration of new firmware e.g dual cdc example should have both /dev/ttyACM0 & ttyACM1 appeared etc ..
I think it would be a great thing to do. I have a python script that I run with my USBTMC class driver that verifies a number of conditions (but certainly could be expanded). Using libusb probably would help, as we could more easily test various corner cases, like aborts in the middle of transmissions. (In fact, I lately found a few bugs using my test script...).
Self Hosted runners
Based on the documentation, this sounds like a questionable idea. The docs suggest only using this for private repositories... I think our "workflow" currently runs when anyone creates a PR, so that could overload the private system, or folks even could run malicious code on the microcontroller... I don't know if there is a way to restrict the workflow to be only when maintainers approve?
Even if it's not automatically run, the hardware-rich testing is a good idea....
These are mostly identical to the MIMXRT10XX,and just adding OPT_MCU_MIMXRT11XX where OPT_MCU_MIMXRT10XX was mentioned. Only in ci_hs_imxrt.h to additional #defines are used to cater for different symbols being used. I tested the dcd part of change with a MIMXRT1176_EVK board.
we can limit the condition to run the self-host e.g only run when master is updated, the rest of the flow can just run as it is.
I just look at 1100 overview, I think we probably don't need an extra define for OPT_MCU_MIMXRT11XX, since NXP/Freescale did a great job with their mcusdk. We could rename this one to simply OPT_MCU_MIMXRT (to also account for rt600/500 in the future as well), the existing one is defined to new one to also allow backward-compatible. And we will update all example to use the new one. Over-time user will migrate (or not)
#define OPT_MCU_MIMXRT 700
#define OPT_MCU_MIMXRT10X...
for this we can replace it with
#if !defined(USB1_BASE) && defined(USB_OTG1_BASE)
#endif
NXP should really need to add USB1_BASE to USB_OTG1_BASE for backward compatible like stm does.
Thank you for your suggestion. I implemented and tested these with MIMXRT10XX and a MIMXRT1176 board, and it works. What I did not include was the line:
#define OPT_MCU_MIMXRT10XX OPT_MCU_MIMXRT11XX
I did not understand it. In the new scheme, OPT_MCU_MIMXRT11XX is not defined any more.
sorry, it is a typo, I mean
``C
#define OPT_MCU_MIMXRT 700
#define OPT_MCU_MIMXRT10XX OPT_MCU_MIMXRT
That's a good addition for backward compatibility. I also extended that to
#define OPT_MCU_MIMXRT 700 ///< NXP iMX RT Series
#define OPT_MCU_MIMXRT10XX OPT_MCU_MIMXRT
#define OPT_MCU_MIMXRT11XX OPT_MCU_MIMXRT
Maybe this is not needed, but does not hurt. I can also make a PR at NXP to add USB1_BASE to USB_OTG1_BASE for backward compatibility.
just removed the OPT_MCU_MIMXRT11XX since it is not used by anyone yet. OPT_MCU_MIMXRT should be the one to use for all imxrt mcu
Thanks. Did that. I pushed my actual chanegd version to the PR.
On a second thought: We could also add the redefinition of
#if !defined(USB1_BASE) && defined(USB_OTG1_BASE)
.....
#endif
into our build scripts. I looked at the NXP header files defining USB_OTG1_BASE. These are >100000 lines monsters. I do not expect that NXP will change these.
On a third thought: Maybe we leave the substitution in TinyUSB. Otherwise a note would be required, and it has to be considered in every potential use of MIMXRT11XX. Even if there is little hope for success, I'll make that PR at NXP.
On a third thought: Maybe we leave the substitution in TinyUSB. Otherwise a note would be required, and it has to be considered in every potential use of MIMXRT11XX. Even if there is little hope for success, I'll make that PR at NXP.
I think the current ifdef in ci_hs_imxrt.h is working great, I don't think NXP would change this as well. I will make an update for those skip/only.txt in the examples
Describe the PR
- improve ci
- add
get-depstarget - build script now use multiple processes
OK. Then let's go with that state.
@hathach / @HiFiPhile Do you have any tips on what to look for?
on high speed it seems to get stuck on the event bus reset on the queue, like it doesnt clear, it did not get more that the first interrupt for the bus reset
I'm suspecting some hardware issue, which board are you using ?
Which board is Russian Woodpecker ?
It's a board by me, i don't have access to any dev boards or premade hardware with one, but it should be good
It's a board by me
Okay, could you share a pdf version ? I don't have kicad :)
Nice layout :) When I have time I'll compare with ASF3 to see if there is any difference.
(I've force-pushed this branch with a revision to clean up handling of default control pipe.)
I've convinced myself that this patch removes some bugs, but we still need to examine how endpoint halts interact with class libraries and in-progress transfers.
In particular, I'm worried about race conditions like:
- Host sends BULK OUT packets (packet 1 through 4 of 8 packet transfer), and device class handles these packets.
- Host sends BULK OUT packet (perhaps the 5th packet of an 8 ...
I'm also interested in this, it would be good to have an update on the host API status from you, @hathach.
If the host API changed but is stable again I might also try my hand at changing this PR over if @rppicomidi isn't on it already, although I'm much less familiar with tinyusb or the changes at this point.
What do you mean by that? the asf code for the USB peripheral? do you know of an example by them relatively ready to go for this device? I can't find one suitable
the asf code for the USB peripheral
Yes ASF3 udphs driver.
I can't find one suitable
Yes they lack a basic example !
When I wrote the driver for SAMx7x I found its USB signal is weaker than other MCUs, @hathach had to use a 30cm cable to let USB work. I don't know if it is the same for SAM3U.
Hm, actually, when i used a longer cable it showed a different behavior, didn't even get to a bus reset, but I'm using a rather short cable right now, could look for something shorter
Hello. Is it possible to have usb host support for Adafruit ESP32? in particular I'm testing Adafruit Qt Py ESP32-S2. If not, is it planned? or there's a deeper reason like some micro missing, like max3421? Thanks!
While trying to port a project from LUFA to tinyUSB I can't seem to find a way to open several TMC ports on a single device. For example the cdc_dual_ports example had a function that allows the user to select whichever port would be addressed uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize) I couldn't find anything similar for TMC however. I would like to be wrong but there does not ...
Currently, the TMC code only supports a single interface. Its API would require modification to support multiple instances. This is low on my priority list (and there are other changes I'm planning to make first).
Operating System
Others
Board
Raspberry pi pico
Firmware
just simple app to test cdc behavior.
https://github.com/MrGreensWorkshop/RasPiPicoSDK_cdc_test
- Download
- Compile and run. (or just use binary named PicoTest.uf2)
- use Terminal.exe app to check DTR behavior.
What happened ?
Handshake setting is set to none. But to receive data we need to enable to DTR. When handshake is off, we shouldn't be force to enable DTR to receive data. or any other flow control...
Okay, thank you for the notice. I will wait then.
Assuming that NXP will not do that, I'll declare this conversation as resolved.
@hathach Is there anything missing here?
API-wise, I'm not sure which way to go.... The major question is if the application or TinyUSB should be responsible for the allocation of the class' data structures. I'm contemplating something for memory allocation like:
bool usbtmc_connect_cb(uint32_t config, uint32_t itf, struct tmc_state **state ); // app may malloc or return static memory address
void usbtmc_disconnect_cb(uint32_t config, uint32_t itf, struct tmc_state **state ); // app should free the memory here, if needed
`...
I am not qualified to answer questions on how the library is supposed to be implemented. My only experience with tinyUSB so far has been just messing with the examples and without a deeper knowledge of the USB protocol I am not even sure if I can really do anything else, or contribute in any meaningful way. (Unfortunately the tinyUSB docs are quite minimal.) On the part about other USB libraries the place where I even got the idea for multiple TMC ports is this project https://github.com/xyph...
It looks like that project only supports a single interface at a time.
I'm starting to believe that TMC is not a great protocol to use for USB-GPIB adapters. VXI-11.2 (or perhaps HiSLIP) is a better match. These could be done using ethernet over USB (RNDIS, ECM, etc...) Also note that each USB488 interface needs 2 endpoints, and most USB devices are limited to 6 or 8 endpoints... so 2 or 3 TMC interfaces per USB device.
Interesting, thank you for the hint.
It isn't that interesting because there is only one USB peripheral
ideally you should be able to do both device and host at the same time
its not planned from the adafruit side but I don't know if espressif is working on it
(or has it working)
I am new to this community so hopefully I am asking this in the right channel. I am working on a project using an ESP32-S2 running CircuitPython (CP). I am currently using the TinyS2 for development but am in the process of designing a custom PCB that will be more suited to the specific hardware requirements of the project. In an effort to validate the process I will need to work through to set up CP on a fresh ESP32-S2 microcontroller I swapped the original one out on one of my dev TinyS2 boars as a test platform to sort out getting this process defined and CP up and running on a fresh ESP32-S2. I am unable to get any response from the test board over USB. Windows 10 does not even see a USB device in device manager. I am also not getting any response from the default board UART. I am assuming that in order to get CP up and running I need to first install TinyUSB? I have had no issues updating firmware on a different TinyS2 board using esptool by putting the board in boot mode and using the TinyUSB virtual COM port that shows up in boot mode. I have done this type of thing many times on Micropython ESP32 based projects where I simply push in the code over the UART interface but the native USB workflow is a bit new to me and any help on this would be greatly appreciated. I have looked for documentation on this and honestly struggling to fully understand exactly what dependencies I need to get sorted and specifically what process I need to go through once the dependencies are all put in place and proven functional. I appreciate any help on this and I am happy to provide any additional information if needed.
You do not need to install the UF2 bootloader to install a CircuitPython .bin file. You do for a .uf2. You can use esptool.py to install the .bin. You hold down the boot button. Are the instructions here not working for you? https://unexpectedmaker.com/tinys2#faq
@glacial stratus thanks for the quick reply. To further clarify, I almost never use UF2 and have exclusively uses a batch file I made to call esptool.py to install a target .bin, this process works fine on two different TinyS2s that were right out of the box however I changed the actual ESP32-S2 microcontroller chip on one of my TinyS2 dev boards for the sole propose of proving out how to take a blank freshly installed ESP32-S2 chip from nothing to a functional CPython firmware instal as I am designing a custom board for this specific project and I will need to have a working process to get CPython up and running on the new boards. The issue I am having is that the blank ESP32-S2 does not respond to the boot/reset button sequence to get it into boot mode which means I do not have a USB virtual com port to push the .bin file to. I tried using the UART pins connected through a know previously working line driver setup but on both the fully functioning OEM TinyS2 and the other TinyS2 that I replaced the microcontroller on esptool.py fails to connect to the ESP32-S2. I have never built my own CPython .bin but plan to for this board. I suspect that a fresh “blank” ESP32-S2 does not have TinyUSB installed/configured so I have no way to activate the USB COM that shows up in boot mode which seams to be the only com port I am currently able to push the .bin file to. I hope all that makes sense and once again, I appreciate your help!
The ESP32-S2 has a bootloader in ROM. TinyUF2 isn't used to load .bin's. So there is some other problem with the chip you put on the board. it should have the ROM bootloader on board on a fresh chip. But there may be a fuse setting to change, or there may be a soldering problem. I am somewhat inclined to suspect the latter.
@glacial stratus ah, okay. So the com port that shows up in boot mode has nothing to do with TinyUSB but rather an independent CDC function that ROM activates in boot mode? If this is the case, I am guessing that TinyUSB gets installed as part of the CPython .bin file which makes sense as that is when the mass storage and repl CDC shows up as they are all handled with TinyUSB? I inspected the soldering very closely and even fixed a few pins that lacked sufficient solder but I did have to get the chip pretty hot to hot air work the thermal ground pad. I think you are correct that this is a chip issue. I will pop a new one on and see how it goes. Thank again for your support!
The combined.bin file from the TinyUF2 repo includes TinyUF2 and the partition table (note: TinyUF2, not TinyUSB: TinyUF2 is built with TinyUSB).
however, the circuitpython .bin does not include TinyUF2
@glacial stratus understood, thanks for the nomenclature clarification, this has been so helpful. Much appreciated!
good luck!
@glacial stratus I put a new MCU on the board but this time I used an oven to keep the heat under control. I was able to get it all up and running. I wanted to say thanks again for the support!
I am experiencing the exact same problem. Is there already a workaround available that doesn't involve fiddling around with drivers?
I'm trying to implement a composite device that has RNDIS capabilities and a serial interface. This works fine as long as I only provide one configuration descriptor.
As soon as I add a second configuration (for CDC_ECM support since Mac OSX devices don't support RNDIS), my windows PC will only pick the very first interface it sees in a descriptor.
After...
I updated this branch to fix #1532.
This has been done intentionally. They use the DTR signal to detect when the PC/host has actually opened or closed the com port. I agree, it causes problems it some cases. Most of the arduino CDC implementations do this as well; it is fairly common.
I have a pull request submitted that adds a CH341 emulation class driver which would solve your problem.
https://github.com/hathach/tinyusb/pull/1507
You can get this from my fork here: [https://github.com/TravisRo/tinyusb/tree/ma...
Honestly, this is kind of useless in its current form.
https://mesonbuild.com/Subprojects.html
Make this a project and expose the dependency, that way it’s easier to include the code.
Thank you for responding my inquiry. Yes I checked the code. And Thank you for the PR #1507
When people use MCU which support USB, and if serial port is needed using CDC is common to use instead of using USB serial converters. When it happens, you expect using CDC to be the same as using a USB serial converter. Using DTR to detect connection shouldn't be implemented. We can't expect all application to raise DTR when open serial port. That's why I raise this issue.
@MrGreensWorkshop
CDC class has very limited function. I made this issue long time ago https://github.com/hathach/tinyusb/issues/400 and had a long discussion https://github.com/hathach/tinyusb/pull/401
thank you for you PR. I change my mind a bit, and re-add the OPT_MCU_MIMXRT11XX. Application should continue to use either OPT_MCU_MIMXRT10XX or OPT_MCU_MIMXRT11XX , the OPT_MCU_MIMXRT is used internally. Although they have no differences now, but in the future, NXP may just introduce some breaking changes e.g to rt1200, so we are better to be safe.
It is a bit late, since it has a compile issue with rt1050 when bumping up mcu-sdk and I have to switch to troubleshoot other issue. Tu...
Thank you for merging. I have tested it with both a MIMXRT1170EVK and a MIMXRT1050_EVKB board. Both work. In the Makefile I use OPT_MCU_MIMXRT, being happy that there is one difference less ni the Makefile for the boards.
I saw in #482 too. I think author of this repo only tested in VT100 terminals like PuTTY or Teraterm. That's why he thinks its ok, but it's not.
PuTTY or Teraterm terminals are made for VT100 etc., not exactly plain text transmission. You can use if you want. But those are uses other pins too. DTR -> DSR and DSR <- DTR. That's the problem.
Asking host application for DSR on is reduce the compatibility with other apps if user is explicitly select no flow control.
I think you should ask pico SDK to remove tud_cdc_n_connected() test, just like #506 remove this test from examples.
@robert-hh rt1050 only has issue with the symbol naming in later mcu-sdk, fixed already.
Thank you for merging. I have tested it with both a MIMXRT1170EVK and a MIMXRT1050_EVKB board. Both work. In the Makefile I use OPT_MCU_MIMXRT, being happy that there is one difference less ni the Makefile for the boards.
no problems, I am the one to say thanks. Everything is working well now. The bsp/imxrt can continue to use the OPT_MCU_MIMXRT that would be no problem at all. I mean in other applications, user should use the more specific MCU macros. It is not a matter now, but N...
Removing tud_cdc_n_connected() from your code is not quite enough. the cdc class also changes the tx fifo back and forth between overwriteable (not connected DTR=0) and not overwriteable (connected DTR=1)
Describe the PR
Fix warnings when compiling rp2040 with older version of gcc. pico-examples with across gcc version 7, 8, 9, 10, 11
https://github.com/hathach/pico-examples/actions/runs/2651623363
- Remove example.cmake and it's calls from each example, as we already have
family_CMake functions that configure examples - Added new CMake function to add the warnings to a target, and (conditiaonlly) called it from the rp2040 family.cmake allowing turning warnings off if it breaks some future SDK release.
- Note: I did not add this to any other family.cmake since there don't seem to be any that define the family_configure_xxx_example` functions
Operating System
Linux
Board
STM32 boards
Firmware
examples/device/cdc_msc_freertos
What happened ?
Using the cdc_msc_freertos example compiled with either ESP-IDF v4.4.1 or latest master with an STM32 chip, when copying files to the MSC device the tud_cdc_rx_cb is not being called.
How to reproduce ?
- Grab the TinyUSB repo
- Set up ESP-IDF and export environment
- Build example using TinyUSB make build system
- Start a debug session and place a breakpoint...
Hey guys! I am super new to this and I've never done anything tinyusb related. I was working on a project and the goal was to have a board that's running CircuitPy to be able to detect what kind of Operating System the host it's being connected to is running. So for example, if I plug the board into a Mac, the board should figure out that it's running MacOS. Consequently, if I plug it to a Windows machine, it should know that it's running Windows etc. Would it be possible to achieve something of this sort by analysing the data packets that are being sent back and forth between the device and the host during a USB enumeration phase? From my understanding, each host OS has some unique patterns in which the data exchange is being made. Would we be able to tell from those patterns what OS the host is running? I was thinking of somehow rewriting some of the steps in the enumeration phase in order to trace back the patterns and assign them to a specific OS
Operating System
Windows 10
Board
lpcxpresso55s28
Firmware
examples/device/hid_generic_inout
What happened ?
I am trying to compile the hid_generic_inout device example but the following error appears:
A subdirectory or file _build\lpcxpresso55s28\obj\examples\device\hid_generic_inout\src\ already exists.
I understand that the problem is when the command promt mkdir is executed from rule.mk file or something similar.
How to reproduce ?
Following th...
thank you very much, I think we need a bit extra works with fallthrough. I push an update asap
we still need to tell gcc 6 this is intended fallthough, also since usbh.c is compiled with other gcc we should check if GNUC is defined first at well
the dowhile didn't do anything, but fallthough in comment is marker to suppress warnings for compiler that does not support the attribute.
everything is perfect now, ci in my pico-examples forks is happy as well from gcc6 to 11 https://github.com/hathach/pico-examples/runs/7339158529?check_suite_focus=true
@kilograham though there are another issue when compiling with LOG=2 in tinyusb example:
make BOARD=raspberry_pi_pico LOG=2
<command-line>: error: "CFG_TUSB_DEBUG" redefined [-Werror]
The CFG_TUSB_DEBUG are defined twice in
https://github.com/hathach/tinyusb/blob/1a8c3a863bb1d172364ffe80029620fa75efc7a4/hw/bsp/rp2040/family.cmake#L121-L123
https://github.com/hathach/tinyusb/blob/1a8c3a863bb1d172364ffe80029620fa75efc7a4/hw/bsp/rp2040/family.cmake#L55-L59
I could ...
I think you'd want to start with a USB analyzer to confirm different patterns
Good point. As far as I know, there are some papers which describe this (how the patterns differ). So assuming I have the patterns, I am not exactly sure how I would implement their detection on top of tinyusb. I am guessing the best bet would be to somehow “log” the flow of packets during an enumeration phase and draw a conclusion based on the exchange order?
you'd probably want to do it in tinyusb
Fair enough. I'll dig around the project and see what I can come up with
[hathach/tinyusb] New branch created: revert\-hid\-callback\-len\-temporarily
Describe the PR
Since this require callback changes -> application change. Postpone this in 0.14.0. We will re-apply it after the release
thanks @perigoso (late response again), I actually ordered this, but it is now kept in the custom. and it has been a PITA with custom to get this particular package.
Can you be specific on which
- esp32 boards are testing with
- which example you are building
Howver, I don't see why would tud_cdc_rx_cb() has to be invoked when copying file to msc. cdc & msc are 2 separated classes.
It seems that windows 10 decides that our descriptors aren't correct and refuse to proceed with enumerate. I still haven't tried this out
@MatiMcFly your issue is different, in this issue, device isn't got it address assigned yet. Double check your descriptor, length, type etc... You could create your own issue with detail of setup/code/log for reproducing/troubleshooting.
[hathach/tinyusb] Pull request review submitted: #1531 USBTMC: Fixes and support for high\-speed USB
Superb! Thank you very much for your PR, and sorry for late response. I have got into too many issues lately :)
CDC should still send & receive data even if DTTR/RTS aren't set. Could you try the stock example from this repo examples/device/cdc_msc to see if it could echo back. cd to the example directory and run
make BOARD=raspberry_pi_pico
If yes, then the issue is pico-sdk making use of the connect() API which return the state of DTR. In that case you should ask rpi team to remove that check.
Were you able to do testing with HS USB to confirm it works?
Were you able to do testing with HS USB to confirm it works?
I would love to, but not yet. The changes look great, but you are right, it may not be enough. I will try to pull out my old windows laptop and get it set up to test with. Will post the testing result here as soon as I could.
While I've been using Windows... Linux does have USBTMC support, though I don't know if it'd run into the same ENDPOINT_HALT bug or not.
Thanks for the reminder, to be honest, I haven't tried usbtmc before, I will give it a try this week.
@hathach
I see examples/device/cdc_msc not using tud_cdc_n_available, but example examples/device/cdc_dual_ports uses tud_cdc_n_available
This is how raspberry pi pico sdk implemented. they are using tud_cdc_n_available that's why its happening.
https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_stdio_usb/stdio_usb.c
Kind of you are right it's their problem. I think there must be better implementation for tud_cdc_connected don't you think so?
Let me know if you figure out the better way to determine there is a connected client, I am happy to make the changes.
Note: there is a difference in cdc behavior when dtr is not set, the tx buffer will become overwritable, i.e if tx fifo is full, it will be overwritten. more details of this behavior is discussed in previous issue/pr mentioned above.
[hathach/tinyusb] New branch created: release\-0\.14\.0
Describe the PR
increase version for release along with minor doc update
I made some changes and test it's behavior.
https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_stdio_usb/stdio_usb.c
first changed this
bool stdio_usb_connected(void) {
return true;
}
and renamed tud_cdc_connected() to stdio_usb_connected()
When port is opened all data in tx buffer output to terminal.
This is not problem because when handling data on pc we can flush buffer.
Is there any other concerns?
as mentioned above, the only difference in behavior is tx fifo can be overwritten when dtr is not set. When dtr is set, tinyusb will blocking wait for tx fifo to be sent since it is certain there is waiting client. In other words, If you send too many data in short period, there maybe some missing.
connected() is option, going to support dtr or not is up to stdio integration i.e rpi team. For the changes you propose is within pico-sdk, you should ask them to see if it is acceptable or not.
@hathach Things are more clear now. Thank you for your explanation.
no problem, I am glad that help. The current state of control signals (dtr,rts, cts etc...) in cdc acm are not standardized among terminal clients, though more and more terminal use dtr as connected nowsaday. I will try to revise/improve this later on when having time. I guess we could now close this issue here ?
I open the this PR on pico-SDK.
Clearly tud_cdc_connected used by choice of pico-sdk team.
though more and more terminal use dtr as connected nowadays.
About that. It is also mentioned in #482.
Universal Serial Bus Communications Class Subclass Specification for PSTN Devices for Abstract Control Model (ACM) ..
PSTN Devices are mostly modems. Most of time we need flow control to control data flow. Let's not confuse with m...
Just to clarify... this was a silly problem. I had to clean the project before. X)
Operating System
RaspberryPi OS
Board
RaspberyPi Pico
Firmware
Pico is running Pico SDK 1.4.0
The RPI4 is running Linux dev1 5.10.103-v7l+
What happened ?
The board runs as a USB device. It has a loop which write 20 times more data than it reads, over the CDC serial port. When using some USB hosts (but not all), the board will eventually hang and not be able to send any data.
I believe that this is what is happening when running the loop mentioned above:
- The ho...
One could argue that neither RPi4 nor the Pico is at fault here. I am reasoning that the RP2040 MCU should silently ignore the OUT packets until it is ready to accept more data. By not responding to the OUT packets, the host should treat this as a failed transmission (data error), so host should retry but perhaps not forever? After some retries, the devices would be declared broken. On the other hand, not being able to accept data for long periods of time could be an acceptable scenario for ...
From my (quite recently acquired) understanding of USB, I'd like to suggest a solution.
I think the problem is that the OUT endpoint is not being "armed" in step 4 above. Even though the rx fifo queue is full, the hardware buffer should be setup to receive more OUT packets. Once the host tries to send another OUT packet, it should be replied with a NAK until there is room in the fifo queue to accept more data. Unless the hardware think the buffer is already full, it would reply with an AC...
@pigrew thank for the feedback. I don't think there are any NAK at all in this case, which is the cause of the problem. I don't have a hardware usb analyzer so I cannot very that though.
I have a RP2040 somewhere, but I'm not familiar with its USB peripheral. I've also not used the FIFO transfers in TinyUSB.... (I only have experience with the block transfer modes).
It would be trickier programming, but the device code could let the HW buffer fill up while the SW FIFO is full. Once the HW buffer is full, the peripheral should automatically NAK future transfers. If it never NAKs when one or both buffers are full, than that certainly is a problem.
You may be able to...