#tinyusb
1 messages ยท Page 15 of 1
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 ...
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...
Mh i don't know, wouldn't that might require even more in-depth knowledge of the driver?
Is your feature request related to a problem? Please describe.
https://github.com/hathach/tinyusb/blob/master/examples/device/net_lwip_webserver/src/main.c#L61 mentions that ideally the MAC should be generated by hardware ID.
However the variable is declared const in https://github.com/hathach/tinyusb/blob/master/src/class/net/net_device.h#L62 and in https://github.com/hathach/tinyusb/blob/master/lib/networking/rndis_reports.c#L39
Describe the solution you'd like
Remove "co...
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
@hathach I see this MCU's USB IP is very different from the other ones, and that seems to be causing trouble. There's no way we can find if a SETUP request was sent using the IP , even a PID OUT raises the same interrupt as PID SETUP. Because of this the driver I implement, calls back to setup_received even when a PID OUT is received.
I see even in TI's USB stack for this MCU, they are checking if the control packet was a standard request in the driver itself. Shall I add a similar check?...
If I remember correctly the maximum CFG_TUD_AUDIO_N_AS_INT is 3. I think it's possible to get n_bytes_per_sample[] from the defines.
For example if CFG_TUD_AUDIO_N_AS_INT = 2, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_XX_AS_1 and CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_XX_AS_2 should be defined if support fifo are used.
Element size of fifo could be fixed to the greater one.
I just realized that there is a bit more to generalize, the driver should be able to support multiple audio functions. Yet, in C it is a bit difficult to allow such a flexibility e.g. if you have two audio functions, one has no EPs at all (just for controlling of attached audio equipment) and one for streaming with EPs and support FIFOs. (I don't know when such a setup would make sense but USB allows for it ^^). Right now, the first audio function would also setup support FIFOs without needin...
@PanRe got it, it takes me time to review the PR anyway. I am still catching up with your work :)
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
@hathach I see this MCU's USB IP is very different from the other ones, and that seems to be causing trouble. There's no way we can find if a SETUP request was sent using the IP , even a PID OUT is treated the same as PID SETUP by the IP. Because of this the driver I implement, calls back to setup_received even when a PID OUT is received.
I see even in TI's USB stack for this MCU, they are checking if the control packet was a standard request in the driver itself. Shall I add a simil...
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
Sure @hathach , I'll try doing so, also, just wanted to ask one question related to the stack, is it possible that in any CONTROL transfer, the stack sends a data of more than 64 bytes? Because currently, while returning the Configuration descriptors, I see the device returns 98 bytes in a single transaction (which is more than max allowed) . Due to this the PC (host) treats it as an erroneous situation and the enumeration fails.
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
that stack can send 98 bytes without any issue, it will break it into 2 packets,
- the 1st is 64 bytes then dcd xfer complete is called
- usbd will schedule another 34 bytes, then dcd xfer complete is called
- usbd will schedule another 0 bytes (on opposite zero endpoint) for ACK
here is the LOG=2 on other mcu.
USBD Setup Received 80 06 00 02 00 00 62 00
Get Descriptor Configuration[0]
Queue EP 80 with 64 bytes
USBD Xfer Complete on EP 80 with 64 bytes
Queue EP 80 ...
[hathach/tinyusb] New branch created: fix\-build\-lpc177x8x
Describe the PR
LPC177x_8x uses the same driver as 5x_6x and 40xx though it is not tested on actual board due to lack of hardware
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
@hathach Thanks for the sample logs. I'm unable to log, it slows the USB part. I'll try to use DMA or Interrupts to log, maybe that helps. Currently I am purely relying on the trace. Thanks!
I am currently a bit puzzeled how to design the driver in such a way that it can be generalized conviniently for multiple audio functions. Especially the buffers are a bit tricky. Picture the following:
- two audio driver functions i.e.
CFG_TUD_AUDIO = 2 - none uses support FIFOs to keep this easy
- the first uses EP IN but needs an additional linear buffer because
usbd_edpt_iso_xfer()is not available for the target MCU - the second does not use EP's at all but only controls audio eq...
Is it possible to add a cb in audiod_init, where we pass all parameters by a struct ?
Fix for https://github.com/adafruit/Adafruit_nRF52_Bootloader/issues/195.
Addresses race condition between writing SIZE.EPOUT=0 and xfer->data_received flag. Since NR52840 always auto ACKs after DMA completion the code should always wait for data_received to be sure the transfer is complete. This doesn't work when starting a sequence of transfers so timeout and write SIZE.EPOUT in this case. If one could differentiate the start/end of a packet sequence at this level of the code then the...
Describe the PR
Adds alignment to buffers in usbtmc_interface_state_t struct.
Updates the visaQuery.py script for PyVisa module import deprecation and to support Linux.
Additional context
It was found that the CFG_TUSB_MEM_ALIGN attributes were missing from the buffers in the usbtmc_interface_state_t struct. This caused exceptions due to alignment issues on the XCore platform. This addition is untested on other platforms.
Additionally the existing visaQuery.py script was hard...
I am working on a project where we want to replace a computer (the Host) with an STM32 microcontroller. The device uses a standard FTDI USB to serial converter as the main mechanism to communicate between the computer and controller. Instead of using the computer, I want to use STM32F4 as a host to communicate with the device.
STM32 -> USB -> FTDI -> Machine controller
STM32 natively supports USB CDC communication but does not support communication with FTDI chips. On ST website there is an article about an ST partner who developed a commercial USB Stack that supports CDC-FTDI, but since the project is still in an experimental phase I am looking for other alternatives https://www.st.com/en/embedded-software/hcc-usb-stack.html
I would appreciate your expert opinion on this ๐ . Does tinyUSB lib or libopencm3 have support for communication with FTDI chips ?
<@&617066238840930324>
the modificaiton of usbtmc_device.c looks OK to me. Though can you also add the CFG_TUSB_MEM_SECTION to the usbtmc_state as well at line 128
CFG_TUSB_MEM_SECTION static usbtmc_interface_state_t usbtmc_state =
{
.itf_id = 0xFF,
};
For the visaQuery.py changes, I have no idea, @pigrew do you have time to help reviewing this.
yeah, it even has an TODO remove later as well, apparently I plan to remove it. I will check it out later on to see what is best to change.
@PanRe there is no need to support multiple audio functions right with this PR. We can do it later on, Sometimes, a cool-down period is what is needed for a brilliant idea. I have switched back and forth between works. Although It takes a bit of time when revising an unresolved issue, we will have a fresh look at it and could resolve it in a much better/cleaner way (done it multiple times). Just leave it to solve later on if needed. There is already lots of works in this PR :)
I just realized the clock setup for same5x is a bit too low level. I would prefer something more abstract and common for all of these same5x e.g both this and d5035_01 should have a similar. The purpose is to get it run with the stock examples. I have looked at the same54 xplained examples, we should use their init_mcu() in the hpl if it got the job done.
- is
SAME54XPLAINEDPROneeded ad used anywhere, I would prefer not to have it since it will encourage to write board-specific code in application. BOARD_NAMEis nice, we could use it for more specific message. Though I prefer not to include the quote, only the string.
The extra quotes turn the defined value into a proper C string. The C string itself doesn't contain the quotes.
I see your point regarding the board define. I could argue that freeing up a PLL1 is targeted at writing board specific code as well.
I am uncertain what is the best way to proceed here. From the TinyUSB project side I can see a desire to keep the examples board agnostic. From an application developer point of view I want to the stack to be as resource friendly and configurab...
True, but i really would like to come up with an interface or a way to initialize the audio driver which does not need to be changed afterwards. The users would not appreciate this i guess ^^. But if it is too complicated i would leave it as it is.
I have a pretty fancy (but not too dramatic) idea in my mind. All we need would be a way to setup arrays of different sizes by use of the C preprocessor! Given the following declared list
`
#define AUDIO_EP_IN_SZ_LIST (11, 22) // Size in b...
Personally I don't like cascade too many macros, it makes debug and understanding difficult.
How about support a max number of audio functions, for example 3, I believe nobody will use more functions. (Also USB descriptor length limit)
Then:
uint8_t audio_ep_in_sw_buffer_1[CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ];
#if CFG_TUD_AUDIO > 1
uint8_t audio_ep_in_sw_buffer_2[CFG_TUD_AUDIO_FUNC_2_EP_IN_SZ];
#endif
#if CFG_TUD_AUDIO > 2
uint8_t audio_ep_in_sw_buffer_3[CFG_TUD_AUDIO_FUNC_3_EP_IN_SZ];...
I fully understand your approach to have optimum set up for specific board. However, I prefer having a generic even less optimized bsp code. Eventually all same5x boards (d5035_01 and same54 xplained) will be grouped into a family much like samd51/21 when adding new board is simply define pins for LED and Button and/or Uart. This will reduce effort to add and maintain bsp. So that I could have more time to spend on the stack itself. E.g with nrf5x, I will set up the internal RC as clock sourc...
tud_mount_cb is working properly and the led turns on. When I disconnect the device from my computer tud_umount_cb should fire and turn off the led. However the led stays turned on.
void usb_task(void *UNUSED_PARAM(pvParameters)) {
extern TaskHandle_t init_task_handle;
xTaskNotifyGive(init_task_handle);
TickType_t xPreviousWakeTime = xTaskGetTickCount();
for (;;) {
tud_task();
vTaskDelayUntil_bounded(&xPreviousWakeTime, 1);
}
}
void tud_mount_cb(void)
{
HAL...
[hathach/tinyusb] New branch created: cleanup\-make
Thank you for your investigation and PR. I am pulling out the nrf52840 datasheet for further reading and testing. Will try to find an way to best avoid blocking wait if possible.
I don't think that TinyUSB supports hosting an FTDI device
My putting a particular RM DLL path was a bad idea, in retrospect. It was a hacky way for me to get it working on my laptop, and I shouldn't have done it. Also, it may not work for all installs of Windows.
What are your thoughts about if we remove all of the os-detection, and just have a call to:
rm = visa.ResourceManager()
With that, one can create a .pyvisarc with the proper library path based on which VISA library the user wants (if pyVISA's auto-selection doesn't work)?
...
Thanks for raising the issue, you are right that we may have some sort of race condition with data_received. After reading back the nrf usb specs along with going through my own question on devzone https://devzone.nordicsemi.com/f/nordic-q-a/35362/usb-bulk-out-hardware-bug. I think we could have a better implementation, the SIZE.EPOUT[epnum] = 0 seem to be only needed once only. Though since it could affect many other projects, I will spend a bit of more time testing it out. Will post more...
PR is updated to only add the CFG_TUSB_MEM_ALIGN and CFG_TUSB_MEM_SECTION attributes to the usbtmc implementation.
I will log an issue for how the test script is used for it to be handled external to this PR.
The current tmc demo has a script called visaQuery.py that explicitly uses a Windows 64bit dll. Consequently, the current demo cannot be run on other platforms without local changes.
My putting a particular RM DLL path was a bad idea, in retrospect. It was a hacky way for me to get it working on my laptop, and I shouldn't have done it. Also, it may not work for all installs of Windows.
What are your thoughts about if we remove all of the os-detection, and just have a call to:
...
Thatโs my conclusion too, only write SIZE.EPOUT[epnum] once to get things started. I tried that while debugging (by omitting the spin wait in my PR) but ended up in a hung state. From what I could tell it was necessary to kick of the DMA by writing SIZE.EPOUT[epnum] at the beginning of each packet sequence (e.g. for each firmware packet of roughly 512 bytes sent by the host). Anyway, I didnโt try too hard so I was probably missing something else that caused the hang.
@xmos-jmccarthy,
Thanks. I'll create a PR to edit the python script.
@hathach,
I'm happy to merge this PR.
thanks @xmos-jmccarthy for your PR and @pigrew for reviewing it.
could you update your first post to include detail in the bug template. It is mandatory.
I am suprised to learn that you are not interested in BSP performance. It is my estimate that there are quite a few folks out there that will experience their respective board's performance by means of running the TinyUSB examples. Not all of them might have the technical background to realize that if performance is bad, it might not the USB stack's or the board's fault but simply due to the way the board was set up.
However, given your statement, I don't think this PR is useful to the Tin...
I am suprised to learn that you are not interested in BSP performance. It is my estimate that there are quite a few folks out there that will experience their respective board's performance by means of running the TinyUSB examples. Not all of them might have the technical background to realize that if performance is bad, it might not the USB stack's or the board's fault but simply due to the way the board was set up.
It is not up to this repo to get the performance out of BSP. Also the B...
this seem to be legit changes, it should be UART instead of SPI
this seem to be legit changes, it should be UART instead of SPI
this seem to be legit changes, it should be UART instead of SPI
[hathach/tinyusb] New branch created: fix\-nrf\-dcd\-bulk\-out\-race
Describe the PR
related to #723, fix issue raised by adafruit/Adafruit_nRF52_Bootloader#195.
- NRF_USBD->SIZE.EPOUT[epnum] only need to write once to enable Bulk/Interrupt transfer. We only need to do it in dcd_edpt_open() and dcd_edpt_clear_stall()
- Separate Control and Bulk/Int OUT hanlding
- Some minor comment and clean up
@khpeterson I have tested and tried it with your dfu file. Seem to work well without blocking wait. Would you mind trying this out.
[hathach/tinyusb] New branch created: feather\-rp2040\-correct\-bootstage2
Describe the PR
Get examples to run on Adafruit Feather RP2040
- also use boot2_generic_03h for now for itsy bitsy and qt rp2040
- change default flash target for rp2040 to flash-pyocd
Running repeats successfully for an hour now - looks good to me. Good job on the quick fix.
I am looking to your final number. Btw, the race condition probably get worse with the zero length packet. CDC host driver normally will send ZLP when all data is sent and is multiple of 64 (endpoint size). Hope we finally fix the issue.
OK, I will run my repeat script overnight tonight and send you the result tomorrow morning.
On Mar 18, 2021, at 10:26 AM, Ha Thach @.@.>> wrote:
Running repeats successfully for an hour now - looks good to me. Good job on the quick fix.
I am looking to your final number. Btw, the race condition probably get worse with the zero length packet. CDC host driver normally will send ZLP when all data is sent and is multiple of 64 (endpoint size). Hope we finally fix th...
1 hours is good enough for me, don't leave it running too long, it could degrade your nrf flash
We were testing midi on feather m7 rt1011, and @ladyada noticed that if MIDI was being sent out but not acted on by CIrcuitPython, "bad things happened". On Linux this manifested as being unable to ctrl-c in the REPL and getting messages in the kernel log: sound midiC4D0: rawmidi drain error (avail = 3934, buffer_size = 4096). Would probably need to throw out some data if buffers fill up? discarding is better than crashing
Maybe this is the wrong place for me to ask - but I'm having some problems setting up a HID device that also has a WebUSB interface for configuring it. I can't get them both working at the same time - do I need to set it up with multiple configurations or something?
yeah, we kind of needing a way to drain the midi buffer. However as notice by MIDI user in #618 , dropping data will cause issue with sysEx message rendering the driver unreliable. In practice, it is rare to have MIDI user that only receive data and do nothing with the data, possibly only happens with test example.
OK, just finished a little more than 1 hour of repeats - 110 trials, no failures. Looks good to me
On Mar 18, 2021, at 10:31 AM, Ha Thach @.@.>> wrote:
1 hours is good enough for me, don't leave it running too long, it could degrade your nrf flash
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/hathach/tinyusb/pull/733#issuecomment-802148062, or unsubscribe<https://github.com/notificatio...
@khpeterson thank you very much for testing and raising this very hard to catch issue :+1:
closed in prefer of #733 with non-blocking approach. Thank you very much of raising the issue
thats ok but it should not take down entire USB subsystem :D
perhaps it can release unlistened packets?
@ladyada hmm, taking down entire stack is not nice, maybe it got some assert() and hanged. I will check it out.
yeah our imx board stopped responding altogether
Describe the PR
This PR adds board-specific code for the STMicro STM32F072-EVAL and STM32072B-EVAL boards.
It is an edited version of the stm32f072disco code, changed for the (slightly) different MCU and hardware.
Additional context
The clock is set up to use the internal RC (HSI48).
Set Up
- PC OS Windows10 Pro version 1909
- Board imxrt1020_evk (note that issue seems like it would occur regardless of Board type)
- Firmware examples/device/cdc_msc with the following modification:
Replace cdc_task with the following code to allow triggering of writes greater than CFG_TUD_CDC_TX_BUFSIZE
//--------------------------------------------------------------------+
// USB CDC
//--------------------------------------------------------------------+
ui...
Thanks for detail report, please put all code in the triple quote following C '```C' . Also can you run your test with the LOG=2 then post your LOG here as well.
I have changed to board startup code to use the internal oscillator. This runs the CDC MSC examples and the board test code.
The previous clock setup function is still in there for reference.
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
@hathach I need some help in the following:
-
The device seems to enumerate fine on my PC. Can you please test it at your end and see if the enumeration is going as expected?
-
I see a few checks are failing, I did add
DEPS_SUBMODULES += hw/mcu/tibut ithe CI builds are still failing.
Original bug report updated to specify "C" language for code fragment. Rebuilt with LOG=2 and here is the resulting log:
USBD init
CDC init
MSC init
USBD Bus Reset
USBD Setup Received 80 06 00 01 00 00 40 00
Get Descriptor Device
Queue EP 80 with 18 bytes ... OK
USBD Xfer Complete on EP 80 with 18 bytes
Queue EP 00 with 0 bytes ... OK
USBD Xfer Complete on EP 00 with 0 bytes
USBD Setup Received 00 05 07 00 00 00 00 00
Set Address
USBD Xfer Complete on EP 80 with 0 ...
So I didn't have time to test this until now, I'm only now trying.
I'm having a weird, unexpected issue, my device is hitting a HardFault on tusb_init I debugged the project and it seems to be failing at:
// Init class drivers
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
{
usbd_class_driver_t const * driver = get_driver(i);
TU_LOG2("%s init\r\n", driver->name);
driver->init();
}
because it tries to jump to init() on iteration i=1 but `init(...
Board: stm32f411blackpill
OS: Ubuntu 20.04
Dmesg output:
[ 346.364923] usb 3-2.3: New USB device found, idVendor=cafe, idProduct=4002, bcdDevice= 1.00
[ 346.364929] usb 3-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 346.364932] usb 3-2.3: Product: TinyUSB Device
[ 346.364935] usb 3-2.3: Manufacturer: TinyUSB
[ 346.364937] usb 3-2.3: SerialNumber: 123456
[ 346.383946] usb 3-2.3: can't set config #1, error -32
sudo lsusb -d cafe:4002 -v
Bus 003 Device 01...
Ok, I was unable to figure out why this looped more than once,
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
{
usbd_class_driver_t const * driver = get_driver(i);
TU_LOG2("%s init\r\n", driver->name);
driver->init();
}```
but i forced it to loop once (i < 1) and after chasing some gremlins with clocks the device enumerated successfully!
I have ordered a sltb009a efm32gg12 dev board from mouser which i will port and then i think we ca...
Set Up
- **Raspberry pico-sdk 1.1 with
cdc_device.zip
tinyusb @ 11c23f8**
- Raspberry Pico
- src/class/cdc/cdc_device.c
Describe The Bug
cdc_device.c throttles serial data if DTR is false
ESP32, flashing tools such as esptool.py assume no flow control and use DTR and RTS to reset ESP32 and put it in flash mode.
When e g Raspberry Pico is used as a USB to serial converter to ESP32, the cur...
thank you, it is great to hear to get it working. If you could make an bsp for the board I have, that would be great, otherwise no problems at all, I found EFM32 dev board is rather expensive as well ( got it as freebie from energy micro a long time ago). I have also ordered sltb009a as well since that is probably most people will buy anyway. Looking forward to your PR.
try to fill out the bug template, put code in the quote, and provide enough information to reproduce then you could open the issue
Thanks for your information. There was actually a talk about ESP32 flashing before starting here.
CDC already changed that it's possible to receive and transmit data even if DTR bit is not set. The tud_cdc_n_connected API still checks this bit because some application might require a real terminal connection to be detected. That's why it should be kept within this function.
I guess in your case you just do not have ...
it is already optional, have you tried the code at master instead of the one come with pico-sdk ?
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
Great news to hear that you got it working. I will try to test it out as soon as I could. As for the ci, a quick glance doesn't give me idea why it wouldn't link. Maybe there is some issues with make. I will also check it out when testing out your work. Thank you very much again.
Great!! Thank you for your hard work, sorry if my goal is not toward bsp but maintaining optimum.
I moved log to its own file since it is too long to post here. I will try to look at the log for analyzing. If you are also troubleshooting it, you could try to comment out the msc descriptors (also update total length), it would be less log to analyze. Or maybe try out the cdc dual ports example,
Do you have any input into the // Init class drivers issue? I didn't figure it out I just overwrote it
Do you have any input into the
// Init class driversissue? I didn't figure it out I just overwrote it
hmm, can you log print the value of TOTAL_DRIVER_COUNT, it shouldn't have any issues, maybe there is some buffer overflow
It apparently resolves to 92
_app_driver_count is 91
hm, i think this is an initialization/startup issue, that variable is not cleared as it should, i tried to use silabs startup, gotta look at it
figured it out, by default silabs startup doesnt clear bss, i had to define __STARTUP_CLEAR_BSS, now _app_driver_count is 0, like it should.
I imagine this was causing issues in other places as well
figured it out, by default silabs startup doesnt clear bss, i had to define __STARTUP_CLEAR_BSS, now _app_driver_count is 0, like it should.
Yeah, I am glad we could figure it out, this probably causes lots of headache across the stack for sure.
[hathach/tinyusb] New comment on pull request #670: WIP : Adding Tiva C \(ek\-tm4c123gxl\) support\.
@hathach It's not completely working right now, I have only put in code for the Control Endpoint. I will be adding code for all other endpoints as well. Thanks for the help :)
Ok I have now tested a couple different examples, all without issues after enumeration, but there is one common issue, every time after initialization the devices times out
[ 5845.144641] usb 3-4.3: USB disconnect, device number 25
[ 5889.104950] usb 3-4.3: new full-speed USB device number 26 using xhci_hcd
[ 5904.562516] usb 3-4.3: device descriptor read/64, error -110
[ 5904.767196] usb 3-4.3: New USB device found, idVendor=cafe, idProduct=4004, bcdDevice= 1.00
[ 5904.7672...
please add the following line, that will help to fix the CI. I have tried may the build to fetch needed submodules (if not already) without user have to do it manually or init it all.
DEPS_SUBMODULES += hw/mcu/silabs/cmsis-dfp-efm32gg12b
Superb !! That is really great to hear Don't worry if you couldn't fix it for now. I think it is already more than enough to wrap up this PR. I am still waiting for the sltb009a to delivery (probably in 2,3 weeks since I am so back ordering other boards as well). I could help to troubleshoot it afterwards with follow-up PR ( just make sure we have an issue for it so that we don't forget). I am actually quite familiar with these kinds of problems with enumeration.
@PanRe I try to test with the plot python script but look like soundevice does not detect device on my Linux. There is no need for you to look at this, I will pull out a windows machine to test with. Just curious to see if I miss something.
ValueError: No input device matching 'Microphone (MicNode) MME'
I try to list it but it doesn't seem to be detected. Maybe I miss something, it does appear in my ubuntu as input device (microphone) though :thinking: :thinking:
$ p...
@PanRe I try to test with the plot python script but look like soundevice does not detect device on my Linux. There is no need for you to look at this, I will pull out a windows machine to test with. Just curious to see if I miss something.
ValueError: No input device matching 'Microphone (MicNode) MME'I try to list it but it doesn't seem to be detected. Maybe I miss something, it does appear in my ubuntu as input device (microphone) though ๐ค ๐ค
``...
did some minor cleanups, and removed the code for the board support, will create a seperate PR with it
Board support for the EFM32GG12 Dev Board
For use with the efm32 family driver added in #703
Ok I have now tested a couple different examples, all without issues after enumeration, but there is one common issue, every time after initialization the devices times out
[ 5845.144641] usb 3-4.3: USB disconnect, device number 25 [ 5889.104950] usb 3-4.3: new full-speed USB device number 26 using xhci_hcd [ 5904.562516] usb 3-4.3: device descriptor read/64, error -110 [ 5904.767196] usb 3-4.3: New USB device found, idVendor=cafe, idProduct=4004, bcdDevice=...
Describe the PR
The Cortex-M0+ (Arm architecture 6M) also supports the
DHCSR.C_DEBUGEN bit (bit 0) to tell whether a debugger is attached.
This PR adds that architecture to TU_BREAKPOINT().
Additional context
If applicable, add any other context about the PR and/or screenshots here.
have you tried it on actual hardware. I could be wrong, but I remember both m0 and m0+ doesn't support bit.
CoreDebug on M3
https://github.com/ARM-software/CMSIS_5/blob/b7b26f50d00072812aec8453f643e24bafedccb5/CMSIS/Core/Include/core_cm3.h#L1384
please add the following line, that will help to fix the CI. I have tried may the build to fetch needed submodules (if not already) without user have to do it manually or init it all.
DEPS_SUBMODULES += hw/mcu/silabs/cmsis-dfp-efm32gg12b
It looks perfect now. I could merge it unless you want to add/update the PR more.
Which mcu you have tested this on. I could be wrong, but I remember both m0 and m0+ doesn't support bit.
Actually, I think you're right. I was misled by the Arm architecture docs.
Ok, but isn't memcpy optimized anyway since it has constant 4 bytes to copy?
I refactored the code for handling the wrapping case as there the number of bytes to copy is not constant.
I see your point. Since dst_u8 is not word-aligned the compiler is not always willing to optimize memcpy out, for example in IAR I have to use highest optimization or it just call __aeabi_memcpy. There is __attribute__((__packed__)) for this kind of stuff.
You can do something like this:
typedef struct{
int i;
} __attribute((__packed__)) unaligned_int_t;
unaligned_int_t* dst = (unaligned_int_t*)(f->buffer + (wRel * f->item_size));;
dst->i = *rx_fifo;
There i...
Fany ^^ But it works, i implemented it and pushed the changes. I hope the CI runs through ^^ Thanks for advice!
@HiFiPhile I don't like this change, this complicate the code more than it should be. How much overhead we are talking about here. I am more concerned about the overhead in our time to process this command in our thought though.
@hathach
this complicate the code more than it should be
I don't see it complicate the code, it's a quite common way to do unaligned copy.
How much overhead we are talking about here
Unless I set optimization to high (which cause problem in step by step debugging), IAR generate this code and it stays for 43 cycles inside __aeabi_memcpy4 on my STM32L412.
ADD R0,SP,#+20
ADR.W R1,?_0
MOVS R2,#+16
CFI F...
You are right, 43 cycles for a word is indeed quite a lot considering we are doing hundreds of this. And a bit of googling, also suggests it is common to address this. It is my bad. Though maybe we should declare it as global typedef for these to reduce duplication (could do this). btw do you think having these align would work instead of using packed struct ?
typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
typedef uint32_t unaligned_uint32_t __attribute__ ((ali...
superb ! merged now, thank you very much.
ah right, it is probably need to have the #703 merged first (and/or) update/rebase aftewrads.
#703 is merged, could you rebase/erge from master to see it could fix the ci.
Mh interesting... i did not test it on linux. You may try the default device i.e. skip
device=device. If it is the only input device than it should be the correct one!
Thank you very much, I will try it out, have to switch to other task to support a coming soon board for iMXRT https://www.adafruit.com/product/4950 . I will test this out again this weekend.
Just a short noticy, i found a bug which i fixed but did not push so far: please select the fifo buffer size to equal the EP...
ah right, I almost forgot about this issue
The silabs cmsis has both a assembly startup and a C startup, on the same dir, for some reason this generates some conflict (im only including the assembly startup), the only way i got this to work was by deleting the c startup
Unfortunately it's not work without struct, gcc simply ignored __attribute__ ((aligned(1))), I've also tried IAR (IAR now support most gcc syntaxes).
In IAR I can simply do dst = *(__packed uint32_t*)(f->buffer + (wRel * f->item_size)); but there is no packed pointer in gcc.
If src is not volatile shift + or and packed struct generate nearly the same code, on ARMv6M:
#Shift + Or
ldr r0, .LCPI0_0
ldrb r1, [r0, #5]
lsls r1, r1, #24
ldrb r2, [r0, #6]
lsls r2, r2, #16
...
I don't really understand this issue
[perigoso@perigoso-desktop hid_generic_inout]$ make BOARD=sltb009a print-SRC_C
SRC_C = hw/mcu/silabs/cmsis-dfp-efm32gg12b/Device/SiliconLabs/EFM32GG12B/Source/system_efm32gg12b.c src/portable/silabs/efm32/dcd_efm32.c hw/bsp/board.c hw/bsp/sltb009a/sltb009a.c examples/device/hid_generic_inout/src/main.c examples/device/hid_generic_inout/src/usb_descriptors.c src/tusb.c src/common/tusb_fifo.c src/device/usbd.c src/device/usbd_control.c src/class/aud...
I think this might be some oversight on the buildsystem
to clarify
the issue here is that there are two files named the same in the silabs cmsis, one in C and the other in assembly
hw/mcu/silabs/cmsis-dfp-efm32gg12b/Device/SiliconLabs/EFM32GG12B/Source/GCC/startup_efm32gg12b.S
hw/mcu/silabs/cmsis-dfp-efm32gg12b/Device/SiliconLabs/EFM32GG12B/Source/GCC/startup_efm32gg12b.c
the only file being included is the assembly one, and thats the only one we want to compile, but it seems the pro...
Thank you for your extra information. I have learned something new (still learn new thing with C every now and then). Using memcpy to replace shift-or is my bad. We have inline helper, maybe we can put them into usage here
https://github.com/hathach/tinyusb/blob/master/src/common/tusb_common.h#L85
I am still prefer doing thing more explicit than leaving it to compiler, especially if it is not too obvious. I really need to wrap up the review and merge this PR asap :sweat_smile:
Yes we can use the inline version.
We only intended to support 32bit little endian systems I think?
Well, take your time ^^. The more i do on generalizing this driver for multiple audio functions / audio streaming (AS) interfaces / alternate settings of AS interfaces, the more demanding this design gets... i will need some time more! I will find a way to not overcomplicate the design.
The generalization is finished in case no support FIFOs and encoding/decoding is required. I fixed it to three audio functions maximum available. Anyway, i want the support FIFOs and encoding/decoding include...
Please review. I have some final testing to complete, and then some additional cleanup I would like to do. I attempted to best follow the existing structure and styling. Please let me know if anything is misplaced, desired debug missing, or any other general hygiene issue.
Describe the PR
This PR completes the DFU Class, resolving feature Issue #29. It extends the prior DFU Class stub, which implemented only a DFU RT detach flow.
Additional context
The class has been valid...
GD32VF103 (RISC-V from GigaDevice) is also using the same driver, in fact I was able to run TinyUSB just by copying stm32f1_fsdev driver plus some structs/defines from stm32 libraries - no changes at all :)
I've identified the issue I believe, in rules. Mk.
Can I make some minor changes in the buildsystem?
Buildsystem does not allow a c and assembly source with the same name, where only one is supposed to be compiled.
I found this issue while trying to implement an example for the efm32 family in #749.
The Cmsis provided by silabs as both a c implementation and an assembly implementation for the startup, only one should be compiled, but the buildsystem right now tries to compile both, regardless of which is included.
I have followed up the issue and think it is in rules.MK where b...
Needs #755 fixed for successful build
@HiFiPhile ah you are right, there is also native mcu endian matter as well, maybe it is better this way. I will go through fifo.c again later on to see what is best suited for. Thank you for bringing this up :)
Describe the PR
Add support for GR-CITRUS as a USB device. A distributer for the board is corestaff, and the site is corestaff online.
Additional context
This PR needs following tools.
- [GCC for Renesas 8.3.0.202004-GNURX](https://gcc-renesa...
For info we can do it like zephyr for GCC, https://github.com/zephyrproject-rtos/zephyr/blob/65ac2f6d1bf9570da68b2da30e769aab2f39b7c2/include/toolchain/gcc.h#L102
I will take care of IAR :)
Describe the PR
A proposition for unaligned access macro.
Then we can refactor unaligned accesses, for example:
uint16_t total_len;
// Use offsetof to avoid pointer to the odd/misaligned address
memcpy(&total_len, (uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength), 2);
Into
uint16_t total_len;
TU_UNALIGNED_GET(total_len, &desc_bos->wTotalLength, uint16_t);
Additional context
It should works on TI compiler, need test.
This makes it possible to setup Mynewt project which checkouts
specified version of tinyusb.
thank you for your PR, it looks good. However, I think this shouldn't be part of the compiler. I am thinking to have an typdef for tu_unaligned_uint32_t then using static inline function for the assignment. I will make an PR to demonstrate the idea.
Superb ! brilliant works, thank you very much for your PR. Too bad that it seems like renesas boards is hard to find and very expensive as well. Therefore I couldn't perform any hand-on tests any will merge this as it is. Which looks really good, except for
- maybe move the submodule from renesas to
renesas/rx63to allow as more families later on - I wonder if rx63n freertos start scheduler would return at all ?
once the submouldes is moved, I could help to fix the ci.
I am not familiar with RX63X, but should the vTaskStartScheduler() never returns
since renesas has multiple families, maybe we should include it as hw/mcu/renesas/rx , that will allow us to add more families from renesas later on (if ported).
Thank you very much for your detail instruction of board usage. Too bad, I couldn't find it in local/online store. Since there is a bit of extra works with the board. It would be better to put this summary work into the gr_citrus.c as comment, it would probably help us in the future.
[hathach/tinyusb] New branch created: fix\-755\-same\-name\-c\-s\-file
this is indeed tricky, maybe we could auto add suffix _asm or _s into the object file of .S file in the rule.
https://github.com/hathach/tinyusb/blob/master/examples/rules.mk#L55 . I will also try to make an PR to fix this as well
Describe the PR
Fix #755 where there is .c and .s with the same name in the same folder.
[hathach/tinyusb] New branch created: kkitayam\-add\_support\_for\_gr\_citrus
thanks for confirmation that the stack work with gd32vf103, I also have this board in my drawer as well. Will put it into the official board later on when having time. However, fsdev driver is totally different than the synopsys one mentioned in this issue.
thanks for confirmation that the stack work with gd32vf103, I also have this board in my drawer as well. Will put it into the official board later on when having time. However, fsdev driver is totally different than the synopsys one mentioned in this issue.
Sic, it seems that my reading skills are failing me. Sorry for making mess. Should I remove my comment?
@kkitayam I have fixed the ci issue caused by lacking the gnurx toolchain. Since rx63n has its own toolchain, it is best to move it into a family (currently with its own board). This is done by simply add the family.mk that include the board.mk. The build command is exactly the same as before make BOARD=gr_citrus. This allow us to run a seperate ci job that cached the gnurx toolchain for rx63n family only. This is push toward your branch already, please fetch/pull first before making additi...
no problems at all, I have no issues with your comments. At least it provide information that it does work with the gd f103 risc-v :)
Set Up
- Ubuntu 20.04
- STM32F072-EVAL board
- Firmware: custom app with just CDC, sending 22-byte messages as fast as possible. Using RTT for logging.
- app waits until host connection before sending anything.
Describe The Bug
After 154 characters are sent successfully (7x22 byte messages), tud_cdc_write() returns 0 bytes written when 2 were requested.
The immediately prior tud_cdc_write() of 22 bytes returned 20 bytes written.
When tud_cdc_write() returns 0 bytes...
Hm i was going to go with a different approach, essentially making two different object lists, i think that would be prefered instead of renaming the objects, i will do a PR in a bit, you can then choose what you prefer, i think your approach would fix either way
my dev board arrived today, will test this tomorrow
You PR looks goog! I just tested it and got a successful build.
looks good, ci is ok, and I tested locally with the problematic board and all worked as expected.
thanks for confirmation, merge now
great work as usual, please give me a bit of time, I will try to review it asap ( in the middle of something else :sweat_smile: )
there is no way for others to reproduce this issue since it is custom app. Please try to have minimal modification to the existing stock example and post your changes here.
I agree, this is not a bug. I stated it badly (clearly one can't transmit at infinite speed).
Sorry to bother you.
My problem is that the overall CDC transmission throughput (in my app that acts as a CAN-to-slcan gateway) is not high enough in practice to keep up with messages being sent rapidly on a 250kbps CAN bus, though I had hoped that it would be.
I've added code to check FIFO space using tud_cdc_write_available() and drop packets if not enough space is available.
Perhaps double-b...
you probably miss the freertos header include for the efm https://github.com/hathach/tinyusb/blob/master/hw/bsp/board_mcu.h . It is not too obvious and well-placed currently. I plan to refactor it later on
[hathach/tinyusb] New branch created: add\-more\-hid\-key
Describe the PR
Add more hid keys
Additional context
https://github.com/adafruit/Adafruit_TinyUSB_ArduinoCore/pull/23
try to increase both CFG_TUD_CDC_EP_BUFSIZE and CFG_TUD_CDC_RX_BUFSIZE, CFG_TUD_CDC_TX_BUFSIZE to see if it is improved.
Thanks for your attention. I don't think it'll be necessary to do that.
It turns out that what was happening was that there was not quite enough space for a whole message.
I added a check of tud_cdc_write_available(), and if that said that there wasn't enough space for a whole message, I did a tud_cdc_write_flush().
That fixed the issue!
You are right. The vTaskStartScheduler() never returns. I'll remove the reutrn 0 statement.
I had made the following misunderstand. In the function prototype of the main(), the return type is int. To match the type, I thought enabling return 0 is in a well mannered way.
However, after some googling, I found out that the main() can omit the return statement.
It is shown in https://stackoverflow.com/a/2890894
Thank you for pointing this out. I think you're right. I'll move the submodule.
actually, I think we could still keep the return 0; for all cases, it is probably my bad. This should be best
#if CFG_TUSB_MCU != OPT_MCU_ESP32S2
vTaskStartScheduler();
NVIC_SystemReset();
#endif
return 0;
The version of tinyusb pinned for pico-skd 1.1 stops communication when DTR is low, which causes problems with mcu flashing tools such as esptool. The current version at https://github.com/hathach/tinyusb works with the same mcu flasher tools, provided that tud_reay() is used instead of tud_cdc_n_connected(itf)
Okay, I understood to keep the return 0 statement. So, I should no need to update for this part, right?
Since NVIC_SystemReset() is not available for RX family, I added #if CFG_TUSB_MCU != OPT_MCU_RX63X. If you mind the ifdef, I will add a dummy macro or function to a somewhere header to eliminate ifdef.
hah, I just realized that rx63n doesn't have NVIC_SystemReset() , we can actually remove it since scheduler start does not return at all. I will remove it :)
Excellent ! It is perfect now, thank you very much for your effort. Great PR as usual, I am happy that we could get the first family from renesas ported :+1: :+1:
I just tested the dev board and the board support code i wrote works :)
I have not tested the buttons or implemented uart, but the devices enumerates and theres visual feedback from the leds
If everything looks good to you you can merge, feel free to request changes
[hathach/tinyusb] New branch created: enhance\-midi
Describe the PR
Fix #735. should also fix root cause of #377 . should also fix issue with https://github.com/adafruit/circuitpython/issues/4190
Root cause of the issue is TX fifo is overflow, though it is not handled safely by driver, which cause the data corruption to the usbd device control and cause the system to crash/hardfault. While fixing the issue, I have go through the whole improvement, including
- Adding MIDI_CIN_ and MIDI_STATUS_ instead of using magic number in stream API...
[hathach/tinyusb] New branch created: update\-doc
Describe the PR
Update doc to reflect
- PR #703 EFM32 port thanks to @perigoso
- PR #757 Renesas rx63n port @kkitayam
Thanks for the update, I am sure this will help others
Ok guys the redesign is ready for review! I fixed it to 3 audio functions as discussed before. Because of this, there are a lot of #defines etc. to enable only the needed buffers etc. So please don't be shocked of this, it is the best we can do with the limited capability of the C preprocessor etc.
Please start with the audio_device.h as from there i hope the strucuture of the driver gets clear.
There are some "fast copy" functions, i leave them for @hathach to reformat to his prefered wa...
Describe the PR
Fixed very slow implementation. Symptoms are that the USB transfers take more and more time, then become fast again as the index (uint16_t) wraps around
I appreciate the fact that some MPUs don't have a hardware divide, so I provided a fast path if the fifo depth is a power of 2.
thank for the pr, could you provide the before and after timing measurement based on your test setup. It is not clear to me how much it is boost the performance here.
Thank you very much for your PR. Sorry for late review, I haven't fully go through it yet. Though there is one thing I spotted. Since DFU mode & runtime is mutual exclusive. I would like to have it as separated driver. So that application that enable the rutnime does not need to also include the DFU mode which require more RAM & ROM. Could you separate the dfu functionalities into dfu _device.h/c, we will leave the dfu_rt code as it is (common enum/typedef move to dfu.h is spot-on)
@PanRe superb!! Thank you very much, I will try to review and hopefully we could wrap it up asap :tada:
after revising the code, I think software double buffering is implemented in the form of fifo. Hardware double buffering on dcd is currently not implemented, since it often needs to use 2 endpoint e.g 1 IN + 1 OUT for an double buffer OUT. currently stack does not support dcd specific option. I will close this issue for now, feel free to open new issue when there is new information.
I have implemented a JTAG probe that receives over 6500 USB packets to program a FPGA. During my tests the wall clock programming goes from 2.5s to 4.5s as I repeat the programming and then goes back to 2.5s at the 10th programming and the cycle repeats. My fifo depth is 64, so mod will loop a 1000 times in the worst case. After the fix, the wall clock time is stable at 2.4s
This is on a Raspberry pico board.
Thanks,
Patrick
From: Ha Thach @.***>
Sent: S...
By the way, it I pulled my hair for a while before discovering the root cause of the slowdown. I donโt know how to profile code on a Cortex-M0+ so I had to convince myself that it was communication problem first (using a LA I saw that the JTAG output was normal, except the programming bursts were more and more spaced out). I then looked at the state of my USB interface for the first time and for the 9th time. I noticed that the read and write pointers were super large on the 9th time. That su...
Could you separate the dfu functionalities into
dfu _device.h/c, we will leave the dfu_rt code as it is (common enum/typedef move to dfu.h is spot-on)
I will separate out class functionality of DFU mode from RT.
I made a few commit to comment out the dcd_edpt_xfer_fifo() the implementation for other ports except stm32 synopsys. I spotted a few untested code and a couple of issue with hardware fifo e.g in samg although it also use fifo its 32-bit register is written in bytes fashion, and nuc505 also has some odd issue with word and byte access as well. Therefore I think it is best to just on stm32 which is what we use to test this PR. dcd_edpt_xfer_fifo() is optional, I could do other ports in ...
Could you separate the dfu functionalities into
dfu _device.h/c, we will leave the dfu_rt code as it is (common enum/typedef move to dfu.h is spot-on)I will separate out class functionality of DFU mode from RT.
Thanks, I will do more review this week, need to pull out the DFU specs, kind of forgot it entirely ~.~ . This will be very helpful to bootloader project like https://github.com/adafruit/tinyuf2 . In fact, I will probably use tinyuf2 to test out this PR, since the flas...
Thank you for detail explanation, hmm, somehow I remembered the while loop only need to do it maximum twice. Maybe many things has changed (my memory is fading). @PanRe since we use fifo as main buffering for audio/iso transfer, we don't have the option to go power of 2 only right ?
Could you also print out the idx value at the 1st and 9th, I am curious to see what is its value at that time.
please keep the previous while() loop, the modulo take lots more time than while minus.
That is very interesting as the while loop is to be executed twice at maximum! The fifo was designed not to need more that that and the while loop was only used to keep it general (in the first PR i did not use the while loop, rather two subtractions but @hathach prefered the while loop).
Could you check the values of idx when the slow-down happens? And depth also?
a bit of update with testing, the plot work well using default device on ubuntu, more testing on the way

Restricting to power of two was never an option for you as i remember ^^. It would simplify a lot of things, however, restricting to a power of two length is a hard limit and not very practical for audio applications... i would not do it unless there is a serious bug we can not solve otherwise!
yeah, I remembered that. It is actually better to have arbitrary depth, that will allow us to fit the stack on memory constraint memory. Thanks for reminding, I need more SRAM for my brain !!! :sweat_smile: :sweat_smile:
I made a few commit to comment out the
dcd_edpt_xfer_fifo()the implementation for other ports except stm32 synopsys. I spotted a fewuntested codeand a couple of issue with hardware fifo e.g in samg although it also use fifo its 32-bit register is written in bytes fashion, and nuc505 also has some odd issue with word and byte access as well. Therefore I think it is best to just on stm32 which is what we use to test this PR.dcd_edpt_xfer_fifo()is optional, I could do other ...
When you are doing so, please give all the variables of the fifo e.g. non_used_index_space etc.!
That i have to admit is true! When i wrote those, i was not aware of the hardware restictions... I would just not forget to implement those and do that in time before we forget how to implement them ^^.
yeah, those commented out code you have written is very useful. I only needs a bit of testing and tweaking to work with the unique hw fifo behavior of each MCU. We will do it later on :)
In time, i will provide another audio example where the software encoding for two I2S streams i.e. 4 channels is used!
[hathach/tinyusb] New branch created: unaligned\-access
Describe the PR
Alternative to #758 but prefer to using static inline instead of macros. Also take into account that ARMv7, v8 (M3-M7 , M23-M33) can do unaligned access natively.
@HiFiPhile @PanRe this is what I had in mind in previous discussion regarding unaligned access. Let me know what you think.
I guess @HiFiPhile knows more of this topic but in any case, could you provide an unaligned access to int16 too? This is required for fast half word copies in the audio encoding/deconding! Thanks :)
Make sure you use this repo master for testing instead of the fork in raspberrypi repo. If not then switch branch and try again
Hmm,he may use the old code fron raspberrypi fork. There is a bug fix regarding fifo used in pico
With a quick looking it should work :)
With IAR there is a little inconvenient is with inline function I can't disable Warning[Pa039]: use of address of unaligned structure member.
So we need to continue to use (uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength) instead of &desc_bos->wTotalLength.
I think i know... maybe. There is a bug in fifo.c which i fixed within #593. In line 564 the command else if (count > f->depth) is wrong! It should be else if (n >= f->depth). This would explain why he needs exactly double the time at some iterations! This is a bug which I verified when i worked on #593! You may try this! :)
With a quick looking it should work :)
With IAR there is a little inconvenient is with inline function I can't disable
Warning[Pa039]: use of address of unaligned structure member.
So we need to continue to use(uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength)instead of&desc_bos->wTotalLength.
can the pragma suppress be added into the inline ? we can have temporarily add that for now and find an better/general way later on.
I guess @HiFiPhile knows more of this topic but in any case, could you provide an unaligned access to int16 too? This is required for fast half word copies in the audio encoding/deconding! Thanks :)
Yeah, I was initially want to add 16-bit version, but put it off since I am not sure if we would use it at all. Though since there are all inline, there is no generated code if not used. So here it is
With __attribute__((always_inline)) the warning can be disable using pragma:
__attribute__((always_inline)) static inline uint32_t tu_unaligned_read32(const void* mem)
{
_Pragma ("diag_suppress=Pa039");
tu_unaligned_uint32_t const* ua32 = (tu_unaligned_uint32_t const*) mem;
return ua32->val;
_Pragma ("diag_default=Pa039");
}
Without always_inline sometimes IAR don't like to inline the function especially in low optimization, the pragma doesn't work since the warn...
@HiFiPhile I added the TU_ATTR_ALWAYS_INLINE, and applied it to basic inline function. Though I don't like to suppress and unsuppress it here. It makes code look less readable, also not all unaligned access need to suppress this e.g uint8_t/void. I am fine with the offsetof() at the caller.
#ifdef __ICCARM__
#define IAR_PA309_SUPPRESS _Pragma("diag_suppress=Pa039")
#define IAR_PA309_UNSUPPRESS _Pragma ("diag_default=Pa039")
#else
#define IAR_PA309_SUPPRESS
#define...
closed in favor of #772
_tu_fifo_write() is rather misleading, should be read to const_dst, although it is already write to that address, this is called within the tu_fifo_read(), should be named in consistent with the data direction from/to fifo. I will do the rename.
Jep, true... this comes from coding in the middle of the night ^^. It should be read_to_const() and write_from_const()
@PanRe no worries, I am renaming as well as applying the new tu_unaligned_write32/read32(). Seem to work well with stm32f4 (ofc since it is M4).
The idx value is 62 the first time and 65472 on the 9th time. As I said, with the version I debugged the idx only grows until it wraps around.
the depth is 64.
It seems that your intent was to bound the idx (read and write) to 2*(_depth)-1. It isn't the case, at least on the pico branch. the read and write values are only ever incremented and they eventually wrap around their max uint16_t values.
So the real correct fix would be to clamp their values to their mod depth.
Ah thats it... ok i don't know the pico branch but the FIFO was designed as you mentioned it above!
@PanRe : I don't think your PR fixed this. The read pointer and the write pointers are not limited. Your PR will make the write pointer be equal to the read pointer but it does not limit the read pointer. The root cause if that the function _tu_fifo_correct_read_pointer is not called if cnt is not higher than the depth. For my case it is never true. Somewhere, there needs to be a check that the read and write pointers are not greater than their max values, regardless how many bytes are writt...
Do you use the master branch? Because there in advance_pointer() or here the pointers are limited to the mentioned maximum!
The fix i mentioned before fixes a different bug ^^
This code is identical on the pico branch
It seems that in the pico branch at least, max_pointer_idx and non_used_index_space get ovewritten to 0 after being initialized to the right values. I need to track this down further.
I will let you know what I find.
@phdussud please try again with the master branch, as mentioned above, there is relevant fixed for this exact queue issue for pico.
Ok. The problem isn't with the vendor fifos but with _usbd_qdef which isn't correctly initialized. The fifo that is embedded in the _usbd_qdef has its max_pointer_idx and non_used_index_space left to 0.
//--------------------------------------------------------------------+
// DCD Event
//--------------------------------------------------------------------+
// Event queue
// OPT_MODE_DEVICE is used by OS NONE for mutex (disable usb isr)
OSAL_QUEUE_DEF(OPT_MODE_DEVICE, _usbd_qdef, CFG...
Thank you for you PR. This is already fixed by #655
I can confirm that everything is good when I switch to the master branch. Thank you very much for your help!!
I can confirm that everything is good when I switch to the master branch. Thank you very much for your help!!
thanks, please test again this repo for your next issue/pr. There has been quite a bit of fixes for rp2040 since it is released in sdk.
In time, i will provide another audio example where the software encoding for two I2S streams i.e. 4 channels is used!
That would be awesome demo, though a bit of extra work may be required for the I2S driver. You could just do it in any native way that you would, I will try to catch-up and do board_i2s() abstraction later on.
In time, i will provide another audio example where the software encoding for two I2S streams i.e. 4 channels is used!
That would be awesome demo, though a bit of extra work may be required for the I2S driver. You could just do it in any native way that you would, I will try to catch-up and do board_i2s() abstraction later on.
Well, it was the idea to do this in an abstract way similar to the current audio example. So there would be two dummy arrays which "simulate" the ...
Well, it was the idea to do this in an abstract way similar to the current audio example. So there would be two dummy arrays which "simulate" the I2S data! The rest is MCU specific and i would leave that to the user!
Yeah, ah right, I was thinking on the actual I2S hardware, i2s encoding is super good already. The hardware come later :)
After successfully testing the ISO in without a single drop. I mostly do the fifo cleanup, rename and refactor. I haven't looked closely at the UAC 2.0 yet (need to pull out its doc), though having audio_device to take care of the fifo wrap-around is a bit of redundant. Since your latest push already move the wraparound handling into the fifo API. Please check to see if we could simply use write_n() and read_n() in the audio_device.c
these API shouldn't be exposed, the wrap-around is handled internally by the fifo write_n() and read_n()
this should already be handled internally by fifo
this should already be handled internally by fifo
Acutally no! These functions are of big importance when reading and writing from/to the FIFO by use DMAs! Somehow, you need the info how much space is available and where to start in order to configure the DMA!!
Furthermore, they allow for a optimized copies as i did for the audio encoding/decoding above!
This is an optimized code which conducts interleaved sample copies! I would strongly advise against doing this with write_n/read_n because it is dramatically inefficient! The way it is done here avoids the unnecessary overhead of updating the read and write pointers for every sample and furthermore, it does not use memcpy for the copy of 1,2,3, or 4 bytes (which by definition are all possible sample sizes in UAC2 type I format).
I understand your desire to put such code into fifo.c but thi...
Ah ok, got it, thanks for detail explanation
got it, you understand audio driver much better. I was thinking the wrap around is added in recent commit and thought that we could refactor this out. Apparently it is not the case :)
Well, the write_n and read_n functions in fifo.c are general purpose functions where you can not tell anything of how much is to be copied etc. They are perfectly fine, but when it comes to optimized stuff they are simply too generall (most of the time). If you want to copy a bunch of samples in one rush from A to B they are perfect, but when you need those fancy interleaved copy stuff they are simply too inefficient...
I don't expect that any other fancy stuff is required ;)
yeah I agree, I don't want to have too fancy function in the write() read() either. Those are very specific to audio and should remain in audio. It is perfect as it is now.
Thank you very much for your PR. I haven't go through all the changes just yet. Though I notice several changes that we could address first with DFU Runtime, still haven't looked at actual DFU mode yet.
- There is couple typo when comparing runtime state with
DFU_REQUEST_DETACH, should beAPP_DETACH - Bitwise result must not be equal-check with 1, it is good as just bitwise alone
- the updated dfu runtime is more complicated than it should be. I think the existing/previous code i...
the runtime attribute should be extracted by parsing the DFU Functional Descriptor in dfu_rtd_open() instead of using callback
Although the specs says stat a timeout and wait for bus reset if does not have will_detach capacities. It does not age well, all the current mcu can reset itself into DFU mode just fine without the need of bus_reset. I think we could just keep the simplified runtime as previously. It should work just fine.
I just realized we should only call tud_dfu_runtime_reboot_to_dfu_cb() in the ACK stage to prevent having usb error message to the host. Since the callback can be implemented with immed reset.
Sounds good. I will remove the RT mode will_detach capability, which should allow this to go back to the original state.
This was purely for a just-in-case. I will remove.
You are correct in that dfu runtime and dfu mode are exclusive. After I split the RT and Mode, I ran into an issue where because the tusb_config.h had:
#define CFG_TUD_DFU_RUNTIME 1
#define CFG_TUD_DFU_MODE 1
Which resulted in both DFU classes being initialized when tud_task() was called.
One possible solution to this would be to have separate builds, one for the app with RT and another for the bootloader with Mode. In the event than an application does not want to have...
Perfect. This particular line is gone now, for the runtime simplification; however, I have made this change in dfu mode.
Resolved in 2e2dc7b
No longer applicable
Resolved in 2e2dc7b
No longer applicable.
Resolved in 2e2dc7b
No longer applicable.
I don't think we would need to ask the app, I wonder why would bptj CFG_TUD_DFU_RUNTIME and CFG_TUD_DFU_MODE are enabled at the same time. And what would be the issue with both dfu mode and dfu rt are initialized. It really doesn't matter, the usb configuration descriptor will dictate which interface e.g itf = 0 for the DFU mode and which is used for DFU runtime should they are both enabled.
Please remove the the RUNTIME_AND_MODE we will treat each one as separated driver like msc vs cdc.
will closed when #593 is merged
Please remove the the RUNTIME_AND_MODE we will treat DFU_RUNTIME and DFU as separated driver like msc vs cdc. There is no conflict when both enabled.
Describe the PR
This pull request adds support for the SAM L22 family of microcontrollers.
Additional context
The SAM L22 is similar enough to the SAM D11/D21 that it's able to use the same implementation in dcd_samd.c, so I just added it to the platform checks in that file. Tested with just about all of the examples on the two boards I'm developing with, a SAM L22 Feather and the [Sensor Watch](https:...
Super! This looks great, I have no problems with board that are in the making. It would be great if you could
Thanks for the feedback! I made those changes, and all of the examples built with no issues.
Describe the PR
remove pico-sdk from submodules list, user should install pico-sdk by themself or set environment PICO_SDK_PATH to correct location.
I am expecting that you would like the nonstandard requests removed from the DFU mode, but I will wait until your review before I make this change.
To adhere to the spec, the finite state machine is verbose, with a fair bit of duplication. I opted for readability rather than compactness, which is why some things, such as get_state and get_status requests are in most states, rather than being checked at the request level.
What happened in this PR
This PR adds support of a new Espressif chip ESP32-S3 into tinyusb project.
The chip peripheral is very similar compare to ESP32-S2 target and support is added as a family driver to allow following extension of the family and group the controllers with similar USB peripheral.
- Update the device controller driver for S family esp32sx:
tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c - Add new esp32s3 based board in
`tinyusb/hw/bsp/esp32s3_addax_1*...
Hi @alisitsyn :) There seem to be changes included that need to be reverted, like submodules being removed. Also to make the changes more clear, is it possible to not include the new example?
Hi @me-no-dev,
There seem to be changes included that need to be reverted, like submodules being removed.
The branch update is in progress (rebase to the latest master) and will be ready after testing soon.
Also to make the changes more clear, is it possible to not include the new example?
My intention is not addition of a new example but update the existing espressif examples to be able to compile them for new added board based on new esp32s3 chip - esp32s3_addax_1.
nice, I didn't know we could do this
not all board has esp32s2 or esp32s3 in their name, we should just use the CHIP_FAMILY. It is good enough.
Thank you very much for your PR. It is great to have the new ESP32-S3 chip added. The changes look good, though I have a few feedback
- Please revert the submodules removal. They are important and needed to build for other platforms :)
- Can you move the esp32s3 into it own family
hw/bsp/esp32s3similar to esps2, it will help to group similar driver such as board_init() and ws2812 driver.
CI also needs to be update to build with esp32s3, though I could help with that.
seem like this line isn't needed, I didn't see it on other board.mk
Thank you very much for you update, I will review it asap :)
The commit I was based on contains the names of the espressif boards started with target prefix. This looked useful for me. This was updated accordingly as it is in latest master.
@hathach,
Thank you for your feedback and advices.
Please revert the submodules removal. They are important and needed to build for other platforms.
It seems that submodules were removed incidentally by script.
Can you move the esp32s3 into it own family hw/bsp/esp32s3 similar to esps2, it will help to group similar driver such as board_init() and ws2812 driver.
I am going to move it into the separated family folder hw/bsp/esp32sx how it was done in the latest master. All...
name like Adafruit funhouse or tinyS2 etc. won't help esp32s2 or s3. It will cause issue with other boards in the future. The $(VENDOR) variable will probably be removed as well. I don't see the use of it in the make. Board name is already uniquely defined. If you think esp32s2_saola_1 does not reflect the espressif as vendor, we could rename it to espressif_saola_1
It seems that submodules were removed incidentally by script.
no problem at all, just make sure you revert it
I am going to move it into the separated family folder
hw/bsp/esp32sxhow it was done in the latest master. All examples will inherit the same standard board functionality and ws2812 driver (exists on esp32s3_addax_1 board also).
I actually think it is better to keep family separated as esp32s2 and esp32s3 (rather than esp32sx), although IDF does an great job of dr...
Ah, I see now. The board name is enough to determine all required information as $(CHIP_TARGET), $(FAMILY) and so on...
I actually think it is better to keep family separated as esp32s2 and esp32s3 (rather than esp32sx), although IDF does an great job of driver abstraction, It is still useful and more obvious to end-user. Yeah, I know there is a bit of code duplication but I am fine with it. Other mcu such as stm32 f2 f3 f4 is actually quite similar, but separated them make it easier to maintain and manage. Hope this makes sense
@me-no-dev , Unfortunately I can not add you to reviewers. Could you take a look to update and give me your comments? Thank you.
Actually the ESP32S (like F4 for STM) is the family and ESP32-S2, ESP32-S3 are actual chips inside this family. I personally think that this is logically correct. It is not an issue to follow your approach from make standpoint. As I understand the structure will be like below. Is this correct?
tinyusb_esp\hw\bsp\ esp32s2\ < --- esp32s2 family boards boards\ adafruit_feather_esp32s2 ...
@me-no-dev , Unfortunately I can not add you to reviewers. Could you take a look to update and give me your comments? Thank you.
Hmm, that is weird, I am sure he is one of repo contributors, in any case, I have added him as reviewer.
This looks good already, please keep it that way. No need to separate s2 and s3. Ignore my previous comment, since I thought s2 and s3 are totally different due to addition of new core and ble :sweat_smile: . This look great already. I will try to have some hand-on testing and will provide more feedback soon.
@hathach Are you still testing this PR or do you have any idea when it is ready for being merged?
@hathach Are you still testing this PR or do you have any idea when it is ready for being merged?
Almost done, I am trying to convert the happy birthday to feed sample. Though I am sure, we will merge this by the end of this week, I promise :sweat_smile: . The audio driver is actually too overwhelmed for me to actually review it thoroughly. So I think it is best to do it as follow-up. Thank you for your patient.
putting final testing, the 4channel mic example seems to have some issue with Linux (and macOS). I hook up it with analyzer, and seems like it failed to response to. There is no need to fix this in this PR, I am more than happy with its current state.

@hathatch,
Normally MCUs within families is only slightly different in ram & rom, pinout (and maybe an extra peripheral). I thought esp32s3 is totally different with extra core. Though you guys at espressif apparently understand it better, if you think their cores and peripheral is similar enough to be in the same group. So yes, please go ahead with esp32sx
You are right about the ESP32-S3. It has enough differences (cores, different peripheral and memory changes) and I can see the re...
Thank you very much @PanRe for spending massive amount of time, thought and effort into this brilliant awesome work. The amount of changes is huge, and the time for wrapping this up is also extensive long. But it is well worthy. Audio class v2.0 is very complicated one, It will definitely takes me lots more months to even come up with some (not) closed to your work. I feel confident that we can now merge this, unless you are still working on something else (saw recent push this morning).
...
You are right about the ESP32-S3. It has enough differences (cores, different peripheral and memory changes) and I can see the reason to divide them into two different family folders. I think it is better to get team opinion about this, cc @me-no-dev.
Actually, it is not a big deal, this bsp family folder thing is just an way to organize boards for testing stock examples in tinyusb repo. It should not make much of differences. Since most end-user people will just IDF platform, arduino or...
Interesting error! First, the Linux driver seems to want only 2 bytes for the sample frequency range descriptor since its length is 2... This is by far to less. But this is covered by the UAC2 specifications:
The actual parameter(s) for the Get request are returned in the data stage of the control transfer. The length
of the parameter block to return is indicated in the wLength field of the request. If the parameter block is
longer than what is indicated in the wLength field, only the ...
The LEDs on Seeduino Xiao are connected to PA17, PA18, and PA19:
https://files.seeedstudio.com/wiki/Seeeduino-XIAO/res/Seeeduino-XIAO-v1.0-SCH-191112.pdf
There is no LED on pin 26.
From schematic, it seems like the led is active low. Could you also change the LED_STATE_ON to 0 as well.
You're right, I'll do that.
I've changed LED_STATE_ON to 0 and amended my last commit. I hope I've done it right, but if not I can raise another PR.
@PanRe I think the issue is not caused by the RANGE request with 2 bytes, usbd will auto truncate the response to match the length of requested by host (never sent more than what host ask for). I think host use 2 bytes to calculate the total length of the response, right afterwards it issue and same request with larger buffer (14 bytes). The software analyzer just doesn't interpreter it correctly (it probably expect more payload). We can safely ignore that
I take a look and capture a coupl...
@PanRe Oh, I see where the issue, I am using stm32f411disco, which board you are using, I think the the size 392 overflow my fifo allocation scheme for the chip.
Open EP 81 with Size = 392
``
We did rework the scheme, maybe we still have it open for some chips. I am fine with this bug. I will create an separated issue for this, it would be good chance to update/enhance the fifo allocation scheme further. I think this PR is solid gold now, and good for merge :)
That is ok, I don't really mind the git log history. The commit message and actual code changes are far more important.
Thank you very much for your PR. Maybe the board revision changes or something. I am glad you spotted it.
I also use an STM32F411 but on a board built by my own and i don't have the disco board unfortunately! And i am pretty sure the USB stack is all fine because i use it in my custom examples and all works fine!
I have the strong feeling that the error is somewhere in main.c, simply because i was not able to test the example of 4 channels as i pushed! I tested it with my own code and i have to apologize to not have tested the example in every detail! I think the error happens because after ...
@PanRe no problem at all, bravos, it works flawlessly with the last push. I will pull out windows and macos to test with

Puh, finally :D i am really glad you like the driver and everthing works!! This driver concludes my duty for the open source community and I am really reliefed this work finally finds its way into the main branch :D :D
Puh, finally :D i am really glad you like the driver and everthing works!! This driver concludes my duty for the open source community and I am really reliefed this work finally finds its way into the main branch :D :D
Tested on windows and macos, all working fine. Thank you very much for your time and effort, who wouldn't like this awesome works of yours :). It one of the biggest and longest PR I have ever worked on. It is specially difficult, since audio require expertise to actually p...
Added flash-bmp and debug-bmp make targets to allow flashing and debugging with the Black Magic Probe
@PanRe that is it, this awesome PR is finally merged. It has been on constant develop-test-review cycles, but I really enjoy working with you. I couldn't thank you enough. Also thanks @HiFiPhile for help with reviewing and testing PR as well. I am looking forward to more PRs and works from you :tada: :tada:
The new driver is out so if you want you may test it! The descriptors are not changed simply because the feature unit would need to be of changing size. Nevertheless, it should be pretty easy to setup your desired descriptors using the examples given ;)
The new driver is out, so you may test your application again. If it does not work, you may look into the dcd driver. There might be an issue with the ISO EPs. You may also test it without RTOS if the problem still remains.
does the /dev/ttyBmpGdb name changes depending on the os (windows/macos/linux) like CDC Serial. If it does we may need to have user to specify to SERIAL= or BMP= similar to other dfu via serial. Of course, we could have with default value that works on most platform with BMP ?=
Yes, it'll be different on different systems. I'll add the BMP variable as you suggested.
Actually, it is not a big deal, this bsp family folder thing is just an way to organize boards for testing stock examples in tinyusb repo. It should not make much of differences. Since most end-user people will just IDF platform, arduino or micropython/circuitpython. It is not really that important and can be easily changes later on if needed.
I agree with your opinion and pushed new commit to update PR according to our discussion. Please take a look when possible.
Yup, later on I w...
According to the blackpill schematics, the LED pin is active low on both F401 and F411 boards. It seems to be the same across all revisions from V1.2 to V3.0.
Great work, everything look good now. I have a couple of minor comments. Since I have do a merge from (master) to fix rp2040 build, I take the chance to update the PR according to the comment as well.
regex is not quite right, * allow some odds such as esp32s2esp32s3 match as well. We could simply have it as "^esp32s[2-3]"
None of the FreeRTOS examples currently work with STM32F4, they all trigger this assert in lib/FreeRTOS-Kernel/portable/GCC/ARM_CM4F/port.c:
764 configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
because the interrupt priority for OTG_FS is too high (that is, the value of ucCurrentPriority is too low).
The (almost) correct call to NVIC_SetPriority was commented out in hw/bsp/stm32f4/family.c.
I have a suspicion that other Cortex-M chips migh...
Thank for the fix, yeah, this is very common issue when using cortex m with freertos. I have this nvic setprio for most of family, but apparently not all of them. This is downside of having too many boards/ports, that sometime I couldn't do all the hand-on testing on actual hardware
Note: The issue is only occurred if default priority (on reset) of USB is too high, somehow my stmf411disco board work just fine without this patch.
Currently, when you build an example, the results are stored under _build/$(BOARD)/, regardless of the value of the DEBUG variable. So, if you have a fully compiled release build and type make DEBUG=1 nothing happens.
I think the debug and release builds should be kept in separate directories, and propose this change to the makefile:
--- a/examples/make.mk
+++ b/examples/make.mk
@@ -3,8 +3,11 @@
# ---------------------------------------
# Build directory
-BUILD := ...
the
board.mkshould not be included here. The reason is that depending on the family, it may need some variables define before the include of board.mk (e.g board linker overwrite family linker etc.. ) and some after. So it is best to remove and let the family.mk to decide.
This approach with includedboard.mkhere was used in previous approach (with esp32sx family) to override the chip target settings. In this update it is not required any more. I removed theboard.mkfrom es...
regex is not quite right,
*allow some odds such asesp32s2esp32s3match as well. We could simply have it as"^esp32s[2-3]"
agree, in some very rare cases it can cause some issues.
I take the chance to update the PR according to the comment as well. I think this PR is ready to merge, unless you still plan to push more update ( let me know if you do ).
I do not have anything to update. Please merge this PR ASAP in spite of rp2040 failures. My esp-idf MR will be merged then. Thank you.
@hathach (Sorry I ended up muting this thread after a while :P)
MSP430 USB hardware doesn't support iso xfers, FWIW. So I think all that commented code referencing ISO xfers can be removed permanently, unless there are other uses for it.
@cr1901 ah thanks, you are right, ISO is not supported by msp430. I will push follow-up PR to address this later on.
Merged now, thank you very much for your PR :+1: :+1:
[hathach/tinyusb] New branch created: fix\-ci
Merged now, thank you very much for your PR ๐ ๐
Thank you very much for your support. ๐
Merged now, thank you very much for your PR +1 +1
Thank you very much for your support.
I am the one to say thank :)
[hathach/tinyusb] New branch created: fix\-ci\-rp2040
It is nice suggestion, though to be honest, I don't feel the need to implement it. Do you have any particular issue with current build. Normally just do a clean would work. DEBUG=1 currently only change the optimization level. So no, I don't we should implement this.
I agree, it's not a big deal, just a bit unusual - many projects do keep debug and release builds separately, so for somebody who just start using TinyUSB it might look counter-intuitive. Anyway, I'm not going to insist, closing the issue now.
Actually, dcd_edpt_xfer_fifo() is not useful for ISO EPs alone, its a general way of getting data directly from a fifo into the usb hardware buffer without the need of a "middle" buffer. True, its primary use is for ISO but it could be of interest for other stuff too. Just wanted to mention that before removing all of it.
ah right, that is correct as well. Thank you for your reminder :)
Now I'm thinking next step : how to add DMA capacity to application layer properly.
Actually tusb_fifo is not exposed to application layer, and @hathach wants keep the fifo internally unless you have changed your idea :)
No matter using support fifo or not, data has to be read using tud_audio_read or tud_audio_read_support_ff, application layer needs to maintains another I2S fifo (or a ping-pong buffer) in order to transfer data to/from peripheral using DMA. (I believe audio is alwa...
It is exactly indended to do it as you sketched it with
USB FIFO -> TUSB_FIFO -> Peripheral (DMA)
Or
USB FIFO -> TUSB_FIFO -> (DMA) -> APP_FIFO-> Peripheral (DMA)
Anything else would be a waste of time and memory. In case of one I2S, you can implement the above e.g. for TX, by init a DMA in circular mode and give the DMA the buffer of the FIFO as a start address. The DMA now may write samples into the FIFO buffer continuously. Next, you choose any suitable interrupt source (e.g. hal...
I implemented such a thing for a USART interface
Me too I've done something similar in #403, at that time DMA hasn't been added to tusb_fifo.
I think we are agreed in the same direction, now we need to decide how to implement it ;)
- Expose the fifo ?
- Add a callback in tusb_fifo to call DMA transfer ?
- Add DMA callback in audio_device ?
- Some dark magic ?
Ah true, i did not thought about that :D. I think we should make it available as general as possible! But how... mh @hathach what do you think? After all, you need to be on board with this ;)
The FIFOs are initiated within audio so there some sort of function would be needed to obtain a handle to the fifo. Then, the easiest way to do something with it would be to expose the fifo.h to the user such that he can do whatever he likes to.
Just wanted to mention that before removing all of it.
@PanRe Alright, well more explicitly, I don't intend to support the FIFO API in msp430 right now :P. I'm sure it's a fine API and fine code, but it's not cognitive overhead I'm willing to take right now.
@cr1901 No worries, it was just a reminder ;).
Currently, if you do a fresh checkout of the tinyusb project and try to build a FreeRTOS example you get an error like this on the first run:
......
LINK _build/seeeduino_xiao/seeeduino_xiao-cdc_msc_freertos.elf
arm-none-eabi-gcc: error: _build/seeeduino_xiao/obj/lib/FreeRTOS-Kernel/list.o: No such file or directory
arm-none-eabi-gcc: error: _build/seeeduino_xiao/obj/lib/FreeRTOS-Kernel/queue.o: No such file or directory
arm-none-eabi-gcc: error: _build/seeeduino_xiao/obj/lib/Free...
hm.. let me fix that build failure first.
yeah, the fetch submodules on-the-fly do not work well with -j option. And gcc may try to split task and I don't know, it doesn't seem to work well with dramatics file changes, similar to make -j clean all won't work. I was thinking of having submodule target, though I think just press up for previous target is much quicker. This is one-time issue, not a deal breaker though. Don't spend too much time on it :)
Thank you for your PR again. There are only several comments, but all is minor (except the timeout change), not really require much changing. Besides that I have 2 major requests
- Could you simplify the
dfu_modeto justdfu(both in API and file name). I think it will be simpler and easier to read. If you think it is too much of a hassle, then I could help with the rename - As part of adding new class, it typically requires to have an example to (a) to test the driver and (b) demonst...
yup, please remove this.
please removed since bus reset is not what class should expose. If needed, it will be done by usbd.
@PanRe @HiFiPhile we can expose the tusb fifo if needed, previously there is no need for that. I have a question though, normally how do you set up a DMA toward I2S peripherals, I don't do audio so any simple virtual code would help.
In anyway we choose to expose the fifo, we will always need to support alternative API as well for MCU that aren't fifo based. Actually more MCUs can perform DMA directly from/to SRAM then I2S peripheral e.g
DMA DMA
USB...
@hathach I am not completely sure what you mean by zero_copy... Since we don't have kernel and user spaces here! Do you mean:
USB HW BUFFER --- (DMA) ---> FIFO --- (DMA) ---> I2S (1)
or
USB HW BUFFER --- (DMA) ---> I2S (2)
or
USB HW BUFFER --- (CPU) ---> FIFO --- (DMA) ---> I2S (3)
?
I am not as experienced as you what all the different MCUs are capable of but i know that the STM32F4 USB hardware buffers do not allow for (2), since the USB hardware buffer can not be written to any mo...
@PanRe zero copy is for other MCU with USB DMA, stm32 is fifo based. Wjich means application and driver simply pass pointer to USBD to schedule transfer. One it is transfer, the app/driver apparently cannot do anything else, application need to employ ping-pong (double) buffering its self. The API is just simply pass the pointer from app to usbd.
IMHO, this would not be useful for audio alone! As @HiFiPhile mentioned, CDC would also benefit from this which is a perfect application for a...
how do you set up a DMA toward I2S peripherals, I don't do audio so any simple virtual code would help.
In TX case it's normally done with the DMA half finished IRQ.
void I2S_TxCpltCallback()
{
// second half finished, filling it up again while first half is playing
FillBuffer (&(buffer [I2S_BUFFER_SIZE >> 1]), I2S_BUFFER_SIZE >> 1);
}
void I2S_TxHalfCpltCallback()
{
// first half finished, filling it up again while second half is playing
FillBuffer (&(buffer ...
1. Could you simplify the `dfu_mode` to just `dfu` (both in API and file name). I think it will be simpler and easier to read. If you think it is too much of a hassle, then I could help with the rename
I can do this. It's funny that you asked for that. When I separated the RT and DFU mode portions I had everything named DFU, and then added MODE so it was consistent with RT. I will change things from dfu_mode to dfu as I go through the rest of your comments.
2. As part of ad...
I can do this. It's funny that you asked for that. When I separated the RT and DFU mode portions I had everything named DFU, and then added MODE so it was consistent with RT. I will change things from dfu_mode to dfu as I go through the rest of your comments.
Actually, I meant to split the runtime from the actual DFU mode, have them as separated drivers. Though words can be misleading, English is not my 1st language after all. That is ok if you don't want to make the rename, I could do i...
[hathach/tinyusb] New branch created: edpt\_ISO\_xfer
[hathach/tinyusb] New branch created: uac2\_fix\_cs\_as\_int\_alt\_set\_0
Describe the PR
Fix bug where the pointer uint8_t * alt_setting was reset to zero when the audio interface was opened by host. Refactor some static functions for faster checks and renamed old depracted and misleading variable names.
I think what you sketched above is a speaker application, what i always have as RX case in mind (since the MCU is receiving...). Is that so?
Ok, so in a first step i would setup some function get_ep_in_ff_handler(), get_ep_out_ff_handler(), get_support_ff_xy_handler(), such that the user can use them as required?! I will setup a new branch for this when i find the time!
During an EMC test the USB bus event DCD_EVENT_BUS_RESET is triggering. However the application code is using the callbacks to determine the line state of as CDC device.
As no callback event occurs the application cannot detect this event. The application must explicitly poll tud_cdc_connected() as a workaround which is not ideal.
I am not sure if there needs to be a new callbac...
I think what you sketched above is a speaker application
Yes, That's for TX case.
Something like
tu_fifo_t* tud_audio_get_rx_fifo(uint8_t itf)
{
return &_audio_itf[itf].rx_ff;
}
Should be enough in first place. Then depending if really needed we can add callback if fifo count is over/under watermark.
I'm also thinking about enhancing tu_fifo_get_linear_r/w_info by returning both (wrapped part) pointers in one call.
- Some DMAs, ex. in SAMDx, SAME70, E...
reopen issue when you filled out all the detail in template
Thank you for the PR, the review is nothing big, just a minor comment on variable naming and a redundant volatile.
audio_fct_idx is too long, audio prefix make it harder to read, how about func_idor fid
volatile should be removed, it is redundant
@hathach Creating 'New issue' from the line of code does not produce a template it would appear... I have got it now via "new issue" button and will apply. cheers.
@hathach I have updated the description, I do not have re-open permissions though
on further investigation the cause of the reset may not be normal as it is possible the 'host' in this case is not aware the Reset had occured. In this situation the Device application needs to disconnect/reconnect to properly re-establish the USB connection. I will continue learning and acquiring understanding of the USB stack.

Sorry for that, left from debugging!
please use the bug template
Ah
tu_fifo_t* tud_audio_get_rx_fifo(uint8_t itf)
{
return &_audio_itf[itf].rx_ff;
}
is already what i ment... with that you can already execute all fifo functions.
Extending tu_fifo_get_linear_r/w_info is not a problem! I was not aware of the linked list option for some DMAs.
@HiFiPhile @PanRe thank for the code, to be honest I don't have much clues on these audio things. It probably depends on you two for the implementation. I will try to make it as portable as possible for other MCUs later on as follow up PRs. That is the main reason, I would suggest to keep all the new changes within audio and stm32.
Yeah, it is true that most DMA capable DCD can schedule multiple transfer at the same time, but that is not portable. I once included the API for such things....
I'll update DMA & tusb_fifo on SAME70 when I have time.
Yeah, it is true that most DMA capable DCD can schedule multiple transfer at the same time, but that is not portable. I once included the API for such things.
You are ahead of me :) I agree we don't need an API for such things, I only want to transfer all the data in once in dcd_edpt_xfer_fifo.
I used the new driver to try the uac2_headset example again, but when I run it on the computer(windows), the USB Audio driver does not work properly, so I canโt find the TinyUSB Device.
In addition, I also tried to use esp32s2 to run audio_test, but it also failed to start the device.
I suspect there is something wrong with the descriptors, but I am not very clear about the USB_Audio protocol.
esp32s2 not yet fully support or tested with ISO transfer and new audio driver. It currently only works best with stm32. This will unfortunately stay this way for awhile until I find more time to fully update all other ports.
The valid firmware check is a bit of a catch all here.
Reset in the dfuMANIFEST-WAIT-RESET state should result in the firmware validity being checked, and the device rebooting if valid, or change to DFU_ERROR. Reset in any other state should result in rebooting to RT, which the app can then decide if that is a hard/soft reboot or reenumeration.
When the start starts the driver is init and the host sends a reset. Starting in APP_DETACH is so the initial RESET doesn't tell the app to reboot/reenumerate back in RT. Depending on what changes in reset, I will update this appropriately.
This callback is named reboot, but could be renamed to prevent confusion.
When this is called the application should reboot hard/soft or reenumerate back to runtime mode. This is a callback since it can occur when dfu-util decides to reset the device or when the firmware is accepted locally by the device.
Yes this is now populated implicitly off of the descriptor
Resolved in 289af58
The application would know the string table that it would have to set with the USB descriptors. Any use of this is nonstandard though, so removed.
Resolved in cc440ad
The application would know the string table that it would have to set with the USB descriptors. Any use of this is nonstandard though, so removed.
Resolved in cc440ad
There is a bug here. I have refactored it to be the correct behavour. request->bRequest should not have been there.
For additional review in 8c80dde
Removed.
Please review b8e5885
Removed.
Please review b8e5885
Removed.
Please review b8e5885
Refactored.
Please review b8e5885
The HID report descriptor is supplied dynamically by tud_hid_descriptor_report_cb(), but the length is not passed back. The report descriptor does not include its own length. The length has to have been set previously in p_hid->report_desc_len. It is set in hidd_open(), since the length must be set in the HID descriptor (not the HID report descriptor).
I am not sure what the utility of this callback is, then. You could substitute an HID Report Descriptor of identical length, but that...
USBTMC: Remove reference reference to windows path of VISA DLL (let pyvisa auto-select it).
If manual selection is needed, user may create .pyvisarc file with as documented by pyvisa.
Closes: #732
I am looking forward to the new audio driver support for esp32s2
[hathach/tinyusb] New branch created: audio\_make\_dma\_ready
Describe the PR
Follow the discussion in #593, this attempts to implement functions to allow for DMA usage in audio functions.
- Add tud_audio_n_get_ep_out_ff(), tud_audio_n_get_ep_in_ff(),
tud_audio_n_get_rx_support_ff(), and tud_audio_n_get_tx_support_ff() - Change get_linear_read/write_info() to return linear and wrapped part
at once - Adjusted affected code in audio_device.c and tested with
audio_4_channel.
Change get_linear_read/write_info() to return linear and wrapped part at once
Oh thanks you are quick :sweat_smile:, I think I would write it this weekend...
You can add a zero check of len_wrap and ptr_wrap before assignment if you like, so they can leave to 0 if not used.
I thought it is faster if we simply avoid this check. Anyway, if len_wrap=0, then ptr_wrap is not valid.
@hathach Could you have a look into this include hassle with pico.h? I don't know why this error comes up...
Seems there is a depenency loop:
osal -> osal_pico -> tusb_fifo -> osal
Ah yes again. This already was once an issue, but @hathach took care of it. I don't know how exactly. I guess this came up again somehow as i needed to include tusb_fifo.h within audio_device.h.
The callback does not include the length on purpose. The length is already decided by hid descriptor (after hid interface) as part of configuration descriptor. I.e by the time tud_descriptor_configuration_cb() is called, you shouldn't change your report descriptor (or it has to be the same length)

I have done some dynamic descriptors for arduino as well, you may want to take a look at
Describe the PR
Add board support for the NXP/Embedded Artists MCU-LINK
Additional context
The MCU-LINK is a cheap board with a LPC55S69JBD64. It provides a level shifting JTAG/SWD and Uart connector and is delivered as CMSIS-DAP adapter. Flash is unprotected.
thank you for the PR, PORT1 HS for lpc55 is still work in progress though. But it looks good for the merge.
@UweBonnes something odds, the PR seems to revert the microchip driver submodule to an older version that causes the ci to failed. Would you mind checking it out.
Describe the PR
This PR implement Port1 Highspeed for lpc55 and lpc546xx/lpc540xx (not tested on actual hardware). There is a few gotcha
- LPC55 highspeed usb can only write/access to USB RAM (0x40100000), attribute((section("m_usb_global")))
- USB RAM does not support unaligned access despite it is cortex M4. Extra macro
TUP_MCU_STRICT_ALIGNis used to overwrite ARCH one, extra effort is also needed to prevent compiler to generate optimized code that result in unaligned acces...
Sorry for the mess I did.
no problem at all.
" make BOARD=mcu_link flash" enumerates successfull. Thanks!
"make BOARD=mcu_link SPEED=full" gets overwritten by hw/bsp/lpc55/family.mk.
" make BOARD=mcu_link flash" enumerates successfull. Thanks!
"make BOARD=mcu_link SPEED=full" gets overwritten by hw/bsp/lpc55/family.mk.
make BOARD=mcu_link PORT=0 to select fullspeed port0, unlike stm32, the lpc55 port1 always has HS PHY so it is always operated at highspeed.
The mcu_link has only port 1 connected.
then just use it with highspeed, why would you want to force it to operate at fullspeed.
So the line "SPEED ?= high" in board.mk is superfluous. Should I do another PR, will you correct or does it not matter?
yeah, it is not needed, no worry, I will may a push for to clean it up.
Should we try to add a blhost flash target option similar to sdpdownload with the RT devices?
Should we try to add a blhost flash target option similar to sdpdownload with the RT devices?
That would be nice but too complicated for this repo. This repo focus mainly on developing/testing usb stack. I would expect most user here has a debugger (cmsisdap/jlink). The sdp host would be a great addition to the tinyuf2 though.
That is why I asked. The MCU-Link board only comes with the SWD controller header loaded. The debug header for the local LPC55 is empty on the back. I'll try to add MCU-Link to TinyUF2, but I probably can't get to it until June.
That is why I asked. The MCU-Link board only comes with the SWD controller header loaded. The debug header for the local LPC55 is empty on the back. I'll try to add MCU-Link to TinyUF2, but I probably can't get to it until June.
There is actually no need to add mcu-link to tinyuf2. Tinyuf2 is meant for maker like you to ease the boards making. Evk is just convenient board that most people will have on their desk, so it got supported. Mcu-link is an nice cheap dev board, people use this ...
Debug adapters need updates more frequently than they should. MBED DAPLink includes a USB mass storage bootloader. There is some value having MCU-Link in TinyUF2, and another board in the same family is not much effort. This progress is encouraging me to get back to the double M33, I'll try to check it out.
I have in mind to implement the blackmagic debug probe firmware for the mcu_link. The BMP has a DFU bootloader. But that will still need some time...
I have in mind to implement the blackmagic debug probe firmware for the mcu_link. The BMP has a DFU bootloader. But that will still need some time...
that would be great :+1: :+1:
Describe the PR
I made the example workable on esp32s2 dev board - saola.
What has been adapted:
- use cmake system
- use esp-idf sdk config
- fix queue handling as the old implementation caused a dead lock.
- ip_addr_t -> ip4_addr_t
- There is still some #if 0 ... #endif and I need some input how to adapt this correctly.
- I switched of fthe webserver. Question: Should I simply port to the already available webserver inside esp-idf?
Additional context
https://github.c...
thanks @PanRe for another great PR. Sorry the in cross include between pico and fifo is getting out of control. I temporarily fixed it by alternating the include order a bit and push the update. Will definitely fix it more properly later on with an overall include revise.
Except from that, I have an a couple of feedback, that I think we could simplify the API for the read/write buffer info. Let me know if that makes sense to you.
nice idea, It could simplify the application usage for these direct buffer access. Though the name is not quite right since it is used for both read/write. Please change it to tu_fifo_buffer_info_t . I think the member name should be changed as well to simply buffer1 and buffer2, the lin/wrap will cause user question for those that aren't familiar with fifo implementation.
typedef struct
{
uint16_t len1 ; ///< length in item size of first buffer
uint16_...
- Do we ever need to use
offset. If not I think we can drop that parameter for a simpler code. - I think we could just drop
nas well, just return len1 and len2 as it is available from buffer. This API would be like query the current buffer state of the fifo. And we could rename function totu_fifo_get_read_info()ortu_fifo_get_read_buffer_info() - As general of thumb, we shouldn't return a struct object (> 4 bytes), it should be passed from application to fill out data. Functi...
Thank you @xmos-jmccarthy for addressing previous feedback, Let me know if you want me to review the updated code, or wait until you push the dfu example.
Describe the PR
- Tested lpc15 working, it can still has issue getting usb started, probably due to some PHY, clock setup stable/delay issue. walkaround is flash it a couple of time until it works. Will look further later on if there is a need.
- Move lpc15 into its own family
Mh, the name buffer_info is a bit too non-speaking don't you mean? linear_wr_info stands for linear write/read info.
Ah i get your idea from below! Ok i rename it!
I would go with tu_fifo_get_read_info().
To 3: Where does this restriction come from? And return false when there is no place to write to or nothing to read from?
I don't know if offset will be needed or when the offset came up the first time... we can remove it completely from the fifo.c, i.e. also from the write and read functions.
To 3: Where does this restriction come from?
Depends on the compiler, sometimes it will make a copy of tu_fifo_buffer_info_t info.
Please review the changes in the latest commit. There are a few unresolved comments that I would like more feedback/consideration on before I make them.
Once the class driver is complete I will add in an in repo example.
Describe the PR
- Group LPC54 to its family
- fix #113
- use official nxp mcux-sdk as submodule
- replace nxp_driver submodule by nxp_lpcopen
- mostly clean up works
I would go with
tu_fifo_get_read_info().
To 3: Where does this restriction come from? And returnfalsewhen there is no place to write to or nothing to read from?
Yeah right, I was mixing thought, I think we can have it to return void if both offset and n are dropped from the argument as 1 and 2
I don't know if offset will be needed or when the offset came up the first time... we can remove it completely from the
fifo.c, i.e. also from the write and read functions.
Yeah, I think offset is is kind of needed for peek_at() initialy, which is trivial with initial implementation. Though If needed, we can just removed the peek_at(offset), and just implement peek() to look at current index only. peek_at random offset is not used by any class driver/application so far. So we don't rea...
Ok i have but one question, the first time i implemented the get_read_info() i did it without struct but with poiners get_read_info(* uint16_t len_1, * uint16_t len_2, ...). However, the CI compilers complained, that len_1 etc. were potentially uninitialized and aborted with an error. To fix this, i came up with the struct at the very end. Now, if i change it to get_read_info(* buffer_info into), then i bet the compiler complains again. This would force the user to always init the str...
hmm, that is weird, did you have any branch in the function that doesn't assign value for the struct memeber. Like invalid short return, it would cause gcc to trigger possible path for uninitialized value.
Me yes... in case there was nothing to read i set len_1 = 0 and left the rest uninitialized to save time.
Nevermind, i change it to the pointer version to the struct if this is your desired design. I guess its not worth spending more time on this ^^
from my point of view, USB DFU will be only used as transport layer as bootloader. There are probably more transport such as cdc/uart/msc/hid as well. What DFU should do is invoked callback when receiving the final packet tud_dfu_device_data_done_check_cb. That would be then up to application/bootloader to decide whether it want to perform checksum and reset to app or failed the DFU. For BUS_RESET, I think we just treat it as data reset for now.
I think we can safely remove the comment now This data is only valid for this call, so the app must use it not or copy it. We have an async API now, dfu invoke callback when receive data. And app call complete API to transition out of BUSY state.
Thanks for the quick push to resolve previous feedbacks. There are only a couple minor this round. I think the API is rather solid and I am happy with the async data_received callback + complete. I am looking forward to see your upcoming example.
We should remove this API as well, just let the bootloader to decide this by itself. Overall, I think BUS_RESET should just reset the dfu state/variables.
it is a typo, should be (uint8_t *) _dfu_state_ctx.transfer_buf without reference operator. This applies for all the usage of transfer_buf
putting all the requests combo with all the states into this make the dfu_state_machine() much more complicated than it should be. We should simplify the dfu_state_machine() by breaking down and handle request that applies to all state such as GETSTATUS and GETSTATE
Yes, so this concern one of my prior comments. I am very open to changing it, but here is some background for how it came to be.
I opted for the current setup where there is a very verbose state machine, but it is explicit in the behaviour to expect on any given request. An earlier iteration had all behaviour inside of dfu_moded_control_xfer_cb. This was incredibly difficult to follow, since each request ended up containing a switch for every single possible state, where most resulted i...
See comment on dfu_state_machine
Thanks for quickly address the feedback. I think we should remove tud_dfu_firmware_valid_check_cb() API, then we could move on with adding example to test our the class driver.
I think we should just remove this tud_dfu_firmware_valid_check_cb()
Side note: we don't really need to check for the MANIFESTATION_TOLERANT here. The reason is that if we could have CPU checking this code, we already able to communicate via USB and therefore imply the MANIFESTATION_TOLERANT = 1 already.
I see, it is your point of view for implementation. Though it is still a bit complicated for my taste. However, you don't have to change it now. We will see how it turn out when adding the example. And I will try to move code around if needed as follow up later on. I do have some renaming in my mind. It is too minor mentioned in reviews.
I tried your stack with samg55 in host mode with keyboard and a 4 port hub.
The usb hub is enumerated not completely correct and an attached keyboard devices stops at GetDeviceDescriptor.

This firmware check determines whether a DFU_GETSTATUS results in dfuMANIFEST, signifying that the firmware is invalid/inprogress, or dfuIDLE if manifesting was completed, from table A.2.7 in the V1.1 spec.
WIth the other changes made, primarily the reset behaviour, the manifestation portions don't really offer anything anymore.
If the class is only responsible for the setup and transfer of firmware, and we want to leave it up to the application for the rest, then the manifestation can be...
I dont know why but the GetPortStatus is not completed:
00> HUB Get Port Status: addr = 1 port = 5
00> Control Setup: A3 00 00 00 05 00 04 00
Last ouput in the log.
Please fill out all the detail in bug template in the first post. It is mandatory. This issue will then be reopened
The stack stops enumeration if a hub with keyboard device is attached to an samg55.
In detail the enumeration is stopped after GetDevice Descriptor of length 8 on the port n. Normally after Reset on the port the host and in this case the samg55 would ask after SetAddress.
Attach the above scenario to an samg55.
Screenshots

Log
00> Port Status Change = 0x08
0...
Set Up
- PC OS
Windows 10 - Board*
Samg55 - Firmware
4 Port Hub with keyboard attached
Describe The Bug
If I attach the Hub and the keyboard the enumeration stops at GetDeviceDescriptor
To Reproduce
tusb_init(); // initialize tinyusb stack
while (true) {
tuh_task();
}
Steps to reproduce the behavior:
- plug in the hub
- plug in the keyboard
- See error stop on GetPortStatus
Screenshots
, HID, WebUSB, CDC, or even BLE/WIFI OTA. Typically each transport will let the bootloader know when...
Thanks for working on the PR, please take your time to add the example (there is no rush). I am sure that will help to finalize the API for application stack interaction. I am looking forward to follow / help with your further commits.
superb ! Thank you for your effort, great PR as usual. the removal of offset make the whole fifo API much cleaner any easier to read/understand. FIFO should be supported offset (random) in the first place. It is my bad to introduce such operation with peek (since I thought it could be handy). Should user need to peek randomly, the new get_read_info() can be used to do it. I have a couple of minor clean up, along with a couple of unit test for new read/write info will push and merge it asap.
comment for n should be removed
Skip beginning of buffer does not seem to fit anymore. It should be Check If the fifo is empty.
Thanks for updating the issue following the template. The SamG55 host driver is unfortunately not supported yet. I am surprised that you could get this far. Are you implementing the host driver locally. Looking at the log, look like the stack could recognize the hub and usb device attach event and able to communicate up to getting 8 bytes of device descriptor. The code that run up to the log is at https://github.com/hathach/tinyusb/blob/master/src/host/usbh.c#L745.
- Did you implement the...
@dhalbert Let me know if you still have question, or API does not make sense to you.
Thanks a lot! :)
I am the one to say thanks :+1:
- No I didnt implement or changed on hcd_frame_number.
- Yes, I do it if I saved my tests.
- Yes, I did test it with different hubs but always the same result.
I come nearer to the problem. In the file usbh.c at line 739 you initiate the reset after the 8 byte descriptor and normally the enumeration comes back with SetAddress after the second reset. This does not happen. What happens is that the stack blocks. I see on the code that you have had problem with the Reset and therefore...

As I mentioned after the call of port Reset from usbh.c at line 739 and following lines.
@Makurisan try to implement the hcd_uframe_number(), it is probably the issue, the reset must stay long enough. Your problem wihtout implement it is
- osal_task_delay() (based on frame number): is not last long enough
- tuh_task() is called, but the port change status is not occurred yet. This may mess up with the follow up call.
hcd_uframe_number() is easy to implement, just return the current micro-frame number. Since SAMG is full-host, you need to multiple norma frame number it wit...
closed, may re-open if needed.
look good, thank you for your PR.
closed in favor of #754
Hm, I think it is long enough. In the usb 1.1 spec it is said that a port reset on a hub is from 10ms to max 20ms.
If I do the following

and

then the stack enumerates completely.
Which board you use normally to check the OHCI code?
@Makurisan oh, I just realize, samg also use OHCI. I normally test with LPC1769 for OHCI, but it has been quite some time. Currently I mostly use lpc18xx EHCI when working on host stack. I really want to improve the host stack, but couldn't find the time to so. I will for sure pull out the samg to test with OHCI next time I work on it.
Yes, it is really interesting that the samg55 use OHCI. I tested it because I want low speed. I don't know if you know but low speed has some specialties and not all MCUs are fully compatible nowadays.
Now I came up width the following solution:


I added an example app for review. I added a separate example, rather than updating the RT example. The reason for this was to avoid requiring that the app reboot/support dynamic configuration (my device does not). dfu-util will give a warning that the device already is in dfu mode, but will still perform the upload or download requested.
I unfortunately do not have my platform ported to run within the TinyUSB repo so I was unable to test, as we discussed earlier. I have tested upload ...
I am glad you figure a way to get it work. Since I will revise the code anyway later on, I pay more attention to this case.
Set Up
- PC OS e.g Ubuntu 20.04 / Windows 10/ macOS 10.15
- Board e.g Feather nRF52840 Express (if custom specify your MCUs)
- Firmware e.g examples/device/cdc_msc
Describe The Bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- See error
Screenshots
If applicable, add screenshots, bus capture to help explain your problem.
Log
If applicable, p...
Thanks for the update, Adding it as separated example is spot on. DFU runtime is application, while DFU is actually bootloader. I am more than welcome anything that could help with the simplification (the stack is too complicated already). I will do an actual test and review as soon as I could
@hathach do you have he sltb009a yet? I now have a luna so I can capture some lower level packets, I want to tackle this bug, because its a bit annoying having to wait 10s every time i plug in a device :stuck_out_tongue:
I still haven't got the board yet, I have some back order from digikey. and They just shipped it out. Though I currently don't have much time to work on this atm, but I will try to help you if needed.
Added new RTOS names to the name string array in print_greeting() in the host example program.
Before adding the new names, the program seemed to hang when a new RTOS was indexed in CFG_TUSB_OS.
Remove reference to the deprecated "num" and "in" members of struct hw_endpoint which still existed in an assert statement that would break DEBUG builds.
Revert a change that was made to rp2040_usb.c that causes slow speed devices to not get configured by the host. It seems likely it is the same as Issue #709.
A low-speed mouse that works with the old TinyUSB source code in the Pico SDK does not work with the latest master from the main repo. This pull request reverts the change that causes this problem. After this line is changed, the mouse works with either version of code.
The reverted change limits the entire data transfer to only 8...
look good thanks for your PR
thanks for the PR, look good
This has conflict with usbd ISO transfer, which can have max packet size of 1023 #657
The reverted change limits the entire data transfer to only 8 bytes for low-speed devices, not just the data packets. So, when the higher level logic requests the 18 byte Device Descriptor, this line of code reduces it to 8 bytes. Lower-level code requests an 8 byte IN packet and signals Last Transfer to the USB controller. Higher-level code may then try to request the remaining 10 bytes, but whatever h...
Fix code in host example where HID keyboard was being stuffed into the HID mouse buffer.
I haven't tested this, but it seems obviously wrong. The HID mouse report buffer was being used for HID keyboard reports.
Describe the PR
#170 and System Control Report Descriptor were in the wrong order, fixed.
[hathach/tinyusb] New branch created: minor\-cleanup
thank for spotting the typo
ep_in_as_intf_num was incorrectly used to access out interface
which is defined for 'in' interface.
Code related to 'out' endpoint should use ep_out_as_intf_num instead.
Describe the PR
Speaker only devices would not build due to incorrect variable usage.
Probably in/out devices would use incorrect variable even if there is no build error.
Additional context
Updated some pico_trace statements that were using deprecated elements of the hw_endpoint structure.
Describe the PR
There is not definition NRF_USBD in NRF5340 headers.
There is however NRF_USBD definition in both cases
NRF52 has:
#define NRF_USBD ((NRF_USBD_Type*) NRF_USBD_BASE)
and NRF5340 has:
#define NRF_USBD NRF_USBD_S
#define NRF_USBD_S ((NRF_USBD_Type*) NRF_USBD_S_BASE)
When common definition is used file can be build for both families.
Additional context
we need to cast the NRF_USBD to uint8_t* first before doing arithmetic operator on it. Though It probably cause gcc to throw warning when casting back to uint32_t* (cast that increases alignment). I think it probably better to have ifdef to unify the base name.
Note: I notice that the base address for secure and non-secure is different as well, one thing we need to keep it in mind later on.
Ah thanks, you really got an eagle eye there. It look correct for me, but let just wait a few days for @PanRe comment
we need to cast the NRF_USBD to
uint8_t*first before doing arithmetic operator on it. Though It probably cause gcc to throw warning when casting back to uint32_t* (cast that increases alignment). I think it probably better to have ifdef to unify the base name.Note: I notice that the base address for secure and non-secure is different as well, one thing we need to keep it in mind later on.
Missing cast fixed.
For now errata 166 does not apply to NRF5340 so whatever you choos...
yeah, just quickly check the 53 errata, not only 166 but all of other errata is not needed for 5340 as well. I think it would be better if we could wrap these errata walkaround with #ifdef NRF52_SERIES. I have push to update the PR. Please let me know if it work on your hardware.
I actually have an PDK 5340 here, but too bad, it doesn't have USB connector populated on the board (!!). I will try to solder one and test it out later on. Though It seems like 5340 revA doesn't have working US...
Erratas that you ifdefed were not applied before and USB worked on 5430 with your changes it will still work provided that code builds.
Yes thanks for the catch! This is a mistake! Thank you for fixing!!
Adds a function so an application can set the mouse or keyboard report format to the standardized Boot format. HID devices that support the Boot format do not always use it by default.
I was thinking about this issue, and it seems like a low-speed device is very unlikely to be doing ISO transfers. So, it may not be pretty, but maybe something like this until a better solution is found:
ifย (TUSB_SPEED_LOW==tuh_device_get_speed(ep->dev_addr))
ย {
ย ย ย ep->transfer_sizeย =ย total_lenย >ย 64ย ?ย 64ย :ย total_len;
ย }
ย else
ย {
ย ย ย ep->transfer_sizeย =ย tu_min16(total_len,ย ep->wMaxPacketSize);
ย }
โ
May 8, 2021, 4:19 AM by @.***:
@hathach> commented on this pull request.
...
I was thinking about this issue, and it seems like a low-speed device is very unlikely to be doing ISO transfers.
I think isochronous transfers are not allowed on low-speed busses:
USB 2.0 spec 5.12.6:
These requirements limit isochronous transfers to full-speed and high-speed
devices only, because low-speed devices do not see SOFs on the bus.
Thank for your PR, but host hid is being reworked, this PR need to wait to see if it still fit after that is done.
Low speed device only support interrupt transfer, however as mentioned above this is out of specs from rp2040 hcd. I would like to look at the datasheet and test it out before making the changes. The reason is doing 64 bytes transfer on 8-bytes buffer can cause buffer overrun and could corrupt other part of memory.
Is your feature request related to a problem? Please describe.
ESP32-S2 has only 5 available endpoint-in FIFOs (including EP0) but 7 available EP IN numbers. In normal CDC virtual com, notification endpoint isn't used, we can save in fifo by enabled but not allocate fifo for it.
Describe the solution you'd like
A sensible/portable way to on/off this feature without too much breaking in the cdc driver.
[hathach/tinyusb] New branch created: host\-hid
Describe the PR
Rework how host hid work including behavior and APIs. Still need more thought for API scenario, any suggestion is welcome.
The signature of tud_hid_report_complete_cb() is
void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode);
However, the boot_mode argument is a bool taken from:
https://github.com/hathach/tinyusb/blob/2d15e1183064a35cc646a46bddf2b82915114cc8/src/class/hid/hid_device.c#L41-L55
boot_mode is passed using this code:
https://github.com/hathach/tinyusb/blob/2d15e1183064a35cc646a46bddf2b82915114cc8/src/class/hid/hid_device.c#L338
So should the signature instead be this?
...
thank Dan, I will push an update for this. May need to rename API as well so that I would make more sense. Have got the time to write a example for boot keyboard just yet.
[hathach/tinyusb] New branch created: fix\-835\-hid\-cleanup
Describe the PR
Fix #835 and more
- add tud_hid_n_interface_protocol()
- rename tud_hid_n_boot_mode() to tud_hid_n_get_protocol()
- rename tud_hid_boot_mode_cb() to tud_hid_set_protocol_cb()
- use HID spec protocol value for get/set_protocol() instead of bool
- add HID_PROTOCOL_BOOT/REPORT to avoid magic number 0,1
- rename HID_PROTOCOL_NONE/KEYBOARD/MOUSE to HID_ITF_PROTOCOL_ to avoid
confusion - rename
itftoinstancein multiple API to have a better meaning.
@dhalbert the value return by API get_protocol and in set_protocol is now follow HID spec, either as HID_PROTOCOL_BOOT/REPORT. Although the boot_mode() is easy for new user, the invert logic cause confusion for people that are familiar with HID

Hello @hathach,
There was the delay with merging of esp-idf tinyusb support on esp32s3 , but it was finally merged. Could you help to reenable CI test support for esp32s3_addax_1 board? Please let me know if you have any questions. Thank you.
Thanks! This makes it consistent internally and externally, and having the names instead of a bool is great.
Describe the PR
Enable ci for esp32s3 boards since IDF now support esp32s3. Follow up to #783
duplicated to https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/85, closed since this will be implemented there.
sorry I have been super busy with lots of work for Arduino TinyUSB Lib for rp2040. I will try to check this out asap (soon)..
Describe the PR
type of bRequest should be uint8_t, not enumerate...
size of a enum is dynamic, it will break the program in some complier(such as xtensa-esp32s2-elf-gcc), error logging like:
Get request not handled, entity = 0, selector = 8, request = 131330
I kindly ask to add usb host support for game controllers and midi. There is a big niche in retrogaming and retrocomputing, so is in midi branch.
There is much more fun to connect such devices, than ordinary mouse or keyboard.
Thanks in advance.
yup, you are spot on, Thank you very much for the PR.
yeah, I agree. I am improving host stack and its driver, will definitely try to get at least PS4 controller since it seem easy enough. Though I am overwhelmed by current amount of work, so it may take a bit of time.
Thanks for quick anwer :)
I use Pi Pico. A lot of fun with it :)
I think PS4 will break through, utilizing others will be much easier then :)
Issuing a MIDI packet read/receive from the main loop disturbs the USB device enumeration/configuration. The host reports the following:
[ 74.733249] usb 1-6: new full-speed USB device number 7 using xhci_hcd
[ ย 74.849035] usb 1-6: Device not responding to setup address.
[ ย 75.051975] usb 1-6: Device not responding to setup address.
[ ย 75.260382] usb 1-6: device not accepting address 7, error -71
Blocking in the device's main loop until the USB connection is established,...
can you provide your setup along with way to reproduce the issue ? Please make sure you use the latest code from master branch as well.
It's running on SAMD51, the code is identical to the master branch. It appears pretty obvious that the current implementation does not protect itself from the race explained above.
@kaysievers can you provide a simplest example along with all the info that could help to reproduce the issue.
Here is a minimal Arduino sketch which produces the failure. Blocking in setup() until USB is ready is not an option, the device needs to work without USB connected too. And it would also fail the same way if the host triggers a reset/reenumeration of the connected device.
#include <Adafruit_TinyUSB.h>
Adafruit_USBD_MIDI usb;
void setup() {
usb.begin();
// Add this to make it work
//delay(500);
}
void loop() {
uint8_t packet[4];
usb.readPacket(packet);
}
...
[hathach/tinyusb] New branch created: hid\-host\-get\-protocol\-when\-enum
Describe the PR
Per HID specs, device is report mode when enumerating, but also mentioned host must not assume anything. So yeah, we need to explicitly send GetProtocol() for boot interface when enumerating.
thanks for your PR, however, after giving a few tries, look like the proposal in https://github.com/raspberrypi/tinyusb/pull/7 does a correct job to fix the root issue with handling 3rd packet issue with transfer. Although that proposal may need some changes, e.g wrapping the walkround with host mode only since those can affect the device stack. However, I think it is indeed the right direction to look at.
closed in prefer of raspberrypi/tinyusb#7 based approach.
probably be fixed by raspberrypi/tinyusb#7 based approach.
[hathach/tinyusb] New branch created: house\-keeping
Describe the PR
- change hid device internal boot_mode to protocol_mode
- only invoke tuh_msc_umount_cb() if needed
Hi,
I would like to know if it would be technically possible with tinyusb to implement a multi-channel sound card that would be useful for beamforming applications.
I was thinking implementing this with RP2040 PIO using up to 16 PDM microphones @ 16kHz. Of course, the maximum sampling rate would depend on the number of channels fitting in a 1ms USB frame.
Adding an example for this kind of application would be awesome.
Any thoughts ?
Best regards,
Dominic
i am trying to run uac2_headset on esp32s2, and UAC device is enumerated successfully (fix by #841).
but It seems cannot receive any data from OUT endpoint.
USB protocol analyzer shows that the OUT-EP endpoint is transmitting data.
any idea?
Describe the PR
fix uac2_headset example
tud_audio_rx_done_cb() is departed, replace with
tud_audio_rx_done_pre_read_cb()
Additional context
test OK on esp32s2(with patch #552 , and run tud_task() in a separate task)
test method:
generate sine wave to uac device with python script:
# refer: https://pythonaudiosynthesisbasics.com/
import numpy as np
import sounddevice as sd
sample_rate = 44100
duration = 120.0
frequency = 440.0
x = np.linspace(0, durati...
@fate100 run uac2_headset on esp32s2 successfully. details: #849
superb! thank you very much. I think the audio got changes and this example does not make use of latest API.
[hathach/tinyusb] New branch created: fix\-warnings
Describe the PR
Fix cast function type for nrf
fix pico osal warning add TODO for overflow in tusb_fifo.c
Is your feature request related to a problem? Please describe.
CMake seems to make thing more manageable and modulo than plain make. Would it be benefit to migrate example building and adding an CMakelist.txt to src for faster integration.
Describe the solution you'd like
make BOARD= should still work as it is, the target will thin wrapper for running cmake with build-BOARD and execute make.
I'd rather use meson than CMake- a bit of a better cross-compilation story IME. But adding toolchains beyond MSVC, Clang, or gcc is more difficult. So it's not unconditionally better.
It's your call :D!
superb! thank you @xmos-jmccarthy very much for the PR. I am really appreciated your effort and patient throughout the whole PR reviews. It has been a bit busy due to the release of rp2040 in recent time. And I couldn't keep up with all the fix and pr. The example work great with both download and upload. Bravo !!! :tada: :tada: . And it is good for the merge now. Later on when integrating into another bootloader, I will do more actual testing on hardware. Should there is any improvement, ...
Thank you for your suggestion, to be honest, I wouldn't want to move a finger to change something that already works :smile: . Though recently both Espressif and RPi release sdk that support tinyusb, and both use CMake as build tool. I have already learned CMake the ugly way (mostly copy & paste from all over the places). Although It works for now, I get to know CMake better and would like to make the tinyusb integration more smoothly on those platform.
A quick google suggest meson is a b...
Well, at least cmake-microchip exists if a PIC port of TinyUSB ever happens...
[hathach/tinyusb] New branch created: more\-housekeeping
sorry I have been busying with other works, will check this out as soon as I could. Thank you for your patient.
Describe the PR
Mostly clean up work
- rename usbd_edpt_iso_xfer to usbd_edpt_xfer_fifo to be consistent with dcd naming
- revise header include, especially conflict between osal and fifo
- update doc
Well, at least cmake-microchip exists if a PIC port of TinyUSB ever happens...
Thank you very much for your pointer, that is great to know. Will check if I ever work on PIC port. Every silicon vendor should provide easy-to-use and easy-to-integrate cmake/make that just link bsp. mcu driver for user. Nah, I don't think they care :sweat_smile: :sweat_smile:
Vendors don't get their SVDs/register maps right. What makes you think they'll get the build system right? :D
true, except rpi, they are doing a great job with docs and build ๐
Is your feature request related to a problem? Please describe.
I was reading #851 and thought that another maintainability change would be to move the examples and the HALs used by them to a separate repo.
Describe the solution you'd like
TinyUSB is commonly submoduled into other repos (CircuitPython, pico-sdk and esp-idf all do this iirc). Splitting the examples and the HAL code for them would make the submodule of the TinyUSB core much smaller. The projects that submodule TinyU...
Hello
I recently used your tinyUSB library through the PICO2040 port of earlephilhower.
It is very pleasant to use with the MIDI protocol.
Today we easily find I2S ADC modules to experiment (it starts with the small I2S microphones)
Consider adding an audio class to your tnyusb lib to be able to do I2S -> ADC -> PICO -> USB AUDIO. ?
I do not realize the work that this requires of you, but I dream of it: D
Anyway, thank you for everything you have already achieved.
phil Artouste
source only repo can be used for this purpose https://github.com/hathach/tinyusb_src , it is update by ci whenever an file within src is updated. Currently multiple repos will require lots more time for maintaining and developing the stack.
audio is already supported (WIP). The arduino wrapper just does not include it yet, if you are willing to do the work, you could use the bare C API to implement it. Audio is not easy, it will take lots of time.
[hathach/tinyusb] New tag created: 0\.10\.0
[hathach/tinyusb] New tag created: 0\.10\.0
[hathach/tinyusb] New branch created: host\-rp2040
UPDATE: I spend a bit more time testing, and make changes to add max(64, mps). It works but the issue with incorrect buf status bit still exists. There is also conflict with submitting multiple transferring as well in host mode. I will need to spend more time with rp2040 hcd. You could follow that branch for update.
https://github.com/hathach/tinyusb/commit/164778a71682559670cc2549565b4d8d5f021fa9
Im using a rp2040 with now behind tinyusb.
Im setting CFG_TUD_HID_BUFSIZE to 8 and recompile.
It works as expected and
lsusb on a linux shows:
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 by...
As discussed in #785 this a draft PR for the port of tinyUSB to the CCRX toolchain and the RX72N device from Renesas.
It is still not complete and only the CDC device class is fully ported. But I guess it is good enough for a discussion.
The following points had to be overcome for porting it to the CCRX toolchain (and the Rx72N used in my project):
- lack of the attribute directive
- overcome the missing weak directive
- overcome of the missing pack directive (used a ...
Please help us to reproduce by providing enough info
- Fill out the requirement information for the hw setup
- Provide your simplest sketch to reproduce in quote
- Provide your serial output in debug mode in quote.
hmm, this is weird, somehow I could "approve and run" ci for this PR. something is tricky with github ci.
Thank you very much for your effort to port the ccrx toolchain. I am not familiar with renesas toolchain, does it has trial with limited functionality ( I don't need all the features), only enough so that I could test this out hand-on before merging and possibly help with tweaking the implementation.
PS: this PR come at pretty good time, my rx65n cloud kit board just come, it will come handy, I still need to get the board ported those. But it is probably similar to existing rx72n.
Hi @hathach,
I can't say anything about the guthub workflow but I'm quite sure that I created a draft merge request.
In the meantime I tried to enable the WiFi module in parallel. While doing so I failed to run two DHCP servers within one example project.
I'm looking for solutions at the moment. May be you have some advice?
Cheers Torsten
Describe the PR
Fix host rp2040 when mounting low speed device (e.g keyboard) with max packet size = 8
- Correct Data Toggle by number of packet: e.g 64 bytes = 8 x 8 bytes --> Data Toggle should not be flipped in the next buffer.
- Improve RP2040-E4 (host buf sel) fix to prevent panic with already available.
Fix #709, also replace https://github.com/raspberrypi/tinyusb/pull/7 as the fix
not sure i you meant to leave all the extra logging stuff in there?
haven't read the spec, but this just smells wrong... toggle the PID IF the transfer is an odd number number of packets total?
Yes there is an evaluation version of the toolchain available. The trial period is the 60 days from the day the first build is executed after installing an evaluation edition. After the trial period exceeded the linkage is limit to 128 KB or smaller.
Here is the link to toolchain webside : CC-RX
I use the version without IDE.
The USB HW implementation of the Rx65N is equal to the one found on the Rx72N.
B...
Yup, the Data Toggle (PID) is toggled every packet. Following is the scheduling 108 bytes with endpoint with max packet size = 8.
- Buffer 0 will start with 64 then 44 as last buf
- 64 is 8 packets starting with DATA1, each packet, DT toggled which mean after 8 packet, it is still DATA1. i.e at the 9th packet (start of 44 bytes, transaction 87 in capture), the DT should remain the same (DATA1).
. Also it makes it difficult to follow in my taste.
- Host and device mode should be able to both enabled, and dynamically run depending on what the softwar...
thanks, that is great to hear, most example is probably less than 128 KB limit. I will give it a try, yeah, the envision seems to be a good kit, though I think it doesn't route the USB to connector and requires additional add-on board from what I could understand.
The Envision Kit HW only offers the host controller functionality (on a USB-A connector). On my Rx72N Envision Kit (which is equal as the Rx65N Envision Kit around the USB HW) I had to modify my board slightly, so it could be used as a function controller (remove the ISL6186USB Port Power Supply Controller and add a resistor).
Unfortunately there is no CCRX toolchain version for Linux (I use a Windows VM on my Linux host). Only a Linux version of their e2studio IDE (this is an eclipse bas...
The issue still doesn't match the template, to reproduce and analyze the issue one need the exact firmware, the log. Also you will need to use the latest version on the master to count as a bug. Ping me when you got it updated.
Your branch does not compile on pico pi branch. It make the pio fail. And the maintainer of pico
does want to update for some reason. However I don't think this bug is releated to that.
Im not sure if the the bug is pico related or generic. You seems to be very uninterested that people
help you to test your code.
The Envision Kit HW only offers the host controller functionality (on a USB-A connector). On my Rx72N Envision Kit (which is equal as the Rx65N Envision Kit around the USB HW) I had to modify my board slightly, so it could be used as a function controller (remove the ISL6186USB Port Power Supply Controller and add a resistor).
Unfortunately there is no CCRX toolchain version for Linux (I use a Windows VM on my Linux host). Only a Linux version of their e2studio IDE (this is an eclips...
Modifications for compatibility with rp2040 (1.2.0 SDK release)
-
Uses tinyusb-0.10.0 branch of pico-sdk for github checks (due to circular dependency - this can undone post SDK release)
-
Rework CMake build for examples
- Examples should be CMake buildable from their own subdirectory; such a build will error out based on
matching .skip.MCU_xxx or a mismatched .only.MCU_ - It should be possible to build from a higher level and use .skip.MCU_ and .only.MCU_ to filter which
...
- Examples should be CMake buildable from their own subdirectory; such a build will error out based on
Define CFG_TUD_VENDOR_CUSTOM to non-zero to use your own callbacks.
my question was whether the code was correct - as far as i can see the packet_count is only dependent on the total transfer size, and therefore does change), or is ep->transfer_size the size per packet?
note i'd like to pull this into the pico-0.10.0 branch anyway which we'll ship SDK1.2.0 with most likely
I don't quite understand your question could you give an example with above total transfer size = 108 bytes above to elaborate. Here is how the transfer size is determined https://github.com/hathach/tinyusb/blob/host-rp2040/src/portable/raspberrypi/rp2040/rp2040_usb.c#L189
note i'd like to pull this into the pico-0.10.0 branch anyway which we'll ship SDK1.2.0 with most likely
no problem, I could release this as 0.10.1 , there is also issue when using pico reading msc thumbdrive as well. I will try to look at when I got time.
I will try to explain as much as I could, as above example total transfer = 108 on endpoint with size = 8, which is broken into 2 sub transfers, both on buffer0 since we don't support double buffer just yet.
- xfer1: transfer size = 64, start with DATA1, packet count = 8
- xfer2: transfer size = 44, also start with DATA1, packet count = 5
if there is ever another xfer on the endpoint, it will start with DATA0 since the packet count is odd. Total transfer is broken in to 2 sub transfer ...
The better approach is not eanble the builtin CFG_TUD_VENDOR at all, and write your own driver from application using usbd_app_driver_get_cb() . Here are 2 examples
- how rpi team add their raspberrypi/pico-sdk#197
- https://github.com/fluffymadness/tinyusb-xinput
Signed-off-by: zhangslice
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.
porting the tinyusb on MM32 MCU
Please do a proper PR with a minimal modification to add support for your MCUs and board only. And please don't close/re-open the PR multiple times.
I guess to be clear, this was the line i was actually complaining about (based on the above).... for the the packets where packet_count is 8 the pid won't toggle, for all the ones packet count is 5 it will.
Superb !! Thank you very much for making this PR. I have recently planned to migrate build system to cmake as well, to have it easier to integrate to pico-sdk and others #851. However, I have just barely read pass the introduction section of "CMake for dummies" :sweat_smile: . This will help enormously to complete the migration later on. Though there are a few notes
project(tinyusb_device_examples)doesn't seem to build, maybe I am doing it in a wrong way.bsp/family.cmakeand `b...
_family_initialize_project with prefix dash seem to be a typo, i couldn't find its implementation anywhere
UPDATE: my bad, this run the function that is defined in the bsp/family.cmake I think we should move and rename this to examples/example.cmake which is similar to the make.mk there.
I have an issue running this CMakelits.txt file, it throws a warning when running cmake.
$ examples/device/build$ cmake .. -DFAMILY=rp2040 -DBOARD=raspberry_pi_pico -DPICO_BUILD_DOCS=0
CMake Warning at /home/hathach/Documents/code/pico/pico-sdk/src/rp2_common/tinyusb/CMakeLists.txt:14 (message):
PICO_TINYUSB_PATH specified but content not present.
when running make with generated project, it has several missing include
/home/hathach/Dropbox/tinyusb/tinyusb/exampl...
tinyusb_device and tinyusb_host are defined in picosdk, it won't allow me to add more driver with more source files without modifying the sdk. IMHO, I think we should have an FLAG to determine whether it will use the tinyusb_device from pico-sdk or including raw source from this repo. Cmakelist.txt examples from pico-sdk can set this flag to compile with the specific version come with sdk.
Note: there is issue when compiling upstream examples with sdk include source, sometime the API ...
I see what you mean there, you suspect that all the 8 packets of first 64 bytes has the same PID right ?
yeah in the SDK build i skip the board name... i assumed you guys wanted it when building from build-family.py, but if not yes we can remove
yes that is part of my plan, i just wasn't 100% sure i wanted to chew that off for the SDK1.2.0 release which I'd like to do asap. I'll see how today looks. It's all a bit of a dance as we support both tinyusb->sdk and sdk->tinyusb and migrate code which clearly belongs in tinyusb from sdk
bsp/family.cmake and bsp/family/rp2040/family.cmake are easily mistaken to each other. We should either rename it to bsp/family_common.cmake or move it to examples/example.cmake. You could give it any other name as well.
Yes i was thinking the same thing... family_common.cmake is probably better, since we are perhaps now using these for things other than examples (i.e. they would be used by the SDK tinyusb cmake build for peoples' own tinyusb based code too)
yeah it builds with warnings in our SDK test
Looking at the trace above the DATA PID in low speed mode needs to be toggled every 8 bytes. It depends on the approach. You can either limit the ep->transfer_size to do several 8 byte transfers. OR you can start a 64 byte transfer in low speed mode and the hardware will flip the PID for you every 8 bytes.
correct
That isn't the case here, the controller is very smart to toggle the PID every packet as shown in the captured which is actual capture to develop this PR. We only need to write the correct initial PID.
You can either limit the ep->transfer_size to do several 8 byte transfers. OR you can start a 64 byte transfer in low speed mode and the hardware will flip the PID for you every 8 bytes.
I tried both way, both works. Actually the code used to limit transfer_size at 8 (max ...
@kilograham do you agree this is resolved if the hardware toggles the pid every 8 bytes in LS mode?
should be fixed now
yeah in the SDK build i skip the board name... i assumed you guys wanted it when building from build-family.py, but if not yes we can remove
Ok, please just remove BOARD from the project name, once this is merged, i will update the gnumake build to match as well.
Yes i was thinking the same thing... family_common.cmake is probably better, since we are perhaps now using these for things other than examples (i.e. they would be used by the SDK tinyusb cmake build for peoples' own tinyu...
no problem, take your time :)
Looks good to me assuming @kilograham agrees the Low Speed DATA PID conversation is resolved.
yeah, i added a comment
i renamed it to family_common.cmake
yup, there is already a comment on the other side :-)
it would be pretty trivial, but we have some stuff to make sure we don't mix the CDC stdio stuff with explicit use of tinyusb, which was the part i wanted tot tackle in the next release.
it should cause the build to failed, I normally have -Werror -Wfatal-errors in other gnu make build. Will figure out how to enable this later on.
thanks, it is resolved
Except for this, I think the PR is ready for merge. In general, pico-sdk and tinyusb should not reply too much on other cmake defines/variable, that would make it easier to change in both sides without affecting others. I could imagine to do quite a bit of work with cmake when migrating all other ports to cmake in the future (just need to fix pending bugs first).
Looks good to me assuming @kilograham agrees the Low Speed DATA PID conversation is resolved.
The PID is toggled by hardware as captured in analyzer. without the fix, it will trigger the incorrect PID USB_INTS_ERROR_DATA_SEQ_BITS error. Thank for the review, I will merge this since I have another PR pending since yesterday.
Describe the PR
Clean up , update some of host HCD API. Still there is plenty of host work.
- remove obsolete hcd_pipe_queue_xfer()/hcd_pipe_xfer()
- update hub driver
- change hcd hcd_uframe_number() --> hcd_frame_number() , micro can be retrieved by optional API on high speed host if needed.
- Update, fix endpoint number and transfer size on OHCI driver.
actually this is only tested with IN transfer, therefore the PID is toggled from the device side. I haven't tested the OUT transfer where host controller is the one responsible for PID toggle. Though there is not many control transfer that has large payload > 64. We can keep this in mind, should it be an issue in the future.
I think the example in this repo should always built with relative path to this code
I've lost track of the context for this ; what relative path of what code?
well i'm still extremely confused by the code... at least a comment is needed... i'm still not clear why you toggle the packet every buffer (and indeed whether that is a 8 byte buffer or not) when the total packet length is odd. what if there are 4 packets?
ah, ok; "the code may be wrong, but fixes the problem at hand" :-) I'm cool with it for now!
Note also, I was not planning to futher disambiguate the builds for this SDK release (which is super imminent), so I'd prefer to merge this as is so that upstream tinyusb is compatible with (and can be merged into the raspberry-pi version by users wanting new stuff) until we fix in a point release. You've already released 0.10.0 anyway
OK, I'll modify it and upload it again
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: "hathach/tinyusb" @.>;
ๅ้ๆถ้ด:ย 2021ๅนด6ๆ1ๆฅ(ๆๆไบ) ไธๅ5:57
@.>;
@.>;"State @.>;
ไธป้ข:ย Re: [hathach/tinyusb] porting the tinyusb on M...
Signed-off-by: zhangslice
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.
well i'm still extremely confused by the code... at least a comment is needed... i'm still not clear why you toggle the packet every buffer (and indeed whether that is a 8 byte buffer or not) when the total packet length is odd. what if there are 4 packets?
I have explained it very clearly as above. PID flipped every packet per USB specs, 4 wont flip it
ah, ok; "the code may be wrong, but fixes the problem at hand" :-) I'm cool with it for now!
The code is spot on and there is no maybe afaik. Please provide example or hands on test case if you are still in doubt.
I think the example in this repo should always built with relative path to this code
I've lost track of the context for this ; what relative path of what code?
I mean path to /src from the example.
Note also, I was not planning to futher disambiguate the builds for this SDK release (which is super imminent), so I'd prefer to merge this as is so that upstream tinyusb is compatible with (and can be merged into the raspberry-pi version by users wanting new stuff) until ...
the hw/mcu should be added as submodule, do mindmotion has github repo for mm322 sdk. else I will help and make one and push update to this PR for you guys.
The following repository can be used, and the SDK will be updated if there are any updates or additions
https://github.com/zhangslice/mm32sdk
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: "hathach/tinyusb" @.>;
ๅ้ๆถ้ด:ย 2021ๅนด6ๆ2ๆฅ(ๆๆไธ) ไธญๅ12:26
@.>;
...
The following repository can be used, and the SDK will be updated if there are any updates or additions https://github.com/zhangslice/mm32sdk
thanks that repo would be useful, I notice that both Keil_core and IAR_Core within the cmsis is the same, without any file differences. you should just have it as CSMSIS/Core https://github.com/zhangslice/mm32sdk/tree/main/mm32f327x/CMSIS
do you want to merge them together ? I am fine If you still want to keep it that way though.
OK, because the syntax of IAR and Keil is different in some places, the reason why they are divided into two folders is that sometimes we will rewrite them, I will delete one of IAR laterย ย
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: "hathach/tinyusb" @.***>;
...
Ok thanks for letting me, in general you should not modify those file since they are from ARM which already taken care of the keil/gcc/iar. But that is up to you.
Well, thank you, that's a good suggestion
------------------ย ๅๅง้ฎไปถย ------------------
ๅไปถไบบ: "hathach/tinyusb" @.>;
ๅ้ๆถ้ด:ย 2021ๅนด6ๆ2ๆฅ(ๆๆไธ) ไธๅ2:24
@.>;
@.@.>;
ไธป้ข:ย Re: [hathach/tinyusb] Add MM32 SDK and USB driver (#869)
...
copyright for the drivers file that is within /src must be MIT license to be compatible with the rest of the project. Please consult your company and put the MIT license here if you are willing to move forward with the PR.
I pushed the update to your master branch on your fork, please pull before making any other commit and update. There are 2 requests for change as follows:
- MIT license is required for
dcd_mm32f327x_otg.c tinyusb_keil.zipmust be removed
ok i have moved the definitions... is it possible to do a 0.10.1 release with this (and including the other rp2040 fix which is already in master) as we can then point the SDK 1.2.0 (planning to release tomorrow) directly at this repo rather than the raspberry pi copy
yeah sure, will do it when ci passed, it seems to fail with rp2040 build. Actually, in the long run, pico sdk and tinyusb should keep its own list I think. Since I wouldn't want to be responsible for building within sdk :sweat_smile: :sweat_smile:
@kilograham seems like you have issue with ci when moved to this. I take this requirement back. Please revert those moving commits if you still want it. I will merge the PR as it is previously (cmake source list in sdk), then make a release to 0.10.1.
I could follow it up to change later on. I need to update the cmake build anyway. you are probably working too much already on sdk 1.2.0. What do you say ?
almost fixed the issues - been busy with other stuff (which were unrelated - more to do with pico-examples maybe not having tinyusb/lwip sub module initialized in which case we shouldn't build lwip examples).
If we keep the lists separate, then there is no guarantee that things are in sync... so it is a bit of 6 of one a dozen of the other. You aren't going to unilaritarily break the SDK build any more than if you were to commit a bad tinyusb other change. We only pick it up a specific com...
@kilograham great, thanks, I am bit worried that you are overworked. Sound good, I will request your review if making changes to cmake, also test it out within pico-sdk as well.
Superb !! thank you very much for your effort. Everything is perfect. Please let me know if want to merge it now (or having any pending works).
Superb !! thank you very much for your effort. Everything is perfect. Please let me know if want to merge it now (or having any pending works).
I think i'm happy too; thanks. I also finally understood your other change (my brain was not in the context of USB enough :-) )
Let me know if it is easy to make a new tinyusb patch release, or whether i should just make one in raspberrypi
Superb !! thank you very much for your effort. Everything is perfect. Please let me know if want to merge it now (or having any pending works).
I think i'm happy too; thanks. I also finally understood your other change (my brain was not in the context of USB enough :-) )
Let me know if it is easy to make a new tinyusb patch release, or whether i should just make one in raspberrypi
I will write some changelog and tag a release as 0.10.1 in a few minutes.
Note: only this file need to be MIT license. Other driver in your sdk does not need to change at all
[hathach/tinyusb] New tag created: 0\.10\.1
0.10.1 is released just now https://github.com/hathach/tinyusb/releases/tag/0.10.1 thank you for the PR again.
still on my radar, just too busy with paid work. Please be patient.
in a particular user case i need to be able to disable CDC hardware flow control at the device end. it is not practical for the host end to simply assert DTR due to the need for backwards compatibility with other software. the feature i'm requesting is a flag to disable hardware flow control that is exposed via the api.
fyi, the hardware i working with is an RP2040.
my proposal is a bit of a hack, i'd welcome better suggestions. in class/cdc/cdc_device.c make the following chan...
Fixes unused variable compiler warnings
thank you, it is my bad, it is temporarily for debug only. Will definitely enable all warning on rpi.
Describe the PR
Add dcd_edpt_xfer_fifo() for RX63N.
Additional context
I have confirmed this patch by using uac2_headset example. On the example, it seems that ISO IN/OUT are succeeded. But, many packets are dropped because performance issue.
audio_test has some issues. audio_test fails enumeration process. In windows 10, I needed to set 44100 into AUDIO_SAMPLE_RATE for enumeration process success. But enumeration is success, I have no observation regarding ISO IN transf...
Now raspberry have updated the SDK so I think im on latest and gratest.
It is very easy to reproduce with hid_composite example.
Apply this little change:
Subject: [PATCH] Buffer overflow demo
This chages the endpoint buffer size from 16 to 8.
This is what usb keyboards when they are hid keyboard.
examples/device/hid_composite/src/tusb_config.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/device/hid_composite/src/tusb_config.h b/examples/device...
Can we built a fido2 u2f key using rp2040 ie. QtPy or rp pico
@hathach @ladyada
hi , this would be the issue you can follow
https://github.com/hathach/tinyusb/issues/91
there is no current ETA or plan