Describe the PR
Add bus suspend and resume support for esp32s2
@dhalbert
1 messages ยท Page 14 of 1
Describe the PR
Add bus suspend and resume support for esp32s2
@dhalbert
Set up
Describe the bug
ESP32-S2 currently doesn't detect disconnection event. Instead Suspend is detected as the side effect (since bus is idel > 3 ms). Worse, it detect suspend infinitely !!
To reproduce
CFG_TUSB_DEBUG = 2Log
...
I had an idea how to solve this issue! Not an overall solution but a step closer to it. If we would allocate all TX FIFOs not starting directly behind the RX FIFO but from the top (like heap and stack), the common RX buffer can always be extended at any time without problems! This comes in handy in case an ISO OUT EP is opened with a size bigger than 64 bytes (the current standard size of the RX FIFO) because now the RX FIFO can be extended immediately! The size of the RX buffer is thus not r...
Hihi, I am off for a couple of days. Will check it out afterwards :)
I wrote an application loosely based on the webusb-serial example, that transfer small packets of sensor data, ~10 packets/s, from a USB dongle (nrf52840-mdk) to the host computer via the vendor interface. Just like in the example, I simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) via controlTransfer() to activate or de-activate data transfer.
Possible problem. IF the following happens:
I just tested usbtmc example (master branch) on a STM32F0, and it's enumerating and responding to "*IDN?" on Windows 10. As far as I know, I'm the only person who has used the class and I've only used it on a ST MCU.
I may order a SAMD21 (I've never used one before), and see if I can figure anything out if this issue doesn't get debugged soon.
The only "different" thing in the UBTMC class is that it uses an interrupt endpoint by default. You could try disabling it? Set `examples/devic...
I just tested usbtmc example (master branch) on a STM32F0, and it's enumerating and responding to "*IDN?" on Windows 10. As far as I know, I'm the only person who has used the class and I've only used it on a ST MCU.
I may order a SAMD21 (I've never used one before), and see if I can figure anything out if this issue doesn't get debugged soon.
The only "different" thing in the UBTMC class is that it uses an interrupt endpoint by default. You could try disabling it? Set `exampl...
I've been able to reproduce the symptoms on a NXP LPCXpresso54114 board.
I'll attempt to debug the problem, but I'm not at all familiar with NXP MCUs.
@PanRe hihi sorry for late response, I have taken a couple of days off and struggle to catch up with day work. This is a good idea, though I still don't quite understand its advantage. Since ISO are opened last, it is all come down to ISOs endpoints only with sub-space of FIFO. For only-one ISO config, there should be no problem at all with fragmentation.
PS: I really need to work on this asap, it has been on-pending for quite some time :(
The problem occurs if you want to open an OUT-EP bigger than the standard size of the RX FIFO. This can occur easily since maximum ISO size is 1023 byte for FS or 1024 byte for HS. The standard RX size is set lower than this value. So you need to extend its size at run time or you need to know this before you allocate the RX FIFO size. Knowing it before is not possible if you do not want to parse the descriptors.
Noob question here:
Will the webusb example work with e.g. ESP32-S2-Saola-1, even though the esp-idf does not support USB host functionality? Or is the USB host functionality not required for webusb?
you dont need USB host for webusb. however, we kinda recommend going with web serial instead of web usb because web usb is much harder to use.
https://codelabs.developers.google.com/codelabs/web-serial/?hl=ro#6
I'm wondering then, what makes the S2 a candidate for tinyusb support but not the good old esp32?
The ESP32-S2-Saola-1 board's specifications say that it includes a USB to UART bridge, is that not a problem?
webusb, USB serial, USB hid etc are using native USB device, which old esp32 does not have. CP210x on saola board is not used in this case, you may use it only for serial logs or to flash, but all USB device implementations work on native USB which is using pins 19 and 20 on S2.
you can use webusb with the S2....but we really recommend webserial for web-to-device interaction as it is so much easier to do and you can use your old esp32 :)
The problem occurs if you want to open an OUT-EP bigger than the standard size of the RX FIFO. This can occur easily since maximum ISO size is 1023 byte for FS or 1024 byte for HS. The standard RX size is set lower than this value. So you need to extend its size at run time or you need to know this before you allocate the RX FIFO size (when a new configuration is set up). Knowing it before is not possible if you do not want to parse the descriptors.
Yeah, you're spot on with out ISO, I am ...
Hi Guys,
Used the example in the tinyusb folder for MSC. (tinyusb-master\examples\device\cdc_msc\src)
I can successfully run the same code in STM32CubeIDE. However, Keil didn't happen in Uvision5. Does not recognize the USB device. Can you help me?
Note: In STM32CubeIDE, the compiler uses GNUC.
I had to enable -gnu to compile it in keil.

Code:
[STM32F0_MASS_STORAGE_V0...
Describe the PR
Add support for USBD of NXP FRDM-KL25Z.
Additional context
The PR needs MCUXpresso SDK for SDK_2.2.0_FRDM-KL25Z. It was pushed on my branch.
board_button_read() returns 0 any time, because the board has no button. Following examples don't wor...
Hi,
I try to bring tinyUsb to my project using IAR EWARM(8.5). I added the source files, copied tusb_config.h and usb_descriptor.c from one of the examples. I expect to get a lot compiler errors and I'll work from there. But instead I got IAR internal errors like this:
Tool Internal Error:
Internal Error: [Front end]: assertion failed at: "layout.c", line 2909 in set_field_size_and_offset
I wonder if I missed anything, like compiler specific configuration etc? It appears this only h...
Hi,
That's quite strange.... Which class driver are you using ?
Signed-off-by: MasterPhi
Describe the PR
IAR complains on "unknown type" on memcpy, and gives warnings on undefined volatile access order
A clear and concise description of what this PR solve.
Thanks for the pr, look great, I only want to slightly make it more portable without uintptr_t
Maybe only ((uint8_t const*) data) + nLin*item_size) is good enough. I am not entirely sure but uintptr_t seems to be optional type for some platforms. Best to keep it as portable as possible
I added cdc, hid, msc sources to my project. The tusb_config.h has CFG_TUD_CDC and CFG_TUD_MSC set to 1 so I guess they're enabled.
make it more portable without uintptr_t
Done
Could you upload your project ? I can't reproduce on 8.50.6 and 8.50.9
Signed-off-by: HiFiPhile
I'm still having issues when receiving more than 3 bytes at once with the MIDI class.
I'm using a STM32F746-Discovery board.
Example code for loopback:
uint32_t num_bytes = 0;
uint8_t buf[64] = {0};
if ((num_bytes = tud_midi_available())){
tud_midi_read(buf, num_bytes);
tud_midi_write(0, buf, num_bytes);
}
When sending a SysEx message from host with 4 bytes (i.e. {0xF0, 0x0, 0x1, 0xF7}), I receive:
{240, 0, 1, 0, 0, 0, 0, 0, 247}
Sending SysEx messages w...
Superb!! Thank you very much, I am off for vacation, will check this out in a couple of days.
Here's my test project. I used ST's example project for the Nucleo STM32L452 board.
Tinyusb source should be under the directory 'tinyusb'.
IAR project file is at: test_proj\STM32Cube_FW_L4_V1.13.0\Projects\NUCLEO-L452RE\Templates_LL\EWARM
Sorry for the delay here, I've been doing some rewriting of other parts of my firmware but I'm about to pick this up again. I'm also now building on top of FreeRTOS so I'm thinking more about avoiding blocking the whole USB stack.
I think putting the new code in net/ makes sense. @hathach , what do you think about renaming src/class/net/net_device.c to src/class/net/ecm_rndis.c and CFG_TUD_NET to CFG_TUD_NET_ECM_RNDIS? Then src/class/net/net_device.h would be split into two files...
Hello!
Thanks for the development of TinyUSB
Can you give me the example of a keyboard and the diagram of connections with USB-DIP? I think I need a 33 ohm resistor, but I can't find the connections (USB pins)
I want to play your demo: https://twitter.com/tinyusb/status/1247559949929967617?s=19
Thanks!
I tried the example on a STM32F411CE blackpill board and had no issues. Runs as expected. I have obtained a j-link debugger to see if I can see differences between the STM32 board and the SAMD21 board with the code execution.
what is the Pa082 that we need to suppress with IAR ? I would prefer to fix the warning with the code rather than suppress it with pragma
can you move the } before the break; , my style is having break outside of }. I admit not many people do it that way. But it is best to be consistent.
@henrix this PR is merged, if you still have issue with it, please open the new issue with detail on your set-up and how to reproduce the issue.
Does IAR complains without these prototypes, these are only used by usbd.c, typically they would have its own private header, though I try to cut-corner and put those prototypes inside the usbd.c diretly
https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L264 .
Thank your very much for your pr to fix compling with IAR. There is only a question regarding the prototypes
hmm, there is probably other places that have :0 padding somewhere in the codebase, I didn't know this is not in the specs :facepalm:
If the option Require Prototypes is enabled, IAR emit error about this.
Yes there are many zero width bitfields :) I've also reported this bug to IAR
It's also my style, just didn't pay attention :)
Warning is Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement
Because both wr_idx and rd_idx are volatile, IAR don't know which one should be accessed first.
In order to fix it we need to add temporary variables:
uint16_t tu_fifo_count(tu_fifo_t* f)
{
uint16_t wr_idx = f->wr_idx;
return _tu_fifo_count(f, wr_idx, f->rd_idx);
}
thank you for the pr, look great now.
thanks for clarification, I guess there is no harm to have extra prototypes here.
anย integral constant expressionย with a value greater or equal to zero. When greater than zero, this is the number of bits that this bit field will occupy. The value zero is only allowed for nameless bitfields and has special meaning: it specifies that the next bit field in the class definition will begin at an allocation unit's boundary.
I checked a bit further, and indeed it is part of the specs (not entire sure which specs version it belongs to). Yes, it is good idea to report ...
thank you very much for your effort to fix warnings with IAR.
It has been fixed in the latest version of SES, with the linker option --undefined-weak-is-zero
thank you for the update, I guess we could then close this issue by now ?
Yes, but maybe put a word somewhere ?
I guess this issue is good enough, most user could google this out. Or we could point them to this as reference
Implemented functions tuh_msc_read10 and tuh_msc_write10
I'm sorry if you are starting review.
I was checking the examples of HID and found a bug. I've pushed the fix for it.
I'm sorry if you are starting review.
I was checking the examples of HID and found a bug. I've pushed the fix for it.
Not a problem at all, I am waiting for the board arrival to test with, which is probably tomorrow.
@HiFiPhile ah, I know this warning, have been encountered it before. IAR is pretty smart about this. There is quite a lot of wr and rd idx passing to a function at same time. So yes, it makes sense to suppress the warning as you did here. We may come back later to "fix" it whenever having time. Please also put the warning message of Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement so that we could know why we suppress the warning.
Set up
Describe the bug
When sending a MIDI SysEx packet from host with more than 3 bytes, mangled byte array with wrong number of bytes is received. Sending a MIDI SysEx packet with more than 3 bytes works fine though. MIDI SysEx is sent from Web MIDI application.
To reproduce
Example code for loopback:
uint32_t num_bytes = 0;
uint8_t buf[...
I struggled with the on-board openSDA of the KL25Z, out of all of my machines, it only enumerated with macOS (linux and windows is big no). Also I couldn't get it into BOOTLOADER mode to update to DAPLink as people suggest to fix the issue. Ended up with just solder the SWD and just external jlink for flashing. But that is not really an issue at all.
Amazing, excellent works !! I have tried it on my FRDM-KL25Z and it works perfectly with msc_cdc, cdc_dual_ports, hid_generic_inout, webusb_serial etc ... Other sram heavy example such as net_lwip_webserver aren't testable due to low SRAM on the KL25Z. Thank you very much for the PR.
PS: Since it break the ci, I will do a follow up that add the KL25Z to nxp_driver (just using the device/MKL25Z4 in your branch) and skip the build for large example
Describe the PR
@kkitayam
Thank you for your confirming.
I am happy to contribute this great project!
Thank you for your confirming.
I am happy to contribute this great project!
Thank you again, I am sure your contribution will be appreciated by many other in the future :)
hihi @j4cbo sorry for late response, I were off for vacation the previously and is only doing catching up until now.
Sorry for the delay here, I've been doing some rewriting of other parts of my firmware but I'm about to pick this up again. I'm also now building on top of FreeRTOS so I'm thinking more about avoiding blocking the whole USB stack.
Not a problem at all.
I think putting the new code in net/ makes sense. @hathach , what do you think about renaming `src/class/net/net_...
The LPC55 currently defaults to the full speed USB port.
It would be nice to get the high speed port working as well since this part has the high speed phy integrated.
I would like to promote this with my LPC55 based feather board, but I need to get it working on high speed port that is connected to the micro-USB connector.
sorry for late response, I have just been back from vacation. Still catching up with other works, it may take a bit of time for me to pull out the host hardware setup to test this out.
Describe the PR
Implementation of #540.
TX FIFOs are now starting to allocate from the top, RX FIFO at the bottom of the available space (like heap and stack). As such, free space is between TX and RX allocations allowing the RX FIFO to grow in size dynamically which is needed in case an ISO OUT EP is opened which is greater than the standard RX FIFO size. Also, once such an OUT EP is closed, the RX FIFO size will be reduced once the RX FIFO is empty.
Adding Double M33 Express board to TinyUSB.
This includes a simple driver for the neopixels.
The linker script is offset for use with TinyUF2.
look great, could you also update the https://github.com/hathach/tinyusb/blob/master/docs/boards.md here with the board name and its link.
The FIFO layout was mentioned at this position before and i only updated it. It is a simply copy and paste issue. I will remove it!
Superb !!! Thank you very much for the PR, it looks great. I haven't tested it on hardware (will do later on), I only have a couples of feedback per review. Let's me know if you think otherwise.
This is minor, the comment regarding the // In FIFO is allocated by following rules: aren't true anymore. we should remove it. This is very minor, I could do it myself later on. Note: the reason for such as rules is I am trying to allocate more than epsize fifo for bullk endpoint e.g msc which will greatly improves its throughput. But yeah, it is not really good, maybe we should have some optional method for application to dictate the fifo size for synopsys later on in a separate PR.
this is such as great idea. Maybe we should have the formula as inline function, that take max_packet_size and return the rxsiz value, and use this function for the initial set in bus_reset() as well.
Note: it is minor, but I think we don't really need to have a min limit to 16 words, since the GRXFSIZ set by bus_reset() is already set a min for it. (64 for FS, 512 for HS).
// function name is terrible, you could name it anything else if that makes sense.
static inline uint16_t ...
since this is bus_reset, we should use = instead of +=
_allocated_fifo_words_tx = 16
Good idea, i called it
static inline uint16_t calc_rx_ff_size(uint16_t ep_size) { return 15 + 2*ep_size + 2*EP_MAX; }
The minimum 16 is not required since this is handled outside.
True, i removed it!
If a bigger FIFO results in a higher throughput, what is the matter to define a bigger EP size anyway? I mean, why should i set an EP size lower than the FIFO size? As for the STM32, you can not write anything into the FIFO once it was scheduled to transmit. Only after the FIFO is empty you can put more into it... But i am not an expert here - it is easy to manipulate the sizes by additional settings. I recommend doing this when somebody really has the need/time to benchm...
Very true, sorry i somehow thought the while loop is outside of dcd_synopsis ^^. I correct this!
@PanRe the EP Size is USB specs's transaction size, each packet can only carry that much. For Fullspeed you can only have max of 64 bytes, but you could set the FIFO for it to larger value e.g 256. The screenshot probably help to explain it, the MSC Read a very large data e.g 4096 bytes, since this is FS the EP size is = 64.
however, you don't have to worry about this for now, I will try to come up with a scheme for these type of optimization later on. The most demanding throughput is MSC, it is normal for MSC to read/write 64KB or more in a single SCSI command.
Very interesting! Thx for the details! Well maybe we should already optimize the FIFO allocation a bit now before complains about performance comes up.
Since we do not parse the descriptors, there is now way of determining the optimal FIFO size. IMHO we need additional information from the user how much bigger the FIFO compared to the EP size should be!
How about introducing a factor ff_fact which determines the FIFO size compares to the EP size. There are various possibilities e.g.
@PanRe don't worry about it for now, people haven't complained just yet. There is a few ways we could bypass the auto allocation like some specific macros as you mentioned, or having platform-dependent API, I didn't make up my mind just yet.
P.S.: Is it alway the case that BULK EPs work better the bigger their FIFO is? How about CTRL and INTERRUPT EPs? Do they also gain significantly from this? ISO does not since they are transmitted only once per frame.
Only Bulk and Control (asynch...
Ok fine! I just thought that if we would find a way to solve the fragmentation problem with the TX FIFOs (as for now only the last opened IN EP can be closed) then we could also stepwise optimize the FIFO allocation! To solve the fragmentation problem we would need to find a way to reallocate active IN EP FIFOs at runtime. This could also be used for optimization. For example, lets say CTRL, INT, and ISO EPs get only the FIFO size equal to the EP size, so no problems with opening them. If a B...
@PanRe those are really great idea, the open/close endpoint does indeed complicate the optimal fifo allocation for Bulk EP. Hopefully people don't complain that fast about the throughput on stm32 :)
As a very quick workaround we could introduce a factor for BULK and CTRL EPs by use of a #define. This way, the users can help themself by adjusting them.
That is one of the way to do it, however, currently the stack doesn't have any special macro for any dcd port since I want to abstract it out as much as possible.
Describe the PR
report size is often 64 bytes, and user often overlook this macros. Change default to 64 to avoid buffer overflow. Application with smaller need (e.g keyboard/mouse) can change it to smaller value.
Describe the PR
increase setup packet size from 8 to 12, since USB DMA controller is suspected to overflow the buffer with 2 extra bytes. Issue is discovered while troubleshooting https://github.com/adafruit/circuitpython/issues/3912 . This is considered a walkaround/hack rather than actual fix. It may probably overflow more than 4 bytes in the future, currently 4 bytes is too cheap fix consider the amount of work to trace it down so far. @dhalbert
In https://www.avrfreaks.net/forum/getting-extrange-data-enumeration-process-usb-uc3c?skey=multi_packet_size, someone asks about two extra bytes they are getting, and the reply is that those are the CRC bytes. This is for AVR, but it's a clue.
I think this may be the issue. From the data sheet, 32.6.2.7, page 799:
If data was successfully received, an ACK handshake is returned to the host if the endpoint is not
isochronous, and the number of received data bytes, excluding CRC, is writ...
The total number of bytes to be received must be written to
PCKSIZE.MULTI_PACKET_SIZE. This value must be a multiple of PCKSIZE.SIZE, otherwise excess
data may be written to SRAM locations used by other parts of the application.
Thanks @dhalbert, the CRC part does make lots of sense. In case of setup packet, MULTI_PACKET_SIZE = 8 which is not multiple of 64, I am not sure if this would be counted as this.
Also there is a scenario when scheduling the ZLP ACK, we have to also prepa...
Do you think that MULTI_PACKET_SIZE=8 is wrong and it should be 64? I don't understand this well enough to comment.
If you merge this, in whatever form, I'll make a PR for CircuitPython and then test this more thoroughly, including on WIndows 7, etc. Thanks.
Do you think that
MULTI_PACKET_SIZE=8is wrong and it should be 64? I don't understand this well enough to comment.
I just poke at microchip driver, they use MULTI_PACKET_SIZE=8, so I think we are good, increase it has a greater chance for greater overflow I guess.
If you merge this, in whatever form, I'll make a PR for CircuitPython and then test this more thoroughly, including on WIndows 7, etc. Thanks.
merging now
Excellent PR !!! Thank you very much for putting effort into this work.
ep_size should be better in bytes. But this is minor,I could do it myself
Describe the PR
minor clean up following #r581
Describe the PR
If you prever, i leave this up to you! :)
Thanks! I am glad you like my ideas :)
I had some thoughts about how to solve the IN EP relocation problem and before i can start with that i would need to be sure about one USB framework behaviour:
If a host tells a device to open an EP (IN or OUT does not matter) and the device currently is not able to execute this request it responds with a NAK message. Some time later, the host will try again and resends its request. Is this correct so far? And further, does the host in the meantime handle remaining active EPs? If so, IN EP F...
I improved the neopixel driver with additional features and moved it to its own files.
After some hiccups getting my Feather M0 back to Arduino, I was able to run the Keyboard HID example. To set the Device Descriptor, can I use TinyUSB, or do I need to build my own boot loader?
@hard mesa you shouldn't need to change the bootloader
Thanks! I am glad you like my ideas :)
it is a great idea, hopefully after a few round of enhancement like this pr, we could have a great FIFO allocation scheme.
Not quite like that, the host doesn't explicitly tell device to open endpoints, all Control-Bulk-Interrupt (CBI) must be opened after the SET_CONFIGURE request. EP needs to be opened/enabled in order to response with NAK, For ISO, since default ITF is almost always has no endpoint. Host will need to SET_INTERFACE to switch to appropriate profile (endpoint size) before communicating.
In short, all CBI must be opened with SET_CONFIGURE, if device failed to response to this request, host may ...
actually I don't prefer to have submodule for sct neopixel driver in this repo. I would just have a copy of it in the local BSP. You could put your license and link in the file if needed.
oops, I just realized the SCT is common to several other NXP MCU and not specific to LPC55. Therefore it has more reason to include this as submodule as common source. Please excuse my lack of knowledge.
Is it possible to have WebUSB on NRF52840?
If yes, is there any plan to support WebUSB on NRF52840?
How does TinyUSB interact with SerialUSB on Feather M0? I notice that if I call Serial.begin() before calling USBDevice.setProductDescriptor(), then my device shows up as a "Feather M0," not as my device.
Describe the PR
Add support for Windows10 Command Prompt as a shell on GNU make.
Additional context
This patch has been checked for build with the following tools. I'm sorry, but I haven't checked for esp32s2.
typically I would use the ifeq ($(OS),Windows_NT), does this OS variable defined in your setup. If yes, we could just use it directly without this ifeq
You are right, these deps file aren't used at all. Would you mind removing these all together as well.
Great, thank you very much for the PR. Would you mind helping me to completely remove the deps rules as well in the PR, it is not used at all, nice catch on this :+1:
nice catch, I overlook this one, it should be relative to top :)
Hmm, the comment in line 5 is not good. I will update the comment.
The reason I am doing this is to detect whether POSIX-like shell (MSYS2/Cygwin) or cmd.exe. $(OS) is the same value, which is WIndows_NT, on these platforms.
MSYS2 and Cygwin work fine without this PR. So, We need to replace the path delimiter from slash to backslash only when using cmd.exe. I think if we use $(OS) for this PR, it will not work with MSYS2 and CYGWIN.
thank you very much for clarification. That makes sense
Thank you very much for the PR. This will help lots of windows user :+1:
Set up
Describe the bug
Toolchain setup
can you clone this repo (tip of master) and compile the example with master of esp-idf. IDF changes structure a lot, and tinyusb copy can get out of sync. https://github.com/hathach/tinyusb/tree/master/examples/device/hid_composite_freertos
I can confirm that libray works just fine with esp-idf, arduino-esp32 and arduino as component. There may be small problem to prepare arduino as component project, but its not related to this library.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
USB communication fails to work after an vendor control request has been handled.
To reproduce
On the ESP imple...
Describe the PR
Implementation of a FIFO instead of a linear buffer to be used as ISO EP buffer as discussed in #504.
Additional context
This is an initial draft and not yet finalized. It works and uses the audio driver for testing. I added usbd_edpt_ISO_xfer() to schedule a transmission by use of a FIFO and implemented it for STM32 by adding dcd_edpt_ISO_xfer() in dcd_synopsis.c.
I further needed to enhance the functionality of tu_usb_fifo as:
can you clone this repo (tip of master) separated and compile the example with master of esp-idf. IDF changes structure a lot, and tinyusb copy can get out of sync. https://github.com/hathach/tinyusb/tree/master/examples/device/hid_composite_freertos
Thanks for your answer. I pulled the latest ESP-IDF again and checked out master (now on tip of master). Updated python modules. Checked out master of tinyusb (now on tip of master). The code compiles now.
Another questions though, I wou...
I don't think you could run esp32s2 without freeRTOS. If you want, just copy CMake and modify it to do so.
I believe the problem is in the usb_descriptors.c file. When I compare the example/device/cdc_msc/src/usb_descriptors.c file, there is a comment about SAMG:
#elif CFG_TUSB_MCU == OPT_MCU_SAMG
// SAMG doesn't support a same endpoint number with different direction IN and OUT
// e.g EP1 OUT & EP1 IN cannot exist together
I believe the problem is in the usb_descriptors.c file. When I compare the example/device/cdc_msc/src/usb_descriptors.c file, there is a comment about SAMG:
#elif CFG_TUSB_MCU == OPT_MCU_SAMG
// SAMG doesn't support a same endpoint number with different direction IN and OUT
// e.g EP1 OUT & EP1 IN cannot exist together
SAMG and SAMD aren't the same, they are using different usb controller.
great PR as usual, I will try to follow this up as much as I could. For naming, please change the both dcd/usbd from edpt_ISO_xfer to edpt_iso_xfer
Great PR ! I'm also working on a USB-I2S bridge based on SAME70+iCE40 FPGA. For the moment FPGA part it's about ok and I'm waiting for SAM E70's dcd implementation. (I prefer STM32 but they need external phy, or too big package :( )
Maybe use 32bit aligned copy ? Like memcpy
Great PR ! I'm also working on a USB-I2S bridge based on SAME70+iCE40 FPGA. For the moment FPGA part it's about ok and I'm waiting for SAM E70's dcd implementation. (I prefer STM32 but they need external phy, or too big package :( )
Thanks i am glad you like it!
What are you going to do with your I2S bridge? :) And why does STM's need an extra physical? Are there not models with HS PHY embedded or what do you need?
Ok! I guess we then could also add __restrict to the src and dst pointers as done for memcpy!
What are you going to do with your I2S bridge
I started a new discussion about audio stuffs so we focus on PR here :)
Describe the PR
Add support for Raspberry PI PICO RP2040.
Note: PR code can be found at https://github.com/raspberrypi/tinyusb/tree/pico , though since github doesn't allow to have PR between repo that aren't forks of each other. I need to fetch and push it as a branch of this repo.
@kilograham You are probably too busy for other works at the moment. So I guess quickest way would be doing it myself, so that I could work on...
yeah go ahead - and i guess you are going to make the changes you suggested?
yeah go ahead - and i guess you are going to make the changes you suggested?
yeah, I will try to do as best as I could for tweaking the port after fixing the ci with decent testing (may be in the form of follow up PR). Would you mind accepting the contributor invitation so that I could request your review on any changes related to rp2040 port in the long run.
i think i already did accept
@kilograham I decide to do modification as follow-up and will merge this PR as it is even though it breaks the ci buidl. That will make it much easier for you to follow the changes and also pull the update.
Describe the PR
groups boards into family to easier to add new boards and maintain
Additional context
existing single board per folder still works just fine as before both with make BOARD= and the ci build
force to merge, ci build failed due to rp2040 aren't fully built yet with existing examples.
Describe the PR
hcd_edpt_xfer() calls get_dev_ep(), which may return NULL, and then unconditionally uses the return pointer. "assert" is used elsewhere in the rp2040 driver code and its use seems warranted here too.
Including "pico/stdlib.h" seems superfluous; there appear to be no issues with its removal.
By convention, TU drivers should implement the dcd_int_handler() API. Ensuring its presence allows users to let a fixed interrupt handler call the driver code.
Interloper macros were substituted...
Describe the PR
-DFAMILY= along with -DBOARD=. Getting all of current examples compiled with rp2040.*_freertos is skipped for rp2040 since I have no idea if freeRTOS could work with rp2040 atmhid_generic_inout has issue, both hid_test.js/py couldn't send/receive data to rp2040. Not sure why, we will fix it in a separated PR.net_lwip_webserver doesn't work with rp2040, again will troubleshoot and fix it lat...Describe the PR
Update Spresense SDK to 2.0.2.
Define Spresense EP numbers that work with the cdc_msc example.
Fix issues that caused the DTR bit not to be changed to 1.
Additional context
Source code for mkspk has been added. This tool is used to create a .spk file.
Changes to dcd_cxd56:
Describe the PR
Add a few upcoming rp2040 boards. not tested, purely based on schematic
superb ! Thank you very much for the PR.
Ah i see, I remembered having issue getting example running with cxd56. This is very rather similar to lpc17xx. Thanks for the comment, I will update the config for other example as well next time I test spresense
Will you follow up with an int_handler change?
wow - lots of great stuff going on here... a little bit overloaded but will try to take a look soon.
Will you follow up with an int_handler change?
will do, I need to get ci running first and do hand-on testing with current state of the dcd first to see what works and what not. also to make sure when changing the dcd ports, there is nothing breaking. The dcd modification is on-the-way, just need a bit of testing.
wow - lots of great stuff going on here... a little bit overloaded but will try to take a look soon.
This PR is mostly refactor BSP build support for tinyusb example an...
I have my Segger JLINK Edu setup and have 2 microcontrollers: (1) Adafruit Trinket M0 (ATSAMD21E18) and (2) STM32 Blackpill (STM32F411CE). STM32 board is working. In "main.c" I tried commenting-out the "usbtmc_app_task_iter()" subroutine and STM32 was just fine (the app did not work but the operating system was fine with the USBTMC device attach). This makes me believe the problem is with either "tusb_init()" or "tud_task()".
Here is my make command for the SAMD21:
`make BOARD=trinket_m0 ...
rtt should print some log out, please try with JLinkRTTViewer, I think you have to select the MCU and it could detect the clock speed, the swd clock around 1-4Mhz is pretty safe. Also you need to clean the project first, since LOG=2 make use of newlib nano which needs a clean to link retarget.
Thanks for the feedback. I am cleaning the build directory before each new make command. When I try a make with the "LOGGER=rtt", program the part and reboot I am not seeing the device enumerate properly. Is this expected?
This is what I see when I am not using the logger:
[ 2900.059388] usb 1-1.1: new full-speed USB device number 97 using xhci_hcd
[ 2900.206578] usb 1-1.1: New USB device found, idVendor=cafe, idProduct=4000, bcdDevice= 1.00
[ 2900.206596] usb 1-1.1: New USB device string...
Describe the PR
Upload pre-built binaries (only uf2) for all examples for all boards within a family artifact. This help testing/running example as proof-of-concept or testing pcb hardware quickly.
Set up
Describe the bug
Device doesn't seem to response to hid_test.py script
To reproduce
Run python3 hid_test.py in the example folder
python3 hid_test.py
Openning HID device with VID = 0xCAFE
{'path': b'/dev/hidraw9', 'vendor_id': 51966, 'product_id': 16388, 'serial_number': '123456', 'release_number': 256, 'manufacturer_string': 'TinyUSB', 'produ...
Set up
Describe the bug
cannot access the on-board webserver at 192.168.7.1 . The device seems to enumerate just fine. Further troubleshooting is needed
Set up
Set up
Describe the bug
Device enumerated, landing URL appear on chrome, could connect via chrome. However, there seem to be issue when using along side with cdc serial. Further troubleshooting is needed.
To reproduce
maybe you could drop the -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL that will cause some missing log, but it doesn't blockingly wait on anything.
https://github.com/hathach/tinyusb/blob/master/examples/make.mk#L121
I will try to pull out an SAMD21 board to test out with RTT log tomorrow or so if I could find time.
This looks good to me, though let's wait for @kilograham comment.
whoop, I just about to make this change, seems like we have the same idea. This does help with existing cross-platform app.
Thanks. I tried the "LOGGER=rtt" make arguement with the STM32F411CE blackpill board and I get the same results as the SAMD21.
[ 1390.525659] usb 1-1.3: new full-speed USB device number 17 using xhci_hcd
[ 1405.716388] usb 1-1.3: device descriptor read/64, error -110
[ 1420.196747] usb 1-1.3: device descriptor read/64, error -32
I was able to see the RTT log using JLinkRTTViewer with the
-DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL option enabled.
The JLinkRTTLogger doesn't work at all.
Attached are the 2 log files from JLinkRTTViewer:
tinyusb_usbtmc_example_stm32f411ce.log
[tinyusb_usbtmc_example_atsamd21e18_2.log](https://github.com/hathach/tinyusb/files/5877833/tinyusb_usbtmc_example_atsamd21e18_2.l...
larger than 64 actually should throw the error, but it won't get this far. USBD will rise an TU_ASSERT()
https://github.com/hathach/tinyusb/blob/master/src/device/usbd.c#L1112
update: further testing show that RP2040 does work when attaching directly to PC, it doesn't seem to work when attaching via an external hub.
Describe the PR
Follow up to update the dcd port of rp2040 as mentioned in the feedback issue
assigned_address in dcd, which can be extracted from requestCFG_TUSB_MCU == OPT_MCU_RP2040 since some auto build system such as arduino will include all the C file which cause compile error on other port (due to lack of pico-sdk etc ..)I was able to reproduce this issue on Elementary OS (Ubuntu derivative). Windows 10 seems to work fine.
I dont know if this is usefull somehow, but webusb (and maybe other hid example) is causing that ubuntu usb driver stop responding/discovering devices at some point:
[ 4627.697667] usb 3-1: new full-speed USB device number 13 using xhci_hcd
[ 4627.875037] usb 3-1: New USB device found, idVendor=cafe, idProduct=4011, bcdDevice= 1.00
[ 4627.875041] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4627.875044] usb 3-1: Product: TinyUSB Device
[ 4627.875046] usb 3-1: ...
@hathach an observation:
Interface Number: 1
Name: cdc_acm
Alternate Number: 0
Class: 0a(data )
Sub Class: 00
Protocol: 00
Number of Endpoints: 2
Endpoint Address: 02
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms
Endpoint Address: 82
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms
Interface Number: 2
Name: usbfs
Alternate Number: 0
Class: ff(vend.)
S...
I needed to remove the "00>" text from the tinyusb_usbtmc_example_atsamd21e18_2.log file so that it can be compared with the other log file. Here is the updated file.
tinyusb_usbtmc_example_atsamd21e18_2.log

Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
I use FreeRTOS to port uac2_headset_freertos, but when I run it and play audio on the computer, I find that the audio data buffer returned by tud_audio_rx_done_cb is only half of the USB packet capture data. I tried to compare the two...
I needed to remove the "00>" text from the tinyusb_usbtmc_example_atsamd21e18_2.log file so that it can be compared with the other log file. Here is the updated file.
The highlighted difference is the host assigning a different USB device address for each MCU. I don't think it's a significant difference.
The "interesting" part is the usbtmcd_open_cb 313: assert failed output in the atsamd log. Its DCD (device driver) doesn't like something about EP 0x81.
One conjecture is that t...
@pigrew, @hathach Thank you very much for finding the bug. The example is working as expected on my SAMD21 and STM32F411 boards.
Should I close the issue, or do you want to do that when the fix has been committed?
Fixes write buffer corruption when sending certain lengths of sysex.
All the paths in this section should set write_target_length, but this one did not.
One conjecture is that this due to the
wMaxPacketSizeof 2 bytes. I'm having trouble deciding if this is legal or not for interrupt endpoints. Full-speed bulk endpoints are restricted to 8, 16, 32, or 64 byte max. High-speed bulk endpoints are restricted to 512 byte. My reading is that interrupt endpoints can be anywhere between 0 and 64 bytes for interrupt full-speed endpoints, so 2 should be legal.
You are right, any number from 0 to 64 is complaint to the specs. However, many MCUs l...
PC OS : Windows 10 2004
Board : NUCLEO-H743ZI2
Firmware: examples/device/uac2_headset
I've encountered a similar problem using tud_audio_rx_done_cb callback to send audio samples using SAI in DMA mode - everything ought to be correct but somehow half of the data is being corrupted, though I'm not sure if it's a bug or my poor understanding of how exactly this library works - both cases are possible.
@hathach, do I create a branch with the changes and then do a pull-request? I setup my ssh key with my github account and made a tinyusb clone using it. I was going to push the changes to a new branch but I don't have permission to do that.
I'm sorry, I don't know what "PT" means.
PC OS : Windows 10 Pro 2004
Board : NUCLEO-H743ZI2
Firmware: examples/device/uac2_headset
I'm having trouble using SAI in DMA mode to transmit received audio samples to external codec ic. It looks like half of the data is being somehow corrupted (for each ~1ms SAI transmission of correct data, there is ~1ms of silence). I'm attaching code snippets:
bool tud_audio_rx_done_cb callback when SAI transmission is being set up (DMA is not using circular buffer):
`bool tud_audio_rx_done_cb(u...
@charkster, I think "PT" is a typo. He means "PR".
What you need to do is "fork" the repository, and then create a new branch in your fork. Once you do that, the GitHub website will let you create a new pull request between tinyusb/master and your branch in the forked repository.
This typo was partly fixed in #186, but the misspelling still exists in a couple of files.
test/test/device/usbd/test_usbd.c
212: uint8_t zlp_desc_configuration[CFG_TUD_ENDOINT0_SIZE*2] =
215: TUD_CONFIG_DESCRIPTOR(1, 0, 0, CFG_TUD_ENDOINT0_SIZE*2, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
225: zlp_desc_configuration, CFG_TUD_ENDOINT0_SIZE, CFG_TUD_ENDOINT0_SIZE, true);
226: dcd_event_xfer_complete(rhport, EDPT_CTRL_IN, CFG_TUD_ENDOINT0_...
fix #558
This is needed for SAMD21 and SAMD51 as Full-Speed endpoint max bytes is specified as 8, 16, 32 and 64.
This is for the USBTMC device example.
This change was verified on SAMD21, SAMD51 and STM32F411CE blackpill.
I don't understand the "unit-test" build failure, but I think it's unrelated to the changes made here.
Perhaps we could rephrase the comment as:
// USBTMC Interrupt xfer always has length of 2, but we use epMaxSize=8 here for compatibility
// with microcontrollers that only allow 8, 16, 32 or 64 for FS endpoints
Either way, I'm happy with this patch.
I don't understand the "unit-test" build failure, but I think it's unrelated to the changes made here.
Perhaps we could rephrase the comment as:
// USBTMC Interrupt xfer always has length of 2, but we use epMaxSize=8 here for compatibility // with microcontrollers that only allow 8, 16, 32 or 64 for FS endpointsEither way, I'm happy with this patch.
Thanks for the help. I replaced the previous comments with yours, and am still failing the unit-test....
@hathach , I'm not sure why the unit-test is failing. I changed one digit of code and modified a comment.
In line 27 of tinyusb/hw/bsp/samd21/family.c the "sam.h" header file is included, but no where to be found.
Also line 27 of tinyusb/hw/bsp/samd51/family.c the "sam.h" header file is included, but no where to be found.
PS OS : Ubuntu 20.04, Raspberry Pi OS
Board: seeeduino xiao
Firmware: examples/device/usbtmc
I am unable to compile the usbtmc example because a header file is missing.
/home/pi/tinyusb/hw/bsp/samd21/family.c:27:10: fatal error: sam.h: No such file or directory
...
Looks like the fork that I made has issue #616. Should I have forked from an earlier revision?
current microchip driver has asf4 in its own submodule https://github.com/hathach/microchip_driver . You need to clone submodule once more level. I will try to see if I could simplify it later on.
git submodule update --init --recursive hw/mcu/microchip
Describe the PR
Ruby v3 seems to break the current unit test, specify version 2.7
Sorry about that. I missed the step of getting all the submodules. I just updated the submodules for all the hardware and am fine now.
Did the Raspberry Pi guys just recursively added all the libraries again under their own hardware?
/home/pi/tinyusb/hw/mcu/raspberrypi/pico-sdk/lib/tinyusb/hw/mcu/microchip
/home/pi/tinyusb/hw/mcu/raspberrypi/pico-sdk/lib/tinyusb/hw/mcu/sony/cxd56/spresense-exported-sdk
When I get all the submodules it is twice the size now.
thanks Dan for spotting this, just fixed it. yeah ESP-IDF doesn't need to update aggressively for tinyusb. I wouldn't do that if not needed as well, just wait until thing is tested :)
Thanks for the PR, the unit test is unrelated, it is due to ci engine upgrade its ruby to major version. It is already fixed by #617
yeah, I saw the same panic as well, looking closely at the driver, though I guess it is due to the write to already-received control endpoint.
Apparently, the problem was caused by USB-SAI timing issues, not by the USB stack itself.
This is basically a new try on what @kaysievers did in #359, with all the recent inner changes. It also has some functions rewritten in lieu of their CDC counterparts.
It might still cause issue #377, I haven't tested it this way, I don't have the hardware. However I'm pretty sure that I can feed loads of data into my SAMD21-based device and get 100% reliable transmission.
Two scenarios were tested, a ~6K worth of SysEx and complex lightshow data with thousands of notes, running at 500 ...
I am not sure if this is the right place to be asking this but here goes!
I am using the tinyusb library with my Raspberry pi pico. i have a button connected to the pico. When the button is pressed a subroutine is called which uses tud_hid_keyboard_report to press a key on the keyboard.
All is working fine, I can do key combinations type sentances etc.
But what i cannot work out is how to use/ press media keys. I would like my button to say for example pause my music when i press it. (...
You can probably guess this but i am coding the pico in c/c++
I was having similar issues and I discovered it to be a problem with sysex sending, which I fixed in #612. Does this also fix your problem?
Hmm, for what it is worth, net_lwip_webserver for the raspberry_pi_pico target works on all PCs (Linux and Windows) that I have locally.
@hathach, if you add an โ#errorโ to ./src/portable/raspberrypi/rp2040/dcd_rp2040.c at about line 328 inside the #if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX block, and then attempt a compile, it doesnโt report the error. The โrp2040_usb_device_enumeration_fixโ appears to be specifically for a problem with (some) USB hubs.
Merge this now, since it doesn't affect the functionality, will revert if needed when comparing between forks.
Merge this now, since it doesn't affect the functionality, will revert if needed when comparing between forks.
@hathach, if you add an โ#errorโ to ./src/portable/raspberrypi/rp2040/dcd_rp2040.c at about line 328 inside the #if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX block, and then attempt a compile, it doesnโt report the error. The โrp2040_usb_device_enumeration_fixโ appears to be specifically for a problem with (some) USB hubs.
Ah, you are spot-on, seem like I did missed the macro, it probably only required for this chip version and will be fixed in future silicon, finding a way to insert the...
update: I have added the enumeration fix, but it still doesn't solve the problem with hub. And it does make sense though, the fix only help rp2040 to exit bus reset state (RP2040-E5), in this case the device already enumerated the hid_test.py can successfully get its config and hid descriptor. It is probably something else, but it is nice to catch the missing enum fix :)
Describe the PR
LOG= forward from make to cmakeHmm, for what it is worth, net_lwip_webserver for the raspberry_pi_pico target works on all PCs (Linux and Windows) that I have locally. (Ubuntu 20.04.1, Linux Mint 19, Linux Mint 17, Windows 7)
Ah thanks for testing it out, indeed, somehow my PC network configure only allow 1 ethernet connection at a time and I have to manual toggle the connection. Work fine when selecting the correct USB conneciton
 exmaple
Describe the PR
add adafruit esp32s2 boards
Describe the PR
update pico-sdk submodules to 1.0.1
This PR:
samd11 as used in other families; modeled after the samd21.luna_d11).luna_d21).Tested on all SAMD11 platforms and on the luna_d21 platform.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
void fill_mic_buffer(int16_t num){
static uint8_t wave_counter = 0;
static int16_t wave_state = 20000;
int16_t *dst = mic_buf;
int16_t *limit = mic_bu...
Have you managed to add support for TIVA C ?, im struggling to port ,the MSP430 example to it. Any help would be greatly appreciated
dcd_msp430x5xx.zip
Thanks.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
ace@ubuntu:~/tinyusb/examples/device/webusb_serial$ make BOARD=stm32f103bluepill all
CC system_stm32f1xx.o
In file included from /home/ace/tinyusb/lib/CMSIS_5/CMSIS/Core/Include/cmsis_compiler.h:54:0,
from /home/ace/tinyusb/lib/...
It looks perfect, thank you very much
I haven't tried to port this to TI Tiva mcu, in fact I haven't even worked with it so far. Though lots of people do, and willing to help you with the port. However, you need to do it in a more collaborating manner by submitting draft PR (zip doesn't help much with discussion). Here is my porting routines, please
board_test example running with led + button, when pressing button, the LED will blink faster...can you check and post your armgcc version here. Anyway, your armgcc is probably too old, try to install with xpacks
npm install --global xpm
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
installation path is either $HOME/.local/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin or ``$HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`
or simply download it from arm
It might still cause issue #377, I haven't tested it this way, I don't have the hardware. However I'm pretty sure that I can feed loads of data into my SAMD21-based device and get 100% reliable transmission.
Thank you for your PR, issue 377 is the only reason 359 got reverted previously. It is necessary to re-test 377 for this PR to be merged. It should be reproducible with SAMD21/SAMD51 or just test with any mcu that you currently have.
All right, I could not make the example run on my hardware and could not be bothered to fix board definitions, so instead I tried the Blue Pill.
I tested a similar setup under macOS, which is my daily OS of choice, and saw no problems other than MIDI Monitor acting ever so slightly sluggish. I used Reason 10, and had a MIDI device within it loop back the data. However, under Windows, the #377 error persists. So I went on and tried by SAMD21 hardware with my original firmware, which ran per...
The devices worked just fine with https://github.com/hathach/tinyusb/pull/359 and they still do. They work with any MIDI monitor/tool or musical software I tried on Windows.
MIDI-OX might just not work correctly. It is unmaintained and the last release is 10 years old. It seems strange to work around this, as it is the only piece of software which appears to have problems.
The simplest tool I could find for Windows is "Pocket MIDI", freely available from the Windows Store, and the examp...
@kaysievers true, Pocket MIDI works alright. I stand by my findings though, there seems to be a certain weirdness about Windows apps when the device isn't listening to data. I tested with Reason 10 for Windows, too.
when the device isn't listening to data
Hmm, do you mean midi_test.ino? There is a MIDI.read(); in the midi_test sketch, and it prints the received MIDI messages.
Nope, the MIDI example from TinyUSB: https://github.com/hathach/tinyusb/blob/master/examples/device/midi_test/src/main.c
It has no reading function, and the overflow drove MIDI-OX crazy. I added lines (see above) that read out the buffer and it works fine.
the MIDI example from TinyUSB
Ah, i see. That makes sense.
and the overflow drove MIDI-OX crazy
It's probably just old-school programming with blocking IO.
read out the buffer and it works fine
That should be added to the test in any case. MIDI devices which do not read incoming messages don't really exist in the real world.
MIDI devices which do not read incoming messages don't really exist in the real world.
Well if this is true then a dummy read function should probably be added to both midi_test and dynamic_configuration examples with a comment explaining its presense. I could make a new PR with these changes, @hathach what do you think?
I can confirm that I had this issue as well, setting bcdUSB to 0x0200 is what I'm doing as well now to get around it. I have an analyzer and will look into this more in depth if I get time to.
if this is true
Old serial MIDI has a fixed speed, and no flow control, conceptually it is just "broadcasting" data in a fixed format. Many devices have only one one-directional port, and communicate only in a single direction.
The fixed speed makes it possible to avoid the concept of flow-control or client tracking. Transmitting devices just assume that the receiver is able to follow the entire stream of data it is interested in. It would usually not even know, if something, or how m...
Thank you @homeodor and @kaysievers for following and testing the PR again. An proper testing with an additional pair of eyes is all this PR needed.
Nope, the MIDI example from TinyUSB: https://github.com/hathach/tinyusb/blob/master/examples/device/midi_test/src/main.c It has no reading function, and the overflow drove MIDI-OX crazy. I added lines (see above) that read out the buffer and it works fine.
Would you also update the PR with the midi read as well, I actually haven't worke...
Would you also update the PR
Maybe you could add something like this to the dummy function as an explanation:
// The MIDI interface always creates input and output port/jack descriptors, regardless
// if both directions are actually used. The device will show up at the host as MIDI IN and
// MIDI OUT. Therefore incoming traffic should be read (possibly just discarded), to
// avoid the sender blocking in IO.
Describe the PR
Release as 0.8.0
All right, I think it's all done!
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
On the pico the callback to fill the transfer buffer are only getting called 200-500 times a second, if I try to up the data size the callback frequency goes down.
When sending data what controls the callback frequency?
Describe the PR
Add ci to mirror sources file only (src/ folder) to https://github.com/hathach/tinyusb_src repo. Source only repo can be helpful for large system integration.
Describe the PR
Add a basic support for RT-Thread RTOS. More about the RT-Thread.
Additional context
None.
unsubscribe
On Sun, 7 Feb, 2021, 8:23 pm tfx2001, notifications@github.com wrote:
Describe the PR
Add a basic support for RT-Thread RTOS. More about the RT-Thread
https://www.rt-thread.io/.Additional context
None.You can view, comment on, or merge this pull request online at:
https://github.com/hathach/tinyusb/pull/637
Commit Summary
- add basic support for rt-thread
File Changes
- M src/osal/osal.h
<h...
PR lack define value for OPT_OS_RTTHREAD. Is it easy enough to add cdc_msc_rtthread example so that we could avoid building issue like this for future changes.
It is my mistake.
I'm a student developer in university, and I am still studying embedded development. Maybe add cdc_msc_rtthread example is a little hard for me. I'm concerned about overlooking support for other MCUs.
In fact, the RT-Thread team already provides a USB Device stack in RT-Thread, but not in RT-Thread Nano (the RTOS kernel of RT-Thread). I hope to provide more options for Chinese developers.
Thank you for your review.
no problem at all if you think adding the example is not trivial, though have you been able to run rt-thread with tinyusb successfully on their studio IDE ?
Describe the PR
This PR mirrors modification from @nekuneko PR https://github.com/adafruit/Adafruit_TinyUSB_ArduinoCore/pull/20 . It add Dpad/Hat and Rx, Ry support for gamepad along with hid_gamepad_report_t and GAMEPAD_BUTTON/HAT enum for using with default gamepad template TUD_HID_REPORT_DESC_GAMEPAD() with following layout
int8_t X, Y, Z, Rz (-127, 127)
int8_t Rx, Ry (-127, 127)
uint8_t hat (1, 8)
uint16_t button (1, 16)
TODO: This...
PS4 Dual Shock Controller hid reporter
Usage Page (Desktop), ; Generic desktop controls (01h)
Usage (Gamepad), ; Gamepad (05h, application collection)
Collection (Application),
Report ID (1),
Usage (X), ; X (30h, dynamic value)
Usage (Y), ; Y (31h, dynamic value)
Usage (Z), ...
XBox one S controller
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x05, // Usage (Game Pad)
0xA1, 0x01, // Collection (Application)
0x85, 0x01, // Report ID (1)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x15, 0x0...
Yes. I have tested it in RT-Thread Studio, I've also tested it in my own CMake project with RT-Thread Nano. They all work fine.
Thanks for the PR, It looks good. There is only a request to suppress unused warning and a bit of code style. Afterwards this should be good for the merge
please add the cast to prevent compiler to throw unused warning
(void) in_isr;
please merge this 2 line together, also needs a space between ##buf and closing }
same as above to avoid unused warning.
Yes. I have tested it in RT-Thread Studio, I've also tested it in my own CMake project with RT-Thread Nano. They all work fine.
That is good enough for this PR
Careful, you will need to change the type name to hid_gamepad_hat_t aswell in the Adafruit_TinyUSB_ArduinoCore library. :3
Yeah, thanks for the reminder, I do plan to sync up the Arduino core with this as well. the bm is for bitmask, since this is not really bitmask, therefore it got should have bm in the name. Though, most people will just probably use the enum value than the type anyway.
look good, thanks for the PR. Will merge when ci complete
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
When changing the channel used by tudi_midi_write24 in the midi_test example code, both MIDI-OX and Ableton Live don't detect anything on the channel. With channel 1, things work perfectly fine.

Unfortunately the "class driver", i.e. the webusb example's main function, intereprets this as a "class" request with bRequest==1 (i.e. V...
can you enable the LOG=2, hook FTDI to GPIO0,1 and paste your log her. The driver works just fine with other mcus therefore it can be a bit more troublesome than mis-representing the request I guess. Though to be honest, I haven't got time to worked on this again.
I cloned the repo and built the midi_test example with the changed channel, and I'm still getting the same issue. Just thought I'd give an update before I figure out how to get the log working.
Hey there, Ha,
You're right that the driver working fine on other mcus suggests that the bug is deeper. On the other hand, it's possible that other MCUs ignore a spurious status report, whereas the RP2040 is programmed to panic.
In any case, I did what you requested. The stack trace of the panic is
(gdb) bt
#0 _exit (status=status@entry=1) at /home/pi/sdk2/src/rp2_common/pico_runtime/runtime.c:164
#1 0x10001a28 in panic (fmt=0x100088f0 "ep %d %s was already available")
...
I worked up this patch:
https://github.com/ipopov/tinyusb/commit/fd8add72e83a7df67dbaae9ec00a8a5eedfe26a3
which shows what I mean, and has allowed me to run the WebUSB Serial demo. However, sadly, it is based off of e0aa405d19e35dbf58cf502b8106455c1a3c2a5c, which is the original "RP2040 Support" commit, shipped with the Pico SDK; and that is based on a TinyUSB fork from November 2020.
I'm not really set up currently to build TinyUSB at head, sadly; so I cannot test whether the fix work...
Describe the PR
This is a simple fix for the rp2040 device that prevents drives that open and close an ep (ie. audio device) from reallocating the buffer in the DPRAM and running out of space and failing the assert.
This should close:
#628
raspberrypi/pico-sdk/issues/85
Additional context
If applicable, add any other context about the PR and/or screenshots here.
I started to integrate/use tinyusb into my STM32 project but noticed that there was no double buffering support. This might not be a deal breaker, but common sense would say that performance would be impacted significantly due to lack of double buffering support and my requirement is to be able to saturate most of the available bandwidth of the bus while keeping microcontroller utilization very low.
For now, I am going to switch to this stack https://github.com/xtoolbox/TeenyUSB which I...
Please add specific family mcu to the issue title stm32 f4, h7 etc since stm32 has 2 usb controllers.
Hmm, I was under the impression from looking at the source code that tinyusb stack in general isn't structured in a way to facilitate double buffering (except on one mcu family that has it built into hardware or something like that, I don't remember).
I was under the impression from looking at the source code that tinyusb stack in general isn't structured in a way to facilitate double buffering
Same. I was under the impression that tinyusb single buffers by design to keep the packet-handling, well, tiny :).
When I wrote the MSP430 backend, I explicitly used single buffering even tho the hardware supports double. I've not run int...
I guess my question is -- do you mean you want to add f4 or h7, etc. to the title so that double buffering support is worked on for one specific mcu? I was thinking the feature request would be to bring double buffering support as a whole to tinyusb to any/all mcus that support it.
ah, I see, I thought you want to implement the hardware double buffering for some of the STM32 MCU, look like you want to have USBD-level double buffering. So far there isn't a need to do so, and we don't real...
OK sounds good ๐
Also, one of the other things I noticed is that for full speed bulk, it sets the max packet size to 64 and seems to mandate the use of that value; however, in my case I send 44 byte packets since one frame of data for me is 44 bytes. When I send 44 bytes on a 64 MPS endpoint, the host USB on the other end doesn't ask for more data in a timely manner because it says "oh look you didn't even use your max allotted packet size so I guess I can stop bothering you for a bit" ...
This ensures that the Pico SDK, too, is built in debug mode and with nice debugging symbols. (Otherwise, it's built by default in Release mode.)
I guess that rules.mk is not the most elegant place to plop this conditional... I'd love any suggestions for a better way to do it. :-)
As discussed in https://github.com/hathach/tinyusb/issues/609,
The problem is that when receiving a "standard" CLEAR_FEATURE request, usbd.c calls into the class driver:
https://github.com/hathach/tinyusb/blob/a96ee8f1d850bbd645040e0f5d133e6c1c93a3a4/src/device/usbd.c#L757. (The comment there says that the class must not call tud_control_status.)
Unfortunately the "class driver", i.e. the webusb example's main function, intereprets this as a "class" request with bRequest==1 (i.e. V...
I managed to get TinyUSB at head building, and put together a proper pull request: https://github.com/hathach/tinyusb/pull/645. PTAL! :-)
Looks like a plausible fix to me. I think the audio example may be the first one that repeatedly opens and closes an ep which is why we didn't see this?
Looks like the indentation needs fixing?
dcd_edpt_xfer() supports a transaction from 0 up to 65535. If you want to transfer 44 bytes at one transaction, you can specify 44 in dcd_edpt_xfer(). If you want to change the max packet size, you can change it with USB descriptor epsize.
I think that packet-level double buffering is the job of DCD, not USBD. [The KL25Z implementation](https://github.com/hathach/tinyusb/blob/master/src/por...
The specs only allow Bulk for FS to be 8, 16, 32 and 64. Unfortunately 44 is out of supported values. Look like I need to make an PR to relax the constraint for bulk.

@kkitayam thanks, I feel the same way as well, since most recent MCU all support DMA, the double buffering is mainly meant for raw bandwidth usage of the hardware. On software side, FIFO (byte copy or DMA) can be added according to the need of the class driver e.g cdc use normal fifo, audio will make use of DMA FIFO. Though, I am still open to discussion and all PRs.
It looks great, I don't have any better place to suggest.
I agree. @ndinsmore can you fix the indentation and match the brace style of the rest of the file please. ie.
if(!(ep->configured))
{
_hw_endpoint_alloc(ep);
}
This looks good, but there is a larger issue here that we don't implement dcd_edpt_close. However, in this instance I feel that closing and opening the endpoint all the time is inefficient so this fix is good enough. Longer term I will raise an issue to implement dcd_edpt_close
Thank you for your log, it is very useful. It is indeed issue between how usbd and class driver agree up on. This seems to be added after webusb is already written and on other mcu, the duplicate ZLP has no effect or overwrite by the next setup packet. Therefore it doesn't bring up any attention to fix. Hmm, I think usbd should detect if tud_control_status() is invoked rather than trusting class driver for not calling it, especially it is vendor in user space.
The #645 is spot-on, I am pro...
all switch should have default, please add one with return false;
Thank you very much for the PR, this is spot-on. I am too lazy to check for the request vendor type. There is only a couple of style feedback
default: return false; to the switch(bRequest){ in the same line with new code, however, you should not reformat the existing style.Interesting, so 44 is technically not a supported value by the official USB spec -- glad Windows happily allows it though :) -- I'll have to test my application on other OSes more thoroughly since I intend on continuing to use 44 for my application. I think it's sort of a silly constraint especially when you consider how the USB protocol works (don't call us, we'll call you).
Thank you for the kind comments! It's a wonderful codebase, I had a great time this weekend getting to know it. I hope I can be of assistance in the future as well.
I've uploaded a new commit addressing your comments.
Thank you very much for your PR. I am appreciate that you have spent time to troubleshoot this issue.
not enirely with braket, but this is OK
Thank you for the kind comments! It's a wonderful codebase, I had a great time this weekend getting to know it. I hope I can be of assistance in the future as well.
I've uploaded a new commit addressing your comments.
Thank you very much for willing to help, I am looking forward to your future PRs. Feel free to submit any issues/pr/discussion.
Describe the PR
usbd should detect if tud_control_status() is invoked rather than trusting class driver for not calling it, especially it is vendor class in user space. This PRs use usbd_edpt_busy() to check if tud_control_status() is called by class driver and skip duplicate the action.
more context
The problem is that when receiving a "standard" CLEAR_FEATURE request, usbd.c calls into the class driver:
https://github.com/hathach/tinyusb/blob/a96ee8f1d850bbd645040e0f5d13...
Describe the PR
from USB 2.0
@MimitechIndustries it is up to you to decide if it is worth the compatible should future OS enforce such as check. I have correct the bulk size check for FS endpoint but also leave it open for you by not enforce the 8,16,32,64 check since most people will go to 64 anyway. Should you have any further information regarding the bulk ep size please open an discussion or issue, we should keep this issue focused on "double buffering", thanks.
https://github.com/hathach/tinyusb/pull/647
closed by either #645 or #646 . Thank you @ipopov for troubleshooting the issue.
Describe the PR
rename dfu_rt to dfu_runtime for easy reading/understanding.
Just tested it from master branch on Elementary OS and it worked great. Thanks for looking into this @ipopov , and @hathach for your quick response!
This looks good, but there is a larger issue here that we don't implement dcd_edpt_close. However, in this instance I feel that closing and opening the endpoint all the time is inefficient so this fix is good enough. Longer term I will raise an issue to implement dcd_edpt_close
Thanks for reviewing, feel free to merge it when you think it is ready.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
I'm trying to use the tinyusb on my own stm32h743 board, before using this lib, I already success to use the usb cdc provided by cubemx. When I'm using the tinyusb, it just has no reponse after running tusb_init(), the jlink also lost connection
`void basicInit...
Here's what I got from the log:
USBD Xfer Complete on EP 81 with 4 bytes
MIDI xfer callback
Queue EP 81 with 4 bytes ... OK
USBD Xfer Complete on EP 81 with 4 bytes
MIDI xfer callback
Queue EP 81 with 4 bytes ... OK
USBD Xfer Complete on EP 81 with 4 bytes
MIDI xfer callback
Queue EP 81 with 4 bytes ... OK
USBD Xfer Complete on EP 81 with 4 bytes
MIDI xfer callback
Queue EP 81 with 4 bytes ... OK
And then it kept repeating.
Sounds good, thank you very much.
Every time the host collected or sent data an interrupt triggers a callback function within the audio driver in which a new transmit for receive or transmit is scheduled.
There is a new design for the audio driver on its rollout, completely redesigning how data is copied. However, i can not say when the PR is finished.
I did a complete redesign of the data handling part of the audio driver. It is decluttered now, meaning unnecessary stuff was removed and very important, the naming convection was changed such that it is easier to understand the driver structure. This way the users should understand the driver faster. I updated the examples to meet the new naming scheme.
What is missing is the implementation of dcd_edpt_iso_xfer() function for all dcd's other than STM32.
@hathach There are some CI tes...
Windows is usually very strict about USB compliance (compared to Linux and MacOS). If you want to see if your out-of-spec device works, I'd recommend trying it there.
Is your feature request related to a problem? Please describe.
For some scenario, user prefer to run entire stack in ISR in low priority mode. At current state, it may be not safe due to osal mutex/queue api that can lead to dead lock depending on the rtos, usage.
Soluion: implement a safe tud_task_isr() api
@PanRe I am on holiday, will check it out when possible.
I can't find any docs to use it with ardinuo, also the examples are not clear.
I just want to make a keyboard using the ESP32-s2 using the usb, but there is not an example so i can base my work on it.
Please help me out.
Also if it possible to simulate or do mouse and keyboard with one ESP32-S2? i can do it using the HID-Project with pro micro.
Hi, would you mind trying it again with latest from master branch. There is a recent pr that may fix this issue #646
Hi, I just tried it again with the latest master branch. commit 09868434cd9f53394350cce682333ada97f796c3.
It still does not work, but now it seems that the asserts are enabled.
USBD Setup Received 80 06 01 03 03 04 05 00
Get Descriptor String[1]
Queue EP 80 with 5 bytes ... OK
USBD Xfer Complete on EP 80 with 5 bytes
Queue EP 00 with 0 bytes ... OK
USBD Xfer Complete on EP 00 with 0 bytes
USBD Setup Received 80 06 01 03 03 04 05 00
Get Descriptor String[1]
Que...
Ah i figured it out. At some point the tud_vendor_control_xfer_cb has been updated to also be called when the transfer is completed.
It works properly now after adding this to the callback.
// nothing to with DATA & ACK stage
if(stage != CONTROL_STAGE_SETUP)
return true;
No worries! Enjoy your holidays! :)--Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 13.02.21, 11:33 schrieb Ha Thach notifications@github.com:
@PanRe I am on holiday, will check it out when possible.
โYou are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
Adds configuration option CFG_TUSB_ALT_BIT_PACKING_ALIGNMENT, which substitutes bitfield variable " : 0" padding syntax with an unused variable of size equal to the remaining number of bits.
This change is intended to resolve aligned access issues for some platforms.
The default behaviour is original if the option is not explicitly enabled. Consequently, this change should not affect existing applications.
Describe the PR
The basics are as follows: (non_used_index_space + max_pointer_idx) should equal UINT16_MAX so that when you add anything to those values it rolls over.
Additional context
This will likely fix a bunch of difficult problems which have been itermitent.
superb !! Thank you, I have overlooked this when merging. osal_pico is probably under development in parallel with the fifo rework
thank you for your PR, would you mind telling me what is your platform you are working. unnamed zero size is pretty much std padding in C language.
I am working on the XCore platform.
Unnamed zero size is indeed standard; However, I found that the compiler for XCore currently will cause a hardware exception when trying to access a bitfield under certain alignment conditions.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
Make fails to find the source files when fired from cygwin terminal.
CC board.o
arm-none-eabi-gcc.exe: error: /%localdir%/tinyusb/hw/bsp/board.c: No such file or directory
To reproduce
Steps to reproduce the behavior:
Describe the PR
The RP2040 spec allows full-sized isochronous buffers, this enables it.
Additional context
The rp2040 spec limits none ISO buffers to 64 bits.
Hi @hathach what development environment would you suggest if I wish to contribute to this project? I am currently using a Windows 10 PC, with make installed on cygwin terminal. Would you prefer me to build this project on a unix machine?
As for the STM32F4 which has a hardware USB FIFO, there is not double buffering possible. Once the hardware FIFO was loaded and scheduled for transmit or receive, hardware buffer is locked and you can not load any more into it. IMHO double buffering is only necessary if you need linear buffers e.g. for signal processing etc. In any other case i would suggest a ring buffer like the tu_fifo, this buffer is also capable of being loaded/read from by DMA. Some functions supporting this are not mer...
I assume that your C:\Users\Pranjal\Documents\... etc isn't reachable from cygwin's root (/, /home, /bin, /etc). To access C:\Users\Pranjal\Documents\... from cygwin, you need to use /cygdrive/c/Users/Pranjal/, not /c/Users/Pranjal/. I'm not sure the best way to put that into the Makefile.
Thanks for the suggestion but unfortunately, the path you mentioned i.e. /cygdrive/c/Users/Pranjal/ , was causing trouble initially, so I aliased it to /c/Users/Pranjal. You're right that these are not the best paths to put into Makefile, I figured out the issue to be the $(TOP) in the top.mk. (The other makefiles that work use relative paths). Currently, I am able to build it under /home but was hoping if there could be a better solution.
Thanks
Although I don't use windows, I guess WSL probably works better than cygwin.
Thanks for the suggestion @hathach ! Can you tell me a preferred development environment if I wish to contribute to the stack? Shall I use Linux and ditch windows?
you should use any environment you feel comfortable with. It is not too important at all.
Thanks for the PR, actually, the bitfield size = 0 is due to my laziness. Since you already counted the unused size, there is no need to introduce the new macro CFG_TUSB_ALT_BIT_PACKING_ALIGNMENT, we should just always use it which is more explicit (therefore more portable). Would you mind updating the PR accordingly.
PS: also it is better to use the TU_RESERVED instead of unused, it expands to unique token name. But it is optional.
Alright. Thanks. One more question @hathach , a little unrelated to this topic. Is it absolutely necessary to use the vendor provided drivers as a BSP if I m porting it to a new MCU?
using min function would make it easier to read
ep->transfer_size = tu_min32(total_len, ep->wMaxPacketSize);
I think this else{} could be merged to the above if() as well if 64 stands for ep size of non-iso here. Unless there is something I don't know of. @liamfraser may shed some light on this.
Look good to me, though I prefer to merge if() else{} with simple min function against ep max size. Let wait for more feedback from RPI team.
like above these line can be simply be
ep->transfer_size = tu_min32(total_len, ep->wMaxPacketSize);
Alright. Thanks. One more question @hathach , a little unrelated to this topic. Is it absolutely necessary to use the vendor provided drivers as a BSP if I m porting it to a new MCU?
You could use any board you have, I tend to go for common/popular one since that is easier for people to get and test.
@PanRe I am on holiday, will check it out when possible.
I was able to fix all but one error, i just don't know how. In case an OS is used, the compiler complains that osal_mutex_t is undefined. Do you know how to fix this? Thanks in advance :)
Similar to the usage of #ifdef UART_DEV and #ifdef BUTTON_BOOTSEL in the same file.
If you are okay with using a non-Cygwin system, examples can be built with msys2 or windows command prompt. I had confirmed at #590
I guess that arm gcc for windows was built with msys2. If gcc was built with cygwin, examples could be built by the gcc on cygwin.
I found the same issue on stackoverflow.
It said that arm gcc for windows does not support with cygwin make.
I suggest msys2 or command prompt for windows users, because WSL2 does not yet support USB devices. WSL2 can build samples, but it cannot flash them via J-Link. Docker for windows does the same.
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
Building tinyusb with mynewt will trig the following warning message:
* Warning: Multiple packages with same pkg.name=tinyusb in repo tinyusb; path1=/cionic-newt-dev/repos/tinyusb/hw/mcu/raspberrypi/pico-sdk/lib/tinyusb path2=/cionic-newt-dev/repos/tinyusb
The issue is coming from pi...
yeah, I notice the issue as well. It is getting a bit complicated since pico-sdk include tinyusb as submodule, and tinyusb also include pico-sdk for building its example. It cross-includes, I don't understand the newt build system to have a sound suggestion. For a walkaround, you could just remove the repos/tinyusb/hw/mcu/raspberrypi/pico-sdk/lib/tinyusb as my newt example ci https://github.com/hathach/mynewt-tinyusb-example/blob/master/.github/workflows/build.yml#L48
thanks for the PR, look great.
@IrisMakes As far as I can tell, the first argument to tudi_midi_write24 is not the MIDI channel but the jack_id. I managed to get the example to run on different channels by setting the low nibble of the second argument like this
// Send Note On for current position at full velocity (127) on channel [CHANNEL].
tudi_midi_write24(0, 0x9[CHANNEL], note_sequence[note_pos], 127);
right the first byte is cable number or jack id, the API name does have a typo somehow, I will update it maybe rename the write24() to write32() as well since 24 is a bit misleading.

Describe the PR
update: PR is coming https://github.com/hathach/tinyusb/pull/660 , please try to modify the channel variable to see if that work for you.
look great, thank you for your PR.
would you mind removing this comment line.
Describe the PR
Enhance fifo to prevent future issue that need fixes such as #536 #655 which is very easy to overlook.
@PanRe thank you for the update, there has been quite a bit of pending issues for paid works after the holiday. I will look at this PR in the weekend since I would expect it needs bit of time for a proper review.
Is your feature request related to a problem? Please describe.
LDREX/STREX instructions are available on ARM cortex M3/M4/M7 which can be used for mutex without the need to disable/enable interrupt.
Reference https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/562#issuecomment-681583256
implemented by #379 :smiley:
Yeah I tried to get it working with mynewt without removing repos/tinyusb/hw/mcu/raspberrypi/pico-sdk/lib/tinyusb, but so far I failed. Anyway, if I find way to avoid this issue, I'd PRd it.
Thanks
thanks for updating, things getting a bit complicated since projects now depends on each other, making recursively submodule clone is out of control. Actually, tinyusb doesn't need any of the submodule, those are mainly for example building and testing. If you know newt have any flags to add to repsitory.yml for that, I will be happy to make changes.
Yeah, maybe examples should sit in a different repo in order to keep the USB stack clean.
There is an src only, read only mirror here for those who need https://github.com/hathach/tinyusb_src
Maintaining an extra examples repo and keeping then in sync is too much work for me at the moment. Other project doesn't need to clone any of the submodules.
@jocelynmass when porting an mcu to mynewt, if there are external dependencies these should be excluded.
Either by deleting them or setting the corresponding mcu pkg.yml via pkg.ign_files or pkg.ign_dirs.
Thanks @mlaz, good to know.
The ep size can actually be smaller for example interrupt ep can have max packet size of 8 or 16. Will we use the actual mps (8) here or 64 still is correct ? If 8 is needed then we should change it to wMaxPacketSize (like iso) instead of fixed 64.
I think we should use wMaxPacketSize everywhere. I think that's what my "// FIXME: What if low speed" was meant for but I never got round to fixing it. I would like there to be a check that wMaxPacketSize is in a valid range for RP2040 somewhere though.
Yeah, that is what I think as well. Will update pr accordingly. usbd already perform the endpoint size check already before passing it to dcd open, so I guess it is rather OK afterwards. https://github.com/hathach/tinyusb/blob/1bba2c0fc3bce05e9fbe4ff23dda30283d08574d/src/device/usbd.c#L1111
Ah. I think I need to swap dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET) with dcd_event_bus_reset(0, TUSB_SPEED_FULL). We don't actually report our speed anywhere. I think the API might have changed since I did the original port.
Thanks for this @kkitayam . It helped! I tried building it on WSL as suggested by @hathach , it seems to build. But I haven't tried flashing it using J-Link or OpenOCD + ICDI yet. Although I'm able to get that done using cygwin, I can try accessing the same project from WSL & Cygwin for both the things as a ad-hoc solution for now.
As far as command prompt is concerned, I tried installing make using choco pack manager, but the results were similar to that of cygwin. Can you please sugge...
Pulling in the latest
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.
I don't know if a FIFO is the right path for ISO, It seems like a double buffer type might actually be more suitable. When you read the specs for UAC2 and USB 2 there is a lot of talk about when data should be ready, and when processing can start on that data. If we could lock the processing loop to the start of frame, a double buffer would be perfect for that.
I don't know if a FIFO is the right path for ISO, It seems like a double buffer type might actually be more suitable. When you read the specs for UAC2 and USB 2 there is a lot of talk about when data should be ready, and when processing can start on that data. If we could lock the processing loop to the start of frame, a double buffer would be perfect for that.
At a first glance you may be right but the devil is in the details! The FIFO has two distinct advantages over a double b...
As far as command prompt is concerned, I tried installing make using choco pack manager, but the results were similar to that of cygwin.
I guess that your PATH environment variable has C:\cygwin64\bin for cygwin. The path for cygwin causes failure.
make for windows treats SHELL environment variable as special. Please refer to Choosing-the-Shell
To avoid the issue, would you specify SHELL=cmd.exe on argu...
After unplug USB cable from PC i am getting this:
20:34:02.400 -> device unmounted
20:34:02.433 -> device unmounted
20:34:02.466 -> device unmounted
20:34:02.466 -> device unmounted
20:34:02.499 -> device unmounted
20:34:02.499 -> device unmounted
20:34:02.533 -> device unmounted
20:34:02.566 -> device unmounted
20:34:02.566 -> device unmounted
20:34:02.599 -> device unmounted
...
20:34:06.108 -> device unmounted
20:34:06.108 -> device unmounted
20:34:06.207 -> device unmou...
Is there any way, I can help with this issue?
Yea, I'm a month late.
I agree this is the best approach for now, but I'd love to eventually see if a "generic" driver is possible. Or at least whether there are "common" parts that are unlikely to change that can be factored out (or parts that change the same way for all chips using Synopsys IP as tinyusb evolves) .
Its probably user fault. After setting flag on unmount which is returning false in tud_msc_test_unit_ready_cb it looks much better.
Thank You so much @kkitayam ! You're right! Specifying the shell explicitly does solve the problem! Thanks for the help! :)
Describe the PR
Porting the stack to support Tiva-C (ek-tm4c123gxl) board. Will be adding the relevant relevant drivers soon,
Additional context
TI doesn't provide a driver layer compliant to the CMSIS register definitions. Next steps are to add the CMSIS provided system_init (clock_init) and port the vendor provided drivers to support CMSIS register definitions.
Hello,
I'm unable to see the files that I committed in hw/mcu/ti/ , am I missing something?
Looks good now! Thanks for the help!

Look great to me. Thank you for your PR.
@diggit yeah, if you are willing to make a PR for this, I will be very happy to merge the it.
@cr1901 yeah, you are right, maybe we could extract the hanlding/processing function such as transfer into common function shared by these dcd rather than merging them all together. I will re-open this and will look at this later on.
Thank you for having a go at this. I have been struggling with it.
@chegewara no it is not, it should only be invoked once, which tinyusb stack you are testing with. Please make sure you run with this repo master. esp32s2 port currently doesn't seem to detect disconnection probably. From what I see, your version use Suspended for disconnected.
somewhat similar https://github.com/hathach/tinyusb/issues/564
@pran005 hw/mcu/ti is a submodule, you need to make an PR to its repo separated https://github.com/hathach/ti_driver , then git commit the tinyusb to update the submodule. Sorry for being more complicated than it should be. If that is too much of hassle, just zip the tiva-c and upload it here, I will push it to the ti_driver and update the tinyusb.
Thanks, i will try to check with this repo. The iisue i have with my library on arduino esp32, which seems to be very far from original. Also it is version before 0.8.0 (with broken return value from tinyusb_init).
I am not familiar with TI MCU, but a quick glance at it, Tiva C is marketing term, I think we could just use tm4c as the name of the dcd and hcd. and both tm4c123x and tm4c129x share the same USB controlleer, therefore please rename the
TM4C_Tiva-C/dcd_TM4C_Tiva-C.c to `tm4c/dcd_tm4c.c'TM4C_Tiva-C/hcd_tm4c123.c to `tm4c/hcd_tm4c.c'I am open to any discussion on the naming,
Yeah, it changes recently to dynamically support FS/HS. It is mostly for HS capable device to work properly with attached to let's say PICO FS host. Fullspeed device as default should have no issue, don't worry about low speed mode. It is virtually non-existent, no body is interested in it :smile: .
update the PR to min check against remaining and ep size. I did accidentally merge from latest master and have to do the trick to change-rechange base for github to update the file difference. All good now, PR will be merged when ci complete. Thank you very much for the fix.
@hathach Appreciated, especially since I was a month late to actually say anything :D!
no problem at all, I mostly file issue whenever idea come up as reminder anyway :)
@hathach I am okay with creating a PR at https://github.com/hathach/ti_driver , although I'll need to figure out how shall I update the submodule in the tinyusb repo.
Regarding naming, yes you're right Tiva-C is a marketing name, but I'd suggest creating to separate families of devices : tm4c123xx & tm4c129xx, the reason being there are some changes in both the silicon, including register definitions. Also some parts under tm4c129xx family have USB chapters of their reference manuals un...
Describe the PR
Pass the correct speed after a bus reset on Spresense.
thanks for the PR, it looks good.
@hathach I am okay with creating a PR at https://github.com/hathach/ti_driver , although I'll need to figure out how shall I update the submodule in the tinyusb repo.
Once the PR to submodule is merged, you just simply pull the submodule, then git add in the tinyusb repo, it will get updated to the latest commit like you did with normal file.
Regarding naming, yes you're right Tiva-C is a marketing name, but I'd suggest creating to separate families of devices : tm4c123xx & tm4c129x...
@hathach Yes the mention is weird. Also, their datasheets contain the register interface and bit definitions as well. There are no register definitions available in the open version : https://www.ti.com/lit/ds/symlink/tm4c129encpdt.pdf?ts=1613987608999&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTM4C129ENCPDT .
I think if the #if macro is fine, then we can name it tm4c* for now, and add the device specific implementation later. I'll get started on this.
I agree with you about the asynchronous processes, and I think that remaining portion of sampling should be handled at the device class level, so that the library user needs to be aware but not necessarily work about it, which a fifo would do.
This issue was a bug caused by the pico dcd fifo implementation, and a buffer overrun. It can now be closed.
The rp2040 driver maintains a ginormous (technical term) RAM array of struct to track endpoints, and the author liked to use a proprietary-to-rp2040 type called โuintโ that translates to a uint32_t.
Since TinyUSBโs dcd_edpt_xfer() only transfers in sizes of uint16_t, there is no reason to store FOUR variables of size uint32_t in the struct (of which there are 32 total in the array) when 16-bit more than suffices.
Fixing this yields 4 x 2 x 32 = 256 bytes, which may not matter to everyon...
look good, thank you for PR, change target branch to the host_msc since I am working on it for testing the host msc
F469 F749 has the "Bit 14 XCVRDLY", but others not have in OTG_HS_DCFG.
Can you share other solution?
Please go ahead. Since PR is not ready for merging yet. I will convert it to draft, feel free to mark it to ready when you think it is OK
Yeah, I use dark theme as well and have no idea how or which format to make it appeared nicely on both light and dark theme.
Here is a quick substitute image. The background of the original png is transparent. I made it white and added 10 pixels all around, because it was cropped very tightly.

@dhalbert, looks good. Make a PR
In lieu of adding TUD_OPT_RP2040_USB_MAX_ENDPOINTS, I unearthed an existing macro USB_MAX_ENDPOINTS in the bowels of pico-sdk that was supposed "to save RAN"... so let's actually put it to use.
Describe the PR
The rp2040 driver currently has 32 instances of three bytes (bool in, uint8_t num, uint8_t ep_addr), each of which collectively stores only one byte of information.
TinyUSB already has functions (tu_edpt_number() and tu_edpt_dir()) that perform the function of the โnumโ and โinโ above, and other device drivers use these.
Bringing the rp2040 into line with established TU code conventions improves readability, reduces overall code size, and saves on RAM usage.
Presently, there is assorted host-only rp2040 code that gets compiled into device-only operation. (Host and device modes are mutually exclusive.) Making this host-only code conditional at compile time saves code and data space.
This PR alone is good for 272 fewer bytes of code and 128 bytes less data RAM consumed.
@hathach , I have created a PR to your ti_driver repo, to add the necessary supporting files for tm4c123xx family of devices. Once that gets merged. I expect the build shall go through fine.
I have created a two channel USB audio microphone application. I have set CFG_TUD_AUDIO_N_CHANNELS_TX to two, but I needed to modify the referenced line to set _nchannelsphysical to CFG_TUD_AUDIO_N_CHANNELS_TX rather than to 0x01.
I am wondering if I should not have used TUD_AUDIO_MIC_DESCRIPTOR in my application, but rather created my own similar macro to define exactly the descripto...
@hathach , I have created a PR to your ti_driver repo, to add the necessary supporting files for tm4c123xx family of devices. Once that gets merged. I expect the build shall go through fine.
It is merged already
Regarding it being ready, when can I say it is ready? When I've added the relevant USB Drivers or when the bare minimal builds pass?
When some of the examples is working as proof of concept, especially the cdc_msc example. Once it is running, it is ready for merging, an...
Describe the PR
Follow up to #524, this PR remove backward-compatible single ITF callback when CFG_TUD_HID=1. This makes it clearer for user to notice that stack support multiple instance of HID interfaces and simplify the #ifelse in application should it choose to enable multiple HID. Following API signature is changed and required updated in application.
would you mind trying this again. There has been lots of improvement for msc driver for the last year.
This is probably caused by cdc not sending zlp when last packet is 64 bytes. Would you mind testing this again ?
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
The CDC device calls read to read the data sent by the host. The data read is not the latest, but the data of the previous frame.
please describe it more in step process, and how you test it. It doesn't sound like issue to me, all data is put to fifo and retrieved in that order.
USBD init
CDC init
dcd_int
dcd_connect
dcd_int_enable
USBD Bus Reset
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with zlp Status
USBD Bus Reset
USBD Setup Received 00 05 2D 00 00 00 00 00
Set Address
dcd_set_address 45
USBD Xfer Complete on EP 80 with 0 bytes
USBD Setup Received 80 06 00 01 00 00 12 00
Get Descriptor Device
Queue EP 80 with 18 bytes
U...
I donโt understand what is your point. Please be concise why you think cdc misbehave. Also what is your mcu ?
I unfortunately do not have a STM32F4 Discovery board to test with anymore- I accidentally fried it in late 2019/early 2020 :P!
@hathach I need your help in one place, 2 FreeRTOS based builds are failing because of the following:
/home/runner/work/tinyusb/tinyusb/lib/FreeRTOS/FreeRTOS/Source/include/portable.h:52:11: fatal error: portmacro.h: No such file or directory
52 | #include "portmacro.h"
Can you please help me understand what's the dependency I'm missing?
Also, please tell me what flash tool shall I use, I have used OpenOCD to flash this board. How shall I be integrating it?
Thanks
Describe the PR
Fix usb setup flag which sometimes caused DTR bit detection problem.
Hey guys do you think this Li-Po charger would provide power to an ESP32 Breakout simultaneously while charging?
https://learn.adafruit.com/adafruit-microlipo-and-minilipo-battery-chargers?view=all
if you want to detect status packet with this logic, it can mis-inteprete other event. For example when receiving 64 bytes of a descriptor, to end the data transfer, ZLP is sent in the DATA state on the IN endpoint. Afterwards there is another ZLP on OUT endpoint for status.
There is a better way to catch status, it is an optional callback dcd_edpt0_status_complete() which is added later after your port. The usbd will call this function right after status phase is complete (full transferred). You could use this to pull setup packet without the need of usbdcd_driver.setup_processed)
https://github.com/hathach/tinyusb/blob/master/src/device/dcd.h#L124
@hathach I merged it. I hope that's not a problem.
Not a problem at all, you understand the dcd much better than me. Though looking through the chance, I think there is probably a better approach with dcd_edpt0_status_complete() some dcd make use of this for changing address after status complete and prepare the next setup https://github.com/hathach/tinyusb/blob/master/src/portable/microchip/samd/dcd_samd.c#L187, some doesn't need it therefore it is optional.
PS: There is another br...
F446 definitely has this bit. It was quite recent addition at that time. Try updating ref. manuals, headers and SVD files. ULPI has much more configs, but ST does not document it. I do not guarantee that it's there, but AFAIK this issue is present on all F2, F4 and maybe F7 MCUs.
I am not aware of any other solution.
Thanks for your comments! This is very useful feedback. I'll try to use dcd_edpt0_status_complete() instead of usbdcd_driver.setup_processed.
Update : The board test seems to work fine now, the LED blinks at nearly 250ms by default, after pressing down SW1 on the board, the blinking rate slows down to 1s.

Additionally, the board prints out the hello statement through the Stellaris VCP (no additional circuitry required, it gets enumerated on connecting the on-board debugger to the PC).
 -> call cdcd_xfer_cb() -> in call cdcd_xfer_cb(), first copy data from epout_buf to rx_ff, but now in epout_buf there not have latest data, only after use _prep_out_transaction() epout_buf have the latest data. this make a problem, when I use read() to read FIFO, I always get the data of the previous frame instead of the latest one. this is my question, is there something wrong with my understanding of the cdc out data process๏ผmy mcu is our co...
bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
{
(void) result;
uint8_t itf;
cdcd_interface_t* p_cdc;
// Received new data
if ( ep_addr == p_cdc->ep_out )
{
// TODO search for wanted char first for better performance
for(uint32_t i=0; i<xferred_bytes; i++)
{
tu_fifo_write(&p_cdc->rx_ff, &p_cdc->epout_buf[i]); // write data from epout_buf to rx_ff
}
// invoke receive callback (if ther...
Sorry, I found out. It's my problem
@pran005 that looks great, board_test is also my first example I would run to make sure the clock is setup up correctly as well. Look like you are all set for dcd port. Don't worry about the flash target if it is too much of trouble, I will do it later. It is just a convenient way to flash the board, just use what you normally use (ide/gui) for now.
@hathach That's what I'm confused about, I use OpenOCD from the command line, the only difference is I need to open a gdb server, from a different terminal, and issue commands manually from the new terminal to actually flash the device. How can I accommodate such a thing from board.mk ?
You can use openocd as standalone flash without gdb http://openocd.org/doc/html/Flash-Commands.html . like the nuvoton mcu https://github.com/hathach/tinyusb/blob/master/hw/bsp/nutiny_nuc121s/board.mk#L55
I unfortunately do not have a STM32F4 Discovery board to test with anymore- I accidentally fried it in late 2019/early 2020 :P!
no problems at all, I will pull out the board to test with later on.
thanks @chegewara, maybe enable the LOG=2 would give some inside info and/or using either software/hardware usb analyzer to capture which data is transferred on the bus would help as well. I don't do much of pyqt to be helpful here.
total_len can actually be > 64KB in case of MSC, I intended to change the dcd_edpt_xfer() total_bytes from uint16_t to uint32_t however, the work is a bit overwhelming to change all the dcd for now.
I am fine with the PR, though I think the total_len should still be uint32_t (uint16_t is kind of my mistake in the dcd API). The max packet size is only up to 1024 (therefore uint16_t), though it may be stil be uint for compatible with RPi's own usb stack. I will leave this to @liamfraser to decide.
although this is correct, this structure is also used by another usb stack (one implemented the BOOTROM). TinyUSB is not the only stack that work with rp2040 mcu, therefore it still would be uint for compatible. I am fine with this though.
All looks good to me. This code is all TinyUSB specific. The bootrom uses its own USB device implementation that was written before our TinyUSB port.
Found few legacy apps on windows which try to send break requests and terminate the connection if request fails.
Meanwhile I have made a change in cdc_device.c to support CDC_REQUEST_SEND_BREAK by adding a new case as show in code snippet.
case CDC_REQUEST_SEND_BREAK:
if (stage == CONTROL_STAGE_SETUP)
{
tud_control_status(rhport, request);
}
else if (stage == CONTROL_STAGE_ACK)
{
TU_LOG2(" Send Break\r\n");
if ( tud_cdc_send_break_cb ) tud_cdc...
Can you name those legacy apps, and how to reproduce the request.
I have setup an rpi pico to behave as USB to UART bridge using CDC. This works perfectly fine in almost all scenarios.
I encountered the behaviour when I tried to flash a firmware using qflash on a quectel modem.
The tool works absolutely fine with ftdi, silabs, prolific etc.
Although the modem needs just the rx and tx uart lines, qflash blindly expects the break request to be acknowledged else it chooses c...
thanks for the context, I am ok with adding more callback, but I would also like to take the chance to understand what the request does as well. I am currently working on other works, will pull out the cdc specs later on. Meanwhile, you could submit an PR for modification (it looks good), since I prefer to review/discuss code modification via PR than issue.
since it is approved by RPi team, I think it is good to merge, though I think we could merge line 74 and 89 together for easier reading.
if the field order is not matter, we should merge this with line 89 into a single #ifdef
good for a merge, only an minor request to change TU_MIN() to tu_min16()
16 pairs of endpoints are lots, 8 is more common. not really need changes though :smile:
TU_MIN() -> tu_min16() would be better, inline function is better than macro (although the stack uses tons of macro already :smile: :smile: )
@kasjer I saw you wrote the device driver for the DA1469X. Could you do me a favour and test the this PR if it works with with MCU? It is about the dcd_edpt_iso_xfer() if it works. No hurry, if you have some time! Thanks in advance! :)
@kasjer I saw you wrote the device driver for the DA1469X. Could you do me a favour and test the this PR if it works with with MCU? It is about the dcd_edpt_iso_xfer() if it works. No hurry, if you have some time! Thanks in advance! :)
@PanRe I will try to squeeze it into my workflow.
Great, will send a pr asap.
Also thanks for writing this wonderful library.
๐
Fix RP2040 host compile. @hathach can we compile something for RP2040 in host mode as part of CI so this would be caught in the future?
@liamfraser ah sorry, I forgot about rp2040 host mode, can you also add .only.MCU_RP2040 file to the host example https://github.com/hathach/tinyusb/tree/master/examples/host/cdc_msc_hid . That will have ci to build host example with rp2040
PS: ci has some internal issues, I have cancel the run, feel free to push new commit.
Update: host example needs to have CMakelists.txt as well to build, I will merge it first and add the host example build for rp2040 in a separated PR. Ru-run ci just now.
The legacy app shouldn't send SEND_BREAK since the current default descriptor doesn't support Send_break in its ACM descriptor. I guess it doesn't read those at all. Note for application that want to make use of send_break should set this bit to 1.

can you move it after tud_cdc_line_coding_cb(), also change the wait_ms to duration_ms.
thanks, the pr looks good, only a minor cosmetic change request.
The legacy app shouldn't send SEND_BREAK since the current default descriptor doesn't support Send_break in its ACM descriptor. I guess it doesn't read those at all. Note for application that want to make use of send_break should set this bit to 1.

thank you for your PR. This should fix #681
no problem, I am glad you find this project useful. closed by #683
only a few minor feedback, if you don't have time. I could do a friendly push to update the PR :)
should be just dir == TUSB_DIR_IN
having both num & dir as cont would be nice.
Describe the PR
Add RP2040 to host example build. Also change ifdef RP2040_USB_HOST_MODE to if TUSB_OPT_HOST_ENABLED to be consistent with tinyusb host detection convention.
hihi @PanRe sorry for late response, I am focusing on rp2040 last week since Adafruit is about to manufacture them (paid work). Will definitely try to review this asap.
hihi @PanRe sorry for late response, I am focusing on rp2040 last week since Adafruit is about to manufacture them (paid work). Will definitely try to review this asap.
No worries, the only thing i really would like to know is this remaining issue why the code does not compile without errors. The problem is with
#if CFG_FIFO_MUTEX #define tu_fifo_mutex_t osal_mutex_t #endif
in the tusb_fifo.h. osal_mutex_t is unknown and thus an error emerges. To be honest, i do not kno...
I think that's a way to remove one to-do item in your code.
Well, that indeed works for boards from TI, but I wanted something specific to "projects using msp430 the arch", regardless of which board you're using.
And I forgot at this point why this was a "TODO" (maybe there's no easy way to extract arch using rules.mk?). Your patch is fine for now tho.
That's indeed a good idea. I've tried to run the stack in PendSV in low priority triggered by SysTick with additional mutex, in this way I don't need a RTOS abd I can have Delay() in main loop.
not all board will have an msp_exp430 in their name. Marketing people will prefer to have AI, Super, in the product name :smile: . @cr1901 we can do it simply by moving msp430 into its own family with shared `family.mk' e.g stm32f4 https://github.com/hathach/tinyusb/tree/master/hw/bsp/stm32f4 . Though I am too lazy to do that with a family with only 1 board :smile: . will wait until some people make PR for another msp430 .
can you use CROSS_COMPILE which is more accurate in this case.
can you use CROSS_COMPILE which is more accurate in this case.
ifeq ($(CROSS_COMPILE), msp430-elf-)
Hi,
I see you have done the BSP support of SAME70, do you have any plan to add the DCD driver ? :)
I saw there is an implementation in zephyr but it's under Apache license.
I have it added after purchasing the board. But have no plan at the moment since it is too much work already. My next todo in free time is host stack, it needs a bit more code.
We have split our cmake into a device and host mode so you don't unnecessarily compile both.
The USB device enumeration fix only applies to device mode. Perhaps this should be linked in by family.cmake?
That is ok though, tinyusb is designed to be all included and controlled by config file. To be honest that make my example easier ๐
It is ok as well, since the code is not run anyway, as above. There may be otg example later on
@hathach I had a question related to one of the call backs that the driver makes to the stack, i.e. dcd_event_setup_received(0, setup, true); . It says whenever we receive a "SETUP" packet then it shall be called. My question is, what do we mean by SETUP packet here, just the SETUP packet as in figure 1, or the Data that follows the SETUP (i.e. Data packet in the SETUP stage) as in figure 2.
Figure 1:
 would turn it off.
There is led pin typo in function off
How about board_led_write(0) to set led to off
Seem like a typo, should be led pin than button
Endpoint descriptor should be 9 bytes in length (not 7) and have two extra bytes at the end: bRefresh and bSynchAddress
According to MIDI USB specification 1.0 (6.2.1 Standard MS Bulk Data Endpoint Descriptor)
This is actual error before fix:
0x07 bLength
0x05 bDescriptorType
*** ERROR: Invalid descriptor length 0x07
Hex dump:
0x07 0x05 0x81 0x02 0x40 0x00 0x00
endpoint descriptor is always 7 (USB specs). There is probably some mis-handling somewhere.If you provide further details on how you test it, people could help to clear it up ( I am assuming you are using midi_test example, if you don't please use that example )
Thank you @PanRe for another great PR. This is too big for me to do a full review in one round. I will try to do break it into a few round, hopefully it doesn't cause any inconvenience.
I have go through the overall PR (not into too much of the detail). To be honest I don't really like to have fifo invoked in the DCD layer API, it will complicate the port for smaller mcu. Also this cause the fifo to be a bit too complicated.
It may be me not familiar with audio application. However, I...
I don't really like to use fifo within dcd driver, dcd should be as simple and easy to port to hardware as possible.
This code is specific to stm32, we shouldn't include it here. What is its pros, if the benefit is not that great. I would prefer to not include it.
It means the 8 bytes of Setup Data, not the Setup PID, you should pullout/get it then pass it into the dcd_event_setup_received(). Hope this clear thing up.
@hathach Thanks for the clarity. One more question I had, is there a way through which I can enable printing of some debug logs from the stack to the board's uart ?
yeah, you can use make LOG=2 (or 1) which will output log to uart (if you implement the board_uart_write() ), you could redirect it to segger rtt if you could hook up an jlink, which is much faster. Detail is described here https://github.com/hathach/tinyusb/blob/master/docs/getting_started.md
This is also valid for other MCUs. At the time of commenting it was done for STM32.
Hathach, you could have told me this a very long time ago that you don't want the dcd to be changed. I asked about this idea in september last year #504. And this PR was a long time open with exactly this change...
If i understand you right, you want all of the fifo logic cut out of the audio driver am i correct? Well IMHO, this will lead to asynchronous problems and users will ask why its not working occsionally. If somebody has problems with the performance, he can change it anyway easily....
@hathach , Are you implementing the debug logs using nano libc and overwriting _write with board_uart_write ? I am hitting many hardfaults (bus faults) when I pass LOG=2. Doesn't happen otherwise. Am I doing something wrong? ( I see the rest of the board.mk files have -nostdlib flag).
yes, I use nanolib with _write() for retarget and have no issues with other mcus. -nostdlib flag is more related to startup and not relevant to nanolib (libc). Do you printf in an ISR, maybe mcu doesn't like that.
Describe the PR
move lpc55 into its family, also add lpcxpresso 55s28 board
Hathach, you could have told me this a very long time ago that you don't want the dcd to be changed. I asked about this idea in september last year #504. And this PR was a long time open with exactly this change...
I apologize for this, I probably got distracted by other works and didn't follow this as closely as I could. In #504, I paid too much attention to the fifo rework for DMA.
If i understand you right, you want all of the fifo logic cut out of the audio driver am i correct? ...
I take back my own words after revisiting #504 . If we could, we should get rid of the middleman EP buffer on appropriate MCU. Samples -> FIFO -> EP buffer -> USB FIFO . dcd_edpt_xfer_fifo() would be an nice (optional) addition to current dcd. Other driver e.g CDC that also use fifo can make use of this API on appropriate MCU as well. We will do more polished work as follow up PR later on. There is only 1 request for change is to rename the API (ubsd/dcd) from edpt_iso_xfer() to `edpt_...
This should be better be done at usbd and or (dcd option flags), driver shouldn't be worried about the MCU, that will hurt the portability. However, we will merge it as it is, I will do this polished job later on as follow-up PR.
I really want to merge/wrap-up this PR, though I am still catching up due to the modification. Please be more patient with me. I have an couple more question in the review.
this fifo write can failed due to mutex if current fifo is occupied by driver/application (e.g writing/reading samples).
instead of setting copy_mode, I think it would be better to have an dedicated API for read_n() write_n() for this mode e.g
tu_fifo_read_n_const_addr(), tu_fifo_write_n_const_addr() ( you can name it differently). That way we don't have to mange the mode internally. It also make the usage more explicitly (const address) where it is called.
Ok, I need help. I thought we want to get rid of the middleman EP Buffer between driver fifo and stm32 USB FIFO. But we still have an middleman EP FIFO. Sorry, the modification is a bit overwhelmed for me to fully understand at once.
I pushed my latest polished version, which i came up yesterday. It bootstraps the audio driver and clarifies a lot of names with the intent to make it easier to understand the purpose of all the buffers and so on.
I know this PR is getting bigger and bigger ^^ To be honest, it was not my intention to flood you with code. It just came out, that the iso_transfere with the FIFO support became more complicated due to these copy modes (which i was not thinking of at the time of starting this pr...
@hathach , no I'm not using an ISR to print. On further debugging I see bss global variables like _usbd_q are not zero initialized when I compile with LOG=2, which is resulting in a fault.
@PanRe about DA1469x changes.
I'm afraid it will not work as intended here is why.
Unlike other MCUs USB controller does not have large enough FIFO to send or receive ISO packet greater then 64 bytes.
To make it work data needs to be read from the hardware FIFO during packet transmission and not after it was received like is usually the case. More over if DMA is not used to read whole packet it is very likely that interrupt handling will not be fast enough to process incoming data.
It was...
regs->rxd is hardware register not continues memory and as such can't be used in current implementation of tu_fifo_write_n
That should work out, i extendend the fifo to posses copy modes exactly for this purpose to copy to a constant address.
I pushed my latest polished version, which i came up yesterday. It bootstraps the audio driver and clarifies a lot of names with the intent to make it easier to understand the purpose of all the buffers and so on.
I know this PR is getting bigger and bigger ^^ To be honest, it was not my intention to flood you with code. It just came out, that the iso_transfere with the FIFO support became more complicated due to these copy modes (which i was not thinking of at the time of starting this pr...
Within dcd_edpt_iso_xfer() the copy mode is set
if (dir == TUSB_DIR_IN)
{
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_CST);
}
else
{
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_CST);
}
But anyway, it would not solve the problem you described with the 64 bytes. The FIFO is capable of handling DMA transferes, however, its write or read pointers would need be updated in between a write/read if a wrap to the start of the FIFO buffer would occur. This needs to be handled ...
The copy mode stuff is to be changed to be better visible.
For DA1469x register address is valid for 8 bits reading only not for 32 bits.
I've made the mistake because of lines
buf8 = buf8 + (n - f->depth) * f->item_size;
...
_ff_push_n(f, buf8, n, wRel);
that suggests that source address (in my case register) can be modified,
and I just assumed that _ff_push_n works as it used to.
but in this case changing address of register also seems suspicious (I did not dig deep enough
to see if this will never happen).
Conditions should probably be switched, there is no need to allocate dma if it will not be used due to second condition.
Same applies to line 452 below.
Looks like something is wrong with my startup file. Can't figure out what.
Ah i see, thanks that was not covered!
I remember i did fill_tx_fifo() extra without using read/write functions from tusb_fifo. I could do the same for the reading part but does it make sense since interrupt is too slow anyway?
That is true! It is possible to resolve this by implementing separate mutexes for write and read pointers. Technically, this would not be a problem but might be much work to do.
This part regards to PCM encoding where you have e.g. 4 channels which are to be interleaved into one stream. For this you need an additional buffer! This is an outdated version right now, in the most recent one only one layer of FIFOs is used since two FIFOs in a consecutive manner are not necessary.
Very true, i will change that!
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.
Today I tested your code (with change to access rx fifo as byte only) and It was not working for unknown reason I will let you know what come out of it tomorrow. I don't know if it was due to timing or some other small detail yet.
One more thing that may affect interrupt latency is that DA146xx chips don't have internal flash. It is all using external SPI flash in XIP mode. So when code is in cache it may work if it needs to be read it may be too slow and DMA would not be affected. Anyway I ...
I mainly run make with LOG=1/2 for debugging, if it becomes too difficult, I will use segger ozone as debugger. Ozone only need axf file, then you could step and breakpoint the program. I don't use much of IDE, it is very hard to keep up with all the ports with IDE, makefile works better.
@PanRe thanks to your awesome rework, I think the fifo can be written and read independently without conflict. If driver follow this rule firmly, maybe we could skip the mutex for it.
I pushed my latest polished version, which i came up yesterday. It bootstraps the audio driver and clarifies a lot of names with the intent to make it easier to understand the purpose of all the buffers and so on.
I know this PR is getting bigger and bigger ^^ To be honest, it was not my intention to flood you with code. It just came out, that the iso_transfere with the FIFO support became more complicated due to these copy modes (which i was not thinking of at the time of starting t...
Describe the PR
Follow up to #675 for host driver
@hathach , There seems to be a serious problem in this MCU's silicon. I went on debugging trying to understand why a specific address is having spurious values even after initialization. The situation is as follows :
@PanRe I tested some more just to be sure.
With default 32MHz clock interrupts are not able handle incoming ISO traffic while current DMA version works ok.
When switched to 96MHz sometimes interrupts seemed to have just enough time but not always (maybe if code
is cached it is fast enough). But on the whole I was not able to have forking stream without DMA when packet size
is above 64 bytes (size of hardware FIFO size).
There is one more problem. If data is streamed directly to TinyUSB F...
This comment is just for DA146xx driver.
@PanRe I tested some more just to be sure. (
With default 32MHz clock interrupts are not able handle incoming ISO traffic while current DMA version works ok.
When switched to 96MHz sometimes interrupts seemed to have just enough time but not always (maybe if code
is cached it is fast enough). But on the whole I was not able to have forking stream without DMA when packet size
is above 64 bytes (size of hardware FIFO size).
...
Describe the PR
pico_bootsel_via_double_reset for all examplesAll CMakelists.txt are updated, just ignore it, the interested modi...
I think so too yes, it anyway it would be weired to allow multiple processes to write into the fifo within one driver.
Ok thank you! I was not sure about the best way how to do it.
Since the
dcd_edpt_iso_xfer()does not have anything specific about ISO, I think we should rename it todcd_edpt_xfer_fifo()
I thought about that too and i would say thats better! There is but one concern, currently all dcd_edpt_xfer_fifo() are implemented such that no EP0 transfere can be handled via the FIFOs. This was a matter of time, since most EP0 transfers are somewhat special and i had no time to dig into that.
I would spare this for later if somebody really has the need f...
@hathach I've fixed the issue in the startup file. Please merge my PR in TI Driver repo to bring in the required changes.
@PanRe hmm, I forgot about multiple API() right across threads in application. Which is indeed true for cdc, the write()/print() can be called virtually across all the thread (with rtos). Hmmm, apparently we may need to put more thought on this, fifo does come with complexity of mutex though. We can separate write/read mutex for fifo and only enable mutex for the driver side (since mutex in isr can be tricky). I am not too worry about it right now, but definitely something to pay more attenti...
Since the
dcd_edpt_iso_xfer()does not have anything specific about ISO, I think we should rename it todcd_edpt_xfer_fifo()I thought about that too and i would say thats better! There is but one concern, currently all
dcd_edpt_xfer_fifo()are implemented such that no EP0 transfere can be handled via the FIFOs. This was a matter of time, since most EP0 transfers are somewhat special and i had no time to dig into that.
I would spare this for later if somebody really has th...
Merged now, will do a bit more in-depth testing between bus reset and disconnection later on. More detail https://github.com/adafruit/circuitpython/issues/4066#issuecomment-789524956
@hathach I've fixed the issue in the startup file. Please merge my PR in TI Driver repo to bring in the required changes.
Is this a bug out of TI startup file. Which is really annoying !!
Well there is the case that you don't have a middle man buffer any more but only one FIFO... i think the best would be to extend the FIFO capabilities now and solve this issue once and for all by using separate mutexes for read and write and allow to not enforce use of mutexes just as you suggested!
Maybe the best would be to check within fifo.c if a mutex is set and only if so execute it. Otherwise just ignore it.
I can do this easily, the only nasty thing is that all projects where mutexe...
@hathach I've fixed the issue in the startup file. Please merge my PR in TI Driver repo to bring in the required changes.
Merged, thanks. Is this a bug out of TI startup file. Which is really annoying !!
Yes! It was annoying indeed! The zerofill loop was written in C and was being optimized out. Converting it to assembly made it work!
Yes! It was annoying indeed! The zerofill loop was written in C and was being optimized out. Converting it to assembly made it work!
it is probably due to the LTO and/or other optimization option, if you continue to see issue like this, you could turn off the -lto and reduce the optimization if needed :)
Describe the PR
Implementation of the SAM70 DCD driver.
Additional context
It's still very sketchy. Tested echo works with cdc_dual_ports example, but EP0 still have issues, for example set_line_coding doesn't work. (Seems like )
TODO:
Any help is appreciated :)
Set up
[Mandatory] Provide details of your setup help us to reproduce the issue as quick as possible
Describe the bug
0.Projects created using the master branch on 2.24 can run normally
1.tusb_init() success
2.The windows device manager prompts that the device descriptor request failed
3.It looks like uint8_t const * tud_descriptor_device_cb(void) function ...
Yes, it was because of Ox optimization option. Thanks for the help :)
Describe the PR
Group more boards into family to speed up ci build
endpoint descriptor is always 7 (USB specs). There is probably some mis-handling somewhere.If you provide further details on how you test it, people could help to clear it up ( I am assuming you are using
midi_testexample, if you don't please use that example )
It does appear that for audio class, the descriptors are length 9. This is mentioned as a note in the USB 2.0 spec (section 9.6):
9.6 Standard USB Descriptor Definitions
The standard descriptors defined in this speci...
Thanks @pigrew @duddie for the issue, this is really a kick in the ass :facepalm: :facepalm: . How can i miss this !!!!

I just double checked with Audio 2.0 and 3.0 specs. USB-IF fixed this by using only 7 bytes for endpoint descriptor, that would be an untold story.
Thank you very much for the PR, that was me being too confident. Sighed !!! PR is good for merge, though I think we need to put a bit of note in the comment to clarify it
@hathach ,
Eeek, yeah, I didn't even notice that USB-MIDI 2.0 and USB AUDIO 2.0 and 3.0 use the 7-byte descriptor:
USB-MIDI spec 2.0: 5.3.1:
Note: In the USB MIDI 1.0 specification, the Standard MIDI Streaming Data Endpoint Descriptor
includes two additional fields, bRefresh, and bSynchAddress. These fields are not included in
USB MIDI 2.0.
It looks like the class driver here is for USB-MIDI 1.0, so this patch is correct. This library's other USB audio class uses audio 2...
@pigrew I just now know about the exist of USB MIDI v2.0 which just come out in May 2020. It is probably too soon for us to support. We probably stick to MIDI v1.0 until its support is stable. I think Audio v1 is probably the only spec that use 9-byte endpoint descriptor. It must be written at the same time with the USB 2.0 specs, and they are just too late to adjust, I guess.
OK, mutex should be used whenever an preempted RTOS is used. Though you could do it in this PR or the follow up one, whichever you prefer. Just make sure you put some // TODO in the mutex access to remind us later on. I think only audio driver make use of the xfer_fifo for now.
great PR, I will help and test it out whenever I could. Please keep it updated :+1: :+1:
I tested it in depth and found that the problem appeared in the loop of tud_task(), so I added log output to the tud_task() function, and found that the program can enter the tud_task()->while(1) loop and be able to get from the queue I received the event, but it is strange that the DCD_EVENT_BUS_RESET event can be received, but the DCD_EVENT_SETUP_RECEIVED cannot be received. This is why the process_control_request() cannot be executed and cannot respond to the host's descriptor request, whi...
Wait, what exactly do you mean? Should
#if CFG_FIFO_MUTEX
static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t mutex_hdl)
{
f->mutex = mutex_hdl;
}
#endif
be changed to
#if CFG_FIFO_MUTEX
static inline void tu_fifo_config_mutex_write(tu_fifo_t *f, tu_fifo_mutex_t mutex_hdl)
{
f->mutex_wr = mutex_hdl;
}
#endif
and
#if CFG_FIFO_MUTEX
static inline void tu_fifo_config_mutex_read(tu_fifo_t *f, tu_fifo_mutex_t mutex_hdl)
{
f->mutex_...
I am not familiar with your IDE and set up. Look like you are having some integration issue which is not really qualified as stack bug. Which I have no idea how to fix. I will move it to discussion, maybe others with similar ide set up could help
@PanRe I mean you could do it now, or leave it to follow up PR. There is no need to implement it right away :). Regarding the API we can change it to
tu_fifo_config_mutex(f, tu_fifo_mutex_t write_mutex, tu_fifo_mutex_t read_mutex)
and it is legit to set either as NULL or both Write and Read mutex to the same one, which we will do atm for existing driver . Regarding updating existing code, it should be no problem, tu_fifo is internal data type, there is only a handful of drive...
Very well, i will implement it right away! It is just, we have discussed that stuff now, later we will have forgotten it ^^
Is your feature request related to a problem? Please describe.
I think we need something to do performance analyse.
Describe the solution you'd like
As we already have RTT for debug print, It should be easy to add SystemView support.
The only thing MCU dependent is SEGGER_SYSVIEW_X_GetTimestamp
Nice idea, I did have systemview running with nrf52 in this repo https://github.com/adafruit/Adafruit_nRF52_Arduino and FreeRTOS. Will got it running late on when having (more) time
Describe the PR
This issue is discovered while troubleshooting https://github.com/adafruit/circuitpython/issues/4066#issuecomment-789524956
Part of enumeration walkaround is waiting for bus reset to complete i.e line state != SE0.
https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c#L61
However, when pull-up is disabled e.g application call tud_disconnect() to soft disconnect from Host (while s...
@dhalbert Circuitpython should also update its MIDI endpoints descriptor as well, the correct endpoint size is 0x09. Just notice cpy is also 0x07.
0x07, 0x05, 0x06, 0x02, 0x40, 0x00, 0x00, // <adafruit_usb_descriptor.standard.EndpointDescriptor object at 0x7fe81cffbdc0>
0x05, 0x25, 0x01, 0x01, 0x01, // <adafruit_usb_descriptor.midi.DataEndpointDescriptor object at 0x7fe81cffbdf0>
0x07, 0x05, 0x86, 0x02, 0x40, 0x00, 0x00, // <adafruit_usb_descriptor.standard.EndpointDescriptor object...
Looks good to me. In terms of VBUS, you can use a level high / level low interrupt on any GPIO to provide a vbus changed interrupt. That is to say, you don't need to use vbus detect from the actual usb controller input.
Looks good to me. In terms of VBUS, you can use a level high / level low interrupt on any GPIO to provide a vbus changed interrupt. That is to say, you don't need to use vbus detect from the actual usb controller input.
Does it trigger the VBUS_DETECT interrupt in sie_status. I would hop to handle it internally by the stack without user to call any API. For example, on nRF52, the PHY is still disabled after tud_init() and only enabled after VBUS is detected. Then it got disabled again af...
If you look at the gpio function table, only some gpios are connected to USB VBUS DET (which can drive the VBUS_DETECT interrupt status). I am saying that you could use any GPIO interrupt to add and remove vbus detect in software (by forcing and removing vbus detect like we do now when the interrupt fires). This effectively lets you use any GPIO as vbus detect.
That is what I guess as well. It will needs an extra API for tinyusb stack to interact with application regarding vbus so it could distinguish between disconnected and suspended as mentioned in the datasheet. Thanks for your advice, I will look at this later on.
Describe the PR
Cache all toolchain to speed up ci (hopefully)
We could remove the // TODO now :smiley:
The mutex read, write for tu_fifo look great. Thank you very much for the update. Adafruit is shipping out rp2040. I will have more time this weekend to test and hopefully help with this PR.
this is minor but we don't really need 2 pair of lock/unlock for read/write. We should have tu_fifo_lock(mutex) and pass either f->mutex_wr or f->mutex_rd, and update the current function accordinly.
We could remove the // TODO now :smiley:
Well yes but within tusb_fifo.c we always use tu_fifo_lock_wr(f); etc. in any case and if we change it to the version you suggested then we always woud need #if #end stuff to exclude tu_fifo_lock(f->mutex_wr) because f->mutex_wr is only defined in this case. I leave it up to you what you prefer ok? :)
it is an macro, macro can swallow argument without any problems :smiley:
Nice, you there is always something new ^^. Already done!
I have one minor thing about the support FIFOs in mind, right now, they are coupled to the number of channels. I would like to decouple them which should not be a big deal any more. I hope i can do this at the weekend!
Describe the PR
Addition of Silabs config options
Addition of EFM32GG12 cmsis
Implementation of the EFM32 DCD driver.
EFM32GG12 Dev Board Support
Additional context
While trying to port this family, thinking it would be completely new, I noticed something very peculiar while looking at the other drivers for help.
I noticed the USB peripheral Silabs uses on their mcus is very close to the one use in the ESP32S2 from espressif, very little difference between them, my guess is that ...
that is great to hear EFM32 also use synopsys as their USB-IP. There is a pending issue #382 to generalize the ip driver much like ehci/ohci. If you could get it running on EFM32, then I guess it would help a lot in the generalization later on. Good news, that I also have an EFM M4 Giant Gecko sitting on my storage for more than 5 years. Would be great to revive it :D .
Seem like EFM from EnergyMicro/Silab also use Synopsys as well, change The issue name for betting meaning. I am hoping to implement it like ehci/ohci where multiple vendors can calls/implement common API to get the driver running.
Describe the PR
Add back lib/CMSIS_5 as submodules https://github.com/hathach/tinyusb/discussions/705 . Also slightly optimize ci submodules checkout
Does this mean that we now need to update submodules recursively in order to fetch this. In CircuitPython we have been disrecommending git submodule update --recursive because it pulled in extra tinyusb submodules that weren't needed.
If you're not using a broken compiler, a common API will be zero runtime cost anyway thanks to LTO. So this seems like a good idea.
@dhalbert circuitpython or any super project only need to check out tinyusb and shouldnโt check out any submodules of tinyusb to compile. Super project should only use src folder of tinyusb, any other submodules/folder are subject to change
With DMA and Dual Bank the throughput is quiet good.
Running at 150MHz in ITCM, with cdc_xfer_cb commented out
// TODO search for wanted char first for better performance
for(uint32_t i=0; i<xferred_bytes; i++)
{
tu_fifo_write(&p_cdc->rx_ff, &p_cdc->epout_buf[i]);
// Check for wanted char and invoke callback if needed
if ( tud_cdc_rx_wanted_cb && ( ((signed char) p_cdc->wanted_char) != -1 ) && ( p_cdc->wanted_char == p_cdc->epout_buf[i] ) )
...
Oh, right, I didn't look closely at the synopsys driver, fascinating.
There is recent bug fix related to vendor control handling especially webusb https://github.com/hathach/tinyusb/pull/646 please pull and try again to see if it fix this issue
@hathach , How does the communication happen stack and the driver if there more than 64 bytes of data to be transferred during control transfer? I see the stack says that the total length of configuration descriptors is 98 bytes, however, the dcd_edpt_xfer function just provides 64 bytes for. The driver needs to send more data on next IN packet from the host. Is there bufer
@hathach , How does the communication happen stack and the driver if there more than 64 bytes of data to be transferred during control transfer? I see the stack says that the total length of configuration descriptors is 98 bytes, however, the dcd_edpt_xfer function just provides 64 bytes for. The driver needs to send more data on next IN packet from the host. Is there a shared buffer that I can use from the driver?
@hathach For some reason the checks are failing as they aren't able to find the ti_driver repo. I don't know what happened all of a sudden, can you help me with that?
Additionally, I had a question, how does the communication happen between the stack & the driver if there are more than 64 bytes to be transferred? I see the configuration descriptor's total length is 98 bytes. However the dcd_edpt_xfer passes only 64 bytes to the driver at a time. Is there a shared buffer that the driv...
Thank you - unfortunately, still the same error
Op za 6 mrt. 2021 om 05:22 schreef Ha Thach notifications@github.com:
There is recent bug fix related to vendor control handling especially
webusb #646 https://github.com/hathach/tinyusb/pull/646 please pull and
try again to see if it fix this issueโ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/hathach/tinyusb/issues/498#issuecomment-791866835...
@HiFiPhile though are pretty good number, and we haven't got into the speed optimization of development stage just yet :smile:
Add DEPS_SUBMODULES = hw/mcu/ti here to fix ci. I have opyimize ci speed by only checkout required module to save time.
TinyUSB usbd can request transfer that is a lot larger than max packet size. It is dcd responsibility to carry out the requested length. When all the bytes is transferred, dcd invoked the dcd_event_xfer_complete() to notify the usbd
TinyUSB usbd can request transfer that is a lot larger than max packet size. It is dcd responsibility to carry out the requested length. When all the bytes is transferred, dcd invoked the dcd_event_xfer_complete() to notify the usbd
@hathach but I see the configuration descriptor is 98 bytes in length, however the len field in dcd_edpt_xfer is set t 64 by the usbd. Also, no stack doesn't request any ZLP to be sent. Is there some other function / shared data structure that requests t...
usbd will request next packet after 64 first bytes is transferred. It will also request xfer with length=0 as zlp as well. DCD must not auto send zlp. Sum up, dcd just need to transfer what the usbd request. The rest will be taken care by usbd.
Note: to save sram, usbd control is transferred 64 byte each, but behavior can be configured/changed later on. Other class driver such as msc can normally request 4K or more for each transfer.
That clears it. Thanks! I'll try calling back 'dcd_event_xfer_complete() ' to notify usbd and expect more data from it. Thanks !
hm, if you are not using the updated example, please also sync your project to the new webusb example handling for control transfer as well. https://github.com/hathach/tinyusb/pull/645
I just pulled out the board stm32f407disco and test with webusb_serial and everything works just fine with chrome on Linux. Please note that it is necessary to test with exact dev board and the exact example since that ensure we are testing the same thing.
I did use the updated example... also yes I have an exact
stm32f407disco board. I compiled in macOS and also in a fresh Ubuntu
20.04.1 VM and uploaded the resulting .elf file with STM32CubeProgrammer in
macOS, resulting in the same error in Chrome macOS. I will try again with
everything inside the Linux VM.
Op di 9 mrt. 2021 om 05:43 schreef Ha Thach notifications@github.com:
hm, if you are not using the updated example, please also sync your
project to the new webusb example handli...
To doublecheck, the stm32f407disco board is this exact one, right?
https://www.st.com/en/evaluation-tools/stm32f4discovery.html
yes, it is that one, maybe it has something to do with macOS. There is a SET_INTERFACE targeted the webusb interface can you update the main.c tud_vendor_control_xfer_cb() of webusb serial to add following if to see if it could get it work
else if (
request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
request->bRequest == 0x22) {
// existing code
}
// new code
else if ( request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD && request->bRequest == ...
Set up
Describe the bug
When connecting a keyboard to Pico the process fails at the point where the stack is trying to read the full Device Descriptor. If the Device Descriptor fits into one single packet (bMaxPacketSize0 == 64) the reading is successful. When...
thanks for the issue, make sure you are running the example with latest master. Though I am not surprized that it doesn't work. It is not your setup or device, it is just the host stack isn't received much of developing time. So far I have reworked usbh and host msc, will do host hid next when I find time.
I ran into the exact same issue while porting for another microcontroller. The demo worked on Windows. On Linux it would enumerate but not be recognized in Chrome.
Assuming you kept the default descriptors, adding this rule to udev may resolve your Linux issues as well:
ATTRS{idVendor}=="cafe", ATTRS{idProduct}=="4011", MODE="0666"
Still the same unfortunately. Here's my updated code, for reference:

also, not sure if related but not long after this the wifi of my Macbook stopped working :) reboot hasn't resolved it
@crosswick update: I also tested with one of my macos machine, it seems to work just fine. I guess you have to do the test here if you don't mind. Can you post the LOG with updated code to see if we got other error rather than the stall with SET_INTERFACE as previously.
USBD Setup Received 01 0B 00 00 02 00 00 00
Set Interface
VENDOR control request
Stall EP0
Describe the PR
Update docs to mention how to find out BOARD and udev for webusb example. Fix #481
Describe the PR
In addition to GET_INTERFACE, Host OS can occasionally send SET_INTERFACE, which is easily omitted by class driver without alternate interface supported. This PR enables usbd to ack SET_INTERFACE if it is not implemented by class driver (esp vendor/external driver).
related #498
thanks @xmos-jmccarthy for confirming the root cause. I update the docs regarding vendor/webusb vs udev to help others in the future.
Describe the PR
Update pico sdk 1.1.0
Alright, I will look into it. Can you specify which version of macOS you are using, please? I've tested on Mojave, can also try on Catalina
Describe the PR
I thought it was included in old PRs but seems not...
In my CDC test with SAME70, throughput increased from 800KB/s to 27MB/s.
@PanRe I am bump it up to master, and change base back and forth to get github file changes updated, also fix ci build. Indeed there is a spaghetti include especially between osal and fifo, since they include each other. or osal_none and osal_pico, the fifo is used to implement os queue structure. I just add enough to get ci passed, will do an overall includes refactor later on as separated PR.
While reviewing your latest push, I realized that fifo to fifo opertation (read, peak) isn't use...
thanks for the PR, yeah, this is one of the improvement I planed to do but totally forgot. However, the implementation is not actually quite right. The driver must invoke the wanted_cb() right at the time it push the wanted_char into the fifo. which allow the application callback that call read() see the wanted_chr right away.
For example, to catch the \n then call read() to get the whole line. Else application must skip dozen of characters. which can potentially has another '\n' ...
mine is 11.1 Big Sur, post the log up (with update code) when you have time tested with, we could analyze it more.
After giving it more thought, I think it is not worth to have wanted as the last char in the fifo at the time of the callback. It doesn't occur often and also doesn't have much impact on existing usage (application may need a minor of adjustment). Let's do it this way, though we still need to check if there is still data in the fifo before invoking the wanted callback, else it could confuse the app.
hmm, maybe it is not worth to have wanted as the absolute last character. Maybe we can implement it this way. Though we may need to check if data is still available before invoking callback (much like the cdc_rx_cb() below) since previous callback can potentially read() all the data.
@PanRe I am bump it up to master, and change base back and forth to get github file changes updated, also fix ci build. Indeed there is a spaghetti include especially between osal and fifo, since they include each other. or osal_none and osal_pico, the fifo is used to implement os queue structure. I just add enough to get ci passed, will do an overall includes refactor later on as separated PR.
While reviewing your latest push, I realized that fifo to fifo opertation (read, p...
Oops, let me know if there is any conflict. Please pull first, I will switch to another branch just to be safe.
Sorry for the late reply! The audio driver was not fully finished at your time using but it is nearly done. There will be some changes regarding the data structure with the FIFOs, but i tried to make everything easier! Please have a look on the new driver once it is out. Not everything is fully tested as audio is a pretty broad topic, so i am happy if you can test it too!
The descriptors were written hard coded at the time being. If you find the time you are very welcome to generalize the ...
It is all set! :) I have no more wishes for the audio driver. Regarding its structure it now posses everything i thought of! So you do not need to fear that i am coming around with some more dramatic large PRs ;)
There might be an issue of how the buffer sizes were set up. There is a new version of the audio driver on its way out but much of the examples were not retested so far. Would be nice if you could try again once the new driver is out! :)
Is your feature request related to a problem? Please describe.
I would like to use TinyUSB in an SDK; however I found that it is less than ideal to add as a submodule, due to the current structure. Tinyusb submodules pico-sdk in hw/mcu/raspberrypi. pico-sdk submodules tinyusb in lib. Currently, pico-sdk submodules a fork without the raspberrypi submodule added, so there is no infinite recursion issue, for now. Additionally, the SDK I am working on has FreeRTOS and fatfs, so currentl...
Well not sure why, but it works now... first I used my Catalina Mac Pro to compile and test - works. Same board also works on the earlier Mojave Macbook. Next, without changing the compile toolchain on that Macbook, I compiled the current version - also works. Perhaps my previous test of 4 days ago somehow wasn't with the updated version...
I could doublecheck with a version prior to the vendor control handling fix if you'd like. In any case: thank you! Issue can be closed as fas as I'm c...
After some thought I feel more hesitate about how to implement it :>
While I use UART extensively in our product, I always use a packet so there is no last char problem.
We also need to make sure data is written (fifo not full) before call the cb. If the application relies on tud_cdc_rx_wanted_cb, there could be a deadlock where the fifo is full but no wanted char received.
If it's a personal project I'd delete this cb and let the application to do all the decoding :) I think we ...
I'm using tinyusb as part of my project, and in the course of integrating it into my build system hit an error when compiling usbd.h. The line below references MSC_SUBCLASS_SCSI which is declared in class/msc/msc.h. However, my build was failing because usbd.h never includes class/msc/msc.h.
https://github.com/hathach/tinyusb/blob/2adb7e719316b12c53a907153cfa0056db1abd70/src/device/usbd.h#L220
Adding a #include "class/msc/msc.h" line to usbd.h resulted in a successful,...
Ooops, as soon as I wrote this up I figured out what I was doing wrong... I had hit this "issue" a couple days ago when I was first setting up, but it was actually a symptom of another issue I was having. This works as expected now.
Sorry for the noise!
thanks for confirmation, the #711 handling SET_INTERFACE at usbd even vendor cb does not handle it at application. If you would just pull and test with the latest master and it still works then I think we could close this for now. Maybe the make doesn't update the changes, best to try with a clean first :)
Oh, I didn't think about the edge case where fifo is full and wanted char has yet to come. Maybe we should have an rx_full_cb(). However, it should not be affected by existing code or your PR. After all, if application want to process a large data with wanted ch (e.g command with newline), they should tune up the fifo to large enough. Anyway, I think we should just continue with this PR, would you mind to add the check if fifo not empty before invoked the wanted callback. That would be enou...
Thanks @PanRe , I will do more testing soon enough. Though I think I will make an release first since this is a really big with major changes :)
I just realized the fifo_empty() did a quicker check than computing the actual count. and changes to both callback check to !fifo_empty()
Describe the PR
this should be moved to main.c . tusb_config.h is for stack configurable value. In practical, application can use it as project config, although since we are making example for usb configure. It is best to make it explicit.
I am slowly reviewing this, still there is a lot more to go through. Though there is few simple lines that I made a quick commit for. Not bad for the start :)
Regarding the audio_task(), do you have an sample with recognized tone that we could feed usb host (repeatedly). Just to show that it works. That will make sure more confident in the example, also allow me (noob at audio) can confidently refactor code in driver and fifo etc ... MIDI example has some thing similar https://github.com/h...
it is typo, should be tu_fifo_unlock(f->mutex_rd);
AFAIK, __restrict is a hint that 2 pointer aren't overlapped, I think we could drop it. Since memcpy does not work well with stm32 fifo register. We could use an temp32 for that. memcpy should be easier to read and less error-prone than shitfting.
Yes, can confirm that it still works with #716
Thanks for confirmation, to sum up it is lack of SET_INTERFACE handling, which only macos send occasionally. Just fix it at usbd level so that it is totally optional for class driver. Closed now
Ok fine! The same is done within the uac2_headset example, which is why i did that in the simple example too! You may change it there as well! :)
Yup, already done that with headset example with latest commit
I am slowly reviewing this, still there is a lot more to go through. Though there is few simple lines that I made a quick commit for. Not bad for the start :)
Regarding the audio_task(), do you have an sample with recognized tone that we could feed usb host (repeatedly). Just to show that it works. That will make sure more confident in the example, also allow me (noob at audio) can confidently refactor code in driver and fifo etc ... MIDI example has some thing similar https:...
Hi @PanRe, I haven't look through the latest audio driver changes, have you implemented interface alternative settings ?
For example one for 16 bit, another for 32 bit, and last one for native DSD ?
Yes alternate settings are implemented! But this was included from beginning on?! So you can define alternate interface descriptors 1,2,3 etc. and the host selects those. There you can define your desired sampling ratios, resolutions etc. Currently, the driver assumes only one sampling rate but this is only used in the #define n_bytes_per_sample which is used to determine the amount of bytes to be copied. If you want the more flexible version this needs to be generalized in the dr...
After more thinking it's a little complicated to always do 32 bit aligned copy.
Since dst itself is not guaranteed to be aligned, dst_u8 is not aligned either, adding CFG_TUSB_MEM_ALIGN won't help.
One compromise is test the destination alignment, if it's aligned then do 32bit copy, if not then byte copy.
Yes alternate settings are implemented! But this was included from beginning on?! So you can define alternate interface descriptors 1,2,3 etc. and the host selects those. There you can define your desired sampling ratios, resolutions etc. Currently, the driver assumes only one sampling rate but this is only used in the #define n_bytes_per_sample which is used to determine the amount of bytes to be copied. If you want the more flexible version this needs to be generalized in the driver...I d...
Same thing for the src_u8
I think we need DMA for further optimization. My idea is add a DMA callback and let the user code to implement DMA routines.
DMA is already covered by the functions
// Pointer modifications intended to be used in combinations with DMAs.
// USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED!
void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n);
void tu_fifo_backward_write_pointer (tu_fifo_t *f, uint16_t n);
void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
void tu_fifo_backward_read_pointer (tu_fifo_t *f, uint16_t n);
// If you want to read/writ...
I though memcpy() already takes care of how the payload needs to be copied byte or word-wise?
Frees up the PLL by using the FLL to clock the USB.
Also cleans up the initialization code / board make file.
Regarding the example, currently the loading of data is done within a callback function
tud_audio_tx_done_pre_load_cb(), hence, withinaudio_task()there is not much left to do... I did not put samples into the buffer from theaudio_task()because i thought it would be pretty unreliable to generate a sample frequency of 48 kHz usingwait()functions. So i put everything at once within the callback. This is of course not the way to do it later when you have real samples but much more...
Regarding the example, currently the loading of data is done within a callback function
tud_audio_tx_done_pre_load_cb(), hence, withinaudio_task()there is not much left to do... I did not put samples into the buffer from theaudio_task()because i thought it would be pretty unreliable to generate a sample frequency of 48 kHz usingwait()functions. So i put everything at once within the callback. This is of course not the way to do it later when you have real samples but...
Yes alternate settings are implemented! But this was included from beginning on?! So you can define alternate interface descriptors 1,2,3 etc. and the host selects those. There you can define your desired sampling ratios, resolutions etc. Currently, the driver assumes only one sampling rate but this is only used in the #define n_bytes_per_sample which is used to determine the amount of bytes to be copied. If you want the more flexible version this needs to be generalized in the dr...